Changes in uspace/drv/bus/usb/usbhid/kbd/kbdrepeat.c [2d1ba51:5f6e25e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/kbd/kbdrepeat.c
r2d1ba51 r5f6e25e 45 45 #include "kbddev.h" 46 46 47 48 /** Delay between auto-repeat state checks when no key is being repeated. */ 49 static unsigned int CHECK_DELAY = 10000; 50 51 /*----------------------------------------------------------------------------*/ 47 52 /** 48 53 * Main loop handling the auto-repeat of keys. … … 55 60 * If the same key is still pressed, it uses the delay between repeats stored 56 61 * in the keyboard structure to wait until the key should be repeated. 57 * 62 * 58 63 * If the currently repeated key is not pressed any more ( 59 * usb_kbd_repeat_stop() was called), it stops repeating it and starts 64 * usb_kbd_repeat_stop() was called), it stops repeating it and starts 60 65 * checking again. 61 66 * 62 67 * @note For accessing the keyboard device auto-repeat information a fibril 63 68 * mutex (repeat_mtx) from the @a kbd structure is used. 64 * 69 * 65 70 * @param kbd Keyboard device structure. 66 71 */ … … 68 73 { 69 74 unsigned int delay = 0; 70 75 71 76 usb_log_debug("Starting autorepeat loop.\n"); 72 77 73 78 while (true) { 74 / * Check if the kbd structure is usable. */79 // check if the kbd structure is usable 75 80 if (!usb_kbd_is_initialized(kbd)) { 76 usb_log_warning("kbd not ready, exiting autorepeat.\n"); 81 if (usb_kbd_is_ready_to_destroy(kbd)) { 82 usb_kbd_destroy(kbd); 83 } 77 84 return; 78 85 } 79 80 fibril_mutex_lock( &kbd->repeat_mtx);86 87 fibril_mutex_lock(kbd->repeat_mtx); 81 88 82 89 if (kbd->repeat.key_new > 0) { 83 90 if (kbd->repeat.key_new == kbd->repeat.key_repeated) { 84 usb_log_debug2("Repeating key: %u.\n", 91 usb_log_debug2("Repeating key: %u.\n", 85 92 kbd->repeat.key_repeated); 86 usb_kbd_push_ev(kbd, KEY_PRESS, 93 // ugly hack with the NULL 94 usb_kbd_push_ev(NULL, kbd, KEY_PRESS, 87 95 kbd->repeat.key_repeated); 88 96 delay = kbd->repeat.delay_between; … … 101 109 delay = CHECK_DELAY; 102 110 } 103 fibril_mutex_unlock(&kbd->repeat_mtx); 111 fibril_mutex_unlock(kbd->repeat_mtx); 112 104 113 async_usleep(delay); 105 114 } 106 115 } 116 107 117 /*----------------------------------------------------------------------------*/ 108 118 /** … … 110 120 * 111 121 * Starts the loop for checking changes in auto-repeat. 112 * 122 * 113 123 * @param arg User-specified argument. Expects pointer to the keyboard device 114 124 * structure representing the keyboard. … … 120 130 { 121 131 usb_log_debug("Autorepeat fibril spawned.\n"); 122 132 123 133 if (arg == NULL) { 124 134 usb_log_error("No device!\n"); 125 135 return EINVAL; 126 136 } 127 128 usb_kbd_t *kbd = arg;129 137 138 usb_kbd_t *kbd = (usb_kbd_t *)arg; 139 130 140 usb_kbd_repeat_loop(kbd); 131 141 132 142 return EOK; 133 143 } 144 134 145 /*----------------------------------------------------------------------------*/ 135 146 /** … … 145 156 void usb_kbd_repeat_start(usb_kbd_t *kbd, unsigned int key) 146 157 { 147 fibril_mutex_lock( &kbd->repeat_mtx);158 fibril_mutex_lock(kbd->repeat_mtx); 148 159 kbd->repeat.key_new = key; 149 fibril_mutex_unlock( &kbd->repeat_mtx);160 fibril_mutex_unlock(kbd->repeat_mtx); 150 161 } 162 151 163 /*----------------------------------------------------------------------------*/ 152 164 /** … … 154 166 * 155 167 * @note Only one key is repeated at any time, but this function may be called 156 * even with key that is not currently repeated (in that case nothing 168 * even with key that is not currently repeated (in that case nothing 157 169 * happens). 158 170 * … … 162 174 void usb_kbd_repeat_stop(usb_kbd_t *kbd, unsigned int key) 163 175 { 164 fibril_mutex_lock( &kbd->repeat_mtx);176 fibril_mutex_lock(kbd->repeat_mtx); 165 177 if (key == kbd->repeat.key_new) { 166 178 kbd->repeat.key_new = 0; 167 179 } 168 fibril_mutex_unlock( &kbd->repeat_mtx);180 fibril_mutex_unlock(kbd->repeat_mtx); 169 181 } 182 170 183 /** 171 184 * @}
Note:
See TracChangeset
for help on using the changeset viewer.