1 /* Copyright (C) 2011-2014 by Jacob Alexander
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 // ----- Defines -----
27 // The USB codes are all taken from the USB HID Spec
28 // http://www.usb.org/developers/devclass_docs/Hut1_11.pdf
30 // List of Keycodes - USB HID 1.11 pg 53
31 #define KEY_NOEVENT 0x00 // Event, not a physical key
32 #define KEY_ERRORROLLOVER 0x01 // Event, not a physical key
33 #define KEY_POSTFAIL 0x02 // Event, not a physical key
34 #define KEY_ERRORUNDEFINED 0x03 // Event, not a physical key
71 #define KEY_ENTER 0x28
73 #define KEY_BACKSPACE 0x2A
75 #define KEY_SPACE 0x2C
76 #define KEY_MINUS 0x2D
77 #define KEY_EQUAL 0x2E
78 #define KEY_LEFT_BRACE 0x2F
79 #define KEY_RIGHT_BRACE 0x30
80 #define KEY_BACKSLASH 0x31
81 #define KEY_NUMBER 0x32
82 #define KEY_SEMICOLON 0x33
83 #define KEY_QUOTE 0x34
84 #define KEY_TILDE 0x35
85 #define KEY_COMMA 0x36
86 #define KEY_PERIOD 0x37
87 #define KEY_SLASH 0x38
88 #define KEY_CAPS_LOCK 0x39
101 #define KEY_PRINTSCREEN 0x46
102 #define KEY_SCROLL_LOCK 0x47
103 #define KEY_PAUSE 0x48
104 #define KEY_INSERT 0x49
105 #define KEY_HOME 0x4A
106 #define KEY_PAGE_UP 0x4B
107 #define KEY_DELETE 0x4C
109 #define KEY_PAGE_DOWN 0x4E
110 #define KEY_RIGHT 0x4F
111 #define KEY_LEFT 0x50
112 #define KEY_DOWN 0x51
114 #define KEY_NUM_LOCK 0x53
115 #define KEYPAD_SLASH 0x54
116 #define KEYPAD_ASTERIX 0x55
117 #define KEYPAD_MINUS 0x56
118 #define KEYPAD_PLUS 0x57
119 #define KEYPAD_ENTER 0x58
120 #define KEYPAD_1 0x59
121 #define KEYPAD_2 0x5A
122 #define KEYPAD_3 0x5B
123 #define KEYPAD_4 0x5C
124 #define KEYPAD_5 0x5D
125 #define KEYPAD_6 0x5E
126 #define KEYPAD_7 0x5F
127 #define KEYPAD_8 0x60
128 #define KEYPAD_9 0x61
129 #define KEYPAD_0 0x62
130 #define KEYPAD_PERIOD 0x63
131 #define KEY_ISO_BACKSLASH 0x64
133 #define KEYBOARD_STATUS 0x66 // Used for indicating status or errors, not a key
134 #define KEYPAD_EQUAL 0x67
147 #define KEY_EXEC 0x74
148 #define KEY_HELP 0x75
149 #define KEY_MENU 0x76
150 #define KEY_SELECT 0x77
151 #define KEY_STOP 0x78
152 #define KEY_AGAIN 0x79
153 #define KEY_UNDO 0x7A
155 #define KEY_COPY 0x7C
156 #define KEY_PASTE 0x7D
157 #define KEY_FIND 0x7E
158 #define KEY_MUTE 0x7F
159 #define KEY_VOL_UP 0x80
160 #define KEY_VOL_DOWN 0x81
161 #define KEY_CAPS_LLOCK 0x82 // "Locking" Scroll Lock (Old keyboards with Locking Caps Lock)
162 #define KEY_NUM_LLOCK 0x83
163 #define KEY_SCROLL_LLOCK 0x84
164 #define KEYPAD_COMMA 0x85 // Brazillian (See spec)
165 #define KEYPAD_EQUAL_AS 0x86 // AS/400 Keyboard (See spec)
166 #define KEY_INTER1 0x87 // KANJI1 - Brazillian and Japanese "Ru" and "-"
167 #define KEY_INTER2 0x88 // KANJI2 - Japanese Katakana/Hiragana
168 #define KEY_INTER3 0x89 // KANJI3 - Japanese Yen
169 #define KEY_INTER4 0x8A // KANJI4 - Japanese Henkan
170 #define KEY_INTER5 0x8B // KANJI5 - Japanese Muhenkan
171 #define KEY_INTER6 0x8C // KANJI6 - PC0x62 Comma (Ka-m-ma)
172 #define KEY_INTER7 0x8D // KANJI7 - Double-Byte/Single-Byte Toggle
173 #define KEY_INTER8 0x8E // KANJI8 - Undefined
174 #define KEY_INTER9 0x8F // KANJI9 - Undefined
175 #define KEY_LANG1 0x90 // Korean Hangul/English Toggle
176 #define KEY_LANG2 0x91 // Korean Hanja Conversion - Japanese Eisu
177 #define KEY_LANG3 0x92 // Japanese Katakana Key (USB)
178 #define KEY_LANG4 0x93 // Japanese Hiragana Key (USB)
179 #define KEY_LANG5 0x94 // Japanese Zenkaku/Hankaku Key (USB)
180 #define KEY_LANG6 0x95 // Reserved (Application Specific)
181 #define KEY_LANG7 0x96 // Reserved (Application Specific)
182 #define KEY_LANG8 0x97 // Reserved (Application Specific)
183 #define KEY_LANG9 0x98 // Reserved (Application Specific)
184 #define KEY_ALT_ERASE 0x99 // Special Erase (See Spec)
185 #define KEY_SYSREQ_ATT 0x9A // Modifier Type
186 #define KEY_CANCEL 0x9B
187 #define KEY_CLEAR 0x9C
188 #define KEY_PRIOR 0x9D
189 #define KEY_RETURN 0x9E
190 #define KEY_SEPARATOR 0x9F
193 #define KEY_OPER 0xA1
194 #define KEY_CLEAR_AGAIN 0xA2
195 #define KEY_CRSEL_PROPS 0xA3
196 #define KEY_EXSEL 0xA4
197 // 0xA5 - 0xAF Reserved
198 #define KEYPAD_00 0xB0
199 #define KEYPAD_000 0xB1
200 #define KEY_1000_SEP 0xB2
201 #define KEY_DECIMAL_SEP 0xB3
202 #define KEY_CURRENCY_MAIN 0xB4
203 #define KEY_CURRENCY_SUB 0xB5
204 #define KEYPAD_LPAREN 0xB6
205 #define KEYPAD_RPAREN 0xB7
206 #define KEYPAD_LBRACE 0xB8
207 #define KEYPAD_RBRACE 0xB9
208 #define KEYPAD_TAB 0xBA
209 #define KEYPAD_BACKSPACE 0xBB
210 #define KEYPAD_A 0xBC
211 #define KEYPAD_B 0xBD
212 #define KEYPAD_C 0xBE
213 #define KEYPAD_D 0xBF
214 #define KEYPAD_E 0xC0
215 #define KEYPAD_F 0xC1
216 #define KEYPAD_XOR 0xC2
217 #define KEYPAD_CHEVRON 0xC3
218 #define KEYPAD_PERCENT 0xC4
219 #define KEYPAD_LTHAN 0xC5
220 #define KEYPAD_GTHAN 0xC6
221 #define KEYPAD_BITAND 0xC7
222 #define KEYPAD_AND 0xC8
223 #define KEYPAD_BITOR 0xC9
224 #define KEYPAD_OR 0xCA
225 #define KEYPAD_COLON 0xCB
226 #define KEYPAD_POUND 0xCC
227 #define KEYPAD_SPACE 0xCD
228 #define KEYPAD_AT 0xCE
229 #define KEYPAD_EXCLAIM 0xCF
230 #define KEYPAD_MEM_STORE 0xD0
231 #define KEYPAD_MEM_RECALL 0xD1
232 #define KEYPAD_MEM_CLEAR 0xD2
233 #define KEYPAD_MEM_ADD 0xD3
234 #define KEYPAD_MEM_SUB 0xD4
235 #define KEYPAD_MEM_MULT 0xD5
236 #define KEYPAD_MEM_DIV 0xD6
237 #define KEYPAD_PLUS_MINUS 0xD7
238 #define KEYPAD_CLEAR 0xD8
239 #define KEYPAD_CLEAR_ENTRY 0xD9
240 #define KEYPAD_BINARY 0xDA
241 #define KEYPAD_OCTAL 0xDB
242 #define KEYPAD_DECIMAL 0xDC
243 #define KEYPAD_HEX 0xDD
244 // 0xDE - 0xDF Reserved
245 #define KEY_CTRL 0xE0 // Convenience
246 #define KEY_LCTRL 0xE0
247 #define KEY_SHIFT 0xE1 // Convenience
248 #define KEY_LSHIFT 0xE1
249 #define KEY_ALT 0xE2 // Convenience
250 #define KEY_LALT 0xE2
251 #define KEY_GUI 0xE3 // Convenience
252 #define KEY_LGUI 0xE3
253 #define KEY_RCTRL 0xE4
254 #define KEY_RSHIFT 0xE5
255 #define KEY_RALT 0xE6
256 #define KEY_RGUI 0xE7
257 // 0xE8 - 0xFFFF Reserved
258 // Except for 0xE0-0xE7 which are DV (Dynamic Flags), all Keycodes are Sel (Selectors).
261 // List of LED codes - USB HID 1.11 pg 61
262 // LED/Indicators are defined as:
263 // OOC - On/Off Control
264 // US - Usage Indicator: 1 - In Use, 0 - Not In Use
265 // UM - Usage Multi Mode Indicator Collection of 1 or more indicators: On, Flash, Slow Blink, Fast Blink, Off
268 #define LED_UNDEFINED 0x00
269 #define LED_NUM_LOCK 0x01 // OOC
270 #define LED_CAPS_LOCK 0x02 // OOC
271 #define LED_SCROLL_LOCK 0x03 // OOC
272 #define LED_COMPOSE 0x04 // OOC
273 #define LED_KANA 0x05 // OOC
274 #define LED_POWER 0x06 // OOC
275 #define LED_SHIFT 0x07 // OOC
276 #define LED_DO_NOT_DISTURB 0x08 // OOC
277 #define LED_MUTE 0x09 // OOC
278 #define LED_TONE_ENABLE 0x0A // OOC
279 #define LED_HIGHCUT_FILTER 0x0B // OOC
280 #define LED_LOWCUT_FILTER 0x0C // OOC
281 #define LED_EQL_ENABLE 0x0D // OOC
282 #define LED_SND_FLD_ON 0x0E // OOC
283 #define LED_SURROUND_ON 0x0F // OOC
284 #define LED_REPEAT 0x10 // OOC
285 #define LED_STEREO 0x11 // OOC
286 #define LED_SAMPLE_RT_DET 0x12 // OOC
287 #define LED_SPINNING 0x13 // OOC
288 #define LED_CAV 0x14 // OOC
289 #define LED_CLV 0x15 // OOC
290 #define LED_REC_FMT_DET 0x16 // OOC
291 #define LED_OFF_HOOK 0x17 // OOC
292 #define LED_RING 0x18 // OOC
293 #define LED_MSG_WAITING 0x19 // OOC
294 #define LED_DATA_MODE 0x1A // OOC
295 #define LED_BAT_OPERATION 0x1B // OOC
296 #define LED_BAT_OK 0x1C // OOC
297 #define LED_BAT_LOW 0x1D // OOC
298 #define LED_SPEAKER 0x1E // OOC
299 #define LED_HEAD_SET 0x1F // OOC
300 #define LED_HOLD 0x20 // OOC
301 #define LED_MICROPHONE 0x21 // OOC
302 #define LED_COVERAGE 0x22 // OOC
303 #define LED_NIGHT_MODE 0x23 // OOC
304 #define LED_SEND_CALLS 0x24 // OOC
305 #define LED_CALL_PICKUP 0x25 // OOC
306 #define LED_CONFERENCE 0x26 // OOC
307 #define LED_STAND_BY 0x27 // OOC
308 #define LED_CAMERA_ON 0x28 // OOC
309 #define LED_CAMERA_OFF 0x29 // OOC
310 #define LED_ON_LINE 0x2A // OOC
311 #define LED_OFF_LINE 0x2B // OOC
312 #define LED_BUSY 0x2C // OOC
313 #define LED_READY 0x2D // OOC
314 #define LED_PAPER_OUT 0x2E // OOC
315 #define LED_PAPER_JAM 0x2F // OOC
316 #define LED_REMOTE 0x30 // OOC
317 #define LED_FORWARD 0x31 // OOC
318 #define LED_REVERSE 0x32 // OOC
319 #define LED_STOP 0x33 // OOC
320 #define LED_REWIND 0x34 // OOC
321 #define LED_FAST_FORWARD 0x35 // OOC
322 #define LED_PLAY 0x36 // OOC
323 #define LED_PAUSE 0x37 // OOC
324 #define LED_RECORD 0x38 // OOC
325 #define LED_ERROR 0x39 // OOC
326 #define LED_USI 0x3A // US
327 #define LED_UIUI 0x3B // US
328 #define LED_UMMI 0x3C // UM
329 #define LED_IND_ON 0x3D // Sel
330 #define LED_IND_FLASH 0x3E // Sel
331 #define LED_IND_SLOW_BLNK 0x3F // Sel
332 #define LED_IND_FAST_BLNK 0x40 // Sel
333 #define LED_IND_OFF 0x41 // Sel
334 #define LED_FLASH_ON_TIME 0x42 // DV
335 #define LED_SLW_B_ON_TIME 0x43 // DV
336 #define LED_SLW_B_OFF_TIME 0x44 // DV
337 #define LED_FST_B_ON_TIME 0x45 // DV
338 #define LED_FST_B_OFF_TIME 0x46 // DV
339 #define LED_UIC 0x47 // UM
340 #define LED_IND_RED 0x48 // Sel
341 #define LED_IND_GREEN 0x49 // Sel
342 #define LED_IND_AMBER 0x4A // Sel
343 #define LED_GENERIC_IND 0x4B // OOC
344 #define LED_SYS_SUSPEND 0x4C // OOC
345 #define LED_EXT_PWR_CONN 0x4D // OOC
346 // 0x4E - 0xFFFF Reserved
349 // List of Mouse Buttons - USB HID 1.11 pg 67
350 #define MOUSE_NOPRESS 0x00
351 #define MOUSE_PRIMARY 0x01 // Button 1
352 #define MOUSE_SECONDARY 0x02 // Button 2
353 #define MOUSE_TERTIARY 0x03 // Button 3
354 #define MOUSE_BUTTON(x) x
355 // Continues to 0xFFFF, the higher the Mouse code, the selector significance descreases
356 // Buttons can be defined as:
358 // OOC - On/Off Control
359 // MC - Momentary Control
360 // OSC - One-Shot Control
361 // depending on context.