The sample USB human interface device (HID) class driver supports input devices such as keyboards, mouse devices, joysticks, gamepads, steering wheels, and so on. In order to present applications with a consistent method of accessing those devices, the HID class driver uses Microsoft® DirectInput® technology. The HID class driver uses USB transfer functions, the interrupt transfer and control transfer functions, to access USB input devices. It uses the stream interface functions to interact with the DirectInput subsystem.
In addition to sending input events from HID class devices to the DirectInput subsystem, the HID class driver also always generates ordinary keyboard and mouse events by using the keybd_event and mouse_event functions. This is not necessary for interacting with the DirectInput subsystem, but it does mean that if an application that is using the mouse or keyboard fails or stops responding, the use of those devices is still available to other applications.
The DirectInput subsystem in Windows CE uses I/O control codes to request various actions from the HID class driver. The HID class driver must support the following eight I/O control codes in its IOControl function:
I/O Control Code |
Description |
IOCTL_HID_ACQUIRE | Notifies the HID class driver that the DirectInput subsystem no longer wants to receive events connected to a handle that was previously obtained through use of the IOCTL_HID_SET_FORMAT control code. |
IOCTL_HID_ATTACH | Notifies the HID class driver that an application needs to use a device. |
IOCTL_HID_ENUM_DEVICES | Return a list of devices that the HID class driver is currently managing. |
IOCTL_HID_ENUM_OBJECTS | Return the number of input sources, such as buttons, on the device. |
IOCTL_HID_GET_INST_DATA | Returns data from the device to the DirectInput subsystem. |
IOCTL_HID_POLL | Requests that the HID class driver poll the device to get the device’s status. |
IOCTL_HID_SET_FORMAT | Sets the format of data that the HID class driver returns for a device to the DirectInput subsystem, and acquires the device for use by an application. |
IOCTL_HID_TRANSFER_EVENT | Registers an event handle that the HID class driver can use to notify the DirectInput subsystem when the device generates data. |
The implementation of the DirectInput subsystem for Windows CE is a subset of the full DirectInput technology defined for desktop versions of Windows. The following differences between these implementations affect the HID class driver: