aboutsummaryrefslogtreecommitdiff
path: root/LUFA
diff options
context:
space:
mode:
authorDean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28>2009-10-26 11:44:36 +0000
committerDean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28>2009-10-26 11:44:36 +0000
commit1442984af0e05ff5e8d60878f5286f4db66189ad (patch)
treebd6d4e98ce3a3d2995a7cbc86f0fcd84abdef5ad /LUFA
parent76eb05b6edfdc12da7a1f651923f3e04c92f847f (diff)
Make HID device class driver ignore the previous HID report comparison buffer when the user sets it to NULL, disabling automatic report comparisons. Update HID device class driver documentation giving previous report buffer limitations.
git-svn-id: http://lufa-lib.googlecode.com/svn/trunk@871 d5102386-fcda-11dd-9fdb-3debd5008f28
Diffstat (limited to 'LUFA')
-rw-r--r--LUFA/Drivers/USB/Class/Device/HID.c11
-rw-r--r--LUFA/Drivers/USB/Class/Device/HID.h9
2 files changed, 15 insertions, 5 deletions
diff --git a/LUFA/Drivers/USB/Class/Device/HID.c b/LUFA/Drivers/USB/Class/Device/HID.c
index 403d494d..26f5697d 100644
--- a/LUFA/Drivers/USB/Class/Device/HID.c
+++ b/LUFA/Drivers/USB/Class/Device/HID.c
@@ -157,12 +157,15 @@ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)
memset(ReportINData, 0, sizeof(ReportINData));
- bool ForceSend = CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportINData, &ReportINSize);
-
- bool StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize) != 0);
+ bool ForceSend = CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportINData, &ReportINSize);
+ bool StatesChanged = false;
bool IdlePeriodElapsed = (HIDInterfaceInfo->State.IdleCount && !(HIDInterfaceInfo->State.IdleMSRemaining));
- memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, ReportINSize);
+ if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL)
+ {
+ StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize) != 0);
+ memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, ReportINSize);
+ }
if (ReportINSize && (ForceSend || StatesChanged || IdlePeriodElapsed))
{
diff --git a/LUFA/Drivers/USB/Class/Device/HID.h b/LUFA/Drivers/USB/Class/Device/HID.h
index dee892d0..4865a124 100644
--- a/LUFA/Drivers/USB/Class/Device/HID.h
+++ b/LUFA/Drivers/USB/Class/Device/HID.h
@@ -77,7 +77,14 @@
void* PrevReportINBuffer; /** Pointer to a buffer where the previously created HID input report can be
* stored by the driver, for comparison purposes to detect report changes that
* must be sent immediately to the host. This should point to a buffer big enough
- * to hold the largest HID input report sent from the HID interface.
+ * to hold the largest HID input report sent from the HID interface. If this is set
+ * to NULL, it is up to the user to force transfers when needed in the
+ * \ref CALLBACK_HID_Device_CreateHIDReport() callback function.
+ *
+ * \note Due to the single buffer, the internal driver can only correctly compare
+ * subsequent reports with identical report IDs. In multiple report devices,
+ * this buffer should be set to NULL and the decision to send reports made
+ * by the user application instead.
*/
uint8_t PrevReportINBufferSize; /** Size in bytes of the given input report buffer. This is used to create a
* second buffer of the same size within the driver so that subsequent reports