diff --git a/CONFIG.md b/CONFIG.md index 45ee6236..a2f79cdb 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -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: diff --git a/common/lib/getchar.c b/common/lib/getchar.c index 7a135187..92469844 100644 --- a/common/lib/getchar.c +++ b/common/lib/getchar.c @@ -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 (;;) { @@ -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; diff --git a/common/lib/libc.s2.c b/common/lib/libc.s2.c index acd2c8e0..9def8660 100644 --- a/common/lib/libc.s2.c +++ b/common/lib/libc.s2.c @@ -5,7 +5,7 @@ #include bool isprint(int c) { - return c >= ' ' && c <= '~'; + return c >= ' ' && c <= 0xff && c != 0x7f; } bool isspace(int c) { diff --git a/common/menu.c b/common/menu.c index bc81a0eb..06b9b240 100644 --- a/common/menu.c +++ b/common/menu.c @@ -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; } diff --git a/common/menu.h b/common/menu.h index d80c5f77..bc8236b7 100644 --- a/common/menu.h +++ b/common/menu.h @@ -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;