3ac1b55b7da849491d5da2a57d2c8e49e0a1ae60
[tmk_keyboard.git] / tmk_core / common / keycode.h
1 /*
2 Copyright 2011,2012 Jun Wako <wakojun@gmail.com>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /*
19 * Keycodes based on HID Usage Keyboard/Keypad Page(0x07) plus special codes
20 * http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
21 */
22 #ifndef KEYCODE_H
23 #define KEYCODE_H
24
25
26 #define IS_ERROR(code) (KC_ROLL_OVER <= (code) && (code) <= KC_UNDEFINED)
27
28 #ifndef ACTIONMAP_ENABLE
29 #define IS_KEY(code) (KC_A <= (code) && (code) <= KC_EXSEL)
30 #else
31 #define IS_KEY(code) ((KC_A <= (code) && (code) <= KC_EXSEL) || \
32 (KC_KP_00 <= (code) && (code) <= KC_KP_HEXADECIMAL))
33 #endif
34
35 #define IS_MOD(code) (KC_LCTRL <= (code) && (code) <= KC_RGUI)
36
37
38 #define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF))
39 #define IS_SYSTEM(code) (KC_PWR <= (code) && (code) <= KC_WAKE)
40 #define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV)
41 #define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31)
42 #define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2)
43 #define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT)
44 #define IS_MOUSEKEY_BUTTON(code) (KC_MS_BTN1 <= (code) && (code) <= KC_MS_BTN5)
45 #define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT)
46 #define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2)
47
48 #define MOD_BIT(code) (1<<MOD_INDEX(code))
49 #define MOD_INDEX(code) ((code) & 0x07)
50 #define FN_BIT(code) (1<<FN_INDEX(code))
51 #define FN_INDEX(code) ((code) - KC_FN0)
52 #define FN_MIN KC_FN0
53 #define FN_MAX KC_FN31
54
55
56 /*
57 * Short names for ease of definition of keymap
58 */
59 #define KC_LCTL KC_LCTRL
60 #define KC_RCTL KC_RCTRL
61 #define KC_LSFT KC_LSHIFT
62 #define KC_RSFT KC_RSHIFT
63 #define KC_ESC KC_ESCAPE
64 #define KC_BSPC KC_BSPACE
65 #define KC_ENT KC_ENTER
66 #define KC_DEL KC_DELETE
67 #define KC_INS KC_INSERT
68 #define KC_CAPS KC_CAPSLOCK
69 #define KC_CLCK KC_CAPSLOCK
70 #define KC_RGHT KC_RIGHT
71 #define KC_PGDN KC_PGDOWN
72 #define KC_PSCR KC_PSCREEN
73 #define KC_SLCK KC_SCROLLLOCK
74 #define KC_PAUS KC_PAUSE
75 #define KC_BRK KC_PAUSE
76 #define KC_NLCK KC_NUMLOCK
77 #define KC_SPC KC_SPACE
78 #define KC_MINS KC_MINUS
79 #define KC_EQL KC_EQUAL
80 #define KC_GRV KC_GRAVE
81 #define KC_RBRC KC_RBRACKET
82 #define KC_LBRC KC_LBRACKET
83 #define KC_COMM KC_COMMA
84 #define KC_BSLS KC_BSLASH
85 #define KC_SLSH KC_SLASH
86 #define KC_SCLN KC_SCOLON
87 #define KC_QUOT KC_QUOTE
88 #define KC_APP KC_APPLICATION
89 #define KC_NUHS KC_NONUS_HASH
90 #define KC_NUBS KC_NONUS_BSLASH
91 #define KC_LCAP KC_LOCKING_CAPS
92 #define KC_LNUM KC_LOCKING_NUM
93 #define KC_LSCR KC_LOCKING_SCROLL
94 #define KC_ERAS KC_ALT_ERASE
95 #define KC_CLR KC_CLEAR
96 /* Japanese specific */
97 #define KC_ZKHK KC_GRAVE
98 #define KC_RO KC_INT1
99 #define KC_KANA KC_INT2
100 #define KC_JYEN KC_INT3
101 #define KC_JPY KC_INT3
102 #define KC_HENK KC_INT4
103 #define KC_MHEN KC_INT5
104 /* Korean specific */
105 #define KC_HAEN KC_LANG1
106 #define KC_HANJ KC_LANG2
107 /* Keypad */
108 #define KC_P1 KC_KP_1
109 #define KC_P2 KC_KP_2
110 #define KC_P3 KC_KP_3
111 #define KC_P4 KC_KP_4
112 #define KC_P5 KC_KP_5
113 #define KC_P6 KC_KP_6
114 #define KC_P7 KC_KP_7
115 #define KC_P8 KC_KP_8
116 #define KC_P9 KC_KP_9
117 #define KC_P0 KC_KP_0
118 #define KC_PDOT KC_KP_DOT
119 #define KC_PCMM KC_KP_COMMA
120 #define KC_PSLS KC_KP_SLASH
121 #define KC_PAST KC_KP_ASTERISK
122 #define KC_PMNS KC_KP_MINUS
123 #define KC_PPLS KC_KP_PLUS
124 #define KC_PEQL KC_KP_EQUAL
125 #define KC_PENT KC_KP_ENTER
126 /* Unix function key */
127 #define KC_EXEC KC_EXECUTE
128 #define KC_SLCT KC_SELECT
129 #define KC_AGIN KC_AGAIN
130 #define KC_PSTE KC_PASTE
131 /* Mousekey */
132 #define KC_MS_U KC_MS_UP
133 #define KC_MS_D KC_MS_DOWN
134 #define KC_MS_L KC_MS_LEFT
135 #define KC_MS_R KC_MS_RIGHT
136 #define KC_BTN1 KC_MS_BTN1
137 #define KC_BTN2 KC_MS_BTN2
138 #define KC_BTN3 KC_MS_BTN3
139 #define KC_BTN4 KC_MS_BTN4
140 #define KC_BTN5 KC_MS_BTN5
141 #define KC_WH_U KC_MS_WH_UP
142 #define KC_WH_D KC_MS_WH_DOWN
143 #define KC_WH_L KC_MS_WH_LEFT
144 #define KC_WH_R KC_MS_WH_RIGHT
145 #define KC_ACL0 KC_MS_ACCEL0
146 #define KC_ACL1 KC_MS_ACCEL1
147 #define KC_ACL2 KC_MS_ACCEL2
148 /* Sytem Control */
149 #define KC_PWR KC_SYSTEM_POWER
150 #define KC_SLEP KC_SYSTEM_SLEEP
151 #define KC_WAKE KC_SYSTEM_WAKE
152 /* Consumer Page */
153 #define KC_MUTE KC_AUDIO_MUTE
154 #define KC_VOLU KC_AUDIO_VOL_UP
155 #define KC_VOLD KC_AUDIO_VOL_DOWN
156 #define KC_MNXT KC_MEDIA_NEXT_TRACK
157 #define KC_MPRV KC_MEDIA_PREV_TRACK
158 #define KC_MFFD KC_MEDIA_FAST_FORWARD
159 #define KC_MRWD KC_MEDIA_REWIND
160 #define KC_MSTP KC_MEDIA_STOP
161 #define KC_MPLY KC_MEDIA_PLAY_PAUSE
162 #define KC_EJCT KC_MEDIA_EJECT
163 #define KC_MSEL KC_MEDIA_SELECT
164 #define KC_MAIL KC_MAIL
165 #define KC_CALC KC_CALCULATOR
166 #define KC_MYCM KC_MY_COMPUTER
167 #define KC_WSCH KC_WWW_SEARCH
168 #define KC_WHOM KC_WWW_HOME
169 #define KC_WBAK KC_WWW_BACK
170 #define KC_WFWD KC_WWW_FORWARD
171 #define KC_WSTP KC_WWW_STOP
172 #define KC_WREF KC_WWW_REFRESH
173 #define KC_WFAV KC_WWW_FAVORITES
174 /* Jump to bootloader */
175 #define KC_BTLD KC_BOOTLOADER
176 /* Transparent */
177 #define KC_TRANSPARENT 1
178 #define KC_TRNS KC_TRANSPARENT
179
180
181
182 /* USB HID Keyboard/Keypad Usage(0x07) */
183 enum hid_keyboard_keypad_usage {
184 KC_NO = 0x00,
185 KC_ROLL_OVER,
186 KC_POST_FAIL,
187 KC_UNDEFINED,
188 KC_A, /* 0x04 */
189 KC_B,
190 KC_C,
191 KC_D,
192 KC_E,
193 KC_F,
194 KC_G,
195 KC_H,
196 KC_I,
197 KC_J,
198 KC_K,
199 KC_L,
200 KC_M, /* 0x10 */
201 KC_N,
202 KC_O,
203 KC_P,
204 KC_Q,
205 KC_R,
206 KC_S,
207 KC_T,
208 KC_U,
209 KC_V,
210 KC_W,
211 KC_X,
212 KC_Y,
213 KC_Z,
214 KC_1,
215 KC_2,
216 KC_3, /* 0x20 */
217 KC_4,
218 KC_5,
219 KC_6,
220 KC_7,
221 KC_8,
222 KC_9,
223 KC_0,
224 KC_ENTER,
225 KC_ESCAPE,
226 KC_BSPACE,
227 KC_TAB,
228 KC_SPACE,
229 KC_MINUS,
230 KC_EQUAL,
231 KC_LBRACKET,
232 KC_RBRACKET, /* 0x30 */
233 KC_BSLASH, /* \ (and |) */
234 KC_NONUS_HASH, /* Non-US # and ~ (Typically near the Enter key) */
235 KC_SCOLON, /* ; (and :) */
236 KC_QUOTE, /* ' and " */
237 KC_GRAVE, /* Grave accent and tilde */
238 KC_COMMA, /* , and < */
239 KC_DOT, /* . and > */
240 KC_SLASH, /* / and ? */
241 KC_CAPSLOCK,
242 KC_F1,
243 KC_F2,
244 KC_F3,
245 KC_F4,
246 KC_F5,
247 KC_F6,
248 KC_F7, /* 0x40 */
249 KC_F8,
250 KC_F9,
251 KC_F10,
252 KC_F11,
253 KC_F12,
254 KC_PSCREEN,
255 KC_SCROLLLOCK,
256 KC_PAUSE,
257 KC_INSERT,
258 KC_HOME,
259 KC_PGUP,
260 KC_DELETE,
261 KC_END,
262 KC_PGDOWN,
263 KC_RIGHT,
264 KC_LEFT, /* 0x50 */
265 KC_DOWN,
266 KC_UP,
267 KC_NUMLOCK,
268 KC_KP_SLASH,
269 KC_KP_ASTERISK,
270 KC_KP_MINUS,
271 KC_KP_PLUS,
272 KC_KP_ENTER,
273 KC_KP_1,
274 KC_KP_2,
275 KC_KP_3,
276 KC_KP_4,
277 KC_KP_5,
278 KC_KP_6,
279 KC_KP_7,
280 KC_KP_8, /* 0x60 */
281 KC_KP_9,
282 KC_KP_0,
283 KC_KP_DOT,
284 KC_NONUS_BSLASH, /* Non-US \ and | (Typically near the Left-Shift key) */
285 KC_APPLICATION,
286 KC_POWER,
287 KC_KP_EQUAL,
288 KC_F13,
289 KC_F14,
290 KC_F15,
291 KC_F16,
292 KC_F17,
293 KC_F18,
294 KC_F19,
295 KC_F20,
296 KC_F21, /* 0x70 */
297 KC_F22,
298 KC_F23,
299 KC_F24,
300 KC_EXECUTE,
301 KC_HELP,
302 KC_MENU,
303 KC_SELECT,
304 KC_STOP,
305 KC_AGAIN,
306 KC_UNDO,
307 KC_CUT,
308 KC_COPY,
309 KC_PASTE,
310 KC_FIND,
311 KC__MUTE,
312 KC__VOLUP, /* 0x80 */
313 KC__VOLDOWN,
314 KC_LOCKING_CAPS, /* locking Caps Lock */
315 KC_LOCKING_NUM, /* locking Num Lock */
316 KC_LOCKING_SCROLL, /* locking Scroll Lock */
317 KC_KP_COMMA,
318 KC_KP_EQUAL_AS400, /* equal sign on AS/400 */
319 KC_INT1,
320 KC_INT2,
321 KC_INT3,
322 KC_INT4,
323 KC_INT5,
324 KC_INT6,
325 KC_INT7,
326 KC_INT8,
327 KC_INT9,
328 KC_LANG1, /* 0x90 */
329 KC_LANG2,
330 KC_LANG3,
331 KC_LANG4,
332 KC_LANG5,
333 KC_LANG6,
334 KC_LANG7,
335 KC_LANG8,
336 KC_LANG9,
337 KC_ALT_ERASE,
338 KC_SYSREQ,
339 KC_CANCEL,
340 KC_CLEAR,
341 KC_PRIOR,
342 KC_RETURN,
343 KC_SEPARATOR,
344 KC_OUT, /* 0xA0 */
345 KC_OPER,
346 KC_CLEAR_AGAIN,
347 KC_CRSEL,
348 KC_EXSEL, /* 0xA4 */
349
350 /* NOTE: Following code range(0xB0-DD) are shared with special codes of 8-bit keymap */
351 KC_KP_00 = 0xB0,
352 KC_KP_000,
353 KC_THOUSANDS_SEPARATOR,
354 KC_DECIMAL_SEPARATOR,
355 KC_CURRENCY_UNIT,
356 KC_CURRENCY_SUB_UNIT,
357 KC_KP_LPAREN,
358 KC_KP_RPAREN,
359 KC_KP_LCBRACKET, /* { */
360 KC_KP_RCBRACKET, /* } */
361 KC_KP_TAB,
362 KC_KP_BSPACE,
363 KC_KP_A,
364 KC_KP_B,
365 KC_KP_C,
366 KC_KP_D,
367 KC_KP_E, /* 0xC0 */
368 KC_KP_F,
369 KC_KP_XOR,
370 KC_KP_HAT,
371 KC_KP_PERC,
372 KC_KP_LT,
373 KC_KP_GT,
374 KC_KP_AND,
375 KC_KP_LAZYAND,
376 KC_KP_OR,
377 KC_KP_LAZYOR,
378 KC_KP_COLON,
379 KC_KP_HASH,
380 KC_KP_SPACE,
381 KC_KP_ATMARK,
382 KC_KP_EXCLAMATION,
383 KC_KP_MEM_STORE, /* 0xD0 */
384 KC_KP_MEM_RECALL,
385 KC_KP_MEM_CLEAR,
386 KC_KP_MEM_ADD,
387 KC_KP_MEM_SUB,
388 KC_KP_MEM_MUL,
389 KC_KP_MEM_DIV,
390 KC_KP_PLUS_MINUS,
391 KC_KP_CLEAR,
392 KC_KP_CLEAR_ENTRY,
393 KC_KP_BINARY,
394 KC_KP_OCTAL,
395 KC_KP_DECIMAL,
396 KC_KP_HEXADECIMAL, /* 0xDD */
397
398 /* Modifiers */
399 KC_LCTRL = 0xE0,
400 KC_LSHIFT,
401 KC_LALT,
402 KC_LGUI,
403 KC_RCTRL,
404 KC_RSHIFT,
405 KC_RALT,
406 KC_RGUI, /* 0xE7 */
407 };
408
409 /* Special keycodes for 8-bit keymap
410 NOTE: 0xA5-DF and 0xE8-FF are used for internal special purpose */
411 enum internal_special_keycodes {
412 /* System Control */
413 KC_SYSTEM_POWER = 0xA5,
414 KC_SYSTEM_SLEEP,
415 KC_SYSTEM_WAKE,
416
417 /* Media Control */
418 KC_AUDIO_MUTE,
419 KC_AUDIO_VOL_UP,
420 KC_AUDIO_VOL_DOWN,
421 KC_MEDIA_NEXT_TRACK,
422 KC_MEDIA_PREV_TRACK,
423 KC_MEDIA_FAST_FORWARD,
424 KC_MEDIA_REWIND,
425 KC_MEDIA_STOP,
426 KC_MEDIA_PLAY_PAUSE,
427 KC_MEDIA_EJECT,
428 KC_MEDIA_SELECT,
429 KC_MAIL,
430 KC_CALCULATOR,
431 KC_MY_COMPUTER,
432 KC_WWW_SEARCH,
433 KC_WWW_HOME,
434 KC_WWW_BACK,
435 KC_WWW_FORWARD,
436 KC_WWW_STOP,
437 KC_WWW_REFRESH,
438 KC_WWW_FAVORITES, /* 0xBC */
439
440 /* Jump to bootloader */
441 KC_BOOTLOADER = 0xBF,
442
443 /* Fn key */
444 KC_FN0 = 0xC0,
445 KC_FN1,
446 KC_FN2,
447 KC_FN3,
448 KC_FN4,
449 KC_FN5,
450 KC_FN6,
451 KC_FN7,
452 KC_FN8,
453 KC_FN9,
454 KC_FN10,
455 KC_FN11,
456 KC_FN12,
457 KC_FN13,
458 KC_FN14,
459 KC_FN15,
460
461 KC_FN16 = 0xD0,
462 KC_FN17,
463 KC_FN18,
464 KC_FN19,
465 KC_FN20,
466 KC_FN21,
467 KC_FN22,
468 KC_FN23,
469 KC_FN24,
470 KC_FN25,
471 KC_FN26,
472 KC_FN27,
473 KC_FN28,
474 KC_FN29,
475 KC_FN30,
476 KC_FN31, /* 0xDF */
477
478 /**************************************/
479 /* 0xE0-E7 for Modifiers. DO NOT USE. */
480 /**************************************/
481
482 /* Mousekey */
483 KC_MS_UP = 0xF0,
484 KC_MS_DOWN,
485 KC_MS_LEFT,
486 KC_MS_RIGHT,
487 KC_MS_BTN1,
488 KC_MS_BTN2,
489 KC_MS_BTN3,
490 KC_MS_BTN4,
491 KC_MS_BTN5, /* 0xF8 */
492 /* Mousekey wheel */
493 KC_MS_WH_UP,
494 KC_MS_WH_DOWN,
495 KC_MS_WH_LEFT,
496 KC_MS_WH_RIGHT, /* 0xFC */
497 /* Mousekey accel */
498 KC_MS_ACCEL0,
499 KC_MS_ACCEL1,
500 KC_MS_ACCEL2 /* 0xFF */
501 };
502
503 #endif /* KEYCODE_H */
Imprint / Impressum