HID System Devices, DirectInput, and WindowsUpdated: December 4, 2001
On This Page
IntroductionThis article presents recommendations for designing a mouse or keyboard compliant with USB Device Class Definition for Human Interface Devices (HID), Version 1.11 (available at http://www.usb.org/developers/ In this article, when a behavior or requirement is attributed to the Microsoft Windows operating system, the behavior or requirement applies to the HID mapping layer, which transforms HID reports into input events compatible with legacy input devices, thereby enabling HID-compliant mice and keyboards to be used as Windows system devices. In Windows 98/Me, the drivers that perform these mappings are Mouhid.vxd and Kbdhid.vxd, respectively. In Windows 2000/Windows XP, the drivers are Mouhid.sys and Kbdhid.sys, respectively. When a behavior or requirement is attributed to DirectInput, the behavior or requirement applies to the DirectInput portion of the Microsoft DirectX application programming interface (API). DirectInput bypasses the Windows messaging subsystem and communicates directly with device drivers. For HID-compliant devices, DirectInput communicates directly with the HID driver stack. Mouse RequirementsFor Windows and DirectInput to recognize a HID-compliant device as a mouse, it must declare its top-level application collection as belonging to the Generic Desktop Page (0x01) and deploy usage Pointer (0x01) or Mouse (0x02). The device must report its X and Y controls using the Generic Desktop Page usages X (0x30) and Y (0x31), respectively. Windows requires that the X and Y controls both be absolute or both be relative. Both Windows and DirectInput require that, if the device features a wheel, that the wheel control be declared as a relative control using the Generic Desktop Page usage Wheel (0x38). When the wheel is rotated away from the user one unit, the value of the wheel control should increase by one. Windows requires that the mouse buttons are declared using the Button Page (0x09), and that they be consecutively numbered starting with usage Button 1 (0x01). Further, Button 1 is interpreted as the primary button (that is, the left button), Button 2 as the secondary button (that is, the right button), and Button 3 as the tertiary button (that is, the center/middle/wheel button). Keyboard RequirementsFor Windows and DirectInput to recognize a HID-compliant device as a keyboard, it must declare its top-level application collection as belonging to the Generic Desktop Page (0x01) and deploy usage Keyboard (0x06) or Keypad (0x07). The report descriptor for a HID keyboard will typically declare an Input report size of 8 bytes (one modifier byte, one reserved byte, and six key-array bytes), and an Output report size of one byte for the light-emitting diode (LED) status indicators (including padding for unused bits). Windows requires that the LED status indicators are declared using the LED Page (0x08). Supporting References
USB Device Class Definition for Human Interface Devices (HID), Version 1.11
DirectX Software Development Kit (SDK) |
|

