Subject: Re: kern/29558
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Matthias Pfaller <leo@dachau.marco.de>
List: netbsd-bugs
Date: 03/04/2005 09:54:01
The following reply was made to PR kern/29558; it has been noted by GNATS.

From: Matthias Pfaller <leo@dachau.marco.de>
To: gnats@netbsd.org
Cc: 
Subject: Re: kern/29558
Date: Thu, 3 Mar 2005 15:20:58 +0100 (CET)

 The last patch has problems. It autorepeats modifier keys as well. That
 one works better.
 --- ukbd.c	11 Mar 2003 16:44:00 -0000	1.85
 +++ ukbd.c	3 Mar 2005 14:15:35 -0000
 @@ -172,6 +172,8 @@
  	struct hid_location sc_capsloc;
  	struct hid_location sc_scroloc;
  	int sc_leds;
 +	usb_callout_t sc_repeat_ch;
 +	int sc_rep_char;
  #if defined(__NetBSD__)
  	usb_callout_t sc_rawrepeat_ch;
 =20
 @@ -250,6 +252,7 @@
  #ifdef WSDISPLAY_COMPAT_RAWKBD
  Static void	ukbd_rawrepeat(void *v);
  #endif
 +Static void	ukbd_repeat(void *v);
 =20
  const struct wskbd_accessops ukbd_accessops =3D {
  	ukbd_enable,
 @@ -511,7 +514,7 @@
  	u_int16_t ibuf[MAXKEYS];	/* chars events */
  	int s;
  	int nkeys, i, j;
 -	int key;
 +	int key, repkey =3D -1;
  #define ADDKEY(c) ibuf[nkeys++] =3D (c)
 =20
  #ifdef UKBD_DEBUG
 @@ -577,6 +580,7 @@
  					goto pfound;
  			DPRINTFN(2,("ukbd_intr: press key=3D0x%02x\n", key));
  			ADDKEY(key | PRESS);
 +			repkey =3D key;
  		pfound:
  			;
  		}
 @@ -631,14 +635,20 @@
  		return;
  	}
  #endif
 -
  	s =3D spltty();
 +	key =3D 0; /* shutup gcc */
  	for (i =3D 0; i < nkeys; i++) {
  		key =3D ibuf[i];
  		wskbd_input(sc->sc_wskbddev,
  		    key&RELEASE ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN,
  		    key&CODEMASK);
  	}
 +	usb_uncallout(sc->sc_repeat_ch, ukbd_repeat, sc);
 +	if (repkey !=3D -1) {
 +		sc->sc_rep_char =3D repkey;
 +		usb_callout(sc->sc_repeat_ch,
 +			    hz * REP_DELAY1 / 1000, ukbd_repeat, sc);
 +	}
  	splx(s);
  }
 =20
 @@ -683,6 +693,22 @@
  }
  #endif
 =20
 +void
 +ukbd_repeat(void *v)
 +{
 +	struct ukbd_softc *sc =3D v;
 +	int s;
 +
 +	s =3D spltty();
 +	wskbd_input(sc->sc_wskbddev, WSCONS_EVENT_KEY_UP,
 +		sc->sc_rep_char & CODEMASK);
 +	wskbd_input(sc->sc_wskbddev, WSCONS_EVENT_KEY_DOWN,
 +		sc->sc_rep_char & CODEMASK);
 +	splx(s);
 +	usb_callout(sc->sc_repeat_ch, hz * REP_DELAYN / 1000,
 +		ukbd_repeat, sc);
 +}
 +
  int
  ukbd_ioctl(void *v, u_long cmd, caddr_t data, int flag, usb_proc_ptr p)
  {
 --=20
 Matthias Pfaller                            Software Entwicklung
 marco Systemanalyse und Entwicklung GmbH    Tel   +49 8131 5161 41
 Hans-B=F6ckler-Str. 2, D 85221 Dachau         Fax   +49 8131 5161 66
 http://www.marco.de/                        Email leo@marco.de