Repository navigation
fix(linux/input): send the ABNT2 slash key as VK_ABNT_C1 - #6217
NestorBrasileiro wants to merge 1 commit into
Conversation
Moonlight sends the dedicated "/ ?" key of ABNT2 keyboards as VK_OEM_102 (0xE2) with SS_KBE_FLAG_NON_NORMALIZED. Windows honors the flag, but on Linux the flags were discarded, so the key became KEY_102ND and typed "\" like the real "\ |" key. Forward the flagged code as VK_ABNT_C1 (0xC1) on non-Windows hosts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
ReenigneArcher
left a comment
There was a problem hiding this comment.
The ABNT2 translation can override an explicit Sunshine keybindings target. The inline finding shows how to apply the compatibility rule only to an original client key with no configured mapping.
git diff --check passed. Isolated tests exercised the target, PR, and proposed ordering. GitHub Actions is awaiting maintainer approval, so the hosted build and test results are unavailable.
Review completed by Codex | Model: gpt-6.2-sol | Thinking: xhigh
| (void) flags; | ||
| constexpr std::uint16_t vk_oem_102 = 0xE2; | ||
| constexpr std::uint16_t vk_abnt_c1 = 0xC1; | ||
| if (modcode == vk_oem_102 && non_normalized) { |
There was a problem hiding this comment.
[P2] Preserve explicit bindings to VK_OEM_102
keyboard_event() receives the result of map_keycode(). On a Linux host, keybindings = [0xDC, 0xE2] turns a non-normalized 0xDC into the ISO key on master. With this change the same press and release become 0xC1, which emits a different physical key even with the updated libvirtualhid. Moonlight Qt can send a flagged 0xDC from SDL_SCANCODE_INTERNATIONAL3.
Move the compatibility rule into map_keycode() in src/input.cpp, below the explicit binding lookup:
short map_keycode(short keycode, std::uint8_t flags) {
if (auto it = config::input.keybindings.find(keycode); it != std::end(config::input.keybindings)) {
return it->second;
}
#ifndef _WIN32
constexpr short vk_oem_102 = 0xE2;
constexpr short vk_abnt_c1 = 0xC1;
if (keycode == vk_oem_102 && (flags & SS_KBE_FLAG_NON_NORMALIZED) != 0) {
return vk_abnt_c1;
}
#else
(void) flags;
#endif
return keycode;
}Pass flags from send_key_and_modifiers() and flags_from_kpid(key) from reset_keyboard_keys(). Update map_keycode()'s @param docs and restore the original non-Windows branch of keyboard_event(). Move the ABNT2 assertions to KeyboardPassthroughTest in tests/unit/test_keyboard.cpp. Using the fake keyboard, cover a flagged 0xDC bound to 0xE2 on press and release, plus a raw flagged 0xE2 with no binding. An isolated Clang harness reproduced the regression and verified the proposed ordering. The full Sunshine test binary was unavailable locally.
Review completed by Codex | Model: gpt-6.2-sol | Thinking: xhigh



Description
On Linux hosts, the dedicated
/ ?key of a Brazilian ABNT2 keyboard types\(and|with Shift) instead of/and?.Root cause. Moonlight doesn't send this key as
VK_ABNT_C1(0xC1). In moonlight-qtapp/streaming/input/keyboard.cpp,SDL_SCANCODE_INTERNATIONAL1falls through toSDL_SCANCODE_NONUSBACKSLASHwithkeyCode = 0xE2(VK_OEM_102) and setsshouldNotConvertToScanCodeOnServer, i.e.SS_KBE_FLAG_NON_NORMALIZED. Windows hosts honor that flag. On other platformskeyboard_event()discarded the flags ((void) flags;), so both ABNT2 keys reached the host asKEY_102NDand couldn't be told apart.Change. On non-Windows hosts, a
0xE2key event withSS_KBE_FLAG_NON_NORMALIZEDis forwarded as0xC1. Unflagged0xE2(the real\ |key) and all other keys are unchanged. The Windows path is functionally the same (the flag test is just hoisted into a local).Dependency. libvirtualhid's Linux backend needs a
0xC1 → KEY_ROmapping: LizardByte/libvirtualhid#246. Until the submodule includes it, a flagged0xE2would be rejected by libvirtualhid instead of typing\. So this should land together with, or after, the submodule bump.Screenshot
Issues Fixed or Closed
/ ?key) — key is silently dropped #6051 (together with fix(linux): map VK_ABNT_C1 to KEY_RO LizardByte/libvirtualhid#246)Roadmap Issues
Testing
Unit test: extended
VirtualHidDeviceTest.TranslatesMouseAndKeyboardInput(non-Windows branch). A flagged0xE2must be submitted as0xC1, an unflagged0xE2must stay0xE2, and0x41with all flags set keeps its code.test_virtualhid_input.cpp:874: Failure ... Which is: 226 / Which is: 193.--gtest_filter='*VirtualHid*:*virtualhid*', Linux, GCC 16,-DSUNSHINE_ENABLE_CUDA=OFF).uv run --locked lb-update-clang-formatproduced no changes to the touched files.Real hardware: I tested the same change backported to 2026.914.233613 (built with CUDA 12.9 for a Pascal GPU), together with the libvirtualhid patch.
capture = wlr, XKB layoutbrxkbcli interactive-waylandon the host:Not run: Windows/macOS/FreeBSD builds and the full CI matrix.
Type of Change
Checklist
AI Usage
See our AI usage policy.
Claude Code traced the key path (moonlight-qt → Sunshine → libvirtualhid → XKB), wrote the change, test and docs, and ran the local checks. I tested the result on my own hardware and ABNT2 keyboard.
🤖 Generated with Claude Code