Subject: Re: ctrl key sequence...
To: Andrew K. Adams <akadams@wraith.psc.edu>
From: Matthias Drochner <drochner@zel459.zel.kfa-juelich.de>
List: port-i386
Date: 08/07/1999 12:21:09
akadams@wraith.psc.edu said:
> if I attempt to type a control sequence with the right control key
> (either in Emacs or on the command line) the first key I hit (in
> parallel with the control key) does not generate anything.  However,
> if I hit the key again it then works properly.

I believe this is fixed in -current and 1.4.1. I've seen it myself
with the AltGr key which is of some importance on german keyboards.
I'll append a patch which should cure it.

The effect is related to automatic key repeat: If the modifier
and the modified key are pressed in quick succession, everything
works. If the right Ctl or Alt key is pressed long enough to
go into autorepeat mode (a second or so) before the other key
is pressed, the keystroke is ignored.
The modifier keys left and right from the space bar differ in
that the right ones generate "extended" (ie two or more byte) key
sequences. There was some botch in the decoding logics which
caused the extended modifiers' autorepeat sequences not to be
ignored as it should be.
I hope it looks less mysterious now...

best regards
Matthias


Index: pckbd.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/pckbc/pckbd.c,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -c -2 -r1.17 -r1.17.2.1
*** pckbd.c	1999/03/26 12:39:13	1.17
--- pckbd.c	1999/06/25 20:59:16	1.17.2.1
***************
*** 1,3 ****
! /* $NetBSD: pckbd.c,v 1.17 1999/03/26 12:39:13 drochner Exp $ */
  
  /*-
--- 1,3 ----
! /* $NetBSD: pckbd.c,v 1.17.2.1 1999/06/25 20:59:16 perry Exp $ */
  
  /*-
***************
*** 377,381 ****
  		}
  
! 		res = pckbd_set_xtscancode(sc->id->t_kbctag, sc->id->t_kbcslot);
  		if (res)
  			return (res);
--- 377,382 ----
  		}
  
! 		res = pckbd_set_xtscancode(sc->id->t_kbctag,
! 					   sc->id->t_kbcslot);
  		if (res)
  			return (res);
***************
*** 409,412 ****
--- 410,415 ----
  	int *dataout;
  {
+ 	int key;
+ 
  	if (datain == KBR_EXTENDED0) {
  		id->t_extended = 1;
***************
*** 416,445 ****
  		return(0);
  	}
  
! 	/* process BREAK key (EXT1 1D 45  EXT1 9D C5) map to (unused) code 7F */
  	if (id->t_extended1 == 2 && (datain == 0x1d || datain == 0x9d)) {
  		id->t_extended1 = 1;
  		return(0);
! 	} else if (id->t_extended1 == 1 && (datain == 0x45 || datain == 0xc5)) {
  		id->t_extended1 = 0;
! 		datain = (datain & 0x80) | 0x7f;
  	} else if (id->t_extended1 > 0) {
  		id->t_extended1 = 0;
  	}
-  
- 	/* Always ignore typematic keys */
- 	if (datain == id->t_lastchar)
- 		return(0);
- 	id->t_lastchar = datain;
  
! 	if (datain & 0x80)
  		*type = WSCONS_EVENT_KEY_UP;
! 	else
  		*type = WSCONS_EVENT_KEY_DOWN;
! 
! 	/* map extended keys to (unused) codes 128-254 */
! 	*dataout = (datain & 0x7f) | (id->t_extended ? 0x80 : 0);
  
! 	id->t_extended = 0;
  	return(1);
  }
--- 419,454 ----
  		return(0);
  	}
+ 
+  	/* map extended keys to (unused) codes 128-254 */
+ 	key = (datain & 0x7f) | (id->t_extended ? 0x80 : 0);
+ 	id->t_extended = 0;
  
! 	/*
! 	 * process BREAK key (EXT1 1D 45  EXT1 9D C5):
! 	 * map to (unused) code 7F
! 	 */
  	if (id->t_extended1 == 2 && (datain == 0x1d || datain == 0x9d)) {
  		id->t_extended1 = 1;
  		return(0);
! 	} else if (id->t_extended1 == 1 &&
! 		   (datain == 0x45 || datain == 0xc5)) {
  		id->t_extended1 = 0;
! 		key = 0x7f;
  	} else if (id->t_extended1 > 0) {
  		id->t_extended1 = 0;
  	}
  
! 	if (datain & 0x80) {
! 		id->t_lastchar = 0;
  		*type = WSCONS_EVENT_KEY_UP;
! 	} else {
! 		/* Always ignore typematic keys */
! 		if (key == id->t_lastchar)
! 			return(0);
! 		id->t_lastchar = key;
  		*type = WSCONS_EVENT_KEY_DOWN;
! 	}
  
! 	*dataout = key;
  	return(1);
  }