17 #if !defined(__HIDBOOT_H__)
21 #include <avr/pgmspace.h>
29 #if defined(ARDUINO) && ARDUINO >=100
41 #define KEY_SPACE 0x2c
43 #define KEY_ZERO2 0x62
44 #define KEY_ENTER 0x28
45 #define KEY_PERIOD 0x63
69 virtual void Parse(
HID *hid,
bool is_rpt_id, uint8_t len, uint8_t *buf);
120 #define KEY_NUM_LOCK 0x53
121 #define KEY_CAPS_LOCK 0x39
122 #define KEY_SCROLL_LOCK 0x47
126 static const uint8_t numKeys[];
127 static const uint8_t symKeysUp[];
128 static const uint8_t symKeysLo[];
129 static const uint8_t padKeys[];
149 virtual void Parse(
HID *hid,
bool is_rpt_id, uint8_t len, uint8_t *buf);
155 virtual void OnKeyUp (uint8_t mod, uint8_t key) {};
158 #define totalEndpoints 2
160 #define HID_MAX_HID_CLASS_DESCRIPTORS 5
162 template <const u
int8_t BOOT_PROTOCOL>
173 uint32_t qNextPollTime;
178 virtual HIDReportParser* GetReportParser(uint8_t
id) {
return pRptParser; };
186 virtual uint8_t
Init(uint8_t parent, uint8_t port,
bool lowspeed);
188 virtual uint8_t
Poll();
195 template <const u
int8_t BOOT_PROTOCOL>
208 template <const u
int8_t BOOT_PROTOCOL>
213 epInfo[i].epAddr = 0;
214 epInfo[i].maxPktSize = (i) ? 0 : 8;
215 epInfo[i].epAttribs = 0;
223 template <const u
int8_t BOOT_PROTOCOL>
228 uint8_t buf[constBufSize];
266 rcode = pUsb->getDevDescr( 0, 0, 8, (uint8_t*)buf );
269 len = (buf[0] > constBufSize) ? constBufSize : buf[0];
276 goto FailGetDevDescr;
292 rcode = pUsb->setAddr( 0, 0, bAddress );
315 rcode = pUsb->getDevDescr( bAddress, 0, len, (uint8_t*)buf );
318 goto FailGetDevDescr;
323 rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
326 goto FailSetDevTblEntry;
330 for (uint8_t i=0; i<num_of_conf; i++)
340 rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser);
353 rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo);
358 rcode = pUsb->setConf(bAddress, 0, bConfNum);
361 goto FailSetConfDescr;
368 goto FailSetProtocol;
370 if (BOOT_PROTOCOL == 1)
372 rcode = SetIdle(bIfaceNum, 0, 0);
407 Serial.println(rcode, HEX);
412 template <const u
int8_t BOOT_PROTOCOL>
416 if (bNumEP > 1 && conf != bConfNum)
430 index = epInterruptInIndex;
435 epInfo[index].epAttribs = 0;
444 template <const u
int8_t BOOT_PROTOCOL>
447 pUsb->GetAddressPool().FreeAddress(bAddress);
458 template <const u
int8_t BOOT_PROTOCOL>
466 if (qNextPollTime <= millis())
468 qNextPollTime = millis() + 10;
470 const uint8_t const_buff_len = 16;
471 uint8_t buf[const_buff_len];
473 uint16_t read = (uint16_t)epInfo[epInterruptInIndex].maxPktSize;
475 uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[epInterruptInIndex].epAddr, &read, buf);
489 pRptParser->Parse((
HID*)
this, 0, (uint8_t)read, buf);
495 #endif // __HIDBOOTMOUSE_H__