17 #if !defined(__HIDBOOT_H__)
22 #define KEY_SPACE 0x2c
24 #define KEY_ZERO2 0x62
25 #define KEY_ENTER 0x28
26 #define KEY_PERIOD 0x63
48 virtual void Parse(
HID *hid,
bool is_rpt_id, uint8_t len, uint8_t *buf);
110 #define KEY_NUM_LOCK 0x53
111 #define KEY_CAPS_LOCK 0x39
112 #define KEY_SCROLL_LOCK 0x47
115 static const uint8_t numKeys[];
116 static const uint8_t symKeysUp[];
117 static const uint8_t symKeysLo[];
118 static const uint8_t padKeys[];
140 virtual void Parse(
HID *hid,
bool is_rpt_id, uint8_t len, uint8_t *buf);
151 virtual void OnKeyUp(uint8_t mod, uint8_t key) {
155 #define totalEndpoints (((BOOT_PROTOCOL & HID_PROTOCOL_KEYBOARD)? 2 : 0)+((BOOT_PROTOCOL & HID_PROTOCOL_MOUSE)? 1 : 0))
156 #define epMUL (((BOOT_PROTOCOL & HID_PROTOCOL_KEYBOARD)? 1 : 0)+((BOOT_PROTOCOL & HID_PROTOCOL_MOUSE)? 1 : 0))
157 #define HID_MAX_HID_CLASS_DESCRIPTORS 5
159 template <const u
int8_t BOOT_PROTOCOL>
169 uint32_t qNextPollTime;
175 return pRptParser[id];
182 pRptParser[id] = prs;
187 virtual uint8_t
Init(uint8_t parent, uint8_t port,
bool lowspeed);
189 virtual uint8_t
Poll();
199 template <const u
int8_t BOOT_PROTOCOL>
206 for(uint8_t i = 0; i <
epMUL; i++) {
207 pRptParser[i] = NULL;
213 template <const u
int8_t BOOT_PROTOCOL>
216 epInfo[i].epAddr = 0;
217 epInfo[i].maxPktSize = (i) ? 0 : 8;
218 epInfo[i].epAttribs = 0;
226 template <const u
int8_t BOOT_PROTOCOL>
230 uint8_t buf[constBufSize];
267 rcode = pUsb->getDevDescr(0, 0, 8, (uint8_t*) buf);
270 len = (buf[0] > constBufSize) ? constBufSize : buf[0];
276 goto FailGetDevDescr;
292 rcode = pUsb->setAddr(0, 0, bAddress);
314 rcode = pUsb->getDevDescr(bAddress, 0, len, (uint8_t*) buf);
317 goto FailGetDevDescr;
322 rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
325 goto FailSetDevTblEntry;
331 for(uint8_t i = 0; i < num_of_conf; i++) {
340 pUsb->getConfDescr(bAddress, 0, i, &confDescrParserA);
346 for(uint8_t i = 0; i < num_of_conf; i++) {
355 pUsb->getConfDescr(bAddress, 0, i, &confDescrParserB);
368 rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo);
373 rcode = pUsb->setConf(bAddress, 0, bConfNum);
376 goto FailSetConfDescr;
383 goto FailSetProtocol;
386 if(BOOT_PROTOCOL & HID_PROTOCOL_KEYBOARD) {
387 rcode = SetIdle(0, 0, 0);
398 #ifdef DEBUG_USB_HOST
404 #ifdef DEBUG_USB_HOST
410 #ifdef DEBUG_USB_HOST
416 #ifdef DEBUG_USB_HOST
422 #ifdef DEBUG_USB_HOST
428 #ifdef DEBUG_USB_HOST
433 #ifdef DEBUG_USB_HOST
440 template <const u
int8_t BOOT_PROTOCOL>
443 if(bNumEP > 1 && conf != bConfNum)
450 uint8_t index = bNumEP;
455 epInfo[index].epAttribs = 0;
462 template <const u
int8_t BOOT_PROTOCOL>
464 pUsb->GetAddressPool().FreeAddress(bAddress);
475 template <const u
int8_t BOOT_PROTOCOL>
482 if(qNextPollTime <= millis()) {
483 qNextPollTime = millis() + 10;
486 for(uint8_t i = 0; i <
epMUL; i++) {
487 const uint8_t const_buff_len = 16;
488 uint8_t buf[const_buff_len];
491 uint16_t read = (uint16_t) epInfo[epInterruptInIndex + i].maxPktSize;
493 uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[epInterruptInIndex + i].epAddr, &read, buf);
496 pRptParser[i]->Parse((
HID*)
this, 0, (uint8_t) read, buf);
513 #endif // __HIDBOOTMOUSE_H__
#define CP_MASK_COMPARE_ALL
#define USB_ERROR_EPINFO_IS_NULL
virtual void OnRightButtonDown(MOUSEINFO *mi)
virtual void OnKeyDown(uint8_t mod, uint8_t key)
virtual void OnMiddleButtonUp(MOUSEINFO *mi)
virtual uint8_t HandleLockingKeys(HID *hid, uint8_t key)
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
virtual void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
union KeyboardReportParser::@14 kbdLockingKeys
#define NotifyFailGetDevDescr(...)
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
union KeyboardReportParser::@13 prevState
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs)
virtual void OnKeyUp(uint8_t mod, uint8_t key)
virtual void FreeAddress(uint8_t addr)=0
#define HID_PROTOCOL_KEYBOARD
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
#define HID_BOOT_PROTOCOL
#define NotifyFailGetConfDescr(...)
virtual void OnLeftButtonUp(MOUSEINFO *mi)
virtual uint8_t GetAddress()
#define USB_NAK_MAX_POWER
#define HID_BOOT_INTF_SUBCLASS
uint8_t bInfo[sizeof(KBDINFO)]
uint8_t bInfo[sizeof(MOUSEINFO)]
virtual void OnMouseMove(MOUSEINFO *mi)
virtual void OnRightButtonUp(MOUSEINFO *mi)
virtual void OnMiddleButtonDown(MOUSEINFO *mi)
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
virtual void OnControlKeysChanged(uint8_t before, uint8_t after)
virtual uint8_t Release()
virtual void OnLeftButtonDown(MOUSEINFO *mi)
#define HID_PROTOCOL_MOUSE
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
static const uint8_t totalEndpoints
#define NotifyFailSetConfDescr(...)
#define NotifyFailSetDevTblEntry(...)
uint8_t OemToAscii(uint8_t mod, uint8_t key)