From 2f4cc9ace0b4ce43056aaad74544a319f24b4f06 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 24 May 2023 22:55:44 -0500 Subject: [PATCH] Add option to always send scancodes Default is enabled to match v0.19.1 behavior Fixes #1233 --- docs/source/about/advanced_usage.rst | 21 +++++++++++++++++++++ src/config.cpp | 3 +++ src/config.h | 2 ++ src/platform/windows/input.cpp | 4 +++- src_assets/common/assets/web/config.html | 22 ++++++++++++++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/docs/source/about/advanced_usage.rst b/docs/source/about/advanced_usage.rst index 32c52ff4..61277e77 100644 --- a/docs/source/about/advanced_usage.rst +++ b/docs/source/about/advanced_usage.rst @@ -200,6 +200,27 @@ key_repeat_frequency key_repeat_frequency = 24.9 +always_send_scancodes +^^^^^^^^^^^^^^^^^^^^^ + +**Description** + Sending scancodes enhances compatibility with games and apps but may result in incorrect keyboard input + from certain clients that aren't using a US English keyboard layout. + + Enable if keyboard input is not working at all in certain applications. + + Disable if keys on the client are generating the wrong input on the host. + + .. Caution:: Applies to Windows only. + +**Default** + ``enabled`` + +**Example** + .. code-block:: text + + always_send_scancodes = enabled + keybindings ^^^^^^^^^^^ diff --git a/src/config.cpp b/src/config.cpp index d723fa06..585bbc37 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -441,6 +441,7 @@ namespace config { true, // keyboard enabled true, // mouse enabled true, // controller enabled + true, // always send scancodes }; sunshine_t sunshine { @@ -1039,6 +1040,8 @@ namespace config { bool_f(vars, "keyboard", input.keyboard); bool_f(vars, "controller", input.controller); + bool_f(vars, "always_send_scancodes", input.always_send_scancodes); + int port = sunshine.port; int_f(vars, "port"s, port); sunshine.port = (std::uint16_t) port; diff --git a/src/config.h b/src/config.h index 39cfcfac..2c32e7af 100644 --- a/src/config.h +++ b/src/config.h @@ -109,6 +109,8 @@ namespace config { bool keyboard; bool mouse; bool controller; + + bool always_send_scancodes; }; namespace flag { diff --git a/src/platform/windows/input.cpp b/src/platform/windows/input.cpp index d0b55210..c9490426 100644 --- a/src/platform/windows/input.cpp +++ b/src/platform/windows/input.cpp @@ -350,7 +350,9 @@ namespace platf { auto &ki = i.ki; // If the client did not normalize this VK code to a US English layout, we can't accurately convert it to a scancode. - if (!(flags & SS_KBE_FLAG_NON_NORMALIZED) && modcode != VK_LWIN && modcode != VK_RWIN && modcode != VK_PAUSE && raw->keyboard_layout != NULL) { + bool send_scancode = !(flags & SS_KBE_FLAG_NON_NORMALIZED) || config::input.always_send_scancodes; + + if (send_scancode && modcode != VK_LWIN && modcode != VK_RWIN && modcode != VK_PAUSE && raw->keyboard_layout != NULL) { // For some reason, MapVirtualKey(VK_LWIN, MAPVK_VK_TO_VSC) doesn't seem to work :/ ki.wScan = MapVirtualKeyEx(modcode, MAPVK_VK_TO_VSC, raw->keyboard_layout); } diff --git a/src_assets/common/assets/web/config.html b/src_assets/common/assets/web/config.html index 3889eced..9878802d 100644 --- a/src_assets/common/assets/web/config.html +++ b/src_assets/common/assets/web/config.html @@ -438,6 +438,27 @@ This configurable option supports decimals + +
+ + +
+ Sending scancodes enhances compatibility with games and apps + but may result in incorrect keyboard input from certain clients + that aren't using a US English keyboard layout.
+ Enable if keyboard input is not working at all in certain applications.
+ Disable if keys on the client are generating the wrong input on the host. +
+
@@ -997,6 +1018,7 @@