keyboard layouts
Hello,
I have been one month and something without doing lot of Grub things. I think that last time that I did something was going/coming from Fosdem :-/
Hopefully soon I can finish the keyboard layouts. See my branch:
sftp://[email protected]/srv/bzr/grub/people/cpina/keyboard_layouts/
Or my attached patch.
Right now (and this needs a change) the modules at_keyboard and usb_keyboard doesn't need the at_keyboard_layouts and usb_keyboard_layouts (they have the default layout hardcoded).
If the user loads usb_keyboard_layouts, usb_keyboard gets loaded (same with AT).
Vladimir suggested, to simplify (usb_keyboard_layouts and at_keyboard_layouts are mainly the same with some defines) that usb_keyboard should depend on keyboard_layouts (generic) and at_keyboard should depen on keyboard_layouts (generic as well).
Vladimir: is it what you suggested? Was some time ago...
I didn't like a lot because in some circumstancies maybe we don't want layouts at all (some users, environments, etc.)
Vladimir liked (if I remember correctly) to avoid having two modules (instead of only one).
I have the feeling that I'm biased and I've ate some vladimir reason :-/
I'll do the changes when we will agree.
Cheers,
Signature · 2 lines
Carles Pina i Estany http://pinux.info
=== added file 'ChangeLog.keyboard_layouts'
ChangeLog.keyboard_layouts +31 -0
@@ -0,0 +1,31 @@ +2010-01-18 Carles Pina i Estany <[email protected]> + + Adds keyboard layouts support (AT and USB) + + * conf/common.rmk (bin_UTILITIES): Add grub-mklayouts rules. + (pkglib_MODULES): Add module `at_keyboard_layouts.mod' and + `usb_keyboard_layouts.mod'. + * include/grub/at_keyboard.h: Include `"keyboard.h"'. New EXPORT_VAR + `grub_keyboard_map'. + * include/grub/keyboard.h: New file. + * include/grub/keyboard_layouts.h: New file. + * include/grub/term.h: Move macros from here ... + * include/grub/keys.h: ... to here. New file. + * include/grub/usb_keyboard.h: New file. + * keyboard_layouts/keyboard_layouts.c: New file. + * keyboard_layouts/at_keyboard_layouts.c: New file. + * keyboard_layouts/usb_keyboard_layouts.c: New file. + * term/at_keyboard.c: Include `<grub/mm.h>'. + (grub_at_keyboard_map): Declare. + (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_MOD_INIT): Initialise `grub_at_keyboard_map'. + * term/usb_keyboard.c: Include `<grub/mm.h>' and + `<grub/usb_keyboard.h>'. + (grub_usb_keyboard_map): Declare. + (keyboard_map_normal): Renamed from keyboard_map. + (grub_usb_keyboard_checkkey): Use `keyboard_map_normal' instead of + `keyboard_map'. + (GRUB_MOD_INIT): Initialise `grub_usb_keyboard_map'. + * util/grub-mklayouts.c: New file.
=== modified file 'conf/common.rmk'
common.rmk +16 -0
@@ -91,6 +91,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 + bin_UTILITIES += grub-bin2h grub_bin2h_SOURCES = gnulib/progname.c util/bin2h.c
@@ -131,6 +135,18 @@ grub_script.tab.c grub_script.tab.h: scr $(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y DISTCLEANFILES += grub_script.tab.c grub_script.tab.h +# For at_keyboard_layouts.mod +pkglib_MODULES += at_keyboard_layouts.mod +at_keyboard_layouts_mod_SOURCES = keyboard_layouts/at_keyboard_layouts.c +at_keyboard_layouts_mod_CFLAGS = $(COMMON_CFLAGS) +at_keyboard_layouts_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For usb_keyboard_layouts.mod +pkglib_MODULES += usb_keyboard_layouts.mod +usb_keyboard_layouts_mod_SOURCES = keyboard_layouts/usb_keyboard_layouts.c +usb_keyboard_layouts_mod_CFLAGS = $(COMMON_CFLAGS) +usb_keyboard_layouts_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For grub-script-check. grub_script_check_init.lst: geninit.sh $(filter-out grub_script_check_init.c,$(grub_script_check_SOURCES)) rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
=== modified file 'include/grub/at_keyboard.h'
grub/at_keyboard.h +4 -0
@@ -19,6 +19,10 @@#ifndef GRUB_AT_KEYBOARD_HEADER #define GRUB_AT_KEYBOARD_HEADER 1 +#include "keyboard.h" + +extern struct grub_keyboard_map_s *EXPORT_VAR (grub_at_keyboard_map ); +#define SHIFT_L 0x2a#define SHIFT_R 0x36#define CTRL 0x1d
=== added file 'include/grub/keyboard.h'
grub/keyboard.h +28 -0
@@ -0,0 +1,28 @@ +/* +* 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_HEADER +#define GRUB_KEYBOARD_HEADER 1 + +struct grub_keyboard_map_s +{ +char *normal; +char *shift; +}; + +#endif
=== 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_KEYBOARD_LAYOUTS */
=== 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 +1 -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
=== added file 'include/grub/usb_keyboard.h'
grub/usb_keyboard.h +26 -0
@@ -0,0 +1,26 @@ +/* +* 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_USB_KEYBOARD_HEADER +#define GRUB_USB_KEYBOARD_HEADER 1 + +#include "keyboard.h" + +extern struct grub_keyboard_map_s *EXPORT_VAR (grub_usb_keyboard_map ); + +#endif
=== added directory 'keyboard_layouts'
=== added file 'keyboard_layouts/at_keyboard_layouts.c'
at_keyboard_layouts.c +6 -0
@@ -0,0 +1,6 @@ +#define DO_AT_KEYBOARD_LAYOUT 1 +#define COMMAND_NAME_LOAD "at_load_layout" +#define COMMAND_NAME_SHOW "at_show_layout" +#define COMMAND_NAME_RESTORE "at**" +#define FILE_SUFFIX ".at" +#include "keyboard_layouts.c"
=== added file 'keyboard_layouts/keyboard_layouts.c'
keyboard_layouts.c +213 -0
213 lines not on this page · raw message
=== added file 'keyboard_layouts/usb_keyboard_layouts.c'
usb_keyboard_layouts.c +6 -0
@@ -0,0 +1,6 @@ +#define DO_USB_KEYBOARD_LAYOUT 1 +#define COMMAND_NAME_LOAD "usb_load_layout" +#define COMMAND_NAME_SHOW "usb_show_layout" +#define COMMAND_NAME_RESTORE "usb**" +#define FILE_SUFFIX ".usb" +#include "keyboard_layouts.c"
=== modified file 'term/at_keyboard.c'
at_keyboard.c +11 -5
@@ -22,6 +22,9 @@#include <grub/cpu/io.h> #include <grub/misc.h> #include <grub/term.h> +#include <grub/mm.h> + +struct grub_keyboard_map_s *grub_at_keyboard_map =NULL ;static short at_keyboard_status =0 ;static int pending_key =-1 ;
@@ -41,7 +44,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 ,
@@ -214,12 +217,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_at_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_at_keyboard_map->shift[code]) + key = grub_at_keyboard_map->shift[code];else - key = keyboard_map[code]; + key = grub_at_keyboard_map->normal[code];if (key ==0 )grub_dprintf ("atkeyb" ,"Unknown key 0x%x detected\n" , code);
@@ -295,6 +298,9 @@ static struct grub_term_input grub_at_keGRUB_MOD_INIT (at_keyboard) {grub_term_register_input ("at_keyboard" , &grub_at_keyboard_term); + + grub_at_keyboard_map->normal = keyboard_map_normal; + grub_at_keyboard_map->shift = keyboard_map_shift; }GRUB_MOD_FINI (at_keyboard)
=== modified file 'term/usb_keyboard.c'
usb_keyboard.c +11 -3
@@ -26,9 +26,14 @@#include <grub/usb.h> #include <grub/dl.h> #include <grub/time.h> +#include <grub/mm.h> +#include <grub/usb_keyboard.h> -static char keyboard_map[128 ] = + +struct grub_keyboard_map_s *grub_usb_keyboard_map =NULL ; + +static char keyboard_map_normal[128 ] = {'\0' ,'\0' ,'\0' ,'\0' ,'a' ,'b' ,'c' ,'d' ,'e' ,'f' ,'g' ,'h' ,'i' ,'j' ,'k' ,'l' ,
@@ -152,11 +157,11 @@ grub_usb_keyboard_checkkey (void)/* Check if the Control or Shift key was pressed. */ if (data[0 ] &0x01 || data[0 ] &0x10 ) - key = keyboard_map[data[2 ]] -'a' +1 ; + key = keyboard_map_normal[data[2 ]] -'a' +1 ;else if (data[0 ] &0x02 || data[0 ] &0x20 ) key = keyboard_map_shift[data[2 ]];else - key = keyboard_map[data[2 ]]; + key = keyboard_map_normal[data[2 ]];if (key ==0 )grub_printf ("Unknown key 0x%x detected\n" , data[2 ]);
@@ -321,6 +326,9 @@ GRUB_MOD_INIT(usb_keyboard) {grub_usb_hid ();grub_term_register_input ("usb_keyboard" , &grub_usb_keyboard_term); + + grub_usb_keyboard_map->normal = keyboard_map_normal; + grub_usb_keyboard_map->shift = keyboard_map_shift; }GRUB_MOD_FINI (usb_keyboard)
=== added file 'util/grub-mklayouts.c'
grub-mklayouts.c +396 -0
396 lines not on this page · raw message