The Platform Builder contains source code for a sample driver for USB mouse devices and an HID class driver. The mouse driver uses interrupt-driven transfers. OEMs and IHVs are encouraged to use the source code for these sample drivers as the basis for other USB device drivers. In the sample, the registry keys are configured to load the drivers automatically; plugging in a mouse or keyboard loads these drivers. Since the HID class driver can control mouse devices, there is no reason to include the mouse driver DLL on platforms that support USB keyboard and mouse devices.
After the sample USB mouse driver is loaded and the USBD module calls the driver’s USBDeviceAttach function, the driver calls an initialize function that opens a pipe to the mouse device’s interrupt endpoint. It also starts a worker thread to handle interrupts. This thread enters a loop in which it submits interrupt transfers by calling the IssueInterruptTransfer function. After the transfer completes, the driver retrieves the mouse event data from the function’s lpvBuffer parameter. It then creates an appropriate mouse event to submit to the Windows CE input system.
There are a number of USB device classes that Microsoft does not currently supply sample drivers for. These include the audio device, storage device, communication device, physical interface device, and power device classes.