Skip to content

Add layout-aware AltGr/Shift/base-character labels - #30

Open
kolbenhans wants to merge 1 commit into
srwi:masterfrom
kolbenhans:feature/layout-aware-altgr-labels
Open

Add layout-aware AltGr/Shift/base-character labels#30
kolbenhans wants to merge 1 commit into
srwi:masterfrom
kolbenhans:feature/layout-aware-altgr-labels

Conversation

@kolbenhans

@kolbenhans kolbenhans commented Jul 30, 2026

Copy link
Copy Markdown

Summary

KeyPeek currently renders RALT(KC_7) as "7" with a generic "Alt" badge, regardless of the user's OS keyboard layout. On a German keyboard, AltGr+7 actually produces {. This adds a Settings dropdown to resolve AltGr, explicit Shift(key) combos, and a key's own base character to what they actually produce on non-US layouts.

  • New "Keyboard layout" setting: US / German / French / Italian / Spanish
  • Resolution happens at draw time (ui_overlay.rs), so switching the dropdown while connected updates immediately, no reconnect needed
  • Covers AltGr, explicit Shift-combos, and base-character remaps (letter swaps like German Y/Z and French A/Q + W/Z, AZERTY's inverted number row, ISO-only KC_NONUS_HASH/KC_NONUS_BACKSLASH)
  • All four non-US tables are sourced directly from xkbcli compile-keymap --layout <code> (not hand-traced xkb include chains, which caused a real bug during development — see commit message)

Screenshots

menu dopdown
swappy-20260730_153651

before1
swappy-20260730_153440
after1
grafik

Test plan

  • cargo build / cargo fmt / cargo test all pass
  • Manually verified against a real Vial keyboard (Sofle) across all five layouts, iterated on real-device feedback for AltGr, Shift-combo, and base-character rendering (home-row mods, ISO keys, AZERTY letter swap, etc.)

🤖 Generated with Claude Code

KeyPeek showed "7 + Alt" for RALT(KC_7) regardless of OS keyboard
layout, when e.g. German AltGr+7 actually produces "{". Adds a
Settings dropdown (US/German/French/Italian/Spanish) that resolves
AltGr, explicit Shift(key) combos, and the key's own base character to
what they actually produce on that layout — including letter swaps
(German Y/Z, French A/Q and W/Z), AZERTY's inverted number row, and
ISO-only keys (KC_NONUS_HASH/KC_NONUS_BACKSLASH). Resolution happens
at draw time (src/overlay_window/ui_overlay.rs), so switching the
layout while connected updates immediately without reconnecting.

All four non-US tables are sourced from `xkbcli compile-keymap
--layout <code>` rather than hand-tracing xkb include chains (the
latter caused a real bug during development: an earlier manual read
picked up the wrong "type4"/default xkb variant for the German
6/7/8/9/0 shift row).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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