usbhid.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. //*****************************************************************************
  2. //
  3. // usbhid.h - Definitions used by HID class devices and hosts.
  4. //
  5. // Copyright (c) 2008-2010 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of AM1808 StarterWare USB Library and reused from revision 6288
  22. // of the Stellaris USB Library.
  23. //
  24. //*****************************************************************************
  25. #ifndef __USBHID_H__
  26. #define __USBHID_H__
  27. //*****************************************************************************
  28. //
  29. // If building with a C++ compiler, make all of the definitions in this header
  30. // have a C binding.
  31. //
  32. //*****************************************************************************
  33. #ifdef __cplusplus
  34. extern "C"
  35. {
  36. #endif
  37. //*****************************************************************************
  38. //
  39. //! \addtogroup hid_device_class_api
  40. //! @{
  41. //
  42. //*****************************************************************************
  43. //*****************************************************************************
  44. //
  45. // HID Interface descriptor Subclasses.
  46. //
  47. //*****************************************************************************
  48. #define USB_HID_SCLASS_NONE 0x00
  49. #define USB_HID_SCLASS_BOOT 0x01
  50. //*****************************************************************************
  51. //
  52. // USB Interface descriptor HID protocols.
  53. //
  54. //*****************************************************************************
  55. #define USB_HID_PROTOCOL_NONE 0
  56. #define USB_HID_PROTOCOL_KEYB 1
  57. #define USB_HID_PROTOCOL_MOUSE 2
  58. //*****************************************************************************
  59. //
  60. // HID Class descriptor types.
  61. //
  62. //*****************************************************************************
  63. #define USB_HID_DTYPE_HID 0x21
  64. #define USB_HID_DTYPE_REPORT 0x22
  65. #define USB_HID_DTYPE_PHYSICAL 0x23
  66. //*****************************************************************************
  67. //
  68. // HID USB requests.
  69. //
  70. //*****************************************************************************
  71. #define USBREQ_GET_REPORT 0x01
  72. #define USBREQ_GET_IDLE 0x02
  73. #define USBREQ_GET_PROTOCOL 0x03
  74. #define USBREQ_SET_REPORT 0x09
  75. #define USBREQ_SET_IDLE 0x0a
  76. #define USBREQ_SET_PROTOCOL 0x0b
  77. //*****************************************************************************
  78. //
  79. // GET_REPORT or SET_REPORT Definitions.
  80. //
  81. //*****************************************************************************
  82. #define USB_HID_REPORT_IN 0x01
  83. #define USB_HID_REPORT_OUTPUT 0x02
  84. #define USB_HID_REPORT_FEATURE 0x03
  85. //*****************************************************************************
  86. //
  87. // GET_PROTOCOL or SET_PROTOCOL Definitions.
  88. //
  89. //*****************************************************************************
  90. #define USB_HID_PROTOCOL_BOOT 0
  91. #define USB_HID_PROTOCOL_REPORT 1
  92. //*****************************************************************************
  93. //
  94. // Report Values used with the Report macros.
  95. //
  96. //*****************************************************************************
  97. #define USB_HID_GENERIC_DESKTOP 0x01
  98. #define USB_HID_BUTTONS 0x09
  99. #define USB_HID_X 0x30
  100. #define USB_HID_Y 0x31
  101. #define USB_HID_POINTER 0x01
  102. #define USB_HID_MOUSE 0x02
  103. #define USB_HID_KEYBOARD 0x06
  104. #define USB_HID_APPLICATION 0x01
  105. #define USB_HID_PHYSICAL 0x00
  106. #define USB_HID_USAGE_POINTER 0x0109
  107. #define USB_HID_USAGE_BUTTONS 0x0509
  108. #define USB_HID_USAGE_LEDS 0x0508
  109. #define USB_HID_USAGE_KEYCODES 0x0507
  110. //*****************************************************************************
  111. //
  112. // HID mouse button definitions as used in the first byte of the output report
  113. // used in the BIOS mouse protocol.
  114. //
  115. //*****************************************************************************
  116. #define HID_MOUSE_BUTTON_1 0x01
  117. #define HID_MOUSE_BUTTON_2 0x02
  118. #define HID_MOUSE_BUTTON_3 0x04
  119. //*****************************************************************************
  120. //
  121. // HID Keyboard LED definitions as used in the first byte of the output report
  122. // used in the BIOS keyboard protocol.
  123. //
  124. //*****************************************************************************
  125. #define HID_KEYB_NUM_LOCK 0x01
  126. #define HID_KEYB_CAPS_LOCK 0x02
  127. #define HID_KEYB_SCROLL_LOCK 0x04
  128. #define HID_KEYB_COMPOSE 0x08
  129. #define HID_KEYB_KANA 0x10
  130. //*****************************************************************************
  131. //
  132. // HID Keyboard key modifiers as provided in the first byte of the input report
  133. // used in the BIOS keyboard protocol.
  134. //
  135. //*****************************************************************************
  136. #define HID_KEYB_LEFT_CTRL 0x01
  137. #define HID_KEYB_LEFT_SHIFT 0x02
  138. #define HID_KEYB_LEFT_ALT 0x04
  139. #define HID_KEYB_LEFT_GUI 0x08
  140. #define HID_KEYB_RIGHT_CTRL 0x10
  141. #define HID_KEYB_RIGHT_SHIFT 0x20
  142. #define HID_KEYB_RIGHT_ALT 0x40
  143. #define HID_KEYB_RIGHT_GUI 0x80
  144. //*****************************************************************************
  145. //
  146. // A subset of the HID keyboard usage IDs.
  147. //
  148. //*****************************************************************************
  149. #define HID_KEYB_USAGE_RESERVED 0x00
  150. #define HID_KEYB_USAGE_ROLLOVER 0x01
  151. #define HID_KEYB_USAGE_A 0x04
  152. #define HID_KEYB_USAGE_B 0x05
  153. #define HID_KEYB_USAGE_C 0x06
  154. #define HID_KEYB_USAGE_D 0x07
  155. #define HID_KEYB_USAGE_E 0x08
  156. #define HID_KEYB_USAGE_F 0x09
  157. #define HID_KEYB_USAGE_G 0x0A
  158. #define HID_KEYB_USAGE_H 0x0B
  159. #define HID_KEYB_USAGE_I 0x0C
  160. #define HID_KEYB_USAGE_J 0x0D
  161. #define HID_KEYB_USAGE_K 0x0E
  162. #define HID_KEYB_USAGE_L 0x0F
  163. #define HID_KEYB_USAGE_M 0x10
  164. #define HID_KEYB_USAGE_N 0x11
  165. #define HID_KEYB_USAGE_O 0x12
  166. #define HID_KEYB_USAGE_P 0x13
  167. #define HID_KEYB_USAGE_Q 0x14
  168. #define HID_KEYB_USAGE_R 0x15
  169. #define HID_KEYB_USAGE_S 0x16
  170. #define HID_KEYB_USAGE_T 0x17
  171. #define HID_KEYB_USAGE_U 0x18
  172. #define HID_KEYB_USAGE_V 0x19
  173. #define HID_KEYB_USAGE_W 0x1A
  174. #define HID_KEYB_USAGE_X 0x1B
  175. #define HID_KEYB_USAGE_Y 0x1C
  176. #define HID_KEYB_USAGE_Z 0x1D
  177. #define HID_KEYB_USAGE_1 0x1E
  178. #define HID_KEYB_USAGE_2 0x1F
  179. #define HID_KEYB_USAGE_3 0x20
  180. #define HID_KEYB_USAGE_4 0x21
  181. #define HID_KEYB_USAGE_5 0x22
  182. #define HID_KEYB_USAGE_6 0x23
  183. #define HID_KEYB_USAGE_7 0x24
  184. #define HID_KEYB_USAGE_8 0x25
  185. #define HID_KEYB_USAGE_9 0x26
  186. #define HID_KEYB_USAGE_0 0x27
  187. #define HID_KEYB_USAGE_ENTER 0x28
  188. #define HID_KEYB_USAGE_ESCAPE 0x29
  189. #define HID_KEYB_USAGE_BACKSPACE \
  190. 0x2A
  191. #define HID_KEYB_USAGE_TAB 0x2B
  192. #define HID_KEYB_USAGE_SPACE 0x2C
  193. #define HID_KEYB_USAGE_MINUS 0x2D
  194. #define HID_KEYB_USAGE_EQUAL 0x2E
  195. #define HID_KEYB_USAGE_LBRACKET 0x2F
  196. #define HID_KEYB_USAGE_RBRACKET 0x30
  197. #define HID_KEYB_USAGE_BSLASH 0x31
  198. #define HID_KEYB_USAGE_SEMICOLON \
  199. 0x33
  200. #define HID_KEYB_USAGE_FQUOTE 0x34
  201. #define HID_KEYB_USAGE_BQUOTE 0x35
  202. #define HID_KEYB_USAGE_COMMA 0x36
  203. #define HID_KEYB_USAGE_PERIOD 0x37
  204. #define HID_KEYB_USAGE_FSLASH 0x38
  205. #define HID_KEYB_USAGE_CAPSLOCK 0x39
  206. #define HID_KEYB_USAGE_F1 0x3A
  207. #define HID_KEYB_USAGE_F2 0x3B
  208. #define HID_KEYB_USAGE_F3 0x3C
  209. #define HID_KEYB_USAGE_F4 0x3D
  210. #define HID_KEYB_USAGE_F5 0x3E
  211. #define HID_KEYB_USAGE_F6 0x3F
  212. #define HID_KEYB_USAGE_F7 0x40
  213. #define HID_KEYB_USAGE_F8 0x41
  214. #define HID_KEYB_USAGE_F9 0x42
  215. #define HID_KEYB_USAGE_F10 0x43
  216. #define HID_KEYB_USAGE_F11 0x44
  217. #define HID_KEYB_USAGE_F12 0x45
  218. #define HID_KEYB_USAGE_RIGHT_ARROW \
  219. 0x4F
  220. #define HID_KEYB_USAGE_LEFT_ARROW \
  221. 0x50
  222. #define HID_KEYB_USAGE_DOWN_ARROW \
  223. 0x51
  224. #define HID_KEYB_USAGE_UP_ARROW 0x52
  225. #define HID_KEYB_USAGE_KEYPAD_SLASH \
  226. 0x54
  227. #define HID_KEYB_USAGE_KEYPAD_STAR \
  228. 0x55
  229. #define HID_KEYB_USAGE_KEYPAD_MINUS \
  230. 0x56
  231. #define HID_KEYB_USAGE_KEYPAD_PLUS \
  232. 0x57
  233. #define HID_KEYB_USAGE_KEPAD_ENTER \
  234. 0x58
  235. #define HID_KEYB_USAGE_KEYPAD_1 0x59
  236. #define HID_KEYB_USAGE_KEYPAD_2 0x5A
  237. #define HID_KEYB_USAGE_KEYPAD_3 0x5B
  238. #define HID_KEYB_USAGE_KEYPAD_4 0x5C
  239. #define HID_KEYB_USAGE_KEYPAD_5 0x5D
  240. #define HID_KEYB_USAGE_KEYPAD_6 0x5E
  241. #define HID_KEYB_USAGE_KEYPAD_7 0x5F
  242. #define HID_KEYB_USAGE_KEYPAD_8 0x60
  243. #define HID_KEYB_USAGE_KEYPAD_9 0x61
  244. #define HID_KEYB_USAGE_KEYPAD_0 0x62
  245. #define HID_KEYB_USAGE_KEPAD_PERIOD \
  246. 0x63
  247. //*****************************************************************************
  248. //
  249. // HID descriptor country codes (most of these are described as "countries" in
  250. // the HID specification even though they are really languages).
  251. //
  252. //*****************************************************************************
  253. #define USB_HID_COUNTRY_NONE 0x00
  254. #define USB_HID_COUNTRY_ARABIC 0x01
  255. #define USB_HID_COUNTRY_BELGIAN 0x02
  256. #define USB_HID_COUNTRY_CANADA_BI \
  257. 0x03
  258. #define USB_HID_COUNTRY_CANADA_FR \
  259. 0x04
  260. #define USB_HID_COUNTRY_CZECH_REPUBLIC \
  261. 0x05
  262. #define USB_HID_COUNTRY_DANISH 0x06
  263. #define USB_HID_COUNTRY_FINNISH 0x07
  264. #define USB_HID_COUNTRY_FRENCH 0x08
  265. #define USB_HID_COUNTRY_GERMAN 0x09
  266. #define USB_HID_COUNTRY_GREEK 0x0A
  267. #define USB_HID_COUNTRY_HEBREW 0x0B
  268. #define USB_HID_COUNTRY_HUNGARY 0x0C
  269. #define USB_HID_COUNTRY_INTERNATIONAL_ISO \
  270. 0x0D
  271. #define USB_HID_COUNTRY_ITALIAN 0x0E
  272. #define USB_HID_COUNTRY_JAPAN_KATAKANA \
  273. 0x0F
  274. #define USB_HID_COUNTRY_KOREAN 0x10
  275. #define USB_HID_COUNTRY_LATIN_AMERICAN \
  276. 0x11
  277. #define USB_HID_COUNTRY_NETHERLANDS \
  278. 0x12
  279. #define USB_HID_COUNTRY_NORWEGIAN \
  280. 0x13
  281. #define USB_HID_COUNTRY_PERSIAN 0x14
  282. #define USB_HID_COUNTRY_POLAND 0x15
  283. #define USB_HID_COUNTRY_PORTUGUESE \
  284. 0x16
  285. #define USB_HID_COUNTRY_RUSSIA 0x17
  286. #define USB_HID_COUNTRY_SLOVAKIA \
  287. 0x18
  288. #define USB_HID_COUNTRY_SPANISH 0x19
  289. #define USB_HID_COUNTRY_SWEDISH 0x1A
  290. #define USB_HID_COUNTRY_SWISS_FRENCH \
  291. 0x1B
  292. #define USB_HID_COUNTRY_SWISS_GERMAN \
  293. 0x1C
  294. #define USB_HID_COUNTRY_SWITZERLAND \
  295. 0x1D
  296. #define USB_HID_COUNTRY_TAIWAN 0x1E
  297. #define USB_HID_COUNTRY_TURKISH_Q \
  298. 0x1F
  299. #define USB_HID_COUNTRY_UK 0x20
  300. #define USB_HID_COUNTRY_US 0x21
  301. #define USB_HID_COUNTRY_YUGOSLAVIA \
  302. 0x22
  303. #define USB_HID_COUNTRY_TURKISH_F \
  304. 0x23
  305. //*****************************************************************************
  306. //
  307. // Data flags used in Input item tags within report descriptors.
  308. //
  309. //*****************************************************************************
  310. #define USB_HID_INPUT_DATA 0x0000
  311. #define USB_HID_INPUT_CONSTANT 0x0001
  312. #define USB_HID_INPUT_ARRAY 0x0000
  313. #define USB_HID_INPUT_VARIABLE 0x0002
  314. #define USB_HID_INPUT_ABS 0x0000
  315. #define USB_HID_INPUT_RELATIVE 0x0004
  316. #define USB_HID_INPUT_NOWRAP 0x0000
  317. #define USB_HID_INPUT_WRAP 0x0008
  318. #define USB_HID_INPUT_LINEAR 0x0000
  319. #define USB_HID_INPUT_NONLINEAR 0x0010
  320. #define USB_HID_INPUT_PREFER 0x0000
  321. #define USB_HID_INPUT_NONPREFER 0x0020
  322. #define USB_HID_INPUT_NONULL 0x0000
  323. #define USB_HID_INPUT_NULL 0x0040
  324. #define USB_HID_INPUT_NONVOLATILE 0x0000
  325. #define USB_HID_INPUT_VOLATILE 0x0080
  326. #define USB_HID_INPUT_BITF 0x0000
  327. #define USB_HID_INPUT_BYTES 0x0100
  328. //*****************************************************************************
  329. //
  330. // Data flags used in Feature item tags within report descriptors.
  331. //
  332. //*****************************************************************************
  333. #define USB_HID_FEATURE_DATA 0x0000
  334. #define USB_HID_FEATURE_CONSTANT \
  335. 0x0001
  336. #define USB_HID_FEATURE_ARRAY 0x0000
  337. #define USB_HID_FEATURE_VARIABLE \
  338. 0x0002
  339. #define USB_HID_FEATURE_ABS 0x0000
  340. #define USB_HID_FEATURE_RELATIVE \
  341. 0x0004
  342. #define USB_HID_FEATURE_NOWRAP 0x0000
  343. #define USB_HID_FEATURE_WRAP 0x0008
  344. #define USB_HID_FEATURE_LINEAR 0x0000
  345. #define USB_HID_FEATURE_NONLINEAR \
  346. 0x0010
  347. #define USB_HID_FEATURE_PREFER 0x0000
  348. #define USB_HID_FEATURE_NONPREFER \
  349. 0x0020
  350. #define USB_HID_FEATURE_NONULL 0x0000
  351. #define USB_HID_FEATURE_NULL 0x0040
  352. #define USB_HID_FEATURE_NONVOLATILE 0x0000
  353. #define USB_HID_FEATURE_VOLATILE 0x0080
  354. #define USB_HID_FEATURE_BITF 0x0000
  355. #define USB_HID_FEATURE_BYTES 0x0100
  356. //*****************************************************************************
  357. //
  358. // Data flags used in Output item tags within report descriptors.
  359. //
  360. //*****************************************************************************
  361. #define USB_HID_OUTPUT_DATA 0x0000
  362. #define USB_HID_OUTPUT_CONSTANT 0x0001
  363. #define USB_HID_OUTPUT_ARRAY 0x0000
  364. #define USB_HID_OUTPUT_VARIABLE 0x0002
  365. #define USB_HID_OUTPUT_ABS 0x0000
  366. #define USB_HID_OUTPUT_RELATIVE 0x0004
  367. #define USB_HID_OUTPUT_NOWRAP 0x0000
  368. #define USB_HID_OUTPUT_WRAP 0x0008
  369. #define USB_HID_OUTPUT_LINEAR 0x0000
  370. #define USB_HID_OUTPUT_NONLINEAR \
  371. 0x0010
  372. #define USB_HID_OUTPUT_PREFER 0x0000
  373. #define USB_HID_OUTPUT_NONPREFER \
  374. 0x0020
  375. #define USB_HID_OUTPUT_NONULL 0x0000
  376. #define USB_HID_OUTPUT_NULL 0x0040
  377. #define USB_HID_OUTPUT_NONVOLATILE 0x0000
  378. #define USB_HID_OUTPUT_VOLATILE 0x0080
  379. #define USB_HID_OUTPUT_BITF 0x0000
  380. #define USB_HID_OUTPUT_BYTES 0x0100
  381. //*****************************************************************************
  382. //
  383. // Physical descriptor bias values.
  384. //
  385. //*****************************************************************************
  386. #define USB_HID_BIAS_NOT_APPLICABLE \
  387. 0x00
  388. #define USB_HID_BIAS_RIGHT_HAND 0x01
  389. #define USB_HID_BIAS_LEFT_HAND 0x02
  390. #define USB_HID_BIAS_BOTH_HANDS 0x03
  391. #define USB_HID_BIAS_EITHER_HAND \
  392. 0x04
  393. //*****************************************************************************
  394. //
  395. // Physical descriptor designator values.
  396. //
  397. //*****************************************************************************
  398. #define USB_HID_DESIGNATOR_NONE 0x00
  399. #define USB_HID_DESIGNATOR_HAND 0x01
  400. #define USB_HID_DESIGNATOR_EYEBALL \
  401. 0x02
  402. #define USB_HID_DESIGNATOR_EYEBROW \
  403. 0x03
  404. #define USB_HID_DESIGNATOR_EYELID \
  405. 0x04
  406. #define USB_HID_DESIGNATOR_EAR 0x05
  407. #define USB_HID_DESIGNATOR_NOSE 0x06
  408. #define USB_HID_DESIGNATOR_MOUTH \
  409. 0x07
  410. #define USB_HID_DESIGNATOR_UPPER_LIP \
  411. 0x08
  412. #define USB_HID_DESIGNATOR_LOWER_LIP \
  413. 0x09
  414. #define USB_HID_DESIGNATOR_JAW 0x0A
  415. #define USB_HID_DESIGNATOR_NECK 0x0B
  416. #define USB_HID_DESIGNATOR_UPPER_ARM \
  417. 0x0C
  418. #define USB_HID_DESIGNATOR_ELBOW \
  419. 0x0D
  420. #define USB_HID_DESIGNATOR_FOREARM \
  421. 0x0E
  422. #define USB_HID_DESIGNATOR_WRIST \
  423. 0x0F
  424. #define USB_HID_DESIGNATOR_PALM 0x10
  425. #define USB_HID_DESIGNATOR_THUMB \
  426. 0x11
  427. #define USB_HID_DESIGNATOR_INDEX_FINGER \
  428. 0x12
  429. #define USB_HID_DESIGNATOR_MIDDLE_FINGER \
  430. 0x13
  431. #define USB_HID_DESIGNATOR_RING_FINGER \
  432. 0x14
  433. #define USB_HID_DESIGNATOR_LITTLE_FINGER \
  434. 0x15
  435. #define USB_HID_DESIGNATOR_HEAD 0x16
  436. #define USB_HID_DESIGNATOR_SHOULDER \
  437. 0x17
  438. #define USB_HID_DESIGNATOR_HIP 0x18
  439. #define USB_HID_DESIGNATOR_WAIST \
  440. 0x19
  441. #define USB_HID_DESIGNATOR_THIGH \
  442. 0x1A
  443. #define USB_HID_DESIGNATOR_KNEE 0x1B
  444. #define USB_HID_DESIGNATOR_CALF 0x1C
  445. #define USB_HID_DESIGNATOR_ANKLE \
  446. 0x1D
  447. #define USB_HID_DESIGNATOR_FOOT 0x1E
  448. #define USB_HID_DESIGNATOR_HEEL 0x1F
  449. #define USB_HID_DESIGNATOR_BALL_OF_FOOT \
  450. 0x20
  451. #define USB_HID_DESIGNATOR_BIG_TOE \
  452. 0x21
  453. #define USB_HID_DESIGNATOR_SECOND_TOE \
  454. 0x22
  455. #define USB_HID_DESIGNATOR_THIRD_TOE \
  456. 0x23
  457. #define USB_HID_DESIGNATOR_FOURTH_TOE \
  458. 0x24
  459. #define USB_HID_DESIGNATOR_LITTLE_TOE \
  460. 0x25
  461. #define USB_HID_DESIGNATOR_BROW 0x26
  462. #define USB_HID_DESIGNATOR_CHEEK \
  463. 0x27
  464. //*****************************************************************************
  465. //
  466. // Physical descriptor qualifier values.
  467. //
  468. //*****************************************************************************
  469. #define USB_HID_QUALIFIER_NOT_APPLICABLE \
  470. (0x00 << 5)
  471. #define USB_HID_QUALIFIER_RIGHT (0x01 << 5)
  472. #define USB_HID_QUALIFIER_LEFT (0x02 << 5)
  473. #define USB_HID_QUALIFIER_BOTH (0x03 << 5)
  474. #define USB_HID_QUALIFIER_EITHER \
  475. (0x04 << 5)
  476. #define USB_HID_QUALIFIER_CENTER \
  477. (0x05 << 5)
  478. //*****************************************************************************
  479. //
  480. // This is the maximum value for a usage code.
  481. //
  482. //*****************************************************************************
  483. #define USBH_HID_MAX_USAGE 256
  484. #define USBH_HID_CAPS_ARRAY_SZ (USBH_HID_MAX_USAGE/sizeof(unsigned int))
  485. //*****************************************************************************
  486. //
  487. // All structures defined in this section of the header require byte packing of
  488. // fields. This is usually a ccomplished using the USBLIB_PACKED macro but, for IAR
  489. // Embedded Workbench, this requires a pragma.
  490. //
  491. //*****************************************************************************
  492. #if defined(ewarm) || defined(__IAR_SYSTEMS_ICC__)
  493. #pragma pack(1)
  494. #endif
  495. //*****************************************************************************
  496. //
  497. //! The class descriptor information structure is used to announce the presence
  498. //! of HID-specific class descriptors within the HID descriptor.
  499. //
  500. //*****************************************************************************
  501. typedef struct
  502. {
  503. //
  504. //! The type of HID class descriptor. This will be USB_HID_DTYPE_REPORT or
  505. //! USB_HID_DTYPE_PHYSICAL.
  506. //
  507. unsigned char bDescriptorType;
  508. //
  509. //! The total length of the HID class descriptor.
  510. //
  511. unsigned short wDescriptorLength;
  512. }
  513. USBLIB_PACKED tHIDClassDescriptorInfo;
  514. //*****************************************************************************
  515. //
  516. //! The HID descriptor is inserted following the interface descriptor and
  517. //! before the endpoint descriptors for a HID class device.
  518. //
  519. //*****************************************************************************
  520. typedef struct
  521. {
  522. //
  523. //! The length of this descriptor in bytes.
  524. //
  525. unsigned char bLength;
  526. //
  527. //! The type of the descriptor. For a HID descriptor, this will be
  528. //! USB_HID_DTYPE_HID (0x21).
  529. //
  530. unsigned char bDescriptorType;
  531. //
  532. //! A BCD value identifying the HID Class specification release supported
  533. //! by the device. For version 1.11, for example, this value would be
  534. //! 0x0111.
  535. //
  536. unsigned short bcdHID;
  537. //
  538. //! The country code for which this hardware is localized or 0 if no
  539. //! localization has been performed. Valid country (or language) codes are
  540. //! in labels of the form USB_HID_COUNTRY_xxx.
  541. unsigned char bCountryCode;
  542. //
  543. //! The number of class-specific descriptors that exist for this device.
  544. //! This indicates the number of class descriptor information structures
  545. //! that are appended to this structure and must be at least 1 (since all
  546. //! HID devices must publish at least 1 report descriptor).
  547. //
  548. unsigned char bNumDescriptors;
  549. //
  550. //! A table announcing each of the class-specific descriptors that this
  551. //! device publishes. The actual number of entries in the array is given
  552. //! by the bNumDescriptors field.
  553. //
  554. tHIDClassDescriptorInfo sClassDescriptor[1];
  555. }
  556. USBLIB_PACKED tHIDDescriptor;
  557. //*****************************************************************************
  558. //
  559. // Return to default packing when using the IAR Embedded Workbench compiler.
  560. //
  561. //*****************************************************************************
  562. #if defined(ewarm) || defined(__IAR_SYSTEMS_ICC__)
  563. #pragma pack()
  564. #endif
  565. //*****************************************************************************
  566. //
  567. //! This structure defines the mapping of USB usage identifiers to printable
  568. //! characters. The structure has three members that hold this information.
  569. //! The ucBytesPerChar, indicates the number of bytes per character in
  570. //! the table. The pulCapsLock array holds a packed bit array of usage
  571. //! identifiers that can be modified by the Caps Lock key. The pCharMapping
  572. //! array is treated as a double indexed array with two "columns". In the case
  573. //! of a single byte character it is treated as pairs of 8 bit values for
  574. //! unshifted and shifted values. In the case of a double byte characters it is
  575. //! treated as pairs of 16 bit values.
  576. //
  577. //*****************************************************************************
  578. typedef struct
  579. {
  580. //
  581. //! Number of bytes per character in the pCharMapping table of this
  582. //! structure.
  583. //
  584. unsigned char ucBytesPerChar;
  585. //
  586. //! This is a packed bitmasked structure with a one bit flags that
  587. //! indicates if the corresponding Usage ID is affected by the Caps Lock
  588. //! key.
  589. //
  590. unsigned int pulCapsLock[USBH_HID_CAPS_ARRAY_SZ];
  591. //
  592. //! This is the indexed table of Usage ID to character value. It must be
  593. //! at least ucBytesPerChar * 2 * USBH_HID_MAX_USAGE bytes in size as it
  594. //! is treated as a double indexed array.
  595. //
  596. void *pCharMapping;
  597. }
  598. tHIDKeyboardUsageTable;
  599. //*****************************************************************************
  600. //
  601. // The US Keyboard mapping used by USB keyboard usage ID to character mapping.
  602. //
  603. //*****************************************************************************
  604. extern const tHIDKeyboardUsageTable g_sUSKeyboardMap;
  605. //*****************************************************************************
  606. //
  607. // Close the Doxygen group.
  608. //! @}
  609. //
  610. //*****************************************************************************
  611. //*****************************************************************************
  612. //
  613. // Mark the end of the C bindings section for C++ compilers.
  614. //
  615. //*****************************************************************************
  616. #ifdef __cplusplus
  617. }
  618. #endif
  619. #endif // __USBHID_H__