mikroSDK Reference Manual
hid.h
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2019 Ha Thach (tinyusb.org)
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 * This file is part of the TinyUSB stack.
25 */
26
31#ifndef _TUSB_HID_H_
32#define _TUSB_HID_H_
33
34#include "common/tusb_common.h"
35
36#ifdef __cplusplus
37 extern "C" {
38#endif
39
40//--------------------------------------------------------------------+
41// Common Definitions
42//--------------------------------------------------------------------+
46
47typedef struct TU_ATTR_PACKED
48{
49 uint8_t bLength;
50 uint8_t bDescriptorType;
52 uint16_t bcdHID;
53 uint8_t bCountryCode;
56 uint8_t bReportType;
57 uint16_t wReportLength;
59
66
74
82
91
102
143
144// HID protocol value used by GetProtocol / SetProtocol
145typedef enum
146{
147 HID_PROTOCOL_BOOT = 0,
148 HID_PROTOCOL_REPORT = 1
149} hid_protocol_mode_enum_t;
150
153//--------------------------------------------------------------------+
154// GAMEPAD
155//--------------------------------------------------------------------+
159/* From https://www.kernel.org/doc/html/latest/input/gamepad.html
160 ____________________________ __
161 / [__ZL__] [__ZR__] \ |
162 / [__ TL __] [__ TR __] \ | Front Triggers
163 __/________________________________\__ __|
164 / _ \ |
165 / /\ __ (N) \ |
166 / || __ |MO| __ _ _ \ | Main Pad
167 | <===DP===> |SE| |ST| (W) -|- (E) | |
168 \ || ___ ___ _ / |
169 /\ \/ / \ / \ (S) /\ __|
170 / \________ | LS | ____ | RS | ________/ \ |
171| / \ \___/ / \ \___/ / \ | | Control Sticks
172| / \_____/ \_____/ \ | __|
173| / \ |
174 \_____/ \_____/
175
176 |________|______| |______|___________|
177 D-Pad Left Right Action Pad
178 Stick Stick
179
180 |_____________|
181 Menu Pad
182
183 Most gamepads have the following features:
184 - Action-Pad 4 buttons in diamonds-shape (on the right side) NORTH, SOUTH, WEST and EAST.
185 - D-Pad (Direction-pad) 4 buttons (on the left side) that point up, down, left and right.
186 - Menu-Pad Different constellations, but most-times 2 buttons: SELECT - START.
187 - Analog-Sticks provide freely moveable sticks to control directions, Analog-sticks may also
188 provide a digital button if you press them.
189 - Triggers are located on the upper-side of the pad in vertical direction. The upper buttons
190 are normally named Left- and Right-Triggers, the lower buttons Z-Left and Z-Right.
191 - Rumble Many devices provide force-feedback features. But are mostly just simple rumble motors.
192 */
193
195typedef struct TU_ATTR_PACKED
196{
197 int8_t x;
198 int8_t y;
199 int8_t z;
200 int8_t rz;
201 int8_t rx;
202 int8_t ry;
203 uint8_t hat;
204 uint32_t buttons;
206
208typedef enum
209{
210 GAMEPAD_BUTTON_0 = TU_BIT(0),
211 GAMEPAD_BUTTON_1 = TU_BIT(1),
212 GAMEPAD_BUTTON_2 = TU_BIT(2),
213 GAMEPAD_BUTTON_3 = TU_BIT(3),
214 GAMEPAD_BUTTON_4 = TU_BIT(4),
215 GAMEPAD_BUTTON_5 = TU_BIT(5),
216 GAMEPAD_BUTTON_6 = TU_BIT(6),
217 GAMEPAD_BUTTON_7 = TU_BIT(7),
218 GAMEPAD_BUTTON_8 = TU_BIT(8),
219 GAMEPAD_BUTTON_9 = TU_BIT(9),
220 GAMEPAD_BUTTON_10 = TU_BIT(10),
221 GAMEPAD_BUTTON_11 = TU_BIT(11),
222 GAMEPAD_BUTTON_12 = TU_BIT(12),
223 GAMEPAD_BUTTON_13 = TU_BIT(13),
224 GAMEPAD_BUTTON_14 = TU_BIT(14),
225 GAMEPAD_BUTTON_15 = TU_BIT(15),
226 GAMEPAD_BUTTON_16 = TU_BIT(16),
227 GAMEPAD_BUTTON_17 = TU_BIT(17),
228 GAMEPAD_BUTTON_18 = TU_BIT(18),
229 GAMEPAD_BUTTON_19 = TU_BIT(19),
230 GAMEPAD_BUTTON_20 = TU_BIT(20),
231 GAMEPAD_BUTTON_21 = TU_BIT(21),
232 GAMEPAD_BUTTON_22 = TU_BIT(22),
233 GAMEPAD_BUTTON_23 = TU_BIT(23),
234 GAMEPAD_BUTTON_24 = TU_BIT(24),
235 GAMEPAD_BUTTON_25 = TU_BIT(25),
236 GAMEPAD_BUTTON_26 = TU_BIT(26),
237 GAMEPAD_BUTTON_27 = TU_BIT(27),
238 GAMEPAD_BUTTON_28 = TU_BIT(28),
239 GAMEPAD_BUTTON_29 = TU_BIT(29),
240 GAMEPAD_BUTTON_30 = TU_BIT(30),
241 GAMEPAD_BUTTON_31 = TU_BIT(31),
243
246#define GAMEPAD_BUTTON_A GAMEPAD_BUTTON_0
247#define GAMEPAD_BUTTON_SOUTH GAMEPAD_BUTTON_0
248
249#define GAMEPAD_BUTTON_B GAMEPAD_BUTTON_1
250#define GAMEPAD_BUTTON_EAST GAMEPAD_BUTTON_1
251
252#define GAMEPAD_BUTTON_C GAMEPAD_BUTTON_2
253
254#define GAMEPAD_BUTTON_X GAMEPAD_BUTTON_3
255#define GAMEPAD_BUTTON_NORTH GAMEPAD_BUTTON_3
256
257#define GAMEPAD_BUTTON_Y GAMEPAD_BUTTON_4
258#define GAMEPAD_BUTTON_WEST GAMEPAD_BUTTON_4
259
260#define GAMEPAD_BUTTON_Z GAMEPAD_BUTTON_5
261#define GAMEPAD_BUTTON_TL GAMEPAD_BUTTON_6
262#define GAMEPAD_BUTTON_TR GAMEPAD_BUTTON_7
263#define GAMEPAD_BUTTON_TL2 GAMEPAD_BUTTON_8
264#define GAMEPAD_BUTTON_TR2 GAMEPAD_BUTTON_9
265#define GAMEPAD_BUTTON_SELECT GAMEPAD_BUTTON_10
266#define GAMEPAD_BUTTON_START GAMEPAD_BUTTON_11
267#define GAMEPAD_BUTTON_MODE GAMEPAD_BUTTON_12
268#define GAMEPAD_BUTTON_THUMBL GAMEPAD_BUTTON_13
269#define GAMEPAD_BUTTON_THUMBR GAMEPAD_BUTTON_14
270
284
286
287//--------------------------------------------------------------------+
288// MOUSE
289//--------------------------------------------------------------------+
293
294typedef struct TU_ATTR_PACKED
295{
296 uint8_t buttons;
297 int8_t x;
298 int8_t y;
299 int8_t wheel;
300 int8_t pan; // using AC Pan
302
304typedef enum
305{
306 MOUSE_BUTTON_LEFT = TU_BIT(0),
307 MOUSE_BUTTON_RIGHT = TU_BIT(1),
312
314
315//--------------------------------------------------------------------+
316// Keyboard
317//--------------------------------------------------------------------+
321
322typedef struct TU_ATTR_PACKED
323{
324 uint8_t modifier;
325 uint8_t reserved;
326 uint8_t keycode[6];
328
341
350
352
353//--------------------------------------------------------------------+
354// HID KEYCODE
355//--------------------------------------------------------------------+
356#define HID_KEY_NONE 0x00
357#define HID_KEY_A 0x04
358#define HID_KEY_B 0x05
359#define HID_KEY_C 0x06
360#define HID_KEY_D 0x07
361#define HID_KEY_E 0x08
362#define HID_KEY_F 0x09
363#define HID_KEY_G 0x0A
364#define HID_KEY_H 0x0B
365#define HID_KEY_I 0x0C
366#define HID_KEY_J 0x0D
367#define HID_KEY_K 0x0E
368#define HID_KEY_L 0x0F
369#define HID_KEY_M 0x10
370#define HID_KEY_N 0x11
371#define HID_KEY_O 0x12
372#define HID_KEY_P 0x13
373#define HID_KEY_Q 0x14
374#define HID_KEY_R 0x15
375#define HID_KEY_S 0x16
376#define HID_KEY_T 0x17
377#define HID_KEY_U 0x18
378#define HID_KEY_V 0x19
379#define HID_KEY_W 0x1A
380#define HID_KEY_X 0x1B
381#define HID_KEY_Y 0x1C
382#define HID_KEY_Z 0x1D
383#define HID_KEY_1 0x1E
384#define HID_KEY_2 0x1F
385#define HID_KEY_3 0x20
386#define HID_KEY_4 0x21
387#define HID_KEY_5 0x22
388#define HID_KEY_6 0x23
389#define HID_KEY_7 0x24
390#define HID_KEY_8 0x25
391#define HID_KEY_9 0x26
392#define HID_KEY_0 0x27
393#define HID_KEY_ENTER 0x28
394#define HID_KEY_ESCAPE 0x29
395#define HID_KEY_BACKSPACE 0x2A
396#define HID_KEY_TAB 0x2B
397#define HID_KEY_SPACE 0x2C
398#define HID_KEY_MINUS 0x2D
399#define HID_KEY_EQUAL 0x2E
400#define HID_KEY_BRACKET_LEFT 0x2F
401#define HID_KEY_BRACKET_RIGHT 0x30
402#define HID_KEY_BACKSLASH 0x31
403#define HID_KEY_EUROPE_1 0x32
404#define HID_KEY_SEMICOLON 0x33
405#define HID_KEY_APOSTROPHE 0x34
406#define HID_KEY_GRAVE 0x35
407#define HID_KEY_COMMA 0x36
408#define HID_KEY_PERIOD 0x37
409#define HID_KEY_SLASH 0x38
410#define HID_KEY_CAPS_LOCK 0x39
411#define HID_KEY_F1 0x3A
412#define HID_KEY_F2 0x3B
413#define HID_KEY_F3 0x3C
414#define HID_KEY_F4 0x3D
415#define HID_KEY_F5 0x3E
416#define HID_KEY_F6 0x3F
417#define HID_KEY_F7 0x40
418#define HID_KEY_F8 0x41
419#define HID_KEY_F9 0x42
420#define HID_KEY_F10 0x43
421#define HID_KEY_F11 0x44
422#define HID_KEY_F12 0x45
423#define HID_KEY_PRINT_SCREEN 0x46
424#define HID_KEY_SCROLL_LOCK 0x47
425#define HID_KEY_PAUSE 0x48
426#define HID_KEY_INSERT 0x49
427#define HID_KEY_HOME 0x4A
428#define HID_KEY_PAGE_UP 0x4B
429#define HID_KEY_DELETE 0x4C
430#define HID_KEY_END 0x4D
431#define HID_KEY_PAGE_DOWN 0x4E
432#define HID_KEY_ARROW_RIGHT 0x4F
433#define HID_KEY_ARROW_LEFT 0x50
434#define HID_KEY_ARROW_DOWN 0x51
435#define HID_KEY_ARROW_UP 0x52
436#define HID_KEY_NUM_LOCK 0x53
437#define HID_KEY_KEYPAD_DIVIDE 0x54
438#define HID_KEY_KEYPAD_MULTIPLY 0x55
439#define HID_KEY_KEYPAD_SUBTRACT 0x56
440#define HID_KEY_KEYPAD_ADD 0x57
441#define HID_KEY_KEYPAD_ENTER 0x58
442#define HID_KEY_KEYPAD_1 0x59
443#define HID_KEY_KEYPAD_2 0x5A
444#define HID_KEY_KEYPAD_3 0x5B
445#define HID_KEY_KEYPAD_4 0x5C
446#define HID_KEY_KEYPAD_5 0x5D
447#define HID_KEY_KEYPAD_6 0x5E
448#define HID_KEY_KEYPAD_7 0x5F
449#define HID_KEY_KEYPAD_8 0x60
450#define HID_KEY_KEYPAD_9 0x61
451#define HID_KEY_KEYPAD_0 0x62
452#define HID_KEY_KEYPAD_DECIMAL 0x63
453#define HID_KEY_EUROPE_2 0x64
454#define HID_KEY_APPLICATION 0x65
455#define HID_KEY_POWER 0x66
456#define HID_KEY_KEYPAD_EQUAL 0x67
457#define HID_KEY_F13 0x68
458#define HID_KEY_F14 0x69
459#define HID_KEY_F15 0x6A
460#define HID_KEY_F16 0x6B
461#define HID_KEY_F17 0x6C
462#define HID_KEY_F18 0x6D
463#define HID_KEY_F19 0x6E
464#define HID_KEY_F20 0x6F
465#define HID_KEY_F21 0x70
466#define HID_KEY_F22 0x71
467#define HID_KEY_F23 0x72
468#define HID_KEY_F24 0x73
469#define HID_KEY_EXECUTE 0x74
470#define HID_KEY_HELP 0x75
471#define HID_KEY_MENU 0x76
472#define HID_KEY_SELECT 0x77
473#define HID_KEY_STOP 0x78
474#define HID_KEY_AGAIN 0x79
475#define HID_KEY_UNDO 0x7A
476#define HID_KEY_CUT 0x7B
477#define HID_KEY_COPY 0x7C
478#define HID_KEY_PASTE 0x7D
479#define HID_KEY_FIND 0x7E
480#define HID_KEY_MUTE 0x7F
481#define HID_KEY_VOLUME_UP 0x80
482#define HID_KEY_VOLUME_DOWN 0x81
483#define HID_KEY_LOCKING_CAPS_LOCK 0x82
484#define HID_KEY_LOCKING_NUM_LOCK 0x83
485#define HID_KEY_LOCKING_SCROLL_LOCK 0x84
486#define HID_KEY_KEYPAD_COMMA 0x85
487#define HID_KEY_KEYPAD_EQUAL_SIGN 0x86
488#define HID_KEY_KANJI1 0x87
489#define HID_KEY_KANJI2 0x88
490#define HID_KEY_KANJI3 0x89
491#define HID_KEY_KANJI4 0x8A
492#define HID_KEY_KANJI5 0x8B
493#define HID_KEY_KANJI6 0x8C
494#define HID_KEY_KANJI7 0x8D
495#define HID_KEY_KANJI8 0x8E
496#define HID_KEY_KANJI9 0x8F
497#define HID_KEY_LANG1 0x90
498#define HID_KEY_LANG2 0x91
499#define HID_KEY_LANG3 0x92
500#define HID_KEY_LANG4 0x93
501#define HID_KEY_LANG5 0x94
502#define HID_KEY_LANG6 0x95
503#define HID_KEY_LANG7 0x96
504#define HID_KEY_LANG8 0x97
505#define HID_KEY_LANG9 0x98
506#define HID_KEY_ALTERNATE_ERASE 0x99
507#define HID_KEY_SYSREQ_ATTENTION 0x9A
508#define HID_KEY_CANCEL 0x9B
509#define HID_KEY_CLEAR 0x9C
510#define HID_KEY_PRIOR 0x9D
511#define HID_KEY_RETURN 0x9E
512#define HID_KEY_SEPARATOR 0x9F
513#define HID_KEY_OUT 0xA0
514#define HID_KEY_OPER 0xA1
515#define HID_KEY_CLEAR_AGAIN 0xA2
516#define HID_KEY_CRSEL_PROPS 0xA3
517#define HID_KEY_EXSEL 0xA4
518// RESERVED 0xA5-DF
519#define HID_KEY_CONTROL_LEFT 0xE0
520#define HID_KEY_SHIFT_LEFT 0xE1
521#define HID_KEY_ALT_LEFT 0xE2
522#define HID_KEY_GUI_LEFT 0xE3
523#define HID_KEY_CONTROL_RIGHT 0xE4
524#define HID_KEY_SHIFT_RIGHT 0xE5
525#define HID_KEY_ALT_RIGHT 0xE6
526#define HID_KEY_GUI_RIGHT 0xE7
527
528
529//--------------------------------------------------------------------+
530// REPORT DESCRIPTOR
531//--------------------------------------------------------------------+
532
533//------------- ITEM & TAG -------------//
534#define HID_REPORT_DATA_0(data)
535#define HID_REPORT_DATA_1(data) , data
536#define HID_REPORT_DATA_2(data) , U16_TO_U8S_LE(data)
537#define HID_REPORT_DATA_3(data) , U32_TO_U8S_LE(data)
538
539#define HID_REPORT_ITEM(data, tag, type, size) \
540 (((tag) << 4) | ((type) << 2) | (size)) HID_REPORT_DATA_##size(data)
541
542// Report Item Types
543enum {
544 RI_TYPE_MAIN = 0,
545 RI_TYPE_GLOBAL = 1,
546 RI_TYPE_LOCAL = 2
547};
548
549//------------- Main Items - HID 1.11 section 6.2.2.4 -------------//
550
551// Report Item Main group
552enum {
553 RI_MAIN_INPUT = 8,
554 RI_MAIN_OUTPUT = 9,
555 RI_MAIN_COLLECTION = 10,
556 RI_MAIN_FEATURE = 11,
557 RI_MAIN_COLLECTION_END = 12
558};
559
560#define HID_INPUT(x) HID_REPORT_ITEM(x, RI_MAIN_INPUT , RI_TYPE_MAIN, 1)
561#define HID_OUTPUT(x) HID_REPORT_ITEM(x, RI_MAIN_OUTPUT , RI_TYPE_MAIN, 1)
562#define HID_COLLECTION(x) HID_REPORT_ITEM(x, RI_MAIN_COLLECTION , RI_TYPE_MAIN, 1)
563#define HID_FEATURE(x) HID_REPORT_ITEM(x, RI_MAIN_FEATURE , RI_TYPE_MAIN, 1)
564#define HID_COLLECTION_END HID_REPORT_ITEM(x, RI_MAIN_COLLECTION_END, RI_TYPE_MAIN, 0)
565
566//------------- Input, Output, Feature - HID 1.11 section 6.2.2.5 -------------//
567#define HID_DATA (0<<0)
568#define HID_CONSTANT (1<<0)
569
570#define HID_ARRAY (0<<1)
571#define HID_VARIABLE (1<<1)
572
573#define HID_ABSOLUTE (0<<2)
574#define HID_RELATIVE (1<<2)
575
576#define HID_WRAP_NO (0<<3)
577#define HID_WRAP (1<<3)
578
579#define HID_LINEAR (0<<4)
580#define HID_NONLINEAR (1<<4)
581
582#define HID_PREFERRED_STATE (0<<5)
583#define HID_PREFERRED_NO (1<<5)
584
585#define HID_NO_NULL_POSITION (0<<6)
586#define HID_NULL_STATE (1<<6)
587
588#define HID_NON_VOLATILE (0<<7)
589#define HID_VOLATILE (1<<7)
590
591#define HID_BITFIELD (0<<8)
592#define HID_BUFFERED_BYTES (1<<8)
593
594//------------- Collection Item - HID 1.11 section 6.2.2.6 -------------//
595enum {
596 HID_COLLECTION_PHYSICAL = 0,
597 HID_COLLECTION_APPLICATION,
598 HID_COLLECTION_LOGICAL,
599 HID_COLLECTION_REPORT,
600 HID_COLLECTION_NAMED_ARRAY,
601 HID_COLLECTION_USAGE_SWITCH,
602 HID_COLLECTION_USAGE_MODIFIER
603};
604
605//------------- Global Items - HID 1.11 section 6.2.2.7 -------------//
606
607// Report Item Global group
608enum {
609 RI_GLOBAL_USAGE_PAGE = 0,
610 RI_GLOBAL_LOGICAL_MIN = 1,
611 RI_GLOBAL_LOGICAL_MAX = 2,
612 RI_GLOBAL_PHYSICAL_MIN = 3,
613 RI_GLOBAL_PHYSICAL_MAX = 4,
614 RI_GLOBAL_UNIT_EXPONENT = 5,
615 RI_GLOBAL_UNIT = 6,
616 RI_GLOBAL_REPORT_SIZE = 7,
617 RI_GLOBAL_REPORT_ID = 8,
618 RI_GLOBAL_REPORT_COUNT = 9,
619 RI_GLOBAL_PUSH = 10,
620 RI_GLOBAL_POP = 11
621};
622
623#define HID_USAGE_PAGE(x) HID_REPORT_ITEM(x, RI_GLOBAL_USAGE_PAGE, RI_TYPE_GLOBAL, 1)
624#define HID_USAGE_PAGE_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_USAGE_PAGE, RI_TYPE_GLOBAL, n)
625
626#define HID_LOGICAL_MIN(x) HID_REPORT_ITEM(x, RI_GLOBAL_LOGICAL_MIN, RI_TYPE_GLOBAL, 1)
627#define HID_LOGICAL_MIN_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_LOGICAL_MIN, RI_TYPE_GLOBAL, n)
628
629#define HID_LOGICAL_MAX(x) HID_REPORT_ITEM(x, RI_GLOBAL_LOGICAL_MAX, RI_TYPE_GLOBAL, 1)
630#define HID_LOGICAL_MAX_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_LOGICAL_MAX, RI_TYPE_GLOBAL, n)
631
632#define HID_PHYSICAL_MIN(x) HID_REPORT_ITEM(x, RI_GLOBAL_PHYSICAL_MIN, RI_TYPE_GLOBAL, 1)
633#define HID_PHYSICAL_MIN_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_PHYSICAL_MIN, RI_TYPE_GLOBAL, n)
634
635#define HID_PHYSICAL_MAX(x) HID_REPORT_ITEM(x, RI_GLOBAL_PHYSICAL_MAX, RI_TYPE_GLOBAL, 1)
636#define HID_PHYSICAL_MAX_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_PHYSICAL_MAX, RI_TYPE_GLOBAL, n)
637
638#define HID_UNIT_EXPONENT(x) HID_REPORT_ITEM(x, RI_GLOBAL_UNIT_EXPONENT, RI_TYPE_GLOBAL, 1)
639#define HID_UNIT_EXPONENT_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_UNIT_EXPONENT, RI_TYPE_GLOBAL, n)
640
641#define HID_UNIT(x) HID_REPORT_ITEM(x, RI_GLOBAL_UNIT, RI_TYPE_GLOBAL, 1)
642#define HID_UNIT_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_UNIT, RI_TYPE_GLOBAL, n)
643
644#define HID_REPORT_SIZE(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_SIZE, RI_TYPE_GLOBAL, 1)
645#define HID_REPORT_SIZE_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_SIZE, RI_TYPE_GLOBAL, n)
646
647#define HID_REPORT_ID(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_ID, RI_TYPE_GLOBAL, 1),
648#define HID_REPORT_ID_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_ID, RI_TYPE_GLOBAL, n),
649
650#define HID_REPORT_COUNT(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_COUNT, RI_TYPE_GLOBAL, 1)
651#define HID_REPORT_COUNT_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_COUNT, RI_TYPE_GLOBAL, n)
652
653#define HID_PUSH HID_REPORT_ITEM(x, RI_GLOBAL_PUSH, RI_TYPE_GLOBAL, 0)
654#define HID_POP HID_REPORT_ITEM(x, RI_GLOBAL_POP, RI_TYPE_GLOBAL, 0)
655
656//------------- LOCAL ITEMS 6.2.2.8 -------------//
657
658enum {
659 RI_LOCAL_USAGE = 0,
660 RI_LOCAL_USAGE_MIN = 1,
661 RI_LOCAL_USAGE_MAX = 2,
662 RI_LOCAL_DESIGNATOR_INDEX = 3,
663 RI_LOCAL_DESIGNATOR_MIN = 4,
664 RI_LOCAL_DESIGNATOR_MAX = 5,
665 // 6 is reserved
666 RI_LOCAL_STRING_INDEX = 7,
667 RI_LOCAL_STRING_MIN = 8,
668 RI_LOCAL_STRING_MAX = 9,
669 RI_LOCAL_DELIMITER = 10,
670};
671
672#define HID_USAGE(x) HID_REPORT_ITEM(x, RI_LOCAL_USAGE, RI_TYPE_LOCAL, 1)
673#define HID_USAGE_N(x, n) HID_REPORT_ITEM(x, RI_LOCAL_USAGE, RI_TYPE_LOCAL, n)
674
675#define HID_USAGE_MIN(x) HID_REPORT_ITEM(x, RI_LOCAL_USAGE_MIN, RI_TYPE_LOCAL, 1)
676#define HID_USAGE_MIN_N(x, n) HID_REPORT_ITEM(x, RI_LOCAL_USAGE_MIN, RI_TYPE_LOCAL, n)
677
678#define HID_USAGE_MAX(x) HID_REPORT_ITEM(x, RI_LOCAL_USAGE_MAX, RI_TYPE_LOCAL, 1)
679#define HID_USAGE_MAX_N(x, n) HID_REPORT_ITEM(x, RI_LOCAL_USAGE_MAX, RI_TYPE_LOCAL, n)
680
681//--------------------------------------------------------------------+
682// Usage Table
683//--------------------------------------------------------------------+
684
686enum {
687 HID_USAGE_PAGE_DESKTOP = 0x01,
688 HID_USAGE_PAGE_SIMULATE = 0x02,
689 HID_USAGE_PAGE_VIRTUAL_REALITY = 0x03,
690 HID_USAGE_PAGE_SPORT = 0x04,
691 HID_USAGE_PAGE_GAME = 0x05,
692 HID_USAGE_PAGE_GENERIC_DEVICE = 0x06,
693 HID_USAGE_PAGE_KEYBOARD = 0x07,
694 HID_USAGE_PAGE_LED = 0x08,
695 HID_USAGE_PAGE_BUTTON = 0x09,
696 HID_USAGE_PAGE_ORDINAL = 0x0a,
697 HID_USAGE_PAGE_TELEPHONY = 0x0b,
698 HID_USAGE_PAGE_CONSUMER = 0x0c,
699 HID_USAGE_PAGE_DIGITIZER = 0x0d,
700 HID_USAGE_PAGE_PID = 0x0f,
701 HID_USAGE_PAGE_UNICODE = 0x10,
702 HID_USAGE_PAGE_ALPHA_DISPLAY = 0x14,
703 HID_USAGE_PAGE_MEDICAL = 0x40,
704 HID_USAGE_PAGE_MONITOR = 0x80, //0x80 - 0x83
705 HID_USAGE_PAGE_POWER = 0x84, // 0x084 - 0x87
706 HID_USAGE_PAGE_BARCODE_SCANNER = 0x8c,
707 HID_USAGE_PAGE_SCALE = 0x8d,
708 HID_USAGE_PAGE_MSR = 0x8e,
709 HID_USAGE_PAGE_CAMERA = 0x90,
710 HID_USAGE_PAGE_ARCADE = 0x91,
711 HID_USAGE_PAGE_FIDO = 0xF1D0, // FIDO alliance HID usage page
712 HID_USAGE_PAGE_VENDOR = 0xFF00 // 0xFF00 - 0xFFFF
713};
714
716enum {
717 HID_USAGE_DESKTOP_POINTER = 0x01,
718 HID_USAGE_DESKTOP_MOUSE = 0x02,
719 HID_USAGE_DESKTOP_JOYSTICK = 0x04,
720 HID_USAGE_DESKTOP_GAMEPAD = 0x05,
721 HID_USAGE_DESKTOP_KEYBOARD = 0x06,
722 HID_USAGE_DESKTOP_KEYPAD = 0x07,
723 HID_USAGE_DESKTOP_MULTI_AXIS_CONTROLLER = 0x08,
724 HID_USAGE_DESKTOP_TABLET_PC_SYSTEM = 0x09,
725 HID_USAGE_DESKTOP_X = 0x30,
726 HID_USAGE_DESKTOP_Y = 0x31,
727 HID_USAGE_DESKTOP_Z = 0x32,
728 HID_USAGE_DESKTOP_RX = 0x33,
729 HID_USAGE_DESKTOP_RY = 0x34,
730 HID_USAGE_DESKTOP_RZ = 0x35,
731 HID_USAGE_DESKTOP_SLIDER = 0x36,
732 HID_USAGE_DESKTOP_DIAL = 0x37,
733 HID_USAGE_DESKTOP_WHEEL = 0x38,
734 HID_USAGE_DESKTOP_HAT_SWITCH = 0x39,
735 HID_USAGE_DESKTOP_COUNTED_BUFFER = 0x3a,
736 HID_USAGE_DESKTOP_BYTE_COUNT = 0x3b,
737 HID_USAGE_DESKTOP_MOTION_WAKEUP = 0x3c,
738 HID_USAGE_DESKTOP_START = 0x3d,
739 HID_USAGE_DESKTOP_SELECT = 0x3e,
740 HID_USAGE_DESKTOP_VX = 0x40,
741 HID_USAGE_DESKTOP_VY = 0x41,
742 HID_USAGE_DESKTOP_VZ = 0x42,
743 HID_USAGE_DESKTOP_VBRX = 0x43,
744 HID_USAGE_DESKTOP_VBRY = 0x44,
745 HID_USAGE_DESKTOP_VBRZ = 0x45,
746 HID_USAGE_DESKTOP_VNO = 0x46,
747 HID_USAGE_DESKTOP_FEATURE_NOTIFICATION = 0x47,
748 HID_USAGE_DESKTOP_RESOLUTION_MULTIPLIER = 0x48,
749 HID_USAGE_DESKTOP_SYSTEM_CONTROL = 0x80,
750 HID_USAGE_DESKTOP_SYSTEM_POWER_DOWN = 0x81,
751 HID_USAGE_DESKTOP_SYSTEM_SLEEP = 0x82,
752 HID_USAGE_DESKTOP_SYSTEM_WAKE_UP = 0x83,
753 HID_USAGE_DESKTOP_SYSTEM_CONTEXT_MENU = 0x84,
754 HID_USAGE_DESKTOP_SYSTEM_MAIN_MENU = 0x85,
755 HID_USAGE_DESKTOP_SYSTEM_APP_MENU = 0x86,
756 HID_USAGE_DESKTOP_SYSTEM_MENU_HELP = 0x87,
757 HID_USAGE_DESKTOP_SYSTEM_MENU_EXIT = 0x88,
758 HID_USAGE_DESKTOP_SYSTEM_MENU_SELECT = 0x89,
759 HID_USAGE_DESKTOP_SYSTEM_MENU_RIGHT = 0x8A,
760 HID_USAGE_DESKTOP_SYSTEM_MENU_LEFT = 0x8B,
761 HID_USAGE_DESKTOP_SYSTEM_MENU_UP = 0x8C,
762 HID_USAGE_DESKTOP_SYSTEM_MENU_DOWN = 0x8D,
763 HID_USAGE_DESKTOP_SYSTEM_COLD_RESTART = 0x8E,
764 HID_USAGE_DESKTOP_SYSTEM_WARM_RESTART = 0x8F,
765 HID_USAGE_DESKTOP_DPAD_UP = 0x90,
766 HID_USAGE_DESKTOP_DPAD_DOWN = 0x91,
767 HID_USAGE_DESKTOP_DPAD_RIGHT = 0x92,
768 HID_USAGE_DESKTOP_DPAD_LEFT = 0x93,
769 HID_USAGE_DESKTOP_SYSTEM_DOCK = 0xA0,
770 HID_USAGE_DESKTOP_SYSTEM_UNDOCK = 0xA1,
771 HID_USAGE_DESKTOP_SYSTEM_SETUP = 0xA2,
772 HID_USAGE_DESKTOP_SYSTEM_BREAK = 0xA3,
773 HID_USAGE_DESKTOP_SYSTEM_DEBUGGER_BREAK = 0xA4,
774 HID_USAGE_DESKTOP_APPLICATION_BREAK = 0xA5,
775 HID_USAGE_DESKTOP_APPLICATION_DEBUGGER_BREAK = 0xA6,
776 HID_USAGE_DESKTOP_SYSTEM_SPEAKER_MUTE = 0xA7,
777 HID_USAGE_DESKTOP_SYSTEM_HIBERNATE = 0xA8,
778 HID_USAGE_DESKTOP_SYSTEM_DISPLAY_INVERT = 0xB0,
779 HID_USAGE_DESKTOP_SYSTEM_DISPLAY_INTERNAL = 0xB1,
780 HID_USAGE_DESKTOP_SYSTEM_DISPLAY_EXTERNAL = 0xB2,
781 HID_USAGE_DESKTOP_SYSTEM_DISPLAY_BOTH = 0xB3,
782 HID_USAGE_DESKTOP_SYSTEM_DISPLAY_DUAL = 0xB4,
783 HID_USAGE_DESKTOP_SYSTEM_DISPLAY_TOGGLE_INT_EXT = 0xB5,
784 HID_USAGE_DESKTOP_SYSTEM_DISPLAY_SWAP_PRIMARY_SECONDARY = 0xB6,
785 HID_USAGE_DESKTOP_SYSTEM_DISPLAY_LCD_AUTOSCALE = 0xB7
786};
787
788
791enum
792{
793 // Generic Control
794 HID_USAGE_CONSUMER_CONTROL = 0x0001,
795
796 // Power Control
797 HID_USAGE_CONSUMER_POWER = 0x0030,
798 HID_USAGE_CONSUMER_RESET = 0x0031,
799 HID_USAGE_CONSUMER_SLEEP = 0x0032,
800
801 // Screen Brightness
802 HID_USAGE_CONSUMER_BRIGHTNESS_INCREMENT = 0x006F,
803 HID_USAGE_CONSUMER_BRIGHTNESS_DECREMENT = 0x0070,
804
805 // These HID usages operate only on mobile systems (battery powered) and
806 // require Windows 8 (build 8302 or greater).
807 HID_USAGE_CONSUMER_WIRELESS_RADIO_CONTROLS = 0x000C,
808 HID_USAGE_CONSUMER_WIRELESS_RADIO_BUTTONS = 0x00C6,
809 HID_USAGE_CONSUMER_WIRELESS_RADIO_LED = 0x00C7,
810 HID_USAGE_CONSUMER_WIRELESS_RADIO_SLIDER_SWITCH = 0x00C8,
811
812 // Media Control
813 HID_USAGE_CONSUMER_PLAY_PAUSE = 0x00CD,
814 HID_USAGE_CONSUMER_SCAN_NEXT = 0x00B5,
815 HID_USAGE_CONSUMER_SCAN_PREVIOUS = 0x00B6,
816 HID_USAGE_CONSUMER_STOP = 0x00B7,
817 HID_USAGE_CONSUMER_VOLUME = 0x00E0,
818 HID_USAGE_CONSUMER_MUTE = 0x00E2,
819 HID_USAGE_CONSUMER_BASS = 0x00E3,
820 HID_USAGE_CONSUMER_TREBLE = 0x00E4,
821 HID_USAGE_CONSUMER_BASS_BOOST = 0x00E5,
822 HID_USAGE_CONSUMER_VOLUME_INCREMENT = 0x00E9,
823 HID_USAGE_CONSUMER_VOLUME_DECREMENT = 0x00EA,
824 HID_USAGE_CONSUMER_BASS_INCREMENT = 0x0152,
825 HID_USAGE_CONSUMER_BASS_DECREMENT = 0x0153,
826 HID_USAGE_CONSUMER_TREBLE_INCREMENT = 0x0154,
827 HID_USAGE_CONSUMER_TREBLE_DECREMENT = 0x0155,
828
829 // Application Launcher
830 HID_USAGE_CONSUMER_AL_CONSUMER_CONTROL_CONFIGURATION = 0x0183,
831 HID_USAGE_CONSUMER_AL_EMAIL_READER = 0x018A,
832 HID_USAGE_CONSUMER_AL_CALCULATOR = 0x0192,
833 HID_USAGE_CONSUMER_AL_LOCAL_BROWSER = 0x0194,
834
835 // Browser/Explorer Specific
836 HID_USAGE_CONSUMER_AC_SEARCH = 0x0221,
837 HID_USAGE_CONSUMER_AC_HOME = 0x0223,
838 HID_USAGE_CONSUMER_AC_BACK = 0x0224,
839 HID_USAGE_CONSUMER_AC_FORWARD = 0x0225,
840 HID_USAGE_CONSUMER_AC_STOP = 0x0226,
841 HID_USAGE_CONSUMER_AC_REFRESH = 0x0227,
842 HID_USAGE_CONSUMER_AC_BOOKMARKS = 0x022A,
843
844 // Mouse Horizontal scroll
845 HID_USAGE_CONSUMER_AC_PAN = 0x0238,
846};
847
849enum
850{
851 HID_USAGE_FIDO_U2FHID = 0x01, // U2FHID usage for top-level collection
852 HID_USAGE_FIDO_DATA_IN = 0x20, // Raw IN data report
853 HID_USAGE_FIDO_DATA_OUT = 0x21 // Raw OUT data report
854};
855
856/*--------------------------------------------------------------------
857 * ASCII to KEYCODE Conversion
858 * Expand to array of [128][2] (shift, keycode)
859 *
860 * Usage: example to convert input chr into keyboard report (modifier + keycode)
861 *
862 * uint8_t const conv_table[128][2] = { HID_ASCII_TO_KEYCODE };
863 *
864 * uint8_t keycode[6] = { 0 };
865 * uint8_t modifier = 0;
866 *
867 * if ( conv_table[chr][0] ) modifier = KEYBOARD_MODIFIER_LEFTSHIFT;
868 * keycode[0] = conv_table[chr][1];
869 * tud_hid_keyboard_report(report_id, modifier, keycode);
870 *
871 *--------------------------------------------------------------------*/
872#define HID_ASCII_TO_KEYCODE \
873 {0, 0 }, /* 0x00 Null */ \
874 {0, 0 }, /* 0x01 */ \
875 {0, 0 }, /* 0x02 */ \
876 {0, 0 }, /* 0x03 */ \
877 {0, 0 }, /* 0x04 */ \
878 {0, 0 }, /* 0x05 */ \
879 {0, 0 }, /* 0x06 */ \
880 {0, 0 }, /* 0x07 */ \
881 {0, HID_KEY_BACKSPACE }, /* 0x08 Backspace */ \
882 {0, HID_KEY_TAB }, /* 0x09 Tab */ \
883 {0, HID_KEY_ENTER }, /* 0x0A Line Feed */ \
884 {0, 0 }, /* 0x0B */ \
885 {0, 0 }, /* 0x0C */ \
886 {0, HID_KEY_ENTER }, /* 0x0D CR */ \
887 {0, 0 }, /* 0x0E */ \
888 {0, 0 }, /* 0x0F */ \
889 {0, 0 }, /* 0x10 */ \
890 {0, 0 }, /* 0x11 */ \
891 {0, 0 }, /* 0x12 */ \
892 {0, 0 }, /* 0x13 */ \
893 {0, 0 }, /* 0x14 */ \
894 {0, 0 }, /* 0x15 */ \
895 {0, 0 }, /* 0x16 */ \
896 {0, 0 }, /* 0x17 */ \
897 {0, 0 }, /* 0x18 */ \
898 {0, 0 }, /* 0x19 */ \
899 {0, 0 }, /* 0x1A */ \
900 {0, HID_KEY_ESCAPE }, /* 0x1B Escape */ \
901 {0, 0 }, /* 0x1C */ \
902 {0, 0 }, /* 0x1D */ \
903 {0, 0 }, /* 0x1E */ \
904 {0, 0 }, /* 0x1F */ \
905 \
906 {0, HID_KEY_SPACE }, /* 0x20 */ \
907 {1, HID_KEY_1 }, /* 0x21 ! */ \
908 {1, HID_KEY_APOSTROPHE }, /* 0x22 " */ \
909 {1, HID_KEY_3 }, /* 0x23 # */ \
910 {1, HID_KEY_4 }, /* 0x24 $ */ \
911 {1, HID_KEY_5 }, /* 0x25 % */ \
912 {1, HID_KEY_7 }, /* 0x26 & */ \
913 {0, HID_KEY_APOSTROPHE }, /* 0x27 ' */ \
914 {1, HID_KEY_9 }, /* 0x28 ( */ \
915 {1, HID_KEY_0 }, /* 0x29 ) */ \
916 {1, HID_KEY_8 }, /* 0x2A * */ \
917 {1, HID_KEY_EQUAL }, /* 0x2B + */ \
918 {0, HID_KEY_COMMA }, /* 0x2C , */ \
919 {0, HID_KEY_MINUS }, /* 0x2D - */ \
920 {0, HID_KEY_PERIOD }, /* 0x2E . */ \
921 {0, HID_KEY_SLASH }, /* 0x2F / */ \
922 {0, HID_KEY_0 }, /* 0x30 0 */ \
923 {0, HID_KEY_1 }, /* 0x31 1 */ \
924 {0, HID_KEY_2 }, /* 0x32 2 */ \
925 {0, HID_KEY_3 }, /* 0x33 3 */ \
926 {0, HID_KEY_4 }, /* 0x34 4 */ \
927 {0, HID_KEY_5 }, /* 0x35 5 */ \
928 {0, HID_KEY_6 }, /* 0x36 6 */ \
929 {0, HID_KEY_7 }, /* 0x37 7 */ \
930 {0, HID_KEY_8 }, /* 0x38 8 */ \
931 {0, HID_KEY_9 }, /* 0x39 9 */ \
932 {1, HID_KEY_SEMICOLON }, /* 0x3A : */ \
933 {0, HID_KEY_SEMICOLON }, /* 0x3B ; */ \
934 {1, HID_KEY_COMMA }, /* 0x3C < */ \
935 {0, HID_KEY_EQUAL }, /* 0x3D = */ \
936 {1, HID_KEY_PERIOD }, /* 0x3E > */ \
937 {1, HID_KEY_SLASH }, /* 0x3F ? */ \
938 \
939 {1, HID_KEY_2 }, /* 0x40 @ */ \
940 {1, HID_KEY_A }, /* 0x41 A */ \
941 {1, HID_KEY_B }, /* 0x42 B */ \
942 {1, HID_KEY_C }, /* 0x43 C */ \
943 {1, HID_KEY_D }, /* 0x44 D */ \
944 {1, HID_KEY_E }, /* 0x45 E */ \
945 {1, HID_KEY_F }, /* 0x46 F */ \
946 {1, HID_KEY_G }, /* 0x47 G */ \
947 {1, HID_KEY_H }, /* 0x48 H */ \
948 {1, HID_KEY_I }, /* 0x49 I */ \
949 {1, HID_KEY_J }, /* 0x4A J */ \
950 {1, HID_KEY_K }, /* 0x4B K */ \
951 {1, HID_KEY_L }, /* 0x4C L */ \
952 {1, HID_KEY_M }, /* 0x4D M */ \
953 {1, HID_KEY_N }, /* 0x4E N */ \
954 {1, HID_KEY_O }, /* 0x4F O */ \
955 {1, HID_KEY_P }, /* 0x50 P */ \
956 {1, HID_KEY_Q }, /* 0x51 Q */ \
957 {1, HID_KEY_R }, /* 0x52 R */ \
958 {1, HID_KEY_S }, /* 0x53 S */ \
959 {1, HID_KEY_T }, /* 0x55 T */ \
960 {1, HID_KEY_U }, /* 0x55 U */ \
961 {1, HID_KEY_V }, /* 0x56 V */ \
962 {1, HID_KEY_W }, /* 0x57 W */ \
963 {1, HID_KEY_X }, /* 0x58 X */ \
964 {1, HID_KEY_Y }, /* 0x59 Y */ \
965 {1, HID_KEY_Z }, /* 0x5A Z */ \
966 {0, HID_KEY_BRACKET_LEFT }, /* 0x5B [ */ \
967 {0, HID_KEY_BACKSLASH }, /* 0x5C '\' */ \
968 {0, HID_KEY_BRACKET_RIGHT }, /* 0x5D ] */ \
969 {1, HID_KEY_6 }, /* 0x5E ^ */ \
970 {1, HID_KEY_MINUS }, /* 0x5F _ */ \
971 \
972 {0, HID_KEY_GRAVE }, /* 0x60 ` */ \
973 {0, HID_KEY_A }, /* 0x61 a */ \
974 {0, HID_KEY_B }, /* 0x62 b */ \
975 {0, HID_KEY_C }, /* 0x63 c */ \
976 {0, HID_KEY_D }, /* 0x66 d */ \
977 {0, HID_KEY_E }, /* 0x65 e */ \
978 {0, HID_KEY_F }, /* 0x66 f */ \
979 {0, HID_KEY_G }, /* 0x67 g */ \
980 {0, HID_KEY_H }, /* 0x68 h */ \
981 {0, HID_KEY_I }, /* 0x69 i */ \
982 {0, HID_KEY_J }, /* 0x6A j */ \
983 {0, HID_KEY_K }, /* 0x6B k */ \
984 {0, HID_KEY_L }, /* 0x6C l */ \
985 {0, HID_KEY_M }, /* 0x6D m */ \
986 {0, HID_KEY_N }, /* 0x6E n */ \
987 {0, HID_KEY_O }, /* 0x6F o */ \
988 {0, HID_KEY_P }, /* 0x70 p */ \
989 {0, HID_KEY_Q }, /* 0x71 q */ \
990 {0, HID_KEY_R }, /* 0x72 r */ \
991 {0, HID_KEY_S }, /* 0x73 s */ \
992 {0, HID_KEY_T }, /* 0x75 t */ \
993 {0, HID_KEY_U }, /* 0x75 u */ \
994 {0, HID_KEY_V }, /* 0x76 v */ \
995 {0, HID_KEY_W }, /* 0x77 w */ \
996 {0, HID_KEY_X }, /* 0x78 x */ \
997 {0, HID_KEY_Y }, /* 0x79 y */ \
998 {0, HID_KEY_Z }, /* 0x7A z */ \
999 {1, HID_KEY_BRACKET_LEFT }, /* 0x7B { */ \
1000 {1, HID_KEY_BACKSLASH }, /* 0x7C | */ \
1001 {1, HID_KEY_BRACKET_RIGHT }, /* 0x7D } */ \
1002 {1, HID_KEY_GRAVE }, /* 0x7E ~ */ \
1003 {0, HID_KEY_DELETE } /* 0x7F Delete */ \
1004
1005/*--------------------------------------------------------------------
1006 * KEYCODE to Ascii Conversion
1007 * Expand to array of [128][2] (ascii without shift, ascii with shift)
1008 *
1009 * Usage: example to convert ascii from keycode (key) and shift modifier (shift).
1010 * Here we assume key < 128 ( printable )
1011 *
1012 * uint8_t const conv_table[128][2] = { HID_KEYCODE_TO_ASCII };
1013 * char ch = shift ? conv_table[chr][1] : conv_table[chr][0];
1014 *
1015 *--------------------------------------------------------------------*/
1016#define HID_KEYCODE_TO_ASCII \
1017 {0 , 0 }, /* 0x00 */ \
1018 {0 , 0 }, /* 0x01 */ \
1019 {0 , 0 }, /* 0x02 */ \
1020 {0 , 0 }, /* 0x03 */ \
1021 {'a' , 'A' }, /* 0x04 */ \
1022 {'b' , 'B' }, /* 0x05 */ \
1023 {'c' , 'C' }, /* 0x06 */ \
1024 {'d' , 'D' }, /* 0x07 */ \
1025 {'e' , 'E' }, /* 0x08 */ \
1026 {'f' , 'F' }, /* 0x09 */ \
1027 {'g' , 'G' }, /* 0x0a */ \
1028 {'h' , 'H' }, /* 0x0b */ \
1029 {'i' , 'I' }, /* 0x0c */ \
1030 {'j' , 'J' }, /* 0x0d */ \
1031 {'k' , 'K' }, /* 0x0e */ \
1032 {'l' , 'L' }, /* 0x0f */ \
1033 {'m' , 'M' }, /* 0x10 */ \
1034 {'n' , 'N' }, /* 0x11 */ \
1035 {'o' , 'O' }, /* 0x12 */ \
1036 {'p' , 'P' }, /* 0x13 */ \
1037 {'q' , 'Q' }, /* 0x14 */ \
1038 {'r' , 'R' }, /* 0x15 */ \
1039 {'s' , 'S' }, /* 0x16 */ \
1040 {'t' , 'T' }, /* 0x17 */ \
1041 {'u' , 'U' }, /* 0x18 */ \
1042 {'v' , 'V' }, /* 0x19 */ \
1043 {'w' , 'W' }, /* 0x1a */ \
1044 {'x' , 'X' }, /* 0x1b */ \
1045 {'y' , 'Y' }, /* 0x1c */ \
1046 {'z' , 'Z' }, /* 0x1d */ \
1047 {'1' , '!' }, /* 0x1e */ \
1048 {'2' , '@' }, /* 0x1f */ \
1049 {'3' , '#' }, /* 0x20 */ \
1050 {'4' , '$' }, /* 0x21 */ \
1051 {'5' , '%' }, /* 0x22 */ \
1052 {'6' , '^' }, /* 0x23 */ \
1053 {'7' , '&' }, /* 0x24 */ \
1054 {'8' , '*' }, /* 0x25 */ \
1055 {'9' , '(' }, /* 0x26 */ \
1056 {'0' , ')' }, /* 0x27 */ \
1057 {'\r' , '\r' }, /* 0x28 */ \
1058 {'\x1b', '\x1b' }, /* 0x29 */ \
1059 {'\b' , '\b' }, /* 0x2a */ \
1060 {'\t' , '\t' }, /* 0x2b */ \
1061 {' ' , ' ' }, /* 0x2c */ \
1062 {'-' , '_' }, /* 0x2d */ \
1063 {'=' , '+' }, /* 0x2e */ \
1064 {'[' , '{' }, /* 0x2f */ \
1065 {']' , '}' }, /* 0x30 */ \
1066 {'\\' , '|' }, /* 0x31 */ \
1067 {'#' , '~' }, /* 0x32 */ \
1068 {';' , ':' }, /* 0x33 */ \
1069 {'\'' , '\"' }, /* 0x34 */ \
1070 {'`' , '~' }, /* 0x35 */ \
1071 {',' , '<' }, /* 0x36 */ \
1072 {'.' , '>' }, /* 0x37 */ \
1073 {'/' , '?' }, /* 0x38 */ \
1074 \
1075 {0 , 0 }, /* 0x39 */ \
1076 {0 , 0 }, /* 0x3a */ \
1077 {0 , 0 }, /* 0x3b */ \
1078 {0 , 0 }, /* 0x3c */ \
1079 {0 , 0 }, /* 0x3d */ \
1080 {0 , 0 }, /* 0x3e */ \
1081 {0 , 0 }, /* 0x3f */ \
1082 {0 , 0 }, /* 0x40 */ \
1083 {0 , 0 }, /* 0x41 */ \
1084 {0 , 0 }, /* 0x42 */ \
1085 {0 , 0 }, /* 0x43 */ \
1086 {0 , 0 }, /* 0x44 */ \
1087 {0 , 0 }, /* 0x45 */ \
1088 {0 , 0 }, /* 0x46 */ \
1089 {0 , 0 }, /* 0x47 */ \
1090 {0 , 0 }, /* 0x48 */ \
1091 {0 , 0 }, /* 0x49 */ \
1092 {0 , 0 }, /* 0x4a */ \
1093 {0 , 0 }, /* 0x4b */ \
1094 {0 , 0 }, /* 0x4c */ \
1095 {0 , 0 }, /* 0x4d */ \
1096 {0 , 0 }, /* 0x4e */ \
1097 {0 , 0 }, /* 0x4f */ \
1098 {0 , 0 }, /* 0x50 */ \
1099 {0 , 0 }, /* 0x51 */ \
1100 {0 , 0 }, /* 0x52 */ \
1101 {0 , 0 }, /* 0x53 */ \
1102 \
1103 {'/' , '/' }, /* 0x54 */ \
1104 {'*' , '*' }, /* 0x55 */ \
1105 {'-' , '-' }, /* 0x56 */ \
1106 {'+' , '+' }, /* 0x57 */ \
1107 {'\r' , '\r' }, /* 0x58 */ \
1108 {'1' , 0 }, /* 0x59 */ \
1109 {'2' , 0 }, /* 0x5a */ \
1110 {'3' , 0 }, /* 0x5b */ \
1111 {'4' , 0 }, /* 0x5c */ \
1112 {'5' , '5' }, /* 0x5d */ \
1113 {'6' , 0 }, /* 0x5e */ \
1114 {'7' , 0 }, /* 0x5f */ \
1115 {'8' , 0 }, /* 0x60 */ \
1116 {'9' , 0 }, /* 0x61 */ \
1117 {'0' , 0 }, /* 0x62 */ \
1118 {'.' , 0 }, /* 0x63 */ \
1119 {0 , 0 }, /* 0x64 */ \
1120 {0 , 0 }, /* 0x65 */ \
1121 {0 , 0 }, /* 0x66 */ \
1122 {'=' , '=' }, /* 0x67 */ \
1123
1124
1125#ifdef __cplusplus
1126 }
1127#endif
1128
1129#endif /* _TUSB_HID_H__ */
1130
uint8_t bDescriptorType
Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
Definition audio.h:657
uint8_t bLength
Size of this descriptor in bytes: 9.
Definition audio.h:656
struct TU_ATTR_PACKED tusb_hid_descriptor_hid_t
USB HID Descriptor.
hid_request_enum_t
HID Class Specific Control Request.
Definition hid.h:94
hid_subclass_enum_t
HID Subclass.
Definition hid.h:62
hid_interface_protocol_enum_t
HID Interface Protocol.
Definition hid.h:69
hid_descriptor_enum_t
HID Descriptor Type.
Definition hid.h:77
hid_report_type_t
HID Request Report Type.
Definition hid.h:85
hid_local_enum_t
HID Local Code.
Definition hid.h:105
@ HID_REQ_CONTROL_GET_PROTOCOL
Get Protocol.
Definition hid.h:97
@ HID_REQ_CONTROL_SET_REPORT
Set Report.
Definition hid.h:98
@ HID_REQ_CONTROL_GET_REPORT
Get Report.
Definition hid.h:95
@ HID_REQ_CONTROL_SET_PROTOCOL
Set Protocol.
Definition hid.h:100
@ HID_REQ_CONTROL_SET_IDLE
Set Idle.
Definition hid.h:99
@ HID_REQ_CONTROL_GET_IDLE
Get Idle.
Definition hid.h:96
@ HID_SUBCLASS_BOOT
Boot Interface Subclass.
Definition hid.h:64
@ HID_SUBCLASS_NONE
No Subclass.
Definition hid.h:63
@ HID_ITF_PROTOCOL_KEYBOARD
Keyboard.
Definition hid.h:71
@ HID_ITF_PROTOCOL_MOUSE
Mouse.
Definition hid.h:72
@ HID_ITF_PROTOCOL_NONE
None.
Definition hid.h:70
@ HID_DESC_TYPE_PHYSICAL
Physical Descriptor.
Definition hid.h:80
@ HID_DESC_TYPE_REPORT
Report Descriptor.
Definition hid.h:79
@ HID_DESC_TYPE_HID
HID Descriptor.
Definition hid.h:78
@ HID_REPORT_TYPE_INPUT
Input.
Definition hid.h:87
@ HID_REPORT_TYPE_OUTPUT
Output.
Definition hid.h:88
@ HID_REPORT_TYPE_FEATURE
Feature.
Definition hid.h:89
@ HID_LOCAL_Switzerland
Switzerland.
Definition hid.h:135
@ HID_LOCAL_Swiss_German
Swiss/German.
Definition hid.h:134
@ HID_LOCAL_Czech_Republic
Czech_Republic.
Definition hid.h:111
@ HID_LOCAL_Danish
Danish.
Definition hid.h:112
@ HID_LOCAL_Persian_Farsi
Persian (Farsi)
Definition hid.h:126
@ HID_LOCAL_Latin_American
Latin_American.
Definition hid.h:123
@ HID_LOCAL_Korean
Korean.
Definition hid.h:122
@ HID_LOCAL_Taiwan
Taiwan.
Definition hid.h:136
@ HID_LOCAL_Turkish_Q
Turkish-Q.
Definition hid.h:137
@ HID_LOCAL_Netherlands_Dutch
Netherlands/Dutch.
Definition hid.h:124
@ HID_LOCAL_Belgian
Belgian.
Definition hid.h:108
@ HID_LOCAL_Canadian_Bilingual
Canadian_Bilingual.
Definition hid.h:109
@ HID_LOCAL_Portuguese
Portuguese.
Definition hid.h:128
@ HID_LOCAL_Arabic
Arabic.
Definition hid.h:107
@ HID_LOCAL_Slovakia
Slovakia.
Definition hid.h:130
@ HID_LOCAL_Spanish
Spanish.
Definition hid.h:131
@ HID_LOCAL_Greek
Greek.
Definition hid.h:116
@ HID_LOCAL_Russia
Russia.
Definition hid.h:129
@ HID_LOCAL_Turkish_F
Turkish-F.
Definition hid.h:141
@ HID_LOCAL_NotSupported
NotSupported.
Definition hid.h:106
@ HID_LOCAL_Hungary
Hungary.
Definition hid.h:118
@ HID_LOCAL_Swedish
Swedish.
Definition hid.h:132
@ HID_LOCAL_Yugoslavia
Yugoslavia.
Definition hid.h:140
@ HID_LOCAL_International
International.
Definition hid.h:119
@ HID_LOCAL_Hebrew
Hebrew.
Definition hid.h:117
@ HID_LOCAL_Finnish
Finnish.
Definition hid.h:113
@ HID_LOCAL_Canadian_French
Canadian_French.
Definition hid.h:110
@ HID_LOCAL_Swiss_French
Swiss/French.
Definition hid.h:133
@ HID_LOCAL_US
US.
Definition hid.h:139
@ HID_LOCAL_UK
UK.
Definition hid.h:138
@ HID_LOCAL_Italian
Italian.
Definition hid.h:120
@ HID_LOCAL_French
French.
Definition hid.h:114
@ HID_LOCAL_German
German.
Definition hid.h:115
@ HID_LOCAL_Japan_Katakana
Japan_Katakana.
Definition hid.h:121
@ HID_LOCAL_Norwegian
Norwegian.
Definition hid.h:125
@ HID_LOCAL_Poland
Poland.
Definition hid.h:127
hid_gamepad_button_bm_t
Standard Gamepad Buttons Bitmap.
Definition hid.h:209
struct TU_ATTR_PACKED hid_gamepad_report_t
HID Gamepad Protocol Report.
hid_gamepad_hat_t
Standard Gamepad HAT/DPAD Buttons (from Linux input event codes)
Definition hid.h:273
@ GAMEPAD_HAT_UP
DPAD_UP.
Definition hid.h:275
@ GAMEPAD_HAT_DOWN_LEFT
DPAD_DOWN_LEFT.
Definition hid.h:280
@ GAMEPAD_HAT_DOWN_RIGHT
DPAD_DOWN_RIGHT.
Definition hid.h:278
@ GAMEPAD_HAT_LEFT
DPAD_LEFT.
Definition hid.h:281
@ GAMEPAD_HAT_RIGHT
DPAD_RIGHT.
Definition hid.h:277
@ GAMEPAD_HAT_DOWN
DPAD_DOWN.
Definition hid.h:279
@ GAMEPAD_HAT_UP_RIGHT
DPAD_UP_RIGHT.
Definition hid.h:276
@ GAMEPAD_HAT_CENTERED
DPAD_CENTERED.
Definition hid.h:274
@ GAMEPAD_HAT_UP_LEFT
DPAD_UP_LEFT.
Definition hid.h:282
hid_keyboard_modifier_bm_t
Keyboard modifier codes bitmap.
Definition hid.h:331
hid_keyboard_led_bm_t
Definition hid.h:343
struct TU_ATTR_PACKED hid_keyboard_report_t
Standard HID Boot Protocol Keyboard Report.
@ KEYBOARD_MODIFIER_RIGHTALT
Right Alt.
Definition hid.h:338
@ KEYBOARD_MODIFIER_RIGHTGUI
Right Window.
Definition hid.h:339
@ KEYBOARD_MODIFIER_RIGHTCTRL
Right Control.
Definition hid.h:336
@ KEYBOARD_MODIFIER_LEFTGUI
Left Window.
Definition hid.h:335
@ KEYBOARD_MODIFIER_LEFTCTRL
Left Control.
Definition hid.h:332
@ KEYBOARD_MODIFIER_RIGHTSHIFT
Right Shift.
Definition hid.h:337
@ KEYBOARD_MODIFIER_LEFTALT
Left Alt.
Definition hid.h:334
@ KEYBOARD_MODIFIER_LEFTSHIFT
Left Shift.
Definition hid.h:333
@ KEYBOARD_LED_CAPSLOCK
Caps Lock LED.
Definition hid.h:345
@ KEYBOARD_LED_KANA
Kana mode.
Definition hid.h:348
@ KEYBOARD_LED_SCROLLLOCK
Scroll Lock LED.
Definition hid.h:346
@ KEYBOARD_LED_COMPOSE
Composition Mode.
Definition hid.h:347
@ KEYBOARD_LED_NUMLOCK
Num Lock LED.
Definition hid.h:344
hid_mouse_button_bm_t
Standard Mouse Buttons Bitmap.
Definition hid.h:305
struct TU_ATTR_PACKED hid_mouse_report_t
Standard HID Boot Protocol Mouse Report.
@ MOUSE_BUTTON_FORWARD
Forward button,.
Definition hid.h:310
@ MOUSE_BUTTON_BACKWARD
Backward button,.
Definition hid.h:309
@ MOUSE_BUTTON_LEFT
Left button.
Definition hid.h:306
@ MOUSE_BUTTON_RIGHT
Right button.
Definition hid.h:307
@ MOUSE_BUTTON_MIDDLE
Middle button.
Definition hid.h:308
AUDIO Channel Cluster Descriptor (4.1)
Definition audio.h:647
int8_t rx
Delta Rx movement of analog left trigger.
Definition hid.h:201
uint16_t wReportLength
Definition hid.h:57
uint8_t buttons
Definition hid.h:296
uint16_t bcdHID
Definition hid.h:52
uint32_t buttons
Buttons mask for currently pressed buttons.
Definition hid.h:204
uint8_t keycode[6]
Definition hid.h:326
int8_t z
Delta z movement of right analog-joystick.
Definition hid.h:199
int8_t wheel
Definition hid.h:299
int8_t x
Delta x movement of left analog-stick.
Definition hid.h:197
uint8_t bReportType
Definition hid.h:56
uint8_t modifier
Definition hid.h:324
uint8_t bNumDescriptors
Definition hid.h:54
int8_t y
Delta y movement of left analog-stick.
Definition hid.h:198
int8_t rz
Delta Rz movement of right analog-joystick.
Definition hid.h:200
uint8_t bCountryCode
Definition hid.h:53
uint8_t reserved
Definition hid.h:325
int8_t ry
Delta Ry movement of analog right trigger.
Definition hid.h:202
uint8_t hat
Buttons mask for currently pressed buttons in the DPad/hat.
Definition hid.h:203