17#if !defined(__USBHID_H__)
23#define MAX_REPORT_PARSERS 2
24#define HID_MAX_HID_CLASS_DESCRIPTORS 5
26#define DATA_SIZE_MASK 0x03
30#define DATA_SIZE_0 0x00
31#define DATA_SIZE_1 0x01
32#define DATA_SIZE_2 0x02
33#define DATA_SIZE_4 0x03
36#define TYPE_GLOBAL 0x04
37#define TYPE_LOCAL 0x08
39#define TAG_MAIN_INPUT 0x80
40#define TAG_MAIN_OUTPUT 0x90
41#define TAG_MAIN_COLLECTION 0xA0
42#define TAG_MAIN_FEATURE 0xB0
43#define TAG_MAIN_ENDCOLLECTION 0xC0
45#define TAG_GLOBAL_USAGEPAGE 0x00
46#define TAG_GLOBAL_LOGICALMIN 0x10
47#define TAG_GLOBAL_LOGICALMAX 0x20
48#define TAG_GLOBAL_PHYSMIN 0x30
49#define TAG_GLOBAL_PHYSMAX 0x40
50#define TAG_GLOBAL_UNITEXP 0x50
51#define TAG_GLOBAL_UNIT 0x60
52#define TAG_GLOBAL_REPORTSIZE 0x70
53#define TAG_GLOBAL_REPORTID 0x80
54#define TAG_GLOBAL_REPORTCOUNT 0x90
55#define TAG_GLOBAL_PUSH 0xA0
56#define TAG_GLOBAL_POP 0xB0
58#define TAG_LOCAL_USAGE 0x00
59#define TAG_LOCAL_USAGEMIN 0x10
60#define TAG_LOCAL_USAGEMAX 0x20
63#define bmREQ_HID_OUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
64#define bmREQ_HID_IN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
65#define bmREQ_HID_REPORT USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_INTERFACE
69#define HID_REQUEST_GET_REPORT 0x01
70#define HID_REQUEST_GET_IDLE 0x02
71#define HID_REQUEST_GET_PROTOCOL 0x03
72#define HID_REQUEST_SET_REPORT 0x09
73#define HID_REQUEST_SET_IDLE 0x0A
74#define HID_REQUEST_SET_PROTOCOL 0x0B
77#define HID_DESCRIPTOR_HID 0x21
78#define HID_DESCRIPTOR_REPORT 0x22
79#define HID_DESRIPTOR_PHY 0x23
82#define USB_HID_BOOT_PROTOCOL 0x00
83#define HID_RPT_PROTOCOL 0x01
89#define HID_BOOT_INTF_SUBCLASS 0x01
92#define USB_HID_PROTOCOL_NONE 0x00
93#define USB_HID_PROTOCOL_KEYBOARD 0x01
94#define USB_HID_PROTOCOL_MOUSE 0x02
96#define HID_ITEM_TYPE_MAIN 0
97#define HID_ITEM_TYPE_GLOBAL 1
98#define HID_ITEM_TYPE_LOCAL 2
99#define HID_ITEM_TYPE_RESERVED 3
101#define HID_LONG_ITEM_PREFIX 0xfe
103#define bmHID_MAIN_ITEM_TAG 0xfc
105#define bmHID_MAIN_ITEM_INPUT 0x80
106#define bmHID_MAIN_ITEM_OUTPUT 0x90
107#define bmHID_MAIN_ITEM_FEATURE 0xb0
108#define bmHID_MAIN_ITEM_COLLECTION 0xa0
109#define bmHID_MAIN_ITEM_END_COLLECTION 0xce
111#define HID_MAIN_ITEM_COLLECTION_PHYSICAL 0
112#define HID_MAIN_ITEM_COLLECTION_APPLICATION 1
113#define HID_MAIN_ITEM_COLLECTION_LOGICAL 2
114#define HID_MAIN_ITEM_COLLECTION_REPORT 3
115#define HID_MAIN_ITEM_COLLECTION_NAMED_ARRAY 4
116#define HID_MAIN_ITEM_COLLECTION_USAGE_SWITCH 5
117#define HID_MAIN_ITEM_COLLECTION_USAGE_MODIFIER 6
virtual void Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)=0
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR *ep_ptr)
uint8_t SetProtocol(uint8_t iface, uint8_t protocol)
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs)
static const uint8_t totalEndpoints
uint8_t GetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t *dataptr)
uint8_t GetIdle(uint8_t iface, uint8_t reportID, uint8_t *dataptr)
uint8_t SetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t *dataptr)
uint8_t GetReportDescr(uint16_t wIndex, USBReadParser *parser=NULL)
static const uint8_t maxHidInterfaces
static const uint8_t epInterruptInIndex
static const uint8_t maxEpPerInterface
uint8_t GetProtocol(uint8_t iface, uint8_t *dataptr)
void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc)
virtual HIDReportParser * GetReportParser(uint8_t id)
uint8_t SetIdle(uint8_t iface, uint8_t reportID, uint8_t duration)
uint8_t GetHidDescr(uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
static const uint8_t epInterruptOutIndex
uint8_t bmIsConstantOrData
uint8_t bmIsVolatileOrNonVolatile
uint8_t bmIsNonLonearOrLinear
uint8_t bmIsArrayOrVariable
uint8_t bmIsRelativeOrAbsolute
uint8_t bmIsNoPreferedOrPrefered