1 /* 2 * Copyright (c) 2022, sakumisu 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #ifndef USB_HID_H 7 #define USB_HID_H 8 9 /* Subclass codes (HID 4.2) */ 10 #define HID_SUBCLASS_NONE 0 /* No subclass */ 11 #define HID_SUBCLASS_BOOTIF 1 /* Boot Interface Subclass */ 12 13 /* HID Protocol Codes (HID 4.3) */ 14 #define HID_PROTOCOL_NONE 0x00 15 #define HID_PROTOCOL_BOOT 0x00 16 #define HID_PROTOCOL_KEYBOARD 0x01 17 #define HID_PROTOCOL_REPORT 0x01 18 #define HID_PROTOCOL_MOUSE 0x02 19 20 /* HID Class Descriptor Types (HID 7.1) */ 21 #define HID_DESCRIPTOR_TYPE_HID 0x21 22 #define HID_DESCRIPTOR_TYPE_HID_REPORT 0x22 23 #define HID_DESCRIPTOR_TYPE_HID_PHYSICAL 0x23 24 25 /* HID Class Specific Requests (HID 7.2) */ 26 #define HID_REQUEST_GET_REPORT 0x01 27 #define HID_REQUEST_GET_IDLE 0x02 28 #define HID_REQUEST_GET_PROTOCOL 0x03 29 #define HID_REQUEST_SET_REPORT 0x09 30 #define HID_REQUEST_SET_IDLE 0x0A 31 #define HID_REQUEST_SET_PROTOCOL 0x0B 32 33 /* Report Type (MS byte of wValue for GET_REPORT) (HID 7.2.1) */ 34 #define HID_REPORT_INPUT 0x01 35 #define HID_REPORT_OUTPUT 0x02 36 #define HID_REPORT_FEATURE 0x03 37 38 /* HID Descriptor ***********************************************************/ 39 40 #define HID_COUNTRY_NONE 0x00 /* Not Supported */ 41 #define HID_COUNTRY_ARABIC 0x01 /* Arabic */ 42 #define HID_COUNTRY_BELGIAN 0x02 /* Belgian */ 43 #define HID_COUNTRY_CANADA 0x03 /* Canadian-Bilingual */ 44 #define HID_COUNTRY_CANADRFR 0x04 /* Canadian-French */ 45 #define HID_COUNTRY_CZECH 0x05 /* Czech Republic */ 46 #define HID_COUNTRY_DANISH 0x06 /* Danish */ 47 #define HID_COUNTRY_FINNISH 0x07 /* Finnish */ 48 #define HID_COUNTRY_FRENCH 0x08 /* French */ 49 #define HID_COUNTRY_GERMAN 0x09 /* German */ 50 #define HID_COUNTRY_GREEK 0x10 /* Greek */ 51 #define HID_COUNTRY_HEBREW 0x11 /* Hebrew */ 52 #define HID_COUNTRY_HUNGARY 0x12 /* Hungary */ 53 #define HID_COUNTRY_ISO 0x13 /* International (ISO) */ 54 #define HID_COUNTRY_ITALIAN 0x14 /* Italian */ 55 #define HID_COUNTRY_JAPAN 0x15 /* Japan (Katakana) */ 56 #define HID_COUNTRY_KOREAN 0x16 /* Korean */ 57 #define HID_COUNTRY_LATINAM 0x17 /* Latin American */ 58 #define HID_COUNTRY_DUTCH 0x18 /* Netherlands/Dutch */ 59 #define HID_COUNTRY_NORWEGIAN 0x19 /* Norwegian */ 60 #define HID_COUNTRY_PERSIAN 0x20 /* Persian (Farsi) */ 61 #define HID_COUNTRY_POLAND 0x21 /* Poland */ 62 #define HID_COUNTRY_PORTUGUESE 0x22 /* Portuguese */ 63 #define HID_COUNTRY_RUSSIA 0x23 /* Russia */ 64 #define HID_COUNTRY_SLOVAKIA 0x24 /* Slovakia */ 65 #define HID_COUNTRY_SPANISH 0x25 /* Spanish */ 66 #define HID_COUNTRY_SWEDISH 0x26 /* Swedish */ 67 #define HID_COUNTRY_SWISSFR 0x27 /* Swiss/French */ 68 #define HID_COUNTRY_SWISSGR 0x28 /* Swiss/German */ 69 #define HID_COUNTRY_SWITZERLAND 0x29 /* Switzerland */ 70 #define HID_COUNTRY_TAIWAN 0x30 /* Taiwan */ 71 #define HID_COUNTRY_TURKISHQ 0x31 /* Turkish-Q */ 72 #define HID_COUNTRY_UK 0x32 /* UK */ 73 #define HID_COUNTRY_US 0x33 /* US */ 74 #define HID_COUNTRY_YUGOSLAVIA 0x34 /* Yugoslavia */ 75 #define HID_COUNTRY_TURKISHF 0x35 /* Turkish-F */ 76 77 /* HID report items */ 78 #define HID_REPORT_ITEM_SIZE_MASK 0x03 79 #define HID_REPORT_ITEM_SIZE_0 0x00 /* No data follows */ 80 #define HID_REPORT_ITEM_SIZE_1 0x01 /* 1 byte of data follows */ 81 #define HID_REPORT_ITEM_SIZE_2 0x02 /* 2 bytes of data follow */ 82 #define HID_REPORT_ITEM_SIZE_4 0x03 /* 4 bytes of data follow */ 83 #define HID_REPORT_ITEM_TYPE_MASK 0x0c 84 #define HID_REPORT_ITEM_TYPE_MAIN 0x00 85 #define HID_REPORT_ITEM_TYPE_GLOBAL 0x04 86 #define HID_REPORT_ITEM_TYPE_LOCAL 0x08 87 #define HID_REPORT_ITEM_TAG_MASK 0xf0 88 89 /* Main Items (HID 6.2.2.4) */ 90 #define HID_MAIN_ITEM_CONSTANT (1 << 0) /* Constant(1) vs Data(0) */ 91 #define HID_MAIN_ITEM_VARIABLE (1 << 1) /* Variable(1) vs Array(0) */ 92 #define HID_MAIN_ITEM_RELATIVE (1 << 2) /* Relative(1) vs Absolute(0) */ 93 #define HID_MAIN_ITEM_WRAP (1 << 3) /* Wrap(1) vs No Wrap(0) */ 94 #define HID_MAIN_ITEM_NONLINEAR (1 << 4) /* Non Linear(1) vs Linear(0) */ 95 #define HID_MAIN_ITEM_NOPREFERRED (1 << 5) /* No Preferred (1) vs Preferred State(0) */ 96 #define HID_MAIN_ITEM_NULLSTATE (1 << 6) /* Null state(1) vs No Null position(0) */ 97 #define HID_MAIN_ITEM_VOLATILE (1 << 7) /* Volatile(1) vs Non volatile(0) */ 98 #define HID_MAIN_ITEM_BUFFEREDBYTES (1 << 8) /* Buffered Bytes(1) vs Bit Field(0) */ 99 100 #define HID_MAIN_ITEM_SIZE(pfx) ((pfx)&HID_REPORT_ITEM_SIZE_MASK) 101 #define HID_MAIN_ITEM_INPUT_PREFIX 0x80 102 #define HID_MAIN_ITEM_INPUT_CONSTANT HID_MAIN_ITEM_CONSTANT 103 #define HID_MAIN_ITEM_INPUT_VARIABLE HID_MAIN_ITEM_VARIABLE 104 #define HID_MAIN_ITEM_INPUT_RELATIVE HID_MAIN_ITEM_RELATIVE 105 #define HID_MAIN_ITEM_INPUT_WRAP HID_MAIN_ITEM_WRAP 106 #define HID_MAIN_ITEM_INPUT_NONLINEAR HID_MAIN_ITEM_NONLINEAR 107 #define HID_MAIN_ITEM_INPUT_NOPREFERRED HID_MAIN_ITEM_NOPREFERRED 108 #define HID_MAIN_ITEM_INPUT_NULLSTATE HID_MAIN_ITEM_NULLSTATE 109 #define HID_MAIN_ITEM_INPUT_BUFFEREDBYTES HID_MAIN_ITEM_BUFFEREDBYTES 110 111 #define HID_MAIN_ITEM_OUTPUT_PREFIX 0x90 112 #define HID_MAIN_ITEM_OUTPUT_CONSTANT HID_MAIN_ITEM_CONSTANT 113 #define HID_MAIN_ITEM_OUTPUT_VARIABLE HID_MAIN_ITEM_VARIABLE 114 #define HID_MAIN_ITEM_OUTPUT_RELATIVE HID_MAIN_ITEM_RELATIVE 115 #define HID_MAIN_ITEM_OUTPUT_WRAP HID_MAIN_ITEM_WRAP 116 #define HID_MAIN_ITEM_OUTPUT_NONLINEAR HID_MAIN_ITEM_NONLINEAR 117 #define HID_MAIN_ITEM_OUTPUT_NOPREFERRED HID_MAIN_ITEM_NOPREFERRED 118 #define HID_MAIN_ITEM_OUTPUT_NULLSTATE HID_MAIN_ITEM_NULLSTATE 119 #define HID_MAIN_ITEM_OUTPUT_VOLATILE HID_MAIN_ITEM_VOLATILE 120 #define HID_MAIN_ITEM_OUTPUT_BUFFEREDBYTES HID_MAIN_ITEM_BUFFEREDBYTES 121 122 #define HID_MAIN_ITEM_FEATURE_PREFIX 0xb0 123 #define HID_MAIN_ITEM_FEATURE_CONSTANT HID_MAIN_ITEM_CONSTANT 124 #define HID_MAIN_ITEM_FEATURE_VARIABLE HID_MAIN_ITEM_VARIABLE 125 #define HID_MAIN_ITEM_FEATURE_RELATIVE HID_MAIN_ITEM_RELATIVE 126 #define HID_MAIN_ITEM_FEATURE_WRAP HID_MAIN_ITEM_WRAP 127 #define HID_MAIN_ITEM_FEATURE_NONLINEAR HID_MAIN_ITEM_NONLINEAR 128 #define HID_MAIN_ITEM_FEATURE_NOPREFERRED HID_MAIN_ITEM_NOPREFERRED 129 #define HID_MAIN_ITEM_FEATURE_NULLSTATE HID_MAIN_ITEM_NULLSTATE 130 #define HID_MAIN_ITEM_FEATURE_VOLATILE HID_MAIN_ITEM_VOLATILE 131 #define HID_MAIN_ITEM_FEATURE_BUFFEREDBYTES HID_MAIN_ITEM_BUFFEREDBYTES 132 133 #define HID_MAIN_ITEM_COLLECTION_PREFIX 0xa0 134 #define HID_MAIN_ITEM_COLLECTION_PHYSICAL 0x00 /* Physical (group of axes) */ 135 #define HID_MAIN_ITEM_COLLECTION_APPL 0x01 /* Application (mouse, keyboard) */ 136 #define HID_MAIN_ITEM_COLLECTION_LOGICAL 0x02 /* Logical (interrelated data) */ 137 #define HID_MAIN_ITEM_COLLECTION_REPORT 0x03 /* Report */ 138 #define HID_MAIN_ITEM_COLLECTION_ARRAY 0x04 /* Named Array */ 139 #define HID_MAIN_ITEM_COLLECTION_SWITCH 0x05 /* Usage Switch */ 140 #define HID_MAIN_ITEM_COLLECTION_MODIFIER 0x06 /* Usage Modifier */ 141 #define HID_MAIN_ITEM_ENDCOLLECTION_PREFIX 0xc0 142 143 /* Global Items (HID 6.2.2.7) */ 144 #define HID_GLOBAL_ITEM_SIZE(pfx) ((pfx)&HID_REPORT_ITEM_SIZE_MASK) 145 #define HID_GLOBAL_ITEM_USAGEPAGE_PREFIX 0x04 /* Usage Page */ 146 #define HID_GLOBAL_ITEM_LOGICALMIN_PREFIX 0x14 /* Logical Minimum */ 147 #define HID_GLOBAL_ITEM_LOGICALMAX_PREFIX 0x24 /* Logical Maximum */ 148 #define HID_GLOBAL_ITEM_PHYSICALMIN_PREFIX 0x34 /* Physical Minimum */ 149 #define HID_GLOBAL_ITEM_PHYSMICALAX_PREFIX 0x44 /* Physical Maximum */ 150 #define HID_GLOBAL_ITEM_UNITEXP_PREFIX 0x54 /* Unit Exponent */ 151 #define HID_GLOBAL_ITEM_UNIT_PREFIX 0x64 /* Unit */ 152 #define HID_GLOBAL_ITEM_REPORTSIZE_PREFIX 0x74 /* Report Size */ 153 #define HID_GLOBAL_ITEM_REPORTID_PREFIX 0x84 /* Report ID */ 154 #define HID_GLOBAL_ITEM_REPORTCOUNT_PREFIX 0x94 /* Report Count */ 155 #define HID_GLOBAL_ITEM_PUSH_PREFIX 0xa4 /* Push */ 156 #define HID_GLOBAL_ITEM_POP_PREFIX 0xb4 /* Pop */ 157 158 /* Local Items (HID 6.2.2.8) */ 159 #define HID_LOCAL_ITEM_SIZE(pfx) ((pfx)&HID_REPORT_ITEM_SIZE_MASK) 160 #define HID_LOCAL_ITEM_USAGE_PREFIX 0x08 /* Usage */ 161 #define HID_LOCAL_ITEM_USAGEMIN_PREFIX 0x18 /* Usage Minimum */ 162 #define HID_LOCAL_ITEM_USAGEMAX_PREFIX 0x28 /* Usage Maximum */ 163 #define HID_LOCAL_ITEM_DESIGNATORIDX_PREFIX 0x38 /* Designator Index */ 164 #define HID_LOCAL_ITEM_DESIGNATORMIN_PREFIX 0x48 /* Designator Minimum */ 165 #define HID_LOCAL_ITEM_DESIGNATORMAX_PREFIX 0x58 /* Designator Maximum */ 166 #define HID_LOCAL_ITEM_STRINGIDX_PREFIX 0x78 /* String Index */ 167 #define HID_LOCAL_ITEM_STRINGMIN_PREFIX 0x88 /* String Minimum */ 168 #define HID_LOCAL_ITEM_STRINGMAX_PREFIX 0x98 /* xx */ 169 #define HID_LOCAL_ITEM_DELIMITER_PREFIX 0xa8 /* Delimiter */ 170 171 /* Modifier Keys (HID 8.3) */ 172 #define HID_MODIFIER_LCTRL (1 << 0) /* Left Ctrl */ 173 #define HID_MODIFIER_LSHIFT (1 << 1) /* Left Shift */ 174 #define HID_MODIFIER_LALT (1 << 2) /* Left Alt */ 175 #define HID_MODIFIER_LGUI (1 << 3) /* Left GUI */ 176 #define HID_MODIFIER_RCTRL (1 << 4) /* Right Ctrl */ 177 #define HID_MODIFIER_RSHIFT (1 << 5) /* Right Shift */ 178 #define HID_MODIFIER_RALT (1 << 6) /* Right Alt */ 179 #define HID_MODIFIER_RGUI (1 << 7) /* Right GUI */ 180 181 /* Keyboard output report (1 byte) (HID B.1) */ 182 #define HID_KBD_OUTPUT_REPORT_NUMLOCK (1 << 0) 183 #define HID_KBD_OUTPUT_REPORT_CAPSLOCK (1 << 1) 184 #define HID_KBD_OUTPUT_REPORT_SCROLLLOCK (1 << 2) 185 #define HID_KBD_OUTPUT_REPORT_COMPOSE (1 << 3) 186 #define HID_KBD_OUTPUT_REPORT_KANA (1 << 4) 187 188 /* Mouse input report (HID B.2) */ 189 #define HID_MOUSE_INPUT_REPORT_BUTTON1 (1 << 0) 190 #define HID_MOUSE_INPUT_REPORT_BUTTON2 (1 << 1) 191 #define HID_MOUSE_INPUT_REPORT_BUTTON3 (1 << 2) 192 #define HID_MOUSE_INPUT_REPORT_BUTTON_MASK (7) 193 194 #define HID_MOUSE_INPUT_BUTTON_LEFT (1 << 0) 195 #define HID_MOUSE_INPUT_BUTTON_RIGHT (1 << 1) 196 #define HID_MOUSE_INPUT_BUTTON_MIDDLE (1 << 2) 197 #define HID_MOUSE_INPUT_BUTTON_BACKWARD (1 << 3) 198 #define HID_MOUSE_INPUT_BUTTON_FORWARD (1 << 4) 199 200 /* Joystick input report (4 bytes) (HID D.1) */ 201 #define HID_JS_INPUT_REPORT_HATSWITCH_SHIFT (0) 202 #define HID_JS_INPUT_REPORT_HATSWITCH_MASK (15 << HID_JSIN_HATSWITCH_SHIFT) 203 #define HID_JS_INPUT_REPORT_BUTTON1 (1 << 4) 204 #define HID_JS_INPUT_REPORT_BUTTON2 (1 << 5) 205 #define HID_JS_INPUT_REPORT_BUTTON3 (1 << 6) 206 #define HID_JS_INPUT_REPORT_BUTTON4 (1 << 7) 207 208 /* Usage pages (HuT 3) */ 209 #define HID_USAGE_PAGE_UNDEFINED 0x00 /* Undefined */ 210 #define HID_USAGE_PAGE_GENERIC_DCTRL 0x01 /* Generic Desktop Controls */ 211 #define HID_USAGE_PAGE_SIMCTRL 0x02 /* Simulation Controls */ 212 #define HID_USAGE_PAGE_VRCTRL 0x03 /* VR Controls */ 213 #define HID_USAGE_PAGE_SPORTCTRL 0x04 /* Sport Controls */ 214 #define HID_USAGE_PAGE_GAMECTRL 0x05 /* Game Controls */ 215 #define HID_USAGE_PAGE_GENERIC_DEVCTRL 0x06 /* Generic Device Controls */ 216 #define HID_USAGE_PAGE_KBD 0x07 /* Keyboard/Keypad */ 217 #define HID_USAGE_PAGE_LEDS 0x08 /* LEDs */ 218 #define HID_USAGE_PAGE_BUTTON 0x09 /* Button */ 219 #define HID_USAGE_PAGE_ORDINAL 0x0a /* Ordinal */ 220 #define HID_USAGE_PAGE_TELEPHONY 0x0b /* Telephony */ 221 #define HID_USAGE_PAGE_CONSUMER 0x0c /* Consumer */ 222 #define HID_USAGE_PAGE_DIGITIZER 0x0d /* Digitizer */ 223 /* 0x0e Reserved */ 224 #define HID_USAGE_PAGE_PIDPAGE 0x0f /* PID Page Physical Interface Device */ 225 #define HID_USAGE_PAGE_UNICODE 0x10 /* Unicode */ 226 /* 0x11-13 Reserved */ 227 #define HID_USAGE_PAGE_ALPHA_DISPLAY 0x14 /* Alphanumeric Display */ 228 /* 0x15-3f Reserved */ 229 #define HID_USAGE_PAGE_MEDICAL 0x40 /* Medical Instruments */ 230 /* 0x41-7f Reserved */ 231 /* 0x80-83 Monitor Devices */ 232 /* 0x84-87 Power Devices */ 233 /* 0x88-8b Reserved */ 234 #define HID_USAGE_PAGE_BARCODE_SCANNER 0x8c /* Bar Code Scanner page */ 235 #define HID_USAGE_PAGE_SCALE 0x8d /* Scale page */ 236 #define HID_USAGE_PAGE_MSR 0x8e /* Magnetic Stripe Reading (MSR) Devices */ 237 #define HID_USAGE_PAGE_POS 0x8f /* Point of Sale devices */ 238 #define HID_USAGE_PAGE_CAMERA_CTRL 0x90 /* Camera Control Page */ 239 240 /* Generic Desktop Page Usage IDs (HuT 4) */ 241 #define HID_DESKTOP_USAGE_UNDEFINED 0x00 /* Undefined */ 242 #define HID_DESKTOP_USAGE_POINTER 0x01 /* Pointer */ 243 #define HID_DESKTOP_USAGE_MOUSE 0x02 /* Mouse */ 244 /* 0x03 Reserved */ 245 #define HID_DESKTOP_USAGE_JOYSTICK 0x04 /* Joystick */ 246 #define HID_DESKTOP_USAGE_GAMEPAD 0x05 /* Game Pad */ 247 #define HID_DESKTOP_USAGE_KEYBOARD 0x06 /* Keyboard */ 248 #define HID_DESKTOP_USAGE_KEYPAD 0x07 /* Keypad */ 249 #define HID_DESKTOP_USAGE_MULTIAXIS 0x08 /* Multi-axis Controller */ 250 #define HID_DESKTOP_USAGE_TABLET 0x09 /* Tablet PC System Controls */ 251 /* 0x0a-2f Reserved */ 252 #define HID_DESKTOP_USAGE_X 0x30 /* X */ 253 #define HID_DESKTOP_USAGE_Y 0x31 /* Y */ 254 #define HID_DESKTOP_USAGE_Z 0x32 /* Z */ 255 #define HID_DESKTOP_USAGE_RX 0x33 /* Rx */ 256 #define HID_DESKTOP_USAGE_RY 0x34 /* Ry */ 257 #define HID_DESKTOP_USAGE_RZ 0x35 /* Rz */ 258 #define HID_DESKTOP_USAGE_SLIDER 0x36 /* Slider */ 259 #define HID_DESKTOP_USAGE_DIAL 0x37 /* Dial */ 260 #define HID_DESKTOP_USAGE_WHEEL 0x38 /* Wheel */ 261 #define HID_DESKTOP_USAGE_HATSWITCH 0x39 /* Hat switch */ 262 #define HID_DESKTOP_USAGE_COUNTED 0x3a /* Counted Buffer */ 263 #define HID_DESKTOP_USAGE_BYTECOUNT 0x3b /* Byte Count */ 264 #define HID_DESKTOP_USAGE_MOTION 0x3c /* Motion Wakeup */ 265 #define HID_DESKTOP_USAGE_START 0x3d /* Start */ 266 #define HID_DESKTOP_USAGE_SELECT 0x3e /* Select */ 267 /* 0x3f Reserved */ 268 #define HID_DESKTOP_USAGE_VX 0x40 /* Vx */ 269 #define HID_DESKTOP_USAGE_VY 0x41 /* Vy */ 270 #define HID_DESKTOP_USAGE_VZ 0x42 /* Vz */ 271 #define HID_DESKTOP_USAGE_VBRX 0x43 /* Vbrx */ 272 #define HID_DESKTOP_USAGE_VBRY 0x44 /* Vbry */ 273 #define HID_DESKTOP_USAGE_VBRZ 0x45 /* Vbrz */ 274 #define HID_DESKTOP_USAGE_VNO 0x46 /* Vno */ 275 #define HID_DESKTOP_USAGE_FEATURE 0x47 /* Feature Notification */ 276 #define HID_DESKTOP_USAGE_RESOLUTION 0x48 /* Resolution Multiplier */ 277 /* 0x49-7f Reserved */ 278 #define HID_DESKTOP_USAGE_CONTROL 0x80 /* System Control */ 279 #define HID_DESKTOP_USAGE_POWERDOWN 0x81 /* System Power Down */ 280 #define HID_DESKTOP_USAGE_SLEEP 0x82 /* System Sleep */ 281 #define HID_DESKTOP_USAGE_WAKEUP 0x83 /* System Wake Up */ 282 #define HID_DESKTOP_USAGE_CONTEXT_MENU 0x84 /* System Context Menu */ 283 #define HID_DESKTOP_USAGE_MAIN_MENU 0x85 /* System Main Menu */ 284 #define HID_DESKTOP_USAGE_APP_MENU 0x86 /* System App Menu */ 285 #define HID_DESKTOP_USAGE_MENU_HELP 0x87 /* System Menu Help */ 286 #define HID_DESKTOP_USAGE_MENU_EXIT 0x88 /* System Menu Exit */ 287 #define HID_DESKTOP_USAGE_MENU_SELECT 0x89 /* System Menu Select */ 288 #define HID_DESKTOP_USAGE_MENU_RIGHT 0x8a /* System Menu Right */ 289 #define HID_DESKTOP_USAGE_MENU_LEFT 0x8b /* System Menu Left */ 290 #define HID_DESKTOP_USAGE_MENU_UP 0x8c /* System Menu Up */ 291 #define HID_DESKTOP_USAGE_MENU_DOWN 0x8d /* System Menu Down */ 292 #define HID_DESKTOP_USAGE_COLD_RESTART 0x8e /* System Cold Restart */ 293 #define HID_DESKTOP_USAGE_WARM_RESTART 0x8f /* System Warm Restart */ 294 #define HID_DESKTOP_USAGE_DPAD_UP 0x90 /* D-pad Up */ 295 #define HID_DESKTOP_USAGE_DPAD_DOWN 0x91 /* D-pad Down */ 296 #define HID_DESKTOP_USAGE_DPAD_RIGHT 0x92 /* D-pad Right */ 297 #define HID_DESKTOP_USAGE_DPAD_LEFT 0x93 /* D-pad Left */ 298 /* 0x94-9f Reserved */ 299 #define HID_DESKTOP_USAGE_DOCK 0xa0 /* System Dock */ 300 #define HID_DESKTOP_USAGE_UNDOCK 0xa1 /* System Undock */ 301 #define HID_DESKTOP_USAGE_SETUP 0xa2 /* System Setup */ 302 #define HID_DESKTOP_USAGE_BREAK 0xa3 /* System Break */ 303 #define HID_DESKTOP_USAGE_DEBUG_BREAK 0xa4 /* System Debugger Break */ 304 #define HID_DESKTOP_USAGE_APP_BREAK 0xa5 /* Application Break */ 305 #define HID_DESKTOP_USAGE_APP_DEBUG_BREAK 0xa6 /* Application Debugger Break */ 306 #define HID_DESKTOP_USAGE_MUTE 0xa7 /* System Speaker Mute */ 307 #define HID_DESKTOP_USAGE_HIBERNATE 0xa8 /* System Hibernate */ 308 /* 0xa9-af Reserved */ 309 #define HID_DESKTOP_USAGE_DISPLAY_INVERT 0xb0 /* System Display Invert */ 310 #define HID_DESKTOP_USAGE_DISPALY_INTERNAL 0xb1 /* System Display Internal */ 311 #define HID_DESKTOP_USAGE_DISPLAY_EXTERNAL 0xb2 /* System Display External */ 312 #define HID_DESKTOP_USAGE_DISPLAY_BOTH 0xb3 /* System Display Both */ 313 #define HID_DESKTOP_USAGE_DISPLAY_DUAL 0xb4 /* System Display Dual */ 314 #define HID_DESKTOP_USAGE_DISPLAY_TOGGLE 0xb5 /* System Display Toggle Int/Ext */ 315 #define HID_DESKTOP_USAGE_DISPLAY_SWAP 0xb6 /* System Display Swap */ 316 #define HID_DESKTOP_USAGE_ 0xb7 /* System Display LCD Autoscale */ 317 /* 0xb8-ffff Reserved */ 318 319 /* Keyboard usage IDs (HuT 10) */ 320 #define HID_KBD_USAGE_NONE 0x00 /* Reserved (no event indicated) */ 321 #define HID_KBD_USAGE_ERRORROLLOVER 0x01 /* Keyboard ErrorRollOver */ 322 #define HID_KBD_USAGE_POSTFAIL 0x02 /* Keyboard POSTFail */ 323 #define HID_KBD_USAGE_ERRUNDEF 0x03 /* Keyboard ErrorUndefined */ 324 #define HID_KBD_USAGE_A 0x04 /* Keyboard a or A (B-Z follow) */ 325 #define HID_KBD_USAGE_1 0x1e /* Keyboard 1 (2-9 follow) */ 326 #define HID_KBD_USAGE_EXCLAM 0x1e /* Keyboard 1 and ! */ 327 #define HID_KBD_USAGE_AT 0x1f /* Keyboard 2 and @ */ 328 #define HID_KBD_USAGE_POUND 0x20 /* Keyboard 3 and # */ 329 #define HID_KBD_USAGE_DOLLAR 0x21 /* Keyboard 4 and $ */ 330 #define HID_KBD_USAGE_PERCENT 0x22 /* Keyboard 5 and % */ 331 #define HID_KBD_USAGE_CARAT 0x23 /* Keyboard 6 and ^ */ 332 #define HID_KBD_USAGE_AMPERSAND 0x24 /* Keyboard 7 and & */ 333 #define HID_KBD_USAGE_ASTERISK 0x25 /* Keyboard 8 and * */ 334 #define HID_KBD_USAGE_LPAREN 0x26 /* Keyboard 9 and ( */ 335 #define HID_KBD_USAGE_0 0x27 /* Keyboard 0 and ) */ 336 #define HID_KBD_USAGE_RPAREN 0x27 /* Keyboard 0 and ) */ 337 #define HID_KBD_USAGE_ENTER 0x28 /* Keyboard Return (ENTER) */ 338 #define HID_KBD_USAGE_ESCAPE 0x29 /* Keyboard ESCAPE */ 339 #define HID_KBD_USAGE_DELETE 0x2a /* Keyboard DELETE (Backspace) */ 340 #define HID_KBD_USAGE_TAB 0x2b /* Keyboard Tab */ 341 #define HID_KBD_USAGE_SPACE 0x2c /* Keyboard Spacebar */ 342 #define HID_KBD_USAGE_HYPHEN 0x2d /* Keyboard - and (underscore) */ 343 #define HID_KBD_USAGE_UNDERSCORE 0x2d /* Keyboard - and (underscore) */ 344 #define HID_KBD_USAGE_EQUAL 0x2e /* Keyboard = and + */ 345 #define HID_KBD_USAGE_PLUS 0x2e /* Keyboard = and + */ 346 #define HID_KBD_USAGE_LBRACKET 0x2f /* Keyboard [ and { */ 347 #define HID_KBD_USAGE_LBRACE 0x2f /* Keyboard [ and { */ 348 #define HID_KBD_USAGE_RBRACKET 0x30 /* Keyboard ] and } */ 349 #define HID_KBD_USAGE_RBRACE 0x30 /* Keyboard ] and } */ 350 #define HID_KBD_USAGE_BSLASH 0x31 /* Keyboard \ and | */ 351 #define HID_KBD_USAGE_VERTBAR 0x31 /* Keyboard \ and | */ 352 #define HID_KBD_USAGE_NONUSPOUND 0x32 /* Keyboard Non-US # and ~ */ 353 #define HID_KBD_USAGE_TILDE 0x32 /* Keyboard Non-US # and ~ */ 354 #define HID_KBD_USAGE_SEMICOLON 0x33 /* Keyboard ; and : */ 355 #define HID_KBD_USAGE_COLON 0x33 /* Keyboard ; and : */ 356 #define HID_KBD_USAGE_SQUOTE 0x34 /* Keyboard ' and " */ 357 #define HID_KBD_USAGE_DQUOUTE 0x34 /* Keyboard ' and " */ 358 #define HID_KBD_USAGE_GACCENT 0x35 /* Keyboard Grave Accent and Tilde */ 359 #define HID_KBD_USAGE_GTILDE 0x35 /* Keyboard Grave Accent and Tilde */ 360 #define HID_KBD_USAGE_COMMON 0x36 /* Keyboard , and < */ 361 #define HID_KBD_USAGE_LT 0x36 /* Keyboard , and < */ 362 #define HID_KBD_USAGE_PERIOD 0x37 /* Keyboard . and > */ 363 #define HID_KBD_USAGE_GT 0x37 /* Keyboard . and > */ 364 #define HID_KBD_USAGE_DIV 0x38 /* Keyboard / and ? */ 365 #define HID_KBD_USAGE_QUESTION 0x38 /* Keyboard / and ? */ 366 #define HID_KBD_USAGE_CAPSLOCK 0x39 /* Keyboard Caps Lock */ 367 #define HID_KBD_USAGE_F1 0x3a /* Keyboard F1 */ 368 #define HID_KBD_USAGE_F2 0x3b /* Keyboard F2 */ 369 #define HID_KBD_USAGE_F3 0x3c /* Keyboard F3 */ 370 #define HID_KBD_USAGE_F4 0x3d /* Keyboard F4 */ 371 #define HID_KBD_USAGE_F5 0x3e /* Keyboard F5 */ 372 #define HID_KBD_USAGE_F6 0x3f /* Keyboard F6 */ 373 #define HID_KBD_USAGE_F7 0x40 /* Keyboard F7 */ 374 #define HID_KBD_USAGE_F8 0x41 /* Keyboard F8 */ 375 #define HID_KBD_USAGE_F9 0x42 /* Keyboard F9 */ 376 #define HID_KBD_USAGE_F10 0x43 /* Keyboard F10 */ 377 #define HID_KBD_USAGE_F11 0x44 /* Keyboard F11 */ 378 #define HID_KBD_USAGE_F12 0x45 /* Keyboard F12 */ 379 #define HID_KBD_USAGE_PRINTSCN 0x46 /* Keyboard PrintScreen */ 380 #define HID_KBD_USAGE_SCROLLLOCK 0x47 /* Keyboard Scroll Lock */ 381 #define HID_KBD_USAGE_PAUSE 0x48 /* Keyboard Pause */ 382 #define HID_KBD_USAGE_INSERT 0x49 /* Keyboard Insert */ 383 #define HID_KBD_USAGE_HOME 0x4a /* Keyboard Home */ 384 #define HID_KBD_USAGE_PAGEUP 0x4b /* Keyboard PageUp */ 385 #define HID_KBD_USAGE_DELFWD 0x4c /* Keyboard Delete Forward */ 386 #define HID_KBD_USAGE_END 0x4d /* Keyboard End */ 387 #define HID_KBD_USAGE_PAGEDOWN 0x4e /* Keyboard PageDown */ 388 #define HID_KBD_USAGE_RIGHT 0x4f /* eyboard RightArrow */ 389 #define HID_KBD_USAGE_LEFT 0x50 /* Keyboard LeftArrow */ 390 #define HID_KBD_USAGE_DOWN 0x51 /* Keyboard DownArrow */ 391 #define HID_KBD_USAGE_UP 0x52 /* Keyboard UpArrow */ 392 #define HID_KBD_USAGE_KPDNUMLOCK 0x53 /* Keypad Num Lock and Clear */ 393 #define HID_KBD_USAGE_KPDNUMLOCKCLEAR 0x53 /* Keypad Num Lock and Clear */ 394 #define HID_KBD_USAGE_KPDDIV 0x54 /* Keypad / */ 395 #define HID_KBD_USAGE_KPDMUL 0x55 /* Keypad * */ 396 #define HID_KBD_USAGE_KPDHMINUS 0x56 /* Keypad - */ 397 #define HID_KBD_USAGE_KPDPLUS 0x57 /* Keypad + */ 398 #define HID_KBD_USAGE_KPDEMTER 0x58 /* Keypad ENTER */ 399 #define HID_KBD_USAGE_KPD1 0x59 /* Keypad 1 (2-9 follow) */ 400 #define HID_KBD_USAGE_KPDEND 0x59 /* Keypad 1 and End */ 401 #define HID_KBD_USAGE_KPDDOWN 0x5a /* Keypad 2 and Down Arrow */ 402 #define HID_KBD_USAGE_KPDPAGEDN 0x5b /* Keypad 3 and PageDn */ 403 #define HID_KBD_USAGE_KPDLEFT 0x5c /* Keypad 4 and Left Arrow */ 404 #define HID_KBD_USAGE_KPDRIGHT 0x5e /* Keypad 6 and Right Arrow */ 405 #define HID_KBD_USAGE_KPDHOME 0x5f /* Keypad 7 and Home */ 406 #define HID_KBD_USAGE_KPDUP 0x60 /* Keypad 8 and Up Arrow */ 407 #define HID_KBD_USAGE_KPDPAGEUP 0x61 /* Keypad 9 and PageUp */ 408 #define HID_KBD_USAGE_KPD0 0x62 /* Keypad 0 and Insert */ 409 #define HID_KBD_USAGE_KPDINSERT 0x62 /* Keypad 0 and Insert */ 410 #define HID_KBD_USAGE_KPDDECIMALPT 0x63 /* Keypad . and Delete */ 411 #define HID_KBD_USAGE_KPDDELETE 0x63 /* Keypad . and Delete */ 412 #define HID_KBD_USAGE_NONSLASH 0x64 /* Keyboard Non-US \ and | */ 413 #define HID_KBD_USAGE_NONUSVERT 0x64 /* Keyboard Non-US \ and | */ 414 #define HID_KBD_USAGE_APPLICATION 0x65 /* Keyboard Application */ 415 #define HID_KBD_USAGE_POWER 0x66 /* Keyboard Power */ 416 #define HID_KBD_USAGE_KPDEQUAL 0x67 /* Keypad = */ 417 #define HID_KBD_USAGE_F13 0x68 /* Keyboard F13 */ 418 #define HID_KBD_USAGE_F14 0x69 /* Keyboard F14 */ 419 #define HID_KBD_USAGE_F15 0x6a /* Keyboard F15 */ 420 #define HID_KBD_USAGE_F16 0x6b /* Keyboard F16 */ 421 #define HID_KBD_USAGE_F17 0x6c /* Keyboard F17 */ 422 #define HID_KBD_USAGE_F18 0x6d /* Keyboard F18 */ 423 #define HID_KBD_USAGE_F19 0x6e /* Keyboard F19 */ 424 #define HID_KBD_USAGE_F20 0x6f /* Keyboard F20 */ 425 #define HID_KBD_USAGE_F21 0x70 /* Keyboard F21 */ 426 #define HID_KBD_USAGE_F22 0x71 /* Keyboard F22 */ 427 #define HID_KBD_USAGE_F23 0x72 /* Keyboard F23 */ 428 #define HID_KBD_USAGE_F24 0x73 /* Keyboard F24 */ 429 #define HID_KBD_USAGE_EXECUTE 0x74 /* Keyboard Execute */ 430 #define HID_KBD_USAGE_HELP 0x75 /* Keyboard Help */ 431 #define HID_KBD_USAGE_MENU 0x76 /* Keyboard Menu */ 432 #define HID_KBD_USAGE_SELECT 0x77 /* Keyboard Select */ 433 #define HID_KBD_USAGE_STOP 0x78 /* Keyboard Stop */ 434 #define HID_KBD_USAGE_AGAIN 0x79 /* Keyboard Again */ 435 #define HID_KBD_USAGE_UNDO 0x7a /* Keyboard Undo */ 436 #define HID_KBD_USAGE_CUT 0x7b /* Keyboard Cut */ 437 #define HID_KBD_USAGE_COPY 0x7c /* Keyboard Copy */ 438 #define HID_KBD_USAGE_PASTE 0x7d /* Keyboard Paste */ 439 #define HID_KBD_USAGE_FIND 0x7e /* Keyboard Find */ 440 #define HID_KBD_USAGE_MUTE 0x7f /* Keyboard Mute */ 441 #define HID_KBD_USAGE_VOLUP 0x80 /* Keyboard Volume Up */ 442 #define HID_KBD_USAGE_VOLDOWN 0x81 /* Keyboard Volume Down */ 443 #define HID_KBD_USAGE_LCAPSLOCK 0x82 /* Keyboard Locking Caps Lock */ 444 #define HID_KBD_USAGE_LNUMLOCK 0x83 /* Keyboard Locking Num Lock */ 445 #define HID_KBD_USAGE_LSCROLLLOCK 0x84 /* Keyboard Locking Scroll Lock */ 446 #define HID_KBD_USAGE_KPDCOMMA 0x85 /* Keypad Comma */ 447 #define HID_KBD_USAGE_KPDEQUALSIGN 0x86 /* Keypad Equal Sign */ 448 #define HID_KBD_USAGE_INTERNATIONAL1 0x87 /* Keyboard International 1 */ 449 #define HID_KBD_USAGE_INTERNATIONAL2 0x88 /* Keyboard International 2 */ 450 #define HID_KBD_USAGE_INTERNATIONAL3 0x89 /* Keyboard International 3 */ 451 #define HID_KBD_USAGE_INTERNATIONAL4 0x8a /* Keyboard International 4 */ 452 #define HID_KBD_USAGE_INTERNATIONAL5 0x8b /* Keyboard International 5 */ 453 #define HID_KBD_USAGE_INTERNATIONAL6 0x8c /* Keyboard International 6 */ 454 #define HID_KBD_USAGE_INTERNATIONAL7 0x8d /* Keyboard International 7 */ 455 #define HID_KBD_USAGE_INTERNATIONAL8 0x8e /* Keyboard International 8 */ 456 #define HID_KBD_USAGE_INTERNATIONAL9 0x8f /* Keyboard International 9 */ 457 #define HID_KBD_USAGE_LANG1 0x90 /* Keyboard LANG1 */ 458 #define HID_KBD_USAGE_LANG2 0x91 /* Keyboard LANG2 */ 459 #define HID_KBD_USAGE_LANG3 0x92 /* Keyboard LANG3 */ 460 #define HID_KBD_USAGE_LANG4 0x93 /* Keyboard LANG4 */ 461 #define HID_KBD_USAGE_LANG5 0x94 /* Keyboard LANG5 */ 462 #define HID_KBD_USAGE_LANG6 0x95 /* Keyboard LANG6 */ 463 #define HID_KBD_USAGE_LANG7 0x96 /* Keyboard LANG7 */ 464 #define HID_KBD_USAGE_LANG8 0x97 /* Keyboard LANG8 */ 465 #define HID_KBD_USAGE_LANG9 0x98 /* Keyboard LANG9 */ 466 #define HID_KBD_USAGE_ALTERASE 0x99 /* Keyboard Alternate Erase */ 467 #define HID_KBD_USAGE_SYSREQ 0x9a /* Keyboard SysReq/Attention */ 468 #define HID_KBD_USAGE_CANCEL 0x9b /* Keyboard Cancel */ 469 #define HID_KBD_USAGE_CLEAR 0x9c /* Keyboard Clear */ 470 #define HID_KBD_USAGE_PRIOR 0x9d /* Keyboard Prior */ 471 #define HID_KBD_USAGE_RETURN 0x9e /* Keyboard Return */ 472 #define HID_KBD_USAGE_SEPARATOR 0x9f /* Keyboard Separator */ 473 #define HID_KBD_USAGE_OUT 0xa0 /* Keyboard Out */ 474 #define HID_KBD_USAGE_OPER 0xa1 /* Keyboard Oper */ 475 #define HID_KBD_USAGE_CLEARAGAIN 0xa2 /* Keyboard Clear/Again */ 476 #define HID_KBD_USAGE_CLRSEL 0xa3 /* Keyboard CrSel/Props */ 477 #define HID_KBD_USAGE_EXSEL 0xa4 /* Keyboard ExSel */ 478 #define HID_KBD_USAGE_KPD00 0xb0 /* Keypad 00 */ 479 #define HID_KBD_USAGE_KPD000 0xb1 /* Keypad 000 */ 480 #define HID_KBD_USAGE_THOUSEPARATOR 0xb2 /* Thousands Separator */ 481 #define HID_KBD_USAGE_DECSEPARATOR 0xb3 /* Decimal Separator */ 482 #define HID_KBD_USAGE_CURRUNIT 0xb4 /* Currency Unit */ 483 #define HID_KBD_USAGE_CURRSUBUNIT 0xb5 /* Currency Sub-unit */ 484 #define HID_KBD_USAGE_KPDLPAREN 0xb6 /* Keypad ( */ 485 #define HID_KBD_USAGE_KPDRPAREN 0xb7 /* Keypad ) */ 486 #define HID_KBD_USAGE_KPDLBRACE 0xb8 /* Keypad { */ 487 #define HID_KBD_USAGE_KPDRBRACE 0xb9 /* Keypad } */ 488 #define HID_KBD_USAGE_KPDTAB 0xba /* Keypad Tab */ 489 #define HID_KBD_USAGE_KPDBACKSPACE 0xbb /* Keypad Backspace */ 490 #define HID_KBD_USAGE_KPDA 0xbc /* Keypad A (B-F follow) */ 491 #define HID_KBD_USAGE_KPDXOR 0xc2 /* Keypad XOR */ 492 #define HID_KBD_USAGE_KPDEXP 0xc3 /* Keypad ^ */ 493 #define HID_KBD_USAGE_KPDPERCENT 0xc4 /* Keypad % */ 494 #define HID_KBD_USAGE_KPDLT 0xc5 /* Keypad < */ 495 #define HID_KBD_USAGE_KPDGT 0xc6 /* Keypad > */ 496 #define HID_KBD_USAGE_KPDAMPERSAND 0xc7 /* Keypad & */ 497 #define HID_KBD_USAGE_KPDAND 0xc8 /* Keypad && */ 498 #define HID_KBD_USAGE_KPDVERT 0xc9 /* Keypad | */ 499 #define HID_KBD_USAGE_KPDOR 0xca /* Keypad || */ 500 #define HID_KBD_USAGE_KPDCOLON 0xcb /* Keypad : */ 501 #define HID_KBD_USAGE_KPDPOUND 0xcc /* Keypad # */ 502 #define HID_KBD_USAGE_KPDSPACE 0xcd /* Keypad Space */ 503 #define HID_KBD_USAGE_KPDAT 0xce /* Keypad @ */ 504 #define HID_KBD_USAGE_KPDEXCLAM 0xcf /* Keypad ! */ 505 #define HID_KBD_USAGE_KPDMEMSTORE 0xd0 /* Keypad Memory Store */ 506 #define HID_KBD_USAGE_KPDMEMRECALL 0xd1 /* Keypad Memory Recall */ 507 #define HID_KBD_USAGE_KPDMEMCLEAR 0xd2 /* Keypad Memory Clear */ 508 #define HID_KBD_USAGE_KPDMEMADD 0xd3 /* Keypad Memory Add */ 509 #define HID_KBD_USAGE_KPDMEMSUB 0xd4 /* Keypad Memory Subtract */ 510 #define HID_KBD_USAGE_KPDMEMMULT 0xd5 /* Keypad Memory Multiply */ 511 #define HID_KBD_USAGE_KPDMEMDIV 0xd6 /* Keypad Memory Divide */ 512 #define HID_KBD_USAGE_KPDPLUSMINUS 0xd7 /* Keypad +/- */ 513 #define HID_KBD_USAGE_KPDCLEAR 0xd8 /* Keypad Clear */ 514 #define HID_KBD_USAGE_KPDCLEARENTRY 0xd9 /* Keypad Clear Entry */ 515 #define HID_KBD_USAGE_KPDBINARY 0xda /* Keypad Binary */ 516 #define HID_KBD_USAGE_KPDOCTAL 0xdb /* Keypad Octal */ 517 #define HID_KBD_USAGE_KPDDECIMAL 0xdc /* Keypad Decimal */ 518 #define HID_KBD_USAGE_KPDHEXADECIMAL 0xdd /* Keypad Hexadecimal */ 519 #define HID_KBD_USAGE_LCTRL 0xe0 /* Keyboard LeftControl */ 520 #define HID_KBD_USAGE_LSHIFT 0xe1 /* Keyboard LeftShift */ 521 #define HID_KBD_USAGE_LALT 0xe2 /* Keyboard LeftAlt */ 522 #define HID_KBD_USAGE_LGUI 0xe3 /* Keyboard Left GUI */ 523 #define HID_KBD_USAGE_RCTRL 0xe4 /* Keyboard RightControl */ 524 #define HID_KBD_USAGE_RSHIFT 0xe5 /* Keyboard RightShift */ 525 #define HID_KBD_USAGE_RALT 0xe6 /* Keyboard RightAlt */ 526 #define HID_KBD_USAGE_RGUI 0xe7 /* Keyboard Right GUI */ 527 528 #define HID_KBD_USAGE_MAX 0xe7 529 530 /* HID Report Definitions */ 531 struct usb_hid_class_subdescriptor { 532 uint8_t bDescriptorType; /* Class descriptor type (See 7.1) */ 533 uint16_t wDescriptorLength; /* Size of the report descriptor */ 534 } __PACKED; 535 536 struct usb_hid_descriptor { 537 uint8_t bLength; /* Size of the HID descriptor */ 538 uint8_t bDescriptorType; /* HID descriptor type */ 539 uint16_t bcdHID; /* HID class specification release */ 540 uint8_t bCountryCode; /* Country code */ 541 uint8_t bNumDescriptors; /* Number of descriptors (>=1) */ 542 543 /* 544 * Specification says at least one Class Descriptor needs to 545 * be present (Report Descriptor). 546 */ 547 struct usb_hid_class_subdescriptor subdesc[1]; 548 } __PACKED; 549 550 /* Standard Reports *********************************************************/ 551 552 /* Keyboard input report (8 bytes) (HID B.1) */ 553 struct usb_hid_kbd_report { 554 uint8_t modifier; /* Modifier keys. See HID_MODIFER_* definitions */ 555 uint8_t reserved; 556 uint8_t key[6]; /* Keycode 1-6 */ 557 }; 558 559 /* Keyboard output report (1 byte) (HID B.1), 560 * see HID_KBD_OUTPUT_* definitions 561 */ 562 563 /* Mouse input report (HID B.2) */ 564 struct usb_hid_mouse_report { 565 uint8_t buttons; /* See HID_MOUSE_INPUT_BUTTON_* definitions */ 566 int8_t xdisp; /* X displacement */ 567 int8_t ydisp; /* y displacement */ 568 /* Device specific additional bytes may follow */ 569 uint8_t wdisp; /* Wheel displacement */ 570 }; 571 572 /* Joystick input report (1 bytes) (HID D.1) */ 573 struct usb_hid_js_report { 574 int8_t xpos; /* X position */ 575 int8_t ypos; /* X position */ 576 uint8_t buttons; /* See USBHID_JSIN_* definitions */ 577 uint8_t throttle; /* Throttle */ 578 }; 579 580 // clang-format off 581 #define HID_MOUSE_DESCRIPTOR_LEN (9 + 9 + 7) 582 583 #define HID_MOUSE_DESCRIPTOR_INIT(bInterfaceNumber, bInterfaceSubClass, wItemLength, int_ep, wMaxPacketSize, bInterval) \ 584 0x09, /* bLength: Interface Descriptor size */ \ 585 USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType: Interface descriptor type */ \ 586 bInterfaceNumber, /* bInterfaceNumber: Number of Interface */ \ 587 0x00, /* bAlternateSetting: Alternate setting */ \ 588 0x01, /* bNumEndpoints */ \ 589 0x03, /* bInterfaceClass: HID */ \ 590 bInterfaceSubClass, /* bInterfaceSubClass : 1=BOOT, 0=no boot */ \ 591 0x02, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */ \ 592 0x00, /* iInterface: Index of string descriptor */ \ 593 0x09, /* bLength: HID Descriptor size */ \ 594 HID_DESCRIPTOR_TYPE_HID, /* bDescriptorType: HID */ \ 595 0x11, /* bcdHID: HID Class Spec release number */ \ 596 0x01, \ 597 0x00, /* bCountryCode: Hardware target country */ \ 598 0x01, /* bNumDescriptors: Number of HID class descriptors to follow */ \ 599 0x22, /* bDescriptorType */ \ 600 WBVAL(wItemLength), /* wItemLength: Total length of Report descriptor */ \ 601 0x07, /* bLength: Endpoint Descriptor size */ \ 602 USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType: */ \ 603 int_ep, /* bEndpointAddress: Endpoint Address (IN) */ \ 604 0x03, /* bmAttributes: Interrupt endpoint */ \ 605 WBVAL(wMaxPacketSize), /* wMaxPacketSize: x Byte max */ \ 606 bInterval /* bInterval: Polling Interval */ 607 608 #define HID_KEYBOARD_DESCRIPTOR_LEN (9 + 9 + 7) 609 610 #define HID_KEYBOARD_DESCRIPTOR_INIT(bInterfaceNumber, bInterfaceSubClass, wItemLength, int_ep, wMaxPacketSize, bInterval) \ 611 0x09, /* bLength: Interface Descriptor size */ \ 612 USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType: Interface descriptor type */ \ 613 bInterfaceNumber, /* bInterfaceNumber: Number of Interface */ \ 614 0x00, /* bAlternateSetting: Alternate setting */ \ 615 0x01, /* bNumEndpoints */ \ 616 0x03, /* bInterfaceClass: HID */ \ 617 bInterfaceSubClass, /* bInterfaceSubClass : 1=BOOT, 0=no boot */ \ 618 0x01, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */ \ 619 0x00, /* iInterface: Index of string descriptor */ \ 620 0x09, /* bLength: HID Descriptor size */ \ 621 HID_DESCRIPTOR_TYPE_HID, /* bDescriptorType: HID */ \ 622 0x11, /* bcdHID: HID Class Spec release number */ \ 623 0x01, \ 624 0x00, /* bCountryCode: Hardware target country */ \ 625 0x01, /* bNumDescriptors: Number of HID class descriptors to follow */ \ 626 0x22, /* bDescriptorType */ \ 627 WBVAL(wItemLength), /* wItemLength: Total length of Report descriptor */ \ 628 0x07, /* bLength: Endpoint Descriptor size */ \ 629 USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType: */ \ 630 int_ep, /* bEndpointAddress: Endpoint Address (IN) */ \ 631 0x03, /* bmAttributes: Interrupt endpoint */ \ 632 WBVAL(wMaxPacketSize), /* wMaxPacketSize: x Byte max */ \ 633 bInterval /* bInterval: Polling Interval */ 634 635 #define HID_CUSTOM_INOUT_DESCRIPTOR_LEN (9 + 9 + 7 + 7) 636 637 #define HID_CUSTOM_INOUT_DESCRIPTOR_INIT(bInterfaceNumber, bInterfaceSubClass, wItemLength, in_ep, out_ep,wMaxPacketSize, bInterval) \ 638 0x09, /* bLength: Interface Descriptor size */ \ 639 USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType: Interface descriptor type */ \ 640 bInterfaceNumber, /* bInterfaceNumber: Number of Interface */ \ 641 0x00, /* bAlternateSetting: Alternate setting */ \ 642 0x02, /* bNumEndpoints */ \ 643 0x03, /* bInterfaceClass: HID */ \ 644 bInterfaceSubClass, /* bInterfaceSubClass : 1=BOOT, 0=no boot */ \ 645 0x00, /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */ \ 646 0x00, /* iInterface: Index of string descriptor */ \ 647 0x09, /* bLength: HID Descriptor size */ \ 648 HID_DESCRIPTOR_TYPE_HID, /* bDescriptorType: HID */ \ 649 0x11, /* bcdHID: HID Class Spec release number */ \ 650 0x01, \ 651 0x00, /* bCountryCode: Hardware target country */ \ 652 0x01, /* bNumDescriptors: Number of HID class descriptors to follow */ \ 653 0x22, /* bDescriptorType */ \ 654 WBVAL(wItemLength), /* wItemLength: Total length of Report descriptor */ \ 655 0x07, /* bLength: Endpoint Descriptor size */ \ 656 USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType: */ \ 657 in_ep, /* bEndpointAddress: Endpoint Address (IN) */ \ 658 0x03, /* bmAttributes: Interrupt endpoint */ \ 659 WBVAL(wMaxPacketSize), /* wMaxPacketSize: x Byte max */ \ 660 bInterval, /* bInterval: Polling Interval */ \ 661 0x07, /* bLength: Endpoint Descriptor size */ \ 662 USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType: */ \ 663 out_ep, /* bEndpointAddress: Endpoint Address (IN) */ \ 664 0x03, /* bmAttributes: Interrupt endpoint */ \ 665 WBVAL(wMaxPacketSize), /* wMaxPacketSize: x Byte max */ \ 666 bInterval /* bInterval: Polling Interval */ 667 // clang-format on 668 669 #endif /* USB_HID_H */ 670