Patch for German keyboard layout for the at_keyboard input
Dear team at grub-devel,
First of all I would like to thank you for the Grand boot loader, your work is very much appreciated.
Recently I downloaded the current grub-2.02-beta3 and started experimenting with it. I am am making use of the luks module in GRUB to provide my clients with fully encrypted harddrives. Since my clients are German, and I keep telling them that strong passwords should contain special characters, I ended up modifying the default keyboard layout for the at_keyboard.c input driver. I provided the diff in keylayouts.c.diff, if you want to make use of it. The support for German keys is only partial, since some of the German keys are non-ASCII.
Also I patched at_keyboard.c. It has a minor typo, in line 91 both scancode 0x52 and 0x53 are mapped to the same GRUB_KEYBOARD_KEY_NUMDOT. This is wrong, scancode 0x52 has to be mapped to GRUB_KEYBOARD_KEY_NUM0 (as that's what it is).
Last but not least, parsing through include/grub/keyboard_layouts.h, I realized that the enumeration of GRUB_KEYBOARD_KEY_* is skipping value 0x31:
Quoted 2 lines
GRUB_KEYBOARD_KEY_RBRACKET=0x30,
GRUB_KEYBOARD_KEY_BACKSLASH=0x32,
I do not know why this is the case, but from my point of view this probably lead to the following comment ( in grub-core/commands/keylayouts.c ):
Quoted 3 lines
/* According to usage table
0x31should be mapped to '/'but testing with real keyboard shows that 0x32 is remapped to '/'. Map 0x31 to 0.
Cleaning up the enumeration would do some good, I guess.
Find attached both aformentioned patches. I'll be glad help out if you deem it appropriate to, e.g. make the support for German at_keyboard layout a configurable option.
Regards, Frank
keylayouts.c renamed from keylayouts.c.orig +61 -13
@@ -30,7 +30,7 @@GRUB_MOD_LICENSE ("GPLv3+" ); -static struct grub_keyboard_layout layout_us = { +static struct grub_keyboard_layout layout_de = { .keyboard_map = {/* Keyboard errors. Handled by driver. */ /* 0x00 */ 0 ,0 ,0 ,0 ,
@@ -38,16 +38,16 @@/* 0x04 */ 'a' ,'b' ,'c' ,'d' ,/* 0x08 */ 'e' ,'f' ,'g' ,'h' ,'i' ,'j' ,'k' ,'l' ,/* 0x10 */ 'm' ,'n' ,'o' ,'p' ,'q' ,'r' ,'s' ,'t' , -/* 0x18 */ 'u' ,'v' ,'w' ,'x' ,'y' ,'z' ,'1' ,'2' , +/* 0x18 */ 'u' ,'v' ,'w' ,'x' ,'z' ,'y' ,'1' ,'2' ,/* 0x20 */ '3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'0' , -/* 0x28 */ '\n' ,'\e' ,'\b' ,'\t' ,' ' ,'-' ,'=' ,'[' , +/* 0x28 */ '\n' ,'\e' ,'\b' ,'\t' ,' ' ,'s' ,'\'' ,'u' ,/* s = ß, ' = ´, u = ü */ /* According to usage table 0x31 should be mapped to '/' but testing with real keyboard shows that 0x32 is remapped to '/'. Map 0x31 to 0. */ -/* 0x30 */ ']' ,0 ,'\\' ,';' ,'\'' ,'`' ,',' ,'.' , +/* 0x30 */ '+' ,0 ,'#' ,'o' ,'a' ,'^' ,',' ,'.' ,/* o = ö, a = ä */ /* 0x39 is CapsLock. Handled by driver. */ -/* 0x38 */ '/' ,0 ,GRUB_TERM_KEY_F1 ,GRUB_TERM_KEY_F2 , +/* 0x38 */ '-' ,0 ,GRUB_TERM_KEY_F1 ,GRUB_TERM_KEY_F2 ,/* 0x3c */ GRUB_TERM_KEY_F3 ,GRUB_TERM_KEY_F4 ,/* 0x3e */ GRUB_TERM_KEY_F5 ,GRUB_TERM_KEY_F6 , /* 0x40 */ GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8,
@@ -71,7 +71,7 @@/* 0x5e */ GRUB_TERM_KEY_RIGHT ,GRUB_TERM_KEY_HOME ,/* 0x60 */ GRUB_TERM_KEY_UP ,GRUB_TERM_KEY_PPAGE ,/* 0x62 */ GRUB_TERM_KEY_INSERT ,GRUB_TERM_KEY_DC , -/* 0x64 */ '\\' +/* 0x64 */ '<' }, .keyboard_map_shift = {/* Keyboard errors. Handled by driver. */
@@ -80,18 +80,18 @@/* 0x04 */ 'A' ,'B' ,'C' ,'D' ,/* 0x08 */ 'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,'K' ,'L' ,/* 0x10 */ 'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' , -/* 0x18 */ 'U' ,'V' ,'W' ,'X' ,'Y' ,'Z' ,'!' ,'@' , -/* 0x20 */ '#' ,'$' ,'%' ,'^' ,'&' ,'*' ,'(' ,')' , +/* 0x18 */ 'U' ,'V' ,'W' ,'X' ,'Z' ,'Y' ,'!' ,'\"' , +/* 0x20 */ 'P' ,'$' ,'%' ,'&' ,'/' ,'(' ,')' ,'=' ,/* P = § */ /* 0x28 */ '\n' |GRUB_TERM_SHIFT ,'\e' |GRUB_TERM_SHIFT ,/* 0x2a */ '\b' |GRUB_TERM_SHIFT ,'\t' |GRUB_TERM_SHIFT , -/* 0x2c */ ' ' |GRUB_TERM_SHIFT ,'_' ,'+' ,'{' , +/* 0x2c */ ' ' |GRUB_TERM_SHIFT ,'?' ,'`' ,'U' ,/* U = Ü */ /* According to usage table 0x31 should be mapped to '/' but testing with real keyboard shows that 0x32 is remapped to '/'. Map 0x31 to 0. */ -/* 0x30 */ '}' ,0 ,'|' ,':' ,'"' ,'~' ,'<' ,'>' , +/* 0x30 */ '*' ,0 ,'\'' ,'O' ,'A' ,'^' ,';' ,':' ,/* O = Ö, ^ = ° */ /* 0x39 is CapsLock. Handled by driver. */ -/* 0x38 */ '?' ,0 , +/* 0x38 */ '_' ,0 ,/* 0x3a */ GRUB_TERM_KEY_F1 |GRUB_TERM_SHIFT ,/* 0x3b */ GRUB_TERM_KEY_F2 |GRUB_TERM_SHIFT , /* 0x3c */ GRUB_TERM_KEY_F3 | GRUB_TERM_SHIFT,
@@ -121,11 +121,59 @@ /* 0x54 */ '/', '*', /* 0x56 */ '-', '+', /* 0x58 */ '\n' | GRUB_TERM_SHIFT, '1', '2', '3', '4', '5','6', '7', - /* 0x60 */ '8', '9', '0', '.', '|' + /* 0x60 */ '8', '9', '0', ',', '>' + }, + .keyboard_map_l3 = { +/* Keyboard errors. Handled by driver. */ +/* 0x00 */ 0 ,0 ,0 ,0 , + +/* 0x04 */ 0 ,0 ,0 ,0 , +/* 0x08 */ 'e' ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,/* e = € */ +/* 0x10 */ 0 ,0 ,0 ,0 ,'@' ,0 ,0 ,0 , +/* 0x18 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,'2' ,/* 2 = ² */ +/* 0x20 */ 3 ,0 ,0 ,0 ,'{' ,'[' ,']' ,'}' ,/* 3 = ³ */ +/* 0x28 */ 0 ,0 ,0 ,0 ,0 ,'\\' , +/* 0x2e */ 0 ,0 , +/* According to usage table 0x31 should be mapped to '/' +but testing with real keyboard shows that 0x32 is remapped to '/'. +Map 0x31 to 0. +*/ +/* 0x30 */ '~' ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +/* 0x39 is CapsLock. Handled by driver. */ +/* 0x38 */ 0 ,0 , +/* 0x3a */ GRUB_TERM_KEY_F1 |GRUB_TERM_ALT , +/* 0x3b */ GRUB_TERM_KEY_F2 |GRUB_TERM_ALT , +/* 0x3c */ GRUB_TERM_KEY_F3 |GRUB_TERM_ALT , +/* 0x3d */ GRUB_TERM_KEY_F4 |GRUB_TERM_ALT , +/* 0x3e */ GRUB_TERM_KEY_F5 |GRUB_TERM_ALT , +/* 0x3f */ GRUB_TERM_KEY_F6 |GRUB_TERM_ALT , +/* 0x40 */ GRUB_TERM_KEY_F7 |GRUB_TERM_ALT , +/* 0x41 */ GRUB_TERM_KEY_F8 |GRUB_TERM_ALT , +/* 0x42 */ GRUB_TERM_KEY_F9 |GRUB_TERM_ALT , +/* 0x43 */ GRUB_TERM_KEY_F10 |GRUB_TERM_ALT , +/* 0x44 */ GRUB_TERM_KEY_F11 |GRUB_TERM_ALT , +/* 0x45 */ GRUB_TERM_KEY_F12 |GRUB_TERM_ALT , +/* PrtScr and ScrollLock. Not handled yet. */ +/* 0x46 */ 0 ,0 , +/* 0x48 is Pause. Not handled yet. */ +/* 0x48 */ 0 ,GRUB_TERM_KEY_INSERT |GRUB_TERM_ALT , +/* 0x4a */ GRUB_TERM_KEY_HOME |GRUB_TERM_ALT , +/* 0x4b */ GRUB_TERM_KEY_PPAGE |GRUB_TERM_ALT , +/* 0x4c */ GRUB_TERM_KEY_DC |GRUB_TERM_ALT , +/* 0x4d */ GRUB_TERM_KEY_END |GRUB_TERM_ALT , +/* 0x4e */ GRUB_TERM_KEY_NPAGE |GRUB_TERM_ALT , +/* 0x4f */ GRUB_TERM_KEY_RIGHT |GRUB_TERM_ALT , +/* 0x50 */ GRUB_TERM_KEY_LEFT |GRUB_TERM_ALT , +/* 0x51 */ GRUB_TERM_KEY_DOWN |GRUB_TERM_ALT , +/* 0x53 is NumLock. Handled by driver. */ +/* 0x52 */ GRUB_TERM_KEY_UP |GRUB_TERM_ALT ,0 , +/* 0x54 */ 0 ,0 ,0 ,0 , +/* 0x58 */ 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , +/* 0x60 */ 0 ,0 ,0 ,0 ,'|' } }; -static struct grub_keyboard_layout *grub_current_layout = &layout_us; +static struct grub_keyboard_layout *grub_current_layout = &layout_de;static int map_key_core (int code,int status,int *alt_gr_consumed)
grub-core/term/at_keyboard.c renamed from at_keyboard.c +1 -1
@@ -88,7 +88,7 @@/* 0x4c */ GRUB_KEYBOARD_KEY_NUM5 ,GRUB_KEYBOARD_KEY_NUM6 ,/* 0x4e */ GRUB_KEYBOARD_KEY_NUMPLUS ,GRUB_KEYBOARD_KEY_NUM1 ,/* 0x50 */ GRUB_KEYBOARD_KEY_NUM2 ,GRUB_KEYBOARD_KEY_NUM3 , -/* 0x52 */ GRUB_KEYBOARD_KEY_NUMDOT ,GRUB_KEYBOARD_KEY_NUMDOT , +/* 0x52 */ GRUB_KEYBOARD_KEY_NUM0 ,GRUB_KEYBOARD_KEY_NUMDOT ,/* 0x54 */ 0 ,0 ,/* 0x56 */ GRUB_KEYBOARD_KEY_102ND ,GRUB_KEYBOARD_KEY_F11 , /* 0x58 */ GRUB_KEYBOARD_KEY_F12, 0,
15.05.2016 21:19, fgndevelop пишет:
Quoted 6 lines
Dear team at grub-devel,
First of all I would like to thank you for the Grand boot loader, your work is very much appreciated.
Quoted 8 lines
Recently I downloaded the current grub-2.02-beta3 and started experimenting with it. I am am making use of the luks module in GRUB to provide my clients with fully encrypted harddrives. Since my clients are German, and I keep telling them that strong passwords should contain special characters, I ended up modifying the default keyboard layout for the
at_keyboard.cinput driver. I provided the diff in keylayouts.c.diff, if you want to make use of it. The support for German keys is only partial, since some of the German keys are non-ASCII.
Layout in keylayout.c is just default one, because there should be some default. This command is used to load external layout table, so you can build German one and provide to your clients. Also GRUB is using Unicode internally, so it should be possible to use full range.
See grub-mklayout.c and grub-kbdcomp. The only problem is, these utilities are too heavy Debian oriented. Making them more portable would be great.
Quoted 31 lines
Also I patched
at_keyboard.c. It has a minor typo, in line 91 both scancode0x52and0x53are mapped to the sameGRUB_KEYBOARD_KEY_NUMDOT. This is wrong, scancode0x52has to be mapped toGRUB_KEYBOARD_KEY_NUM0(as that's what it is).Last but not least, parsing through
include/grub/keyboard_layouts.h, I realized that the enumeration of GRUB_KEYBOARD_KEY_* is skipping value0x31:Quoted 2 lines
GRUB_KEYBOARD_KEY_RBRACKET=0x30,
GRUB_KEYBOARD_KEY_BACKSLASH=0x32,I do not know why this is the case, but from my point of view this probably lead to the following comment ( in
grub-core/commands/keylayouts.c):Quoted 3 lines
/* According to usage table
0x31should be mapped to '/'but testing with real keyboard shows that 0x32 is remapped to '/'. Map 0x31 to 0.Cleaning up the enumeration would do some good, I guess.
Find attached both aformentioned patches. I'll be glad help out if you deem it appropriate to, e.g. make the support for German
at_keyboardlayout a configurable option.Regards, Frank
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
15.05.2016 21:19, fgndevelop пишет:
Quoted 5 lines
Also I patched
at_keyboard.c. It has a minor typo, in line 91 both scancode0x52and0x53are mapped to the sameGRUB_KEYBOARD_KEY_NUMDOT. This is wrong, scancode0x52has to be mapped toGRUB_KEYBOARD_KEY_NUM0(as that's what it is).
set 2 was apparently reversed too. Applied, thanks!