1 #ifndef USB_HID_H 2 #define USB_HID_H 3 4 // (Partial) USB Class Definitions for HID Devices, version 1.11 5 // Reference: http://www.usb.org/developers/devclass_docs/hid1_11.pdf 6 7 #define USB_HID_DEVICE_CLASS 0x03 8 #define USB_HID_CLASS_VERSION 0x0100 9 10 enum { // HID Interface Subclasses 11 USB_HID_INTERFACE_NO_SUBCLASS = 0x00, // No Subclass 12 USB_HID_INTERFACE_BOOT_SUBCLASS // Boot Interface Subclass 13 }; 14 15 enum { // HID Class-Specific descriptor subtypes 16 USB_HID_DESCRIPTOR_HID = 0x21, 17 USB_HID_DESCRIPTOR_REPORT, 18 USB_HID_DESCRIPTOR_PHYSICAL 19 }; 20 21 enum { // HID Class-specific requests 22 USB_REQUEST_HID_GET_REPORT = 0x01, 23 USB_REQUEST_HID_GET_IDLE, 24 USB_REQUEST_HID_GET_PROTOCOL, 25 26 USB_REQUEST_HID_SET_REPORT = 0x09, 27 USB_REQUEST_HID_SET_IDLE, 28 USB_REQUEST_HID_SET_PROTOCOL 29 }; 30 31 typedef struct { 32 uint8 length; 33 uint8 descriptor_type; 34 uint16 hid_version; 35 uint8 country_code; 36 uint8 num_descriptors; 37 struct { 38 uint8 descriptor_type; 39 uint16 descriptor_length; 40 } _PACKED descriptor_info [1]; 41 } _PACKED usb_hid_descriptor; 42 43 44 /* 45 Usage Pages/IDs 46 */ 47 48 enum { 49 USAGE_PAGE_GENERIC_DESKTOP = 0x1, 50 USAGE_PAGE_SIMULATION, 51 USAGE_PAGE_VR, 52 USAGE_PAGE_SPORT, 53 USAGE_PAGE_GAME, 54 USAGE_PAGE_GENERIC, 55 USAGE_PAGE_KEYBOARD, 56 USAGE_PAGE_LED, 57 USAGE_PAGE_BUTTON, 58 USAGE_PAGE_ORDINAL, 59 USAGE_PAGE_TELEPHONY, 60 USAGE_PAGE_CONSUMER, 61 USAGE_PAGE_DIGITIZER, 62 USAGE_PAGE_PID = 0xf, 63 USAGE_PAGE_UNICODE, 64 USAGE_PAGE_ALPHANUM_DISPLAY = 0x14, 65 USAGE_PAGE_MEDICAL = 0x40, 66 USAGE_PAGE_MICROSOFT = 0xff00 67 }; 68 69 /* Page 1: Generic Desktop */ 70 71 enum { 72 USAGE_ID_POINTER = 0x1, 73 USAGE_ID_MOUSE, 74 USAGE_ID_JOYSTICK = 0x4, 75 USAGE_ID_GAMEPAD, 76 USAGE_ID_KEYBOARD, 77 USAGE_ID_KEYPAD, 78 USAGE_ID_MULTIAXIS = 0x8, 79 80 USAGE_ID_X = 0x30, 81 USAGE_ID_Y, 82 USAGE_ID_Z, 83 USAGE_ID_RX, 84 USAGE_ID_RY, 85 USAGE_ID_RZ, 86 USAGE_ID_SLIDER, 87 USAGE_ID_DIAL, 88 USAGE_ID_WHEEL, 89 USAGE_ID_HAT_SWITCH, 90 USAGE_ID_COUNTED_BUFFER, 91 USAGE_ID_BYTE_COUNT, 92 USAGE_ID_MOTION_WAKEUP, 93 USAGE_ID_START, 94 USAGE_ID_SELECT, 95 USAGE_ID_VX = 0x40, 96 USAGE_ID_VY, 97 USAGE_ID_VZ, 98 USAGE_ID_VBRX, 99 USAGE_ID_VBRY, 100 USAGE_ID_VBRZ, 101 USAGE_ID_VNO, 102 USAGE_ID_FEATURE_NOTIFICATION 103 }; 104 105 /* Page 2: Simulation */ 106 107 enum { 108 USAGE_ID_RUDDER = 0xBA, 109 USAGE_ID_THROTTLE = 0xBB, 110 }; 111 112 #endif // USB_HID_H 113