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