Changeset dfe53af in mainline for uspace/drv/usbhid/kbddev.c
- Timestamp:
- 2011-03-10T10:47:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 17ada7a, 8a02ff3
- Parents:
- 269bd9b4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/kbddev.c
r269bd9b4 rdfe53af 37 37 #include <errno.h> 38 38 #include <str_error.h> 39 #include <fibril.h>40 39 #include <stdio.h> 41 40 … … 43 42 #include <ipc/kbd.h> 44 43 #include <async.h> 44 #include <fibril.h> 45 #include <fibril_synch.h> 45 46 46 47 #include <usb/usb.h> … … 56 57 #include "layout.h" 57 58 #include "conv.h" 59 #include "kbdrepeat.h" 58 60 59 61 /*----------------------------------------------------------------------------*/ … … 65 67 static const uint8_t BOOTP_ERROR_ROLLOVER = 1; 66 68 static const uint8_t IDLE_RATE = 0; 69 static const unsigned int DEFAULT_DELAY_BEFORE_FIRST_REPEAT = 500 * 1000; 70 static const unsigned int DEFAULT_REPEAT_DELAY = 50 * 1000; 67 71 68 72 /** Keyboard polling endpoint description for boot protocol class. */ … … 190 194 /*----------------------------------------------------------------------------*/ 191 195 192 static void usbhid_kbd_push_ev(usbhid_kbd_t *kbd_dev, int type, 193 unsigned int key) 196 void usbhid_kbd_push_ev(usbhid_kbd_t *kbd_dev, int type, unsigned int key) 194 197 { 195 198 console_event_t ev; … … 233 236 * up the lock state. 234 237 */ 238 unsigned int locks_old = kbd_dev->lock_keys; 239 235 240 kbd_dev->mods = 236 241 kbd_dev->mods ^ (mod_mask & ~kbd_dev->lock_keys); … … 238 243 239 244 /* Update keyboard lock indicator lights. */ 240 usbhid_kbd_set_led(kbd_dev); 245 if (kbd_dev->lock_keys != locks_old) { 246 usbhid_kbd_set_led(kbd_dev); 247 } 241 248 } else { 242 249 kbd_dev->lock_keys = kbd_dev->lock_keys & ~mod_mask; … … 359 366 // not found, i.e. the key was released 360 367 key = usbhid_parse_scancode(kbd_dev->keys[j]); 368 usbhid_kbd_repeat_stop(kbd_dev, key); 361 369 usbhid_kbd_push_ev(kbd_dev, KEY_RELEASE, key); 362 370 usb_log_debug2("Key released: %d\n", key); … … 383 391 key_codes[i]); 384 392 usbhid_kbd_push_ev(kbd_dev, KEY_PRESS, key); 393 usbhid_kbd_repeat_start(kbd_dev, key); 385 394 } else { 386 395 // found, nothing happens … … 527 536 } 528 537 538 if ((*kbd_dev)->repeat_mtx != NULL) { 539 /* TODO: replace by some check and wait */ 540 assert(!fibril_mutex_is_locked((*kbd_dev)->repeat_mtx)); 541 free((*kbd_dev)->repeat_mtx); 542 } 543 529 544 free(*kbd_dev); 530 545 *kbd_dev = NULL; … … 598 613 kbd_dev->mods = DEFAULT_ACTIVE_MODS; 599 614 kbd_dev->lock_keys = 0; 615 616 kbd_dev->repeat.key_new = 0; 617 kbd_dev->repeat.key_repeated = 0; 618 kbd_dev->repeat.delay_before = DEFAULT_DELAY_BEFORE_FIRST_REPEAT; 619 kbd_dev->repeat.delay_between = DEFAULT_REPEAT_DELAY; 620 621 kbd_dev->repeat_mtx = (fibril_mutex_t *)( 622 malloc(sizeof(fibril_mutex_t))); 623 if (kbd_dev->repeat_mtx == NULL) { 624 usb_log_fatal("No memory!\n"); 625 free(kbd_dev->keys); 626 return ENOMEM; 627 } 628 629 fibril_mutex_initialize(kbd_dev->repeat_mtx); 600 630 601 631 /* … … 833 863 } 834 864 fibril_add_ready(fid); 865 866 /* 867 * Create new fibril for auto-repeat 868 */ 869 fid = fibril_create(usbhid_kbd_repeat_fibril, kbd_dev); 870 if (fid == 0) { 871 usb_log_error("Failed to start fibril for KBD auto-repeat"); 872 return ENOMEM; 873 } 874 fibril_add_ready(fid); 835 875 836 876 (void)keyboard_ops;
Note:
See TracChangeset
for help on using the changeset viewer.