Ensure that the Keyboard and Mouse demos adhere to the boot protocol specification...
[pub/USBasp.git] / Demos / Mouse / Mouse.c
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
 /** 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
        \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
                }\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
        }\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
        \r
        /* Select the Mouse Report Endpoint */\r
        Endpoint_SelectEndpoint(MOUSE_EPNUM);\r