|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "common/stdint.h"Go to the source code of this file.
Data Structures | |
| struct | keyboard_event_t |
| a single keyboard event returned by keyboard_read_event(). More... | |
Typedefs | |
| typedef bool(*) | keyboard_filter_fn(const keyboard_event_t *event) |
| a function that sees every key event before it is buffered (in the keyboard interrupt). | |
Enumerations | |
| enum | key_state_t { KEY_RELEASED = 0 , KEY_PRESSED = 1 } |
| keyboard key state enumeration KEY_RELEASED: the key is not pressed KEY_PRESSED: the key is pressed More... | |
| enum | keyboard_special_key_t { KEY_ARROW_UP = 1 , KEY_ARROW_DOWN = 2 , KEY_ARROW_LEFT = 3 , KEY_ARROW_RIGHT = 4 , KEY_HOME = 5 , KEY_END = 6 , KEY_PAGE_UP = 7 , KEY_PAGE_DOWN = 8 , KEY_INSERT = 9 , KEY_DELETE = 10 } |
| special key codes for keys that cannot be represented as a plain char. More... | |
| enum | keyboard_event_type_t { KEY_EVENT_CHAR = 0 , KEY_EVENT_SPECIAL = 1 , KEY_EVENT_RAW = 2 } |
| event type tag for keyboard_event_t. More... | |
Functions | |
| void | keyboard_initialize (void) |
| initialize the keyboard driver and register the keyboard interrupt handler. | |
| void | keyboard_handle_scancode (uint8_t scancode) |
| decode one byte of PS/2 scan code set 1 (0xE0 starts a two-byte code, bit 7 marks a release). | |
| void | keyboard_set_raw_events (bool on) |
| report every key press and release as a KEY_EVENT_RAW event (also the modifier keys), and no character or special events, or go back to the normal events. | |
| int | keyboard_available (void) |
| check if at least one event is available in the event buffer. | |
| char | keyboard_getchar (void) |
| read the next character from the event buffer without blocking. | |
| int | keyboard_read (void) |
| read the next character from the event buffer, blocking until one arrives. | |
| int | keyboard_read_event (keyboard_event_t *event_out) |
| read the next keyboard event from the event buffer without blocking. | |
| bool | keyboard_wait_event (keyboard_event_t *event_out) |
| read the next keyboard event from the event buffer, blocking until one arrives. | |
| void | keyboard_set_filter (keyboard_filter_fn filter) |
| set the filter (NULL: none). | |
| void | keyboard_flush (void) |
| drop every buffered event (input typed but not read yet). | |
| uint32_t | keyboard_dropped_count (void) |
| return the number of events dropped due to a full buffer since boot. | |
| typedef bool(*) keyboard_filter_fn(const keyboard_event_t *event) |
a function that sees every key event before it is buffered (in the keyboard interrupt).
it returns true to take the event out of the input: the terminal uses it for Ctrl+C and the other signal keys.
| enum key_state_t |
event type tag for keyboard_event_t.
KEY_EVENT_CHAR: the event carries a printable/control character in .character. KEY_EVENT_SPECIAL: the event carries a special key code in .special.
| Enumerator | |
|---|---|
| KEY_EVENT_CHAR | |
| KEY_EVENT_SPECIAL | |
| KEY_EVENT_RAW | |
| void keyboard_initialize | ( | void | ) |
initialize the keyboard driver and register the keyboard interrupt handler.
should be called after the IRQ subsystem is initialized.
| void keyboard_handle_scancode | ( | uint8_t | scancode | ) |
decode one byte of PS/2 scan code set 1 (0xE0 starts a two-byte code, bit 7 marks a release).
the PS/2 interrupt calls it, and the USB keyboard driver calls it with codes made from its reports. call with interrupts off.
| scancode | the byte. |
| void keyboard_set_raw_events | ( | bool | on | ) |
report every key press and release as a KEY_EVENT_RAW event (also the modifier keys), and no character or special events, or go back to the normal events.
for games, which need key releases and the positions of the keys rather than characters. the terminal turns this on with the XKEYRAW termios flag.
| int keyboard_available | ( | void | ) |
check if at least one event is available in the event buffer.
only a hint: another reader may take the event first, so callers that then read must use a read function that copes with an empty buffer.
| char keyboard_getchar | ( | void | ) |
read the next character from the event buffer without blocking.
special key events (arrow keys, etc.) are discarded; only KEY_EVENT_CHAR events are returned here. callers that need special keys should use keyboard_read_event() instead.
| int keyboard_read | ( | void | ) |
read the next character from the event buffer, blocking until one arrives.
special key events are discarded the same way as keyboard_getchar().
| int keyboard_read_event | ( | keyboard_event_t * | event_out | ) |
read the next keyboard event from the event buffer without blocking.
| event_out | output structure filled with the event type and value. |
| bool keyboard_wait_event | ( | keyboard_event_t * | event_out | ) |
read the next keyboard event from the event buffer, blocking until one arrives.
the calling process sleeps until the keyboard IRQ wakes it; it does not spin. safe with several readers: each event goes to exactly one of them.
| event_out | output structure filled with the event type and value. |
| void keyboard_set_filter | ( | keyboard_filter_fn | filter | ) |
set the filter (NULL: none).
| void keyboard_flush | ( | void | ) |
drop every buffered event (input typed but not read yet).
| uint32_t keyboard_dropped_count | ( | void | ) |
return the number of events dropped due to a full buffer since boot.