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