From 7227e133a9cf8d4de1214671211a0d93edb2b4bc Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Thu, 30 Jul 2009 14:40:42 +0000 Subject: Ensure that the previous HID reports in the HID device class driver are kept per-instance, rather than per-device. --- LUFA/Drivers/USB/Class/Device/HID.c | 6 ++---- LUFA/Drivers/USB/Class/Device/HID.h | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'LUFA/Drivers/USB') diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c index 4c13436e0..bfe97ffbb 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.c +++ b/LUFA/Drivers/USB/Class/Device/HID.c @@ -150,8 +150,6 @@ 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; @@ -167,10 +165,10 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ReportINSize = CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportINData); - bool StatesChanged = (memcmp(ReportINData, PreviousReportINData, ReportINSize) != 0); + bool StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->State.PreviousReportINData, ReportINSize) != 0); bool IdlePeriodElapsed = (HIDInterfaceInfo->State.IdleCount && !(HIDInterfaceInfo->State.IdleMSRemaining)); - memcpy(PreviousReportINData, ReportINData, ReportINSize); + memcpy(HIDInterfaceInfo->State.PreviousReportINData, ReportINData, ReportINSize); if (ReportINSize && (StatesChanged || IdlePeriodElapsed)) { diff --git a/LUFA/Drivers/USB/Class/Device/HID.h b/LUFA/Drivers/USB/Class/Device/HID.h index 61f43a141..ae68134fe 100644 --- a/LUFA/Drivers/USB/Class/Device/HID.h +++ b/LUFA/Drivers/USB/Class/Device/HID.h @@ -88,7 +88,9 @@ bool UsingReportProtocol; /**< Indicates if the HID interface is set to Boot or Report protocol mode */ uint16_t IdleCount; /**< Report idle period, in mS, set by the host */ uint16_t IdleMSRemaining; /**< Total number of mS remaining before the idle period elapsed - this should be - * decremented by the user application if non-zero each millisecond */ + * decremented by the user application if non-zero each millisecond */ + + uint8_t PreviousReportINData[HID_MAX_REPORT_SIZE]; /**< Previously generated report from the HID interface */ } State; /**< State data for the USB class interface within the device. All elements in this section * are reset to their defaults when the interface is enumerated. */ -- cgit v1.2.3