Date: Tue, 16 Dec 1997 10:29:26 +0100 (CET)
From: Geert Uytterhoeven <Geert.Uytterhoeven@cs.kuleuven.ac.be>
To: Linux/m68k <linux-m68k@lists.linux-m68k.org>
cc: Linux/PPC Development <linuxppc-dev@cs.wisc.edu>,
        SPARClinux CVS Repository Team <sparclinux-cvs@vger.rutgers.edu>
Subject: L68K: Keycode 0 fix
Sender: owner-linux-m68k@phil.uni-sb.de
Reply-To: Geert Uytterhoeven <Geert.Uytterhoeven@cs.kuleuven.ac.be>


This patch got lost somewhere during the last few months. It makes it possible
again to change the mapping of the key with keycode 0 (backquote/tilde on Amiga
keyboards) using loadkeys.

--- drivers/char/vt.c.orig	Mon Nov 17 22:00:32 1997
+++ drivers/char/vt.c	Mon Dec 15 22:13:58 1997
@@ -265,9 +265,12 @@
 		    if (kbd->kbdmode != VC_UNICODE)
 				return -EINVAL;
 
+		/* ++Geert: non-PC keyboards may generate keycode zero */
+#ifndef __mc68000__
 		/* assignment to entry 0 only tests validity of args */
 		if (!i)
 			break;
+#endif
 
 		if (!(key_map = key_maps[s])) {
 			int j;


This reminds me of a more principle question. What to do with keycode 0? PC
keyboards never generate scancode zero, so the keyboard driver assumes keycode
0 is invalid (that's what the comments say). But AFAIK the only place that
checks this is in vt.c (changed by the patch above).

Note: `scancode' is raw code generated by the keyboard. One keypress may
generate multiple scancodes. `keycode' is the code after interpretation (and
merging of multiple-scancode keys) by the keyboard driver, but before mapping
through the keymap. On Amiga, keycodes are equal to scancodes.

Amiga and Mac keyboards do generate scancode 0, and on Amiga it has been
working for years without problems. Unlike on Amiga, the ADB (Pmac/CHRP)
keyboard driver maps scancode 0 (the `a' key) to keycode 0x5a (which isn't
used) to obey to the PCish rules (sigh).

X uses the raw scancodes, and this now causes problems on PPC. The X server
(XF68_FBDev) inherits the keymap translation table from the kernel (by using
the keymap query ioctl KDGKBENT), but this gives problems for the `a' key:
according to the map, it's 0x5a, but when I press that key, the X server
receives code 0.

I see two solutions:

  - allow keycode 0 (and use the patch above on all architectures)

  - remap scancode 0 to an unused value very early, so no code (including X)
    ever sees a 0.

I'm in favor of the first method. I don't like arbitrary limitations that were
created `because the case doesn't happen on someones favorite architecture'.

Any comments are welcome!

Greetings,

						Geert

--
Geert Uytterhoeven                     Geert.Uytterhoeven@cs.kuleuven.ac.be
Wavelets, Linux/{m68k~Amiga,PPC~CHRP}  http://www.cs.kuleuven.ac.be/~geert/
Department of Computer Science -- Katholieke Universiteit Leuven -- Belgium

