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.

usb_keycodes.h 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. /*
  2. * Key codes from HID Keyboard/Keypad Page
  3. * http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
  4. *
  5. * Based on Keyboard Upgrade v0.3.0 http://github.com/rhomann/kbupgrade
  6. */
  7. /*
  8. * Keyboard Upgrade -- Firmware for homebrew computer keyboard controllers.
  9. * Copyright (C) 2009 Robert Homann
  10. *
  11. * Based on RUMP (http://mg8.org/rump/), Copyright (C) 2008 Chris Lee
  12. *
  13. * Based on c64key (http://symlink.dk/projects/c64key/),
  14. * Copyright (C) 2006-2007 Mikkel Holm Olsen
  15. *
  16. * Based on HID-Test by Christian Starkjohann, Objective Development
  17. *
  18. * This file is part of the Keyboard Upgrade package.
  19. *
  20. * This program is free software; you can redistribute it and/or modify
  21. * it under the terms of the GNU General Public License as published by
  22. * the Free Software Foundation; either version 2 of the License, or
  23. * (at your option) any later version.
  24. *
  25. * This program is distributed in the hope that it will be useful, but
  26. * WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. * GNU General Public License for more details.
  29. *
  30. * You should have received a copy of the GNU General Public License
  31. * along with the Keyboard Upgrade package; if not, write to the
  32. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  33. * MA 02110-1301 USA
  34. */
  35. #ifndef USB_KEYCODES_H
  36. #define USB_KEYCODES_H
  37. #define IS_ERROR(code) (KB_ROLL_OVER <= (code) && (code) <= KB_UNDEFINED)
  38. #define IS_KEY(code) (KB_A <= (code) && (code) <= KP_HEXADECIMAL)
  39. #define IS_MOD(code) (KB_LCTRL <= (code) && (code) <= KB_RGUI)
  40. #define IS_FN(code) (FN_0 <= (code) && (code) <= FN_7)
  41. #define IS_MOUSE(code) (MS_UP <= (code) && (code) <= MS_WH_RIGHT)
  42. #define IS_MOUSE_MOVE(code) (MS_UP <= (code) && (code) <= MS_RIGHT)
  43. #define IS_MOUSE_BUTTON(code) (MS_BTN1 <= (code) && (code) <= MS_BTN5)
  44. #define IS_MOUSE_WHEEL(code) (MS_WH_UP <= (code) && (code) <= MS_WH_RIGHT)
  45. #define MOD_BIT(code) (1<<((code) & 0x07))
  46. #define FN_BIT(code) (1<<((code) - FN_0))
  47. // short names
  48. #define KB_LCTL KB_LCTRL
  49. #define KB_RCTL KB_RCTRL
  50. #define KB_LSFT KB_LSHIFT
  51. #define KB_RSFT KB_RSHIFT
  52. #define KB_ESC KB_ESCAPE
  53. #define KB_BSPC KB_BSPACE
  54. #define KB_ENT KB_ENTER
  55. #define KB_DEL KB_DELETE
  56. #define KB_INS KB_INSERT
  57. #define KB_CAPS KB_CAPSLOCK
  58. #define KB_RGHT KB_RIGHT
  59. #define KB_PGDN KB_PGDOWN
  60. #define KB_PSCR KB_PSCREEN
  61. #define KB_SLCK KB_SCKLOCK
  62. #define KB_BRK KB_BREAK
  63. #define KB_SPC KB_SPACE
  64. #define KB_MINS KB_MINUS
  65. #define KB_EQL KB_EQUAL
  66. #define KB_GRV KB_GRAVE
  67. #define KB_RBRC KB_RBRACKET
  68. #define KB_LBRC KB_LBRACKET
  69. #define KB_COMM KB_COMMA
  70. #define KB_BSLS KB_BSLASH
  71. #define KB_SLSH KB_SLASH
  72. #define KB_SCLN KB_SCOLON
  73. #define KB_PWR KB_POWER
  74. #define KP_SLSH KP_SLASH
  75. #define KP_ASTR KP_ASTERISK
  76. #define KP_MINS KP_MINUS
  77. #define MS_RGHT MS_RIGHT
  78. #define MS_WH_U MS_WH_UP
  79. #define MS_WH_D MS_WH_DOWN
  80. #define MS_WH_L MS_WH_LEFT
  81. #define MS_WH_R MS_WH_RIGHT
  82. enum keycodes {
  83. KB_NO = 0,
  84. KB_ROLL_OVER,
  85. KB_POST_FAIL,
  86. KB_UNDEFINED,
  87. KB_A,
  88. KB_B,
  89. KB_C,
  90. KB_D,
  91. KB_E,
  92. KB_F,
  93. KB_G,
  94. KB_H,
  95. KB_I,
  96. KB_J,
  97. KB_K,
  98. KB_L,
  99. KB_M, /* 0x10 */
  100. KB_N,
  101. KB_O,
  102. KB_P,
  103. KB_Q,
  104. KB_R,
  105. KB_S,
  106. KB_T,
  107. KB_U,
  108. KB_V,
  109. KB_W,
  110. KB_X,
  111. KB_Y,
  112. KB_Z,
  113. KB_1,
  114. KB_2,
  115. KB_3, /* 0x20 */
  116. KB_4,
  117. KB_5,
  118. KB_6,
  119. KB_7,
  120. KB_8,
  121. KB_9,
  122. KB_0,
  123. KB_ENTER,
  124. KB_ESCAPE,
  125. KB_BSPACE,
  126. KB_TAB,
  127. KB_SPACE,
  128. KB_MINUS,
  129. KB_EQUAL,
  130. KB_LBRACKET, /* [ */
  131. KB_RBRACKET, /* ] */
  132. KB_BSLASH, /* \ (and |) */
  133. KB_NONUS_HASH, /* Non-US # and ~ */
  134. KB_SCOLON, /* ; (and :) */
  135. KB_QUOTE, /* ' and " */
  136. KB_GRAVE, /* Grave accent and tilde */
  137. KB_COMMA, /* , and < */
  138. KB_DOT, /* . and > */
  139. KB_SLASH, /* / and ? */
  140. KB_CAPSLOCK,
  141. KB_F1,
  142. KB_F2,
  143. KB_F3,
  144. KB_F4,
  145. KB_F5,
  146. KB_F6,
  147. KB_F7, /* 0x40 */
  148. KB_F8,
  149. KB_F9,
  150. KB_F10,
  151. KB_F11,
  152. KB_F12,
  153. KB_PSCREEN,
  154. KB_SCKLOCK,
  155. KB_BREAK,
  156. KB_INSERT,
  157. KB_HOME,
  158. KB_PGUP,
  159. KB_DELETE,
  160. KB_END,
  161. KB_PGDOWN,
  162. KB_RIGHT,
  163. KB_LEFT, /* 0x50 */
  164. KB_DOWN,
  165. KB_UP,
  166. KB_NUMLOCK,
  167. KP_SLASH,
  168. KP_ASTERISK,
  169. KP_MINUS,
  170. KP_PLUS,
  171. KP_ENTER,
  172. KP_1,
  173. KP_2,
  174. KP_3,
  175. KP_4,
  176. KP_5,
  177. KP_6,
  178. KP_7,
  179. KP_8, /* 0x60 */
  180. KP_9,
  181. KP_0,
  182. KP_DOT,
  183. KB_NONUS_BSLASH, /* Non-US \ and | */
  184. KB_APPLICATION,
  185. KB_POWER,
  186. KP_EQUAL,
  187. KB_F13,
  188. KB_F14,
  189. KB_F15,
  190. KB_F16,
  191. KB_F17,
  192. KB_F18,
  193. KB_F19,
  194. KB_F20,
  195. KB_F21, /* 0x70 */
  196. KB_F22,
  197. KB_F23,
  198. KB_F24,
  199. KB_EXECUTE,
  200. KB_HELP,
  201. KB_MENU,
  202. KB_SELECT,
  203. KB_STOP,
  204. KB_AGAIN,
  205. KB_UNDO,
  206. KB_CUT,
  207. KB_COPY,
  208. KB_PASTE,
  209. KB_FIND,
  210. KB_MUTE,
  211. KB_VOLUP, /* 0x80 */
  212. KB_VOLDOWN,
  213. KB_LOCKING_CAPS, /* locking Caps Lock */
  214. KB_LOCKING_NUM, /* locking Num Lock */
  215. KB_LOCKING_SCROLL, /* locking Scroll Lock */
  216. KP_COMMA,
  217. KP_EQUAL_AS400, /* equal sign on AS/400 */
  218. KB_INT1,
  219. KB_INT2,
  220. KB_INT3,
  221. KB_INT4,
  222. KB_INT5,
  223. KB_INT6,
  224. KB_INT7,
  225. KB_INT8,
  226. KB_INT9,
  227. KB_LANG1, /* 0x90 */
  228. KB_LANG2,
  229. KB_LANG3,
  230. KB_LANG4,
  231. KB_LANG5,
  232. KB_LANG6,
  233. KB_LANG7,
  234. KB_LANG8,
  235. KB_LANG9,
  236. KB_ALT_ERASE,
  237. KB_SYSREQ,
  238. KB_CANCEL,
  239. KB_CLEAR,
  240. KB_PRIOR,
  241. KB_RETURN,
  242. KB_SEPARATOR,
  243. KB_OUT,
  244. KB_OPER,
  245. KB_CLEAR_AGAIN,
  246. KB_CRSEL,
  247. KB_EXSEL,
  248. KP_00 = 0xB0,
  249. KP_000,
  250. KB_THOUSANDS_SEPARATOR,
  251. KB_DECIMAL_SEPARATOR,
  252. CURRENCY_UNIT,
  253. CURRENCY_SUB_UNIT,
  254. KP_LPAREN,
  255. KP_RPAREN,
  256. KP_LCBRACKET, /* { */
  257. KP_RCBRACKET, /* } */
  258. KP_TAB,
  259. KP_BSPACE,
  260. KP_A,
  261. KP_B,
  262. KP_C,
  263. KP_D,
  264. KP_E,
  265. KP_F,
  266. KP_XOR,
  267. KP_HAT,
  268. KP_PERC,
  269. KP_LT,
  270. KP_GT,
  271. KP_AND,
  272. KP_LAZYAND,
  273. KP_OR,
  274. KP_LAZYOR,
  275. KP_COLON,
  276. KP_HASH,
  277. KP_SPACE,
  278. KP_ATMARK,
  279. KP_EXCLAMATION,
  280. KP_MEM_STORE,
  281. KP_MEM_RECALL,
  282. KP_MEM_CLEAR,
  283. KP_MEM_ADD,
  284. KP_MEM_SUB,
  285. KP_MEM_MUL,
  286. KP_MEM_DIV,
  287. KP_PLUS_MINUS,
  288. KP_CLEAR,
  289. KP_CLEAR_ENTRY,
  290. KP_BINARY,
  291. KP_OCTAL,
  292. KP_DECIMAL,
  293. KP_HEXADECIMAL,
  294. /* modifiers */
  295. KB_LCTRL = 0xE0, /* 0x01 */
  296. KB_LSHIFT, /* 0x02 */
  297. KB_LALT, /* 0x04 */
  298. KB_LGUI, /* 0x08 */
  299. KB_RCTRL, /* 0x10 */
  300. KB_RSHIFT, /* 0x20 */
  301. KB_RALT, /* 0x40 */
  302. KB_RGUI, /* 0x80 */
  303. /* extensions for internal use */
  304. FN_0 = 0xE8,
  305. FN_1,
  306. FN_2,
  307. FN_3,
  308. FN_4,
  309. FN_5,
  310. FN_6,
  311. FN_7,
  312. MS_UP = 0xF0,
  313. MS_DOWN,
  314. MS_LEFT,
  315. MS_RIGHT,
  316. MS_BTN1 = 0xF4,
  317. MS_BTN2,
  318. MS_BTN3,
  319. MS_BTN4,
  320. MS_BTN5,
  321. MS_WH_UP,
  322. MS_WH_DOWN,
  323. MS_WH_LEFT,
  324. MS_WH_RIGHT,
  325. };
  326. #endif /* USB_KEYCODES_H */