Add option to always send scancodes

Default is enabled to match v0.19.1 behavior

Fixes #1233
This commit is contained in:
Cameron Gutman 2023-05-24 22:55:44 -05:00
parent 0f1dc1bb05
commit 2f4cc9ace0
5 changed files with 51 additions and 1 deletions

View File

@ -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
^^^^^^^^^^^

View File

@ -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;

View File

@ -109,6 +109,8 @@ namespace config {
bool keyboard;
bool mouse;
bool controller;
bool always_send_scancodes;
};
namespace flag {

View File

@ -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);
}

View File

@ -438,6 +438,27 @@
This configurable option supports decimals
</div>
</div>
<!-- Always send scancodes -->
<div class="mb-3" v-if="platform === 'windows'">
<label for="always_send_scancodes" class="form-label"
>Always Send Scancodes</label
>
<select
id="always_send_scancodes"
class="form-select"
v-model="config.always_send_scancodes"
>
<option value="disabled">Disabled</option>
<option value="enabled">Enabled</option>
</select>
<div class="form-text">
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.<br />
Enable if keyboard input is not working at all in certain applications.<br />
Disable if keys on the client are generating the wrong input on the host.
</div>
</div>
</div>
<!--Files Tab-->
<div v-if="currentTab === 'av'" class="config-page">
@ -997,6 +1018,7 @@
<script>
// create dictionary for defaultConfig
const defaultConfig = {
"always_send_scancodes": "enabled",
"amd_coder": "auto",
"amd_preanalysis": "disabled",
"amd_quality": "balanced",