diff options
author | root <root@lamia.panaceas.james.local> | 2015-06-13 13:08:23 +0100 |
---|---|---|
committer | root <root@lamia.panaceas.james.local> | 2015-06-13 13:08:23 +0100 |
commit | cd568297a41e5a6f2e130de82c07b6b789d34f4b (patch) | |
tree | a8ac2021e11d8a33d178fa521bde323c819e4c8d /app/keyboard.c | |
parent | 162fcd3f8d879615dc39181daea95ef6fcb83752 (diff) | |
download | tims_keyboard-cd568297a41e5a6f2e130de82c07b6b789d34f4b.tar.gz tims_keyboard-cd568297a41e5a6f2e130de82c07b6b789d34f4b.tar.bz2 tims_keyboard-cd568297a41e5a6f2e130de82c07b6b789d34f4b.zip |
add usb wakeup support, all keys up on bad data, and resend for parity errors
Diffstat (limited to 'app/keyboard.c')
-rw-r--r-- | app/keyboard.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/app/keyboard.c b/app/keyboard.c index d35f466..f780ccc 100644 --- a/app/keyboard.c +++ b/app/keyboard.c @@ -127,19 +127,23 @@ keyboard_send (uint8_t modifiers, uint8_t * key_list) key_list[4], key_list[5], 0 }; - usbd_ep_write_packet (usbd_dev, KEYBOARD_EP, buf, sizeof (buf)); + if (!usb_is_suspended) + usbd_ep_write_packet (usbd_dev, KEYBOARD_EP, buf, sizeof (buf)); } +static uint8_t modifiers; +static uint8_t key_list[KEY_LIST_LEN]; + void keyboard_dispatch (int sc, int updown) { - static uint8_t modifiers; - static uint8_t key_list[KEY_LIST_LEN]; int i; /*Windows needs the modifiers spliting out, so we do this as per our * descriptor, others need them in the list so we do that as well */ + usb_wakeup_host(); + switch (sc) { case USB_K_SC_LEFTCTRL: @@ -156,6 +160,7 @@ keyboard_dispatch (int sc, int updown) modifiers &= ~(1 << (sc - USB_K_SC_LEFTCTRL)); break; default: + /* Some oses are picky and need these not to move about so we make * a list of the down keys */ @@ -195,6 +200,16 @@ keyboard_dispatch (int sc, int updown) } +void +keyboard_error (void) +{ + modifiers = 0; + memset (key_list, 0, sizeof (key_list)); + keyboard_send (modifiers, key_list); +} + + + int keyboard_control_request (usbd_device * usbd_dev, struct usb_setup_data *req, uint8_t ** buf, uint16_t * len, |