lib/getchar: Add configurable keyboard layout support#604
Conversation
Signed-off-by: Mintsuki <mintsuki@protonmail.com>
Adds a keyboard_layout config option currently supporting "dvorak", that remaps printable keystrokes. Documented in CONFIG.md, including the caveat that this assumes firmware resolves keystrokes as US-QWERTY.
iczelia
left a comment
There was a problem hiding this comment.
ATM, revisions are necessary (code, documentation and logic-wise). The first two have been addressed in the comments, the logic issue is more overreaching.
Nominally, your patch works on the wrong layer in the UEFI case: ascii comes from getchar.c:375, i.e. kd.Key.UnicodeChar; firmware-resolved. The table maps QWERTY -> Dvorak, but this is correct only upon the assumption that the firmware itself considers the keyboard to be US-QWERTY. If this assumption (which is not necessarily true) does not hold, then the behaviour is unintended; e.g. when the user's firmware+keyboard combo already resolves Dvorak keys.
So in principle there is no way to resolve this issue, so it should be documented.
| #include <lib/misc.h> | ||
| #include <lib/term.h> | ||
| #include <lib/print.h> | ||
| #include <lib/config.h> |
There was a problem hiding this comment.
configuration options are typically parsed in menu.c, this include was left out of lib/getchar.c for a specific purpose.
| #include <sys/cpu.h> | ||
|
|
||
|
|
||
| static int dvorak_enabled = -1; |
There was a problem hiding this comment.
Perhaps I suggest turning this into a value of an enum to support more layouts in the future (e.g. AZERTY).
| ['<']='W', ['>']='V', ['?']='Z', | ||
| }; | ||
|
|
||
| static bool keyboard_is_dvorak(void) { |
| wallpaper: ${WALLPAPER_PATH} | ||
| wallpaper_style: centered | ||
| backdrop: 008080 | ||
| keyboard_layout: dvorak |
There was a problem hiding this comment.
Please remove this line from the test configuration.
|
|
||
| static bool keyboard_is_dvorak(void) { | ||
| if(dvorak_enabled == -1) { | ||
| char *layout = config_get_value(NULL, 0, "keyboard_layout"); |
There was a problem hiding this comment.
The option is not documented in the respective markdown file.
|
Hi iczelia, |
Adds support for configurable keyboard layouts via the
keyboard_layoutconfiguration option.
This PR implements the Dvorak keyboard layout.