Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows report descriptor reconstructor reengineered pp struct #306

Conversation

JoergAtGithub
Copy link
Contributor

@JoergAtGithub JoergAtGithub commented Jul 18, 2021

This is a variant of #262, but based on the Google Chromium approach using a reengineered struct of the preparsed data returned by HIDP_PREPARSED_DATA.

The output of hidtest can be read by visualization tools like: https://eleccelerator.com/usbdescreqparser/

In ALL cases known to me the generated report descriptor is logical identical to the original, which I read using the free version of USBlyszer. But it's not byte wise identical. The order of the bytes differ, handling of reundant information differs and padding bits can be defined in a different way. And theoretical there might be also a different in report length, but only if somebody adds more constant padding bits at the end of the report than neccessary.

I developed this code with Windows7 64Bit Service Pack1 Windows7, and mcuee tested it on Windows 10 Enterprise x64 (version 20H2).

JoergAtGithub and others added 23 commits April 10, 2021 14:03
- macOS implementation for it;
- stubs for all other platforms;
…ate to the hid_get_report_descriptor API function of PR libusb#303
Added debug output for possible failure cases in button array code
…s_report_descriptor_reconstructor_reengineered_pp_struct
@mcuee
Copy link
Member

mcuee commented Jul 18, 2021

Nice.

This is the output for my devices and the results look better than #262 at the first glance.

