This patch provides a "-b" (dump binary keymap) option to the "loadkeys" utility. Binary keymap is the keymap format used by Busybox (http://www.busybox.org). Author: Michel Stempin diff -Naur kbd-1.12.orig/man/man1/loadkeys.1.in kbd-1.12/man/man1/loadkeys.1.in --- kbd-1.12.orig/man/man1/loadkeys.1.in 2002-10-11 13:08:58.000000000 +0200 +++ kbd-1.12/man/man1/loadkeys.1.in 2005-08-06 08:48:31.000000000 +0200 @@ -5,6 +5,8 @@ .SH SYNOPSIS .B loadkeys [ +.I -b --bkeymap +] [ .I -c --clearcompose ] [ .I -d --default @@ -120,6 +122,17 @@ .I /usr/src/linux\%/drivers\%/char\%/defkeymap.c, specifying the default key bindings for a kernel (and does not modify the current keymap). +.SH "CREATE BINARY KEYMAP" +If the +.I -b +(or +.I --bkeymap +) option is given +.B loadkeys +prints to the standard output a file that may be used as a binary +keymap as expected by Busybox +.B loadkmap +command (and does not modify the current keymap). .SH "OTHER OPTIONS" .TP .B \-h \-\-help diff -Naur kbd-1.12.orig/po/Makefile kbd-1.12/po/Makefile --- kbd-1.12.orig/src/loadkeys.y 2004-01-16 22:51:25.000000000 +0100 +++ kbd-1.12/src/loadkeys.y 2005-08-06 08:24:13.000000000 +0200 @@ -64,6 +64,7 @@ static void do_constant_key (int, u_short); static void loadkeys(void); static void mktable(void); +static void bkeymap(void); static void strings_as_usual(void); static void keypad_as_usual(char *keyboard); static void function_keys_as_usual(char *keyboard); @@ -253,6 +254,7 @@ " -d --default load \"" DEFMAP "\"\n" " -h --help display this help text\n" " -m --mktable output a \"defkeymap.c\" to stdout\n" +" -b --bkeymap output a binary keymap to stdout\n" " -s --clearstrings clear kernel string table\n" " -u --unicode implicit conversion to Unicode\n" " -v --verbose report the changes\n"), VERSION); @@ -260,6 +262,7 @@ } char **args; +int optb = 0; int optd = 0; int optm = 0; int opts = 0; @@ -269,8 +272,9 @@ int main(unsigned int argc, char *argv[]) { - const char *short_opts = "cdhmsuqvV"; + const char *short_opts = "bcdhmsuqvV"; const struct option long_opts[] = { + { "bkeymap", no_argument, NULL, 'b' }, { "clearcompose", no_argument, NULL, 'c' }, { "default", no_argument, NULL, 'd' }, { "help", no_argument, NULL, 'h' }, @@ -289,6 +293,9 @@ while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) { switch (c) { + case 'b': + optb = 1; + break; case 'c': nocompose = 1; break; @@ -330,6 +337,8 @@ do_constant(); if(optm) mktable(); + else if(optb) + bkeymap(); else loadkeys(); exit(0); @@ -1220,3 +1229,28 @@ exit(0); } + +static void +bkeymap () { + int i, j; + + u_char *p; + char flag, magic[] = "bkeymap"; + unsigned short v; + + write(1, magic, 7); + for (i = 0; i < MAX_NR_KEYMAPS; i++) { + flag = key_map[i]? 1 : 0; + write(1, &flag, 1); + } + for (i = 0; i < MAX_NR_KEYMAPS; i++) { + if (key_map[i]) { + for (j = 0; j < NR_KEYS / 2; j++) { + v = key_map[i][j]; + write(1, &v, 2); + } + } + } + exit(0); +} +