From f85a53a31b00190ad726f509ad275079fc6eb994 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Wed, 15 Jul 2009 05:49:19 +0000 Subject: Fix HID class device driver -- if a SetIDle request is issued with the LSB of wValue set to zero, the idle period must be set for all HID interfaces. Fix Keyboard and Mouse demos, Idle period is now multiplied by 4 as the period is read into and sent out of the device to ensure it is always stored as a multiple of 1ms. Fixes Keyboard demo using an initial Idle period of 2s rather than 500ms (thanks to Brian Dickman). Move out the internal device serial descriptor reading routine into a seperate static function, rather than being part of USB_Device_GetDescriptor. --- LUFA/Drivers/USB/Class/Device/HID.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'LUFA/Drivers/USB/Class/Device/HID.c') diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c index d0320868f..bad934a3c 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.c +++ b/LUFA/Drivers/USB/Class/Device/HID.c @@ -38,8 +38,11 @@ void HID_Device_ProcessControlPacket(USB_ClassInfo_HID_Device_t* const HIDInterf if (!(Endpoint_IsSETUPReceived())) return; - if (USB_ControlRequest.wIndex != HIDInterfaceInfo->Config.InterfaceNumber) - return; + if ((USB_ControlRequest.wIndex != HIDInterfaceInfo->Config.InterfaceNumber) && + (USB_ControlRequest.bRequest != SetIdle)) + { + return; + } switch (USB_ControlRequest.bRequest) { @@ -105,12 +108,16 @@ void HID_Device_ProcessControlPacket(USB_ClassInfo_HID_Device_t* const HIDInterf case REQ_SetIdle: if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) { - Endpoint_ClearSETUP(); - - HIDInterfaceInfo->State.IdleCount = ((USB_ControlRequest.wValue >> 8) << 2); - - while (!(Endpoint_IsINReady())); - Endpoint_ClearIN(); + if ((USB_ControlRequest.wIndex == HIDInterfaceInfo->Config.InterfaceNumber) || + (USB_ControlRequest.wValue & 0xFF) == 0) + { + Endpoint_ClearSETUP(); + + HIDInterfaceInfo->State.IdleCount = ((USB_ControlRequest.wValue & 0xFF00) >> 6); + + while (!(Endpoint_IsINReady())); + Endpoint_ClearIN(); + } } break; -- cgit v1.2.3