Rev 1476 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1476 | Rev 1560 | ||
---|---|---|---|
Line 70... | Line 70... | ||
70 | 70 | ||
71 | /** Push key to key buffer. |
71 | /** Push key to key buffer. |
72 | * If buffer is full, character is ignored. |
72 | * If buffer is full, character is ignored. |
73 | * @param key code of stored key |
73 | * @param key code of stored key |
74 | */ |
74 | */ |
75 | void keybuffer_push(keybuffer_t *keybuffer, char key) |
75 | void keybuffer_push(keybuffer_t *keybuffer, int key) |
76 | { |
76 | { |
77 | futex_down(&keybuffer_futex); |
77 | futex_down(&keybuffer_futex); |
78 | if (keybuffer->items < KEYBUFFER_SIZE) { |
78 | if (keybuffer->items < KEYBUFFER_SIZE) { |
79 | keybuffer->fifo[keybuffer->tail] = key; |
79 | keybuffer->fifo[keybuffer->tail] = key; |
80 | keybuffer->tail = (keybuffer->tail + 1) % KEYBUFFER_SIZE; |
80 | keybuffer->tail = (keybuffer->tail + 1) % KEYBUFFER_SIZE; |
Line 85... | Line 85... | ||
85 | 85 | ||
86 | /** Pop character from buffer. |
86 | /** Pop character from buffer. |
87 | * @param c pointer to space where to store character from buffer. |
87 | * @param c pointer to space where to store character from buffer. |
88 | * @return zero on empty buffer, nonzero else |
88 | * @return zero on empty buffer, nonzero else |
89 | */ |
89 | */ |
90 | int keybuffer_pop(keybuffer_t *keybuffer, char *c) |
90 | int keybuffer_pop(keybuffer_t *keybuffer, int *c) |
91 | { |
91 | { |
92 | futex_down(&keybuffer_futex); |
92 | futex_down(&keybuffer_futex); |
93 | if (keybuffer->items > 0) { |
93 | if (keybuffer->items > 0) { |
94 | keybuffer->items--; |
94 | keybuffer->items--; |
95 | *c = keybuffer->fifo[keybuffer->head]; |
95 | *c = (keybuffer->fifo[keybuffer->head]) ; |
96 | keybuffer->head = (keybuffer->head + 1) % KEYBUFFER_SIZE; |
96 | keybuffer->head = (keybuffer->head + 1) % KEYBUFFER_SIZE; |
97 | futex_up(&keybuffer_futex); |
97 | futex_up(&keybuffer_futex); |
98 | return 1; |
98 | return 1; |
99 | } |
99 | } |
100 | futex_up(&keybuffer_futex); |
100 | futex_up(&keybuffer_futex); |