Merge pull request #210 from joseangeljimenez/master

Added support to HIDBoot for easily enabling the Report Protocol
This commit is contained in:
Kristian Sloth Lauszus 2016-02-16 17:05:58 +01:00
commit 3ca6ddd8d4

View file

@ -210,6 +210,7 @@ class HIDBoot : public USBHID //public USBDeviceConfig, public UsbConfigXtracter
uint32_t qNextPollTime; // next poll time uint32_t qNextPollTime; // next poll time
bool bPollEnable; // poll enable flag bool bPollEnable; // poll enable flag
uint8_t bInterval; // largest interval uint8_t bInterval; // largest interval
bool bRptProtoEnable; // Report Protocol enable flag
void Initialize(); void Initialize();
@ -218,7 +219,7 @@ class HIDBoot : public USBHID //public USBDeviceConfig, public UsbConfigXtracter
}; };
public: public:
HIDBoot(USB *p); HIDBoot(USB *p, bool bRptProtoEnable = false);
virtual bool SetReportParser(uint8_t id, HIDReportParser *prs) { virtual bool SetReportParser(uint8_t id, HIDReportParser *prs) {
pRptParser[id] = prs; pRptParser[id] = prs;
@ -252,10 +253,11 @@ public:
}; };
template <const uint8_t BOOT_PROTOCOL> template <const uint8_t BOOT_PROTOCOL>
HIDBoot<BOOT_PROTOCOL>::HIDBoot(USB *p) : HIDBoot<BOOT_PROTOCOL>::HIDBoot(USB *p, bool bRptProtoEnable/* = false*/) :
USBHID(p), USBHID(p),
qNextPollTime(0), qNextPollTime(0),
bPollEnable(false) { bPollEnable(false),
bRptProtoEnable(bRptProtoEnable) {
Initialize(); Initialize();
for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) { for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
@ -456,7 +458,7 @@ uint8_t HIDBoot<BOOT_PROTOCOL>::Init(uint8_t parent, uint8_t port, bool lowspeed
// Yes, mouse wants SetProtocol and SetIdle too! // Yes, mouse wants SetProtocol and SetIdle too!
for(uint8_t i = 0; i < epMUL(BOOT_PROTOCOL); i++) { for(uint8_t i = 0; i < epMUL(BOOT_PROTOCOL); i++) {
USBTRACE2("\r\nInterface:", i); USBTRACE2("\r\nInterface:", i);
rcode = SetProtocol(i, USB_HID_BOOT_PROTOCOL); rcode = SetProtocol(i, bRptProtoEnable ? HID_RPT_PROTOCOL : USB_HID_BOOT_PROTOCOL);
if(rcode) goto FailSetProtocol; if(rcode) goto FailSetProtocol;
USBTRACE2("PROTOCOL SET HID_BOOT rcode:", rcode); USBTRACE2("PROTOCOL SET HID_BOOT rcode:", rcode);
rcode = SetIdle(i, 0, 0); rcode = SetIdle(i, 0, 0);