From e9c28d762d81b639492fcbfc8c212c57aaf530fa Mon Sep 17 00:00:00 2001 From: "Jose A. Jimenez" Date: Sun, 7 Feb 2016 22:32:08 +0100 Subject: [PATCH] Added flag bRptProtoEnable to HIDBoot() constructor. The flag defaults to false in order to maintain current behavior (Boot Protocol). If flag is the to true, HIDBoot() will enable the Report Protocol. This modification is very useful for communication with HID devices with the full, richer, Report Protocol. --- hidboot.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hidboot.h b/hidboot.h index 27fda78d..7932efea 100644 --- a/hidboot.h +++ b/hidboot.h @@ -210,6 +210,7 @@ class HIDBoot : public USBHID //public USBDeviceConfig, public UsbConfigXtracter uint32_t qNextPollTime; // next poll time bool bPollEnable; // poll enable flag uint8_t bInterval; // largest interval + bool bRptProtoEnable; // Report Protocol enable flag void Initialize(); @@ -218,7 +219,7 @@ class HIDBoot : public USBHID //public USBDeviceConfig, public UsbConfigXtracter }; public: - HIDBoot(USB *p); + HIDBoot(USB *p, bool bRptProtoEnable=false); virtual bool SetReportParser(uint8_t id, HIDReportParser *prs) { pRptParser[id] = prs; @@ -252,10 +253,11 @@ public: }; template -HIDBoot::HIDBoot(USB *p) : +HIDBoot::HIDBoot(USB *p, bool bRptProtoEnable) : USBHID(p), qNextPollTime(0), -bPollEnable(false) { +bPollEnable(false), +bRptProtoEnable(bRptProtoEnable) { Initialize(); for(int i = 0; i < epMUL(BOOT_PROTOCOL); i++) { @@ -456,7 +458,7 @@ uint8_t HIDBoot::Init(uint8_t parent, uint8_t port, bool lowspeed // Yes, mouse wants SetProtocol and SetIdle too! for(uint8_t i = 0; i < epMUL(BOOT_PROTOCOL); i++) { USBTRACE2("\r\nInterface:", i); - rcode = SetProtocol(i, USB_HID_BOOT_PROTOCOL); + rcode = SetProtocol(i, bRptProtoEnable ? HID_RPT_PROTOCOL : HID_BOOT_PROTOCOL); if(rcode) goto FailSetProtocol; USBTRACE2("PROTOCOL SET HID_BOOT rcode:", rcode); rcode = SetIdle(i, 0, 0);