aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cores/arduino/USBCore.h5
-rw-r--r--libraries/HID/HID.cpp9
2 files changed, 9 insertions, 5 deletions
diff --git a/cores/arduino/USBCore.h b/cores/arduino/USBCore.h
index 806fa60..530abec 100644
--- a/cores/arduino/USBCore.h
+++ b/cores/arduino/USBCore.h
@@ -49,8 +49,9 @@
#define REQUEST_OTHER 0x03
#define REQUEST_RECIPIENT 0x03
-#define REQUEST_DEVICETOHOST_CLASS_INTERFACE (REQUEST_DEVICETOHOST + REQUEST_CLASS + REQUEST_INTERFACE)
-#define REQUEST_HOSTTODEVICE_CLASS_INTERFACE (REQUEST_HOSTTODEVICE + REQUEST_CLASS + REQUEST_INTERFACE)
+#define REQUEST_DEVICETOHOST_CLASS_INTERFACE (REQUEST_DEVICETOHOST + REQUEST_CLASS + REQUEST_INTERFACE)
+#define REQUEST_HOSTTODEVICE_CLASS_INTERFACE (REQUEST_HOSTTODEVICE + REQUEST_CLASS + REQUEST_INTERFACE)
+#define REQUEST_DEVICETOHOST_STANDARD_INTERFACE (REQUEST_DEVICETOHOST + REQUEST_STANDARD + REQUEST_INTERFACE)
// Class requests
diff --git a/libraries/HID/HID.cpp b/libraries/HID/HID.cpp
index 762d170..bff00e3 100644
--- a/libraries/HID/HID.cpp
+++ b/libraries/HID/HID.cpp
@@ -40,9 +40,12 @@ int HID_::getInterface(uint8_t* interfaceCount)
int HID_::getDescriptor(USBSetup& setup)
{
- if (pluggedInterface != setup.wIndex) {
- return 0;
- }
+ // Check if this is a HID Class Descriptor request
+ if (setup.bmRequestType != REQUEST_DEVICETOHOST_STANDARD_INTERFACE) { return 0; }
+ if (setup.wValueH != HID_REPORT_DESCRIPTOR_TYPE) { return 0; }
+
+ // In a HID Class Descriptor wIndex cointains the interface number
+ if (setup.wIndex != pluggedInterface) { return 0; }
int total = 0;
HIDDescriptorListNode* node;