Documentation ¶
Overview ¶
HID package to access Human Interface Devices. The platform specific parts of this package are heavily based on Signal 11 - HIDAPI. (https://github.com/signal11/hidapi)
Index ¶
Constants ¶
View Source
const ( SUCCESS usbError = C.LIBUSB_SUCCESS ERROR_IO usbError = C.LIBUSB_ERROR_IO ERROR_INVALID_PARAM usbError = C.LIBUSB_ERROR_INVALID_PARAM ERROR_ACCESS usbError = C.LIBUSB_ERROR_ACCESS ERROR_NO_DEVICE usbError = C.LIBUSB_ERROR_NO_DEVICE ERROR_NOT_FOUND usbError = C.LIBUSB_ERROR_NOT_FOUND ERROR_BUSY usbError = C.LIBUSB_ERROR_BUSY ERROR_TIMEOUT usbError = C.LIBUSB_ERROR_TIMEOUT ERROR_OVERFLOW usbError = C.LIBUSB_ERROR_OVERFLOW ERROR_PIPE usbError = C.LIBUSB_ERROR_PIPE ERROR_INTERRUPTED usbError = C.LIBUSB_ERROR_INTERRUPTED ERROR_NO_MEM usbError = C.LIBUSB_ERROR_NO_MEM ERROR_NOT_SUPPORTED usbError = C.LIBUSB_ERROR_NOT_SUPPORTED ERROR_OTHER usbError = C.LIBUSB_ERROR_OTHER // Request types to use in ControlTransfer(). REQUEST_TYPE_STANDARD = (0x00 << 5) REQUEST_TYPE_CLASS = (0x01 << 5) REQUEST_TYPE_VENDOR = (0x02 << 5) REQUEST_TYPE_RESERVED = (0x03 << 5) // Recipient bits for the reqType of ControlTransfer(). Values 4 - 31 // are reserved. RECIPIENT_DEVICE = 0x00 RECIPIENT_INTERFACE = 0x01 RECIPIENT_ENDPOINT = 0x02 RECIPIENT_OTHER = 0x03 // in: device-to-host ENDPOINT_IN = 0x80 // out: host-to-device ENDPOINT_OUT = 0x00 // Descriptor types as defined by the USB specification. DT_DEVICE = 0x01 DT_CONFIG = 0x02 DT_STRING = 0x03 DT_INTERFACE = 0x04 DT_ENDPOINT = 0x05 DT_HID = 0x21 DT_REPORT = 0x22 DT_PHYSICAL = 0x23 DT_HUB = 0x29 // Standard request types, as defined in table 9-3 of the USB2 specifications REQUEST_GET_STATUS = 0x00 REQUEST_CLEAR_FEATURE = 0x01 // Set or enable a specific feature REQUEST_SET_FEATURE = 0x03 // Set device address for all future accesses REQUEST_SET_ADDRESS = 0x05 // Get the specified descriptor REQUEST_GET_DESCRIPTOR = 0x06 // Used to update existing descriptors or add new descriptors REQUEST_SET_DESCRIPTOR = 0x07 // Get the current device configuration value REQUEST_GET_CONFIGURATION = 0x08 // Set device configuration REQUEST_SET_CONFIGURATION = 0x09 // Return the selected alternate setting for the specified interface. REQUEST_GET_INTERFACE = 0x0A // Select an alternate interface for the specified interface REQUEST_SET_INTERFACE = 0x0B // Set then report an endpoint's synchronization frame REQUEST_SYNCH_FRAME = 0x0C HID_GET_REPORT = 0x01 HID_GET_IDLE = 0x02 HID_GET_PROTOCOL = 0x03 HID_SET_REPORT = 0x09 HID_SET_IDLE = 0x0A HID_SET_PROTOCOL = 0x0B HID_REPORT_TYPE_INPUT = 0x01 HID_REPORT_TYPE_OUTPUT = 0x02 HID_REPORT_TYPE_FEATURE = 0x03 )
Variables ¶
This section is empty.
Functions ¶
func Devices ¶
func Devices() <-chan *DeviceInfo
func FindDevices ¶
func FindDevices(vendor uint16, product uint16) <-chan *DeviceInfo
FindDevices iterates through all devices with a given vendor and product id
func FindDevicesByProduct ¶
func FindDevicesByProduct(product string) <-chan *DeviceInfo
FindDevicesByProduct iterates through all devices with a given vendor and product id
Types ¶
type Device ¶
type Device interface { // Close closes the device and release all keept resources. Close() // Write to the device // (technically a HID report with type 'output' is send to the device) Write([]byte) error // Write to the device // (technically a HID report with type 'feature' is send to the device) WriteFeature([]byte) error // Preform an interrupt transfer to the device WriteInterrupt(byte, []byte) (int, error) }
Device interface for an opened HID USB device
type DeviceInfo ¶
type DeviceInfo struct { // Path contains a Platform-specific device path which is used to identify the device Path string // VendorId contains the USB Vendor ID of the device VendorId uint16 // ProductId contains the USB Product ID of the device ProductId uint16 // VersionNumber contains the Version / Release Number of the device VersionNumber uint16 // Manufacturer of the USB device Manufacturer string // Product contains the product name of the device Product string InputReportLength uint16 OutputReportLength uint16 FeatureReportLength uint16 }
DeviceInfo provides general information about a device
func ByPath ¶
func ByPath(path string) (*DeviceInfo, error)
func (*DeviceInfo) Open ¶
func (di *DeviceInfo) Open() (Device, error)
Click to show internal directories.
Click to hide internal directories.