[HID] Improved checks in getDescriptor() method

This commit is contained in:
Cristian Maglie 2015-10-08 16:38:57 +02:00
parent 7217f85b62
commit fb4f5066bf
2 changed files with 9 additions and 5 deletions

View File

@ -49,8 +49,9 @@
#define REQUEST_OTHER 0x03 #define REQUEST_OTHER 0x03
#define REQUEST_RECIPIENT 0x03 #define REQUEST_RECIPIENT 0x03
#define REQUEST_DEVICETOHOST_CLASS_INTERFACE (REQUEST_DEVICETOHOST + 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_HOSTTODEVICE_CLASS_INTERFACE (REQUEST_HOSTTODEVICE + REQUEST_CLASS + REQUEST_INTERFACE)
#define REQUEST_DEVICETOHOST_STANDARD_INTERFACE (REQUEST_DEVICETOHOST + REQUEST_STANDARD + REQUEST_INTERFACE)
// Class requests // Class requests

View File

@ -40,9 +40,12 @@ int HID_::getInterface(uint8_t* interfaceCount)
int HID_::getDescriptor(USBSetup& setup) int HID_::getDescriptor(USBSetup& setup)
{ {
if (pluggedInterface != setup.wIndex) { // Check if this is a HID Class Descriptor request
return 0; 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; int total = 0;
HIDDescriptorListNode* node; HIDDescriptorListNode* node;