summaryrefslogtreecommitdiffstats
path: root/usb_keycodes.h
blob: 59c97785a4781737547cc8168c98f71c779dea23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
/* 
 * Key codes from HID Keyboard/Keypad Page
 * http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
 *
 * Based on Keyboard Upgrade v0.3.0 http://github.com/rhomann/kbupgrade
 */
/*
 * Keyboard Upgrade -- Firmware for homebrew computer keyboard controllers.
 * Copyright (C) 2009  Robert Homann
 *
 * Based on RUMP (http://mg8.org/rump/), Copyright (C) 2008  Chris Lee
 *
 * Based on c64key (http://symlink.dk/projects/c64key/),
 * Copyright (C) 2006-2007  Mikkel Holm Olsen
 *
 * Based on HID-Test by Christian Starkjohann, Objective Development
 *
 * This file is part of the Keyboard Upgrade package.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the Keyboard Upgrade package; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA  02110-1301  USA
 */
#ifndef USB_KEYCODES_H
#define USB_KEYCODES_H


#define IS_ERROR(code)           (KB_ROLL_OVER <= (code) && (code) <= KB_UNDEFINED)
#define IS_KEY(code)             (KB_A         <= (code) && (code) <= KB_KP_HEXADECIMAL)
#define IS_MOD(code)             (KB_LCTRL     <= (code) && (code) <= KB_RGUI)
#define IS_FN(code)              (KB_FN0       <= (code) && (code) <= KB_FN7)
#define IS_MOUSEKEY(code)        (KB_MS_UP     <= (code) && (code) <= KB_MS_WH_RIGHT)
#define IS_MOUSEKEY_MOVE(code)   (KB_MS_UP     <= (code) && (code) <= KB_MS_RIGHT)
#define IS_MOUSEKEY_BUTTON(code) (KB_MS_BTN1   <= (code) && (code) <= KB_MS_BTN5)
#define IS_MOUSEKEY_WHEEL(code)  (KB_MS_WH_UP  <= (code) && (code) <= KB_MS_WH_RIGHT)

#define MOD_BIT(code) (1<<((code) & 0x07))
#define FN_BIT(code)  (1<<((code) - KB_FN0))


//
// Short names
//
#define KB_LCTL KB_LCTRL
#define KB_RCTL KB_RCTRL
#define KB_LSFT KB_LSHIFT
#define KB_RSFT KB_RSHIFT
#define KB_ESC  KB_ESCAPE
#define KB_BSPC KB_BSPACE
#define KB_ENT  KB_ENTER
#define KB_DEL  KB_DELETE
#define KB_INS  KB_INSERT
#define KB_CAPS KB_CAPSLOCK
#define KB_RGHT KB_RIGHT
#define KB_PGDN KB_PGDOWN
#define KB_PSCR KB_PSCREEN
#define KB_SLCK KB_SCKLOCK
#define KB_BRK  KB_BREAK
#define KB_NLCK KB_NUMLOCK
#define KB_SPC  KB_SPACE
#define KB_MINS KB_MINUS
#define KB_EQL  KB_EQUAL
#define KB_GRV  KB_GRAVE
#define KB_RBRC KB_RBRACKET
#define KB_LBRC KB_LBRACKET
#define KB_COMM KB_COMMA
#define KB_BSLS KB_BSLASH
#define KB_SLSH KB_SLASH
#define KB_SCLN KB_SCOLON
#define KB_QUOT KB_QUOTE
#define KB_PWR  KB_POWER
#define KB_VOLU KB_VOLUP
#define KB_VOLD KB_VOLDOWN
// Keypad
#define KB_P1   KB_KP_1
#define KB_P2   KB_KP_2
#define KB_P3   KB_KP_3
#define KB_P4   KB_KP_4
#define KB_P5   KB_KP_5
#define KB_P6   KB_KP_6
#define KB_P7   KB_KP_7
#define KB_P8   KB_KP_8
#define KB_P9   KB_KP_9
#define KB_P0   KB_KP_0
#define KB_PDOT KB_KP_DOT
#define KB_PSLS KB_KP_SLASH
#define KB_PAST KB_KP_ASTERISK
#define KB_PMNS KB_KP_MINUS
#define KB_PPLS KB_KP_PLUS
#define KB_PEQL KB_KP_EQUAL
#define KB_PENT KB_KP_ENTER
// Mousekey
#define KB_MS_U KB_MS_UP
#define KB_MS_D KB_MS_DOWN
#define KB_MS_L KB_MS_LEFT
#define KB_MS_R KB_MS_RIGHT
#define KB_BTN1 KB_MS_BTN1
#define KB_BTN2 KB_MS_BTN2
#define KB_BTN3 KB_MS_BTN3
#define KB_BTN4 KB_MS_BTN4
#define KB_BTN5 KB_MS_BTN5
#define KB_WH_U KB_MS_WH_UP
#define KB_WH_D KB_MS_WH_DOWN
#define KB_WH_L KB_MS_WH_LEFT
#define KB_WH_R KB_MS_WH_RIGHT


