PERFORCE change 166980 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Mon Aug 3 18:40:36 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=166980
Change 166980 by hselasky at hselasky_laptop001 on 2009/08/03 18:39:51
Avoid using microtime() in polling mode.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/input/ukbd.c#27 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/input/ukbd.c#27 (text+ko) ====
@@ -170,7 +170,6 @@
int32_t sc_state; /* shift/lock key state */
int32_t sc_accents; /* accent key index (> 0) */
- uint16_t sc_microtime; /* used when polling */
uint16_t sc_inputs;
uint16_t sc_inputhead;
uint16_t sc_inputtail;
@@ -303,8 +302,8 @@
static void
ukbd_do_poll(struct ukbd_softc *sc, uint8_t wait)
{
- struct timeval tv;
- uint16_t temp;
+ uint8_t i;
+ uint8_t j;
DPRINTFN(2, "polling\n");
@@ -312,21 +311,17 @@
usbd_transfer_poll(sc->sc_xfer, UKBD_N_TRANSFER);
- microtime(&tv);
+ /* Delay-optimised support for repetition of keys */
- temp = tv.tv_usec / 25000;
+ for (j = i = 0; i < UKBD_NKEYCODE; i++)
+ j |= sc->sc_odata.keycode[i];
- /* support repetition of keys: */
+ if (j) {
+ /* a key is pressed - need timekeeping */
+ DELAY(1000);
- if (sc->sc_microtime != temp) {
-
- /* wait for next delta */
-
- sc->sc_microtime = temp;
-
- /* 25 milliseconds have passed */
-
- sc->sc_time_ms += 25;
+ /* 1 millisecond has passed */
+ sc->sc_time_ms += 1;
}
ukbd_interrupt(sc);
More information about the p4-projects
mailing list