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