Skip to content

input/w32: add --input-layout-independent option - #18812

Open
soredake wants to merge 1 commit into
mpv-player:masterfrom
soredake:layout-independent-keybindings
Open

soredake wants to merge 1 commit into
mpv-player:masterfrom
soredake:layout-independent-keybindings

Conversation

@soredake

Copy link
Copy Markdown
Contributor

On Windows, key input is translated with ToUnicode according to the currently active keyboard layout, so bindings only work while the active layout produces the bound characters. With a non-latin layout active, letter bindings stop working and users have to switch layouts just to control the player (#351).

Add --input-layout-independent (disabled by default). When enabled, virtual keys are translated with ToUnicodeEx using the US English layout HKL, so bindings follow the letters engraved on the physical keys regardless of the active layout, similar to how Ctrl+C/Ctrl+V behave in most GUI software.

Notes:

  • Injected unicode input (WM_CHAR/WM_UNICHAR) is unaffected.
  • AltGr combinations translate to the underlying US key instead of layout-specific symbols; documented with the option.
  • If the US English layout cannot be loaded, a warning is logged once and input falls back to the active layout.

Implements the Windows part of #351.

Tested on Windows 11 x64 with Russian and Ukrainian layouts active, both option states, via --input-test with a CI-built binary of this commit.

Disclosure: this change and pull request were prepared with the assistance of the ZCode agent running the GLM-5.3-Flash model, at the direction of the human author.

@soredake
soredake force-pushed the layout-independent-keybindings branch from 8361e0e to 4c397ef Compare November 11, 2026 15:18
@soredake
soredake marked this pull request as draft November 12, 2026 18:57
On Windows, keyboard input is translated with ToUnicode according to the
currently active keyboard layout, so keybindings only work when the
layout produces the bound characters (e.g. bindings stop working when a
non-latin layout is active). This fixes the Windows part of mpv-player#351.

Add an option (disabled by default) that translates virtual keys as if
the US English layout was active by using ToUnicodeEx with the HKL of
the US English layout. Virtual key codes already follow the letters
engraved on the physical keys, so this makes bindings match the
physical keys regardless of the active layout, similar to how Ctrl+C /
Ctrl+V behave in most GUI software.

Injected unicode input (WM_CHAR/WM_UNICHAR) is unaffected and keeps
working as before. If the US English layout cannot be loaded, input
falls back to translation with the active layout and a warning is
logged once. AltGr combinations follow the US layout as well, which is
documented along with the option.
@soredake
soredake force-pushed the layout-independent-keybindings branch from 4c397ef to b68ccb0 Compare November 13, 2026 07:00
@soredake
soredake marked this pull request as ready for review November 13, 2026 07:44
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.

1 participant