Windows: Report correct usagePage and usage values for HID
authorchunyu.xie <xiechunyu88@126.com>
Wed, 8 Mar 2017 10:45:11 +0000 (18:45 +0800)
committerChris Dickens <christopher.a.dickens@gmail.com>
Fri, 22 Dec 2017 20:52:59 +0000 (12:52 -0800)
Closes #278, Closes #281

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/windows_winusb.c
libusb/os/windows_winusb.h
libusb/version_nano.h

index 4b9afbf..6ec5f70 100644 (file)
@@ -3188,10 +3188,10 @@ static int _hid_get_report_descriptor(struct hid_device_priv *dev, void *data, s
        uint8_t d[MAX_HID_DESCRIPTOR_SIZE];
        size_t i = 0;
 
-       /* usage page (0xFFA0 == vendor defined) */
-       d[i++] = 0x06; d[i++] = 0xA0; d[i++] = 0xFF;
-       /* usage (vendor defined) */
-       d[i++] = 0x09; d[i++] = 0x01;
+       /* usage page */
+       d[i++] = 0x06; d[i++] = dev->usagePage & 0xFF; d[i++] = dev->usagePage >> 8;
+       /* usage */
+       d[i++] = 0x09; d[i++] = (uint8_t)dev->usage;
        /* start collection (application) */
        d[i++] = 0xA1; d[i++] = 0x01;
        /* input report */
@@ -3615,6 +3615,10 @@ static int hid_open(int sub_api, struct libusb_device_handle *dev_handle)
                priv->hid->output_report_size = capabilities.OutputReportByteLength;
                priv->hid->feature_report_size = capabilities.FeatureReportByteLength;
 
+               // Store usage and usagePage values
+               priv->hid->usage = capabilities.Usage;
+               priv->hid->usagePage = capabilities.UsagePage;
+
                // Fetch string descriptors
                priv->hid->string_index[0] = priv->dev_descriptor.iManufacturer;
                if (priv->hid->string_index[0] != 0)
index 483425c..b411ba2 100644 (file)
@@ -193,6 +193,8 @@ struct hid_device_priv {
        uint16_t input_report_size;
        uint16_t output_report_size;
        uint16_t feature_report_size;
+       uint16_t usage;
+       uint16_t usagePage;
        WCHAR string[3][MAX_USB_STRING_LENGTH];
        uint8_t string_index[3]; // man, prod, ser
 };
index 8ee4d42..cdd76bf 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11222
+#define LIBUSB_NANO 11223