Hi, If I'm not mistaken, the auto-repeat keys in WSKBD_RAW mode is not needed. WSKBD_RAW mode used in X, but X independently implements auto-repeat keys.
Tested on usb keyboard, work fine. OK ? -- Alexandr Shadchin Index: arch/hp300/dev/dnkbd.c =================================================================== RCS file: /cvs/src/sys/arch/hp300/dev/dnkbd.c,v retrieving revision 1.17 diff -u -p -r1.17 dnkbd.c --- arch/hp300/dev/dnkbd.c 23 Jul 2009 21:05:56 -0000 1.17 +++ arch/hp300/dev/dnkbd.c 4 Jun 2011 12:24:10 -0000 @@ -150,11 +150,6 @@ struct dnkbd_softc { #ifdef WSDISPLAY_COMPAT_RAWKBD int sc_rawkbd; - int sc_nrep; - char sc_rep[2]; /* at most, one key */ - struct timeout sc_rawrepeat_ch; -#define REP_DELAY1 400 -#define REP_DELAYN 100 #endif }; @@ -224,7 +219,6 @@ int dnkbd_intr(void *); int dnkbd_pollin(struct apciregs *, u_int); int dnkbd_pollout(struct apciregs *, int); int dnkbd_probe(struct dnkbd_softc *); -void dnkbd_rawrepeat(void *); int dnkbd_send(struct apciregs *, const u_int8_t *, size_t); int dnsubmatch_kbd(struct device *, void *, void *); int dnsubmatch_mouse(struct device *, void *, void *); @@ -252,9 +246,6 @@ dnkbd_attach(struct device *parent, stru sc->sc_regs = (struct apciregs *)IIOV(FRODO_BASE + fa->fa_offset); timeout_set(&sc->sc_bellstop_tmo, dnkbd_bellstop, sc); -#ifdef WSDISPLAY_COMPAT_RAWKBD - timeout_set(&sc->sc_rawrepeat_ch, dnkbd_rawrepeat, sc); -#endif /* reset the port */ apciinit(sc->sc_regs, 1200, CFCR_8BITS | CFCR_PEVEN | CFCR_PENAB); @@ -667,20 +658,11 @@ dnevent_kbd_internal(struct dnkbd_softc cbuf[j] = c & 0x7f; if (type == WSCONS_EVENT_KEY_UP) cbuf[j] |= 0x80; - else { - /* remember pressed key for autorepeat */ - bcopy(cbuf, sc->sc_rep, sizeof(sc->sc_rep)); - } j++; - } - if (j != 0) { s = spltty(); wskbd_rawinput(sc->sc_wskbddev, cbuf, j); splx(s); - timeout_del(&sc->sc_rawrepeat_ch); - sc->sc_nrep = j; - timeout_add_msec(&sc->sc_rawrepeat_ch, REP_DELAY1); } } else #endif @@ -691,21 +673,6 @@ dnevent_kbd_internal(struct dnkbd_softc } } -#ifdef WSDISPLAY_COMPAT_RAWKBD -void -dnkbd_rawrepeat(void *v) -{ - struct dnkbd_softc *sc = v; - int s; - - s = spltty(); - wskbd_rawinput(sc->sc_wskbddev, sc->sc_rep, sc->sc_nrep); - splx(s); - - timeout_add_msec(&sc->sc_rawrepeat_ch, REP_DELAYN); -} -#endif - #if NWSMOUSE > 0 void dnevent_mouse(struct dnkbd_softc *sc, u_int8_t *dat) @@ -950,7 +917,6 @@ dnkbd_ioctl(void *v, u_long cmd, caddr_t #ifdef WSDISPLAY_COMPAT_RAWKBD case WSKBDIO_SETMODE: sc->sc_rawkbd = *(int *)data == WSKBD_RAW; - timeout_del(&sc->sc_rawrepeat_ch); return (0); #endif } Index: arch/zaurus/dev/zaurus_kbd.c =================================================================== RCS file: /cvs/src/sys/arch/zaurus/dev/zaurus_kbd.c,v retrieving revision 1.31 diff -u -p -r1.31 zaurus_kbd.c --- arch/zaurus/dev/zaurus_kbd.c 7 Sep 2010 16:21:41 -0000 1.31 +++ arch/zaurus/dev/zaurus_kbd.c 4 Jun 2011 12:24:11 -0000 @@ -104,10 +104,7 @@ struct zkbd_softc { int sc_rawkbd; #ifdef WSDISPLAY_COMPAT_RAWKBD const char *sc_xt_keymap; - struct timeout sc_rawrepeat_ch; #define MAXKEYS 20 - char sc_rep[MAXKEYS]; - int sc_nrep; #endif }; @@ -137,7 +134,6 @@ struct cfdriver zkbd_cd = { int zkbd_enable(void *, int); void zkbd_set_leds(void *, int); int zkbd_ioctl(void *, u_long, caddr_t, int, struct proc *); -void zkbd_rawrepeat(void *v); struct wskbd_accessops zkbd_accessops = { zkbd_enable, @@ -248,26 +244,8 @@ zkbd_attach(struct device *parent, struc sc->sc_wskbddev = config_found(self, &a, wskbddevprint); timeout_set(&(sc->sc_roll_to), zkbd_poll, sc); -#ifdef WSDISPLAY_COMPAT_RAWKBD - timeout_set(&sc->sc_rawrepeat_ch, zkbd_rawrepeat, sc); -#endif - } -#ifdef WSDISPLAY_COMPAT_RAWKBD -void -zkbd_rawrepeat(void *v) -{ - struct zkbd_softc *sc = v; - int s; - - s = spltty(); - wskbd_rawinput(sc->sc_wskbddev, sc->sc_rep, sc->sc_nrep); - splx(s); - timeout_add(&sc->sc_rawrepeat_ch, hz * REP_DELAYN / 1000); -} -#endif - /* XXX only deal with keys that can be pressed when display is open? */ /* XXX are some not in the array? */ /* handle keypress interrupt */ @@ -287,8 +265,8 @@ zkbd_poll(void *v) int stuck; int keystate; #ifdef WSDISPLAY_COMPAT_RAWKBD - int npress = 0, ncbuf = 0, c; - char cbuf[MAXKEYS *2]; + int ncbuf = 0, c; + char cbuf[MAXKEYS * 2]; #endif s = spltty(); @@ -379,15 +357,8 @@ zkbd_poll(void *v) cbuf[ncbuf++] = 0xe0; } cbuf[ncbuf] = c & 0x7f; - - if (keystate) { - if (c & 0x80) { - sc->sc_rep[npress++] = 0xe0; - } - sc->sc_rep[npress++] = c & 0x7f; - } else { + if (!keystate) cbuf[ncbuf] |= 0x80; - } ncbuf++; sc->sc_okeystate[i] = keystate; } @@ -411,14 +382,8 @@ zkbd_poll(void *v) } #ifdef WSDISPLAY_COMPAT_RAWKBD - if (sc->sc_polling == 0 && sc->sc_rawkbd) { + if (sc->sc_polling == 0 && sc->sc_rawkbd) wskbd_rawinput(sc->sc_wskbddev, cbuf, ncbuf); - sc->sc_nrep = npress; - if (npress != 0) - timeout_add(&sc->sc_rawrepeat_ch, hz * REP_DELAY1/1000); - else - timeout_del(&sc->sc_rawrepeat_ch); - } #endif if (keysdown) timeout_add(&(sc->sc_roll_to), hz * REP_DELAYN / 1000 / 2); @@ -534,7 +499,6 @@ zkbd_ioctl(void *v, u_long cmd, caddr_t #ifdef WSDISPLAY_COMPAT_RAWKBD case WSKBDIO_SETMODE: sc->sc_rawkbd = *(int *)data == WSKBD_RAW; - timeout_del(&sc->sc_rawrepeat_ch); return (0); #endif Index: dev/adb/akbd.c =================================================================== RCS file: /cvs/src/sys/dev/adb/akbd.c,v retrieving revision 1.8 diff -u -p -r1.8 akbd.c --- dev/adb/akbd.c 23 May 2010 15:09:38 -0000 1.8 +++ dev/adb/akbd.c 4 Jun 2011 12:24:11 -0000 @@ -92,7 +92,6 @@ void akbd_adbcomplete(caddr_t, caddr_t, void akbd_capslockwrapper(struct akbd_softc *, int); void akbd_input(struct akbd_softc *, int); void akbd_processevent(struct akbd_softc *, adb_event_t *); -void akbd_rawrepeat(void *v); #ifdef notyet u_char getleds(int); int setleds(struct akbd_softc *, u_char); @@ -238,10 +237,6 @@ akbdattach(struct device *parent, struct printf("akbd: returned %d from set_adb_info\n", error); #endif -#ifdef WSDISPLAY_COMPAT_RAWKBD - timeout_set(&sc->sc_rawrepeat_ch, akbd_rawrepeat, sc); -#endif - if (akbd_is_console() && wskbd_eligible) a.console = (++akbd_console_initted == 1); else @@ -421,7 +416,6 @@ akbd_ioctl(void *v, u_long cmd, caddr_t #ifdef WSDISPLAY_COMPAT_RAWKBD case WSKBDIO_SETMODE: sc->sc_rawkbd = *(int *)data == WSKBD_RAW; - timeout_del(&sc->sc_rawrepeat_ch); return (0); #endif @@ -439,20 +433,6 @@ akbd_ioctl(void *v, u_long cmd, caddr_t } } -#ifdef WSDISPLAY_COMPAT_RAWKBD -void -akbd_rawrepeat(void *v) -{ - struct akbd_softc *sc = v; - int s; - - s = spltty(); - wskbd_rawinput(sc->sc_wskbddev, sc->sc_rep, sc->sc_nrep); - splx(s); - timeout_add_msec(&sc->sc_rawrepeat_ch, REP_DELAYN); -} -#endif - /* * The ``caps lock'' key is special: since on earlier keyboards, the physical * key stays down when pressed, we will get a notification of the key press, @@ -548,11 +528,10 @@ akbd_input(struct akbd_softc *sc, int ke adb_polledkey = key; #ifdef WSDISPLAY_COMPAT_RAWKBD } else if (sc->sc_rawkbd) { - char cbuf[MAXKEYS *2]; + char cbuf[2]; int c, j, s; - int npress; - j = npress = 0; + j = 0; c = keyboard[val]; if (c == 0) { @@ -561,22 +540,12 @@ akbd_input(struct akbd_softc *sc, int ke if (c & 0x80) cbuf[j++] = 0xe0; cbuf[j] = c & 0x7f; - if (type == WSCONS_EVENT_KEY_UP) { + if (type == WSCONS_EVENT_KEY_UP) cbuf[j] |= 0x80; - } else { - /* this only records last key pressed */ - if (c & 0x80) - sc->sc_rep[npress++] = 0xe0; - sc->sc_rep[npress++] = c & 0x7f; - } j++; s = spltty(); wskbd_rawinput(sc->sc_wskbddev, cbuf, j); splx(s); - timeout_del(&sc->sc_rawrepeat_ch); - sc->sc_nrep = npress; - if (npress != 0) - timeout_add_msec(&sc->sc_rawrepeat_ch, REP_DELAY1); #endif } else { wskbd_input(sc->sc_wskbddev, type, val); Index: dev/adb/akbdvar.h =================================================================== RCS file: /cvs/src/sys/dev/adb/akbdvar.h,v retrieving revision 1.2 diff -u -p -r1.2 akbdvar.h --- dev/adb/akbdvar.h 23 Mar 2006 21:54:26 -0000 1.2 +++ dev/adb/akbdvar.h 4 Jun 2011 12:24:11 -0000 @@ -51,13 +51,7 @@ struct akbd_softc { struct device *sc_wskbddev; #ifdef WSDISPLAY_COMPAT_RAWKBD -#define MAXKEYS 20 -#define REP_DELAY1 400 -#define REP_DELAYN 100 int sc_rawkbd; - int sc_nrep; - char sc_rep[MAXKEYS]; - struct timeout sc_rawrepeat_ch; #endif /* defined(WSDISPLAY_COMPAT_RAWKBD) */ }; Index: dev/hil/hilkbd.c =================================================================== RCS file: /cvs/src/sys/dev/hil/hilkbd.c,v retrieving revision 1.14 diff -u -p -r1.14 hilkbd.c --- dev/hil/hilkbd.c 21 Jan 2009 21:53:59 -0000 1.14 +++ dev/hil/hilkbd.c 4 Jun 2011 12:24:11 -0000 @@ -64,11 +64,6 @@ struct hilkbd_softc { #ifdef WSDISPLAY_COMPAT_RAWKBD int sc_rawkbd; - int sc_nrep; - char sc_rep[HILBUFSIZE * 2]; - struct timeout sc_rawrepeat_ch; -#define REP_DELAY1 400 -#define REP_DELAYN 100 #endif }; @@ -126,7 +121,6 @@ void hilkbd_bell(struct hil_softc *, u_i void hilkbd_callback(struct hildev_softc *, u_int, u_int8_t *); void hilkbd_decode(struct hilkbd_softc *, u_int8_t, u_int *, int *, int); int hilkbd_is_console(int); -void hilkbd_rawrepeat(void *); int seen_hilkbd_console; @@ -196,10 +190,6 @@ hilkbdattach(struct device *parent, stru */ ps2 = (sc->sc_numleds != 0); -#ifdef WSDISPLAY_COMPAT_RAWKBD - timeout_set(&sc->sc_rawrepeat_ch, hilkbd_rawrepeat, sc); -#endif - /* Do not consider button boxes as console devices. */ if (ha->ha_type == HIL_DEVICE_BUTTONBOX) a.console = 0; @@ -315,7 +305,6 @@ hilkbd_ioctl(void *v, u_long cmd, caddr_ #ifdef WSDISPLAY_COMPAT_RAWKBD case WSKBDIO_SETMODE: sc->sc_rawkbd = *(int *)data == WSKBD_RAW; - timeout_del(&sc->sc_rawrepeat_ch); return 0; #endif case WSKBDIO_COMPLEXBELL: @@ -407,9 +396,8 @@ hilkbd_callback(struct hildev_softc *dev #ifdef WSDISPLAY_COMPAT_RAWKBD if (sc->sc_rawkbd) { u_char cbuf[HILBUFSIZE * 2]; - int c, j, npress; + int c, j = 0; - npress = j = 0; for (i = 1, buf++; i < buflen; i++) { hilkbd_decode(sc, *buf++, &type, &key, kbdtype); c = hilkbd_raw[key]; @@ -421,23 +409,12 @@ hilkbd_callback(struct hildev_softc *dev cbuf[j] = c & 0x7f; if (type == WSCONS_EVENT_KEY_UP) cbuf[j] |= 0x80; - else { - /* remember pressed keys for autorepeat */ - if (c & 0x80) - sc->sc_rep[npress++] = 0xe0; - sc->sc_rep[npress++] = c & 0x7f; - } j++; } s = spltty(); wskbd_rawinput(sc->sc_wskbddev, cbuf, j); splx(s); - timeout_del(&sc->sc_rawrepeat_ch); - sc->sc_nrep = npress; - if (npress != 0) { - timeout_add_msec(&sc->sc_rawrepeat_ch, REP_DELAY1); - } } else #endif { @@ -480,17 +457,3 @@ hilkbd_is_console(int hil_is_console) seen_hilkbd_console = 1; return (1); } - -#ifdef WSDISPLAY_COMPAT_RAWKBD -void -hilkbd_rawrepeat(void *v) -{ - struct hilkbd_softc *sc = v; - int s; - - s = spltty(); - wskbd_rawinput(sc->sc_wskbddev, sc->sc_rep, sc->sc_nrep); - splx(s); - timeout_add_msec(&sc->sc_rawrepeat_ch, REP_DELAYN); -} -#endif Index: dev/sun/sunkbd.c =================================================================== RCS file: /cvs/src/sys/dev/sun/sunkbd.c,v retrieving revision 1.25 diff -u -p -r1.25 sunkbd.c --- dev/sun/sunkbd.c 12 Jan 2009 21:11:58 -0000 1.25 +++ dev/sun/sunkbd.c 4 Jun 2011 12:24:12 -0000 @@ -61,7 +61,6 @@ void sunkbd_decode5(u_int8_t, u_int *, i int sunkbd_enable(void *, int); int sunkbd_getleds(struct sunkbd_softc *); int sunkbd_ioctl(void *, u_long, caddr_t, int, struct proc *); -void sunkbd_rawrepeat(void *); void sunkbd_setleds(void *, int); struct wskbd_accessops sunkbd_accessops = { @@ -73,10 +72,6 @@ struct wskbd_accessops sunkbd_accessops void sunkbd_attach(struct sunkbd_softc *sc, struct wskbddev_attach_args *waa) { -#ifdef WSDISPLAY_COMPAT_RAWKBD - timeout_set(&sc->sc_rawrepeat_tmo, sunkbd_rawrepeat, sc); -#endif - if (ISTYPE5(sc->sc_layout)) sc->sc_decode = sunkbd_decode5; else @@ -189,11 +184,8 @@ sunkbd_input(struct sunkbd_softc *sc, u_ #ifdef WSDISPLAY_COMPAT_RAWKBD if (sc->sc_rawkbd) { u_char rbuf[SUNKBD_MAX_INPUT_SIZE * 2]; - int c, rlen, npress; - - timeout_del(&sc->sc_rawrepeat_tmo); + int c, rlen = 0; - npress = rlen = 0; while (buflen-- != 0) { (*sc->sc_decode)(*buf++, &type, &value); c = sunkbd_rawmap[value]; @@ -205,21 +197,12 @@ sunkbd_input(struct sunkbd_softc *sc, u_ rbuf[rlen] = c & 0x7f; if (type == WSCONS_EVENT_KEY_UP) rbuf[rlen] |= 0x80; - else { - /* remember down keys for autorepeat */ - if (c & 0x80) - sc->sc_rep[npress++] = 0xe0; - sc->sc_rep[npress++] = c & 0x7f; - } rlen++; } s = spltty(); wskbd_rawinput(sc->sc_wskbddev, rbuf, rlen); splx(s); - sc->sc_nrep = npress; - if (npress != 0) - timeout_add_msec(&sc->sc_rawrepeat_tmo, REP_DELAY1); } else #endif { @@ -259,7 +242,6 @@ sunkbd_ioctl(void *v, u_long cmd, caddr_ #ifdef WSDISPLAY_COMPAT_RAWKBD case WSKBDIO_SETMODE: sc->sc_rawkbd = *(int *)data == WSKBD_RAW; - timeout_del(&sc->sc_rawrepeat_tmo); return (0); #endif } @@ -308,20 +290,6 @@ sunkbd_raw(struct sunkbd_softc *sc, u_in break; } } - -#ifdef WSDISPLAY_COMPAT_RAWKBD -void -sunkbd_rawrepeat(void *v) -{ - struct sunkbd_softc *sc = v; - int s; - - s = spltty(); - wskbd_rawinput(sc->sc_wskbddev, sc->sc_rep, sc->sc_nrep); - splx(s); - timeout_add_msec(&sc->sc_rawrepeat_tmo, REP_DELAYN); -} -#endif int sunkbd_setclick(struct sunkbd_softc *sc, int click) Index: dev/sun/sunkbdvar.h =================================================================== RCS file: /cvs/src/sys/dev/sun/sunkbdvar.h,v retrieving revision 1.15 diff -u -p -r1.15 sunkbdvar.h --- dev/sun/sunkbdvar.h 12 Jan 2009 21:11:58 -0000 1.15 +++ dev/sun/sunkbdvar.h 4 Jun 2011 12:24:12 -0000 @@ -52,11 +52,6 @@ struct sunkbd_softc { #ifdef WSDISPLAY_COMPAT_RAWKBD int sc_rawkbd; - int sc_nrep; - char sc_rep[SUNKBD_MAX_INPUT_SIZE * 2]; - struct timeout sc_rawrepeat_tmo; -#define REP_DELAY1 400 -#define REP_DELAYN 100 #endif }; Index: dev/usb/hidkbd.c =================================================================== RCS file: /cvs/src/sys/dev/usb/hidkbd.c,v retrieving revision 1.4 diff -u -p -r1.4 hidkbd.c --- dev/usb/hidkbd.c 23 Oct 2010 16:14:06 -0000 1.4 +++ dev/usb/hidkbd.c 4 Jun 2011 12:24:12 -0000 @@ -152,10 +152,6 @@ void *hidkbd_bell_fn_arg; void hidkbd_decode(struct hidkbd *, struct hidkbd_data *); void hidkbd_delayed_decode(void *addr); -#ifdef WSDISPLAY_COMPAT_RAWKBD -void hidkbd_rawrepeat(void *); -#endif - extern const struct wscons_keydesc ukbd_keydesctab[]; struct wskbd_mapdata ukbd_keymapdata = { @@ -193,9 +189,6 @@ hidkbd_attach(struct device *self, struc hidkbd_is_console = 0; } -#ifdef WSDISPLAY_COMPAT_RAWKBD - timeout_set(&kbd->sc_rawrepeat_ch, hidkbd_rawrepeat, kbd); -#endif timeout_set(&kbd->sc_delay, hidkbd_delayed_decode, kbd); return 0; @@ -223,11 +216,6 @@ hidkbd_detach(struct hidkbd *kbd, int fl DPRINTF(("hidkbd_detach: sc=%p flags=%d\n", kbd->sc_device, flags)); -#ifdef WSDISPLAY_COMPAT_RAWKBD - if (timeout_initialized(&kbd->sc_rawrepeat_ch)) - timeout_del(&kbd->sc_rawrepeat_ch); -#endif - if (kbd->sc_console_keyboard) { #if 0 /* @@ -416,9 +404,8 @@ hidkbd_decode(struct hidkbd *kbd, struct if (kbd->sc_rawkbd) { u_char cbuf[MAXKEYS * 2]; int c; - int npress; - for (npress = i = j = 0; i < nkeys; i++) { + for (i = j = 0; i < nkeys; i++) { key = ibuf[i]; c = hidkbd_trtab[key & CODEMASK]; if (c == NN) @@ -428,12 +415,6 @@ hidkbd_decode(struct hidkbd *kbd, struct cbuf[j] = c & 0x7f; if (key & RELEASE) cbuf[j] |= 0x80; - else { - /* remember pressed keys for autorepeat */ - if (c & 0x80) - kbd->sc_rep[npress++] = 0xe0; - kbd->sc_rep[npress++] = c & 0x7f; - } DPRINTFN(1,("hidkbd_decode: raw = %s0x%02x\n", c & 0x80 ? "0xe0 " : "", cbuf[j])); @@ -441,11 +422,6 @@ hidkbd_decode(struct hidkbd *kbd, struct } s = spltty(); wskbd_rawinput(kbd->sc_wskbddev, cbuf, j); - if (npress != 0) { - kbd->sc_nrep = npress; - timeout_add_msec(&kbd->sc_rawrepeat_ch, REP_DELAY1); - } else - timeout_del(&kbd->sc_rawrepeat_ch); /* * Pass audio keys to wskbd_input anyway. @@ -530,26 +506,11 @@ hidkbd_ioctl(struct hidkbd *kbd, u_long case WSKBDIO_SETMODE: DPRINTF(("hidkbd_ioctl: set raw = %d\n", *(int *)data)); kbd->sc_rawkbd = *(int *)data == WSKBD_RAW; - timeout_del(&kbd->sc_rawrepeat_ch); return (0); #endif } return (-1); } - -#ifdef WSDISPLAY_COMPAT_RAWKBD -void -hidkbd_rawrepeat(void *v) -{ - struct hidkbd *kbd = v; - int s; - - s = spltty(); - wskbd_rawinput(kbd->sc_wskbddev, kbd->sc_rep, kbd->sc_nrep); - splx(s); - timeout_add_msec(&kbd->sc_rawrepeat_ch, REP_DELAYN); -} -#endif void hidkbd_cngetc(struct hidkbd *kbd, u_int *type, int *data) Index: dev/usb/hidkbdsc.h =================================================================== RCS file: /cvs/src/sys/dev/usb/hidkbdsc.h,v retrieving revision 1.1 diff -u -p -r1.1 hidkbdsc.h --- dev/usb/hidkbdsc.h 31 Jul 2010 16:04:50 -0000 1.1 +++ dev/usb/hidkbdsc.h 4 Jun 2011 12:24:12 -0000 @@ -75,13 +75,8 @@ struct hidkbd { struct hidkbd_data sc_data; /* for quirk handling */ /* key repeat logic */ - struct timeout sc_rawrepeat_ch; #if defined(WSDISPLAY_COMPAT_RAWKBD) -#define REP_DELAY1 400 -#define REP_DELAYN 100 int sc_rawkbd; - int sc_nrep; - char sc_rep[MAXKEYS]; #endif /* defined(WSDISPLAY_COMPAT_RAWKBD) */ int sc_polling;