Send out the mouse position and wheel values continuously if the report is not zeros, but only send the mouse button states when they change
This commit is contained in:
@@ -408,33 +408,29 @@ void UpdateUsbReports(void)
|
|||||||
|
|
||||||
updateActiveUsbReports();
|
updateActiveUsbReports();
|
||||||
|
|
||||||
bool HasUsbBasicKeyboardReportChanged = false;
|
bool HasUsbBasicKeyboardReportChanged = memcmp(ActiveUsbBasicKeyboardReport, GetInactiveUsbBasicKeyboardReport(), sizeof(usb_basic_keyboard_report_t)) != 0;
|
||||||
if (memcmp(ActiveUsbBasicKeyboardReport, GetInactiveUsbBasicKeyboardReport(), sizeof(usb_basic_keyboard_report_t)) != 0) {
|
if (HasUsbBasicKeyboardReportChanged) {
|
||||||
HasUsbBasicKeyboardReportChanged = true;
|
|
||||||
UsbBasicKeyboardAction();
|
UsbBasicKeyboardAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasUsbMediaKeyboardReportChanged = false;
|
bool HasUsbMediaKeyboardReportChanged = memcmp(ActiveUsbMediaKeyboardReport, GetInactiveUsbMediaKeyboardReport(), sizeof(usb_media_keyboard_report_t)) != 0;
|
||||||
if (memcmp(ActiveUsbMediaKeyboardReport, GetInactiveUsbMediaKeyboardReport(), sizeof(usb_media_keyboard_report_t)) != 0) {
|
if (HasUsbMediaKeyboardReportChanged) {
|
||||||
HasUsbMediaKeyboardReportChanged = true;
|
|
||||||
UsbMediaKeyboardAction();
|
UsbMediaKeyboardAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasUsbSystemKeyboardReportChanged = false;
|
bool HasUsbSystemKeyboardReportChanged = memcmp(ActiveUsbSystemKeyboardReport, GetInactiveUsbSystemKeyboardReport(), sizeof(usb_system_keyboard_report_t)) != 0;
|
||||||
if (memcmp(ActiveUsbSystemKeyboardReport, GetInactiveUsbSystemKeyboardReport(), sizeof(usb_system_keyboard_report_t)) != 0) {
|
if (HasUsbSystemKeyboardReportChanged) {
|
||||||
HasUsbSystemKeyboardReportChanged = true;
|
|
||||||
UsbSystemKeyboardAction();
|
UsbSystemKeyboardAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send out the report continuously if the report was not zeros
|
// Send out the mouse position and wheel values continuously if the report is not zeros, but only send the mouse button states when they change.
|
||||||
bool HasUsbMouseReportChanged = false;
|
bool HasUsbMouseReportChanged = memcmp(ActiveUsbMouseReport, GetInactiveUsbMouseReport(), sizeof(usb_mouse_report_t)) != 0;
|
||||||
uint8_t zeroBuf[sizeof(usb_mouse_report_t)] = { 0 };
|
if (HasUsbMouseReportChanged || ActiveUsbMouseReport->x || ActiveUsbMouseReport->y ||
|
||||||
if (memcmp(ActiveUsbMouseReport, zeroBuf, sizeof(usb_mouse_report_t)) != 0) {
|
ActiveUsbMouseReport->wheelX || ActiveUsbMouseReport->wheelY) {
|
||||||
HasUsbMouseReportChanged = true;
|
|
||||||
usbMouseAction();
|
usbMouseAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((previousLayer != LayerId_Base || HasUsbBasicKeyboardReportChanged || HasUsbMediaKeyboardReportChanged || HasUsbSystemKeyboardReportChanged || HasUsbMouseReportChanged) && IsHostSleeping) {
|
if (IsHostSleeping && (previousLayer != LayerId_Base || HasUsbBasicKeyboardReportChanged || HasUsbMediaKeyboardReportChanged || HasUsbSystemKeyboardReportChanged || HasUsbMouseReportChanged)) {
|
||||||
WakeUpHost(true); // Wake up the host if any key is pressed and the computer is sleeping.
|
WakeUpHost(true); // Wake up the host if any key is pressed and the computer is sleeping.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user