17 #if !defined(__HID_H__)
21 #include <avr/pgmspace.h>
28 #if defined(ARDUINO) && ARDUINO >=100
41 #define DATA_SIZE_MASK 0x03
42 #define TYPE_MASK 0x0C
45 #define DATA_SIZE_0 0x00
46 #define DATA_SIZE_1 0x01
47 #define DATA_SIZE_2 0x02
48 #define DATA_SIZE_4 0x03
50 #define TYPE_MAIN 0x00
51 #define TYPE_GLOBAL 0x04
52 #define TYPE_LOCAL 0x08
54 #define TAG_MAIN_INPUT 0x80
55 #define TAG_MAIN_OUTPUT 0x90
56 #define TAG_MAIN_COLLECTION 0xA0
57 #define TAG_MAIN_FEATURE 0xB0
58 #define TAG_MAIN_ENDCOLLECTION 0xC0
60 #define TAG_GLOBAL_USAGEPAGE 0x00
61 #define TAG_GLOBAL_LOGICALMIN 0x10
62 #define TAG_GLOBAL_LOGICALMAX 0x20
63 #define TAG_GLOBAL_PHYSMIN 0x30
64 #define TAG_GLOBAL_PHYSMAX 0x40
65 #define TAG_GLOBAL_UNITEXP 0x50
66 #define TAG_GLOBAL_UNIT 0x60
67 #define TAG_GLOBAL_REPORTSIZE 0x70
68 #define TAG_GLOBAL_REPORTID 0x80
69 #define TAG_GLOBAL_REPORTCOUNT 0x90
70 #define TAG_GLOBAL_PUSH 0xA0
71 #define TAG_GLOBAL_POP 0xB0
73 #define TAG_LOCAL_USAGE 0x00
74 #define TAG_LOCAL_USAGEMIN 0x10
75 #define TAG_LOCAL_USAGEMAX 0x20
78 #define bmREQ_HIDOUT USB_SETUP_HOST_TO_DEVICE|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
79 #define bmREQ_HIDIN USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_CLASS|USB_SETUP_RECIPIENT_INTERFACE
80 #define bmREQ_HIDREPORT USB_SETUP_DEVICE_TO_HOST|USB_SETUP_TYPE_STANDARD|USB_SETUP_RECIPIENT_INTERFACE
84 #define HID_REQUEST_GET_REPORT 0x01
85 #define HID_REQUEST_GET_IDLE 0x02
86 #define HID_REQUEST_GET_PROTOCOL 0x03
87 #define HID_REQUEST_SET_REPORT 0x09
88 #define HID_REQUEST_SET_IDLE 0x0A
89 #define HID_REQUEST_SET_PROTOCOL 0x0B
92 #define HID_DESCRIPTOR_HID 0x21
93 #define HID_DESCRIPTOR_REPORT 0x22
94 #define HID_DESRIPTOR_PHY 0x23
97 #define HID_BOOT_PROTOCOL 0x00
98 #define HID_RPT_PROTOCOL 0x01
101 #define HID_INTF 0x03
104 #define HID_BOOT_INTF_SUBCLASS 0x01
107 #define HID_PROTOCOL_NONE 0x00
108 #define HID_PROTOCOL_KEYBOARD 0x01
109 #define HID_PROTOCOL_MOUSE 0x02
117 #define HID_ITEM_TYPE_MAIN 0
118 #define HID_ITEM_TYPE_GLOBAL 1
119 #define HID_ITEM_TYPE_LOCAL 2
120 #define HID_ITEM_TYPE_RESERVED 3
122 #define HID_LONG_ITEM_PREFIX 0xfe // Long item prefix value
124 #define bmHID_MAIN_ITEM_TAG 0xfc // Main item tag mask
126 #define bmHID_MAIN_ITEM_INPUT 0x80 // Main item Input tag value
127 #define bmHID_MAIN_ITEM_OUTPUT 0x90 // Main item Output tag value
128 #define bmHID_MAIN_ITEM_FEATURE 0xb0 // Main item Feature tag value
129 #define bmHID_MAIN_ITEM_COLLECTION 0xa0 // Main item Collection tag value
130 #define bmHID_MAIN_ITEM_END_COLLECTION 0xce // Main item End Collection tag value
132 #define HID_MAIN_ITEM_COLLECTION_PHYSICAL 0
133 #define HID_MAIN_ITEM_COLLECTION_APPLICATION 1
134 #define HID_MAIN_ITEM_COLLECTION_LOGICAL 2
135 #define HID_MAIN_ITEM_COLLECTION_REPORT 3
136 #define HID_MAIN_ITEM_COLLECTION_NAMED_ARRAY 4
137 #define HID_MAIN_ITEM_COLLECTION_USAGE_SWITCH 5
138 #define HID_MAIN_ITEM_COLLECTION_USAGE_MODIFIER 6
155 virtual void Parse(
HID *hid,
bool is_rpt_id, uint8_t len, uint8_t *buf) = 0;
158 #define MAX_REPORT_PARSERS 2
159 #define HID_MAX_HID_CLASS_DESCRIPTORS 5
189 uint8_t
SetProtocol(uint8_t iface, uint8_t protocol);
190 uint8_t
GetProtocol(uint8_t iface, uint8_t* dataptr);
191 uint8_t
GetIdle(uint8_t iface, uint8_t reportID, uint8_t* dataptr);
192 uint8_t
SetIdle(uint8_t iface, uint8_t reportID, uint8_t duration);
196 uint8_t
GetHidDescr(uint8_t ep, uint16_t nbytes, uint8_t* dataptr);
197 uint8_t
GetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t* dataptr);
198 uint8_t
SetReport(uint8_t ep, uint8_t iface, uint8_t report_type, uint8_t report_id, uint16_t nbytes, uint8_t* dataptr);