Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The following are the authors/maintainers of Limine with the rights to push commits to trunk and create
releases signed with their GPG keys.

- Mintsuki, GPG ID 05D29860D0A0668AAEFB9D691F3C021BECA23821.
- Iczelia (Kamila Szewczyk), GPG ID 6C222EA6B2BD216AA406516AC868F0B6DE38409D.

6 changes: 6 additions & 0 deletions CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ Miscellaneous:
"displayed" status bit in the ACPI BGRT table so the OS redraws the logo
itself. The image is re-centred for the active resolution. UEFI only;
defaults to `no`.
* `keyboard_layout` - Specifies a keyboard layout to remap printable
keystrokes to before they reach the menu and editor. Currently only
`dvorak` is supported. If unset, no remapping is applied and keystrokes
are used as-is. This assumes the underlying firmware resolves keystrokes
as US-QWERTY; on firmware/keyboard combinations that already resolve a
different layout natively, this option may produce incorrect output.

Limine interface control options:

Expand Down
25 changes: 25 additions & 0 deletions common/lib/getchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <lib/misc.h>
#include <lib/term.h>
#include <lib/print.h>
#include <menu.h>
#if defined (BIOS)
# include <lib/real.h>
#elif defined (UEFI)
Expand All @@ -13,6 +14,25 @@
#include <drivers/serial.h>
#include <sys/cpu.h>

static const char qwerty_to_dvorak[128] = {
['q']='\'', ['w']=',', ['e']='.', ['r']='p', ['t']='y',
['y']='f', ['u']='g', ['i']='c', ['o']='r', ['p']='l',
['[']='/', [']']='=', ['\\']='\\', ['a']='a', ['s']='o',
['d']='e', ['f']='u', ['g']='i', ['h']='d', ['j']='h',
['k']='t', ['l']='n', [';']='s', ['\'']='-', ['z']=';', ['x']='q',
['c']='j', ['v']='k', ['b']='x', ['n']='b', ['m']='m',
[',']='w', ['.']='v', ['/']='z',

['Q']='\"', ['W']='<', ['E']='>', ['R']='P', ['T']='Y',
['Y']='F', ['U']='G', ['I']='C', ['O']='R', ['P']='L',
['{']='?', ['}']='+', ['|']='|', ['A']='A', ['S']='O',
['D']='E', ['F']='U', ['G']='I', ['H']='D', ['J']='H',
['K']='T', ['L']='N', [':']='S', ['"']='_', ['Z']=':', ['X']='Q',
['C']='J', ['V']='K', ['B']='X', ['N']='B', ['M']='M',
['<']='W', ['>']='V', ['?']='Z',
};


int getchar(void) {
for (;;) {
int ret = pit_sleep_and_quit_on_keypress(65535);
Expand Down Expand Up @@ -104,6 +124,11 @@ int getchar_internal(uint8_t scancode, uint8_t ascii, uint32_t shift_state) {
if (ascii < 0x20 || ascii > 0x7e) {
return -1;
}

if (current_keyboard_layout == KEYBOARD_LAYOUT_DVORAK && qwerty_to_dvorak[(uint8_t)ascii] != 0) {
return qwerty_to_dvorak[(uint8_t)ascii];
}

return ascii;
}

Expand Down
13 changes: 12 additions & 1 deletion common/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ static char menu_branding_colour[24] = "\e[38;2;0;170;170m";

static char *menu_branding = NULL;

enum keyboard_layout current_keyboard_layout = KEYBOARD_LAYOUT_UNKNOWN;

static void keyboard_layout_init(void) {
char *layout = config_get_value(NULL, 0, "keyboard_layout");
if (layout != NULL && strcasecmp(layout, "dvorak") == 0) {
current_keyboard_layout = KEYBOARD_LAYOUT_DVORAK;
} else {
current_keyboard_layout = KEYBOARD_LAYOUT_QWERTY;
}
}

static char *append_uint_dec(char *p, uint64_t val) {
char buf[20];
size_t i = 0;
Expand Down Expand Up @@ -1161,7 +1172,7 @@ static void menu_init_term(void) {
#elif defined (UEFI)
char *graphics = "yes";
#endif

keyboard_layout_init();
if (graphics == NULL || strcmp(graphics, "no") != 0) {
size_t req_width = 0, req_height = 0, req_bpp = 0;

Expand Down
8 changes: 8 additions & 0 deletions common/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ char *config_entry_editor(const char *title, const char *orig_entry);

extern bool booting_from_editor;

enum keyboard_layout {
KEYBOARD_LAYOUT_UNKNOWN = -1,
KEYBOARD_LAYOUT_QWERTY,
KEYBOARD_LAYOUT_DVORAK,
};

extern enum keyboard_layout current_keyboard_layout;

#endif