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