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
9 changes: 5 additions & 4 deletions CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ Miscellaneous:
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.
`dvorak` and `azerty` are 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
35 changes: 35 additions & 0 deletions common/lib/getchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,41 @@ static const char qwerty_to_dvorak[128] = {
['K']='T', ['L']='N', [':']='S', ['"']='_', ['Z']=':', ['X']='Q',
['C']='J', ['V']='K', ['B']='X', ['N']='B', ['M']='M',
['<']='W', ['>']='V', ['?']='Z',

['`']='`', ['1']='1', ['2']='2', ['3']='3', ['4']='4',
['5']='5', ['6']='6', ['7']='7', ['8']='8', ['9']='9',
['0']='0', ['-']='[', ['=']=']',

['~']='~', ['!']='!', ['@']='@', ['#']='#', ['$']='$',
['%']='%', ['^']='^', ['&']='&', ['*']='*', ['(']='(',
[')']=')', ['_']='{', ['+']='}',
};

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

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

['`']='\xB2', ['1']='&', ['2']='\xE9', ['3']='\"', ['4']='\'',
['5']='(', ['6']='-', ['7']='\xE8', ['8']='_', ['9']='\xE7',
['0']='\xE0', ['-']=')', ['=']='=',

['!']='1', ['@']='2', ['#']='3', ['$']='4', ['%']='5',
['^']='6', ['&']='7', ['*']='8', ['(']='9', [')']='0',
['_']='\xB0', ['+']='+',
};

int getchar(void) {
for (;;) {
Expand Down Expand Up @@ -127,6 +160,8 @@ int getchar_internal(uint8_t scancode, uint8_t ascii, uint32_t shift_state) {

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

return ascii;
Expand Down
2 changes: 1 addition & 1 deletion common/lib/libc.s2.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <lib/misc.h>

bool isprint(int c) {
return c >= ' ' && c <= '~';
return c >= ' ' && c <= 0xff && c != 0x7f;
}

bool isspace(int c) {
Expand Down
2 changes: 2 additions & 0 deletions common/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ 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 if (layout != NULL && strcasecmp(layout, "azerty") == 0) {
current_keyboard_layout = KEYBOARD_LAYOUT_AZERTY;
} else {
current_keyboard_layout = KEYBOARD_LAYOUT_QWERTY;
}
Expand Down
1 change: 1 addition & 0 deletions common/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum keyboard_layout {
KEYBOARD_LAYOUT_UNKNOWN = -1,
KEYBOARD_LAYOUT_QWERTY,
KEYBOARD_LAYOUT_DVORAK,
KEYBOARD_LAYOUT_AZERTY,
};

extern enum keyboard_layout current_keyboard_layout;
Expand Down