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