Skip to content

lib/getchar: Add configurable keyboard layout support#604

Merged
iczelia merged 3 commits into
Limine-Bootloader:trunkfrom
Ma4lstrom:keyboard-layout-support
Jul 4, 2026
Merged

lib/getchar: Add configurable keyboard layout support#604
iczelia merged 3 commits into
Limine-Bootloader:trunkfrom
Ma4lstrom:keyboard-layout-support

Conversation

@Ma4lstrom

Copy link
Copy Markdown
Contributor

Adds support for configurable keyboard layouts via the keyboard_layout
configuration option.

This PR implements the Dvorak keyboard layout.

Mintsuki and others added 2 commits July 2, 2026 20:49
@Ma4lstrom Ma4lstrom changed the base branch from v12.x to trunk July 3, 2026 05:10
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 iczelia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread common/lib/getchar.c Outdated
#include <lib/misc.h>
#include <lib/term.h>
#include <lib/print.h>
#include <lib/config.h>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

configuration options are typically parsed in menu.c, this include was left out of lib/getchar.c for a specific purpose.

Comment thread common/lib/getchar.c Outdated
#include <sys/cpu.h>


static int dvorak_enabled = -1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps I suggest turning this into a value of an enum to support more layouts in the future (e.g. AZERTY).

Comment thread common/lib/getchar.c Outdated
['<']='W', ['>']='V', ['?']='Z',
};

static bool keyboard_is_dvorak(void) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please move this to menu.c.

Comment thread test/limine.conf Outdated
wallpaper: ${WALLPAPER_PATH}
wallpaper_style: centered
backdrop: 008080
keyboard_layout: dvorak

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please remove this line from the test configuration.

Comment thread common/lib/getchar.c Outdated

static bool keyboard_is_dvorak(void) {
if(dvorak_enabled == -1) {
char *layout = config_get_value(NULL, 0, "keyboard_layout");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The option is not documented in the respective markdown file.

@Ma4lstrom

Copy link
Copy Markdown
Contributor Author

Hi iczelia,
Thanks for catching the UEFI firmware assumption. I've documented it as a known limitation in CONFIG.md, along with the new keyboard_layout option itself.
For sharing that state with getchar.c, I went with a global (current_keyboard_layout, exposed via menu.h). If you'd prefer a different approach there, let me know and I'll happily change it.
I’ve also made adjustments to your other comments as well.

@Ma4lstrom Ma4lstrom requested a review from iczelia July 4, 2026 00:04

@iczelia iczelia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@iczelia iczelia merged commit 0879339 into Limine-Bootloader:trunk Jul 4, 2026
2 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