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
67 virtual void Parse(
HID *hid,
bool is_rpt_id, uint8_t len, uint8_t *buf);
129 #define KEY_NUM_LOCK 0x53
130 #define KEY_CAPS_LOCK 0x39
131 #define KEY_SCROLL_LOCK 0x47
134 static const uint8_t numKeys[];
135 static const uint8_t symKeysUp[];
136 static const uint8_t symKeysLo[];
137 static const uint8_t padKeys[];
159 virtual void Parse(
HID *hid,
bool is_rpt_id, uint8_t len, uint8_t *buf);
167 virtual void OnKeyUp(uint8_t mod, uint8_t key) {
171 #define totalEndpoints 2
173 #define HID_MAX_HID_CLASS_DESCRIPTORS 5
175 template <const u
int8_t BOOT_PROTOCOL>
186 uint32_t qNextPollTime;
204 virtual uint8_t
Init(uint8_t parent, uint8_t port,
bool lowspeed);
206 virtual uint8_t
Poll();
216 template <const u
int8_t BOOT_PROTOCOL>
228 template <const u
int8_t BOOT_PROTOCOL>
231 epInfo[i].epAddr = 0;
232 epInfo[i].maxPktSize = (i) ? 0 : 8;
233 epInfo[i].epAttribs = 0;
241 template <const u
int8_t BOOT_PROTOCOL>
245 uint8_t buf[constBufSize];
282 rcode = pUsb->getDevDescr(0, 0, 8, (uint8_t*) buf);
285 len = (buf[0] > constBufSize) ? constBufSize : buf[0];
291 goto FailGetDevDescr;
307 rcode = pUsb->setAddr(0, 0, bAddress);
329 rcode = pUsb->getDevDescr(bAddress, 0, len, (uint8_t*) buf);
332 goto FailGetDevDescr;
337 rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
340 goto FailSetDevTblEntry;
344 for(uint8_t i = 0; i < num_of_conf; i++) {
351 rcode = pUsb->getConfDescr(bAddress, 0, i, &confDescrParser);
364 rcode = pUsb->setEpInfoEntry(bAddress, bNumEP, epInfo);
369 rcode = pUsb->setConf(bAddress, 0, bConfNum);
372 goto FailSetConfDescr;
379 goto FailSetProtocol;
381 if(BOOT_PROTOCOL == 1) {
382 rcode = SetIdle(bIfaceNum, 0, 0);
423 template <const u
int8_t BOOT_PROTOCOL>
426 if(bNumEP > 1 && conf != bConfNum)
435 index = epInterruptInIndex;
440 epInfo[index].epAttribs = 0;
446 template <const u
int8_t BOOT_PROTOCOL>
448 pUsb->GetAddressPool().FreeAddress(bAddress);
459 template <const u
int8_t BOOT_PROTOCOL>
466 if(qNextPollTime <= millis()) {
467 qNextPollTime = millis() + 10;
469 const uint8_t const_buff_len = 16;
470 uint8_t buf[const_buff_len];
472 uint16_t read = (uint16_t) epInfo[epInterruptInIndex].maxPktSize;
474 uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[epInterruptInIndex].epAddr, &read, buf);
487 pRptParser->Parse((
HID*)
this, 0, (uint8_t) read, buf);
493 #endif // __HIDBOOTMOUSE_H__