Changeset fa09449 in mainline for uspace/srv/kbd/generic/key_buffer.c
- Timestamp:
- 2009-02-15T22:31:07Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6cd9aa6
- Parents:
- 76dd25b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/kbd/generic/key_buffer.c
r76dd25b rfa09449 41 41 /** Clear key buffer. 42 42 */ 43 void keybuffer_free(keybuffer_t *keybuffer) 43 void keybuffer_free(keybuffer_t *keybuffer) 44 44 { 45 45 futex_down(&keybuffer_futex); … … 76 76 } 77 77 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. 81 84 */ 82 void keybuffer_push(keybuffer_t *keybuffer, int key)85 void keybuffer_push(keybuffer_t *keybuffer, const kbd_event_t *ev) 83 86 { 84 87 futex_down(&keybuffer_futex); 85 88 if (keybuffer->items < KEYBUFFER_SIZE) { 86 keybuffer->fifo[keybuffer->tail] = key;89 keybuffer->fifo[keybuffer->tail] = *ev; 87 90 keybuffer->tail = (keybuffer->tail + 1) % KEYBUFFER_SIZE; 88 91 keybuffer->items++; … … 91 94 } 92 95 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 96 void 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. 96 108 */ 97 int keybuffer_pop(keybuffer_t *keybuffer, int *c)109 int keybuffer_pop(keybuffer_t *keybuffer, kbd_event_t *edst) 98 110 { 99 111 futex_down(&keybuffer_futex); 100 112 if (keybuffer->items > 0) { 101 113 keybuffer->items--; 102 * c= (keybuffer->fifo[keybuffer->head]) ;114 *edst = (keybuffer->fifo[keybuffer->head]) ; 103 115 keybuffer->head = (keybuffer->head + 1) % KEYBUFFER_SIZE; 104 116 futex_up(&keybuffer_futex);
Note:
See TracChangeset
for help on using the changeset viewer.