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.

pull/1469/head
Dean Camera 16 years ago
parent 7184153e5d
commit ee7bd5685e

@ -385,8 +385,9 @@ void ProcessLEDReport(uint8_t LEDReport)
/** Sends the next HID report to the host, via the keyboard data endpoint. */ /** Sends the next HID report to the host, via the keyboard data endpoint. */
static inline void SendNextReport(void) static inline void SendNextReport(void)
{ {
USB_KeyboardReport_Data_t KeyboardReportData; static USB_KeyboardReport_Data_t PrevKeyboardReportData;
bool SendReport = true; USB_KeyboardReport_Data_t KeyboardReportData;
bool SendReport = true;
/* Create the next keyboard report for transmission to the host */ /* Create the next keyboard report for transmission to the host */
CreateKeyboardReport(&KeyboardReportData); CreateKeyboardReport(&KeyboardReportData);
@ -402,11 +403,14 @@ static inline void SendNextReport(void)
} }
else else
{ {
/* Idle period not elapsed, indicate that a report must not be sent */ /* Idle period not elapsed, indicate that a report must not be sent unless the report has changed */
SendReport = false; 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 */ /* Select the Keyboard Report Endpoint */
Endpoint_SelectEndpoint(KEYBOARD_EPNUM); Endpoint_SelectEndpoint(KEYBOARD_EPNUM);

@ -337,8 +337,9 @@ void CreateMouseReport(USB_MouseReport_Data_t* ReportData)
/** Sends the next HID report to the host, via the keyboard data endpoint. */ /** Sends the next HID report to the host, via the keyboard data endpoint. */
static inline void SendNextReport(void) static inline void SendNextReport(void)
{ {
USB_MouseReport_Data_t MouseReportData; static USB_MouseReport_Data_t PrevMouseReportData;
bool SendReport = true; USB_MouseReport_Data_t MouseReportData;
bool SendReport = true;
/* Create the next mouse report for transmission to the host */ /* Create the next mouse report for transmission to the host */
CreateMouseReport(&MouseReportData); CreateMouseReport(&MouseReportData);
@ -354,10 +355,13 @@ static inline void SendNextReport(void)
} }
else else
{ {
/* Idle period not elapsed, indicate that a report must not be sent */ /* Idle period not elapsed, indicate that a report must not be sent unless the report has changed */
SendReport = false; 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 */ /* Select the Mouse Report Endpoint */
Endpoint_SelectEndpoint(MOUSE_EPNUM); Endpoint_SelectEndpoint(MOUSE_EPNUM);

Loading…
Cancel
Save