]> git.gir.st - tmk_keyboard.git/blob - common/usb_keycodes.h
Initial version of new code for layer switch is added.
[tmk_keyboard.git] / common / usb_keycodes.h
1 /*
2 Copyright 2011 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 * Key codes: HID Keyboard/Keypad Page(0x07)
20 * http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
21 */
22 #ifndef USB_KEYCODES_H
23 #define USB_KEYCODES_H
24
25
26 #define IS_ERROR(code) (KB_ROLL_OVER <= (code) && (code) <= KB_UNDEFINED)
27 #define IS_ANY(code) (KB_A <= (code))
28 #define IS_KEY(code) (KB_A <= (code) && (code) <= KB_EXSEL)
29 #define IS_MOD(code) (KB_LCTRL <= (code) && (code) <= KB_RGUI)
30 #define IS_FN(code) (KB_FN0 <= (code) && (code) <= KB_FN7)
31 #define IS_MOUSEKEY(code) (KB_MS_UP <= (code) && (code) <= KB_MS_WH_RIGHT)
32 #define IS_MOUSEKEY_MOVE(code) (KB_MS_UP <= (code) && (code) <= KB_MS_RIGHT)
33 #define IS_MOUSEKEY_BUTTON(code) (KB_MS_BTN1 <= (code) && (code) <= KB_MS_BTN5)
34 #define IS_MOUSEKEY_WHEEL(code) (KB_MS_WH_UP <= (code) && (code) <= KB_MS_WH_RIGHT)
35
36 #define MOD_BIT(code) (1<<((code) & 0x07))
37 #define FN_BIT(code) (1<<((code) - KB_FN0))
38 #define FN_INDEX(code) ((code) - KB_FN0)
39
40
41 /* Short names */
42 #define KB_LCTL KB_LCTRL
43 #define KB_RCTL KB_RCTRL
44 #define KB_LSFT KB_LSHIFT
45 #define KB_RSFT KB_RSHIFT
46 #define KB_ESC KB_ESCAPE
47 #define KB_BSPC KB_BSPACE
48 #define KB_ENT KB_ENTER
49 #define KB_DEL KB_DELETE
50 #define KB_INS KB_INSERT
51 #define KB_CAPS KB_CAPSLOCK
52 #define KB_RGHT KB_RIGHT
53 #define KB_PGDN KB_PGDOWN
54 #define KB_PSCR KB_PSCREEN
55 #define KB_SLCK KB_SCKLOCK
56 #define KB_PAUS KB_PAUSE
57 #define KB_BRK KB_PAUSE
58 #define KB_NLCK KB_NUMLOCK
59 #define KB_SPC KB_SPACE
60 #define KB_MINS KB_MINUS
61 #define KB_EQL KB_EQUAL
62 #define KB_GRV KB_GRAVE
63 #define KB_RBRC KB_RBRACKET
64 #define KB_LBRC KB_LBRACKET
65 #define KB_COMM KB_COMMA
66 #define KB_BSLS KB_BSLASH
67 #define KB_SLSH KB_SLASH
68 #define KB_SCLN KB_SCOLON
69 #define KB_QUOT KB_QUOTE
70 #define KB_APP KB_APPLICATION
71 #define KB_NUHS KB_NONUS_HASH
72 #define KB_NUBS KB_NONUS_BSLASH
73 #define KB_ERAS KB_ALT_ERASE,
74 #define KB_CLR KB_CLEAR
75 /* for Japanese */
76 #define KB_ZKHK KB_GRAVE
77 #define KB_RO KB_INT1
78 #define KB_KANA KB_INT2
79 #define KB_JYEN KB_INT3
80 #define KB_HENK KB_INT4
81 #define KB_MHEN KB_INT5
82 /* Keypad */
83 #define KB_P1 KB_KP_1
84 #define KB_P2 KB_KP_2
85 #define KB_P3 KB_KP_3
86 #define KB_P4 KB_KP_4
87 #define KB_P5 KB_KP_5
88 #define KB_P6 KB_KP_6
89 #define KB_P7 KB_KP_7
90 #define KB_P8 KB_KP_8
91 #define KB_P9 KB_KP_9
92 #define KB_P0 KB_KP_0
93 #define KB_PDOT KB_KP_DOT
94 #define KB_PCMM KB_KP_COMMA
95 #define KB_PSLS KB_KP_SLASH
96 #define KB_PAST KB_KP_ASTERISK
97 #define KB_PMNS KB_KP_MINUS
98 #define KB_PPLS KB_KP_PLUS
99 #define KB_PEQL KB_KP_EQUAL
100 #define KB_PENT KB_KP_ENTER
101 /* Mousekey */
102 #define KB_MS_U KB_MS_UP
103 #define KB_MS_D KB_MS_DOWN
104 #define KB_MS_L KB_MS_LEFT
105 #define KB_MS_R KB_MS_RIGHT
106 #define KB_BTN1 KB_MS_BTN1
107 #define KB_BTN2 KB_MS_BTN2
108 #define KB_BTN3 KB_MS_BTN3
109 #define KB_BTN4 KB_MS_BTN4
110 #define KB_BTN5 KB_MS_BTN5
111 #define KB_WH_U KB_MS_WH_UP
112 #define KB_WH_D KB_MS_WH_DOWN
113 #define KB_WH_L KB_MS_WH_LEFT
114 #define KB_WH_R KB_MS_WH_RIGHT
115 /* Sytem Control & Consumer usage */
116 #define KB_PWR KB_SYSTEM_POWER
117 #define KB_SLEP KB_SYSTEM_SLEEP
118 #define KB_WAKE KB_SYSTEM_WAKE
119 #define KB_MUTE KB_AUDIO_MUTE
120 #define KB_VOLU KB_AUDIO_VOL_UP
121 #define KB_VOLD KB_AUDIO_VOL_DOWN
122 #define KB_MNXT KB_MEDIA_NEXT_TRACK
123 #define KB_MPRV KB_MEDIA_PREV_TRACK
124 #define KB_MSTP KB_MEDIA_STOP
125 #define KB_MPLY KB_MEDIA_PLAY_PAUSE
126 #define KB_MSEL KB_MEDIA_SELECT
127 #define KB_MAIL KB_MAIL
128 #define KB_CALC KB_CALCULATOR
129 #define KB_MYCM KB_MY_COMPUTER
130 #define KB_WSCH KB_WWW_SEARCH
131 #define KB_WHOM KB_WWW_HOME
132 #define KB_WBAK KB_WWW_BACK
133 #define KB_WFWD KB_WWW_FORWARD
134 #define KB_WSTP KB_WWW_STOP
135 #define KB_WREF KB_WWW_REFRESH
136 #define KB_WFAV KB_WWW_FAVORITES
137
138
139 /* Special keycode */
140 enum special_keycodes {
141 /* System Control */
142 KB_SYSTEM_POWER = 0xB0,
143 KB_SYSTEM_SLEEP,
144 KB_SYSTEM_WAKE,
145
146 /* Consumer Page */
147 KB_AUDIO_MUTE,
148 KB_AUDIO_VOL_UP,
149 KB_AUDIO_VOL_DOWN,
150 KB_MEDIA_NEXT_TRACK,
151 KB_MEDIA_PREV_TRACK,
152 KB_MEDIA_STOP,
153 KB_MEDIA_PLAY_PAUSE,
154 KB_MEDIA_SELECT,
155 KB_MAIL,
156 KB_CALCULATOR,
157 KB_MY_COMPUTER,
158 KB_WWW_SEARCH,
159 KB_WWW_HOME,
160 KB_WWW_BACK, /* 0xC0 */
161 KB_WWW_FORWARD,
162 KB_WWW_STOP,
163 KB_WWW_REFRESH,
164 KB_WWW_FAVORITES,
165
166 /* reserve 0xE0-E7 for Modifiers */
167
168 /* Layer Switching */
169 KB_FN0 = 0xE8,
170 KB_FN1,
171 KB_FN2,
172 KB_FN3,
173 KB_FN4,
174 KB_FN5,
175 KB_FN6,
176 KB_FN7,
177
178 /* Mousekey */
179 KB_MS_UP = 0xF0,
180 KB_MS_DOWN,
181 KB_MS_LEFT,
182 KB_MS_RIGHT,
183 KB_MS_BTN1,
184 KB_MS_BTN2,
185 KB_MS_BTN3,
186 KB_MS_BTN4,
187 KB_MS_BTN5,
188 /* Mousekey wheel */
189 KB_MS_WH_UP,
190 KB_MS_WH_DOWN,
191 KB_MS_WH_LEFT,
192 KB_MS_WH_RIGHT,
193 };
194
195 enum keycodes {
196 KB_NO = 0,
197 KB_ROLL_OVER,
198 KB_POST_FAIL,
199 KB_UNDEFINED,
200 KB_A,
201 KB_B,
202 KB_C,
203 KB_D,
204 KB_E,
205 KB_F,
206 KB_G,
207 KB_H,
208 KB_I,
209 KB_J,
210 KB_K,
211 KB_L,
212 KB_M, /* 0x10 */
213 KB_N,
214 KB_O,
215 KB_P,
216 KB_Q,
217 KB_R,
218 KB_S,
219 KB_T,
220 KB_U,
221 KB_V,
222 KB_W,
223 KB_X,
224 KB_Y,
225 KB_Z,
226 KB_1,
227 KB_2,
228 KB_3, /* 0x20 */
229 KB_4,
230 KB_5,
231 KB_6,
232 KB_7,
233 KB_8,
234 KB_9,
235 KB_0,
236 KB_ENTER,
237 KB_ESCAPE,
238 KB_BSPACE,
239 KB_TAB,
240 KB_SPACE,
241 KB_MINUS,
242 KB_EQUAL,
243 KB_LBRACKET,
244 KB_RBRACKET, /* 0x30 */
245 KB_BSLASH, /* \ (and |) */
246 KB_NONUS_HASH, /* Non-US # and ~ */
247 KB_SCOLON, /* ; (and :) */
248 KB_QUOTE, /* ' and " */
249 KB_GRAVE, /* Grave accent and tilde */
250 KB_COMMA, /* , and < */
251 KB_DOT, /* . and > */
252 KB_SLASH, /* / and ? */
253 KB_CAPSLOCK,
254 KB_F1,
255 KB_F2,
256 KB_F3,
257 KB_F4,
258 KB_F5,
259 KB_F6,
260 KB_F7, /* 0x40 */
261 KB_F8,
262 KB_F9,
263 KB_F10,
264 KB_F11,
265 KB_F12,
266 KB_PSCREEN,
267 KB_SCKLOCK,
268 KB_PAUSE,
269 KB_INSERT,
270 KB_HOME,
271 KB_PGUP,
272 KB_DELETE,
273 KB_END,
274 KB_PGDOWN,
275 KB_RIGHT,
276 KB_LEFT, /* 0x50 */
277 KB_DOWN,
278 KB_UP,
279 KB_NUMLOCK,
280 KB_KP_SLASH,
281 KB_KP_ASTERISK,
282 KB_KP_MINUS,
283 KB_KP_PLUS,
284 KB_KP_ENTER,
285 KB_KP_1,
286 KB_KP_2,
287 KB_KP_3,
288 KB_KP_4,
289 KB_KP_5,
290 KB_KP_6,
291 KB_KP_7,
292 KB_KP_8, /* 0x60 */
293 KB_KP_9,
294 KB_KP_0,
295 KB_KP_DOT,
296 KB_NONUS_BSLASH, /* Non-US \ and | */
297 KB_APPLICATION,
298 KB_POWER,
299 KB_KP_EQUAL,
300 KB_F13,
301 KB_F14,
302 KB_F15,
303 KB_F16,
304 KB_F17,
305 KB_F18,
306 KB_F19,
307 KB_F20,
308 KB_F21, /* 0x70 */
309 KB_F22,
310 KB_F23,
311 KB_F24,
312 KB_EXECUTE,
313 KB_HELP,
314 KB_MENU,
315 KB_SELECT,
316 KB_STOP,
317 KB_AGAIN,
318 KB_UNDO,
319 KB_CUT,
320 KB_COPY,
321 KB_PASTE,
322 KB_FIND,
323 KB__MUTE,
324 KB__VOLUP, /* 0x80 */
325 KB__VOLDOWN,
326 KB_LOCKING_CAPS, /* locking Caps Lock */
327 KB_LOCKING_NUM, /* locking Num Lock */
328 KB_LOCKING_SCROLL, /* locking Scroll Lock */
329 KB_KP_COMMA,
330 KB_KP_EQUAL_AS400, /* equal sign on AS/400 */
331 KB_INT1,
332 KB_INT2,
333 KB_INT3,
334 KB_INT4,
335 KB_INT5,
336 KB_INT6,
337 KB_INT7,
338 KB_INT8,
339 KB_INT9,
340 KB_LANG1, /* 0x90 */
341 KB_LANG2,
342 KB_LANG3,
343 KB_LANG4,
344 KB_LANG5,
345 KB_LANG6,
346 KB_LANG7,
347 KB_LANG8,
348 KB_LANG9,
349 KB_ALT_ERASE,
350 KB_SYSREQ,
351 KB_CANCEL,
352 KB_CLEAR,
353 KB_PRIOR,
354 KB_RETURN,
355 KB_SEPARATOR,
356 KB_OUT, /* 0xA0 */
357 KB_OPER,
358 KB_CLEAR_AGAIN,
359 KB_CRSEL,
360 KB_EXSEL,
361
362 /* NOTE: 0xB0-DF are used as special_keycodes */
363 #if 0
364 KB_KP_00 = 0xB0,
365 KB_KP_000,
366 KB_THOUSANDS_SEPARATOR,
367 KB_DECIMAL_SEPARATOR,
368 KB_CURRENCY_UNIT,
369 KB_CURRENCY_SUB_UNIT,
370 KB_KP_LPAREN,
371 KB_KP_RPAREN,
372 KB_KP_LCBRACKET, /* { */
373 KB_KP_RCBRACKET, /* } */
374 KB_KP_TAB,
375 KB_KP_BSPACE,
376 KB_KP_A,
377 KB_KP_B,
378 KB_KP_C,
379 KB_KP_D,
380 KB_KP_E, /* 0xC0 */
381 KB_KP_F,
382 KB_KP_XOR,
383 KB_KP_HAT,
384 KB_KP_PERC,
385 KB_KP_LT,
386 KB_KP_GT,
387 KB_KP_AND,
388 KB_KP_LAZYAND,
389 KB_KP_OR,
390 KB_KP_LAZYOR,
391 KB_KP_COLON,
392 KB_KP_HASH,
393 KB_KP_SPACE,
394 KB_KP_ATMARK,
395 KB_KP_EXCLAMATION,
396 KB_KP_MEM_STORE, /* 0xD0 */
397 KB_KP_MEM_RECALL,
398 KB_KP_MEM_CLEAR,
399 KB_KP_MEM_ADD,
400 KB_KP_MEM_SUB,
401 KB_KP_MEM_MUL,
402 KB_KP_MEM_DIV,
403 KB_KP_PLUS_MINUS,
404 KB_KP_CLEAR,
405 KB_KP_CLEAR_ENTRY,
406 KB_KP_BINARY,
407 KB_KP_OCTAL,
408 KB_KP_DECIMAL,
409 KB_KP_HEXADECIMAL,
410 #endif
411
412 /* Modifiers */
413 KB_LCTRL = 0xE0,
414 KB_LSHIFT,
415 KB_LALT,
416 KB_LGUI,
417 KB_RCTRL,
418 KB_RSHIFT,
419 KB_RALT,
420 KB_RGUI,
421
422 /* NOTE: 0xE8-FF are used as special_keycodes */
423 };
424
425 #endif /* USB_KEYCODES_H */
Imprint / Impressum