Ensure that the Keyboard and Mouse demos adhere to the boot protocol specification...
authorDean Camera <dean@fourwalledcubicle.com>
Thu, 19 Mar 2009 15:10:51 +0000 (15:10 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Thu, 19 Mar 2009 15:10:51 +0000 (15:10 +0000)
Demos/Keyboard/Keyboard.c
Demos/Mouse/Mouse.c

index a26f357..d6b254f 100644 (file)
@@ -385,8 +385,9 @@ void ProcessLEDReport(uint8_t LEDReport)
 /** Sends the next HID report to the host, via the keyboard data endpoint. */\r
 static inline void SendNextReport(void)\r
 {\r
-       USB_KeyboardReport_Data_t KeyboardReportData;\r
-       bool                      SendReport = true;\r
+       static USB_KeyboardReport_Data_t PrevKeyboardReportData;\r
+       USB_KeyboardReport_Data_t        KeyboardReportData;\r
+       bool                             SendReport = true;\r
        \r
        /* Create the next keyboard report for transmission to the host */\r
        CreateKeyboardReport(&KeyboardReportData);\r
@@ -402,11 +403,14 @@ static inline void SendNextReport(void)
                }\r
                else\r
                {\r
-                       /* Idle period not elapsed, indicate that a report must not be sent */\r
-                       SendReport = false;                     \r
+                       /* Idle period not elapsed, indicate that a report must not be sent unless the report has changed */\r
+                       SendReport = (memcmp(&PrevKeyboardReportData, &KeyboardReportData, sizeof(USB_KeyboardReport_Data_t)) != 0);\r
                }\r
        }\r
        \r
+       /* Save the current report data for later comparison to check for changes */\r
+       PrevKeyboardReportData = KeyboardReportData;\r
+\r
        /* Select the Keyboard Report Endpoint */\r
        Endpoint_SelectEndpoint(KEYBOARD_EPNUM);\r
 \r
index c4b7f55..c066d42 100644 (file)
@@ -337,8 +337,9 @@ void CreateMouseReport(USB_MouseReport_Data_t* ReportData)
 /** Sends the next HID report to the host, via the keyboard data endpoint. */\r
 static inline void SendNextReport(void)\r
 {\r
-       USB_MouseReport_Data_t MouseReportData;\r
-       bool                   SendReport = true;\r
+       static USB_MouseReport_Data_t PrevMouseReportData;\r
+       USB_MouseReport_Data_t        MouseReportData;\r
+       bool                          SendReport = true;\r
        \r
        /* Create the next mouse report for transmission to the host */\r
        CreateMouseReport(&MouseReportData);\r
@@ -354,10 +355,13 @@ static inline void SendNextReport(void)
                }\r
                else\r
                {\r
-                       /* Idle period not elapsed, indicate that a report must not be sent */\r
-                       SendReport = false;\r
+                       /* Idle period not elapsed, indicate that a report must not be sent unless the report has changed */\r
+                       SendReport = (memcmp(&PrevMouseReportData, &MouseReportData, sizeof(USB_MouseReport_Data_t)) != 0);\r
                }\r
        }\r
+\r
+       /* Save the current report data for later comparison to check for changes */\r
+       PrevMouseReportData = MouseReportData;\r
        \r
        /* Select the Mouse Report Endpoint */\r
        Endpoint_SelectEndpoint(MOUSE_EPNUM);\r