click to expand
C:\work\hid\hidapi_test2\windows\x64\Release [windows_report_descriptor_reconstructor_reengineered_pp_struct ≡]> .\hidtest.exe
hidapi test/example tool. Compiled with hidapi version 0.11.0, runtime version 0.11.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col01#7&383a3a17&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 02            Usage  (2)
A1 01            Collection (Application)
09 01            Usage  (1)
A1 00            Collection (Physical)
85 02            Report ID (2)
05 09            Usage Page (9)
19 01            Usage Minimum (1)
29 10            Usage Maximum (16)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 10            Report Count (16)
81 02            Input (0x02)
05 01            Usage Page (1)
09 30            Usage (48)
09 31            Usage (49)
16 01 F8         Logical Minimum (-2047)
26 FF 07         Logical Maximum (2047)
75 0C            Report Size (12)
95 02            Report Count (2)
81 06            Input (0x06)
09 38            Usage (56)
15 81            Logical Minimum (-127)
25 7F            Logical Maximum (127)
75 08            Report Size (8)
95 01            Report Count (1)
81 06            Input (0x06)
05 0C            Usage Page (12)
0A 38 02         Usage (568)
15 81            Logical Minimum (-127)
25 7F            Logical Maximum (127)
75 08            Report Size (8)
95 01            Report Count (1)
81 06            Input (0x06)
C0               End Collection
C0               End Collection
(75 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00,
0x85, 0x02, 0x05, 0x09, 0x19, 0x01, 0x29, 0x10, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x10, 0x81, 0x02, 0x05, 0x01,
0x09, 0x30, 0x09, 0x31, 0x16, 0x01, 0xf8, 0x26, 0xff, 0x07,
0x75, 0x0c, 0x95, 0x02, 0x81, 0x06, 0x09, 0x38, 0x15, 0x81,
0x25, 0x7f, 0x75, 0x08, 0x95, 0x01, 0x81, 0x06, 0x05, 0x0c,
0x0a, 0x38, 0x02, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 0x95,
0x01, 0x81, 0x06, 0xc0, 0xc0,

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col02#7&383a3a17&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xc)
  Report Descriptor:
05 0C            Usage Page (12)
09 01            Usage  (1)
A1 01            Collection (Application)
85 03            Report ID (3)
19 01            Usage Minimum (1)
2A 8C 02         Usage Maximum (652)
15 01            Logical Minimum (1)
26 8C 02         Logical Maximum (652)
75 10            Report Size (16)
95 02            Report Count (2)
81 00            Input (0x00)
C0               End Collection
(25 bytes)
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x19, 0x01,
0x2a, 0x8c, 0x02, 0x15, 0x01, 0x26, 0x8c, 0x02, 0x75, 0x10,
0x95, 0x02, 0x81, 0x00, 0xc0,

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col03#7&383a3a17&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x80 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 80            Usage  (128)
A1 01            Collection (Application)
85 04            Report ID (4)
09 83            Usage (131)
09 81            Usage (129)
09 82            Usage (130)
15 01            Logical Minimum (1)
25 03            Logical Maximum (3)
75 02            Report Size (2)
95 03            Report Count (3)
81 60            Input (0x60)
Report Size (-2)
95 01            Report Count (1)
81 03            Input (0x03) Padding
75 01            Report Size (1)
95 01            Report Count (1)
81 03            Input (0x03) Padding
Report Size (-2)
95 01            Report Count (1)
81 03            Input (0x03) Padding
75 01            Report Size (1)
95 01            Report Count (1)
81 03            Input (0x03) Padding
Report Size (-1)
95 01            Report Count (1)
81 03            Input (0x03) Padding
75 07            Report Size (7)
95 01            Report Count (1)
81 03            Input (0x03) Padding
C0               End Collection
(55 bytes)
0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x04, 0x09, 0x83,
0x09, 0x81, 0x09, 0x82, 0x15, 0x01, 0x25, 0x03, 0x75, 0x02,
0x95, 0x03, 0x81, 0x60, 0x95, 0x01, 0x81, 0x03, 0x75, 0x01,
0x95, 0x01, 0x81, 0x03, 0x95, 0x01, 0x81, 0x03, 0x75, 0x01,
0x95, 0x01, 0x81, 0x03, 0x95, 0x01, 0x81, 0x03, 0x75, 0x07,
0x95, 0x01, 0x81, 0x03, 0xc0,

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col04#7&383a3a17&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xff00)
  Report Descriptor:
06 00 FF         Usage Page (65280)
09 01            Usage  (1)
A1 01            Collection (Application)
85 10            Report ID (16)
09 01            Usage (1)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 06            Report Count (6)
81 00            Input (0x00)
09 01            Usage (1)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 06            Report Count (6)
91 00            Output (0x00)
C0               End Collection
(36 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x10, 0x09,
0x01, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x06,
0x81, 0x00, 0x09, 0x01, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
0x08, 0x95, 0x06, 0x91, 0x00, 0xc0,

Device Found
  type: 0488 121f
  path: \\?\hid#dell091a&col01#5&99b72d3&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0x2 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 02            Usage  (2)
A1 01            Collection (Application)
09 01            Usage  (1)
A1 00            Collection (Physical)
85 01            Report ID (1)
05 09            Usage Page (9)
19 01            Usage Minimum (1)
29 03            Usage Maximum (3)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 03            Report Count (3)
81 02            Input (0x02)
75 05            Report Size (5)
95 01            Report Count (1)
81 03            Input (0x03) Padding
05 01            Usage Page (1)
09 30            Usage (48)
09 31            Usage (49)
09 38            Usage (56)
15 81            Logical Minimum (-127)
25 7F            Logical Maximum (127)
75 08            Report Size (8)
95 03            Report Count (3)
81 06            Input (0x06)
05 0C            Usage Page (12)
0A 38 02         Usage (568)
15 81            Logical Minimum (-127)
25 7F            Logical Maximum (127)
75 08            Report Size (8)
95 01            Report Count (1)
81 06            Input (0x06)
C0               End Collection
C0               End Collection
(69 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00,
0x85, 0x01, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x03, 0x81, 0x02, 0x75, 0x05,
0x95, 0x01, 0x81, 0x03, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31,
0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 0x95, 0x03,
0x81, 0x06, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x15, 0x81, 0x25,
0x7f, 0x75, 0x08, 0x95, 0x01, 0x81, 0x06, 0xc0, 0xc0,

Device Found
  type: 8087 0a1e
  path: \\?\hid#intc816&col01#3&36a7043c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      200
  Interface:    -1
  Usage (page): 0xc (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 0C            Usage  (12)
A1 01            Collection (Application)
85 08            Report ID (8)
09 C6            Usage (198)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 01            Report Count (1)
81 06            Input (0x06)
75 07            Report Size (7)
95 01            Report Count (1)
81 03            Input (0x03) Padding
C0               End Collection
(27 bytes)
0x05, 0x01, 0x09, 0x0c, 0xa1, 0x01, 0x85, 0x08, 0x09, 0xc6,
0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x01, 0x81, 0x06,
0x75, 0x07, 0x95, 0x01, 0x81, 0x03, 0xc0,

Device Found
  type: 044e 1212
  path: \\?\hid#vid_044e&pid_1212&col01&col02#7&290aacae&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x6 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 06            Usage  (6)
A1 01            Collection (Application)
85 07            Report ID (7)
05 07            Usage Page (7)
19 E0            Usage Minimum (224)
29 E7            Usage Maximum (231)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 08            Report Count (8)
81 02            Input (0x02)
75 08            Report Size (8)
95 01            Report Count (1)
81 03            Input (0x03) Padding
19 00            Usage Minimum (0)
29 75            Usage Maximum (117)
15 00            Logical Minimum (0)
25 FF            Logical Maximum (-1)
75 08            Report Size (8)
95 06            Report Count (6)
81 00            Input (0x00)
C0               End Collection
(45 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x85, 0x07, 0x05, 0x07,
0x19, 0xe0, 0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01,
0x95, 0x08, 0x81, 0x02, 0x75, 0x08, 0x95, 0x01, 0x81, 0x03,
0x19, 0x00, 0x29, 0x75, 0x15, 0x00, 0x25, 0xff, 0x75, 0x08,
0x95, 0x06, 0x81, 0x00, 0xc0,

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col05#7&383a3a17&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0xff00)
  Report Descriptor:
06 00 FF         Usage Page (65280)
09 02            Usage  (2)
A1 01            Collection (Application)
85 11            Report ID (17)
09 02            Usage (2)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 13            Report Count (19)
81 00            Input (0x00)
09 02            Usage (2)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 13            Report Count (19)
91 00            Output (0x00)
C0               End Collection
(36 bytes)
0x06, 0x00, 0xff, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x11, 0x09,
0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x13,
0x81, 0x00, 0x09, 0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
0x08, 0x95, 0x13, 0x91, 0x00, 0xc0,

Device Found
  type: 8087 0a1e
  path: \\?\hid#intc816&col02#3&36a7043c&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      200
  Interface:    -1
  Usage (page): 0xd (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 0D            Usage  (13)
A1 01            Collection (Application)
09 0D            Usage  (13)
A1 02            Collection (Logical)
85 1C            Report ID (28)
09 81            Usage (129)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 01            Report Count (1)
81 02            Input (0x02)
09 CB            Usage (203)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 01            Report Count (1)
B1 02            Feature (0x02)
75 07            Report Size (7)
95 01            Report Count (1)
81 03            Input (0x03) Padding
75 07            Report Size (7)
95 01            Report Count (1)
B1 03            Feature (0x03) Padding
C0               End Collection
C0               End Collection
(50 bytes)
0x05, 0x01, 0x09, 0x0d, 0xa1, 0x01, 0x09, 0x0d, 0xa1, 0x02,
0x85, 0x1c, 0x09, 0x81, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01,
0x95, 0x01, 0x81, 0x02, 0x09, 0xcb, 0x15, 0x00, 0x25, 0x01,
0x75, 0x01, 0x95, 0x01, 0xb1, 0x02, 0x75, 0x07, 0x95, 0x01,
0x81, 0x03, 0x75, 0x07, 0x95, 0x01, 0xb1, 0x03, 0xc0, 0xc0,

Device Found
  type: 044e 1212
  path: \\?\hid#vid_044e&pid_1212&col01&col01#7&290aacae&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x2 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 02            Usage  (2)
A1 01            Collection (Application)
09 01            Usage  (1)
A1 00            Collection (Physical)
85 06            Report ID (6)
05 09            Usage Page (9)
19 01            Usage Minimum (1)
29 03            Usage Maximum (3)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 03            Report Count (3)
81 02            Input (0x02)
75 05            Report Size (5)
95 01            Report Count (1)
81 03            Input (0x03) Padding
05 01            Usage Page (1)
09 30            Usage (48)
09 31            Usage (49)
16 00 FE         Logical Minimum (-512)
26 00 02         Logical Maximum (512)
75 10            Report Size (16)
95 02            Report Count (2)
81 06            Input (0x06)
C0               End Collection
C0               End Collection
(54 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00,
0x85, 0x06, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x03, 0x81, 0x02, 0x75, 0x05,
0x95, 0x01, 0x81, 0x03, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31,
0x16, 0x00, 0xfe, 0x26, 0x00, 0x02, 0x75, 0x10, 0x95, 0x02,
0x81, 0x06, 0xc0, 0xc0,

Device Found
  type: 0488 121f
  path: \\?\hid#dell091a&col02#5&99b72d3&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0x5 (0xd)
  Report Descriptor:
05 0D            Usage Page (13)
09 05            Usage  (5)
A1 01            Collection (Application)
09 22            Usage  (34)
A1 02            Collection (Logical)
85 08            Report ID (8)
09 47            Usage (71)
09 42            Usage (66)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 02            Report Count (2)
81 02            Input (0x02)
09 51            Usage (81)
15 00            Logical Minimum (0)
25 05            Logical Maximum (5)
75 03            Report Size (3)
95 01            Report Count (1)
81 02            Input (0x02)
75 03            Report Size (3)
95 01            Report Count (1)
81 03            Input (0x03) Padding
05 01            Usage Page (1)
09 30            Usage (48)
15 00            Logical Minimum (0)
26 AF 04         Logical Maximum (1199)
35 00            Physical Minimum (0)
46 E8 03         Physical Maximum (1000)
55 0E            Unit Exponent (14)
65 11            Unit (17)
75 10            Report Size (16)
95 01            Report Count (1)
81 02            Input (0x02)
09 31            Usage (49)
15 00            Logical Minimum (0)
26 7B 02         Logical Maximum (635)
35 00            Physical Minimum (0)
46 12 02         Physical Maximum (530)
75 10            Report Size (16)
95 01            Report Count (1)
81 02            Input (0x02)
C0               End Collection
05 0D            Usage Page (13)
09 56            Usage (86)
15 00            Logical Minimum (0)
27 FF FF 00 00   Logical Maximum (65535)
35 00            Physical Minimum (0)
47 FF FF 00 00   Physical Maximum (65535)
55 0C            Unit Exponent (12)
66 01 10         Unit (4097)
75 10            Report Size (16)
95 01            Report Count (1)
81 02            Input (0x02)
09 54            Usage (84)
15 00            Logical Minimum (0)
25 05            Logical Maximum (5)
75 08            Report Size (8)
95 01            Report Count (1)
81 02            Input (0x02)
05 09            Usage Page (9)
09 02            Usage (2)
09 03            Usage (3)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 02            Report Count (2)
45 00            Physical Maximum (0)
55 00            Unit Exponent (0)
65 00            Unit (0)
81 02            Input (0x02)
85 09            Report ID (9)
05 0D            Usage Page (13)
09 55            Usage (85)
15 00            Logical Minimum (0)
25 05            Logical Maximum (5)
35 00            Physical Minimum (0)
47 FF FF 00 00   Physical Maximum (65535)
55 0C            Unit Exponent (12)
66 01 10         Unit (4097)
75 08            Report Size (8)
95 01            Report Count (1)
B1 02            Feature (0x02)
85 0A            Report ID (10)
06 00 FF         Usage Page (65280)
09 C5            Usage (197)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
96 00 01         Report Count (256)
B1 02            Feature (0x02)
75 06            Report Size (6)
95 01            Report Count (1)
81 03            Input (0x03) Padding
C0               End Collection
(204 bytes)
0x05, 0x0d, 0x09, 0x05, 0xa1, 0x01, 0x09, 0x22, 0xa1, 0x02,
0x85, 0x08, 0x09, 0x47, 0x09, 0x42, 0x15, 0x00, 0x25, 0x01,
0x75, 0x01, 0x95, 0x02, 0x81, 0x02, 0x09, 0x51, 0x15, 0x00,
0x25, 0x05, 0x75, 0x03, 0x95, 0x01, 0x81, 0x02, 0x75, 0x03,
0x95, 0x01, 0x81, 0x03, 0x05, 0x01, 0x09, 0x30, 0x15, 0x00,
0x26, 0xaf, 0x04, 0x35, 0x00, 0x46, 0xe8, 0x03, 0x55, 0x0e,
0x65, 0x11, 0x75, 0x10, 0x95, 0x01, 0x81, 0x02, 0x09, 0x31,
0x15, 0x00, 0x26, 0x7b, 0x02, 0x35, 0x00, 0x46, 0x12, 0x02,
0x75, 0x10, 0x95, 0x01, 0x81, 0x02, 0xc0, 0x05, 0x0d, 0x09,
0x56, 0x15, 0x00, 0x27, 0xff, 0xff, 0x00, 0x00, 0x35, 0x00,
0x47, 0xff, 0xff, 0x00, 0x00, 0x55, 0x0c, 0x66, 0x01, 0x10,
0x75, 0x10, 0x95, 0x01, 0x81, 0x02, 0x09, 0x54, 0x15, 0x00,
0x25, 0x05, 0x75, 0x08, 0x95, 0x01, 0x81, 0x02, 0x05, 0x09,
0x09, 0x02, 0x09, 0x03, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01,
0x95, 0x02, 0x45, 0x00, 0x55, 0x00, 0x65, 0x00, 0x81, 0x02,
0x85, 0x09, 0x05, 0x0d, 0x09, 0x55, 0x15, 0x00, 0x25, 0x05,
0x35, 0x00, 0x47, 0xff, 0xff, 0x00, 0x00, 0x55, 0x0c, 0x66,
0x01, 0x10, 0x75, 0x08, 0x95, 0x01, 0xb1, 0x02, 0x85, 0x0a,
0x06, 0x00, 0xff, 0x09, 0xc5, 0x15, 0x00, 0x26, 0xff, 0x00,
0x75, 0x08, 0x96, 0x00, 0x01, 0xb1, 0x02, 0x75, 0x06, 0x95,
0x01, 0x81, 0x03, 0xc0,

Device Found
  type: 04d8 0033
  path: \\?\hid#vid_04d8&pid_0033#e&bd5b18b&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: pk2new
  Manufacturer: Microchip Technology Inc.
  Product:      PICkit 2 Microcontroller Programmer
  Release:      2
  Interface:    -1
  Usage (page): 0x1 (0xff00)
  Report Descriptor:
06 00 FF         Usage Page (65280)
09 01            Usage  (1)
A1 01            Collection (Application)
19 01            Usage Minimum (1)
29 40            Usage Maximum (64)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 40            Report Count (64)
81 02            Input (0x02)
19 01            Usage Minimum (1)
29 40            Usage Maximum (64)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 40            Report Count (64)
91 02            Output (0x02)
C0               End Collection
(38 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x19, 0x01, 0x29,
0x40, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x40,
0x81, 0x02, 0x19, 0x01, 0x29, 0x40, 0x15, 0x00, 0x26, 0xff,
0x00, 0x75, 0x08, 0x95, 0x40, 0x91, 0x02, 0xc0,

Device Found
  type: 045e 0000
  path: \\?\hid#converteddevice&col02#5&379854aa&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xc)
  Report Descriptor:
05 0C            Usage Page (12)
09 01            Usage  (1)
A1 01            Collection (Application)
85 02            Report ID (2)
09 E9            Usage (233)
09 EA            Usage (234)
0A 21 02         Usage (545)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 03            Report Count (3)
81 02            Input (0x02)
75 05            Report Size (5)
95 01            Report Count (1)
81 03            Input (0x03) Padding
C0               End Collection
(32 bytes)
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x02, 0x09, 0xe9,
0x09, 0xea, 0x0a, 0x21, 0x02, 0x15, 0x00, 0x25, 0x01, 0x75,
0x01, 0x95, 0x03, 0x81, 0x02, 0x75, 0x05, 0x95, 0x01, 0x81,
0x03, 0xc0,

Device Found
  type: 045e 0000
  path: \\?\hid#converteddevice&col03#5&379854aa&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x80 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 80            Usage  (128)
A1 01            Collection (Application)
85 03            Report ID (3)
09 81            Usage (129)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 01            Report Count (1)
81 02            Input (0x02)
75 07            Report Size (7)
95 01            Report Count (1)
81 03            Input (0x03) Padding
C0               End Collection
(27 bytes)
0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x03, 0x09, 0x81,
0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x01, 0x81, 0x02,
0x75, 0x07, 0x95, 0x01, 0x81, 0x03, 0xc0,

Device Found
  type: 0488 121f
  path: \\?\hid#dell091a&col03#5&99b72d3&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0x1 (0xff01)
  Report Descriptor:
06 01 FF         Usage Page (65281)
09 01            Usage  (1)
A1 01            Collection (Application)
85 03            Report ID (3)
09 01            Usage (1)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
35 00            Physical Minimum (0)
47 FF FF 00 00   Physical Maximum (65535)
55 0C            Unit Exponent (12)
66 01 10         Unit (4097)
75 08            Report Size (8)
95 1B            Report Count (27)
81 02            Input (0x02)
85 04            Report ID (4)
09 02            Usage (2)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 1B            Report Count (27)
81 02            Input (0x02)
85 06            Report ID (6)
09 04            Usage (4)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 07            Report Count (7)
81 02            Input (0x02)
85 05            Report ID (5)
09 03            Usage (3)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 07            Report Count (7)
B1 02            Feature (0x02)
C0               End Collection
(80 bytes)
0x06, 0x01, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x09,
0x01, 0x15, 0x00, 0x26, 0xff, 0x00, 0x35, 0x00, 0x47, 0xff,
0xff, 0x00, 0x00, 0x55, 0x0c, 0x66, 0x01, 0x10, 0x75, 0x08,
0x95, 0x1b, 0x81, 0x02, 0x85, 0x04, 0x09, 0x02, 0x15, 0x00,
0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x1b, 0x81, 0x02, 0x85,
0x06, 0x09, 0x04, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08,
0x95, 0x07, 0x81, 0x02, 0x85, 0x05, 0x09, 0x03, 0x15, 0x00,
0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x07, 0xb1, 0x02, 0xc0,

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_00#7&1c54b96&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    0
  Usage (page): 0x6 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 06            Usage  (6)
A1 01            Collection (Application)
05 07            Usage Page (7)
19 E0            Usage Minimum (224)
29 E7            Usage Maximum (231)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 08            Report Count (8)
81 02            Input (0x02)
75 08            Report Size (8)
95 01            Report Count (1)
81 03            Input (0x03) Padding
19 00            Usage Minimum (0)
29 A4            Usage Maximum (164)
15 00            Logical Minimum (0)
26 A4 00         Logical Maximum (164)
75 08            Report Size (8)
95 06            Report Count (6)
81 00            Input (0x00)
05 08            Usage Page (8)
19 01            Usage Minimum (1)
29 05            Usage Maximum (5)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 05            Report Count (5)
91 02            Output (0x02)
75 03            Report Size (3)
95 01            Report Count (1)
91 03            Output (0x03) Padding
C0               End Collection
(66 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0,
0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08,
0x81, 0x02, 0x75, 0x08, 0x95, 0x01, 0x81, 0x03, 0x19, 0x00,
0x29, 0xa4, 0x15, 0x00, 0x26, 0xa4, 0x00, 0x75, 0x08, 0x95,
0x06, 0x81, 0x00, 0x05, 0x08, 0x19, 0x01, 0x29, 0x05, 0x15,
0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x05, 0x91, 0x02, 0x75,
0x03, 0x95, 0x01, 0x91, 0x03, 0xc0,

Device Found
  type: 0488 121f
  path: \\?\hid#dell091a&col04#5&99b72d3&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0x1 (0xff02)
  Report Descriptor:
06 02 FF         Usage Page (65282)
09 01            Usage  (1)
A1 01            Collection (Application)
85 07            Report ID (7)
09 02            Usage (2)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
35 00            Physical Minimum (0)
47 FF FF 00 00   Physical Maximum (65535)
55 0C            Unit Exponent (12)
66 01 10         Unit (4097)
75 08            Report Size (8)
95 86            Report Count (134)
B1 02            Feature (0x02)
C0               End Collection
(35 bytes)
0x06, 0x02, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x07, 0x09,
0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x35, 0x00, 0x47, 0xff,
0xff, 0x00, 0x00, 0x55, 0x0c, 0x66, 0x01, 0x10, 0x75, 0x08,
0x95, 0x86, 0xb1, 0x02, 0xc0,

Device Found
  type: 0488 121f
  path: \\?\hid#dell091a&col05#5&99b72d3&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0xe (0xd)
  Report Descriptor:
05 0D            Usage Page (13)
09 0E            Usage  (14)
A1 01            Collection (Application)
09 22            Usage  (34)
A1 02            Collection (Logical)
85 0B            Report ID (11)
09 52            Usage (82)
15 00            Logical Minimum (0)
25 0A            Logical Maximum (10)
35 00            Physical Minimum (0)
47 FF FF 00 00   Physical Maximum (65535)
55 0C            Unit Exponent (12)
66 01 10         Unit (4097)
75 08            Report Size (8)
95 01            Report Count (1)
B1 02            Feature (0x02)
C0               End Collection
09 22            Usage  (34)
A1 00            Collection (Physical)
85 0C            Report ID (12)
09 57            Usage (87)
09 58            Usage (88)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 02            Report Count (2)
45 00            Physical Maximum (0)
55 00            Unit Exponent (0)
65 00            Unit (0)
B1 02            Feature (0x02)
75 06            Report Size (6)
95 01            Report Count (1)
B1 03            Feature (0x03) Padding
C0               End Collection
C0               End Collection
(71 bytes)
0x05, 0x0d, 0x09, 0x0e, 0xa1, 0x01, 0x09, 0x22, 0xa1, 0x02,
0x85, 0x0b, 0x09, 0x52, 0x15, 0x00, 0x25, 0x0a, 0x35, 0x00,
0x47, 0xff, 0xff, 0x00, 0x00, 0x55, 0x0c, 0x66, 0x01, 0x10,
0x75, 0x08, 0x95, 0x01, 0xb1, 0x02, 0xc0, 0x09, 0x22, 0xa1,
0x00, 0x85, 0x0c, 0x09, 0x57, 0x09, 0x58, 0x15, 0x00, 0x25,
0x01, 0x75, 0x01, 0x95, 0x02, 0x45, 0x00, 0x55, 0x00, 0x65,
0x00, 0xb1, 0x02, 0x75, 0x06, 0x95, 0x01, 0xb1, 0x03, 0xc0,
0xc0,

Device Found
  type: 045e 0000
  path: \\?\hid#converteddevice&col01#5&379854aa&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x6 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 06            Usage  (6)
A1 01            Collection (Application)
85 01            Report ID (1)
05 07            Usage Page (7)
09 69            Usage (105)
09 6A            Usage (106)
09 6B            Usage (107)
09 6C            Usage (108)
09 E3            Usage (227)
09 4C            Usage (76)
09 E2            Usage (226)
09 E0            Usage (224)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 08            Report Count (8)
81 02            Input (0x02)
C0               End Collection
(37 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x85, 0x01, 0x05, 0x07,
0x09, 0x69, 0x09, 0x6a, 0x09, 0x6b, 0x09, 0x6c, 0x09, 0xe3,
0x09, 0x4c, 0x09, 0xe2, 0x09, 0xe0, 0x15, 0x00, 0x25, 0x01,
0x75, 0x01, 0x95, 0x08, 0x81, 0x02, 0xc0,

Device Found
  type: 046d b010
  path: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002046d_pid&b010&col01#8&1cf1c1b9&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x2 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 02            Usage  (2)
A1 01            Collection (Application)
09 01            Usage  (1)
A1 00            Collection (Physical)
85 02            Report ID (2)
05 09            Usage Page (9)
19 01            Usage Minimum (1)
29 08            Usage Maximum (8)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 08            Report Count (8)
81 02            Input (0x02)
05 01            Usage Page (1)
09 30            Usage (48)
09 31            Usage (49)
16 01 F8         Logical Minimum (-2047)
26 FF 07         Logical Maximum (2047)
75 0C            Report Size (12)
95 02            Report Count (2)
81 06            Input (0x06)
09 38            Usage (56)
15 81            Logical Minimum (-127)
25 7F            Logical Maximum (127)
75 08            Report Size (8)
95 01            Report Count (1)
81 06            Input (0x06)
05 0C            Usage Page (12)
0A 38 02         Usage (568)
15 81            Logical Minimum (-127)
25 7F            Logical Maximum (127)
75 08            Report Size (8)
95 01            Report Count (1)
81 06            Input (0x06)
C0               End Collection
C0               End Collection
(75 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00,
0x85, 0x02, 0x05, 0x09, 0x19, 0x01, 0x29, 0x08, 0x15, 0x00,
0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81, 0x02, 0x05, 0x01,
0x09, 0x30, 0x09, 0x31, 0x16, 0x01, 0xf8, 0x26, 0xff, 0x07,
0x75, 0x0c, 0x95, 0x02, 0x81, 0x06, 0x09, 0x38, 0x15, 0x81,
0x25, 0x7f, 0x75, 0x08, 0x95, 0x01, 0x81, 0x06, 0x05, 0x0c,
0x0a, 0x38, 0x02, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 0x95,
0x01, 0x81, 0x06, 0xc0, 0xc0,

Device Found
  type: 046d b010
  path: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002046d_pid&b010&col02#8&1cf1c1b9&1&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xc)
  Report Descriptor:
05 0C            Usage Page (12)
09 01            Usage  (1)
A1 01            Collection (Application)
85 03            Report ID (3)
05 06            Usage Page (6)
09 20            Usage (32)
15 00            Logical Minimum (0)
25 64            Logical Maximum (100)
75 08            Report Size (8)
95 01            Report Count (1)
81 02            Input (0x02)
C0               End Collection
(23 bytes)
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x03, 0x05, 0x06,
0x09, 0x20, 0x15, 0x00, 0x25, 0x64, 0x75, 0x08, 0x95, 0x01,
0x81, 0x02, 0xc0,

Device Found
  type: 046d b010
  path: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002046d_pid&b010&col03#8&1cf1c1b9&1&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xff00)
  Report Descriptor:
06 00 FF         Usage Page (65280)
09 01            Usage  (1)
A1 01            Collection (Application)
85 10            Report ID (16)
09 01            Usage (1)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 06            Report Count (6)
81 00            Input (0x00)
09 01            Usage (1)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 06            Report Count (6)
91 00            Output (0x00)
C0               End Collection
(36 bytes)
0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x10, 0x09,
0x01, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x06,
0x81, 0x00, 0x09, 0x01, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
0x08, 0x95, 0x06, 0x91, 0x00, 0xc0,

Device Found
  type: 046d b010
  path: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002046d_pid&b010&col04#8&1cf1c1b9&1&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x2 (0xff00)
  Report Descriptor:
06 00 FF         Usage Page (65280)
09 02            Usage  (2)
A1 01            Collection (Application)
85 11            Report ID (17)
09 02            Usage (2)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 13            Report Count (19)
81 00            Input (0x00)
09 02            Usage (2)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 13            Report Count (19)
91 00            Output (0x00)
C0               End Collection
(36 bytes)
0x06, 0x00, 0xff, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x11, 0x09,
0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x13,
0x81, 0x00, 0x09, 0x02, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
0x08, 0x95, 0x13, 0x91, 0x00, 0xc0,

Device Found
  type: 046d b010
  path: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002046d_pid&b010&col05#8&1cf1c1b9&1&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x6 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 06            Usage  (6)
A1 01            Collection (Application)
85 04            Report ID (4)
05 07            Usage Page (7)
19 E0            Usage Minimum (224)
29 E7            Usage Maximum (231)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 08            Report Count (8)
81 02            Input (0x02)
75 08            Report Size (8)
95 01            Report Count (1)
81 03            Input (0x03) Padding
19 00            Usage Minimum (0)
29 FF            Usage Maximum (255)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 06            Report Count (6)
81 00            Input (0x00)
05 08            Usage Page (8)
19 01            Usage Minimum (1)
29 05            Usage Maximum (5)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 05            Report Count (5)
91 02            Output (0x02)
75 03            Report Size (3)
95 01            Report Count (1)
91 03            Output (0x03) Padding
C0               End Collection
(68 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x85, 0x04, 0x05, 0x07,
0x19, 0xe0, 0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01,
0x95, 0x08, 0x81, 0x02, 0x75, 0x08, 0x95, 0x01, 0x81, 0x03,
0x19, 0x00, 0x29, 0xff, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
0x08, 0x95, 0x06, 0x81, 0x00, 0x05, 0x08, 0x19, 0x01, 0x29,
0x05, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x05, 0x91,
0x02, 0x75, 0x03, 0x95, 0x01, 0x91, 0x03, 0xc0,

Device Found
  type: 046d b010
  path: \\?\hid#{00001124-0000-1000-8000-00805f9b34fb}_vid&0002046d_pid&b010&col06#8&1cf1c1b9&1&0005#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 34885dab0c12
  Manufacturer: Logitech
  Product:      Logitech Bluetooth Wireless Mouse
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xc)
  Report Descriptor:
05 0C            Usage Page (12)
09 01            Usage  (1)
A1 01            Collection (Application)
85 05            Report ID (5)
0A 25 02         Usage (549)
0A 24 02         Usage (548)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 02            Report Count (2)
81 02            Input (0x02)
75 06            Report Size (6)
95 01            Report Count (1)
81 03            Input (0x03) Padding
C0               End Collection
(31 bytes)
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x05, 0x0a, 0x25,
0x02, 0x0a, 0x24, 0x02, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01,
0x95, 0x02, 0x81, 0x02, 0x75, 0x06, 0x95, 0x01, 0x81, 0x03,
0xc0,

unable to open device

@mcuee mcuee added the Windows Related to Windows backend label Jul 18, 2021
@mcuee
Copy link
Member

mcuee commented Jul 18, 2021

Result for Microsoft USB Nano Receiver.

click to expand
Device Found
  type: 045e 0773
  path: \\?\hid#vid_045e&pid_0773&mi_00#7&2f5f6ab5&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer:
  Product:
  Release:      674
  Interface:    0
  Usage (page): 0x6 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 06            Usage  (6)
A1 01            Collection (Application)
05 07            Usage Page (7)
19 E0            Usage Minimum (224)
29 E7            Usage Maximum (231)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 08            Report Count (8)
81 02            Input (0x02)
75 08            Report Size (8)
95 01            Report Count (1)
81 03            Input (0x03) Padding
19 00            Usage Minimum (0)
29 91            Usage Maximum (145)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 06            Report Count (6)
81 00            Input (0x00)
05 08            Usage Page (8)
19 01            Usage Minimum (1)
29 03            Usage Maximum (3)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 03            Report Count (3)
91 02            Output (0x02)
75 05            Report Size (5)
95 01            Report Count (1)
91 03            Output (0x03) Padding
C0               End Collection
(66 bytes)
0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0,
0x29, 0xe7, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08,
0x81, 0x02, 0x75, 0x08, 0x95, 0x01, 0x81, 0x03, 0x19, 0x00,
0x29, 0x91, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95,
0x06, 0x81, 0x00, 0x05, 0x08, 0x19, 0x01, 0x29, 0x03, 0x15,
0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x03, 0x91, 0x02, 0x75,
0x05, 0x95, 0x01, 0x91, 0x03, 0xc0,

Device Found
  type: 045e 0773
  path: \\?\hid#vid_045e&pid_0773&mi_02&col01#7&3b731c32&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      674
  Interface:    2
  Usage (page): 0x1 (0xc)
  Report Descriptor:
05 0C            Usage Page (12)
09 01            Usage  (1)
A1 01            Collection (Application)
85 21            Report ID (33)
06 00 FF         Usage Page (65280)
1A 10 FA         Usage Minimum (64016)
2A 1F FA         Usage Maximum (64031)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 10            Report Count (16)
81 02            Input (0x02)
85 27            Report ID (39)
0A 0A FA         Usage (64010)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 1F            Report Count (31)
81 02            Input (0x02)
85 14            Report ID (20)
0A 01 FE         Usage (65025)
15 00            Logical Minimum (0)
25 03            Logical Maximum (3)
75 02            Report Size (2)
95 01            Report Count (1)
81 02            Input (0x02)
85 04            Report ID (4)
0A 01 FE         Usage (65025)
15 00            Logical Minimum (0)
25 03            Logical Maximum (3)
75 02            Report Size (2)
95 01            Report Count (1)
81 02            Input (0x02)
85 20            Report ID (32)
0A 0A FA         Usage (64010)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 12            Report Count (18)
B1 02            Feature (0x02)
85 28            Report ID (40)
1A 10 FA         Usage Minimum (64016)
2A 1F FA         Usage Maximum (64031)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 10            Report Count (16)
B1 02            Feature (0x02)
85 22            Report ID (34)
0A 0A FA         Usage (64010)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 1A            Report Count (26)
B1 02            Feature (0x02)
85 23            Report ID (35)
0A 0A FA         Usage (64010)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 1A            Report Count (26)
B1 02            Feature (0x02)
85 24            Report ID (36)
0A 0A FA         Usage (64010)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 1F            Report Count (31)
B1 02            Feature (0x02)
85 25            Report ID (37)
0A 0A FA         Usage (64010)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 1F            Report Count (31)
B1 02            Feature (0x02)
85 26            Report ID (38)
0A 0A FA         Usage (64010)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 1F            Report Count (31)
B1 02            Feature (0x02)
75 06            Report Size (6)
95 01            Report Count (1)
81 03            Input (0x03) Padding
75 06            Report Size (6)
95 01            Report Count (1)
81 03            Input (0x03) Padding
C0               End Collection
(200 bytes)
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x21, 0x06, 0x00,
0xff, 0x1a, 0x10, 0xfa, 0x2a, 0x1f, 0xfa, 0x15, 0x00, 0x25,
0x01, 0x75, 0x01, 0x95, 0x10, 0x81, 0x02, 0x85, 0x27, 0x0a,
0x0a, 0xfa, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95,
0x1f, 0x81, 0x02, 0x85, 0x14, 0x0a, 0x01, 0xfe, 0x15, 0x00,
0x25, 0x03, 0x75, 0x02, 0x95, 0x01, 0x81, 0x02, 0x85, 0x04,
0x0a, 0x01, 0xfe, 0x15, 0x00, 0x25, 0x03, 0x75, 0x02, 0x95,
0x01, 0x81, 0x02, 0x85, 0x20, 0x0a, 0x0a, 0xfa, 0x15, 0x00,
0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x12, 0xb1, 0x02, 0x85,
0x28, 0x1a, 0x10, 0xfa, 0x2a, 0x1f, 0xfa, 0x15, 0x00, 0x25,
0x01, 0x75, 0x01, 0x95, 0x10, 0xb1, 0x02, 0x85, 0x22, 0x0a,
0x0a, 0xfa, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95,
0x1a, 0xb1, 0x02, 0x85, 0x23, 0x0a, 0x0a, 0xfa, 0x15, 0x00,
0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x1a, 0xb1, 0x02, 0x85,
0x24, 0x0a, 0x0a, 0xfa, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75,
0x08, 0x95, 0x1f, 0xb1, 0x02, 0x85, 0x25, 0x0a, 0x0a, 0xfa,
0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x1f, 0xb1,
0x02, 0x85, 0x26, 0x0a, 0x0a, 0xfa, 0x15, 0x00, 0x26, 0xff,
0x00, 0x75, 0x08, 0x95, 0x1f, 0xb1, 0x02, 0x75, 0x06, 0x95,
0x01, 0x81, 0x03, 0x75, 0x06, 0x95, 0x01, 0x81, 0x03, 0xc0,

Device Found
  type: 045e 0773
  path: \\?\hid#vid_045e&pid_0773&mi_02&col02#7&3b731c32&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      674
  Interface:    2
  Usage (page): 0x1 (0xc)
  Report Descriptor:
05 0C            Usage Page (12)
09 01            Usage  (1)
A1 01            Collection (Application)
85 07            Report ID (7)
19 00            Usage Minimum (0)
2A FF 03         Usage Maximum (1023)
15 00            Logical Minimum (0)
26 FF 03         Logical Maximum (1023)
75 10            Report Size (16)
95 01            Report Count (1)
81 00            Input (0x00)
05 07            Usage Page (7)
19 00            Usage Minimum (0)
29 FF            Usage Maximum (255)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 01            Report Count (1)
81 00            Input (0x00)
75 08            Report Size (8)
95 01            Report Count (1)
81 03            Input (0x03) Padding
06 00 FF         Usage Page (65280)
0A 03 FE         Usage (65027)
0A 04 FE         Usage (65028)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 02            Report Count (2)
81 02            Input (0x02)
0A 05 FF         Usage (65285)
15 00            Logical Minimum (0)
25 1F            Logical Maximum (31)
75 05            Report Size (5)
95 01            Report Count (1)
81 02            Input (0x02)
75 01            Report Size (1)
95 01            Report Count (1)
81 03            Input (0x03) Padding
1A 01 FD         Usage Minimum (64769)
2A FF FD         Usage Maximum (65023)
15 01            Logical Minimum (1)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 01            Report Count (1)
81 00            Input (0x00)
0A 02 FF         Usage (65282)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 01            Report Count (1)
81 02            Input (0x02)
C0               End Collection
(117 bytes)
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x85, 0x07, 0x19, 0x00,
0x2a, 0xff, 0x03, 0x15, 0x00, 0x26, 0xff, 0x03, 0x75, 0x10,
0x95, 0x01, 0x81, 0x00, 0x05, 0x07, 0x19, 0x00, 0x29, 0xff,
0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x01, 0x81,
0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x03, 0x06, 0x00, 0xff,
0x0a, 0x03, 0xfe, 0x0a, 0x04, 0xfe, 0x15, 0x00, 0x25, 0x01,
0x75, 0x01, 0x95, 0x02, 0x81, 0x02, 0x0a, 0x05, 0xff, 0x15,
0x00, 0x25, 0x1f, 0x75, 0x05, 0x95, 0x01, 0x81, 0x02, 0x75,
0x01, 0x95, 0x01, 0x81, 0x03, 0x1a, 0x01, 0xfd, 0x2a, 0xff,
0xfd, 0x15, 0x01, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x01,
0x81, 0x00, 0x0a, 0x02, 0xff, 0x15, 0x00, 0x26, 0xff, 0x00,
0x75, 0x08, 0x95, 0x01, 0x81, 0x02, 0xc0,

Device Found
  type: 045e 0773
  path: \\?\hid#vid_045e&pid_0773&mi_02&col03#7&3b731c32&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      674
  Interface:    2
  Usage (page): 0x88 (0xffbc)
  Report Descriptor:
06 BC FF         Usage Page (65468)
09 88            Usage  (136)
A1 01            Collection (Application)
85 08            Report ID (8)
19 01            Usage Minimum (1)
29 FF            Usage Maximum (255)
15 01            Logical Minimum (1)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 01            Report Count (1)
81 00            Input (0x00)
C0               End Collection
(25 bytes)
0x06, 0xbc, 0xff, 0x09, 0x88, 0xa1, 0x01, 0x85, 0x08, 0x19,
0x01, 0x29, 0xff, 0x15, 0x01, 0x26, 0xff, 0x00, 0x75, 0x08,
0x95, 0x01, 0x81, 0x00, 0xc0,

Device Found
  type: 045e 0773
  path: \\?\hid#vid_045e&pid_0773&mi_02&col04#7&3b731c32&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      674
  Interface:    2
  Usage (page): 0x80 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 80            Usage  (128)
A1 01            Collection (Application)
85 03            Report ID (3)
19 00            Usage Minimum (0)
29 FF            Usage Maximum (255)
15 00            Logical Minimum (0)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 01            Report Count (1)
81 00            Input (0x00)
C0               End Collection
(24 bytes)
0x05, 0x01, 0x09, 0x80, 0xa1, 0x01, 0x85, 0x03, 0x19, 0x00,
0x29, 0xff, 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95,
0x01, 0x81, 0x00, 0xc0,

Device Found
  type: 045e 0773
  path: \\?\hid#vid_045e&pid_0773&mi_01&col01#7&179bde70&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      674
  Interface:    1
  Usage (page): 0x2 (0x1)
  Report Descriptor:
05 01            Usage Page (1)
09 02            Usage  (2)
A1 01            Collection (Application)
09 02            Usage  (2)
A1 02            Collection (Logical)
09 01            Usage  (1)
A1 00            Collection (Physical)
85 1A            Report ID (26)
05 09            Usage Page (9)
19 01            Usage Minimum (1)
29 05            Usage Maximum (5)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 05            Report Count (5)
81 02            Input (0x02)
75 03            Report Size (3)
95 01            Report Count (1)
81 03            Input (0x03) Padding
05 01            Usage Page (1)
09 30            Usage (48)
09 31            Usage (49)
16 01 80         Logical Minimum (-32767)
26 FF 7F         Logical Maximum (32767)
75 10            Report Size (16)
95 02            Report Count (2)
81 06            Input (0x06)
09 00            Usage  (0)
A1 02            Collection (Logical)
09 38            Usage (56)
16 01 80         Logical Minimum (-32767)
26 FF 7F         Logical Maximum (32767)
75 10            Report Size (16)
95 01            Report Count (1)
81 06            Input (0x06)
85 12            Report ID (18)
09 48            Usage (72)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
35 01            Physical Minimum (1)
45 04            Physical Maximum (4)
75 02            Report Size (2)
95 01            Report Count (1)
B1 02            Feature (0x02)
C0               End Collection
09 00            Usage  (0)
A1 02            Collection (Logical)
85 1A            Report ID (26)
05 0C            Usage Page (12)
0A 38 02         Usage (568)
16 01 80         Logical Minimum (-32767)
26 FF 7F         Logical Maximum (32767)
35 00            Physical Minimum (0)
45 00            Physical Maximum (0)
75 10            Report Size (16)
95 01            Report Count (1)
81 06            Input (0x06)
85 12            Report ID (18)
05 01            Usage Page (1)
09 48            Usage (72)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
35 01            Physical Minimum (1)
45 04            Physical Maximum (4)
75 02            Report Size (2)
95 01            Report Count (1)
B1 02            Feature (0x02)
75 04            Report Size (4)
95 01            Report Count (1)
B1 03            Feature (0x03) Padding
C0               End Collection
C0               End Collection
C0               End Collection
C0               End Collection
(150 bytes)
0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x02, 0xa1, 0x02,
0x09, 0x01, 0xa1, 0x00, 0x85, 0x1a, 0x05, 0x09, 0x19, 0x01,
0x29, 0x05, 0x15, 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x05,
0x81, 0x02, 0x75, 0x03, 0x95, 0x01, 0x81, 0x03, 0x05, 0x01,
0x09, 0x30, 0x09, 0x31, 0x16, 0x01, 0x80, 0x26, 0xff, 0x7f,
0x75, 0x10, 0x95, 0x02, 0x81, 0x06, 0x09, 0x00, 0xa1, 0x02,
0x09, 0x38, 0x16, 0x01, 0x80, 0x26, 0xff, 0x7f, 0x75, 0x10,
0x95, 0x01, 0x81, 0x06, 0x85, 0x12, 0x09, 0x48, 0x15, 0x00,
0x25, 0x01, 0x35, 0x01, 0x45, 0x04, 0x75, 0x02, 0x95, 0x01,
0xb1, 0x02, 0xc0, 0x09, 0x00, 0xa1, 0x02, 0x85, 0x1a, 0x05,
0x0c, 0x0a, 0x38, 0x02, 0x16, 0x01, 0x80, 0x26, 0xff, 0x7f,
0x35, 0x00, 0x45, 0x00, 0x75, 0x10, 0x95, 0x01, 0x81, 0x06,
0x85, 0x12, 0x05, 0x01, 0x09, 0x48, 0x15, 0x00, 0x25, 0x01,
0x35, 0x01, 0x45, 0x04, 0x75, 0x02, 0x95, 0x01, 0xb1, 0x02,
0x75, 0x04, 0x95, 0x01, 0xb1, 0x03, 0xc0, 0xc0, 0xc0, 0xc0,

Device Found
  type: 045e 0773
  path: \\?\hid#vid_045e&pid_0773&mi_01&col02#7&179bde70&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      674
  Interface:    1
  Usage (page): 0x1 (0xc)
  Report Descriptor:
05 0C            Usage Page (12)
09 01            Usage  (1)
A1 01            Collection (Application)
05 01            Usage Page (1)
09 02            Usage  (2)
A1 02            Collection (Logical)
85 1F            Report ID (31)
05 0C            Usage Page (12)
0A 38 02         Usage (568)
16 01 80         Logical Minimum (-32767)
26 FF 7F         Logical Maximum (32767)
75 10            Report Size (16)
95 01            Report Count (1)
81 06            Input (0x06)
85 17            Report ID (23)
06 00 FF         Usage Page (65280)
0A 06 FF         Usage (65286)
0A 0F FF         Usage (65295)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
35 01            Physical Minimum (1)
45 04            Physical Maximum (4)
75 02            Report Size (2)
95 02            Report Count (2)
B1 02            Feature (0x02)
0A 04 FF         Usage (65284)
15 00            Logical Minimum (0)
25 01            Logical Maximum (1)
75 01            Report Size (1)
95 01            Report Count (1)
35 00            Physical Minimum (0)
45 00            Physical Maximum (0)
B1 02            Feature (0x02)
75 03            Report Size (3)
95 01            Report Count (1)
B1 03            Feature (0x03) Padding
C0               End Collection
85 16            Report ID (22)
05 0C            Usage Page (12)
19 00            Usage Minimum (0)
2A FF 03         Usage Maximum (1023)
15 00            Logical Minimum (0)
26 FF 03         Logical Maximum (1023)
75 10            Report Size (16)
95 01            Report Count (1)
81 00            Input (0x00)
06 00 FF         Usage Page (65280)
1A 01 FD         Usage Minimum (64769)
2A FF FD         Usage Maximum (65023)
15 01            Logical Minimum (1)
26 FF 00         Logical Maximum (255)
75 08            Report Size (8)
95 01            Report Count (1)
81 00            Input (0x00)
85 1C            Report ID (28)
0A 25 FF         Usage (65317)
15 00            Logical Minimum (0)
25 04            Logical Maximum (4)
75 08            Report Size (8)
95 01            Report Count (1)
81 02            Input (0x02)
0A 26 FF         Usage (65318)
15 00            Logical Minimum (0)
27 FF FF 00 00   Logical Maximum (65535)
75 10            Report Size (16)
95 01            Report Count (1)
81 02            Input (0x02)
C0               End Collection
(152 bytes)
0x05, 0x0c, 0x09, 0x01, 0xa1, 0x01, 0x05, 0x01, 0x09, 0x02,
0xa1, 0x02, 0x85, 0x1f, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x16,
0x01, 0x80, 0x26, 0xff, 0x7f, 0x75, 0x10, 0x95, 0x01, 0x81,
0x06, 0x85, 0x17, 0x06, 0x00, 0xff, 0x0a, 0x06, 0xff, 0x0a,
0x0f, 0xff, 0x15, 0x00, 0x25, 0x01, 0x35, 0x01, 0x45, 0x04,
0x75, 0x02, 0x95, 0x02, 0xb1, 0x02, 0x0a, 0x04, 0xff, 0x15,
0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x01, 0x35, 0x00, 0x45,
0x00, 0xb1, 0x02, 0x75, 0x03, 0x95, 0x01, 0xb1, 0x03, 0xc0,
0x85, 0x16, 0x05, 0x0c, 0x19, 0x00, 0x2a, 0xff, 0x03, 0x15,
0x00, 0x26, 0xff, 0x03, 0x75, 0x10, 0x95, 0x01, 0x81, 0x00,
0x06, 0x00, 0xff, 0x1a, 0x01, 0xfd, 0x2a, 0xff, 0xfd, 0x15,
0x01, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, 0x01, 0x81, 0x00,
0x85, 0x1c, 0x0a, 0x25, 0xff, 0x15, 0x00, 0x25, 0x04, 0x75,
0x08, 0x95, 0x01, 0x81, 0x02, 0x0a, 0x26, 0xff, 0x15, 0x00,
0x27, 0xff, 0xff, 0x00, 0x00, 0x75, 0x10, 0x95, 0x01, 0x81,
0x02, 0xc0,

@mcuee
Copy link
Member

mcuee commented Jul 18, 2021

Microchip PICKit 2: checked, good

Logitech M557 Bluetooth Mouse: at least report ID, report size and report count are all correct with a quick check.

Logitech USB receiver: to be checked

Microsoft USB Nano Receiver: to be checked

@JoergAtGithub
Copy link
Contributor Author

Which Windows version did you use for the test? I think i is important, to check this with various Windows versions.
I developed it with: Windows7 64Bit Service Pack1

@mcuee
Copy link
Member

mcuee commented Jul 18, 2021

Windows 10 Enterprise x64 (version 20H2)

@JoergAtGithub
Copy link
Contributor Author

@Youw @DJm00n @mcuee This is now complete and ready for code review!

@DJm00n
Copy link
Contributor

DJm00n commented Nov 21, 2021

@JoergAtGithub I think that your code could be moved to separate file. hid.c is too big with your changes.
hid_report_desc.c etc.
@Youw any thoughts?

@JoergAtGithub
Copy link
Contributor Author

@DJm00n I could seperate it, but than we need also a header file, which contains all the typedefs and declarations used by both.

@Youw
Copy link
Member

Youw commented Nov 22, 2021

could be moved to separate file

Not yet. See your README:

HIDAPI is a multi-platform library ... can be embedded directly into a target application by adding a single source file (per platform) and a single header.

That is currently our design. I do want to change that, so we can decouple the implementation, move some common parts, etc.
But that we will perform separately, some time later, for all backends.

@Youw
Copy link
Member

Youw commented Nov 22, 2021

This is now complete and ready for code review!

Thanks! I'll go over it over the weekend (I hope).

Copy link
Member

@Youw Youw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have too many comments to the implementation/code style.
So instead of leaving them on GH, I'll create a separate commit instead with "fixes".

And after giving it a good though - it seems like a good idea to try to separate the implementation out of hid.c.
I'll work on that too.

hidtest/test.c Outdated Show resolved Hide resolved
hidtest/test.c Outdated Show resolved Hide resolved
windows/hid.c Outdated Show resolved Hide resolved
windows/hid.c Outdated Show resolved Hide resolved
@JoergAtGithub
Copy link
Contributor Author

Thanks for working on this!

If you restructure the code, please keep the testability in mind. For the unit test in #343 it's neccessary:

  • to execute the function reconstruct_report_descriptor standalone
  • to include, all the structures and types used in the preparsed data struct, into the unit test program (a private header-file for the Windows backend would make this much cleaner than now)

@Youw
Copy link
Member

Youw commented Dec 29, 2021

For the unit test in #343

Yeah, maybe I'll update that too.

@Youw
Copy link
Member

Youw commented Jan 3, 2022

I still have (none-written) comments regarding the implementation but lets have a libusb:get-descriptor as a working branch for this change - merging as is for now.

@Youw Youw merged commit 2610d00 into libusb:get-descriptor Jan 3, 2022
@JoergAtGithub
Copy link
Contributor Author

Thanks for cleaning up my code!

@hugmyndakassi
Copy link

hugmyndakassi commented Jan 12, 2023

@JoergAtGithub Just wanted to add a little piece of information since I am currently myself trying to reconstruct what HIDP_PREPARSED_DATA is actually defined as.

For obvious reasons we can't be sure about the names -- except for items that correspond 1:1 to another documented struct -- but compared to this one I came up with this:

// Choice of basic types informed by other documented HID-related structs and experience with KM drivers
typedef struct _HIDP_CAPS_REPORT_INFO
{
    USHORT FirstCap;
    // NB: Took your name just now, I had called this SomeCounter until now
    USHORT NumberOfCaps; // Includes empty caps after LastCap
    // Until now I had no clue about this and only saw there were three xrefs from hidparse!HidP_AllocateCollections to this field
    USHORT LastCap;
    // NB: Didn't assign a name to this as of yet, but saw some boundary checks involving a number of those
    // "tail bytes" structs
    USHORT ByteLength; // Corresponds to HIDP_CAPS::InputReportByteLength/HIDP_CAPS::OutputReportByteLength/HIDP_CAPS::FeatureReportByteLength as per
                       // hidparse!HidP_GetCaps
} HIDP_CAPS_REPORT_INFO;

typedef struct _HIDP_PREPARSED_DATA_TAIL
{
    UCHAR Buf[104];
} HIDP_PREPARSED_DATA_TAIL;

#define HIDP_PREPARSED_DATA_DRIVER_SIGNATURE1 'PdiH' // == 0x50646948U
#define HIDP_PREPARSED_DATA_DRIVER_SIGNATURE2 'RDK ' // == 0x52444B20U

typedef struct _HIDP_PREPARSED_DATA
{
    ULONG DriverSignature1; // == 'PdiH' -> coincides with hidparse's pool tag
    ULONG DriverSignature2; // == 'RDK '
    USHORT Usage;           // corresponds to HIDP_CAPS::Usage as per hidparse!HidP_GetCaps
    USHORT UsagePage;       // corresponds to HIDP_CAPS::UsagePage as per hidparse!HidP_GetCaps
    ULONG SysPowerCaps;     // name based on hidparse!HidP_SysPowerCaps, which accesses just this
    HIDP_CAPS_REPORT_INFO Input;
    HIDP_CAPS_REPORT_INFO Output;
    HIDP_CAPS_REPORT_INFO Feature;
    // Could also be something like:
    //     HIDP_CAPS_REPORT_INFO Reports[3];
    // ... indexed by the documented HIDP_REPORT_TYPE (hidpi.h)
    USHORT OffsetToLinkCollectionArray;
    // NB: Adapted the above name OffsetToLinkCollectionArray from you now, referenced by hidparse!HidP_GetLinkCollectionNodes and
    // hidparse!HidP_AllocateCollections and used as an offset based on what I called "tail bytes" (below)
    // Previously I had kept the default name from IDA, as I hadn't gotten around to it.
    USHORT NumberOfLinkCollectionNodes; // corresponds to HIDP_CAPS::NumberLinkCollectionNodes as per hidparse!HidP_GetCaps
    // The following seems to be an ANYSIZE_ARRAY of a struct of size 104 (0x68)
    HIDP_PREPARSED_DATA_TAIL TailBytes[ANYSIZE_ARRAY];
} HIDP_PREPARSED_DATA;

So in conclusion you can use the info about ULONG SysPowerCaps;, which is the only field accessed by hidparse!HidP_SysPowerCaps. That name may not be the same as Microsoft uses, but it's the closest we can get.

Additionally, as commented inline above, it's possible that the report info structs (your hid_pp_caps_info) are thought as an array, indexed by HIDP_REPORT_TYPE (hidpi.h):

HIDP_CAPS_REPORT_INFO Reports[3];

But my initial hunch was to have those separate, probably because I hadn't looked at as many functions as I have now. However, that said, the array hypothesis isn't too far-fetched if we look at how a number of functions taking HIDP_PREPARSED_DATA* PreparsedData as input treat this. Generally any functions taking that as input, appear to start with this:

if (!PreparsedData || PreparsedData->DriverSignature1 != HIDP_PREPARSED_DATA_DRIVER_SIGNATURE1 ||
    PreparsedData->DriverSignature2 != HIDP_PREPARSED_DATA_DRIVER_SIGNATURE2)
{
    return HIDP_STATUS_INVALID_PREPARSED_DATA;
}

I'd say chances are that this is hidden behind a macro, as it's repeated all over the place. Curiously hidparse!HidP_SysPowerCaps doesn't appear to have this check (or any other); perhaps owed to its "internal" nature?!

That check is then followed by something that takes the HIDP_REPORT_TYPE ReportType argument, does bounds checking against the values defined in the enum, and then uses known offsets (from HIDP_PREPARSED_DATA) to compute what amounts to a HIDP_CAPS_REPORT_INFO * for the respective ReportType. Since it works with offsets, though, I reckon that internally these are indeed separate members and not an array.

Based on your information I can probably speed up my effort in what call HIDP_PREPARSED_DATA_TAIL above. Thanks! 😉

One more note: you wrote:

// MINGW: flexible array member in union not supported - but works with MSVC

and while that may be true, customarily Microsoft uses ANYSIZE_ARRAY (i.e. #define ANYSIZE_ARRAY 1) to describe such arrays. C++ also doesn't like just [] and I reckon that's why the define exists.

PS: If I find out anything further that can complete the idea of the involved structs, I'll let you know.
PPS: the hidparse.sys was this one and the hid.dll this one.

@hugmyndakassi
Copy link

@hugmyndakassi https://github.com/tongzx/nt5src/blob/daad8a087a4e75422ec96b7911f1df4669989611/Source/XPSP1/NT/drivers/wdm/input/hidparse/hidparse.h#L151-L177 🙈

@DJm00n Ouch, I'm not really allowed to look at leaked proprietary code. Clean room reverse engineering and all.

Either way, I found that IDA curiously knows about this, supposedly from the PDB. And indeed looking with https://github.com/horsicq/PDBRipper discloses that the PDB contains definitions.

image

This is what IDA makes of it, when exporting to a header:

/*
   This file has been generated by IDA.
   It contains local type definitions from
   the type library 'hidparse.sys'
*/

#define __int8 char
#define __int16 short
#define __int32 int
#define __int64 long long

/* 152 */
struct _HIDP_UNKNOWN_TOKEN
{
  unsigned __int8 Token;
  unsigned __int8 Reserved[3];
  unsigned int BitField;
};

/* 153 */
union $BC552F92952051640026B0CDE7ED463D
{
  struct
  {
    unsigned __int16 UsageMin;
    unsigned __int16 UsageMax;
    unsigned __int16 StringMin;
    unsigned __int16 StringMax;
    unsigned __int16 DesignatorMin;
    unsigned __int16 DesignatorMax;
    unsigned __int16 DataIndexMin;
    unsigned __int16 DataIndexMax;
  } Range;
  struct
  {
    unsigned __int16 Usage;
    unsigned __int16 Reserved1;
    unsigned __int16 StringIndex;
    unsigned __int16 Reserved2;
    unsigned __int16 DesignatorIndex;
    unsigned __int16 Reserved3;
    unsigned __int16 DataIndex;
    unsigned __int16 Reserved4;
  } NotRange;
};

/* 154 */
union $2E4BAE54AE40A62CFE47CF014A0A6FCB
{
  struct
  {
    int LogicalMin;
    int LogicalMax;
  } button;
  struct
  {
    unsigned __int8 HasNull;
    unsigned __int8 Reserved[3];
    int LogicalMin;
    int LogicalMax;
    int PhysicalMin;
    int PhysicalMax;
  } Data;
};

/* 155 */
struct _HIDP_CHANNEL_DESC
{
  unsigned __int16 UsagePage;
  unsigned __int8 ReportID;
  unsigned __int8 BitOffset;
  unsigned __int16 ReportSize;
  unsigned __int16 ReportCount;
  unsigned __int16 ByteOffset;
  unsigned __int16 BitLength;
  unsigned int BitField;
  unsigned __int16 ByteEnd;
  unsigned __int16 LinkCollection;
  unsigned __int16 LinkUsagePage;
  unsigned __int16 LinkUsage;
  unsigned __int32 MoreChannels : 1;
  unsigned __int32 IsConst : 1;
  unsigned __int32 IsButton : 1;
  unsigned __int32 IsAbsolute : 1;
  unsigned __int32 IsRange : 1;
  unsigned __int32 IsAlias : 1;
  unsigned __int32 IsStringRange : 1;
  unsigned __int32 IsDesignatorRange : 1;
  unsigned __int32 Reserved : 20;
  unsigned __int32 NumGlobalUnknowns : 4;
  _HIDP_UNKNOWN_TOKEN GlobalUnknowns[4];
  $BC552F92952051640026B0CDE7ED463D ___u23;
  $2E4BAE54AE40A62CFE47CF014A0A6FCB ___u24;
  unsigned int Units;
  unsigned int UnitExp;
};

/* 157 */
struct _CHANNEL_REPORT_HEADER
{
  unsigned __int16 Offset;
  unsigned __int16 Size;
  unsigned __int16 Index;
  unsigned __int16 ByteLen;
};

/* 158 */
struct __declspec(align(4)) _HIDP_PREPARSED_DATA
{
  int Signature1;
  int Signature2;
  unsigned __int16 Usage;
  unsigned __int16 UsagePage;
  unsigned int PowerButtonMask;
  _CHANNEL_REPORT_HEADER Input;
  _CHANNEL_REPORT_HEADER Output;
  _CHANNEL_REPORT_HEADER Feature;
  unsigned __int16 LinkCollectionArrayOffset;
  unsigned __int16 LinkCollectionArrayLength;
  _HIDP_CHANNEL_DESC Data[];
  unsigned __int8 RawBytes[];
  _BYTE gap2C[104];
};

So finally I also have more sensible type and member names. And sort of a confirmation for those things where I wasn't a 100% certain. But I find _HIDP_UNKNOWN_TOKEN curious. The name seems to originate from Windows.

The gist is, I should probably pay more attention to IDA's changelog and their blog and always consult the "Local Types" (Shift+F1) when dealing with code that has debug symbols available.

@DJm00n
Copy link
Contributor

DJm00n commented Jan 17, 2023

_HIDP_UNKNOWN_TOKEN is about not recognized global HID items. See "6.2.2.7 Global Items" part of the HID spec for a list of possible tokens:
1100 01 nn to 1111 01 nn - Range reserved for future use.

@JoergAtGithub
Copy link
Contributor Author

_HIDP_UNKNOWN_TOKEN is official documented here: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/hidpi/ns-hidpi-_hidp_unknown_token

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Related to Windows backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants