keyboard layout patches
Hello,
I've done a first version of keyboard_layout. Find a patch attached, or check the branch:
bzr.savannah.gnu.org/srv/bzr/grub/people/cpina/keyboard_layouts
I've tested only in at_keyboard. Using something like:
insmod at_keyboardterminal_input at_keyboard
insmod keyboard_layouts
set keymaps_dir=/boot/grub/layoutsload_keyboard es
and before I generate the file called "es" and copied into /boot/grub/layouts using grub-mklayout es
How could grub-mkinstall (00_header.in) know the current keyboard in the system? I wold tweak 00_header.in to generate the keymap file and setup it.
Comments about the current patch are welcomed, I would change it on next days.
Some days ago I read:
"There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors."
Don't hesitate to tell me how would you rename some things, I'll do. I'm not happy with the name of some variables/functions but I cannot think about it today :-)
Cheers,
Signature · 2 lines
Carles Pina i Estany http://pinux.info
=== modified file 'conf/common.rmk'
common.rmk +10 -0
@@ -88,6 +88,10 @@ endif bin_UTILITIES += grub-mkrelpath grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c +# For grub-mklayouts. +bin_UTILITIES += grub-mklayouts +grub_mklayouts_SOURCES = gnulib/progname.c util/grub-mklayouts.c util/misc.c + # For the parser. grub_script.tab.c grub_script.tab.h: script/parser.y $(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y
@@ -647,6 +651,12 @@ gettext_mod_SOURCES = gettext/gettext.c gettext_mod_CFLAGS = $(COMMON_CFLAGS) gettext_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For keyboard_layouts.mod +pkglib_MODULES += keyboard_layouts.mod +keyboard_layouts_mod_SOURCES = keyboard_layouts/keyboard_layouts.c +keyboard_layouts_mod_CFLAGS = $(COMMON_CFLAGS) +keyboard_layouts_mod_LDFLAGS = $(COMMON_LDFLAGS) + # Misc. pkglib_MODULES += xnu_uuid.mod
=== added file 'include/grub/keys.h'
grub/keys.h +36 -0
@@ -0,0 +1,36 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2010 Free Software Foundation, Inc. +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef GRUB_KEYS_HEADER +#define GRUB_KEYS_HEADER 1 + +/* Internal codes used by GRUB to represent terminal input. */ +#define GRUB_TERM_LEFT 2 +#define GRUB_TERM_RIGHT 6 +#define GRUB_TERM_UP 16 +#define GRUB_TERM_DOWN 14 +#define GRUB_TERM_HOME 1 +#define GRUB_TERM_END 5 +#define GRUB_TERM_DC 4 +#define GRUB_TERM_PPAGE 7 +#define GRUB_TERM_NPAGE 3 +#define GRUB_TERM_ESC '\e' +#define GRUB_TERM_TAB '\t' +#define GRUB_TERM_BACKSPACE 8 + +#endif /* ! GRUB_KEYS_HEADER */
=== modified file 'include/grub/term.h'
grub/term.h +9 -13
@@ -19,19 +19,7 @@#ifndef GRUB_TERM_HEADER #define GRUB_TERM_HEADER 1 -/* Internal codes used by GRUB to represent terminal input. */ -#define GRUB_TERM_LEFT 2 -#define GRUB_TERM_RIGHT 6 -#define GRUB_TERM_UP 16 -#define GRUB_TERM_DOWN 14 -#define GRUB_TERM_HOME 1 -#define GRUB_TERM_END 5 -#define GRUB_TERM_DC 4 -#define GRUB_TERM_PPAGE 7 -#define GRUB_TERM_NPAGE 3 -#define GRUB_TERM_ESC '\e' -#define GRUB_TERM_TAB '\t' -#define GRUB_TERM_BACKSPACE 8 +#include <grub/keys.h> #ifndef ASM_FILE
@@ -198,6 +186,14 @@ extern struct grub_term_input *EXPORT_VAextern struct grub_term_output *EXPORT_VAR (grub_term_outputs );extern struct grub_term_input *EXPORT_VAR (grub_term_inputs ); +struct grub_keyboard_map_s +{ +char *normal; +char *shift; +}; + +extern struct grub_keyboard_map_s *EXPORT_VAR (grub_keyboard_map ); +static inline void grub_term_register_input (const char *name __attribute__ ((unused)),grub_term_input_t term)
=== modified file 'kern/term.c'
term.c +2 -0
@@ -30,6 +30,8 @@ struct grub_term_input *grub_term_inputsvoid (*grub_newline_hook) (void ) =NULL ; +struct grub_keyboard_map_s *grub_keyboard_map =NULL ; +/* Put a Unicode character. */ void grub_putcode (grub_uint32_t code,struct grub_term_output *term)
=== added directory 'keyboard_layouts'
=== added file 'keyboard_layouts/keyboard_layouts.c'
keyboard_layouts.c +160 -0
160 lines not on this page · raw message
=== modified file 'term/i386/pc/at_keyboard.c'
i386/pc/at_keyboard.c +7 -3
@@ -22,6 +22,7 @@#include <grub/i386/io.h> #include <grub/misc.h> #include <grub/term.h> +#include <grub/mm.h> static short at_keyboard_status =0 ;
@@ -40,7 +41,7 @@ static grub_uint8_t led_status;#define KEYBOARD_LED_NUM (1 << 1)#define KEYBOARD_LED_CAPS (1 << 2) -static char keyboard_map[128 ] = +static char keyboard_map_normal[128 ] = {'\0' ,GRUB_TERM_ESC ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,GRUB_TERM_BACKSPACE ,GRUB_TERM_TAB ,
@@ -213,12 +214,12 @@ grub_at_keyboard_getkey_noblock (void)break ;default :if (at_keyboard_status & (KEYBOARD_STATUS_CTRL_L |KEYBOARD_STATUS_CTRL_R )) - key = keyboard_map[code] -'a' +1 ; + key = grub_keyboard_map->normal[code] -'a' +1 ;else if ((at_keyboard_status & (KEYBOARD_STATUS_SHIFT_L |KEYBOARD_STATUS_SHIFT_R )) && keyboard_map_shift[code]) key = keyboard_map_shift[code];else - key = keyboard_map[code]; + key = grub_keyboard_map->normal[code];if (key ==0 )grub_dprintf ("atkeyb" ,"Unknown key 0x%x detected\n" , code);
@@ -279,6 +280,9 @@ static struct grub_term_input grub_at_keGRUB_MOD_INIT (at_keyboard) {grub_term_register_input ("at_keyboard" , &grub_at_keyboard_term); + + grub_keyboard_map->normal = keyboard_map_normal; + grub_keyboard_map->shift = keyboard_map_shift; }GRUB_MOD_FINI (at_keyboard)
=== added file 'util/grub-mklayouts.c'
grub-mklayouts.c +287 -0
287 lines not on this page · raw message
Am Montag, den 18.01.2010, 00:10 +0000 schrieb Carles Pina i Estany:
Quoted 5 lines
Hello,
I've done a first version of
keyboard_layout. Find a patch attached, or check the branch:
bzr.savannah.gnu.org/srv/bzr/grub/people/cpina/keyboard_layouts
Nice work, though I haven't yet looked at the patch itself.
Quoted 4 lines
How could grub-mkinstall (00_header.in) know the current keyboard in the system? I wold tweak 00_header.in to generate the keymap file and setup it.
I think that's completely distribution specific and maybe even can depend on the window manager/desktop enviromnent you use (if you use one).
So I suggest to just use a variable in /etc/default/grub for that.
Signature · 2 lines
Felix Zielcke Proud Debian Maintainer and GNU GRUB developer
Quoted 14 lines · Carles Pina i Estany
Hello,
I've done a first version of
keyboard_layout. Find a patch attached, or check the branch:
bzr.savannah.gnu.org/srv/bzr/grub/people/cpina/keyboard_layoutsI've tested only in
at_keyboard. Using something like:insmod
at_keyboardterminal_inputat_keyboard
insmodkeyboard_layouts
set keymaps_dir=/boot/grub/layoutsload_keyboardes
Quoted 5 lines
and before I generate the file called "es" and copied into
/boot/grub/layoutsusing grub-mklayout esHow could grub-mkinstall (00_header.in) know the current keyboard in the system?
setxkbmap -print will give you the x layout but it won't work outside of X.
Quoted 3 lines
I wold tweak 00_header.in to generate the keymap file and setup it.
It may be executed by a daemon with no X available.
Quoted 12 lines
Comments about the current patch are welcomed, I would change it on next days.
Some days ago I read:
"There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors."Don't hesitate to tell me how would you rename some things, I'll do. I'm not happy with the name of some variables/functions but I cannot think about it today :-)
+/* Layout file format constants. */
+static const char file_magic[7] = { 'G', 'R', 'U', 'B', 'L', 'A', 'Y' };
Don't use misaligned magics.
+ prefix = grub_env_get ("keymaps_dir");
+ if (!prefix)
+ return grub_error (GRUB_ERR_READ_ERROR,
+ "`keymaps_dir' variable not set up");
+
+ filename =
+ grub_malloc (grub_strlen (prefix) + grub_strlen ("/") +
+ grub_strlen (args[0]) + 1);
Can you add support for complete filenames?
+ grub_sprintf (filename, "%s/%s", prefix, args[0]);
+ sprintf (command, CKBCOMP " %s", keymap);
+
+ fp = popen (command, "r");
+
Opens the possibility to execute any code by specifying layouts like |rm -rf /
+ for (i= 0; i < 128; i++)
+ {
+ keyboard_map_normal[i] = '\0';
+ keyboard_map_shift[i] = '\0';
+ }
use memset
+ grub_util_write_image ("GRUBLAY", 7, fp);
+ grub_util_write_image ((char *) &version, 4, fp);
should be macroified and put somewhere in a header instead of duplicating
Can you think of a way to restoring keyboard map to English?
Quoted 9 lines
Cheers,
------------------------------------------------------------------------
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Hi,
I answer in fast way... more at evening. Items that I don't comment I understand and agree.
Quoted 7 lines · Vladimir '??-coder/phcoder' Serbinenko
Quoted 2 lines
How could grub-mkinstall (00_header.in) know the current keyboard in the system?
setxkbmap -print will give you the x layout but it won't work outside of X.
Quoted 3 lines
I wold tweak 00_header.in to generate the keymap file and setup it.
It may be executed by a daemon with no X available.
I'll use Felix suggestion: do whatever is in /etc/grub/default
Quoted 4 lines
keyboard_layouts.c +3
-0+ filename = +grub_malloc (grub_strlen (prefix) +grub_strlen ("/" ) + +grub_strlen (args[0 ]) +1 );Can you add support for complete filenames?
do you mean that, for example, if args[0] starts by "/" then filename = args[0]?
Actually if prefix (that it's a variable) is "/" then args[0] acts as a filename. Would be like "///test/filename" and it's a valid directory.
Quoted 1 line
Can you think of a way to restoring keyboard map to English?
unloading the module restores the original keyboard (so, English one). I save the original one when the module is loaded.
Thanks for the other comments,
Signature · 2 lines
Carles Pina i Estany http://pinux.info
Quoted 33 lines · Carles Pina i Estany
Hi,
I answer in fast way... more at evening. Items that I don't comment I understand and agree.
Quoted 11 lines · Vladimir '??-coder/phcoder' Serbinenko
Quoted 3 lines
How could grub-mkinstall (00_header.in) know the current keyboard in the system?
setxkbmap -print will give you the x layout but it won't work outside of X.
Quoted 4 lines
I wold tweak 00_header.in to generate the keymap file and setup it.
It may be executed by a daemon with no X available.
I'll use Felix suggestion: do whatever is in
/etc/grub/defaultQuoted 5 lines
keyboard_layouts.c +3
-0+ filename = +grub_malloc (grub_strlen (prefix) +grub_strlen ("/" ) + +grub_strlen (args[0 ]) +1 );Can you add support for complete filenames?
do you mean that, for example, if args[0] starts by "/" then filename = args[0]?
Quoted 4 lines
Actually if prefix (that it's a variable) is "/" then args[0] acts as a filename. Would be like "///test/filename" and it's a valid directory.
Perhaps we should remove prefix variables altogether.
Quoted 7 lines
Quoted 2 lines
Can you think of a way to restoring keyboard map to English?
unloading the module restores the original keyboard (so, English one). I save the original one when the module is loaded.
I mean imagine that you're in a face to a grub with klingon keyboard how would you find your way out?
Also keyboard_layouts is pretty small. Perhaps we can just make *_keyboard depend on it and put US keyboard into it as default and shave some complexity this way
Quoted 3 lines
Thanks for the other comments,
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Hi,
Quoted 7 lines · Vladimir '??-coder/phcoder' Serbinenko
Quoted 4 lines · Carles Pina i Estany
Actually if prefix (that it's a variable) is "/" then args[0] acts as a filename. Would be like "///test/filename" and it's a valid directory.
Perhaps we should remove prefix variables altogether.
I understand that you mean that the user would type:
load_keyboard /boot/grub/layouts/es
right? (in the shell or the config file)
Comments on this?
(I don't like it, I would even prefer to have the prefix hardcoded or like it's now)
Quoted 9 lines
Quoted 7 lines
Quoted 2 lines
Can you think of a way to restoring keyboard map to English?
unloading the module restores the original keyboard (so, English one). I save the original one when the module is loaded.
I mean imagine that you're in a face to a grub with klingon keyboard how would you find your way out?
Klingon is my primary layout! :-)
I have different things to say and we could discuss quite long, but let's jump to the ideas:
a) very short term: what about to register a command to "something" (like "1234", numbers doesn't usually change between keyboard, right? or "**" for the keypad -I should check that it works, but would fix if it doesn't) that reverts to English?
b) medium term: as you suggested some days ago on IRC: Shift+Shift, or Ctrl+Shift or something like this reverts to English.
I'm not sure about the infrastructure needed for b)
Quoted 3 lines
Also
keyboard_layoutsis pretty small. Perhaps we can just make*_keyboarddepend on it and put US keyboard into it as default and shave some complexity this way
How it would work in rescue mode and at_keyboard? I mean, extreme cases that Grub for some reason could not reach the keyboard layout file.
The complexitity that we save is very reduced.
Signature · 2 lines
Carles Pina i Estany http://pinux.info
Quoted 2 lines · Carles Pina i Estany
a) very short term: what about to register a command to "something" (like "1234", numbers doesn't usually change between keyboard, right?
The standard counterexample is French. Function keys do stay constant, though.
Signature · 1 line
Colin Watson [[email protected]]
Hi,
Quoted 4 lines · Vladimir '??-coder/phcoder' Serbinenko
grub-mklayouts.c +2
-0+grub_util_write_image ("GRUBLAY" ,7 , fp); +grub_util_write_image ((char *) &version,4 , fp);should be macroified and put somewhere in a header instead of duplicating
I agree. Any reason that I don't see that in util/grub-mkfont.c:
grub_util_write_image ("FILE", 4, file);
grub_util_write_image ("PFF2", 4, file);and then in font/font.c:
static const char section_names_file[4] = { 'F', 'I', 'L', 'E' }; static const char pff2_magic[4] = { 'P', 'F', 'F', '2' };
?
If should be in a macro (as I think so) I will fix after finishing other things.
Cheers,
Signature · 2 lines
Carles Pina i Estany http://pinux.info
Hi,
Quoted 6 lines · Colin Watson
Quoted 2 lines · Carles Pina i Estany
a) very short term: what about to register a command to "something" (like "1234", numbers doesn't usually change between keyboard, right?
The standard counterexample is French. Function keys do stay constant, though.
Usually are not mapped to any ASCII output to call a command. I know that I can do it idfferent, but then it's not option a).
What about the star in the numeric pad? Is it constant for all keyboards? (I can check generating all keymaps and a script, but maybe you know on the top of your head)
Signature · 2 lines
Carles Pina i Estany http://pinux.info
Hi,
Quoted 1 line · Carles Pina i Estany
I've done a first version of
keyboard_layout. Find a patch attached, or
Thanks to the comments from different people in the thread, I send a new version.
It does, on from my head:
a) Constants used in util/ and Grub are in a common header file.
b) Use 8 bytes magic file, instead of 7
c) Adds a new command "**" to revert to the default keyboard
d) Don't use popen and use fork + execlp + pipe
e) Change some names that I didn't like
f) Implements a new variable in /etc/grub/default
And some other small bugfixes.
Everything is tested but not f).
The solution of c) is temporary, but I think that good enough for this stage. When this is in trunk/experimental (I think that can go to trunk straight away since there isn't major changes, but I give it up to you) I can implement some other solution.
What else I should change, or some other comment?
Thanks,
Signature · 2 lines
Carles Pina i Estany http://pinux.info
=== added file 'ChangeLog.keyboard_layouts'
ChangeLog.keyboard_layouts +22 -0
@@ -0,0 +1,22 @@ +2010-01-18 Carles Pina i Estany <[email protected]> + + Adds keyboard layouts support. + + * conf/common.rmk (bin_UTILITIES): Add grub-mklayouts rules. + (pkglib_MODULES): Add module `keyboard_layouts.mod'. + * include/grub/keyboard_layouts.h: New file. + * include/grub/term.h: New struct `grub_keyboard_map_s'. New + EXPORTED_VAR `grub_keyboard_map'. Move GRUB_TERM_* keys definitions + to... + * include/grub/keys.h: ... here. New file. + * kern/term.c (grub_keyboard_map): Initialise to NULL. + * keyboard_layouts/keyboard_layouts.c: New file. + * term/i386/pc/at_keyboard.c: Include `<grub/mm.h>'. + (keyboard_map_normal): Renamed from `keyboard_map'. + (grub_at_keyboard_getkey_noblock): Use `grub_keyboard_map' instead of + `keyboard_map' and `keyboard_map_shift'. + (grub_term_input): Initialise `grub_keyboard_map->normal' and + `grub_keyboard_map->shift'. + * util/grub-mklayouts.c: New file. + * util/grub-mkconfig.in: New variable `GRUB_KEYBOARD_LAYOUT'. + * util/grub.d/00_header.in: Set up layout configuration.
=== modified file 'conf/common.rmk'
common.rmk +10 -0
@@ -88,6 +88,10 @@ endif bin_UTILITIES += grub-mkrelpath grub_mkrelpath_SOURCES = gnulib/progname.c util/grub-mkrelpath.c util/misc.c +# For grub-mklayouts. +bin_UTILITIES += grub-mklayouts +grub_mklayouts_SOURCES = gnulib/progname.c util/grub-mklayouts.c util/misc.c + # For the parser. grub_script.tab.c grub_script.tab.h: script/parser.y $(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y
@@ -647,6 +651,12 @@ gettext_mod_SOURCES = gettext/gettext.c gettext_mod_CFLAGS = $(COMMON_CFLAGS) gettext_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For keyboard_layouts.mod +pkglib_MODULES += keyboard_layouts.mod +keyboard_layouts_mod_SOURCES = keyboard_layouts/keyboard_layouts.c +keyboard_layouts_mod_CFLAGS = $(COMMON_CFLAGS) +keyboard_layouts_mod_LDFLAGS = $(COMMON_LDFLAGS) + # Misc. pkglib_MODULES += xnu_uuid.mod
=== added file 'include/grub/keyboard_layouts.h'
grub/keyboard_layouts.h +25 -0
@@ -0,0 +1,25 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2010 Free Software Foundation, Inc. +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef GRUB_KEYBOARD_LAYOUTS_H +#define GRUB_KEYBOARD_LAYOUTS_H 1 + +#define GRUB_KEYBOARD_LAYOUTS_FILEMAGIC "GRUBLAYO" +#define GRUB_KEYBOARD_LAYOUTS_VERSION 1 + +#endif /* GRUB_USB_H */
=== added file 'include/grub/keys.h'
grub/keys.h +36 -0
@@ -0,0 +1,36 @@ +/* +* GRUB -- GRand Unified Bootloader +* Copyright (C) 2010 Free Software Foundation, Inc. +* +* GRUB is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* GRUB is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with GRUB. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef GRUB_KEYS_HEADER +#define GRUB_KEYS_HEADER 1 + +/* Internal codes used by GRUB to represent terminal input. */ +#define GRUB_TERM_LEFT 2 +#define GRUB_TERM_RIGHT 6 +#define GRUB_TERM_UP 16 +#define GRUB_TERM_DOWN 14 +#define GRUB_TERM_HOME 1 +#define GRUB_TERM_END 5 +#define GRUB_TERM_DC 4 +#define GRUB_TERM_PPAGE 7 +#define GRUB_TERM_NPAGE 3 +#define GRUB_TERM_ESC '\e' +#define GRUB_TERM_TAB '\t' +#define GRUB_TERM_BACKSPACE 8 + +#endif /* ! GRUB_KEYS_HEADER */
=== modified file 'include/grub/term.h'
grub/term.h +9 -13
@@ -19,19 +19,7 @@#ifndef GRUB_TERM_HEADER #define GRUB_TERM_HEADER 1 -/* Internal codes used by GRUB to represent terminal input. */ -#define GRUB_TERM_LEFT 2 -#define GRUB_TERM_RIGHT 6 -#define GRUB_TERM_UP 16 -#define GRUB_TERM_DOWN 14 -#define GRUB_TERM_HOME 1 -#define GRUB_TERM_END 5 -#define GRUB_TERM_DC 4 -#define GRUB_TERM_PPAGE 7 -#define GRUB_TERM_NPAGE 3 -#define GRUB_TERM_ESC '\e' -#define GRUB_TERM_TAB '\t' -#define GRUB_TERM_BACKSPACE 8 +#include <grub/keys.h> #ifndef ASM_FILE
@@ -198,6 +186,14 @@ extern struct grub_term_input *EXPORT_VAextern struct grub_term_output *EXPORT_VAR (grub_term_outputs );extern struct grub_term_input *EXPORT_VAR (grub_term_inputs ); +struct grub_keyboard_map_s +{ +char *normal; +char *shift; +}; + +extern struct grub_keyboard_map_s *EXPORT_VAR (grub_keyboard_map ); +static inline void grub_term_register_input (const char *name __attribute__ ((unused)),grub_term_input_t term)
=== modified file 'kern/term.c'
term.c +2 -0
@@ -30,6 +30,8 @@ struct grub_term_input *grub_term_inputsvoid (*grub_newline_hook) (void ) =NULL ; +struct grub_keyboard_map_s *grub_keyboard_map =NULL ; +/* Put a Unicode character. */ void grub_putcode (grub_uint32_t code,struct grub_term_output *term)
=== added directory 'keyboard_layouts'
=== added file 'keyboard_layouts/keyboard_layouts.c'
keyboard_layouts.c +186 -0
186 lines not on this page · raw message
=== modified file 'term/i386/pc/at_keyboard.c'
i386/pc/at_keyboard.c +9 -5
@@ -22,6 +22,7 @@#include <grub/i386/io.h> #include <grub/misc.h> #include <grub/term.h> +#include <grub/mm.h> static short at_keyboard_status =0 ;
@@ -40,7 +41,7 @@ static grub_uint8_t led_status;#define KEYBOARD_LED_NUM (1 << 1)#define KEYBOARD_LED_CAPS (1 << 2) -static char keyboard_map[128 ] = +static char keyboard_map_normal[128 ] = {'\0' ,GRUB_TERM_ESC ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,GRUB_TERM_BACKSPACE ,GRUB_TERM_TAB ,
@@ -213,12 +214,12 @@ grub_at_keyboard_getkey_noblock (void)break ;default :if (at_keyboard_status & (KEYBOARD_STATUS_CTRL_L |KEYBOARD_STATUS_CTRL_R )) - key = keyboard_map[code] -'a' +1 ; + key = grub_keyboard_map->normal[code] -'a' +1 ;else if ((at_keyboard_status & (KEYBOARD_STATUS_SHIFT_L |KEYBOARD_STATUS_SHIFT_R )) - && keyboard_map_shift[code]) - key = keyboard_map_shift[code]; + && grub_keyboard_map->shift[code]) + key = grub_keyboard_map->shift[code];else - key = keyboard_map[code]; + key = grub_keyboard_map->normal[code];if (key ==0 )grub_dprintf ("atkeyb" ,"Unknown key 0x%x detected\n" , code);
@@ -279,6 +280,9 @@ static struct grub_term_input grub_at_keGRUB_MOD_INIT (at_keyboard) {grub_term_register_input ("at_keyboard" , &grub_at_keyboard_term); + + grub_keyboard_map->normal = keyboard_map_normal; + grub_keyboard_map->shift = keyboard_map_shift; }GRUB_MOD_FINI (at_keyboard)
=== modified file 'util/grub-mkconfig.in'
grub-mkconfig.in +2 -1
@@ -220,7 +220,8 @@ export GRUB_DEFAULT \ GRUB_DISABLE_LINUX_UUID \ GRUB_DISABLE_LINUX_RECOVERY \ GRUB_GFXMODE \ - GRUB_DISABLE_OS_PROBER + GRUB_DISABLE_OS_PROBER \ + GRUB_KEYBOARD_LAYOUT if test "x${grub_cfg}" != "x"; then rm -f ${grub_cfg}.new
=== added file 'util/grub-mklayouts.c'
grub-mklayouts.c +308 -0
308 lines not on this page · raw message
=== modified file 'util/grub.d/00_header.in'
grub.d/00_header.in +8 -0
@@ -129,6 +129,14 @@ insmod gettext EOF fi +if [ "x${GRUB_KEYBOARD_LAYOUT}" != "x" ] ; then + cat << EOF +insmod keyboard_layouts +set keymaps_dir=${grub_prefix}/layouts +load_layout ${GRUB_KEYBOARD_LAYOUT} +EOF +fi + if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then verbose=
Quoted 4 lines · Carles Pina i Estany
Quoted 1 line
Can you think of a way to restoring keyboard map to English?
unloading the module restores the original keyboard (so, English one). I save the original one when the module is loaded.
Don't confuse keyboard layouts with languages! You probably meant US keyboard.
Signature · 3 lines
Robert Millan "Be the change you want to see in the world" -- Gandhi
Quoted 6 lines · Carles Pina i Estany
Quoted 3 lines
Also
keyboard_layoutsis pretty small. Perhaps we can just make*_keyboarddepend on it and put US keyboard into it as default and shave some complexity this wayHow it would work in rescue mode and
at_keyboard? I mean, extreme cases that Grub for some reason could not reach the keyboard layout file.
What's the total size we're talking about?
Signature · 3 lines
Robert Millan "Be the change you want to see in the world" -- Gandhi
Quoted 14 lines · Carles Pina i Estany
Quoted 4 lines · Vladimir '??-coder/phcoder' Serbinenko
grub-mklayouts.c +2
-0+grub_util_write_image ("GRUBLAY" ,7 , fp); +grub_util_write_image ((char *) &version,4 , fp);should be macroified and put somewhere in a header instead of duplicating
I agree. Any reason that I don't see that in
util/grub-mkfont.c:grub_util_write_image ("FILE", 4, file); grub_util_write_image ("PFF2", 4, file);and then in
font/font.c:
Quoted 7 lines
static const char section_names_file[4] = { 'F', 'I', 'L', 'E' }; static const char pff2_magic[4] = { 'P', 'F', 'F', '2' };
?
If should be in a macro (as I think so) I will fix after finishing other things.
Yeah it should.
Signature · 3 lines
Robert Millan "Be the change you want to see in the world" -- Gandhi
Hi,
Quoted 9 lines · Robert Millan
Quoted 6 lines · Carles Pina i Estany
Quoted 3 lines
Also
keyboard_layoutsis pretty small. Perhaps we can just make*_keyboarddepend on it and put US keyboard into it as default and shave some complexity this wayHow it would work in rescue mode and
at_keyboard? I mean, extreme cases that Grub for some reason could not reach the keyboard layout file.What's the total size we're talking about?
Layout files are 268 bytes (128 for standard layout, 128 for shift and some headers, 8 bytes for filemagic, 4 bytes for version)
keyboard_layouts.mod is 3164. Aprox 520 with error messages, maybe now is too much detailed.
Signature · 2 lines
Carles Pina i Estany http://pinux.info