Here is a patch to enable simple translation of chars.

It's quite simple. I renamed the getkey definitions to raw_getkey, and added a
wrapper function getkey.

Limitation: it doesn't work for keystrokes with ctrl. If someone can tell me how
it works...

cu Pixel.

--------------------------------------------------------------------------------
diff -r -u grub-0.5.94.old/grub/asmstub.c grub-0.5.94/grub/asmstub.c
--- grub-0.5.94.old/grub/asmstub.c      Tue Feb 29 02:56:52 2000
+++ grub-0.5.94/grub/asmstub.c  Mon Mar 27 19:52:09 2000
@@ -793,7 +793,7 @@
 
 /* returns packed BIOS/ASCII code */
 int
-getkey (void)
+raw_getkey (void)
 {
   int c;
 
diff -r -u grub-0.5.94.old/stage2/asm.S grub-0.5.94/stage2/asm.S
--- grub-0.5.94.old/stage2/asm.S        Mon Feb  7 06:14:46 2000
+++ grub-0.5.94/stage2/asm.S    Mon Mar 27 19:54:42 2000
@@ -1992,7 +1992,7 @@
  *                     %al = ASCII character
  */
 
-ENTRY(getkey)
+ENTRY(raw_getkey)
        push    %ebp
        push    %ebx                    /* save %ebx */
 
diff -r -u grub-0.5.94.old/stage2/builtins.c grub-0.5.94/stage2/builtins.c
--- grub-0.5.94.old/stage2/builtins.c   Tue Feb 29 22:47:48 2000
+++ grub-0.5.94/stage2/builtins.c       Mon Mar 27 19:52:10 2000
@@ -52,6 +52,8 @@
 int grub_timeout = -1;
 /* The BIOS drive map.  */
 static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1];
+char keytable_transl[256];
+static void keytable_init (void);
 
 /* Initialize the data for builtins.  */
 void
@@ -73,6 +75,12 @@
   password = 0;
   fallback_entry = -1;
   grub_timeout = -1;
+  keytable_init();
+}
+
+int getkey(void) {
+  int c = raw_getkey();
+  return keytable_transl[ASCII_CHAR(c)] + (c & 0xff00);
 }
 
 /* Print which sector is read when loading a file.  */
@@ -1870,6 +1878,51 @@
 };
 
 
+/* keytable */
+static void
+keytable_init (void)
+{
+  int i;
+  for (i = 0; i < 256; i++) keytable_transl[i] = i;
+} 
+
+static int
+keytable_func (char *arg, int flags)
+{
+  if (arg[0] == '\0')
+    {
+      keytable_init();
+      printf("    [keytable resetted]\n");
+      return 1;
+    }
+  else 
+    {
+      int len;
+
+      if (! grub_open (arg))
+       return 0;
+
+      len = grub_read (keytable_transl, 256);
+
+      if (len == 256)
+       printf ("   [keytable @ 0x%x, 0x%x bytes]\n", keytable_transl, len);
+
+      grub_close ();
+      return len == 256;
+    }
+}
+
+static struct builtin builtin_keytable =
+{
+  "keytable",
+  keytable_func,
+  BUILTIN_CMDLINE,
+  "keytable FILE",
+  "Change the keyboard map. The file is a translation table."
+  "For example, for azerty (french) keyboard, at offset 'q' you find 'a'"
+};
+
+
 /* makeactive */
 static int
 makeactive_func (char *arg, int flags)
@@ -2953,6 +3006,7 @@
   &builtin_install,
   &builtin_ioprobe,
   &builtin_kernel,
+  &builtin_keytable,
   &builtin_makeactive,
   &builtin_map,
   &builtin_module,
diff -r -u grub-0.5.94.old/stage2/shared.h grub-0.5.94/stage2/shared.h
--- grub-0.5.94.old/stage2/shared.h     Tue Feb 22 08:25:17 2000
+++ grub-0.5.94/stage2/shared.h Mon Mar 27 19:52:10 2000
@@ -554,6 +554,7 @@
 void track_int13 (int drive);
 
 /* The key map.  */
+extern char keytable_transl[];
 extern unsigned short bios_key_map[];
 extern unsigned short ascii_key_map[];
 extern unsigned short io_map[];
@@ -619,6 +620,7 @@
 
 /* Wait for a keypress, and return its packed BIOS/ASCII key code.
    Use ASCII_CHAR(ret) to extract the ASCII code. */
+int raw_getkey (void);
 int getkey (void);
 
 /* Like GETKEY, but doesn't block, and returns -1 if no keystroke is

--------------------------------------------------------------------------------

Reply via email to