The USB human interface device class ("USB HID class") is a USB device class that describes human interface devices such as computer keyboards, computer mice, game controllers, and alphanumeric display devices. The USB HID class is defined in a number of documents provided by the USB Implementers Forum's Device Working Group. The primary document used to describe the USB HID class is the Device Class Definition for HID 1.11. There are a number of other documents that describe more specific devices in the HID class.
The interface devices are also defined with subclass descriptors. The subclass descriptor is used to declare a device bootable. A bootable device meets a minimum adherence to a basic protocol and will be recognized by a computer BIOS.
Each USB HID interface communicates with the host using either a control pipe or an interrupt pipe. isochronous and bulk pipes are not used in HID class devices. Both IN and OUT control transfers are required for enumeration; only an IN interrupt transfer is required for HID reports. OUT interrupt transfers are optional in HID class devices.
The host periodically polls the device's interrupt IN endpoint during operation. When the device has data to send it forms a report and sends it as a reply to the poll token. Common devices such as keyboards and mice send reports that are well-defined by manufacturers such as Microsoft. When a vendor makes a custom USB HID class device, the reports formed by the device need only match the report description given during enumeration and the driver installed on the host system. In this way it is possible for the USB HID class to be extremely flexible.
The USB HID API is very complicated and can be difficult to understand, even for doing the most basic things. Much of it can be ignored for almost all users, the hard part is knowing what to ignore.
There are two levels of APIs related to USB HID: the USB level and the OS level. At the USB level, there is a protocol for devices to announce their capabilities and the OS to parse the data it gets.
Every OS has a HID API to enable programs to interact with USB HID devices. Many of the same concepts apply when trying to get HID data.
There is also quite a bit of jargon specific to the USB HID API.
As usage is a descriptive tag for a single element of a device. For example: "trigger", "x axis", "slider", or "throttle".
The USB HID API includes a very long list of usages, which are organized into "usage pages". A usage page is a group of related usages. The most commonly used usage page is "generic desktop", which includes an X, Y, and Z axis, "dial", "slider", etc.
A collection is a set of usages grouped into common device types, for example joystick, gamepad, or the more general pointer.
A descriptor is a special report from the device to the host computer that describes that device in terms of usages, usage pages, and collections. The descriptor tells the host computer the data format coming from the device, laid out in byte-deliniated chunks. If the data doesn't fit neatly into bytes, it must be padded with constants to make it fit into bytes.
An on/off control is a usage that only has two states. A single bit is used to send state of an on/off control.
A dynamic value is a usage that changes over a range of values. It can be up to one byte in size (8-bit, 0 to 255 or -127 to 127).
This article is licensed under the GNU Free Documentation License.
It uses material from the
"USB human interface device class".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world