enum keycodes {
    KB_NO = 0,
    KB_ROLL_OVER,
    KB_POST_FAIL,
    KB_UNDEFINED,
    KB_A,
    KB_B,
    KB_C,
    KB_D,
    KB_E,
    KB_F,
    KB_G,
    KB_H,
    KB_I,
    KB_J,
    KB_K,
    KB_L,
    KB_M,       /* 0x10 */
    KB_N,
    KB_O,
    KB_P,
    KB_Q,
    KB_R,
    KB_S,
    KB_T,
    KB_U,
    KB_V,
    KB_W,
    KB_X,
    KB_Y,
    KB_Z,
    KB_1,
    KB_2,
    KB_3,       /* 0x20 */
    KB_4,
    KB_5,
    KB_6,
    KB_7,
    KB_8,
    KB_9,
    KB_0,
    KB_ENTER,
    KB_ESCAPE,
    KB_BSPACE,
    KB_TAB,
    KB_SPACE,
    KB_MINUS,
    KB_EQUAL,
    KB_LBRACKET,          /* [ */
    KB_RBRACKET,          /* ] */
    KB_BSLASH,            /* \ (and |) */
    KB_NONUS_HASH,        /* Non-US # and ~ */
    KB_SCOLON,            /* ; (and :) */
    KB_QUOTE,             /* ' and " */
    KB_GRAVE,             /* Grave accent and tilde */
    KB_COMMA,             /* , and < */
    KB_DOT,               /* . and > */
    KB_SLASH,             /* / and ? */
    KB_CAPSLOCK,
    KB_F1,
    KB_F2,
    KB_F3,
    KB_F4,
    KB_F5,
    KB_F6,
    KB_F7,      /* 0x40 */
    KB_F8,
    KB_F9,
    KB_F10,
    KB_F11,
    KB_F12,
    KB_PSCREEN,
    KB_SCKLOCK,
    KB_BREAK,
    KB_INSERT,
    KB_HOME,
    KB_PGUP,
    KB_DELETE,
    KB_END,
    KB_PGDOWN,
    KB_RIGHT,
    KB_LEFT,    /* 0x50 */
    KB_DOWN,
    KB_UP,
    KB_NUMLOCK,
    KB_KP_SLASH,
    KB_KP_ASTERISK,
    KB_KP_MINUS,
    KB_KP_PLUS,
    KB_KP_ENTER,
    KB_KP_1,
    KB_KP_2,
    KB_KP_3,
    KB_KP_4,
    KB_KP_5,
    KB_KP_6,
    KB_KP_7,
    KB_KP_8,       /* 0x60 */
    KB_KP_9,
    KB_KP_0,
    KB_KP_DOT,
    KB_NONUS_BSLASH,      /* Non-US \ and | */
    KB_APPLICATION,
    KB_POWER,
    KB_KP_EQUAL,
    KB_F13,
    KB_F14,
    KB_F15,
    KB_F16,
    KB_F17,
    KB_F18,
    KB_F19,
    KB_F20,
    KB_F21,     /* 0x70 */
    KB_F22,
    KB_F23,
    KB_F24,
    KB_EXECUTE,
    KB_HELP,
    KB_MENU,
    KB_SELECT,
    KB_STOP,
    KB_AGAIN,
    KB_UNDO,
    KB_CUT,
    KB_COPY,
    KB_PASTE,
    KB_FIND,
    KB_MUTE,
    KB_VOLUP,   /* 0x80 */
    KB_VOLDOWN,
    KB_LOCKING_CAPS,      /* locking Caps Lock */
    KB_LOCKING_NUM,       /* locking Num Lock */
    KB_LOCKING_SCROLL,    /* locking Scroll Lock */
    KB_KP_COMMA,
    KB_KP_EQUAL_AS400,       /* equal sign on AS/400 */
    KB_INT1,
    KB_INT2,
    KB_INT3,
    KB_INT4,
    KB_INT5,
    KB_INT6,
    KB_INT7,
    KB_INT8,
    KB_INT9,
    KB_LANG1,    /* 0x90 */
    KB_LANG2,
    KB_LANG3,
    KB_LANG4,
    KB_LANG5,
    KB_LANG6,
    KB_LANG7,
    KB_LANG8,
    KB_LANG9,
    KB_ALT_ERASE,
    KB_SYSREQ,
    KB_CANCEL,
    KB_CLEAR,
    KB_PRIOR,
    KB_RETURN,
    KB_SEPARATOR,
    KB_OUT,
    KB_OPER,
    KB_CLEAR_AGAIN,
    KB_CRSEL,
    KB_EXSEL,

