Recently, I started to learn about communicating with HID devices on Windows 10.
But I got a few questions.
According to the Window's document, HidD_SetOutputReport
must set the first byte of the ReportBuffer
parameter to a report ID or 0x00
.
Since my device's HID Report Descriptor has declared some report id, so I have to set the report id when I use HidD_setoutputreport
instead of 0x00
?
When I used the report id 0x80 as the buf[0]
, ex: 0x80 0x02 0x00 ....... 0x00 (my Capabilities.OutputReportByteLength
is 64)
And my code is ret = HidD_SetOutputReport(handle->device_handle, buf2, 65)
But I always send the data like this (on Bus Hound):
64 OUT 80 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 4.1.0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 4.1.16
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 4.1.32
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 4.1.48
I thought that it should send buf[1] to buf[64]
instead of buf[0] to buf[63]
, so I tried ret = HidD_SetOutputReport(handle->device_handle, buf2, 64)
, but the result was same.
Here is my HID report descriptor of INPUT and OUTPUT:
Usage Page (Generic Desktop) 05 01
Logical Minimum (0) 15 00
Usage (Joystick) 09 04
Collection (Application) A1 01
Report ID (48) 85 30
Usage Page (Generic Desktop) 05 01
Usage Page (Button) 05 09
Usage Minimum (Button 1) 19 01
Usage Maximum (Button 10) 29 0A
Logical Minimum (0) 15 00
Logical Maximum (1) 25 01
Report Size (1) 75 01
Report Count (10) 95 0A
Unit Exponent (0) 55 00
Unit (None) 65 00
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
Usage Page (Button) 05 09
Usage Minimum (Button 11) 19 0B
Usage Maximum (Button 14) 29 0E
Logical Minimum (0) 15 00
Logical Maximum (1) 25 01
Report Size (1) 75 01
Report Count (4) 95 04
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
Report Size (1) 75 01
Report Count (2) 95 02
Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 03
Usage (Generic Desktop:Pointer) 0B 01 00 01 00
Collection (Physical) A1 00
Usage (Generic Desktop:X) 0B 30 00 01 00 Usage (Generic Desktop:Y) 0B 31 00 01 00 Usage (Generic Desktop:Z) 0B 32 00 01 00 Usage (Generic Desktop:Rz) 0B 35 00 01 00 Logical Minimum (0) 15 00 Logical Maximum (65535) 27 FF FF 00 00 Report Size (16) 75 10 Report Count (4) 95 04 Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
End Collection C0
Usage (Generic Desktop:Hat Switch) 0B 39 00 01 00
Logical Minimum (0) 15 00
Logical Maximum (7) 25 07
Physical Minimum (0) 35 00
Physical Maximum (315) 46 3B 01
Unit (Eng Rot: Degree) 65 14
Report Size (4) 75 04
Report Count (1) 95 01
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
Usage Page (Button) 05 09
Usage Minimum (Button 15) 19 0F
Usage Maximum (Button 18) 29 12
Logical Minimum (0) 15 00
Logical Maximum (1) 25 01
Report Size (1) 75 01
Report Count (4) 95 04
Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02
Report Size (8) 75 08
Report Count (52) 95 34
Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 03
Usage Page (Vendor-Defined 1) 06 00 FF
Report ID (33) 85 21
Usage (Vendor-Defined 1) 09 01
Report Size (8) 75 08
Report Count (63) 95 3F
Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 03
Report ID (129) 85 81
Usage (Vendor-Defined 2) 09 02
Report Size (8) 75 08
Report Count (63) 95 3F
Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 03
Report ID (1) 85 01
Usage (Vendor-Defined 3) 09 03
Report Size (8) 75 08
Report Count (63) 95 3F
Output (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Vol,Bit) 91 83
Report ID (16) 85 10
Usage (Vendor-Defined 4) 09 04
Report Size (8) 75 08
Report Count (63) 95 3F
Output (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Vol,Bit) 91 83
Report ID (128) 85 80
Usage (Vendor-Defined 5) 09 05
Report Size (8) 75 08
Report Count (63) 95 3F
Output (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Vol,Bit) 91 83
Report ID (130) 85 82
Usage (Vendor-Defined 6) 09 06
Report Size (8) 75 08
Report Count (63) 95 3F
Output (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Vol,Bit) 91 83
End Collection C0