]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - usb_keycodes.h
59c97785a4781737547cc8168c98f71c779dea23
[max/tmk_keyboard.git] / usb_keycodes.h
1 /* 
2  * Key codes from HID Keyboard/Keypad Page
3  * http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
4  *
5  * Based on Keyboard Upgrade v0.3.0 http://github.com/rhomann/kbupgrade
6  */
7 /*
8  * Keyboard Upgrade -- Firmware for homebrew computer keyboard controllers.
9  * Copyright (C) 2009  Robert Homann
10  *
11  * Based on RUMP (http://mg8.org/rump/), Copyright (C) 2008  Chris Lee
12  *
13  * Based on c64key (http://symlink.dk/projects/c64key/),
14  * Copyright (C) 2006-2007  Mikkel Holm Olsen
15  *
16  * Based on HID-Test by Christian Starkjohann, Objective Development
17  *
18  * This file is part of the Keyboard Upgrade package.
19  *
20  * This program is free software; you can redistribute it and/or modify
21  * it under the terms of the GNU General Public License as published by
22  * the Free Software Foundation; either version 2 of the License, or
23  * (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful, but
26  * WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  * GNU General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with the Keyboard Upgrade package; if not, write to the
32  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
33  * MA  02110-1301  USA
34  */
35 #ifndef USB_KEYCODES_H
36 #define USB_KEYCODES_H
37
38
39 #define IS_ERROR(code)           (KB_ROLL_OVER <= (code) && (code) <= KB_UNDEFINED)
40 #define IS_KEY(code)             (KB_A         <= (code) && (code) <= KB_KP_HEXADECIMAL)
41 #define IS_MOD(code)             (KB_LCTRL     <= (code) && (code) <= KB_RGUI)
42 #define IS_FN(code)              (KB_FN0       <= (code) && (code) <= KB_FN7)
43 #define IS_MOUSEKEY(code)        (KB_MS_UP     <= (code) && (code) <= KB_MS_WH_RIGHT)
44 #define IS_MOUSEKEY_MOVE(code)   (KB_MS_UP     <= (code) && (code) <= KB_MS_RIGHT)
45 #define IS_MOUSEKEY_BUTTON(code) (KB_MS_BTN1   <= (code) && (code) <= KB_MS_BTN5)
46 #define IS_MOUSEKEY_WHEEL(code)  (KB_MS_WH_UP  <= (code) && (code) <= KB_MS_WH_RIGHT)
47
48 #define MOD_BIT(code) (1<<((code) & 0x07))
49 #define FN_BIT(code)  (1<<((code) - KB_FN0))
50
51
52 //
53 // Short names
54 //
55 #define KB_LCTL KB_LCTRL
56 #define KB_RCTL KB_RCTRL
57 #define KB_LSFT KB_LSHIFT
58 #define KB_RSFT KB_RSHIFT
59 #define KB_ESC  KB_ESCAPE
60 #define KB_BSPC KB_BSPACE
61 #define KB_ENT  KB_ENTER
62 #define KB_DEL  KB_DELETE
63 #define KB_INS  KB_INSERT
64 #define KB_CAPS KB_CAPSLOCK
65 #define KB_RGHT KB_RIGHT
66 #define KB_PGDN KB_PGDOWN
67 #define KB_PSCR KB_PSCREEN
68 #define KB_SLCK KB_SCKLOCK
69 #define KB_BRK  KB_BREAK
70 #define KB_NLCK KB_NUMLOCK
71 #define KB_SPC  KB_SPACE
72 #define KB_MINS KB_MINUS
73 #define KB_EQL  KB_EQUAL
74 #define KB_GRV  KB_GRAVE
75 #define KB_RBRC KB_RBRACKET
76 #define KB_LBRC KB_LBRACKET
77 #define KB_COMM KB_COMMA
78 #define KB_BSLS KB_BSLASH
79 #define KB_SLSH KB_SLASH
80 #define KB_SCLN KB_SCOLON
81 #define KB_QUOT KB_QUOTE
82 #define KB_PWR  KB_POWER
83 #define KB_VOLU KB_VOLUP
84 #define KB_VOLD KB_VOLDOWN
85 // Keypad
86 #define KB_P1   KB_KP_1
87 #define KB_P2   KB_KP_2
88 #define KB_P3   KB_KP_3
89 #define KB_P4   KB_KP_4
90 #define KB_P5   KB_KP_5
91 #define KB_P6   KB_KP_6
92 #define KB_P7   KB_KP_7
93 #define KB_P8   KB_KP_8
94 #define KB_P9   KB_KP_9
95 #define KB_P0   KB_KP_0
96 #define KB_PDOT KB_KP_DOT
97 #define KB_PSLS KB_KP_SLASH
98 #define KB_PAST KB_KP_ASTERISK
99 #define KB_PMNS KB_KP_MINUS
100 #define KB_PPLS KB_KP_PLUS
101 #define KB_PEQL KB_KP_EQUAL
102 #define KB_PENT KB_KP_ENTER
103 // Mousekey
104 #define KB_MS_U KB_MS_UP
105 #define KB_MS_D KB_MS_DOWN
106 #define KB_MS_L KB_MS_LEFT
107 #define KB_MS_R KB_MS_RIGHT
108 #define KB_BTN1 KB_MS_BTN1
109 #define KB_BTN2 KB_MS_BTN2
110 #define KB_BTN3 KB_MS_BTN3
111 #define KB_BTN4 KB_MS_BTN4
112 #define KB_BTN5 KB_MS_BTN5
113 #define KB_WH_U KB_MS_WH_UP
114 #define KB_WH_D KB_MS_WH_DOWN
115 #define KB_WH_L KB_MS_WH_LEFT
116 #define KB_WH_R KB_MS_WH_RIGHT
117
118
119 enum keycodes {
120     KB_NO = 0,
121     KB_ROLL_OVER,
122     KB_POST_FAIL,
123     KB_UNDEFINED,
124     KB_A,
125     KB_B,
126     KB_C,
127     KB_D,
128     KB_E,
129     KB_F,
130     KB_G,
131     KB_H,
132     KB_I,
133     KB_J,
134     KB_K,
135     KB_L,
136     KB_M,       /* 0x10 */
137     KB_N,
138     KB_O,
139     KB_P,
140     KB_Q,
141     KB_R,
142     KB_S,
143     KB_T,
144     KB_U,
145     KB_V,
146     KB_W,
147     KB_X,
148     KB_Y,
149     KB_Z,
150     KB_1,
151     KB_2,
152     KB_3,       /* 0x20 */
153     KB_4,
154     KB_5,
155     KB_6,
156     KB_7,
157     KB_8,
158     KB_9,
159     KB_0,
160     KB_ENTER,
161     KB_ESCAPE,
162     KB_BSPACE,
163     KB_TAB,
164     KB_SPACE,
165     KB_MINUS,
166     KB_EQUAL,
167     KB_LBRACKET,          /* [ */
168     KB_RBRACKET,          /* ] */
169     KB_BSLASH,            /* \ (and |) */
170     KB_NONUS_HASH,        /* Non-US # and ~ */
171     KB_SCOLON,            /* ; (and :) */
172     KB_QUOTE,             /* ' and " */
173     KB_GRAVE,             /* Grave accent and tilde */
174     KB_COMMA,             /* , and < */
175     KB_DOT,               /* . and > */
176     KB_SLASH,             /* / and ? */
177     KB_CAPSLOCK,
178     KB_F1,
179     KB_F2,
180     KB_F3,
181     KB_F4,
182     KB_F5,
183     KB_F6,
184     KB_F7,      /* 0x40 */
185     KB_F8,
186     KB_F9,
187     KB_F10,
188     KB_F11,
189     KB_F12,
190     KB_PSCREEN,
191     KB_SCKLOCK,
192     KB_BREAK,
193     KB_INSERT,
194     KB_HOME,
195     KB_PGUP,
196     KB_DELETE,
197     KB_END,
198     KB_PGDOWN,
199     KB_RIGHT,
200     KB_LEFT,    /* 0x50 */
201     KB_DOWN,
202     KB_UP,
203     KB_NUMLOCK,
204     KB_KP_SLASH,
205     KB_KP_ASTERISK,
206     KB_KP_MINUS,
207     KB_KP_PLUS,
208     KB_KP_ENTER,
209     KB_KP_1,
210     KB_KP_2,
211     KB_KP_3,
212     KB_KP_4,
213     KB_KP_5,
214     KB_KP_6,
215     KB_KP_7,
216     KB_KP_8,       /* 0x60 */
217     KB_KP_9,
218     KB_KP_0,
219     KB_KP_DOT,
220     KB_NONUS_BSLASH,      /* Non-US \ and | */
221     KB_APPLICATION,
222     KB_POWER,
223     KB_KP_EQUAL,
224     KB_F13,
225     KB_F14,
226     KB_F15,
227     KB_F16,
228     KB_F17,
229     KB_F18,
230     KB_F19,
231     KB_F20,
232     KB_F21,     /* 0x70 */
233     KB_F22,
234     KB_F23,
235     KB_F24,
236     KB_EXECUTE,
237     KB_HELP,
238     KB_MENU,
239     KB_SELECT,
240     KB_STOP,
241     KB_AGAIN,
242     KB_UNDO,
243     KB_CUT,
244     KB_COPY,
245     KB_PASTE,
246     KB_FIND,
247     KB_MUTE,
248     KB_VOLUP,   /* 0x80 */
249     KB_VOLDOWN,
250     KB_LOCKING_CAPS,      /* locking Caps Lock */
251     KB_LOCKING_NUM,       /* locking Num Lock */
252     KB_LOCKING_SCROLL,    /* locking Scroll Lock */
253     KB_KP_COMMA,
254     KB_KP_EQUAL_AS400,       /* equal sign on AS/400 */
255     KB_INT1,
256     KB_INT2,
257     KB_INT3,
258     KB_INT4,
259     KB_INT5,
260     KB_INT6,
261     KB_INT7,
262     KB_INT8,
263     KB_INT9,
264     KB_LANG1,    /* 0x90 */
265     KB_LANG2,
266     KB_LANG3,
267     KB_LANG4,
268     KB_LANG5,
269     KB_LANG6,
270     KB_LANG7,
271     KB_LANG8,
272     KB_LANG9,
273     KB_ALT_ERASE,
274     KB_SYSREQ,
275     KB_CANCEL,
276     KB_CLEAR,
277     KB_PRIOR,
278     KB_RETURN,
279     KB_SEPARATOR,
280     KB_OUT,
281     KB_OPER,
282     KB_CLEAR_AGAIN,
283     KB_CRSEL,
284     KB_EXSEL,
285
286     KB_KP_00 = 0xB0,
287     KB_KP_000,
288     KB_THOUSANDS_SEPARATOR,
289     KB_DECIMAL_SEPARATOR,
290     KB_CURRENCY_UNIT,
291     KB_CURRENCY_SUB_UNIT,
292     KB_KP_LPAREN,
293     KB_KP_RPAREN,
294     KB_KP_LCBRACKET,         /* { */
295     KB_KP_RCBRACKET,         /* } */
296     KB_KP_TAB,
297     KB_KP_BSPACE,
298     KB_KP_A,
299     KB_KP_B,
300     KB_KP_C,
301     KB_KP_D,
302     KB_KP_E,
303     KB_KP_F,
304     KB_KP_XOR,
305     KB_KP_HAT,
306     KB_KP_PERC,
307     KB_KP_LT,
308     KB_KP_GT,
309     KB_KP_AND,
310     KB_KP_LAZYAND,
311     KB_KP_OR,
312     KB_KP_LAZYOR,
313     KB_KP_COLON,
314     KB_KP_HASH,
315     KB_KP_SPACE,
316     KB_KP_ATMARK,
317     KB_KP_EXCLAMATION,
318     KB_KP_MEM_STORE,
319     KB_KP_MEM_RECALL,
320     KB_KP_MEM_CLEAR,
321     KB_KP_MEM_ADD,
322     KB_KP_MEM_SUB,
323     KB_KP_MEM_MUL,
324     KB_KP_MEM_DIV,
325     KB_KP_PLUS_MINUS,
326     KB_KP_CLEAR,
327     KB_KP_CLEAR_ENTRY,
328     KB_KP_BINARY,
329     KB_KP_OCTAL,
330     KB_KP_DECIMAL,
331     KB_KP_HEXADECIMAL,
332
333     /* modifiers */
334     KB_LCTRL = 0xE0,    /* 0x01 */
335     KB_LSHIFT,          /* 0x02 */
336     KB_LALT,            /* 0x04 */
337     KB_LGUI,            /* 0x08 */
338     KB_RCTRL,           /* 0x10 */
339     KB_RSHIFT,          /* 0x20 */
340     KB_RALT,            /* 0x40 */
341     KB_RGUI,            /* 0x80 */
342
343     /* extensions for internal use */
344     KB_FN0 = 0xE8,
345     KB_FN1,
346     KB_FN2,
347     KB_FN3,
348     KB_FN4,
349     KB_FN5,
350     KB_FN6,
351     KB_FN7,
352     // Mousekey move
353     KB_MS_UP = 0xF0,
354     KB_MS_DOWN,
355     KB_MS_LEFT,
356     KB_MS_RIGHT,
357     // Mousekey buttons
358     KB_MS_BTN1 = 0xF4,
359     KB_MS_BTN2,
360     KB_MS_BTN3,
361     KB_MS_BTN4,
362     KB_MS_BTN5,
363     // Mousekey wheel
364     KB_MS_WH_UP,
365     KB_MS_WH_DOWN,
366     KB_MS_WH_LEFT,
367     KB_MS_WH_RIGHT,
368 };
369
370 #endif /* USB_KEYCODES_H */