    KB_KP_00 = 0xB0,
    KB_KP_000,
    KB_THOUSANDS_SEPARATOR,
    KB_DECIMAL_SEPARATOR,
    KB_CURRENCY_UNIT,
    KB_CURRENCY_SUB_UNIT,
    KB_KP_LPAREN,
    KB_KP_RPAREN,
    KB_KP_LCBRACKET,         /* { */
    KB_KP_RCBRACKET,         /* } */
    KB_KP_TAB,
    KB_KP_BSPACE,
    KB_KP_A,
    KB_KP_B,
    KB_KP_C,
    KB_KP_D,
    KB_KP_E,
    KB_KP_F,
    KB_KP_XOR,
    KB_KP_HAT,
    KB_KP_PERC,
    KB_KP_LT,
    KB_KP_GT,
    KB_KP_AND,
    KB_KP_LAZYAND,
    KB_KP_OR,
    KB_KP_LAZYOR,
    KB_KP_COLON,
    KB_KP_HASH,
    KB_KP_SPACE,
    KB_KP_ATMARK,
    KB_KP_EXCLAMATION,
    KB_KP_MEM_STORE,
    KB_KP_MEM_RECALL,
    KB_KP_MEM_CLEAR,
    KB_KP_MEM_ADD,
    KB_KP_MEM_SUB,
    KB_KP_MEM_MUL,
    KB_KP_MEM_DIV,
    KB_KP_PLUS_MINUS,
    KB_KP_CLEAR,
    KB_KP_CLEAR_ENTRY,
    KB_KP_BINARY,
    KB_KP_OCTAL,
    KB_KP_DECIMAL,
    KB_KP_HEXADECIMAL,

    /* modifiers */
    KB_LCTRL = 0xE0,    /* 0x01 */
    KB_LSHIFT,          /* 0x02 */
    KB_LALT,            /* 0x04 */
    KB_LGUI,            /* 0x08 */
    KB_RCTRL,           /* 0x10 */
    KB_RSHIFT,          /* 0x20 */
    KB_RALT,            /* 0x40 */
    KB_RGUI,            /* 0x80 */

    /* extensions for internal use */
    KB_FN0 = 0xE8,
    KB_FN1,
    KB_FN2,
    KB_FN3,
    KB_FN4,
    KB_FN5,
    KB_FN6,
    KB_FN7,
    // Mousekey move
    KB_MS_UP = 0xF0,
    KB_MS_DOWN,
    KB_MS_LEFT,
    KB_MS_RIGHT,
    // Mousekey buttons
    KB_MS_BTN1 = 0xF4,
    KB_MS_BTN2,
    KB_MS_BTN3,
    KB_MS_BTN4,
    KB_MS_BTN5,
    // Mousekey wheel
    KB_MS_WH_UP,
    KB_MS_WH_DOWN,
    KB_MS_WH_LEFT,
    KB_MS_WH_RIGHT,
};

#endif /* USB_KEYCODES_H */