diff options
-rw-r--r-- | sys/dev/usb/ukbd.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c index d06bd37..4496e86 100644 --- a/sys/dev/usb/ukbd.c +++ b/sys/dev/usb/ukbd.c @@ -422,7 +422,7 @@ static int ukbd_enable_intr(keyboard_t *kbd, int on, usbd_intr_t *func); static void ukbd_timeout(void *arg); -static int ukbd_getc(ukbd_state_t *state); +static int ukbd_getc(ukbd_state_t *state, int wait); static int probe_keyboard(struct usb_attach_arg *uaa, int flags); static int init_keyboard(ukbd_state_t *state, int *type, int flags); @@ -845,7 +845,7 @@ ukbd_interrupt(keyboard_t *kbd, void *arg) } static int -ukbd_getc(ukbd_state_t *state) +ukbd_getc(ukbd_state_t *state, int wait) { int c; int s; @@ -853,8 +853,11 @@ ukbd_getc(ukbd_state_t *state) if (state->ks_polling) { DPRINTFN(1,("ukbd_getc: polling\n")); s = splusb(); - while (state->ks_inputs <= 0) + while (state->ks_inputs <= 0) { usbd_dopoll(state->ks_iface); + if (wait == FALSE) + break; + } splx(s); } s = splusb(); @@ -930,7 +933,7 @@ ukbd_read(keyboard_t *kbd, int wait) #endif /* UKBD_EMULATE_ATSCANCODE */ /* XXX */ - usbcode = ukbd_getc(state); + usbcode = ukbd_getc(state, wait); if (!KBD_IS_ACTIVE(kbd) || (usbcode == -1)) return -1; ++kbd->kb_count; @@ -1022,7 +1025,7 @@ next_code: /* see if there is something in the keyboard port */ /* XXX */ - usbcode = ukbd_getc(state); + usbcode = ukbd_getc(state, wait); if (usbcode == -1) return NOKEY; ++kbd->kb_count; @@ -1392,9 +1395,9 @@ ukbd_poll(keyboard_t *kbd, int on) s = splusb(); if (on) { - if (state->ks_polling == 0) - usbd_set_polling(dev, on); ++state->ks_polling; + if (state->ks_polling == 1) + usbd_set_polling(dev, on); } else { --state->ks_polling; if (state->ks_polling == 0) |