diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-07-30 14:35:42 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-07-30 14:35:42 +0000 |
commit | 72932e278000c7086073a28639e3cfae06e39eb3 (patch) | |
tree | 8fd1350e0f1029cdd0dd0ee715be35774f516a97 /LUFA/Drivers/USB/Class/Device/HID.c | |
parent | ec079c71d89913dd4823fe7ecf22d0d3f42b1e6d (diff) | |
download | lufa-72932e278000c7086073a28639e3cfae06e39eb3.tar.gz lufa-72932e278000c7086073a28639e3cfae06e39eb3.tar.bz2 lufa-72932e278000c7086073a28639e3cfae06e39eb3.zip |
Fix to HID device mode Class driver, so that new reports are compared against the old, and updated reports made within the idle period are sent immediately to the host.
Diffstat (limited to 'LUFA/Drivers/USB/Class/Device/HID.c')
-rw-r--r-- | LUFA/Drivers/USB/Class/Device/HID.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c index 43f11ee7c..4c13436e0 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.c +++ b/LUFA/Drivers/USB/Class/Device/HID.c @@ -51,7 +51,7 @@ void HID_Device_ProcessControlPacket(USB_ClassInfo_HID_Device_t* const HIDInterf {
Endpoint_ClearSETUP();
- uint8_t ReportINData[HIDInterfaceInfo->Config.ReportINBufferSize];
+ uint8_t ReportINData[HID_MAX_REPORT_SIZE];
uint16_t ReportINSize;
uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);
@@ -150,27 +150,32 @@ bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfac void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
{
+ static uint8_t PreviousReportINData[HID_MAX_REPORT_SIZE];
+
if (USB_DeviceState != DEVICE_STATE_Configured)
return;
Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpointNumber);
- if (Endpoint_IsReadWriteAllowed() &&
- !(HIDInterfaceInfo->State.IdleCount && HIDInterfaceInfo->State.IdleMSRemaining))
+ if (Endpoint_IsReadWriteAllowed())
{
- if (HIDInterfaceInfo->State.IdleCount && !(HIDInterfaceInfo->State.IdleMSRemaining))
- HIDInterfaceInfo->State.IdleMSRemaining = HIDInterfaceInfo->State.IdleCount;
-
- uint8_t ReportINData[HIDInterfaceInfo->Config.ReportINBufferSize];
- uint16_t ReportINSize;
+ uint8_t ReportINData[HID_MAX_REPORT_SIZE];
uint8_t ReportID = 0;
+ uint16_t ReportINSize;
memset(ReportINData, 0, sizeof(ReportINData));
- ReportINSize = CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportINData);
+ ReportINSize = CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportINData);
- if (ReportINSize)
+ bool StatesChanged = (memcmp(ReportINData, PreviousReportINData, ReportINSize) != 0);
+ bool IdlePeriodElapsed = (HIDInterfaceInfo->State.IdleCount && !(HIDInterfaceInfo->State.IdleMSRemaining));
+
+ memcpy(PreviousReportINData, ReportINData, ReportINSize);
+
+ if (ReportINSize && (StatesChanged || IdlePeriodElapsed))
{
+ HIDInterfaceInfo->State.IdleMSRemaining = HIDInterfaceInfo->State.IdleCount;
+
if (ReportID)
Endpoint_Write_Stream_LE(&ReportID, sizeof(ReportID), NO_STREAM_CALLBACK);
|