Subject: Re: multiuser X 4.1.0
To: None <port-i386@netbsd.org>
From: Matthias Pfaller <leo@marco.de>
List: port-i386
Date: 10/02/2001 16:07:08
In article <200109071300.f87D0ux11799@lethe.dachau.marco.de>,
	leo@marco.de (Matthias Pfaller) writes:
> In article <200109050646.f856kex03245@lethe.dachau.marco.de>,
> 	leo@lethe.dachau.marco.de (Matthias Pfaller) writes:
>> in my config file I was able to run two X servers with two graphic
>> boards and two keyboards on my machine. I still have to get some USB
>> mice. For the first tests I just run without mice. Connecting a second
>> keyboard to the mouseport worked like a charm. It looks like the X server
>> will not work with the raw keyboard devices. I had to specify the mux devices
>> in XF86Config.
> 
> Now that I have a couple of USB mice, I was able to really use my
> multihead/multiuser X-Terminal. There are a two problems remaining
> because I'm using a second keyboard connected to the mouseport.
> 
> First of all, the keyboard mapping for some of the keys seem to be
> "unusual". The Insert/Home/PageUp/Remove/End/Pagedown and some other
> keys report different scancodes to X than on the main keyboard. Any
> ideas? I did a special xmodmap to make this work (so this isn't a
> real problem). The other problem is that I'm unable to make autorepeat
> work on the second keyboard.

Finally I had enough time to track down this last problem. Usually the
X-Server puts the keyboard into "raw" mode and does all the scan code
magic.

When I start the X-Server for the second graphics board with the -nocons
option my patch is providing, X is using the keyboard in "event" mode. In
that mode the kernel filters out typematic events (and thus I don't get
autorepeat) and the "special keys" report back different scan codes from
usual. The following hack makes everything work as expected (for me):

RCS file: /cvsroot/syssrc/sys/dev/pckbc/pckbd.c,v
retrieving revision 1.26
diff -u -u -r1.26 pckbd.c
--- pckbd.c	2001/07/07 16:58:27	1.26
+++ pckbd.c	2001/10/02 14:03:22
@@ -445,13 +445,35 @@
 		id->t_extended1 = 0;
 	}
 
+	switch (key) {
+		case 156: key =  95; break; /* End		*/
+		case 157: key = 101; break; /* Ctrl_R		*/
+		case 181: key = 104; break; /* KP_F2		*/
+		case 184: key = 105; break; /* Alt_R		*/
+		case 199: key =  89; break; /* KP_F1		*/
+		case 200: key =  90; break; /* Up		*/
+		case 201: key =  91; break; /* Prior		*/
+		case 203: key =  92; break; /* Left		*/
+		case 205: key =  94; break; /* Right		*/
+		case 207: key = 100; break; /* KP_Enter 	*/
+		case 208: key =  96; break; /* Down		*/
+		case 209: key =  97; break; /* Next		*/
+		case 210: key =  98; break; /* Insert		*/
+		case 211: key =  99; break; /* Delete		*/
+		case 219: key = 107; break; /* Meta_L		*/
+		case 220: key = 108; break; /* Meta_R		*/
+		case 221: key = 109; break; /* Menu		*/
+	}
+
 	if (datain & 0x80) {
 		id->t_lastchar = 0;
 		*type = WSCONS_EVENT_KEY_UP;
 	} else {
+#if 0
 		/* Always ignore typematic keys */
 		if (key == id->t_lastchar)
 			return(0);
+#endif
 		id->t_lastchar = key;
 		*type = WSCONS_EVENT_KEY_DOWN;
 	}

With X on the main graphics board everything still works as expected because
the keyboard is used in "raw" mode anyway. The second server is using event
mode and thus my "translations" work ok. Typematic keys are no longer filtered
and so I get working autorepeat.

BUT: In console mode the special keys no longer work because I remap them and
     now we have to autorepeat generators running.

Either the X server needs to get fixed, or we provide a wskbd ioctl to put
the keyboard into "translating" mode even when used in event mode. This
would solve the problems with the USB keyboards as well.

Regards, Matthias
-- 
Matthias Pfaller                            Software Entwicklung
marco Systemanalyse und Entwicklung GmbH    Tel   +49 8131 5161-41
Hans-Böckler-Str. 2, D 85221 Dachau         Fax   +49 8131 5161-66
http://www.marco.de/                        Email leo@dachau.marco.de