diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-03-19 15:10:51 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-03-19 15:10:51 +0000 |
commit | ee7bd5685e000b3a128069fd75d436c653ab54b2 (patch) | |
tree | d3c4585860bc6b9662f520319cb9c502c4f06104 /Demos | |
parent | 7184153e5dc68e134d64cb16a1096ba9f1957964 (diff) | |
download | lufa-ee7bd5685e000b3a128069fd75d436c653ab54b2.tar.gz lufa-ee7bd5685e000b3a128069fd75d436c653ab54b2.tar.bz2 lufa-ee7bd5685e000b3a128069fd75d436c653ab54b2.zip |
Ensure that the Keyboard and Mouse demos adhere to the boot protocol specification in that they send a report before the idle period has elapsed if the report data has changed.
Diffstat (limited to 'Demos')
-rw-r--r-- | Demos/Keyboard/Keyboard.c | 12 | ||||
-rw-r--r-- | Demos/Mouse/Mouse.c | 12 |
2 files changed, 16 insertions, 8 deletions
diff --git a/Demos/Keyboard/Keyboard.c b/Demos/Keyboard/Keyboard.c index a26f357a1..d6b254ffb 100644 --- a/Demos/Keyboard/Keyboard.c +++ b/Demos/Keyboard/Keyboard.c @@ -385,8 +385,9 @@ void ProcessLEDReport(uint8_t LEDReport) /** Sends the next HID report to the host, via the keyboard data endpoint. */
static inline void SendNextReport(void)
{
- USB_KeyboardReport_Data_t KeyboardReportData;
- bool SendReport = true;
+ static USB_KeyboardReport_Data_t PrevKeyboardReportData;
+ USB_KeyboardReport_Data_t KeyboardReportData;
+ bool SendReport = true;
/* Create the next keyboard report for transmission to the host */
CreateKeyboardReport(&KeyboardReportData);
@@ -402,11 +403,14 @@ static inline void SendNextReport(void) }
else
{
- /* Idle period not elapsed, indicate that a report must not be sent */
- SendReport = false;
+ /* Idle period not elapsed, indicate that a report must not be sent unless the report has changed */
+ SendReport = (memcmp(&PrevKeyboardReportData, &KeyboardReportData, sizeof(USB_KeyboardReport_Data_t)) != 0);
}
}
+ /* Save the current report data for later comparison to check for changes */
+ PrevKeyboardReportData = KeyboardReportData;
+
/* Select the Keyboard Report Endpoint */
Endpoint_SelectEndpoint(KEYBOARD_EPNUM);
diff --git a/Demos/Mouse/Mouse.c b/Demos/Mouse/Mouse.c index c4b7f55ad..c066d424a 100644 --- a/Demos/Mouse/Mouse.c +++ b/Demos/Mouse/Mouse.c @@ -337,8 +337,9 @@ void CreateMouseReport(USB_MouseReport_Data_t* ReportData) /** Sends the next HID report to the host, via the keyboard data endpoint. */
static inline void SendNextReport(void)
{
- USB_MouseReport_Data_t MouseReportData;
- bool SendReport = true;
+ static USB_MouseReport_Data_t PrevMouseReportData;
+ USB_MouseReport_Data_t MouseReportData;
+ bool SendReport = true;
/* Create the next mouse report for transmission to the host */
CreateMouseReport(&MouseReportData);
@@ -354,10 +355,13 @@ static inline void SendNextReport(void) }
else
{
- /* Idle period not elapsed, indicate that a report must not be sent */
- SendReport = false;
+ /* Idle period not elapsed, indicate that a report must not be sent unless the report has changed */
+ SendReport = (memcmp(&PrevMouseReportData, &MouseReportData, sizeof(USB_MouseReport_Data_t)) != 0);
}
}
+
+ /* Save the current report data for later comparison to check for changes */
+ PrevMouseReportData = MouseReportData;
/* Select the Mouse Report Endpoint */
Endpoint_SelectEndpoint(MOUSE_EPNUM);
|