Kiibohd Controller
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

usb_hid.h 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. /* Copyright (C) 2011-2014 by Jacob Alexander
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. #ifndef __usb_hid_h
  22. #define __usb_hid_h
  23. // ----- Defines -----
  24. // The USB codes are all taken from the USB HID Spec
  25. // http://www.usb.org/developers/devclass_docs/Hut1_11.pdf
  26. // List of Keycodes - USB HID 1.11 pg 53
  27. #define KEY_NOEVENT 0x00 // Event, not a physical key
  28. #define KEY_ERRORROLLOVER 0x01 // Event, not a physical key
  29. #define KEY_POSTFAIL 0x02 // Event, not a physical key
  30. #define KEY_ERRORUNDEFINED 0x03 // Event, not a physical key
  31. #define KEY_A 0x04
  32. #define KEY_B 0x05
  33. #define KEY_C 0x06
  34. #define KEY_D 0x07
  35. #define KEY_E 0x08
  36. #define KEY_F 0x09
  37. #define KEY_G 0x0A
  38. #define KEY_H 0x0B
  39. #define KEY_I 0x0C
  40. #define KEY_J 0x0D
  41. #define KEY_K 0x0E
  42. #define KEY_L 0x0F
  43. #define KEY_M 0x10
  44. #define KEY_N 0x11
  45. #define KEY_O 0x12
  46. #define KEY_P 0x13
  47. #define KEY_Q 0x14
  48. #define KEY_R 0x15
  49. #define KEY_S 0x16
  50. #define KEY_T 0x17
  51. #define KEY_U 0x18
  52. #define KEY_V 0x19
  53. #define KEY_W 0x1A
  54. #define KEY_X 0x1B
  55. #define KEY_Y 0x1C
  56. #define KEY_Z 0x1D
  57. #define KEY_1 0x1E
  58. #define KEY_2 0x1F
  59. #define KEY_3 0x20
  60. #define KEY_4 0x21
  61. #define KEY_5 0x22
  62. #define KEY_6 0x23
  63. #define KEY_7 0x24
  64. #define KEY_8 0x25
  65. #define KEY_9 0x26
  66. #define KEY_0 0x27
  67. #define KEY_ENTER 0x28
  68. #define KEY_ESC 0x29
  69. #define KEY_BACKSPACE 0x2A
  70. #define KEY_TAB 0x2B
  71. #define KEY_SPACE 0x2C
  72. #define KEY_MINUS 0x2D
  73. #define KEY_EQUAL 0x2E
  74. #define KEY_LEFT_BRACE 0x2F
  75. #define KEY_RIGHT_BRACE 0x30
  76. #define KEY_BACKSLASH 0x31
  77. #define KEY_NUMBER 0x32
  78. #define KEY_SEMICOLON 0x33
  79. #define KEY_QUOTE 0x34
  80. #define KEY_TILDE 0x35
  81. #define KEY_COMMA 0x36
  82. #define KEY_PERIOD 0x37
  83. #define KEY_SLASH 0x38
  84. #define KEY_CAPS_LOCK 0x39
  85. #define KEY_F1 0x3A
  86. #define KEY_F2 0x3B
  87. #define KEY_F3 0x3C
  88. #define KEY_F4 0x3D
  89. #define KEY_F5 0x3E
  90. #define KEY_F6 0x3F
  91. #define KEY_F7 0x40
  92. #define KEY_F8 0x41
  93. #define KEY_F9 0x42
  94. #define KEY_F10 0x43
  95. #define KEY_F11 0x44
  96. #define KEY_F12 0x45
  97. #define KEY_PRINTSCREEN 0x46
  98. #define KEY_SCROLL_LOCK 0x47
  99. #define KEY_PAUSE 0x48
  100. #define KEY_INSERT 0x49
  101. #define KEY_HOME 0x4A
  102. #define KEY_PAGE_UP 0x4B
  103. #define KEY_DELETE 0x4C
  104. #define KEY_END 0x4D
  105. #define KEY_PAGE_DOWN 0x4E
  106. #define KEY_RIGHT 0x4F
  107. #define KEY_LEFT 0x50
  108. #define KEY_DOWN 0x51
  109. #define KEY_UP 0x52
  110. #define KEY_NUM_LOCK 0x53
  111. #define KEYPAD_SLASH 0x54
  112. #define KEYPAD_ASTERIX 0x55
  113. #define KEYPAD_MINUS 0x56
  114. #define KEYPAD_PLUS 0x57
  115. #define KEYPAD_ENTER 0x58
  116. #define KEYPAD_1 0x59
  117. #define KEYPAD_2 0x5A
  118. #define KEYPAD_3 0x5B
  119. #define KEYPAD_4 0x5C
  120. #define KEYPAD_5 0x5D
  121. #define KEYPAD_6 0x5E
  122. #define KEYPAD_7 0x5F
  123. #define KEYPAD_8 0x60
  124. #define KEYPAD_9 0x61
  125. #define KEYPAD_0 0x62
  126. #define KEYPAD_PERIOD 0x63
  127. #define KEY_ISO_BACKSLASH 0x64
  128. #define KEY_APP 0x65
  129. #define KEYBOARD_STATUS 0x66 // Used for indicating status or errors, not a key
  130. #define KEYPAD_EQUAL 0x67
  131. #define KEY_F13 0x68
  132. #define KEY_F14 0x69
  133. #define KEY_F15 0x6A
  134. #define KEY_F16 0x6B
  135. #define KEY_F17 0x6C
  136. #define KEY_F18 0x6D
  137. #define KEY_F19 0x6E
  138. #define KEY_F20 0x6F
  139. #define KEY_F21 0x70
  140. #define KEY_F22 0x71
  141. #define KEY_F23 0x72
  142. #define KEY_F24 0x73
  143. #define KEY_EXEC 0x74
  144. #define KEY_HELP 0x75
  145. #define KEY_MENU 0x76
  146. #define KEY_SELECT 0x77
  147. #define KEY_STOP 0x78
  148. #define KEY_AGAIN 0x79
  149. #define KEY_UNDO 0x7A
  150. #define KEY_CUT 0x7B
  151. #define KEY_COPY 0x7C
  152. #define KEY_PASTE 0x7D
  153. #define KEY_FIND 0x7E
  154. #define KEY_MUTE 0x7F
  155. #define KEY_VOL_UP 0x80
  156. #define KEY_VOL_DOWN 0x81
  157. #define KEY_CAPS_LLOCK 0x82 // "Locking" Scroll Lock (Old keyboards with Locking Caps Lock)
  158. #define KEY_NUM_LLOCK 0x83
  159. #define KEY_SCROLL_LLOCK 0x84
  160. #define KEYPAD_COMMA 0x85 // Brazillian (See spec)
  161. #define KEYPAD_EQUAL_AS 0x86 // AS/400 Keyboard (See spec)
  162. #define KEY_INTER1 0x87 // KANJI1 - Brazillian and Japanese "Ru" and "-"
  163. #define KEY_INTER2 0x88 // KANJI2 - Japanese Katakana/Hiragana
  164. #define KEY_INTER3 0x89 // KANJI3 - Japanese Yen
  165. #define KEY_INTER4 0x8A // KANJI4 - Japanese Henkan
  166. #define KEY_INTER5 0x8B // KANJI5 - Japanese Muhenkan
  167. #define KEY_INTER6 0x8C // KANJI6 - PC0x62 Comma (Ka-m-ma)
  168. #define KEY_INTER7 0x8D // KANJI7 - Double-Byte/Single-Byte Toggle
  169. #define KEY_INTER8 0x8E // KANJI8 - Undefined
  170. #define KEY_INTER9 0x8F // KANJI9 - Undefined
  171. #define KEY_LANG1 0x90 // Korean Hangul/English Toggle
  172. #define KEY_LANG2 0x91 // Korean Hanja Conversion - Japanese Eisu
  173. #define KEY_LANG3 0x92 // Japanese Katakana Key (USB)
  174. #define KEY_LANG4 0x93 // Japanese Hiragana Key (USB)
  175. #define KEY_LANG5 0x94 // Japanese Zenkaku/Hankaku Key (USB)
  176. #define KEY_LANG6 0x95 // Reserved (Application Specific)
  177. #define KEY_LANG7 0x96 // Reserved (Application Specific)
  178. #define KEY_LANG8 0x97 // Reserved (Application Specific)
  179. #define KEY_LANG9 0x98 // Reserved (Application Specific)
  180. #define KEY_ALT_ERASE 0x99 // Special Erase (See Spec)
  181. #define KEY_SYSREQ_ATT 0x9A // Modifier Type
  182. #define KEY_CANCEL 0x9B
  183. #define KEY_CLEAR 0x9C
  184. #define KEY_PRIOR 0x9D
  185. #define KEY_RETURN 0x9E
  186. #define KEY_SEPARATOR 0x9F
  187. #define KEY_OUT 0xA0
  188. #define KEY_OPER 0xA1
  189. #define KEY_CLEAR_AGAIN 0xA2
  190. #define KEY_CRSEL_PROPS 0xA3
  191. #define KEY_EXSEL 0xA4
  192. // 0xA5 - 0xAF Reserved
  193. #define KEYPAD_00 0xB0
  194. #define KEYPAD_000 0xB1
  195. #define KEY_1000_SEP 0xB2
  196. #define KEY_DECIMAL_SEP 0xB3
  197. #define KEY_CURRENCY_MAIN 0xB4
  198. #define KEY_CURRENCY_SUB 0xB5
  199. #define KEYPAD_LPAREN 0xB6
  200. #define KEYPAD_RPAREN 0xB7
  201. #define KEYPAD_LBRACE 0xB8
  202. #define KEYPAD_RBRACE 0xB9
  203. #define KEYPAD_TAB 0xBA
  204. #define KEYPAD_BACKSPACE 0xBB
  205. #define KEYPAD_A 0xBC
  206. #define KEYPAD_B 0xBD
  207. #define KEYPAD_C 0xBE
  208. #define KEYPAD_D 0xBF
  209. #define KEYPAD_E 0xC0
  210. #define KEYPAD_F 0xC1
  211. #define KEYPAD_XOR 0xC2
  212. #define KEYPAD_CHEVRON 0xC3
  213. #define KEYPAD_PERCENT 0xC4
  214. #define KEYPAD_LTHAN 0xC5
  215. #define KEYPAD_GTHAN 0xC6
  216. #define KEYPAD_BITAND 0xC7
  217. #define KEYPAD_AND 0xC8
  218. #define KEYPAD_BITOR 0xC9
  219. #define KEYPAD_OR 0xCA
  220. #define KEYPAD_COLON 0xCB
  221. #define KEYPAD_POUND 0xCC
  222. #define KEYPAD_SPACE 0xCD
  223. #define KEYPAD_AT 0xCE
  224. #define KEYPAD_EXCLAIM 0xCF
  225. #define KEYPAD_MEM_STORE 0xD0
  226. #define KEYPAD_MEM_RECALL 0xD1
  227. #define KEYPAD_MEM_CLEAR 0xD2
  228. #define KEYPAD_MEM_ADD 0xD3
  229. #define KEYPAD_MEM_SUB 0xD4
  230. #define KEYPAD_MEM_MULT 0xD5
  231. #define KEYPAD_MEM_DIV 0xD6
  232. #define KEYPAD_PLUS_MINUS 0xD7
  233. #define KEYPAD_CLEAR 0xD8
  234. #define KEYPAD_CLEAR_ENTRY 0xD9
  235. #define KEYPAD_BINARY 0xDA
  236. #define KEYPAD_OCTAL 0xDB
  237. #define KEYPAD_DECIMAL 0xDC
  238. #define KEYPAD_HEX 0xDD
  239. // 0xDE - 0xDF Reserved
  240. #define KEY_CTRL 0xE0 // Convenience
  241. #define KEY_LCTRL 0xE0
  242. #define KEY_SHIFT 0xE1 // Convenience
  243. #define KEY_LSHIFT 0xE1
  244. #define KEY_ALT 0xE2 // Convenience
  245. #define KEY_LALT 0xE2
  246. #define KEY_GUI 0xE3 // Convenience
  247. #define KEY_LGUI 0xE3
  248. #define KEY_RCTRL 0xE4
  249. #define KEY_RSHIFT 0xE5
  250. #define KEY_RALT 0xE6
  251. #define KEY_RGUI 0xE7
  252. // 0xE8 - 0xFFFF Reserved
  253. // Except for 0xE0-0xE7 which are DV (Dynamic Flags), all Keycodes are Sel (Selectors).
  254. // List of LED codes - USB HID 1.11 pg 61
  255. // LED/Indicators are defined as:
  256. // OOC - On/Off Control
  257. // US - Usage Indicator: 1 - In Use, 0 - Not In Use
  258. // UM - Usage Multi Mode Indicator Collection of 1 or more indicators: On, Flash, Slow Blink, Fast Blink, Off
  259. // Sel - Selector
  260. // DV - Dynamic Flag
  261. #define LED_UNDEFINED 0x00
  262. #define LED_NUM_LOCK 0x01 // OOC
  263. #define LED_CAPS_LOCK 0x02 // OOC
  264. #define LED_SCROLL_LOCK 0x03 // OOC
  265. #define LED_COMPOSE 0x04 // OOC
  266. #define LED_KANA 0x05 // OOC
  267. #define LED_POWER 0x06 // OOC
  268. #define LED_SHIFT 0x07 // OOC
  269. #define LED_DO_NOT_DISTURB 0x08 // OOC
  270. #define LED_MUTE 0x09 // OOC
  271. #define LED_TONE_ENABLE 0x0A // OOC
  272. #define LED_HIGHCUT_FILTER 0x0B // OOC
  273. #define LED_LOWCUT_FILTER 0x0C // OOC
  274. #define LED_EQL_ENABLE 0x0D // OOC
  275. #define LED_SND_FLD_ON 0x0E // OOC
  276. #define LED_SURROUND_ON 0x0F // OOC
  277. #define LED_REPEAT 0x10 // OOC
  278. #define LED_STEREO 0x11 // OOC
  279. #define LED_SAMPLE_RT_DET 0x12 // OOC
  280. #define LED_SPINNING 0x13 // OOC
  281. #define LED_CAV 0x14 // OOC
  282. #define LED_CLV 0x15 // OOC
  283. #define LED_REC_FMT_DET 0x16 // OOC
  284. #define LED_OFF_HOOK 0x17 // OOC
  285. #define LED_RING 0x18 // OOC
  286. #define LED_MSG_WAITING 0x19 // OOC
  287. #define LED_DATA_MODE 0x1A // OOC
  288. #define LED_BAT_OPERATION 0x1B // OOC
  289. #define LED_BAT_OK 0x1C // OOC
  290. #define LED_BAT_LOW 0x1D // OOC
  291. #define LED_SPEAKER 0x1E // OOC
  292. #define LED_HEAD_SET 0x1F // OOC
  293. #define LED_HOLD 0x20 // OOC
  294. #define LED_MICROPHONE 0x21 // OOC
  295. #define LED_COVERAGE 0x22 // OOC
  296. #define LED_NIGHT_MODE 0x23 // OOC
  297. #define LED_SEND_CALLS 0x24 // OOC
  298. #define LED_CALL_PICKUP 0x25 // OOC
  299. #define LED_CONFERENCE 0x26 // OOC
  300. #define LED_STAND_BY 0x27 // OOC
  301. #define LED_CAMERA_ON 0x28 // OOC
  302. #define LED_CAMERA_OFF 0x29 // OOC
  303. #define LED_ON_LINE 0x2A // OOC
  304. #define LED_OFF_LINE 0x2B // OOC
  305. #define LED_BUSY 0x2C // OOC
  306. #define LED_READY 0x2D // OOC
  307. #define LED_PAPER_OUT 0x2E // OOC
  308. #define LED_PAPER_JAM 0x2F // OOC
  309. #define LED_REMOTE 0x30 // OOC
  310. #define LED_FORWARD 0x31 // OOC
  311. #define LED_REVERSE 0x32 // OOC
  312. #define LED_STOP 0x33 // OOC
  313. #define LED_REWIND 0x34 // OOC
  314. #define LED_FAST_FORWARD 0x35 // OOC
  315. #define LED_PLAY 0x36 // OOC
  316. #define LED_PAUSE 0x37 // OOC
  317. #define LED_RECORD 0x38 // OOC
  318. #define LED_ERROR 0x39 // OOC
  319. #define LED_USI 0x3A // US
  320. #define LED_UIUI 0x3B // US
  321. #define LED_UMMI 0x3C // UM
  322. #define LED_IND_ON 0x3D // Sel
  323. #define LED_IND_FLASH 0x3E // Sel
  324. #define LED_IND_SLOW_BLNK 0x3F // Sel
  325. #define LED_IND_FAST_BLNK 0x40 // Sel
  326. #define LED_IND_OFF 0x41 // Sel
  327. #define LED_FLASH_ON_TIME 0x42 // DV
  328. #define LED_SLW_B_ON_TIME 0x43 // DV
  329. #define LED_SLW_B_OFF_TIME 0x44 // DV
  330. #define LED_FST_B_ON_TIME 0x45 // DV
  331. #define LED_FST_B_OFF_TIME 0x46 // DV
  332. #define LED_UIC 0x47 // UM
  333. #define LED_IND_RED 0x48 // Sel
  334. #define LED_IND_GREEN 0x49 // Sel
  335. #define LED_IND_AMBER 0x4A // Sel
  336. #define LED_GENERIC_IND 0x4B // OOC
  337. #define LED_SYS_SUSPEND 0x4C // OOC
  338. #define LED_EXT_PWR_CONN 0x4D // OOC
  339. // 0x4E - 0xFFFF Reserved
  340. // List of Mouse Buttons - USB HID 1.11 pg 67
  341. #define MOUSE_NOPRESS 0x00
  342. #define MOUSE_PRIMARY 0x01 // Button 1
  343. #define MOUSE_SECONDARY 0x02 // Button 2
  344. #define MOUSE_TERTIARY 0x03 // Button 3
  345. #define MOUSE_BUTTON(x) x
  346. // Continues to 0xFFFF, the higher the Mouse code, the selector significance descreases
  347. // Buttons can be defined as:
  348. // Sel - Selector
  349. // OOC - On/Off Control
  350. // MC - Momentary Control
  351. // OSC - One-Shot Control
  352. // depending on context.
  353. #endif