From e300fbed0ff878ffed9c4dd40156f9790b02193b Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Thu, 1 Mar 2018 09:42:13 -0600 Subject: [PATCH 1/3] Added a 10ms delay to work around a problem with Windows Remote Desktop --- src/MultiReport/Keyboard.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/MultiReport/Keyboard.cpp b/src/MultiReport/Keyboard.cpp index ed37a3b9..43a7ac7a 100644 --- a/src/MultiReport/Keyboard.cpp +++ b/src/MultiReport/Keyboard.cpp @@ -149,6 +149,15 @@ int Keyboard_::sendReport(void) { int returnCode = HID().SendReport(HID_REPORTID_NKRO_KEYBOARD, &lastKeyReport, sizeof(lastKeyReport)); if (returnCode < 0) lastKeyReport.modifiers = last_mods; + // For Windows Remote Desktop, the problem is even worse. Even if the modifier is sent + // in a separate report, if one or more other keycodes are added in a subsequent + // report that comes too soon (probably before the next "frame" is sent to the remote + // host), it seems that the two reports get combined, and we once again see the + // problem. So, if both a modifier keycode and a non-modified keycode have changed in + // one report, we add a delay between the modifier report (sent above) and the other + // report (sent below). 10ms seems to work well. + if (memcmp(lastKeyReport.keys, keyReport.keys, sizeof(keyReport.keys))) + delay(10); } // If the last report is different than the current report, then we need to send a report. From 3847fbb6a3886f91173b447d6acb92baecf94bb3 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Thu, 8 Mar 2018 23:31:15 -0600 Subject: [PATCH 2/3] Only use Windows Remote Desktop if compile flag is used The 10ms delay for Windows Remote Desktop is now only enabled if the compiler flag `KEYBOARDIOHID_ENABLE_WINDOWS_REMOTE_DESKTOP_WORKAROUND` is used. --- src/MultiReport/Keyboard.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/MultiReport/Keyboard.cpp b/src/MultiReport/Keyboard.cpp index 43a7ac7a..881b39ed 100644 --- a/src/MultiReport/Keyboard.cpp +++ b/src/MultiReport/Keyboard.cpp @@ -149,6 +149,8 @@ int Keyboard_::sendReport(void) { int returnCode = HID().SendReport(HID_REPORTID_NKRO_KEYBOARD, &lastKeyReport, sizeof(lastKeyReport)); if (returnCode < 0) lastKeyReport.modifiers = last_mods; + +#if defined(KEYBOARDIOHID_ENABLE_WINDOWS_REMOTE_DESKTOP_WORKAROUND) // For Windows Remote Desktop, the problem is even worse. Even if the modifier is sent // in a separate report, if one or more other keycodes are added in a subsequent // report that comes too soon (probably before the next "frame" is sent to the remote @@ -158,6 +160,8 @@ int Keyboard_::sendReport(void) { // report (sent below). 10ms seems to work well. if (memcmp(lastKeyReport.keys, keyReport.keys, sizeof(keyReport.keys))) delay(10); +#endif + } // If the last report is different than the current report, then we need to send a report. From ba8b4fa3f6de2d6b96fd61d3b73503e42040ebe0 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Mon, 12 Mar 2018 13:40:32 -0500 Subject: [PATCH 3/3] Make the Windows Remote Desktop workaround delay configurable --- src/MultiReport/Keyboard.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/MultiReport/Keyboard.cpp b/src/MultiReport/Keyboard.cpp index 881b39ed..28bfba58 100644 --- a/src/MultiReport/Keyboard.cpp +++ b/src/MultiReport/Keyboard.cpp @@ -150,16 +150,16 @@ int Keyboard_::sendReport(void) { if (returnCode < 0) lastKeyReport.modifiers = last_mods; -#if defined(KEYBOARDIOHID_ENABLE_WINDOWS_REMOTE_DESKTOP_WORKAROUND) +#if defined(KEYBOARDIOHID_MODIFIER_FLAG_DELAY) // For Windows Remote Desktop, the problem is even worse. Even if the modifier is sent // in a separate report, if one or more other keycodes are added in a subsequent // report that comes too soon (probably before the next "frame" is sent to the remote // host), it seems that the two reports get combined, and we once again see the // problem. So, if both a modifier keycode and a non-modified keycode have changed in // one report, we add a delay between the modifier report (sent above) and the other - // report (sent below). 10ms seems to work well. + // report (sent below). if (memcmp(lastKeyReport.keys, keyReport.keys, sizeof(keyReport.keys))) - delay(10); + delay(KEYBOARDIOHID_MODIFIER_FLAG_DELAY); #endif }