]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - usb_keycodes.h
ADD: keymap macro for human to read easier
[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
36 #ifndef USB_KEYCODES_H
37 #define USB_KEYCODES_H
38
39 #define IS_ERROR(code) (KB_ROLL_OVER <= (code) && (code) <= KB_UNDEFINED)
40 #define IS_KEY(code) (KB_A <= (code) && (code) <= KP_HEXADECIMAL)
41 #define IS_MOD(code) (KB_LCTRL <= (code) && (code) <= KB_RGUI)
42 #define IS_FN(code) (FN_0 <= (code) && (code) <= FN_7)
43 #define IS_MOUSE(code) (MS_UP <= (code) && (code) <= MS_WH_RIGHT)
44 #define IS_MOUSE_MOVE(code) (MS_UP <= (code) && (code) <= MS_RIGHT)
45 #define IS_MOUSE_BUTTON(code) (MS_BTN1 <= (code) && (code) <= MS_BTN5)
46 #define IS_MOUSE_WHEEL(code) (MS_WH_UP <= (code) && (code) <= MS_WH_RIGHT)
47
48 #define MOD_BIT(code) (1<<((code) & 0x07))
49 #define FN_BIT(code) (1<<((code) - FN_0))
50
51
52 // short names
53 #define KB_LCTL KB_LCTRL
54 #define KB_RCTL KB_RCTRL
55 #define KB_LSFT KB_LSHIFT
56 #define KB_RSFT KB_RSHIFT
57 #define KB_ESC  KB_ESCAPE
58 #define KB_BSPC KB_BSPACE
59 #define KB_ENT  KB_ENTER
60 #define KB_DEL  KB_DELETE
61 #define KB_INS  KB_INSERT
62 #define KB_CAPS KB_CAPSLOCK
63 #define KB_RGHT KB_RIGHT
64 #define KB_PGDN KB_PGDOWN
65 #define KB_PSCR KB_PSCREEN
66 #define KB_SLCK KB_SCKLOCK
67 #define KB_BRK  KB_BREAK
68 #define KB_SPC  KB_SPACE
69 #define KB_MINS KB_MINUS
70 #define KB_EQL  KB_EQUAL
71 #define KB_GRV  KB_GRAVE
72 #define KB_RBRC KB_RBRACKET
73 #define KB_LBRC KB_LBRACKET
74 #define KB_COMM KB_COMMA
75 #define KB_BSLS KB_BSLASH
76 #define KB_SLSH KB_SLASH
77 #define KB_SCLN KB_SCOLON
78 #define KB_PWR  KB_POWER
79 #define KP_SLSH KP_SLASH
80 #define KP_ASTR KP_ASTERISK
81 #define KP_MINS KP_MINUS
82 #define MS_RGHT MS_RIGHT
83 #define MS_WH_U MS_WH_UP
84 #define MS_WH_D MS_WH_DOWN
85 #define MS_WH_L MS_WH_LEFT
86 #define MS_WH_R MS_WH_RIGHT
87
88
89 enum keycodes {
90     KB_NO = 0,
91     KB_ROLL_OVER,
92     KB_POST_FAIL,
93     KB_UNDEFINED,
94     KB_A,
95     KB_B,
96     KB_C,
97     KB_D,
98     KB_E,
99     KB_F,
100     KB_G,
101     KB_H,
102     KB_I,
103     KB_J,
104     KB_K,
105     KB_L,
106     KB_M,       /* 0x10 */
107     KB_N,
108     KB_O,
109     KB_P,
110     KB_Q,
111     KB_R,
112     KB_S,
113     KB_T,
114     KB_U,
115     KB_V,
116     KB_W,
117     KB_X,
118     KB_Y,
119     KB_Z,
120     KB_1,
121     KB_2,
122     KB_3,       /* 0x20 */
123     KB_4,
124     KB_5,
125     KB_6,
126     KB_7,
127     KB_8,
128     KB_9,
129     KB_0,
130     KB_ENTER,
131     KB_ESCAPE,
132     KB_BSPACE,
133     KB_TAB,
134     KB_SPACE,
135     KB_MINUS,
136     KB_EQUAL,
137     KB_LBRACKET,          /* [ */
138     KB_RBRACKET,          /* ] */
139     KB_BSLASH,            /* \ (and |) */
140     KB_NONUS_HASH,        /* Non-US # and ~ */
141     KB_SCOLON,            /* ; (and :) */
142     KB_QUOTE,             /* ' and " */
143     KB_GRAVE,             /* Grave accent and tilde */
144     KB_COMMA,             /* , and < */
145     KB_DOT,               /* . and > */
146     KB_SLASH,             /* / and ? */
147     KB_CAPSLOCK,
148     KB_F1,
149     KB_F2,
150     KB_F3,
151     KB_F4,
152     KB_F5,
153     KB_F6,
154     KB_F7,      /* 0x40 */
155     KB_F8,
156     KB_F9,
157     KB_F10,
158     KB_F11,
159     KB_F12,
160     KB_PSCREEN,
161     KB_SCKLOCK,
162     KB_BREAK,
163     KB_INSERT,
164     KB_HOME,
165     KB_PGUP,
166     KB_DELETE,
167     KB_END,
168     KB_PGDOWN,
169     KB_RIGHT,
170     KB_LEFT,    /* 0x50 */
171     KB_DOWN,
172     KB_UP,
173     KB_NUMLOCK,
174     KP_SLASH,
175     KP_ASTERISK,
176     KP_MINUS,
177     KP_PLUS,
178     KP_ENTER,
179     KP_1,
180     KP_2,
181     KP_3,
182     KP_4,
183     KP_5,
184     KP_6,
185     KP_7,
186     KP_8,       /* 0x60 */
187     KP_9,
188     KP_0,
189     KP_DOT,
190     KB_NONUS_BSLASH,      /* Non-US \ and | */
191     KB_APPLICATION,
192     KB_POWER,
193     KP_EQUAL,
194     KB_F13,
195     KB_F14,
196     KB_F15,
197     KB_F16,
198     KB_F17,
199     KB_F18,
200     KB_F19,
201     KB_F20,
202     KB_F21,     /* 0x70 */
203     KB_F22,
204     KB_F23,
205     KB_F24,
206     KB_EXECUTE,
207     KB_HELP,
208     KB_MENU,
209     KB_SELECT,
210     KB_STOP,
211     KB_AGAIN,
212     KB_UNDO,
213     KB_CUT,
214     KB_COPY,
215     KB_PASTE,
216     KB_FIND,
217     KB_MUTE,
218     KB_VOLUP,   /* 0x80 */
219     KB_VOLDOWN,
220     KB_LOCKING_CAPS,      /* locking Caps Lock */
221     KB_LOCKING_NUM,       /* locking Num Lock */
222     KB_LOCKING_SCROLL,    /* locking Scroll Lock */
223     KP_COMMA,
224     KP_EQUAL_AS400,       /* equal sign on AS/400 */
225     KB_INT1,
226     KB_INT2,
227     KB_INT3,
228     KB_INT4,
229     KB_INT5,
230     KB_INT6,
231     KB_INT7,
232     KB_INT8,
233     KB_INT9,
234     KB_LANG1,    /* 0x90 */
235     KB_LANG2,
236     KB_LANG3,
237     KB_LANG4,
238     KB_LANG5,
239     KB_LANG6,
240     KB_LANG7,
241     KB_LANG8,
242     KB_LANG9,
243     KB_ALT_ERASE,
244     KB_SYSREQ,
245     KB_CANCEL,
246     KB_CLEAR,
247     KB_PRIOR,
248     KB_RETURN,
249     KB_SEPARATOR,
250     KB_OUT,
251     KB_OPER,
252     KB_CLEAR_AGAIN,
253     KB_CRSEL,
254     KB_EXSEL,
255
256     KP_00 = 0xB0,
257     KP_000,
258     KB_THOUSANDS_SEPARATOR,
259     KB_DECIMAL_SEPARATOR,
260     CURRENCY_UNIT,
261     CURRENCY_SUB_UNIT,
262     KP_LPAREN,
263     KP_RPAREN,
264     KP_LCBRACKET,         /* { */
265     KP_RCBRACKET,         /* } */
266     KP_TAB,
267     KP_BSPACE,
268     KP_A,
269     KP_B,
270     KP_C,
271     KP_D,
272     KP_E,
273     KP_F,
274     KP_XOR,
275     KP_HAT,
276     KP_PERC,
277     KP_LT,
278     KP_GT,
279     KP_AND,
280     KP_LAZYAND,
281     KP_OR,
282     KP_LAZYOR,
283     KP_COLON,
284     KP_HASH,
285     KP_SPACE,
286     KP_ATMARK,
287     KP_EXCLAMATION,
288     KP_MEM_STORE,
289     KP_MEM_RECALL,
290     KP_MEM_CLEAR,
291     KP_MEM_ADD,
292     KP_MEM_SUB,
293     KP_MEM_MUL,
294     KP_MEM_DIV,
295     KP_PLUS_MINUS,
296     KP_CLEAR,
297     KP_CLEAR_ENTRY,
298     KP_BINARY,
299     KP_OCTAL,
300     KP_DECIMAL,
301     KP_HEXADECIMAL,
302
303     /* modifiers */
304     KB_LCTRL = 0xE0,    /* 0x01 */
305     KB_LSHIFT,          /* 0x02 */
306     KB_LALT,            /* 0x04 */
307     KB_LGUI,            /* 0x08 */
308     KB_RCTRL,           /* 0x10 */
309     KB_RSHIFT,          /* 0x20 */
310     KB_RALT,            /* 0x40 */
311     KB_RGUI,            /* 0x80 */
312
313     /* extensions for internal use */
314     FN_0 = 0xE8,
315     FN_1,
316     FN_2,
317     FN_3,
318     FN_4,
319     FN_5,
320     FN_6,
321     FN_7,
322     MS_UP = 0xF0,
323     MS_DOWN,
324     MS_LEFT,
325     MS_RIGHT,
326     MS_BTN1 = 0xF4,
327     MS_BTN2,
328     MS_BTN3,
329     MS_BTN4,
330     MS_BTN5,
331     MS_WH_UP,
332     MS_WH_DOWN,
333     MS_WH_LEFT,
334     MS_WH_RIGHT,
335 };
336
337 #endif /* USB_KEYCODES_H */