Ignore:
Timestamp:
2012-02-18T16:47:38Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4449c6c
Parents:
bd5f3b7 (diff), f943dd3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhid/kbd/kbdrepeat.c

    rbd5f3b7 r00aece0  
    4545#include "kbddev.h"
    4646
    47 
    48 /** Delay between auto-repeat state checks when no key is being repeated. */
    49 static unsigned int CHECK_DELAY = 10000;
    50 
    51 /*----------------------------------------------------------------------------*/
    5247/**
    5348 * Main loop handling the auto-repeat of keys.
     
    6055 * If the same key is still pressed, it uses the delay between repeats stored
    6156 * in the keyboard structure to wait until the key should be repeated.
    62  * 
     57 *
    6358 * If the currently repeated key is not pressed any more (
    64  * usb_kbd_repeat_stop() was called), it stops repeating it and starts 
     59 * usb_kbd_repeat_stop() was called), it stops repeating it and starts
    6560 * checking again.
    6661 *
    6762 * @note For accessing the keyboard device auto-repeat information a fibril
    6863 *       mutex (repeat_mtx) from the @a kbd structure is used.
    69  * 
     64 *
    7065 * @param kbd Keyboard device structure.
    7166 */
     
    7368{
    7469        unsigned int delay = 0;
    75        
     70
    7671        usb_log_debug("Starting autorepeat loop.\n");
    7772
    7873        while (true) {
    79                 // check if the kbd structure is usable
     74                /* Check if the kbd structure is usable. */
    8075                if (!usb_kbd_is_initialized(kbd)) {
    81                         if (usb_kbd_is_ready_to_destroy(kbd)) {
    82                                 usb_kbd_free(&kbd);
    83                                 assert(kbd == NULL);
    84                         }
     76                        usb_log_warning("kbd not ready, exiting autorepeat.\n");
    8577                        return;
    8678                }
    87                
    88                 fibril_mutex_lock(kbd->repeat_mtx);
     79
     80                fibril_mutex_lock(&kbd->repeat_mtx);
    8981
    9082                if (kbd->repeat.key_new > 0) {
    9183                        if (kbd->repeat.key_new == kbd->repeat.key_repeated) {
    92                                 usb_log_debug2("Repeating key: %u.\n", 
     84                                usb_log_debug2("Repeating key: %u.\n",
    9385                                    kbd->repeat.key_repeated);
    94                                 // ugly hack with the NULL
    95                                 usb_kbd_push_ev(NULL, kbd, KEY_PRESS,
     86                                usb_kbd_push_ev(kbd, KEY_PRESS,
    9687                                    kbd->repeat.key_repeated);
    9788                                delay = kbd->repeat.delay_between;
     
    110101                        delay = CHECK_DELAY;
    111102                }
    112                 fibril_mutex_unlock(kbd->repeat_mtx);
    113                
     103                fibril_mutex_unlock(&kbd->repeat_mtx);
    114104                async_usleep(delay);
    115105        }
    116106}
    117 
    118107/*----------------------------------------------------------------------------*/
    119108/**
     
    121110 *
    122111 * Starts the loop for checking changes in auto-repeat.
    123  * 
     112 *
    124113 * @param arg User-specified argument. Expects pointer to the keyboard device
    125114 *            structure representing the keyboard.
     
    131120{
    132121        usb_log_debug("Autorepeat fibril spawned.\n");
    133        
     122
    134123        if (arg == NULL) {
    135124                usb_log_error("No device!\n");
    136125                return EINVAL;
    137126        }
    138        
    139         usb_kbd_t *kbd = (usb_kbd_t *)arg;
    140        
     127
     128        usb_kbd_t *kbd = arg;
     129
    141130        usb_kbd_repeat_loop(kbd);
    142        
     131
    143132        return EOK;
    144133}
    145 
    146134/*----------------------------------------------------------------------------*/
    147135/**
     
    157145void usb_kbd_repeat_start(usb_kbd_t *kbd, unsigned int key)
    158146{
    159         fibril_mutex_lock(kbd->repeat_mtx);
     147        fibril_mutex_lock(&kbd->repeat_mtx);
    160148        kbd->repeat.key_new = key;
    161         fibril_mutex_unlock(kbd->repeat_mtx);
     149        fibril_mutex_unlock(&kbd->repeat_mtx);
    162150}
    163 
    164151/*----------------------------------------------------------------------------*/
    165152/**
     
    167154 *
    168155 * @note Only one key is repeated at any time, but this function may be called
    169  *       even with key that is not currently repeated (in that case nothing 
     156 *       even with key that is not currently repeated (in that case nothing
    170157 *       happens).
    171158 *
     
    175162void usb_kbd_repeat_stop(usb_kbd_t *kbd, unsigned int key)
    176163{
    177         fibril_mutex_lock(kbd->repeat_mtx);
     164        fibril_mutex_lock(&kbd->repeat_mtx);
    178165        if (key == kbd->repeat.key_new) {
    179166                kbd->repeat.key_new = 0;
    180167        }
    181         fibril_mutex_unlock(kbd->repeat_mtx);
     168        fibril_mutex_unlock(&kbd->repeat_mtx);
    182169}
    183 
    184170/**
    185171 * @}
Note: See TracChangeset for help on using the changeset viewer.