hidintro.rst 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ======================================
  3. Introduction to HID report descriptors
  4. ======================================
  5. This chapter is meant to give a broad overview of what HID report
  6. descriptors are, and of how a casual (non-kernel) programmer can deal
  7. with HID devices that are not working well with Linux.
  8. .. contents::
  9. :local:
  10. :depth: 2
  11. .. toctree::
  12. :maxdepth: 2
  13. hidreport-parsing
  14. Introduction
  15. ============
  16. HID stands for Human Interface Device, and can be whatever device you
  17. are using to interact with a computer, be it a mouse, a touchpad, a
  18. tablet, a microphone.
  19. Many HID devices work out the box, even if their hardware is different.
  20. For example, mice can have any number of buttons; they may have a
  21. wheel; movement sensitivity differs between different models, and so
  22. on. Nonetheless, most of the time everything just works, without the
  23. need to have specialized code in the kernel for every mouse model
  24. developed since 1970.
  25. This is because modern HID devices do advertise their capabilities
  26. through the *HID report descriptor*, a fixed set of bytes describing
  27. exactly what *HID reports* may be sent between the device and the host
  28. and the meaning of each individual bit in those reports. For example,
  29. a HID Report Descriptor may specify that "in a report with ID 3 the
  30. bits from 8 to 15 is the delta x coordinate of a mouse".
  31. The HID report itself then merely carries the actual data values
  32. without any extra meta information. Note that HID reports may be sent
  33. from the device ("Input Reports", i.e. input events), to the device
  34. ("Output Reports" to e.g. change LEDs) or used for device configuration
  35. ("Feature reports"). A device may support one or more HID reports.
  36. The HID subsystem is in charge of parsing the HID report descriptors,
  37. and converts HID events into normal input device interfaces (see
  38. Documentation/hid/hid-transport.rst). Devices may misbehave because the
  39. HID report descriptor provided by the device is wrong, or because it
  40. needs to be dealt with in a special way, or because some special
  41. device or interaction mode is not handled by the default code.
  42. The format of HID report descriptors is described by two documents,
  43. available from the `USB Implementers Forum <https://www.usb.org/>`_
  44. `HID web page <https://www.usb.org/hid>`_ address:
  45. * the `HID USB Device Class Definition
  46. <https://www.usb.org/document-library/device-class-definition-hid-111>`_ (HID Spec from now on)
  47. * the `HID Usage Tables <https://usb.org/document-library/hid-usage-tables-14>`_ (HUT from now on)
  48. The HID subsystem can deal with different transport drivers
  49. (USB, I2C, Bluetooth, etc.). See Documentation/hid/hid-transport.rst.
  50. Parsing HID report descriptors
  51. ==============================
  52. The current list of HID devices can be found at ``/sys/bus/hid/devices/``.
  53. For each device, say ``/sys/bus/hid/devices/0003\:093A\:2510.0002/``,
  54. one can read the corresponding report descriptor::
  55. $ hexdump -C /sys/bus/hid/devices/0003\:093A\:2510.0002/report_descriptor
  56. 00000000 05 01 09 02 a1 01 09 01 a1 00 05 09 19 01 29 03 |..............).|
  57. 00000010 15 00 25 01 75 01 95 03 81 02 75 05 95 01 81 01 |..%.u.....u.....|
  58. 00000020 05 01 09 30 09 31 09 38 15 81 25 7f 75 08 95 03 |...0.1.8..%.u...|
  59. 00000030 81 06 c0 c0 |....|
  60. 00000034
  61. Optional: the HID report descriptor can be read also by
  62. directly accessing the hidraw driver [#hidraw]_.
  63. The basic structure of HID report descriptors is defined in the HID
  64. spec, while HUT "defines constants that can be interpreted by an
  65. application to identify the purpose and meaning of a data field in a
  66. HID report". Each entry is defined by at least two bytes, where the
  67. first one defines what type of value is following and is described in
  68. the HID spec, while the second one carries the actual value and is
  69. described in the HUT.
  70. HID report descriptors can, in principle, be painstakingly parsed by
  71. hand, byte by byte.
  72. A short introduction on how to do this is sketched in
  73. Documentation/hid/hidreport-parsing.rst; you only need to understand it
  74. if you need to patch HID report descriptors.
  75. In practice you should not parse HID report descriptors by hand; rather,
  76. you should use an existing parser. Among all the available ones
  77. * the online `USB Descriptor and Request Parser
  78. <http://eleccelerator.com/usbdescreqparser/>`_;
  79. * `hidrdd <https://github.com/abend0c1/hidrdd>`_,
  80. that provides very detailed and somewhat verbose descriptions
  81. (verbosity can be useful if you are not familiar with HID report
  82. descriptors);
  83. * `hid-tools <https://gitlab.freedesktop.org/libevdev/hid-tools>`_,
  84. a complete utility set that allows, among other things,
  85. to record and replay the raw HID reports and to debug
  86. and replay HID devices.
  87. It is being actively developed by the Linux HID subsystem maintainers.
  88. Parsing the mouse HID report descriptor with `hid-tools
  89. <https://gitlab.freedesktop.org/libevdev/hid-tools>`_ leads to
  90. (explanations interposed)::
  91. $ ./hid-decode /sys/bus/hid/devices/0003\:093A\:2510.0002/report_descriptor
  92. # device 0:0
  93. # 0x05, 0x01, // Usage Page (Generic Desktop) 0
  94. # 0x09, 0x02, // Usage (Mouse) 2
  95. # 0xa1, 0x01, // Collection (Application) 4
  96. # 0x09, 0x01, // Usage (Pointer) 6
  97. # 0xa1, 0x00, // Collection (Physical) 8
  98. # 0x05, 0x09, // Usage Page (Button) 10
  99. what follows is a button ::
  100. # 0x19, 0x01, // Usage Minimum (1) 12
  101. # 0x29, 0x03, // Usage Maximum (3) 14
  102. first button is button number 1, last button is button number 3 ::
  103. # 0x15, 0x00, // Logical Minimum (0) 16
  104. # 0x25, 0x01, // Logical Maximum (1) 18
  105. each button can send values from 0 up to including 1
  106. (i.e. they are binary buttons) ::
  107. # 0x75, 0x01, // Report Size (1) 20
  108. each button is sent as exactly one bit ::
  109. # 0x95, 0x03, // Report Count (3) 22
  110. and there are three of those bits (matching the three buttons) ::
  111. # 0x81, 0x02, // Input (Data,Var,Abs) 24
  112. it's actual Data (not constant padding), they represent
  113. a single variable (Var) and their values are Absolute (not relative);
  114. See HID spec Sec. 6.2.2.5 "Input, Output, and Feature Items" ::
  115. # 0x75, 0x05, // Report Size (5) 26
  116. five additional padding bits, needed to reach a byte ::
  117. # 0x95, 0x01, // Report Count (1) 28
  118. those five bits are repeated only once ::
  119. # 0x81, 0x01, // Input (Cnst,Arr,Abs) 30
  120. and take Constant (Cnst) values i.e. they can be ignored. ::
  121. # 0x05, 0x01, // Usage Page (Generic Desktop) 32
  122. # 0x09, 0x30, // Usage (X) 34
  123. # 0x09, 0x31, // Usage (Y) 36
  124. # 0x09, 0x38, // Usage (Wheel) 38
  125. The mouse has also two physical positions (Usage (X), Usage (Y))
  126. and a wheel (Usage (Wheel)) ::
  127. # 0x15, 0x81, // Logical Minimum (-127) 40
  128. # 0x25, 0x7f, // Logical Maximum (127) 42
  129. each of them can send values ranging from -127 up to including 127 ::
  130. # 0x75, 0x08, // Report Size (8) 44
  131. which is represented by eight bits ::
  132. # 0x95, 0x03, // Report Count (3) 46
  133. and there are three of those eight bits, matching X, Y and Wheel. ::
  134. # 0x81, 0x06, // Input (Data,Var,Rel) 48
  135. This time the data values are Relative (Rel), i.e. they represent
  136. the change from the previously sent report (event) ::
  137. # 0xc0, // End Collection 50
  138. # 0xc0, // End Collection 51
  139. #
  140. R: 52 05 01 09 02 a1 01 09 01 a1 00 05 09 19 01 29 03 15 00 25 01 75 01 95 03 81 02 75 05 95 01 81 01 05 01 09 30 09 31 09 38 15 81 25 7f 75 08 95 03 81 06 c0 c0
  141. N: device 0:0
  142. I: 3 0001 0001
  143. This Report Descriptor tells us that the mouse input will be
  144. transmitted using four bytes: the first one for the buttons (three
  145. bits used, five for padding), the last three for the mouse X, Y and
  146. wheel changes, respectively.
  147. Indeed, for any event, the mouse will send a *report* of four bytes.
  148. We can check the values sent by resorting e.g. to the `hid-recorder`
  149. tool, from `hid-tools <https://gitlab.freedesktop.org/libevdev/hid-tools>`_:
  150. The sequence of bytes sent by clicking and releasing button 1, then button 2, then button 3 is::
  151. $ sudo ./hid-recorder /dev/hidraw1
  152. ....
  153. output of hid-decode
  154. ....
  155. # Button: 1 0 0 | # | X: 0 | Y: 0 | Wheel: 0
  156. E: 000000.000000 4 01 00 00 00
  157. # Button: 0 0 0 | # | X: 0 | Y: 0 | Wheel: 0
  158. E: 000000.183949 4 00 00 00 00
  159. # Button: 0 1 0 | # | X: 0 | Y: 0 | Wheel: 0
  160. E: 000001.959698 4 02 00 00 00
  161. # Button: 0 0 0 | # | X: 0 | Y: 0 | Wheel: 0
  162. E: 000002.103899 4 00 00 00 00
  163. # Button: 0 0 1 | # | X: 0 | Y: 0 | Wheel: 0
  164. E: 000004.855799 4 04 00 00 00
  165. # Button: 0 0 0 | # | X: 0 | Y: 0 | Wheel: 0
  166. E: 000005.103864 4 00 00 00 00
  167. This example shows that when button 2 is clicked,
  168. the bytes ``02 00 00 00`` are sent, and the immediately subsequent
  169. event (``00 00 00 00``) is the release of button 2 (no buttons are
  170. pressed, remember that the data values are *absolute*).
  171. If instead one clicks and holds button 1, then clicks and holds button
  172. 2, releases button 1, and finally releases button 2, the reports are::
  173. # Button: 1 0 0 | # | X: 0 | Y: 0 | Wheel: 0
  174. E: 000044.175830 4 01 00 00 00
  175. # Button: 1 1 0 | # | X: 0 | Y: 0 | Wheel: 0
  176. E: 000045.975997 4 03 00 00 00
  177. # Button: 0 1 0 | # | X: 0 | Y: 0 | Wheel: 0
  178. E: 000047.407930 4 02 00 00 00
  179. # Button: 0 0 0 | # | X: 0 | Y: 0 | Wheel: 0
  180. E: 000049.199919 4 00 00 00 00
  181. where with ``03 00 00 00`` both buttons are pressed, and with the
  182. subsequent ``02 00 00 00`` button 1 is released while button 2 is still
  183. active.
  184. Output, Input and Feature Reports
  185. ---------------------------------
  186. HID devices can have Input Reports, like in the mouse example, Output
  187. Reports, and Feature Reports. "Output" means that the information is
  188. sent to the device. For example, a joystick with force feedback will
  189. have some output; the led of a keyboard would need an output as well.
  190. "Input" means that data come from the device.
  191. "Feature"s are not meant to be consumed by the end user and define
  192. configuration options for the device. They can be queried from the host;
  193. when declared as *Volatile* they should be changed by the host.
  194. Collections, Report IDs and Evdev events
  195. ========================================
  196. A single device can logically group data into different independent
  197. sets, called a *Collection*. Collections can be nested and there are
  198. different types of collections (see the HID spec 6.2.2.6
  199. "Collection, End Collection Items" for details).
  200. Different reports are identified by means of different *Report ID*
  201. fields, i.e. a number identifying the structure of the immediately
  202. following report.
  203. Whenever a Report ID is needed it is transmitted as the first byte of
  204. any report. A device with only one supported HID report (like the mouse
  205. example above) may omit the report ID.
  206. Consider the following HID report descriptor::
  207. 05 01 09 02 A1 01 85 01 05 09 19 01 29 05 15 00
  208. 25 01 95 05 75 01 81 02 95 01 75 03 81 01 05 01
  209. 09 30 09 31 16 00 F8 26 FF 07 75 0C 95 02 81 06
  210. 09 38 15 80 25 7F 75 08 95 01 81 06 05 0C 0A 38
  211. 02 15 80 25 7F 75 08 95 01 81 06 C0 05 01 09 02
  212. A1 01 85 02 05 09 19 01 29 05 15 00 25 01 95 05
  213. 75 01 81 02 95 01 75 03 81 01 05 01 09 30 09 31
  214. 16 00 F8 26 FF 07 75 0C 95 02 81 06 09 38 15 80
  215. 25 7F 75 08 95 01 81 06 05 0C 0A 38 02 15 80 25
  216. 7F 75 08 95 01 81 06 C0 05 01 09 07 A1 01 85 05
  217. 05 07 15 00 25 01 09 29 09 3E 09 4B 09 4E 09 E3
  218. 09 E8 09 E8 09 E8 75 01 95 08 81 02 95 00 81 01
  219. C0 05 0C 09 01 A1 01 85 06 15 00 25 01 75 01 95
  220. 01 09 3F 81 06 09 3F 81 06 09 3F 81 06 09 3F 81
  221. 06 09 3F 81 06 09 3F 81 06 09 3F 81 06 09 3F 81
  222. 06 C0 05 0C 09 01 A1 01 85 03 09 05 15 00 26 FF
  223. 00 75 08 95 02 B1 02 C0
  224. After parsing it (try to parse it on your own using the suggested
  225. tools!) one can see that the device presents two ``Mouse`` Application
  226. Collections (with reports identified by Reports IDs 1 and 2,
  227. respectively), a ``Keypad`` Application Collection (whose report is
  228. identified by the Report ID 5) and two ``Consumer Controls`` Application
  229. Collections, (with Report IDs 6 and 3, respectively). Note, however,
  230. that a device can have different Report IDs for the same Application
  231. Collection.
  232. The data sent will begin with the Report ID byte, and will be followed
  233. by the corresponding information. For example, the data transmitted for
  234. the last consumer control::
  235. 0x05, 0x0C, // Usage Page (Consumer)
  236. 0x09, 0x01, // Usage (Consumer Control)
  237. 0xA1, 0x01, // Collection (Application)
  238. 0x85, 0x03, // Report ID (3)
  239. 0x09, 0x05, // Usage (Headphone)
  240. 0x15, 0x00, // Logical Minimum (0)
  241. 0x26, 0xFF, 0x00, // Logical Maximum (255)
  242. 0x75, 0x08, // Report Size (8)
  243. 0x95, 0x02, // Report Count (2)
  244. 0xB1, 0x02, // Feature (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position,Non-volatile)
  245. 0xC0, // End Collection
  246. will be of three bytes: the first for the Report ID (3), the next two
  247. for the headphone, with two (``Report Count (2)``) bytes
  248. (``Report Size (8)``), each ranging from 0 (``Logical Minimum (0)``)
  249. to 255 (``Logical Maximum (255)``).
  250. All the Input data sent by the device should be translated into
  251. corresponding Evdev events, so that the remaining part of the stack can
  252. know what is going on, e.g. the bit for the first button translates into
  253. the ``EV_KEY/BTN_LEFT`` evdev event and relative X movement translates
  254. into the ``EV_REL/REL_X`` evdev event".
  255. Events
  256. ======
  257. In Linux, one ``/dev/input/event*`` is created for each ``Application
  258. Collection``. Going back to the mouse example, and repeating the
  259. sequence where one clicks and holds button 1, then clicks and holds
  260. button 2, releases button 1, and finally releases button 2, one gets::
  261. $ sudo libinput record /dev/input/event1
  262. # libinput record
  263. version: 1
  264. ndevices: 1
  265. libinput:
  266. version: "1.23.0"
  267. git: "unknown"
  268. system:
  269. os: "opensuse-tumbleweed:20230619"
  270. kernel: "6.3.7-1-default"
  271. dmi: "dmi:bvnHP:bvrU77Ver.01.05.00:bd03/24/2022:br5.0:efr20.29:svnHP:pnHPEliteBook64514inchG9NotebookPC:pvr:rvnHP:rn89D2:rvrKBCVersion14.1D.00:cvnHP:ct10:cvr:sku5Y3J1EA#ABZ:"
  272. devices:
  273. - node: /dev/input/event1
  274. evdev:
  275. # Name: PixArt HP USB Optical Mouse
  276. # ID: bus 0x3 vendor 0x3f0 product 0x94a version 0x111
  277. # Supported Events:
  278. # Event type 0 (EV_SYN)
  279. # Event type 1 (EV_KEY)
  280. # Event code 272 (BTN_LEFT)
  281. # Event code 273 (BTN_RIGHT)
  282. # Event code 274 (BTN_MIDDLE)
  283. # Event type 2 (EV_REL)
  284. # Event code 0 (REL_X)
  285. # Event code 1 (REL_Y)
  286. # Event code 8 (REL_WHEEL)
  287. # Event code 11 (REL_WHEEL_HI_RES)
  288. # Event type 4 (EV_MSC)
  289. # Event code 4 (MSC_SCAN)
  290. # Properties:
  291. name: "PixArt HP USB Optical Mouse"
  292. id: [3, 1008, 2378, 273]
  293. codes:
  294. 0: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] # EV_SYN
  295. 1: [272, 273, 274] # EV_KEY
  296. 2: [0, 1, 8, 11] # EV_REL
  297. 4: [4] # EV_MSC
  298. properties: []
  299. hid: [
  300. 0x05, 0x01, 0x09, 0x02, 0xa1, 0x01, 0x09, 0x01, 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03,
  301. 0x15, 0x00, 0x25, 0x01, 0x95, 0x08, 0x75, 0x01, 0x81, 0x02, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31,
  302. 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 0x95, 0x03, 0x81, 0x06, 0xc0, 0xc0
  303. ]
  304. udev:
  305. properties:
  306. - ID_INPUT=1
  307. - ID_INPUT_MOUSE=1
  308. - LIBINPUT_DEVICE_GROUP=3/3f0/94a:usb-0000:05:00.3-2
  309. quirks:
  310. events:
  311. # Current time is 12:31:56
  312. - evdev:
  313. - [ 0, 0, 4, 4, 30] # EV_MSC / MSC_SCAN 30 (obfuscated)
  314. - [ 0, 0, 1, 272, 1] # EV_KEY / BTN_LEFT 1
  315. - [ 0, 0, 0, 0, 0] # ------------ SYN_REPORT (0) ---------- +0ms
  316. - evdev:
  317. - [ 1, 207892, 4, 4, 30] # EV_MSC / MSC_SCAN 30 (obfuscated)
  318. - [ 1, 207892, 1, 273, 1] # EV_KEY / BTN_RIGHT 1
  319. - [ 1, 207892, 0, 0, 0] # ------------ SYN_REPORT (0) ---------- +1207ms
  320. - evdev:
  321. - [ 2, 367823, 4, 4, 30] # EV_MSC / MSC_SCAN 30 (obfuscated)
  322. - [ 2, 367823, 1, 272, 0] # EV_KEY / BTN_LEFT 0
  323. - [ 2, 367823, 0, 0, 0] # ------------ SYN_REPORT (0) ---------- +1160ms
  324. # Current time is 12:32:00
  325. - evdev:
  326. - [ 3, 247617, 4, 4, 30] # EV_MSC / MSC_SCAN 30 (obfuscated)
  327. - [ 3, 247617, 1, 273, 0] # EV_KEY / BTN_RIGHT 0
  328. - [ 3, 247617, 0, 0, 0] # ------------ SYN_REPORT (0) ---------- +880ms
  329. Note: if ``libinput record`` is not available on your system try using
  330. ``evemu-record``.
  331. When something does not work
  332. ============================
  333. There can be a number of reasons why a device does not behave
  334. correctly. For example
  335. * The HID report descriptor provided by the HID device may be wrong
  336. because e.g.
  337. * it does not follow the standard, so that the kernel
  338. will not able to make sense of the HID report descriptor;
  339. * the HID report descriptor *does not match* what is actually
  340. sent by the device (this can be verified by reading the raw HID
  341. data);
  342. * the HID report descriptor may need some "quirks" (see later on).
  343. As a consequence, a ``/dev/input/event*`` may not be created
  344. for each Application Collection, and/or the events
  345. there may not match what you would expect.
  346. Quirks
  347. ------
  348. There are some known peculiarities of HID devices that the kernel
  349. knows how to fix - these are called the HID quirks and a list of those
  350. is available in `include/linux/hid.h`.
  351. Should this be the case, it should be enough to add the required quirk
  352. in the kernel, for the HID device at hand. This can be done in the file
  353. `drivers/hid/hid-quirks.c`. How to do it should be relatively
  354. straightforward after looking into the file.
  355. The list of currently defined quirks, from `include/linux/hid.h`, is
  356. .. kernel-doc:: include/linux/hid.h
  357. :doc: HID quirks
  358. Quirks for USB devices can be specified while loading the usbhid module,
  359. see ``modinfo usbhid``, although the proper fix should go into
  360. hid-quirks.c and **be submitted upstream**.
  361. See Documentation/process/submitting-patches.rst for guidelines on how
  362. to submit a patch. Quirks for other busses need to go into hid-quirks.c.
  363. Fixing HID report descriptors
  364. -----------------------------
  365. Should you need to patch HID report descriptors the easiest way is to
  366. resort to eBPF, as described in Documentation/hid/hid-bpf.rst.
  367. Basically, you can change any byte of the original HID report
  368. descriptor. The examples in samples/hid should be a good starting point
  369. for your code, see e.g. `samples/hid/hid_mouse.bpf.c`::
  370. SEC("fmod_ret/hid_bpf_rdesc_fixup")
  371. int BPF_PROG(hid_rdesc_fixup, struct hid_bpf_ctx *hctx)
  372. {
  373. ....
  374. data[39] = 0x31;
  375. data[41] = 0x30;
  376. return 0;
  377. }
  378. Of course this can be also done within the kernel source code, see e.g.
  379. `drivers/hid/hid-aureal.c` or `drivers/hid/hid-samsung.c` for a slightly
  380. more complex file.
  381. Check Documentation/hid/hidreport-parsing.rst if you need any help
  382. navigating the HID manuals and understanding the exact meaning of
  383. the HID report descriptor hex numbers.
  384. Whatever solution you come up with, please remember to **submit the
  385. fix to the HID maintainers**, so that it can be directly integrated in
  386. the kernel and that particular HID device will start working for
  387. everyone else. See Documentation/process/submitting-patches.rst for
  388. guidelines on how to do this.
  389. Modifying the transmitted data on the fly
  390. -----------------------------------------
  391. Using eBPF it is also possible to modify the data exchanged with the
  392. device. See again the examples in `samples/hid`.
  393. Again, **please post your fix**, so that it can be integrated in the
  394. kernel!
  395. Writing a specialized driver
  396. ----------------------------
  397. This should really be your last resort.
  398. .. rubric:: Footnotes
  399. .. [#hidraw] read hidraw: see Documentation/hid/hidraw.rst and
  400. file `samples/hidraw/hid-example.c` for an example.
  401. The output of ``hid-example`` would be, for the same mouse::
  402. $ sudo ./hid-example
  403. Report Descriptor Size: 52
  404. Report Descriptor:
  405. 5 1 9 2 a1 1 9 1 a1 0 5 9 19 1 29 3 15 0 25 1 75 1 95 3 81 2 75 5 95 1 81 1 5 1 9 30 9 31 9 38 15 81 25 7f 75 8 95 3 81 6 c0 c0
  406. Raw Name: PixArt USB Optical Mouse
  407. Raw Phys: usb-0000:05:00.4-2.3/input0
  408. Raw Info:
  409. bustype: 3 (USB)
  410. vendor: 0x093a
  411. product: 0x2510
  412. ...