SDL_scancode.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * # CategoryScancode
  20. *
  21. * Defines keyboard scancodes.
  22. */
  23. #ifndef SDL_scancode_h_
  24. #define SDL_scancode_h_
  25. #include <SDL3/SDL_stdinc.h>
  26. /**
  27. * The SDL keyboard scancode representation.
  28. *
  29. * An SDL scancode is the physical representation of a key on the keyboard,
  30. * independent of language and keyboard mapping.
  31. *
  32. * Values of this type are used to represent keyboard keys, among other places
  33. * in the `scancode` field of the SDL_KeyboardEvent structure.
  34. *
  35. * The values in this enumeration are based on the USB usage page standard:
  36. * https://usb.org/sites/default/files/hut1_5.pdf
  37. *
  38. * \since This enum is available since SDL 3.1.3.
  39. */
  40. typedef enum SDL_Scancode
  41. {
  42. SDL_SCANCODE_UNKNOWN = 0,
  43. /**
  44. * \name Usage page 0x07
  45. *
  46. * These values are from usage page 0x07 (USB keyboard page).
  47. */
  48. /* @{ */
  49. SDL_SCANCODE_A = 4,
  50. SDL_SCANCODE_B = 5,
  51. SDL_SCANCODE_C = 6,
  52. SDL_SCANCODE_D = 7,
  53. SDL_SCANCODE_E = 8,
  54. SDL_SCANCODE_F = 9,
  55. SDL_SCANCODE_G = 10,
  56. SDL_SCANCODE_H = 11,
  57. SDL_SCANCODE_I = 12,
  58. SDL_SCANCODE_J = 13,
  59. SDL_SCANCODE_K = 14,
  60. SDL_SCANCODE_L = 15,
  61. SDL_SCANCODE_M = 16,
  62. SDL_SCANCODE_N = 17,
  63. SDL_SCANCODE_O = 18,
  64. SDL_SCANCODE_P = 19,
  65. SDL_SCANCODE_Q = 20,
  66. SDL_SCANCODE_R = 21,
  67. SDL_SCANCODE_S = 22,
  68. SDL_SCANCODE_T = 23,
  69. SDL_SCANCODE_U = 24,
  70. SDL_SCANCODE_V = 25,
  71. SDL_SCANCODE_W = 26,
  72. SDL_SCANCODE_X = 27,
  73. SDL_SCANCODE_Y = 28,
  74. SDL_SCANCODE_Z = 29,
  75. SDL_SCANCODE_1 = 30,
  76. SDL_SCANCODE_2 = 31,
  77. SDL_SCANCODE_3 = 32,
  78. SDL_SCANCODE_4 = 33,
  79. SDL_SCANCODE_5 = 34,
  80. SDL_SCANCODE_6 = 35,
  81. SDL_SCANCODE_7 = 36,
  82. SDL_SCANCODE_8 = 37,
  83. SDL_SCANCODE_9 = 38,
  84. SDL_SCANCODE_0 = 39,
  85. SDL_SCANCODE_RETURN = 40,
  86. SDL_SCANCODE_ESCAPE = 41,
  87. SDL_SCANCODE_BACKSPACE = 42,
  88. SDL_SCANCODE_TAB = 43,
  89. SDL_SCANCODE_SPACE = 44,
  90. SDL_SCANCODE_MINUS = 45,
  91. SDL_SCANCODE_EQUALS = 46,
  92. SDL_SCANCODE_LEFTBRACKET = 47,
  93. SDL_SCANCODE_RIGHTBRACKET = 48,
  94. SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return
  95. * key on ISO keyboards and at the right end
  96. * of the QWERTY row on ANSI keyboards.
  97. * Produces REVERSE SOLIDUS (backslash) and
  98. * VERTICAL LINE in a US layout, REVERSE
  99. * SOLIDUS and VERTICAL LINE in a UK Mac
  100. * layout, NUMBER SIGN and TILDE in a UK
  101. * Windows layout, DOLLAR SIGN and POUND SIGN
  102. * in a Swiss German layout, NUMBER SIGN and
  103. * APOSTROPHE in a German layout, GRAVE
  104. * ACCENT and POUND SIGN in a French Mac
  105. * layout, and ASTERISK and MICRO SIGN in a
  106. * French Windows layout.
  107. */
  108. SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code
  109. * instead of 49 for the same key, but all
  110. * OSes I've seen treat the two codes
  111. * identically. So, as an implementor, unless
  112. * your keyboard generates both of those
  113. * codes and your OS treats them differently,
  114. * you should generate SDL_SCANCODE_BACKSLASH
  115. * instead of this code. As a user, you
  116. * should not rely on this code because SDL
  117. * will never generate it with most (all?)
  118. * keyboards.
  119. */
  120. SDL_SCANCODE_SEMICOLON = 51,
  121. SDL_SCANCODE_APOSTROPHE = 52,
  122. SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI
  123. * and ISO keyboards). Produces GRAVE ACCENT and
  124. * TILDE in a US Windows layout and in US and UK
  125. * Mac layouts on ANSI keyboards, GRAVE ACCENT
  126. * and NOT SIGN in a UK Windows layout, SECTION
  127. * SIGN and PLUS-MINUS SIGN in US and UK Mac
  128. * layouts on ISO keyboards, SECTION SIGN and
  129. * DEGREE SIGN in a Swiss German layout (Mac:
  130. * only on ISO keyboards), CIRCUMFLEX ACCENT and
  131. * DEGREE SIGN in a German layout (Mac: only on
  132. * ISO keyboards), SUPERSCRIPT TWO and TILDE in a
  133. * French Windows layout, COMMERCIAL AT and
  134. * NUMBER SIGN in a French Mac layout on ISO
  135. * keyboards, and LESS-THAN SIGN and GREATER-THAN
  136. * SIGN in a Swiss German, German, or French Mac
  137. * layout on ANSI keyboards.
  138. */
  139. SDL_SCANCODE_COMMA = 54,
  140. SDL_SCANCODE_PERIOD = 55,
  141. SDL_SCANCODE_SLASH = 56,
  142. SDL_SCANCODE_CAPSLOCK = 57,
  143. SDL_SCANCODE_F1 = 58,
  144. SDL_SCANCODE_F2 = 59,
  145. SDL_SCANCODE_F3 = 60,
  146. SDL_SCANCODE_F4 = 61,
  147. SDL_SCANCODE_F5 = 62,
  148. SDL_SCANCODE_F6 = 63,
  149. SDL_SCANCODE_F7 = 64,
  150. SDL_SCANCODE_F8 = 65,
  151. SDL_SCANCODE_F9 = 66,
  152. SDL_SCANCODE_F10 = 67,
  153. SDL_SCANCODE_F11 = 68,
  154. SDL_SCANCODE_F12 = 69,
  155. SDL_SCANCODE_PRINTSCREEN = 70,
  156. SDL_SCANCODE_SCROLLLOCK = 71,
  157. SDL_SCANCODE_PAUSE = 72,
  158. SDL_SCANCODE_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but
  159. does send code 73, not 117) */
  160. SDL_SCANCODE_HOME = 74,
  161. SDL_SCANCODE_PAGEUP = 75,
  162. SDL_SCANCODE_DELETE = 76,
  163. SDL_SCANCODE_END = 77,
  164. SDL_SCANCODE_PAGEDOWN = 78,
  165. SDL_SCANCODE_RIGHT = 79,
  166. SDL_SCANCODE_LEFT = 80,
  167. SDL_SCANCODE_DOWN = 81,
  168. SDL_SCANCODE_UP = 82,
  169. SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards
  170. */
  171. SDL_SCANCODE_KP_DIVIDE = 84,
  172. SDL_SCANCODE_KP_MULTIPLY = 85,
  173. SDL_SCANCODE_KP_MINUS = 86,
  174. SDL_SCANCODE_KP_PLUS = 87,
  175. SDL_SCANCODE_KP_ENTER = 88,
  176. SDL_SCANCODE_KP_1 = 89,
  177. SDL_SCANCODE_KP_2 = 90,
  178. SDL_SCANCODE_KP_3 = 91,
  179. SDL_SCANCODE_KP_4 = 92,
  180. SDL_SCANCODE_KP_5 = 93,
  181. SDL_SCANCODE_KP_6 = 94,
  182. SDL_SCANCODE_KP_7 = 95,
  183. SDL_SCANCODE_KP_8 = 96,
  184. SDL_SCANCODE_KP_9 = 97,
  185. SDL_SCANCODE_KP_0 = 98,
  186. SDL_SCANCODE_KP_PERIOD = 99,
  187. SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO
  188. * keyboards have over ANSI ones,
  189. * located between left shift and Y.
  190. * Produces GRAVE ACCENT and TILDE in a
  191. * US or UK Mac layout, REVERSE SOLIDUS
  192. * (backslash) and VERTICAL LINE in a
  193. * US or UK Windows layout, and
  194. * LESS-THAN SIGN and GREATER-THAN SIGN
  195. * in a Swiss German, German, or French
  196. * layout. */
  197. SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */
  198. SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag,
  199. * not a physical key - but some Mac keyboards
  200. * do have a power key. */
  201. SDL_SCANCODE_KP_EQUALS = 103,
  202. SDL_SCANCODE_F13 = 104,
  203. SDL_SCANCODE_F14 = 105,
  204. SDL_SCANCODE_F15 = 106,
  205. SDL_SCANCODE_F16 = 107,
  206. SDL_SCANCODE_F17 = 108,
  207. SDL_SCANCODE_F18 = 109,
  208. SDL_SCANCODE_F19 = 110,
  209. SDL_SCANCODE_F20 = 111,
  210. SDL_SCANCODE_F21 = 112,
  211. SDL_SCANCODE_F22 = 113,
  212. SDL_SCANCODE_F23 = 114,
  213. SDL_SCANCODE_F24 = 115,
  214. SDL_SCANCODE_EXECUTE = 116,
  215. SDL_SCANCODE_HELP = 117, /**< AL Integrated Help Center */
  216. SDL_SCANCODE_MENU = 118, /**< Menu (show menu) */
  217. SDL_SCANCODE_SELECT = 119,
  218. SDL_SCANCODE_STOP = 120, /**< AC Stop */
  219. SDL_SCANCODE_AGAIN = 121, /**< AC Redo/Repeat */
  220. SDL_SCANCODE_UNDO = 122, /**< AC Undo */
  221. SDL_SCANCODE_CUT = 123, /**< AC Cut */
  222. SDL_SCANCODE_COPY = 124, /**< AC Copy */
  223. SDL_SCANCODE_PASTE = 125, /**< AC Paste */
  224. SDL_SCANCODE_FIND = 126, /**< AC Find */
  225. SDL_SCANCODE_MUTE = 127,
  226. SDL_SCANCODE_VOLUMEUP = 128,
  227. SDL_SCANCODE_VOLUMEDOWN = 129,
  228. /* not sure whether there's a reason to enable these */
  229. /* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */
  230. /* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */
  231. /* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */
  232. SDL_SCANCODE_KP_COMMA = 133,
  233. SDL_SCANCODE_KP_EQUALSAS400 = 134,
  234. SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see
  235. footnotes in USB doc */
  236. SDL_SCANCODE_INTERNATIONAL2 = 136,
  237. SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */
  238. SDL_SCANCODE_INTERNATIONAL4 = 138,
  239. SDL_SCANCODE_INTERNATIONAL5 = 139,
  240. SDL_SCANCODE_INTERNATIONAL6 = 140,
  241. SDL_SCANCODE_INTERNATIONAL7 = 141,
  242. SDL_SCANCODE_INTERNATIONAL8 = 142,
  243. SDL_SCANCODE_INTERNATIONAL9 = 143,
  244. SDL_SCANCODE_LANG1 = 144, /**< Hangul/English toggle */
  245. SDL_SCANCODE_LANG2 = 145, /**< Hanja conversion */
  246. SDL_SCANCODE_LANG3 = 146, /**< Katakana */
  247. SDL_SCANCODE_LANG4 = 147, /**< Hiragana */
  248. SDL_SCANCODE_LANG5 = 148, /**< Zenkaku/Hankaku */
  249. SDL_SCANCODE_LANG6 = 149, /**< reserved */
  250. SDL_SCANCODE_LANG7 = 150, /**< reserved */
  251. SDL_SCANCODE_LANG8 = 151, /**< reserved */
  252. SDL_SCANCODE_LANG9 = 152, /**< reserved */
  253. SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */
  254. SDL_SCANCODE_SYSREQ = 154,
  255. SDL_SCANCODE_CANCEL = 155, /**< AC Cancel */
  256. SDL_SCANCODE_CLEAR = 156,
  257. SDL_SCANCODE_PRIOR = 157,
  258. SDL_SCANCODE_RETURN2 = 158,
  259. SDL_SCANCODE_SEPARATOR = 159,
  260. SDL_SCANCODE_OUT = 160,
  261. SDL_SCANCODE_OPER = 161,
  262. SDL_SCANCODE_CLEARAGAIN = 162,
  263. SDL_SCANCODE_CRSEL = 163,
  264. SDL_SCANCODE_EXSEL = 164,
  265. SDL_SCANCODE_KP_00 = 176,
  266. SDL_SCANCODE_KP_000 = 177,
  267. SDL_SCANCODE_THOUSANDSSEPARATOR = 178,
  268. SDL_SCANCODE_DECIMALSEPARATOR = 179,
  269. SDL_SCANCODE_CURRENCYUNIT = 180,
  270. SDL_SCANCODE_CURRENCYSUBUNIT = 181,
  271. SDL_SCANCODE_KP_LEFTPAREN = 182,
  272. SDL_SCANCODE_KP_RIGHTPAREN = 183,
  273. SDL_SCANCODE_KP_LEFTBRACE = 184,
  274. SDL_SCANCODE_KP_RIGHTBRACE = 185,
  275. SDL_SCANCODE_KP_TAB = 186,
  276. SDL_SCANCODE_KP_BACKSPACE = 187,
  277. SDL_SCANCODE_KP_A = 188,
  278. SDL_SCANCODE_KP_B = 189,
  279. SDL_SCANCODE_KP_C = 190,
  280. SDL_SCANCODE_KP_D = 191,
  281. SDL_SCANCODE_KP_E = 192,
  282. SDL_SCANCODE_KP_F = 193,
  283. SDL_SCANCODE_KP_XOR = 194,
  284. SDL_SCANCODE_KP_POWER = 195,
  285. SDL_SCANCODE_KP_PERCENT = 196,
  286. SDL_SCANCODE_KP_LESS = 197,
  287. SDL_SCANCODE_KP_GREATER = 198,
  288. SDL_SCANCODE_KP_AMPERSAND = 199,
  289. SDL_SCANCODE_KP_DBLAMPERSAND = 200,
  290. SDL_SCANCODE_KP_VERTICALBAR = 201,
  291. SDL_SCANCODE_KP_DBLVERTICALBAR = 202,
  292. SDL_SCANCODE_KP_COLON = 203,
  293. SDL_SCANCODE_KP_HASH = 204,
  294. SDL_SCANCODE_KP_SPACE = 205,
  295. SDL_SCANCODE_KP_AT = 206,
  296. SDL_SCANCODE_KP_EXCLAM = 207,
  297. SDL_SCANCODE_KP_MEMSTORE = 208,
  298. SDL_SCANCODE_KP_MEMRECALL = 209,
  299. SDL_SCANCODE_KP_MEMCLEAR = 210,
  300. SDL_SCANCODE_KP_MEMADD = 211,
  301. SDL_SCANCODE_KP_MEMSUBTRACT = 212,
  302. SDL_SCANCODE_KP_MEMMULTIPLY = 213,
  303. SDL_SCANCODE_KP_MEMDIVIDE = 214,
  304. SDL_SCANCODE_KP_PLUSMINUS = 215,
  305. SDL_SCANCODE_KP_CLEAR = 216,
  306. SDL_SCANCODE_KP_CLEARENTRY = 217,
  307. SDL_SCANCODE_KP_BINARY = 218,
  308. SDL_SCANCODE_KP_OCTAL = 219,
  309. SDL_SCANCODE_KP_DECIMAL = 220,
  310. SDL_SCANCODE_KP_HEXADECIMAL = 221,
  311. SDL_SCANCODE_LCTRL = 224,
  312. SDL_SCANCODE_LSHIFT = 225,
  313. SDL_SCANCODE_LALT = 226, /**< alt, option */
  314. SDL_SCANCODE_LGUI = 227, /**< windows, command (apple), meta */
  315. SDL_SCANCODE_RCTRL = 228,
  316. SDL_SCANCODE_RSHIFT = 229,
  317. SDL_SCANCODE_RALT = 230, /**< alt gr, option */
  318. SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */
  319. SDL_SCANCODE_MODE = 257, /**< I'm not sure if this is really not covered
  320. * by any of the above, but since there's a
  321. * special SDL_KMOD_MODE for it I'm adding it here
  322. */
  323. /* @} *//* Usage page 0x07 */
  324. /**
  325. * \name Usage page 0x0C
  326. *
  327. * These values are mapped from usage page 0x0C (USB consumer page).
  328. *
  329. * There are way more keys in the spec than we can represent in the
  330. * current scancode range, so pick the ones that commonly come up in
  331. * real world usage.
  332. */
  333. /* @{ */
  334. SDL_SCANCODE_SLEEP = 258, /**< Sleep */
  335. SDL_SCANCODE_WAKE = 259, /**< Wake */
  336. SDL_SCANCODE_CHANNEL_INCREMENT = 260, /**< Channel Increment */
  337. SDL_SCANCODE_CHANNEL_DECREMENT = 261, /**< Channel Decrement */
  338. SDL_SCANCODE_MEDIA_PLAY = 262, /**< Play */
  339. SDL_SCANCODE_MEDIA_PAUSE = 263, /**< Pause */
  340. SDL_SCANCODE_MEDIA_RECORD = 264, /**< Record */
  341. SDL_SCANCODE_MEDIA_FAST_FORWARD = 265, /**< Fast Forward */
  342. SDL_SCANCODE_MEDIA_REWIND = 266, /**< Rewind */
  343. SDL_SCANCODE_MEDIA_NEXT_TRACK = 267, /**< Next Track */
  344. SDL_SCANCODE_MEDIA_PREVIOUS_TRACK = 268, /**< Previous Track */
  345. SDL_SCANCODE_MEDIA_STOP = 269, /**< Stop */
  346. SDL_SCANCODE_MEDIA_EJECT = 270, /**< Eject */
  347. SDL_SCANCODE_MEDIA_PLAY_PAUSE = 271, /**< Play / Pause */
  348. SDL_SCANCODE_MEDIA_SELECT = 272, /* Media Select */
  349. SDL_SCANCODE_AC_NEW = 273, /**< AC New */
  350. SDL_SCANCODE_AC_OPEN = 274, /**< AC Open */
  351. SDL_SCANCODE_AC_CLOSE = 275, /**< AC Close */
  352. SDL_SCANCODE_AC_EXIT = 276, /**< AC Exit */
  353. SDL_SCANCODE_AC_SAVE = 277, /**< AC Save */
  354. SDL_SCANCODE_AC_PRINT = 278, /**< AC Print */
  355. SDL_SCANCODE_AC_PROPERTIES = 279, /**< AC Properties */
  356. SDL_SCANCODE_AC_SEARCH = 280, /**< AC Search */
  357. SDL_SCANCODE_AC_HOME = 281, /**< AC Home */
  358. SDL_SCANCODE_AC_BACK = 282, /**< AC Back */
  359. SDL_SCANCODE_AC_FORWARD = 283, /**< AC Forward */
  360. SDL_SCANCODE_AC_STOP = 284, /**< AC Stop */
  361. SDL_SCANCODE_AC_REFRESH = 285, /**< AC Refresh */
  362. SDL_SCANCODE_AC_BOOKMARKS = 286, /**< AC Bookmarks */
  363. /* @} *//* Usage page 0x0C */
  364. /**
  365. * \name Mobile keys
  366. *
  367. * These are values that are often used on mobile phones.
  368. */
  369. /* @{ */
  370. SDL_SCANCODE_SOFTLEFT = 287, /**< Usually situated below the display on phones and
  371. used as a multi-function feature key for selecting
  372. a software defined function shown on the bottom left
  373. of the display. */
  374. SDL_SCANCODE_SOFTRIGHT = 288, /**< Usually situated below the display on phones and
  375. used as a multi-function feature key for selecting
  376. a software defined function shown on the bottom right
  377. of the display. */
  378. SDL_SCANCODE_CALL = 289, /**< Used for accepting phone calls. */
  379. SDL_SCANCODE_ENDCALL = 290, /**< Used for rejecting phone calls. */
  380. /* @} *//* Mobile keys */
  381. /* Add any other keys here. */
  382. SDL_SCANCODE_RESERVED = 400, /**< 400-500 reserved for dynamic keycodes */
  383. SDL_SCANCODE_COUNT = 512 /**< not a key, just marks the number of scancodes for array bounds */
  384. } SDL_Scancode;
  385. #endif /* SDL_scancode_h_ */