Skip to content

fix(linux): map VK_ABNT_C1 to KEY_RO - #246

Merged
ReenigneArcher merged 1 commit into
LizardByte:masterfrom
NestorBrasileiro:fix/linux-abnt2-c1-key
Dec 2, 2026
Merged

ReenigneArcher merged 1 commit into
LizardByte:masterfrom
NestorBrasileiro:fix/linux-abnt2-c1-key

Conversation

@NestorBrasileiro

Copy link
Copy Markdown
Contributor

Description

The Linux backend's key_code_to_linux() table has no entry for VK_ABNT_C1 (0xC1), the dedicated / ? key on Brazilian ABNT2 keyboards. Unmapped codes return -1, so the key is rejected ("keyboard key code is not supported by the Linux backend"). The Windows backend already handles it (keylayout.hpp: 115, /* 0xc1 */).

This adds {0xC1, KEY_RO}. KEY_RO (evdev 89) is the kernel code of the ABNT2 slash key, XKB <AB11>, which symbols/br maps to slash question degree questiondown. On non-ABNT2 host layouts it lands on an unmapped position, like other layout-specific keys.

Note for Sunshine: Moonlight clients send this key as 0xE2 with SS_KBE_FLAG_NON_NORMALIZED, not as 0xC1. A companion Sunshine PR forwards that flagged 0xE2 as 0xC1 on Linux, so both pieces are needed for Moonlight users.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Testing

Unit test: added linux_key_code(0xC1) == KEY_RO to LinuxBackendTest.TranslatesKeyboardKeys.

  • Without the fix, it fails: test_linux_backend.cpp:104: Failure ... Which is: -1.
  • With the fix, it passes, and so do all 38 LinuxBackendTest.* tests (cmake-build-debug/tests/test_libvirtualhid --gtest_filter='LinuxBackendTest.*', GCC 16, Arch).

Real hardware: tested with this change plus the companion Sunshine change, built into Sunshine 2026.914.233613.

Host Omarchy 4.5 (Arch), kernel 7.2.15, Hyprland 0.56.2, XKB layout br
CPU / GPU Intel i5-7400 / GeForce GTX 1050 (driver 580.178.04)
Client Ubuntu 26.04, Moonlight v6.2.0, physical ABNT2 keyboard

xkbcli interactive-wayland on the host:

BEFORE  "/?" key      -> [ LSGT ] backslash  \
        Shift + "/?"  -> [ LSGT ] bar        |
        "\|" key      -> [ LSGT ] backslash  \
AFTER   "/?" key      -> [ AB11 ] slash      /
        Shift + "/?"  -> [ AB11 ] question   ?
        "\|" key      -> [ LSGT ] backslash  \   (unchanged)

Not run: the Windows/macOS builds and the full CI matrix. The change is limited to the Linux table and its test.

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Tests have been added or updated for new or modified functionality, including regression tests for bug fixes

AI Usage

See our AI usage policy.

  • AI tools were used while preparing this PR

Claude Code diagnosed the key path (Moonlight → Sunshine → libvirtualhid → XKB), wrote the change and test, and ran the local validation. I tested the result on my own hardware and ABNT2 keyboard.


Generated with Claude Code (agent) using Claude Opus 5.5 (claude-opus-5-5), thinking level: low.

🤖 Generated with Claude Code

The dedicated "/ ?" key on Brazilian ABNT2 keyboards is VK_ABNT_C1
(0xC1). The Linux keyboard table had no entry for it, so the key was
rejected as unsupported. Map it to KEY_RO, the evdev code that XKB
exposes as <AB11> and the br layout binds to slash/question.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Dec 2, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

@NestorBrasileiro

Copy link
Copy Markdown
Contributor Author

Companion Sunshine PR (forwards Moonlight's flagged 0xE2 as 0xC1 on Linux): SunshineStream/Sunshine#6217

@codecov

codecov Bot commented Dec 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.69%. Comparing base (acb6202) to head (25d15b2).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #246      +/-   ##
==========================================
- Coverage   73.70%   73.69%   -0.02%     
==========================================
  Files          45       45              
  Lines        9940     9940              
  Branches     3706     3706              
==========================================
- Hits         7326     7325       -1     
  Misses       2232     2232              
- Partials      382      383       +1     
Flag Coverage Δ
FreeBSD 53.88% <ø> (ø)
Linux-Clang 68.62% <ø> (-0.02%) ⬇️
Linux-GCC 80.89% <ø> (ø)
PowerShell 78.60% <ø> (ø)
Windows-MSVC 73.70% <ø> (+0.01%) ⬆️
Windows-MinGW-UCRT64 66.37% <ø> (-0.04%) ⬇️
macOS 51.29% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/platform/linux/uhid_backend.cpp 81.04% <ø> (-0.06%) ⬇️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update acb6202...25d15b2. Read the comment docs.

@ReenigneArcher
ReenigneArcher merged commit bef56ce into LizardByte:master Dec 2, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants