Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HIDClassCommon.h 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2014.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  9. Permission to use, copy, modify, distribute, and sell this
  10. software and its documentation for any purpose is hereby granted
  11. without fee, provided that the above copyright notice appear in
  12. all copies and that both that the copyright notice and this
  13. permission notice and warranty disclaimer appear in supporting
  14. documentation, and that the name of the author not be used in
  15. advertising or publicity pertaining to distribution of the
  16. software without specific, written prior permission.
  17. The author disclaims all warranties with regard to this
  18. software, including all implied warranties of merchantability
  19. and fitness. In no event shall the author be liable for any
  20. special, indirect or consequential damages or any damages
  21. whatsoever resulting from loss of use, data or profits, whether
  22. in an action of contract, negligence or other tortious action,
  23. arising out of or in connection with the use or performance of
  24. this software.
  25. */
  26. /** \file
  27. * \brief Common definitions and declarations for the library USB HID Class driver.
  28. *
  29. * Common definitions and declarations for the library USB HID Class driver.
  30. *
  31. * \note This file should not be included directly. It is automatically included as needed by the USB module driver
  32. * dispatch header located in LUFA/Drivers/USB.h.
  33. */
  34. /** \ingroup Group_USBClassHID
  35. * \defgroup Group_USBClassHIDCommon Common Class Definitions
  36. *
  37. * \section Sec_USBClassHIDCommon_ModDescription Module Description
  38. * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
  39. * HID Class.
  40. *
  41. * @{
  42. */
  43. #ifndef _HID_CLASS_COMMON_H_
  44. #define _HID_CLASS_COMMON_H_
  45. /* Includes: */
  46. #include "../../Core/StdDescriptors.h"
  47. #include "HIDParser.h"
  48. /* Enable C linkage for C++ Compilers: */
  49. #if defined(__cplusplus)
  50. extern "C" {
  51. #endif
  52. /* Preprocessor Checks: */
  53. #if !defined(__INCLUDE_FROM_HID_DRIVER)
  54. #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
  55. #endif
  56. /* Macros: */
  57. /** \name Keyboard Standard Report Modifier Masks */
  58. //@{
  59. /** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */
  60. #define HID_KEYBOARD_MODIFIER_LEFTCTRL (1 << 0)
  61. /** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */
  62. #define HID_KEYBOARD_MODIFIER_LEFTSHIFT (1 << 1)
  63. /** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */
  64. #define HID_KEYBOARD_MODIFIER_LEFTALT (1 << 2)
  65. /** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */
  66. #define HID_KEYBOARD_MODIFIER_LEFTGUI (1 << 3)
  67. /** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */
  68. #define HID_KEYBOARD_MODIFIER_RIGHTCTRL (1 << 4)
  69. /** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */
  70. #define HID_KEYBOARD_MODIFIER_RIGHTSHIFT (1 << 5)
  71. /** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */
  72. #define HID_KEYBOARD_MODIFIER_RIGHTALT (1 << 6)
  73. /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */
  74. #define HID_KEYBOARD_MODIFIER_RIGHTGUI (1 << 7)
  75. //@}
  76. /** \name Keyboard Standard Report LED Masks */
  77. //@{
  78. /** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */
  79. #define HID_KEYBOARD_LED_NUMLOCK (1 << 0)
  80. /** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */
  81. #define HID_KEYBOARD_LED_CAPSLOCK (1 << 1)
  82. /** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */
  83. #define HID_KEYBOARD_LED_SCROLLLOCK (1 << 2)
  84. /** Constant for a keyboard output report LED byte, indicating that the host's COMPOSE mode is currently set. */
  85. #define HID_KEYBOARD_LED_COMPOSE (1 << 3)
  86. /** Constant for a keyboard output report LED byte, indicating that the host's KANA mode is currently set. */
  87. #define HID_KEYBOARD_LED_KANA (1 << 4)
  88. //@}
  89. /** \name Keyboard Standard Report Key Scan-codes */
  90. //@{
  91. #define HID_KEYBOARD_SC_ERROR_ROLLOVER 0x01
  92. #define HID_KEYBOARD_SC_POST_FAIL 0x02
  93. #define HID_KEYBOARD_SC_ERROR_UNDEFINED 0x03
  94. #define HID_KEYBOARD_SC_A 0x04
  95. #define HID_KEYBOARD_SC_B 0x05
  96. #define HID_KEYBOARD_SC_C 0x06
  97. #define HID_KEYBOARD_SC_D 0x07
  98. #define HID_KEYBOARD_SC_E 0x08
  99. #define HID_KEYBOARD_SC_F 0x09
  100. #define HID_KEYBOARD_SC_G 0x0A
  101. #define HID_KEYBOARD_SC_H 0x0B
  102. #define HID_KEYBOARD_SC_I 0x0C
  103. #define HID_KEYBOARD_SC_J 0x0D
  104. #define HID_KEYBOARD_SC_K 0x0E
  105. #define HID_KEYBOARD_SC_L 0x0F
  106. #define HID_KEYBOARD_SC_M 0x10
  107. #define HID_KEYBOARD_SC_N 0x11
  108. #define HID_KEYBOARD_SC_O 0x12
  109. #define HID_KEYBOARD_SC_P 0x13
  110. #define HID_KEYBOARD_SC_Q 0x14
  111. #define HID_KEYBOARD_SC_R 0x15
  112. #define HID_KEYBOARD_SC_S 0x16
  113. #define HID_KEYBOARD_SC_T 0x17
  114. #define HID_KEYBOARD_SC_U 0x18
  115. #define HID_KEYBOARD_SC_V 0x19
  116. #define HID_KEYBOARD_SC_W 0x1A
  117. #define HID_KEYBOARD_SC_X 0x1B
  118. #define HID_KEYBOARD_SC_Y 0x1C
  119. #define HID_KEYBOARD_SC_Z 0x1D
  120. #define HID_KEYBOARD_SC_1_AND_EXCLAMATION 0x1E
  121. #define HID_KEYBOARD_SC_2_AND_AT 0x1F
  122. #define HID_KEYBOARD_SC_3_AND_HASHMARK 0x20
  123. #define HID_KEYBOARD_SC_4_AND_DOLLAR 0x21
  124. #define HID_KEYBOARD_SC_5_AND_PERCENTAGE 0x22
  125. #define HID_KEYBOARD_SC_6_AND_CARET 0x23
  126. #define HID_KEYBOARD_SC_7_AND_AMPERSAND 0x24
  127. #define HID_KEYBOARD_SC_8_AND_ASTERISK 0x25
  128. #define HID_KEYBOARD_SC_9_AND_OPENING_PARENTHESIS 0x26
  129. #define HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS 0x27
  130. #define HID_KEYBOARD_SC_ENTER 0x28
  131. #define HID_KEYBOARD_SC_ESCAPE 0x29
  132. #define HID_KEYBOARD_SC_BACKSPACE 0x2A
  133. #define HID_KEYBOARD_SC_TAB 0x2B
  134. #define HID_KEYBOARD_SC_SPACE 0x2C
  135. #define HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE 0x2D
  136. #define HID_KEYBOARD_SC_EQUAL_AND_PLUS 0x2E
  137. #define HID_KEYBOARD_SC_OPENING_BRACKET_AND_OPENING_BRACE 0x2F
  138. #define HID_KEYBOARD_SC_CLOSING_BRACKET_AND_CLOSING_BRACE 0x30
  139. #define HID_KEYBOARD_SC_BACKSLASH_AND_PIPE 0x31
  140. #define HID_KEYBOARD_SC_NON_US_HASHMARK_AND_TILDE 0x32
  141. #define HID_KEYBOARD_SC_SEMICOLON_AND_COLON 0x33
  142. #define HID_KEYBOARD_SC_APOSTROPHE_AND_QUOTE 0x34
  143. #define HID_KEYBOARD_SC_GRAVE_ACCENT_AND_TILDE 0x35
  144. #define HID_KEYBOARD_SC_COMMA_AND_LESS_THAN_SIGN 0x36
  145. #define HID_KEYBOARD_SC_DOT_AND_GREATER_THAN_SIGN 0x37
  146. #define HID_KEYBOARD_SC_SLASH_AND_QUESTION_MARK 0x38
  147. #define HID_KEYBOARD_SC_CAPS_LOCK 0x39
  148. #define HID_KEYBOARD_SC_F1 0x3A
  149. #define HID_KEYBOARD_SC_F2 0x3B
  150. #define HID_KEYBOARD_SC_F3 0x3C
  151. #define HID_KEYBOARD_SC_F4 0x3D
  152. #define HID_KEYBOARD_SC_F5 0x3E
  153. #define HID_KEYBOARD_SC_F6 0x3F
  154. #define HID_KEYBOARD_SC_F7 0x40
  155. #define HID_KEYBOARD_SC_F8 0x41
  156. #define HID_KEYBOARD_SC_F9 0x42
  157. #define HID_KEYBOARD_SC_F10 0x43
  158. #define HID_KEYBOARD_SC_F11 0x44
  159. #define HID_KEYBOARD_SC_F12 0x45
  160. #define HID_KEYBOARD_SC_PRINT_SCREEN 0x46
  161. #define HID_KEYBOARD_SC_SCROLL_LOCK 0x47
  162. #define HID_KEYBOARD_SC_PAUSE 0x48
  163. #define HID_KEYBOARD_SC_INSERT 0x49
  164. #define HID_KEYBOARD_SC_HOME 0x4A
  165. #define HID_KEYBOARD_SC_PAGE_UP 0x4B
  166. #define HID_KEYBOARD_SC_DELETE 0x4C
  167. #define HID_KEYBOARD_SC_END 0x4D
  168. #define HID_KEYBOARD_SC_PAGE_DOWN 0x4E
  169. #define HID_KEYBOARD_SC_RIGHT_ARROW 0x4F
  170. #define HID_KEYBOARD_SC_LEFT_ARROW 0x50
  171. #define HID_KEYBOARD_SC_DOWN_ARROW 0x51
  172. #define HID_KEYBOARD_SC_UP_ARROW 0x52
  173. #define HID_KEYBOARD_SC_NUM_LOCK 0x53
  174. #define HID_KEYBOARD_SC_KEYPAD_SLASH 0x54
  175. #define HID_KEYBOARD_SC_KEYPAD_ASTERISK 0x55
  176. #define HID_KEYBOARD_SC_KEYPAD_MINUS 0x56
  177. #define HID_KEYBOARD_SC_KEYPAD_PLUS 0x57
  178. #define HID_KEYBOARD_SC_KEYPAD_ENTER 0x58
  179. #define HID_KEYBOARD_SC_KEYPAD_1_AND_END 0x59
  180. #define HID_KEYBOARD_SC_KEYPAD_2_AND_DOWN_ARROW 0x5A
  181. #define HID_KEYBOARD_SC_KEYPAD_3_AND_PAGE_DOWN 0x5B
  182. #define HID_KEYBOARD_SC_KEYPAD_4_AND_LEFT_ARROW 0x5C
  183. #define HID_KEYBOARD_SC_KEYPAD_5 0x5D
  184. #define HID_KEYBOARD_SC_KEYPAD_6_AND_RIGHT_ARROW 0x5E
  185. #define HID_KEYBOARD_SC_KEYPAD_7_AND_HOME 0x5F
  186. #define HID_KEYBOARD_SC_KEYPAD_8_AND_UP_ARROW 0x60
  187. #define HID_KEYBOARD_SC_KEYPAD_9_AND_PAGE_UP 0x61
  188. #define HID_KEYBOARD_SC_KEYPAD_0_AND_INSERT 0x62
  189. #define HID_KEYBOARD_SC_KEYPAD_DOT_AND_DELETE 0x63
  190. #define HID_KEYBOARD_SC_NON_US_BACKSLASH_AND_PIPE 0x64
  191. #define HID_KEYBOARD_SC_APPLICATION 0x65
  192. #define HID_KEYBOARD_SC_POWER 0x66
  193. #define HID_KEYBOARD_SC_KEYPAD_EQUAL_SIGN 0x67
  194. #define HID_KEYBOARD_SC_F13 0x68
  195. #define HID_KEYBOARD_SC_F14 0x69
  196. #define HID_KEYBOARD_SC_F15 0x6A
  197. #define HID_KEYBOARD_SC_F16 0x6B
  198. #define HID_KEYBOARD_SC_F17 0x6C
  199. #define HID_KEYBOARD_SC_F18 0x6D
  200. #define HID_KEYBOARD_SC_F19 0x6E
  201. #define HID_KEYBOARD_SC_F20 0x6F
  202. #define HID_KEYBOARD_SC_F21 0x70
  203. #define HID_KEYBOARD_SC_F22 0x71
  204. #define HID_KEYBOARD_SC_F23 0x72
  205. #define HID_KEYBOARD_SC_F24 0x73
  206. #define HID_KEYBOARD_SC_EXECUTE 0x74
  207. #define HID_KEYBOARD_SC_HELP 0x75
  208. #define HID_KEYBOARD_SC_MENU 0x76
  209. #define HID_KEYBOARD_SC_SELECT 0x77
  210. #define HID_KEYBOARD_SC_STOP 0x78
  211. #define HID_KEYBOARD_SC_AGAIN 0x79
  212. #define HID_KEYBOARD_SC_UNDO 0x7A
  213. #define HID_KEYBOARD_SC_CUT 0x7B
  214. #define HID_KEYBOARD_SC_COPY 0x7C
  215. #define HID_KEYBOARD_SC_PASTE 0x7D
  216. #define HID_KEYBOARD_SC_FIND 0x7E
  217. #define HID_KEYBOARD_SC_MUTE 0x7F
  218. #define HID_KEYBOARD_SC_VOLUME_UP 0x80
  219. #define HID_KEYBOARD_SC_VOLUME_DOWN 0x81
  220. #define HID_KEYBOARD_SC_LOCKING_CAPS_LOCK 0x82
  221. #define HID_KEYBOARD_SC_LOCKING_NUM_LOCK 0x83
  222. #define HID_KEYBOARD_SC_LOCKING_SCROLL_LOCK 0x84
  223. #define HID_KEYBOARD_SC_KEYPAD_COMMA 0x85
  224. #define HID_KEYBOARD_SC_KEYPAD_EQUAL_SIGN_AS400 0x86
  225. #define HID_KEYBOARD_SC_INTERNATIONAL1 0x87
  226. #define HID_KEYBOARD_SC_INTERNATIONAL2 0x88
  227. #define HID_KEYBOARD_SC_INTERNATIONAL3 0x89
  228. #define HID_KEYBOARD_SC_INTERNATIONAL4 0x8A
  229. #define HID_KEYBOARD_SC_INTERNATIONAL5 0x8B
  230. #define HID_KEYBOARD_SC_INTERNATIONAL6 0x8C
  231. #define HID_KEYBOARD_SC_INTERNATIONAL7 0x8D
  232. #define HID_KEYBOARD_SC_INTERNATIONAL8 0x8E
  233. #define HID_KEYBOARD_SC_INTERNATIONAL9 0x8F
  234. #define HID_KEYBOARD_SC_LANG1 0x90
  235. #define HID_KEYBOARD_SC_LANG2 0x91
  236. #define HID_KEYBOARD_SC_LANG3 0x92
  237. #define HID_KEYBOARD_SC_LANG4 0x93
  238. #define HID_KEYBOARD_SC_LANG5 0x94
  239. #define HID_KEYBOARD_SC_LANG6 0x95
  240. #define HID_KEYBOARD_SC_LANG7 0x96
  241. #define HID_KEYBOARD_SC_LANG8 0x97
  242. #define HID_KEYBOARD_SC_LANG9 0x98
  243. #define HID_KEYBOARD_SC_ALTERNATE_ERASE 0x99
  244. #define HID_KEYBOARD_SC_SYSREQ 0x9A
  245. #define HID_KEYBOARD_SC_CANCEL 0x9B
  246. #define HID_KEYBOARD_SC_CLEAR 0x9C
  247. #define HID_KEYBOARD_SC_PRIOR 0x9D
  248. #define HID_KEYBOARD_SC_RETURN 0x9E
  249. #define HID_KEYBOARD_SC_SEPARATOR 0x9F
  250. #define HID_KEYBOARD_SC_OUT 0xA0
  251. #define HID_KEYBOARD_SC_OPER 0xA1
  252. #define HID_KEYBOARD_SC_CLEAR_AND_AGAIN 0xA2
  253. #define HID_KEYBOARD_SC_CRSEL_AND_PROPS 0xA3
  254. #define HID_KEYBOARD_SC_EXSEL 0xA4
  255. #define HID_KEYBOARD_SC_KEYPAD_00 0xB0
  256. #define HID_KEYBOARD_SC_KEYPAD_000 0xB1
  257. #define HID_KEYBOARD_SC_THOUSANDS_SEPARATOR 0xB2
  258. #define HID_KEYBOARD_SC_DECIMAL_SEPARATOR 0xB3
  259. #define HID_KEYBOARD_SC_CURRENCY_UNIT 0xB4
  260. #define HID_KEYBOARD_SC_CURRENCY_SUB_UNIT 0xB5
  261. #define HID_KEYBOARD_SC_KEYPAD_OPENING_PARENTHESIS 0xB6
  262. #define HID_KEYBOARD_SC_KEYPAD_CLOSING_PARENTHESIS 0xB7
  263. #define HID_KEYBOARD_SC_KEYPAD_OPENING_BRACE 0xB8
  264. #define HID_KEYBOARD_SC_KEYPAD_CLOSING_BRACE 0xB9
  265. #define HID_KEYBOARD_SC_KEYPAD_TAB 0xBA
  266. #define HID_KEYBOARD_SC_KEYPAD_BACKSPACE 0xBB
  267. #define HID_KEYBOARD_SC_KEYPAD_A 0xBC
  268. #define HID_KEYBOARD_SC_KEYPAD_B 0xBD
  269. #define HID_KEYBOARD_SC_KEYPAD_C 0xBE
  270. #define HID_KEYBOARD_SC_KEYPAD_D 0xBF
  271. #define HID_KEYBOARD_SC_KEYPAD_E 0xC0
  272. #define HID_KEYBOARD_SC_KEYPAD_F 0xC1
  273. #define HID_KEYBOARD_SC_KEYPAD_XOR 0xC2
  274. #define HID_KEYBOARD_SC_KEYPAD_CARET 0xC3
  275. #define HID_KEYBOARD_SC_KEYPAD_PERCENTAGE 0xC4
  276. #define HID_KEYBOARD_SC_KEYPAD_LESS_THAN_SIGN 0xC5
  277. #define HID_KEYBOARD_SC_KEYPAD_GREATER_THAN_SIGN 0xC6
  278. #define HID_KEYBOARD_SC_KEYPAD_AMP 0xC7
  279. #define HID_KEYBOARD_SC_KEYPAD_AMP_AMP 0xC8
  280. #define HID_KEYBOARD_SC_KEYPAD_PIPE 0xC9
  281. #define HID_KEYBOARD_SC_KEYPAD_PIPE_PIPE 0xCA
  282. #define HID_KEYBOARD_SC_KEYPAD_COLON 0xCB
  283. #define HID_KEYBOARD_SC_KEYPAD_HASHMARK 0xCC
  284. #define HID_KEYBOARD_SC_KEYPAD_SPACE 0xCD
  285. #define HID_KEYBOARD_SC_KEYPAD_AT 0xCE
  286. #define HID_KEYBOARD_SC_KEYPAD_EXCLAMATION_SIGN 0xCF
  287. #define HID_KEYBOARD_SC_KEYPAD_MEMORY_STORE 0xD0
  288. #define HID_KEYBOARD_SC_KEYPAD_MEMORY_RECALL 0xD1
  289. #define HID_KEYBOARD_SC_KEYPAD_MEMORY_CLEAR 0xD2
  290. #define HID_KEYBOARD_SC_KEYPAD_MEMORY_ADD 0xD3
  291. #define HID_KEYBOARD_SC_KEYPAD_MEMORY_SUBTRACT 0xD4
  292. #define HID_KEYBOARD_SC_KEYPAD_MEMORY_MULTIPLY 0xD5
  293. #define HID_KEYBOARD_SC_KEYPAD_MEMORY_DIVIDE 0xD6
  294. #define HID_KEYBOARD_SC_KEYPAD_PLUS_AND_MINUS 0xD7
  295. #define HID_KEYBOARD_SC_KEYPAD_CLEAR 0xD8
  296. #define HID_KEYBOARD_SC_KEYPAD_CLEAR_ENTRY 0xD9
  297. #define HID_KEYBOARD_SC_KEYPAD_BINARY 0xDA
  298. #define HID_KEYBOARD_SC_KEYPAD_OCTAL 0xDB
  299. #define HID_KEYBOARD_SC_KEYPAD_DECIMAL 0xDC
  300. #define HID_KEYBOARD_SC_KEYPAD_HEXADECIMAL 0xDD
  301. #define HID_KEYBOARD_SC_LEFT_CONTROL 0xE0
  302. #define HID_KEYBOARD_SC_LEFT_SHIFT 0xE1
  303. #define HID_KEYBOARD_SC_LEFT_ALT 0xE2
  304. #define HID_KEYBOARD_SC_LEFT_GUI 0xE3
  305. #define HID_KEYBOARD_SC_RIGHT_CONTROL 0xE4
  306. #define HID_KEYBOARD_SC_RIGHT_SHIFT 0xE5
  307. #define HID_KEYBOARD_SC_RIGHT_ALT 0xE6
  308. #define HID_KEYBOARD_SC_RIGHT_GUI 0xE7
  309. #define HID_KEYBOARD_SC_MEDIA_PLAY 0xE8
  310. #define HID_KEYBOARD_SC_MEDIA_STOP 0xE9
  311. #define HID_KEYBOARD_SC_MEDIA_PREVIOUS_TRACK 0xEA
  312. #define HID_KEYBOARD_SC_MEDIA_NEXT_TRACK 0xEB
  313. #define HID_KEYBOARD_SC_MEDIA_EJECT 0xEC
  314. #define HID_KEYBOARD_SC_MEDIA_VOLUME_UP 0xED
  315. #define HID_KEYBOARD_SC_MEDIA_VOLUME_DOWN 0xEE
  316. #define HID_KEYBOARD_SC_MEDIA_MUTE 0xEF
  317. #define HID_KEYBOARD_SC_MEDIA_WWW 0xF0
  318. #define HID_KEYBOARD_SC_MEDIA_BACKWARD 0xF1
  319. #define HID_KEYBOARD_SC_MEDIA_FORWARD 0xF2
  320. #define HID_KEYBOARD_SC_MEDIA_CANCEL 0xF3
  321. #define HID_KEYBOARD_SC_MEDIA_SEARCH 0xF4
  322. #define HID_KEYBOARD_SC_MEDIA_SLEEP 0xF8
  323. #define HID_KEYBOARD_SC_MEDIA_LOCK 0xF9
  324. #define HID_KEYBOARD_SC_MEDIA_RELOAD 0xFA
  325. #define HID_KEYBOARD_SC_MEDIA_CALCULATOR 0xFB
  326. //@}
  327. /** \name Common HID Device Report Descriptors */
  328. //@{
  329. /** \hideinitializer
  330. * A list of HID report item array elements that describe a typical HID USB Joystick. The resulting report
  331. * descriptor is structured according to the following layout:
  332. *
  333. * \code
  334. * struct
  335. * {
  336. * intA_t X; // Signed X axis value
  337. * intA_t Y; // Signed Y axis value
  338. * intA_t Z; // Signed Z axis value
  339. * uintB_t Buttons; // Pressed buttons bitmask
  340. * } Joystick_Report;
  341. * \endcode
  342. *
  343. * Where \c uintA_t is a type large enough to hold the ranges of the signed \c MinAxisVal and \c MaxAxisVal values,
  344. * and \c intB_t is a type large enough to hold one bit per button.
  345. *
  346. * \param[in] MinAxisVal Minimum logical axis value (16-bit).
  347. * \param[in] MaxAxisVal Maximum logical axis value (16-bit).
  348. * \param[in] MinPhysicalVal Minimum physical axis value, for movement resolution calculations (16-bit).
  349. * \param[in] MaxPhysicalVal Maximum physical axis value, for movement resolution calculations (16-bit).
  350. * \param[in] Buttons Total number of buttons in the device (8-bit).
  351. */
  352. #define HID_DESCRIPTOR_JOYSTICK(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons) \
  353. HID_RI_USAGE_PAGE(8, 0x01), \
  354. HID_RI_USAGE(8, 0x04), \
  355. HID_RI_COLLECTION(8, 0x01), \
  356. HID_RI_USAGE(8, 0x01), \
  357. HID_RI_COLLECTION(8, 0x00), \
  358. HID_RI_USAGE(8, 0x30), \
  359. HID_RI_USAGE(8, 0x31), \
  360. HID_RI_USAGE(8, 0x32), \
  361. HID_RI_LOGICAL_MINIMUM(16, MinAxisVal), \
  362. HID_RI_LOGICAL_MAXIMUM(16, MaxAxisVal), \
  363. HID_RI_PHYSICAL_MINIMUM(16, MinPhysicalVal), \
  364. HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \
  365. HID_RI_REPORT_COUNT(8, 3), \
  366. HID_RI_REPORT_SIZE(8, (((MinAxisVal >= -128) && (MaxAxisVal <= 127)) ? 8 : 16)), \
  367. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
  368. HID_RI_END_COLLECTION(0), \
  369. HID_RI_USAGE_PAGE(8, 0x09), \
  370. HID_RI_USAGE_MINIMUM(8, 0x01), \
  371. HID_RI_USAGE_MAXIMUM(8, Buttons), \
  372. HID_RI_LOGICAL_MINIMUM(8, 0x00), \
  373. HID_RI_LOGICAL_MAXIMUM(8, 0x01), \
  374. HID_RI_REPORT_SIZE(8, 0x01), \
  375. HID_RI_REPORT_COUNT(8, Buttons), \
  376. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
  377. HID_RI_REPORT_SIZE(8, (Buttons % 8) ? (8 - (Buttons % 8)) : 0), \
  378. HID_RI_REPORT_COUNT(8, 0x01), \
  379. HID_RI_INPUT(8, HID_IOF_CONSTANT), \
  380. HID_RI_END_COLLECTION(0)
  381. /** \hideinitializer
  382. * A list of HID report item array elements that describe a typical HID USB keyboard. The resulting report descriptor
  383. * is compatible with \ref USB_KeyboardReport_Data_t when \c MaxKeys is equal to 6. For other values, the report will
  384. * be structured according to the following layout:
  385. *
  386. * \code
  387. * struct
  388. * {
  389. * uint8_t Modifier; // Keyboard modifier byte indicating pressed modifier keys (\c HID_KEYBOARD_MODIFER_* masks)
  390. * uint8_t Reserved; // Reserved for OEM use, always set to 0.
  391. * uint8_t KeyCode[MaxKeys]; // Length determined by the number of keys that can be reported
  392. * } Keyboard_Report;
  393. * \endcode
  394. *
  395. * \param[in] MaxKeys Number of simultaneous keys that can be reported at the one time (8-bit).
  396. */
  397. #define HID_DESCRIPTOR_KEYBOARD(MaxKeys) \
  398. HID_RI_USAGE_PAGE(8, 0x01), \
  399. HID_RI_USAGE(8, 0x06), \
  400. HID_RI_COLLECTION(8, 0x01), \
  401. HID_RI_USAGE_PAGE(8, 0x07), \
  402. HID_RI_USAGE_MINIMUM(8, 0xE0), \
  403. HID_RI_USAGE_MAXIMUM(8, 0xE7), \
  404. HID_RI_LOGICAL_MINIMUM(8, 0x00), \
  405. HID_RI_LOGICAL_MAXIMUM(8, 0x01), \
  406. HID_RI_REPORT_SIZE(8, 0x01), \
  407. HID_RI_REPORT_COUNT(8, 0x08), \
  408. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
  409. HID_RI_REPORT_COUNT(8, 0x01), \
  410. HID_RI_REPORT_SIZE(8, 0x08), \
  411. HID_RI_INPUT(8, HID_IOF_CONSTANT), \
  412. HID_RI_USAGE_PAGE(8, 0x08), \
  413. HID_RI_USAGE_MINIMUM(8, 0x01), \
  414. HID_RI_USAGE_MAXIMUM(8, 0x05), \
  415. HID_RI_REPORT_COUNT(8, 0x05), \
  416. HID_RI_REPORT_SIZE(8, 0x01), \
  417. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \
  418. HID_RI_REPORT_COUNT(8, 0x01), \
  419. HID_RI_REPORT_SIZE(8, 0x03), \
  420. HID_RI_OUTPUT(8, HID_IOF_CONSTANT), \
  421. HID_RI_LOGICAL_MINIMUM(8, 0x00), \
  422. HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \
  423. HID_RI_USAGE_PAGE(8, 0x07), \
  424. HID_RI_USAGE_MINIMUM(8, 0x00), \
  425. HID_RI_USAGE_MAXIMUM(8, 0xFF), \
  426. HID_RI_REPORT_COUNT(8, MaxKeys), \
  427. HID_RI_REPORT_SIZE(8, 0x08), \
  428. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), \
  429. HID_RI_END_COLLECTION(0)
  430. /** \hideinitializer
  431. * A list of HID report item array elements that describe a typical HID USB mouse. The resulting report descriptor
  432. * is compatible with \ref USB_MouseReport_Data_t if the \c MinAxisVal and \c MaxAxisVal values fit within a \c int8_t range
  433. * and the number of Buttons is less than 8. For other values, the report is structured according to the following layout:
  434. *
  435. * \code
  436. * struct
  437. * {
  438. * uintA_t Buttons; // Pressed buttons bitmask
  439. * intB_t X; // X axis value
  440. * intB_t Y; // Y axis value
  441. * } Mouse_Report;
  442. * \endcode
  443. *
  444. * Where \c intA_t is a type large enough to hold one bit per button, and \c intB_t is a type large enough to hold the
  445. * ranges of the signed \c MinAxisVal and \c MaxAxisVal values.
  446. *
  447. * \param[in] MinAxisVal Minimum X/Y logical axis value (16-bit).
  448. * \param[in] MaxAxisVal Maximum X/Y logical axis value (16-bit).
  449. * \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations (16-bit).
  450. * \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations (16-bit).
  451. * \param[in] Buttons Total number of buttons in the device (8-bit).
  452. * \param[in] AbsoluteCoords Boolean \c true to use absolute X/Y coordinates (e.g. touchscreen).
  453. */
  454. #define HID_DESCRIPTOR_MOUSE(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons, AbsoluteCoords) \
  455. HID_RI_USAGE_PAGE(8, 0x01), \
  456. HID_RI_USAGE(8, 0x02), \
  457. HID_RI_COLLECTION(8, 0x01), \
  458. HID_RI_USAGE(8, 0x01), \
  459. HID_RI_COLLECTION(8, 0x00), \
  460. HID_RI_USAGE_PAGE(8, 0x09), \
  461. HID_RI_USAGE_MINIMUM(8, 0x01), \
  462. HID_RI_USAGE_MAXIMUM(8, Buttons), \
  463. HID_RI_LOGICAL_MINIMUM(8, 0x00), \
  464. HID_RI_LOGICAL_MAXIMUM(8, 0x01), \
  465. HID_RI_REPORT_COUNT(8, Buttons), \
  466. HID_RI_REPORT_SIZE(8, 0x01), \
  467. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
  468. HID_RI_REPORT_COUNT(8, 0x01), \
  469. HID_RI_REPORT_SIZE(8, (Buttons % 8) ? (8 - (Buttons % 8)) : 0), \
  470. HID_RI_INPUT(8, HID_IOF_CONSTANT), \
  471. HID_RI_USAGE_PAGE(8, 0x01), \
  472. HID_RI_USAGE(8, 0x30), \
  473. HID_RI_USAGE(8, 0x31), \
  474. HID_RI_LOGICAL_MINIMUM(16, MinAxisVal), \
  475. HID_RI_LOGICAL_MAXIMUM(16, MaxAxisVal), \
  476. HID_RI_PHYSICAL_MINIMUM(16, MinPhysicalVal), \
  477. HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \
  478. HID_RI_REPORT_COUNT(8, 0x02), \
  479. HID_RI_REPORT_SIZE(8, (((MinAxisVal >= -128) && (MaxAxisVal <= 127)) ? 8 : 16)), \
  480. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | (AbsoluteCoords ? HID_IOF_ABSOLUTE : HID_IOF_RELATIVE)), \
  481. HID_RI_END_COLLECTION(0), \
  482. HID_RI_END_COLLECTION(0)
  483. /** \hideinitializer
  484. * A list of HID report item array elements that describe a typical Vendor Defined byte array HID report descriptor,
  485. * used for transporting arbitrary data between the USB host and device via HID reports. The resulting report should be
  486. * a \c uint8_t byte array of the specified length in both Device to Host (IN) and Host to Device (OUT) directions.
  487. *
  488. * \param[in] VendorPageNum Vendor Defined HID Usage Page index, ranging from 0x00 to 0xFF.
  489. * \param[in] CollectionUsage Vendor Usage for the encompassing report IN and OUT collection, ranging from 0x00 to 0xFF.
  490. * \param[in] DataINUsage Vendor Usage for the IN report data, ranging from 0x00 to 0xFF.
  491. * \param[in] DataOUTUsage Vendor Usage for the OUT report data, ranging from 0x00 to 0xFF.
  492. * \param[in] NumBytes Length of the data IN and OUT reports.
  493. */
  494. #define HID_DESCRIPTOR_VENDOR(VendorPageNum, CollectionUsage, DataINUsage, DataOUTUsage, NumBytes) \
  495. HID_RI_USAGE_PAGE(16, (0xFF00 | VendorPageNum)), \
  496. HID_RI_USAGE(8, CollectionUsage), \
  497. HID_RI_COLLECTION(8, 0x01), \
  498. HID_RI_USAGE(8, DataINUsage), \
  499. HID_RI_LOGICAL_MINIMUM(8, 0x00), \
  500. HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \
  501. HID_RI_REPORT_SIZE(8, 0x08), \
  502. HID_RI_REPORT_COUNT(8, NumBytes), \
  503. HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \
  504. HID_RI_USAGE(8, DataOUTUsage), \
  505. HID_RI_LOGICAL_MINIMUM(8, 0x00), \
  506. HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \
  507. HID_RI_REPORT_SIZE(8, 0x08), \
  508. HID_RI_REPORT_COUNT(8, NumBytes), \
  509. HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \
  510. HID_RI_END_COLLECTION(0)
  511. //@}
  512. /* Type Defines: */
  513. /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the HID
  514. * device class.
  515. */
  516. enum HID_Descriptor_ClassSubclassProtocol_t
  517. {
  518. HID_CSCP_HIDClass = 0x03, /**< Descriptor Class value indicating that the device or interface
  519. * belongs to the HID class.
  520. */
  521. HID_CSCP_NonBootSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface
  522. * does not implement a HID boot protocol.
  523. */
  524. HID_CSCP_BootSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or interface
  525. * implements a HID boot protocol.
  526. */
  527. HID_CSCP_NonBootProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface
  528. * does not belong to a HID boot protocol.
  529. */
  530. HID_CSCP_KeyboardBootProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface
  531. * belongs to the Keyboard HID boot protocol.
  532. */
  533. HID_CSCP_MouseBootProtocol = 0x02, /**< Descriptor Protocol value indicating that the device or interface
  534. * belongs to the Mouse HID boot protocol.
  535. */
  536. };
  537. /** Enum for the HID class specific control requests that can be issued by the USB bus host. */
  538. enum HID_ClassRequests_t
  539. {
  540. HID_REQ_GetReport = 0x01, /**< HID class-specific Request to get the current HID report from the device. */
  541. HID_REQ_GetIdle = 0x02, /**< HID class-specific Request to get the current device idle count. */
  542. HID_REQ_GetProtocol = 0x03, /**< HID class-specific Request to get the current HID report protocol mode. */
  543. HID_REQ_SetReport = 0x09, /**< HID class-specific Request to set the current HID report to the device. */
  544. HID_REQ_SetIdle = 0x0A, /**< HID class-specific Request to set the device's idle count. */
  545. HID_REQ_SetProtocol = 0x0B, /**< HID class-specific Request to set the current HID report protocol mode. */
  546. };
  547. /** Enum for the HID class specific descriptor types. */
  548. enum HID_DescriptorTypes_t
  549. {
  550. HID_DTYPE_HID = 0x21, /**< Descriptor header type value, to indicate a HID class HID descriptor. */
  551. HID_DTYPE_Report = 0x22, /**< Descriptor header type value, to indicate a HID class HID report descriptor. */
  552. };
  553. /** Enum for the different types of HID reports. */
  554. enum HID_ReportItemTypes_t
  555. {
  556. HID_REPORT_ITEM_In = 0, /**< Indicates that the item is an IN report type. */
  557. HID_REPORT_ITEM_Out = 1, /**< Indicates that the item is an OUT report type. */
  558. HID_REPORT_ITEM_Feature = 2, /**< Indicates that the item is a FEATURE report type. */
  559. };
  560. /** \brief HID class-specific HID Descriptor (LUFA naming conventions).
  561. *
  562. * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID
  563. * specification for details on the structure elements.
  564. *
  565. * \see \ref USB_HID_StdDescriptor_HID_t for the version of this type with standard element names.
  566. *
  567. * \note Regardless of CPU architecture, these values should be stored as little endian.
  568. */
  569. typedef struct
  570. {
  571. USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */
  572. uint16_t HIDSpec; /**< BCD encoded version that the HID descriptor and device complies to.
  573. *
  574. * \see \ref VERSION_BCD() utility macro.
  575. */
  576. uint8_t CountryCode; /**< Country code of the localized device, or zero if universal. */
  577. uint8_t TotalReportDescriptors; /**< Total number of HID report descriptors for the interface. */
  578. uint8_t HIDReportType; /**< Type of HID report, set to \ref HID_DTYPE_Report. */
  579. uint16_t HIDReportLength; /**< Length of the associated HID report descriptor, in bytes. */
  580. } ATTR_PACKED USB_HID_Descriptor_HID_t;
  581. /** \brief HID class-specific HID Descriptor (USB-IF naming conventions).
  582. *
  583. * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID
  584. * specification for details on the structure elements.
  585. *
  586. * \see \ref USB_HID_Descriptor_HID_t for the version of this type with non-standard LUFA specific
  587. * element names.
  588. *
  589. * \note Regardless of CPU architecture, these values should be stored as little endian.
  590. */
  591. typedef struct
  592. {
  593. uint8_t bLength; /**< Size of the descriptor, in bytes. */
  594. uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value
  595. * given by the specific class.
  596. */
  597. uint16_t bcdHID; /**< BCD encoded version that the HID descriptor and device complies to.
  598. *
  599. * \see \ref VERSION_BCD() utility macro.
  600. */
  601. uint8_t bCountryCode; /**< Country code of the localized device, or zero if universal. */
  602. uint8_t bNumDescriptors; /**< Total number of HID report descriptors for the interface. */
  603. uint8_t bDescriptorType2; /**< Type of HID report, set to \ref HID_DTYPE_Report. */
  604. uint16_t wDescriptorLength; /**< Length of the associated HID report descriptor, in bytes. */
  605. } ATTR_PACKED USB_HID_StdDescriptor_HID_t;
  606. /** \brief Standard HID Boot Protocol Mouse Report.
  607. *
  608. * Type define for a standard Boot Protocol Mouse report
  609. */
  610. typedef struct
  611. {
  612. uint8_t Button; /**< Button mask for currently pressed buttons in the mouse. */
  613. int8_t X; /**< Current delta X movement of the mouse. */
  614. int8_t Y; /**< Current delta Y movement on the mouse. */
  615. } ATTR_PACKED USB_MouseReport_Data_t;
  616. /** \brief Standard HID Boot Protocol Keyboard Report.
  617. *
  618. * Type define for a standard Boot Protocol Keyboard report
  619. */
  620. typedef struct
  621. {
  622. uint8_t Modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of
  623. * \c HID_KEYBOARD_MODIFER_* masks).
  624. */
  625. uint8_t Reserved; /**< Reserved for OEM use, always set to 0. */
  626. uint8_t KeyCode[6]; /**< Key codes of the currently pressed keys. */
  627. } ATTR_PACKED USB_KeyboardReport_Data_t;
  628. /** Type define for the data type used to store HID report descriptor elements. */
  629. typedef uint8_t USB_Descriptor_HIDReport_Datatype_t;
  630. /* Disable C linkage for C++ Compilers: */
  631. #if defined(__cplusplus)
  632. }
  633. #endif
  634. #endif
  635. /** @} */