Questions on HID reports in HID minidriver

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:

  1. 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)

  2. 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

are you saying the PHID_XFER_PACKET reportId field is zero? if so, I think that is an error in the app sending a malformed buffer


From: xxxxx@lists.osr.com [xxxxx@lists.osr.com] on behalf of xxxxx@gmail.com [xxxxx@gmail.com]
Sent: Friday, September 25, 2009 9:54 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Questions on HID reports in HID minidriver

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:

  1. 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)

  2. 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


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Yes, it is the reportId in PHID_XFER_PACKET. According to WDK, it can be 0 legally. If the reportId in the IOCTL request is 0, what should my minidriver do? Return one or both reports?

reportId
“Specifies the report ID of the report contained at reportBuffer. This parameter is optional, and, if not specified, should be set to zero.”

I am pretty sure the optionally allowed zero is to cover the case where you have only one report descriptor/tlc where there is no need to distinguish between 2 different reports

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@gmail.com
Sent: Friday, September 25, 2009 4:14 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Questions on HID reports in HID minidriver

Yes, it is the reportId in PHID_XFER_PACKET. According to WDK, it can be 0 legally. If the reportId in the IOCTL request is 0, what should my minidriver do? Return one or both reports?

reportId
“Specifies the report ID of the report contained at reportBuffer. This parameter is optional, and, if not specified, should be set to zero.”


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Hi Doron,

Do you have answers to my other questions? Thanks.

Henry