Hi,
I am new to HID device drivers. I am writing a virtual HID minidriver based on the VHIDMIN sample in WDK. I have two top-level HID collections (see below), a standard one for mouse, and a custom one for data control between app and the driver. I have a few questions on how to return the HID reports on a few HID minidriver IOCTLs below:
-
HID reports
IOCTL_HID_GET_INPUT_REPORT
If the reportID is 0 in Irp->UserBuffer, which report (mouse or data control) should I return? or return both?
IOCTL_HID_READ_REPORT
Since there is no reportID in Irp->UserBuffer, how do I know which report to return? If I am supposed to return both reports, are the data arranged in the following format?
3 bits (for mouse buttons)
5 bits (for padding)
1 byte (for report ID in custom collection)
1 byte (for data in custom collection) -
on a IOCTL_HID_READ_REPORT request, should I just return the current state of the mouse or all the unreported states? If I have to return all the previously unreported states of the mouse, what format should be the returned data?
Below is my report descriptor:
HID_REPORT_DESCRIPTOR DefaultReportDescriptor =
{
// Mouse collection
0x05, 0x01, // Usage Page (Generic Desktop),
0x09, 0x02, // Usage (Mouse),
0xA1, 0x01, // Collection (Application),
0x85, MOUSE_FEATURE_REPORT_ID, // REPORT_ID (2)
0x09, 0x01, // Usage (Pointer),
0xA1, 0x00, // Collection (Physical),
0x05, 0x09, // Usage Page (Buttons),
0x19, 0x01, // Usage Minimum (01),
0x29, 0x03, // Usage Maximun (03),
0x15, 0x00, // Logical Minimum (0),
0x25, 0x01, // Logical Maximum (1),
0x95, 0x03, // Report Count (3),
0x75, 0x01, // Report Size (1),
0x81, 0x02, // Input (Data, Variable, Absolute): 3 button bits
0x95, 0x01, // Report Count (1),
0x75, 0x05, // Report Size (5),
0x81, 0x01, // Input (Constant): 5 bit padding
0x05, 0x01, // Usage Page (Generic Desktop),
0x09, 0x30, // Usage (X),
0x09, 0x31, // Usage (Y),
0x15, 0x81, // Logical Minimum (-127),
0x25, 0x7F, // Logical Maximum (127),
0x75, 0x08, // Report Size (8),
0x95, 0x02, // Report Count (2),
0x81, 0x06, // input (Data, Variable, Relative): 2 position bytes (X & Y)
0xC0, // End Collection,
0xC0, // End Collection,
// Custom collection
0x06,0x00,0xFF, // USAGE_PAGE (Vender Defined Usage Page)
0x09,0x01, // USAGE (Vendor Usage 0x01)
0xA1,0x01, // COLLECTION (Application)
0x85,CONTROL_FEATURE_REPORT_ID, // REPORT_ID (1)
0x09,0x01, // USAGE (Vendor Usage 0x01)
0x15,0x00, // LOGICAL_MINIMUM(0)
0x26,0xff,0x00, // LOGICAL_MAXIMUM(255)
0x75,0x08, // REPORT_SIZE (0x08)
0x95,0x01, // REPORT_COUNT (0x01)
0xB1,0x00, // FEATURE (Data,Ary,Abs)
0x09,0x01, // USAGE (Vendor Usage 0x01)
0x75,0x08, // REPORT_SIZE (0x08)
0x95,INPUT_REPORT_BYTES, // REPORT_COUNT (0x01)
0x81,0x00, // INPUT (Data,Ary,Abs)
0xC0 // END_COLLECTION
};
Thanks a lot.
Henry