/** 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
}\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
/** 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
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