Changeset fa09449 in mainline for uspace/srv/kbd/generic/key_buffer.c


Ignore:
Timestamp:
2009-02-15T22:31:07Z (16 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6cd9aa6
Parents:
76dd25b
Message:

Keycodes, keyboard events, kbd_event_get(). Keyboard driver now (formally) produces kbd events (press/release, keycode, mods, char) instead of just characters. In reality, the driver and client are only hacked to work with the new interface atm.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/kbd/generic/key_buffer.c

    r76dd25b rfa09449  
    4141/** Clear key buffer.
    4242 */
    43 void keybuffer_free(keybuffer_t *keybuffer) 
     43void keybuffer_free(keybuffer_t *keybuffer)
    4444{
    4545        futex_down(&keybuffer_futex);
     
    7676}
    7777
    78 /** Push key to key buffer.
    79  * If buffer is full, character is ignored.
    80  * @param key code of stored key
     78/** Push key event to key buffer.
     79 *
     80 * If the buffer is full, the event is ignored.
     81 *
     82 * @param keybuffer     The keybuffer.
     83 * @param ev            The event to push.
    8184 */
    82 void keybuffer_push(keybuffer_t *keybuffer, int key)
     85void keybuffer_push(keybuffer_t *keybuffer, const kbd_event_t *ev)
    8386{
    8487        futex_down(&keybuffer_futex);
    8588        if (keybuffer->items < KEYBUFFER_SIZE) {
    86                 keybuffer->fifo[keybuffer->tail] = key;
     89                keybuffer->fifo[keybuffer->tail] = *ev;
    8790                keybuffer->tail = (keybuffer->tail + 1) % KEYBUFFER_SIZE;
    8891                keybuffer->items++;
     
    9194}
    9295
    93 /** Pop character from buffer.
    94  * @param c pointer to space where to store character from buffer.
    95  * @return zero on empty buffer, nonzero else
     96void keybuffer_push0(keybuffer_t *keybuffer, int c)
     97{
     98        kbd_event_t ev;
     99
     100        ev.key = c; ev.mods = 0; ev.c = c;
     101        keybuffer_push(keybuffer, &ev);
     102}
     103
     104/** Pop event from buffer.
     105 *
     106 * @param edst  Pointer to where the event should be saved.
     107 * @return      Zero on empty buffer, nonzero otherwise.
    96108 */
    97 int keybuffer_pop(keybuffer_t *keybuffer, int *c)
     109int keybuffer_pop(keybuffer_t *keybuffer, kbd_event_t *edst)
    98110{
    99111        futex_down(&keybuffer_futex);
    100112        if (keybuffer->items > 0) {
    101113                keybuffer->items--;
    102                 *c = (keybuffer->fifo[keybuffer->head]) ;
     114                *edst = (keybuffer->fifo[keybuffer->head]) ;
    103115                keybuffer->head = (keybuffer->head + 1) % KEYBUFFER_SIZE;
    104116                futex_up(&keybuffer_futex);
Note: See TracChangeset for help on using the changeset viewer.