Skip to content

feat: opt-in Windows layout-aware shortcut chords - #269

Open
Guffawaffle wants to merge 2 commits into
netniV:devfrom
Guffawaffle:feature/layout-aware-letter-shortcuts
Open

feat: opt-in Windows layout-aware shortcut chords#269
Guffawaffle wants to merge 2 commits into
netniV:devfrom
Guffawaffle:feature/layout-aware-letter-shortcuts

Conversation

@Guffawaffle

@Guffawaffle Guffawaffle commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Configured punctuation now follows the active Windows keyboard layout, including the Shift needed to type it. For example, / uses Shift+7 on German and CTRL-' uses Ctrl+Shift+#. Letters follow the active layout too. Physical mode remains the default.

[control]
keyboard_layout_mode = "layout"

Restart once after changing the setting. Subsequent layout changes apply live. Hints and generated shortcut values retain the configured TOML text.

Implementation

  • Windows x64 only: native character-to-key translation, supported scan-code positions and a non-composing fallback for unshifted dead keys.
  • Cache each requested character's physical key and required Shift. Rebuild at initialization or on Unity device notifications; no layout polling, extra timer or new detour.
  • Retain transition-frame and held-key suppression. Notification failure disables layout bindings until restart; unresolved characters are disabled individually.
  • Preserve explicit modifier matching and named controls. Characters requiring inferred Ctrl/Alt/AltGr remain unsupported.
  • One user setting, compact runtime mapping status and per-character failure logs. No prototype preview machinery, detailed diagnostic toggle or legacy setting alias.
  • macOS retains default physical behavior. Explicit layout mode reports unsupported and disables printable bindings; macOS layout support is deferred.

German experimental shortcuts

Alliance Help and Armada retain upstream's enable_experimental = true requirement. The default Help SHIFT-' shadows default Armada CTRL-' on German because apostrophe already requires Shift and existing modified shortcuts accept extra modifiers. Use this tested configuration in the existing sections:

[control]
keyboard_layout_mode = "layout"
enable_experimental = true

[shortcuts]
show_alliance = "ALT-^"
show_alliance_help = "SHIFT-^"
show_alliance_armada = "CTRL-'"

On a German keyboard, Armada is Ctrl+Shift+#, using the # key beside Enter. This documents the overlap without changing upstream shortcut defaults or modifier priority.

Validation

  • Rebuilt from netniV dev 2915f4f; final head e8a4883.
  • Final Windows release build and native chord, mapping/transition, and production-linked dispatch/hint suites pass. Releasedbg build and tests also passed during reconstruction.
  • Three independent review lanes accepted the final correction. Tests cover the default German overlap and documented remap.
  • Exact final release DLL deployed with verified hash. User confirmed German Shift+7, Alliance, Help and Armada, followed by US Ctrl+apostrophe. Logs confirm US → German → US notification refresh.
  • git diff --check passes. Remote CI is tracked separately.
  • Remaining runtime gaps: held-key switching, keyboard reconnection and notification-failure injection. Held-key behavior is covered by fixtures; no macOS runtime support is claimed.

See layout behavior and configuration.

@netniV netniV left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like overkill. If the unity engine is capable of working both ways, we should be simply following what the game currently does. If we should override that, it is surely as simple as updating which mode it's operating in?

Additionally, we are resolving shortcuts during a keyframe in the key functions adding overhead.

Keyboard layouts change by nationality in more ways than just the alphabetic keys.

@netniV

netniV commented Sep 6, 2026

Copy link
Copy Markdown
Owner

@Guffawaffle

Copy link
Copy Markdown
Contributor Author

Ooo, I'll dig into this—thanks for the pointer! You're right, I should keep it slimmer, as always 😄

This already uses Unity's FindKeyOnCurrentKeyboardLayout to bridge layout-aware letters into our existing KeyCode polling, so configured Z follows the active layout. But the docs point to a cleaner change-notification approach that could move the layout checks out of the shortcut-query path. I'll investigate that, along with whether there's a simpler mode-setting option available to us.

A–Z was deliberately the first slice, but fair point that layouts differ beyond letters too. I'll keep that distinction explicit while slimming this down.

@Guffawaffle
Guffawaffle marked this pull request as draft September 7, 2026 00:32
@Guffawaffle Guffawaffle changed the title feat: opt-in layout-aware letter shortcuts feat: opt-in layout-aware shortcut keys Sep 7, 2026
Comment thread tests/shortcut_hint_cache.cc Outdated
Comment thread tests/shortcut_hint_cache.cc
@Guffawaffle
Guffawaffle marked this pull request as ready for review September 7, 2026 07:53
@Guffawaffle
Guffawaffle marked this pull request as draft September 8, 2026 02:25
@Guffawaffle
Guffawaffle force-pushed the feature/layout-aware-letter-shortcuts branch from 3b229c6 to e8a4883 Compare September 10, 2026 03:58
@Guffawaffle Guffawaffle changed the title feat: opt-in layout-aware shortcut keys feat: opt-in Windows layout-aware shortcut chords Sep 10, 2026
@Guffawaffle
Guffawaffle marked this pull request as ready for review September 11, 2026 20:54
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.

2 participants