mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +01:00
[HID] Improved checks in getDescriptor() method
This commit is contained in:
parent
7217f85b62
commit
fb4f5066bf
@ -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
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user