hid.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. /*
  2. * Copyright (c) 2018 Intel Corporation
  3. * Copyright (c) 2018,2021 Nordic Semiconductor ASA
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. */
  7. /**
  8. * @file
  9. * @brief USB Human Interface Device (HID) common definitions header
  10. *
  11. * Header follows Device Class Definition for Human Interface Devices (HID)
  12. * Version 1.11 document (HID1_11-1.pdf).
  13. */
  14. #ifndef ZEPHYR_INCLUDE_USB_CLASS_HID_H_
  15. #define ZEPHYR_INCLUDE_USB_CLASS_HID_H_
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /**
  20. * @brief hid.h API
  21. * @defgroup usb_hid_definitions USB HID common definitions
  22. * @{
  23. * @}
  24. */
  25. /**
  26. * @defgroup usb_hid_types USB HID types and values
  27. * @ingroup usb_hid_definitions
  28. * @{
  29. */
  30. /** USB HID Class HID descriptor type */
  31. #define USB_DESC_HID 0x21
  32. /** USB HID Class Report descriptor type */
  33. #define USB_DESC_HID_REPORT 0x22
  34. /** USB HID Class physical descriptor type */
  35. #define USB_DESC_HID_PHYSICAL 0x23
  36. /** USB HID Class GetReport bRequest value */
  37. #define USB_HID_GET_REPORT 0x01
  38. /** USB HID Class GetIdle bRequest value */
  39. #define USB_HID_GET_IDLE 0x02
  40. /** USB HID Class GetProtocol bRequest value */
  41. #define USB_HID_GET_PROTOCOL 0x03
  42. /** USB HID Class SetReport bRequest value */
  43. #define USB_HID_SET_REPORT 0x09
  44. /** USB HID Class SetIdle bRequest value */
  45. #define USB_HID_SET_IDLE 0x0A
  46. /** USB HID Class SetProtocol bRequest value */
  47. #define USB_HID_SET_PROTOCOL 0x0B
  48. /** USB HID Boot Interface Protocol (bInterfaceProtocol) Code None */
  49. #define HID_BOOT_IFACE_CODE_NONE 0
  50. /** USB HID Boot Interface Protocol (bInterfaceProtocol) Code Keyboard */
  51. #define HID_BOOT_IFACE_CODE_KEYBOARD 1
  52. /** USB HID Boot Interface Protocol (bInterfaceProtocol) Code Mouse */
  53. #define HID_BOOT_IFACE_CODE_MOUSE 2
  54. /** USB HID Class Boot protocol code */
  55. #define HID_PROTOCOL_BOOT 0
  56. /** USB HID Class Report protocol code */
  57. #define HID_PROTOCOL_REPORT 1
  58. /** HID Main item type */
  59. #define HID_ITEM_TYPE_MAIN 0x0
  60. /** HID Global item type */
  61. #define HID_ITEM_TYPE_GLOBAL 0x1
  62. /** HID Local item type */
  63. #define HID_ITEM_TYPE_LOCAL 0x2
  64. /** HID Input item tag */
  65. #define HID_ITEM_TAG_INPUT 0x8
  66. /** HID Output item tag */
  67. #define HID_ITEM_TAG_OUTPUT 0x9
  68. /** HID Collection item tag */
  69. #define HID_ITEM_TAG_COLLECTION 0xA
  70. /** HID Feature item tag */
  71. #define HID_ITEM_TAG_FEATURE 0xB
  72. /** HID End Collection item tag */
  73. #define HID_ITEM_TAG_COLLECTION_END 0xC
  74. /** HID Usage Page item tag */
  75. #define HID_ITEM_TAG_USAGE_PAGE 0x0
  76. /** HID Logical Minimum item tag */
  77. #define HID_ITEM_TAG_LOGICAL_MIN 0x1
  78. /** HID Logical Maximum item tag */
  79. #define HID_ITEM_TAG_LOGICAL_MAX 0x2
  80. /** HID Physical Minimum item tag */
  81. #define HID_ITEM_TAG_PHYSICAL_MIN 0x3
  82. /** HID Physical Maximum item tag */
  83. #define HID_ITEM_TAG_PHYSICAL_MAX 0x4
  84. /** HID Unit Exponent item tag */
  85. #define HID_ITEM_TAG_UNIT_EXPONENT 0x5
  86. /** HID Unit item tag */
  87. #define HID_ITEM_TAG_UNIT 0x6
  88. /** HID Report Size item tag */
  89. #define HID_ITEM_TAG_REPORT_SIZE 0x7
  90. /** HID Report ID item tag */
  91. #define HID_ITEM_TAG_REPORT_ID 0x8
  92. /** HID Report count item tag */
  93. #define HID_ITEM_TAG_REPORT_COUNT 0x9
  94. /** HID Usage item tag */
  95. #define HID_ITEM_TAG_USAGE 0x0
  96. /** HID Usage Minimum item tag */
  97. #define HID_ITEM_TAG_USAGE_MIN 0x1
  98. /** HID Usage Maximum item tag */
  99. #define HID_ITEM_TAG_USAGE_MAX 0x2
  100. /** Physical collection type */
  101. #define HID_COLLECTION_PHYSICAL 0x00
  102. /** Application collection type */
  103. #define HID_COLLECTION_APPLICATION 0x01
  104. /* Usage page and IDs from Universal Serial Bus HID Usage Tables */
  105. /** HID Generic Desktop Controls Usage page */
  106. #define HID_USAGE_GEN_DESKTOP 0x01
  107. /** HID Keyboard Usage page */
  108. #define HID_USAGE_GEN_KEYBOARD 0x07
  109. /** HID LEDs Usage page */
  110. #define HID_USAGE_GEN_LEDS 0x08
  111. /** HID Button Usage page */
  112. #define HID_USAGE_GEN_BUTTON 0x09
  113. /** HID Generic Desktop Undefined Usage ID */
  114. #define HID_USAGE_GEN_DESKTOP_UNDEFINED 0x00
  115. /** HID Generic Desktop Pointer Usage ID */
  116. #define HID_USAGE_GEN_DESKTOP_POINTER 0x01
  117. /** HID Generic Desktop Mouse Usage ID */
  118. #define HID_USAGE_GEN_DESKTOP_MOUSE 0x02
  119. /** HID Generic Desktop Joystick Usage ID */
  120. #define HID_USAGE_GEN_DESKTOP_JOYSTICK 0x04
  121. /** HID Generic Desktop Gamepad Usage ID */
  122. #define HID_USAGE_GEN_DESKTOP_GAMEPAD 0x05
  123. /** HID Generic Desktop Keyboard Usage ID */
  124. #define HID_USAGE_GEN_DESKTOP_KEYBOARD 0x06
  125. /** HID Generic Desktop Keypad Usage ID */
  126. #define HID_USAGE_GEN_DESKTOP_KEYPAD 0x07
  127. /** HID Generic Desktop X Usage ID */
  128. #define HID_USAGE_GEN_DESKTOP_X 0x30
  129. /** HID Generic Desktop Y Usage ID */
  130. #define HID_USAGE_GEN_DESKTOP_Y 0x31
  131. /** HID Generic Desktop Wheel Usage ID */
  132. #define HID_USAGE_GEN_DESKTOP_WHEEL 0x38
  133. /**
  134. * @}
  135. */
  136. /**
  137. * @defgroup usb_hid_items USB HID Item helpers
  138. * @ingroup usb_hid_definitions
  139. * @{
  140. */
  141. /**
  142. * @brief Define HID short item.
  143. *
  144. * @param bTag Item tag
  145. * @param bType Item type
  146. * @param bSize Item data size
  147. * @return HID Input item
  148. */
  149. #define HID_ITEM(bTag, bType, bSize) (((bTag & 0xF) << 4) | \
  150. ((bType & 0x3) << 2) | (bSize & 0x3))
  151. /**
  152. * @brief Define HID Input item with the data length of one byte.
  153. *
  154. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  155. * @ref HID_KEYBOARD_REPORT_DESC()
  156. *
  157. * @param a Input item data
  158. * @return HID Input item
  159. */
  160. #define HID_INPUT(a) \
  161. HID_ITEM(HID_ITEM_TAG_INPUT, HID_ITEM_TYPE_MAIN, 1), a
  162. /**
  163. * @brief Define HID Output item with the data length of one byte.
  164. *
  165. * For usage examples, see @ref HID_KEYBOARD_REPORT_DESC()
  166. *
  167. * @param a Output item data
  168. * @return HID Output item
  169. */
  170. #define HID_OUTPUT(a) \
  171. HID_ITEM(HID_ITEM_TAG_OUTPUT, HID_ITEM_TYPE_MAIN, 1), a
  172. /**
  173. * @brief Define HID Feature item with the data length of one byte.
  174. *
  175. * @param a Feature item data
  176. * @return HID Feature item
  177. */
  178. #define HID_FEATURE(a) \
  179. HID_ITEM(HID_ITEM_TAG_OUTPUT, HID_ITEM_TYPE_MAIN, 1), a
  180. /**
  181. * @brief Define HID Collection item with the data length of one byte.
  182. *
  183. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  184. * @ref HID_KEYBOARD_REPORT_DESC()
  185. *
  186. * @param a Collection item data
  187. * @return HID Collection item
  188. */
  189. #define HID_COLLECTION(a) \
  190. HID_ITEM(HID_ITEM_TAG_COLLECTION, HID_ITEM_TYPE_MAIN, 1), a
  191. /**
  192. * @brief Define HID End Collection (non-data) item.
  193. *
  194. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  195. * @ref HID_KEYBOARD_REPORT_DESC()
  196. *
  197. * @return HID End Collection item
  198. */
  199. #define HID_END_COLLECTION \
  200. HID_ITEM(HID_ITEM_TAG_COLLECTION_END, HID_ITEM_TYPE_MAIN, 0)
  201. /**
  202. * @brief Define HID Usage Page item.
  203. *
  204. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  205. * @ref HID_KEYBOARD_REPORT_DESC()
  206. *
  207. * @param page Usage Page
  208. * @return HID Usage Page item
  209. */
  210. #define HID_USAGE_PAGE(page) \
  211. HID_ITEM(HID_ITEM_TAG_USAGE_PAGE, HID_ITEM_TYPE_GLOBAL, 1), page
  212. /**
  213. * @brief Define HID Logical Minimum item with the data length of one byte.
  214. *
  215. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  216. * @ref HID_KEYBOARD_REPORT_DESC()
  217. *
  218. * @param a Minimum value in logical units
  219. * @return HID Logical Minimum item
  220. */
  221. #define HID_LOGICAL_MIN8(a) \
  222. HID_ITEM(HID_ITEM_TAG_LOGICAL_MIN, HID_ITEM_TYPE_GLOBAL, 1), a
  223. /**
  224. * @brief Define HID Logical Maximum item with the data length of one byte.
  225. *
  226. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  227. * @ref HID_KEYBOARD_REPORT_DESC()
  228. *
  229. * @param a Maximum value in logical units
  230. * @return HID Logical Maximum item
  231. */
  232. #define HID_LOGICAL_MAX8(a) \
  233. HID_ITEM(HID_ITEM_TAG_LOGICAL_MAX, HID_ITEM_TYPE_GLOBAL, 1), a
  234. /**
  235. * @brief Define HID Logical Minimum item with the data length of two bytes.
  236. *
  237. * @param a Minimum value lower byte
  238. * @param b Minimum value higher byte
  239. * @return HID Logical Minimum item
  240. */
  241. #define HID_LOGICAL_MIN16(a, b) \
  242. HID_ITEM(HID_ITEM_TAG_LOGICAL_MIN, HID_ITEM_TYPE_GLOBAL, 2), a, b
  243. /**
  244. * @brief Define HID Logical Maximum item with the data length of two bytes.
  245. *
  246. * @param a Minimum value lower byte
  247. * @param b Minimum value higher byte
  248. * @return HID Logical Maximum item
  249. */
  250. #define HID_LOGICAL_MAX16(a, b) \
  251. HID_ITEM(HID_ITEM_TAG_LOGICAL_MAX, HID_ITEM_TYPE_GLOBAL, 2), a, b
  252. /**
  253. * @brief Define HID Logical Minimum item with the data length of four bytes.
  254. *
  255. * @param a Minimum value lower byte
  256. * @param b Minimum value low middle byte
  257. * @param c Minimum value high middle byte
  258. * @param d Minimum value higher byte
  259. * @return HID Logical Minimum item
  260. */
  261. #define HID_LOGICAL_MIN32(a, b, c, d) \
  262. HID_ITEM(HID_ITEM_TAG_LOGICAL_MIN, HID_ITEM_TYPE_GLOBAL, 3), a, b, c, d
  263. /**
  264. * @brief Define HID Logical Maximum item with the data length of four bytes.
  265. *
  266. * @param a Minimum value lower byte
  267. * @param b Minimum value low middle byte
  268. * @param c Minimum value high middle byte
  269. * @param d Minimum value higher byte
  270. * @return HID Logical Maximum item
  271. */
  272. #define HID_LOGICAL_MAX32(a, b, c, d) \
  273. HID_ITEM(HID_ITEM_TAG_LOGICAL_MAX, HID_ITEM_TYPE_GLOBAL, 3), a, b, c, d
  274. /**
  275. * @brief Define HID Report Size item with the data length of one byte.
  276. *
  277. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  278. * @ref HID_KEYBOARD_REPORT_DESC()
  279. *
  280. * @param size Report field size in bits
  281. * @return HID Report Size item
  282. */
  283. #define HID_REPORT_SIZE(size) \
  284. HID_ITEM(HID_ITEM_TAG_REPORT_SIZE, HID_ITEM_TYPE_GLOBAL, 1), size
  285. /**
  286. * @brief Define HID Report ID item with the data length of one byte.
  287. *
  288. * @param id Report ID
  289. * @return HID Report ID item
  290. */
  291. #define HID_REPORT_ID(id) \
  292. HID_ITEM(HID_ITEM_TAG_REPORT_ID, HID_ITEM_TYPE_GLOBAL, 1), id
  293. /**
  294. * @brief Define HID Report Count item with the data length of one byte.
  295. *
  296. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  297. * @ref HID_KEYBOARD_REPORT_DESC()
  298. *
  299. * @param count Number of data fields included in the report
  300. * @return HID Report Count item
  301. */
  302. #define HID_REPORT_COUNT(count) \
  303. HID_ITEM(HID_ITEM_TAG_REPORT_COUNT, HID_ITEM_TYPE_GLOBAL, 1), count
  304. /**
  305. * @brief Define HID Usage Index item with the data length of one byte.
  306. *
  307. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  308. * @ref HID_KEYBOARD_REPORT_DESC()
  309. *
  310. * @param idx Number of data fields included in the report
  311. * @return HID Usage Index item
  312. */
  313. #define HID_USAGE(idx) \
  314. HID_ITEM(HID_ITEM_TAG_USAGE, HID_ITEM_TYPE_LOCAL, 1), idx
  315. /**
  316. * @brief Define HID Usage Minimum item with the data length of one byte.
  317. *
  318. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  319. * @ref HID_KEYBOARD_REPORT_DESC()
  320. *
  321. * @param a Starting Usage
  322. * @return HID Usage Minimum item
  323. */
  324. #define HID_USAGE_MIN8(a) \
  325. HID_ITEM(HID_ITEM_TAG_USAGE_MIN, HID_ITEM_TYPE_LOCAL, 1), a
  326. /**
  327. * @brief Define HID Usage Maximum item with the data length of one byte.
  328. *
  329. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  330. * @ref HID_KEYBOARD_REPORT_DESC()
  331. *
  332. * @param a Ending Usage
  333. * @return HID Usage Maximum item
  334. */
  335. #define HID_USAGE_MAX8(a) \
  336. HID_ITEM(HID_ITEM_TAG_USAGE_MAX, HID_ITEM_TYPE_LOCAL, 1), a
  337. /**
  338. * @brief Define HID Usage Minimum item with the data length of two bytes.
  339. *
  340. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  341. * @ref HID_KEYBOARD_REPORT_DESC()
  342. *
  343. * @param a Starting Usage lower byte
  344. * @param b Starting Usage higher byte
  345. * @return HID Usage Minimum item
  346. */
  347. #define HID_USAGE_MIN16(a, b) \
  348. HID_ITEM(HID_ITEM_TAG_USAGE_MIN, HID_ITEM_TYPE_LOCAL, 2), a, b
  349. /**
  350. * @brief Define HID Usage Maximum item with the data length of two bytes.
  351. *
  352. * For usage examples, see @ref HID_MOUSE_REPORT_DESC(),
  353. * @ref HID_KEYBOARD_REPORT_DESC()
  354. *
  355. * @param a Ending Usage lower byte
  356. * @param b Ending Usage higher byte
  357. * @return HID Usage Maximum item
  358. */
  359. #define HID_USAGE_MAX16(a, b) \
  360. HID_ITEM(HID_ITEM_TAG_USAGE_MAX, HID_ITEM_TYPE_LOCAL, 2), a, b
  361. /**
  362. * @}
  363. */
  364. /**
  365. * @defgroup usb_hid_mk_report_desc Mouse and keyboard report descriptors
  366. * @ingroup usb_hid_definitions
  367. * @{
  368. */
  369. /**
  370. * @brief Simple HID mouse report descriptor for n button mouse.
  371. *
  372. * @param bcnt Button count. Allowed values from 1 to 8.
  373. */
  374. #define HID_MOUSE_REPORT_DESC(bcnt) { \
  375. HID_USAGE_PAGE(HID_USAGE_GEN_DESKTOP), \
  376. HID_USAGE(HID_USAGE_GEN_DESKTOP_MOUSE), \
  377. HID_COLLECTION(HID_COLLECTION_APPLICATION), \
  378. HID_USAGE(HID_USAGE_GEN_DESKTOP_POINTER), \
  379. HID_COLLECTION(HID_COLLECTION_PHYSICAL), \
  380. /* Bits used for button signalling */ \
  381. HID_USAGE_PAGE(HID_USAGE_GEN_BUTTON), \
  382. HID_USAGE_MIN8(1), \
  383. HID_USAGE_MAX8(bcnt), \
  384. HID_LOGICAL_MIN8(0), \
  385. HID_LOGICAL_MAX8(1), \
  386. HID_REPORT_SIZE(1), \
  387. HID_REPORT_COUNT(bcnt), \
  388. /* HID_INPUT (Data,Var,Abs) */ \
  389. HID_INPUT(0x02), \
  390. /* Unused bits */ \
  391. HID_REPORT_SIZE(8 - bcnt), \
  392. HID_REPORT_COUNT(1), \
  393. /* HID_INPUT (Cnst,Ary,Abs) */ \
  394. HID_INPUT(1), \
  395. /* X and Y axis, scroll */ \
  396. HID_USAGE_PAGE(HID_USAGE_GEN_DESKTOP), \
  397. HID_USAGE(HID_USAGE_GEN_DESKTOP_X), \
  398. HID_USAGE(HID_USAGE_GEN_DESKTOP_Y), \
  399. HID_USAGE(HID_USAGE_GEN_DESKTOP_WHEEL), \
  400. HID_LOGICAL_MIN8(-127), \
  401. HID_LOGICAL_MAX8(127), \
  402. HID_REPORT_SIZE(8), \
  403. HID_REPORT_COUNT(3), \
  404. /* HID_INPUT (Data,Var,Rel) */ \
  405. HID_INPUT(0x06), \
  406. HID_END_COLLECTION, \
  407. HID_END_COLLECTION, \
  408. }
  409. /**
  410. * @brief Simple HID keyboard report descriptor.
  411. */
  412. #define HID_KEYBOARD_REPORT_DESC() { \
  413. HID_USAGE_PAGE(HID_USAGE_GEN_DESKTOP), \
  414. HID_USAGE(HID_USAGE_GEN_DESKTOP_KEYBOARD), \
  415. HID_COLLECTION(HID_COLLECTION_APPLICATION), \
  416. HID_USAGE_PAGE(HID_USAGE_GEN_DESKTOP_KEYPAD), \
  417. /* HID_USAGE_MINIMUM(Keyboard LeftControl) */ \
  418. HID_USAGE_MIN8(0xE0), \
  419. /* HID_USAGE_MAXIMUM(Keyboard Right GUI) */ \
  420. HID_USAGE_MAX8(0xE7), \
  421. HID_LOGICAL_MIN8(0), \
  422. HID_LOGICAL_MAX8(1), \
  423. HID_REPORT_SIZE(1), \
  424. HID_REPORT_COUNT(8), \
  425. /* HID_INPUT(Data,Var,Abs) */ \
  426. HID_INPUT(0x02), \
  427. HID_REPORT_SIZE(8), \
  428. HID_REPORT_COUNT(1), \
  429. /* HID_INPUT(Cnst,Var,Abs) */ \
  430. HID_INPUT(0x03), \
  431. HID_REPORT_SIZE(1), \
  432. HID_REPORT_COUNT(5), \
  433. HID_USAGE_PAGE(HID_USAGE_GEN_LEDS), \
  434. /* HID_USAGE_MINIMUM(Num Lock) */ \
  435. HID_USAGE_MIN8(1), \
  436. /* HID_USAGE_MAXIMUM(Kana) */ \
  437. HID_USAGE_MAX8(5), \
  438. /* HID_OUTPUT(Data,Var,Abs) */ \
  439. HID_OUTPUT(0x02), \
  440. HID_REPORT_SIZE(3), \
  441. HID_REPORT_COUNT(1), \
  442. /* HID_OUTPUT(Cnst,Var,Abs) */ \
  443. HID_OUTPUT(0x03), \
  444. HID_REPORT_SIZE(8), \
  445. HID_REPORT_COUNT(6), \
  446. HID_LOGICAL_MIN8(0), \
  447. HID_LOGICAL_MAX8(101), \
  448. HID_USAGE_PAGE(HID_USAGE_GEN_DESKTOP_KEYPAD), \
  449. /* HID_USAGE_MIN8(Reserved) */ \
  450. HID_USAGE_MIN8(0), \
  451. /* HID_USAGE_MAX8(Keyboard Application) */ \
  452. HID_USAGE_MAX8(101), \
  453. /* HID_INPUT (Data,Ary,Abs) */ \
  454. HID_INPUT(0x00), \
  455. HID_END_COLLECTION, \
  456. }
  457. /**
  458. * @brief HID keyboard button codes.
  459. */
  460. enum hid_kbd_code {
  461. HID_KEY_A = 4,
  462. HID_KEY_B = 5,
  463. HID_KEY_C = 6,
  464. HID_KEY_D = 7,
  465. HID_KEY_E = 8,
  466. HID_KEY_F = 9,
  467. HID_KEY_G = 10,
  468. HID_KEY_H = 11,
  469. HID_KEY_I = 12,
  470. HID_KEY_J = 13,
  471. HID_KEY_K = 14,
  472. HID_KEY_L = 15,
  473. HID_KEY_M = 16,
  474. HID_KEY_N = 17,
  475. HID_KEY_O = 18,
  476. HID_KEY_P = 19,
  477. HID_KEY_Q = 20,
  478. HID_KEY_R = 21,
  479. HID_KEY_S = 22,
  480. HID_KEY_T = 23,
  481. HID_KEY_U = 24,
  482. HID_KEY_V = 25,
  483. HID_KEY_W = 26,
  484. HID_KEY_X = 27,
  485. HID_KEY_Y = 28,
  486. HID_KEY_Z = 29,
  487. HID_KEY_1 = 30,
  488. HID_KEY_2 = 31,
  489. HID_KEY_3 = 32,
  490. HID_KEY_4 = 33,
  491. HID_KEY_5 = 34,
  492. HID_KEY_6 = 35,
  493. HID_KEY_7 = 36,
  494. HID_KEY_8 = 37,
  495. HID_KEY_9 = 38,
  496. HID_KEY_0 = 39,
  497. HID_KEY_ENTER = 40,
  498. HID_KEY_ESC = 41,
  499. HID_KEY_BACKSPACE = 42,
  500. HID_KEY_TAB = 43,
  501. HID_KEY_SPACE = 44,
  502. HID_KEY_MINUS = 45,
  503. HID_KEY_EQUAL = 46,
  504. HID_KEY_LEFTBRACE = 47,
  505. HID_KEY_RIGHTBRACE = 48,
  506. HID_KEY_BACKSLASH = 49,
  507. HID_KEY_HASH = 50, /* Non-US # and ~ */
  508. HID_KEY_SEMICOLON = 51,
  509. HID_KEY_APOSTROPHE = 52,
  510. HID_KEY_GRAVE = 53,
  511. HID_KEY_COMMA = 54,
  512. HID_KEY_DOT = 55,
  513. HID_KEY_SLASH = 56,
  514. HID_KEY_CAPSLOCK = 57,
  515. HID_KEY_F1 = 58,
  516. HID_KEY_F2 = 59,
  517. HID_KEY_F3 = 60,
  518. HID_KEY_F4 = 61,
  519. HID_KEY_F5 = 62,
  520. HID_KEY_F6 = 63,
  521. HID_KEY_F7 = 64,
  522. HID_KEY_F8 = 65,
  523. HID_KEY_F9 = 66,
  524. HID_KEY_F10 = 67,
  525. HID_KEY_F11 = 68,
  526. HID_KEY_F12 = 69,
  527. HID_KEY_SYSRQ = 70, /* PRINTSCREEN */
  528. HID_KEY_SCROLLLOCK = 71,
  529. HID_KEY_PAUSE = 72,
  530. HID_KEY_INSERT = 73,
  531. HID_KEY_HOME = 74,
  532. HID_KEY_PAGEUP = 75,
  533. HID_KEY_DELETE = 76,
  534. HID_KEY_END = 77,
  535. HID_KEY_PAGEDOWN = 78,
  536. HID_KEY_RIGHT = 79,
  537. HID_KEY_LEFT = 80,
  538. HID_KEY_DOWN = 81,
  539. HID_KEY_UP = 82,
  540. HID_KEY_NUMLOCK = 83,
  541. HID_KEY_KPSLASH = 84, /* NUMPAD DIVIDE */
  542. HID_KEY_KPASTERISK = 85, /* NUMPAD MULTIPLY */
  543. HID_KEY_KPMINUS = 86,
  544. HID_KEY_KPPLUS = 87,
  545. HID_KEY_KPENTER = 88,
  546. HID_KEY_KP_1 = 89,
  547. HID_KEY_KP_2 = 90,
  548. HID_KEY_KP_3 = 91,
  549. HID_KEY_KP_4 = 92,
  550. HID_KEY_KP_5 = 93,
  551. HID_KEY_KP_6 = 94,
  552. HID_KEY_KP_7 = 95,
  553. HID_KEY_KP_8 = 96,
  554. HID_KEY_KP_9 = 97,
  555. HID_KEY_KP_0 = 98,
  556. };
  557. /**
  558. * @brief HID keyboard modifiers.
  559. */
  560. enum hid_kbd_modifier {
  561. HID_KBD_MODIFIER_NONE = 0x00,
  562. HID_KBD_MODIFIER_LEFT_CTRL = 0x01,
  563. HID_KBD_MODIFIER_LEFT_SHIFT = 0x02,
  564. HID_KBD_MODIFIER_LEFT_ALT = 0x04,
  565. HID_KBD_MODIFIER_LEFT_UI = 0x08,
  566. HID_KBD_MODIFIER_RIGHT_CTRL = 0x10,
  567. HID_KBD_MODIFIER_RIGHT_SHIFT = 0x20,
  568. HID_KBD_MODIFIER_RIGHT_ALT = 0x40,
  569. HID_KBD_MODIFIER_RIGHT_UI = 0x80,
  570. };
  571. /**
  572. * @brief HID keyboard LEDs.
  573. */
  574. enum hid_kbd_led {
  575. HID_KBD_LED_NUM_LOCK = 0x01,
  576. HID_KBD_LED_CAPS_LOCK = 0x02,
  577. HID_KBD_LED_SCROLL_LOCK = 0x04,
  578. HID_KBD_LED_COMPOSE = 0x08,
  579. HID_KBD_LED_KANA = 0x10,
  580. };
  581. /**
  582. * @}
  583. */
  584. #ifdef __cplusplus
  585. }
  586. #endif
  587. #endif /* ZEPHYR_INCLUDE_USB_CLASS_HID_H_ */