|
PatchworkOS
|
Keyboard abstraction. More...
Data Structures | |
| struct | kbd_t |
| Keyboard structure. More... | |
Macros | |
| #define | KBD_MAX_EVENT 32 |
| Maximum number of queued keyboard events. | |
Functions | |
| kbd_t * | kbd_new (const char *name) |
| Allocate and initialize a keyboard structure. | |
| void | kbd_free (kbd_t *kbd) |
| Free and deinitialize a keyboard structure. | |
| void | kbd_push (kbd_t *kbd, kbd_event_type_t type, keycode_t code) |
| Push a keyboard event to the keyboard event queue. | |
Keyboard abstraction.
Keyboard devices are exposed as /dev/kbd/[id] directories, containing the following files:
events: A read-only pollable file that can be read to receive keyboard events as kbd_event_t structs.name: A read-only file that contains the keyboard driver specified name (e.g. "PS/2") | #define KBD_MAX_EVENT 32 |
| void kbd_free | ( | kbd_t * | kbd | ) |
Free and deinitialize a keyboard structure.
Removes the keyboard from /dev/kbd/[id].
| kbd | Pointer to the keyboard structure to free. |
Definition at line 147 of file kbd.c.
References DEREF, kbd_t::dir, kbd_t::eventsFile, kbd, kbd_t::nameFile, and NULL.
Referenced by ps2_kbd_init().
| kbd_t * kbd_new | ( | const char * | name | ) |
Allocate and initialize a keyboard structure.
Will make the keyboard available under /dev/kbd/[id].
| name | Driver specified name of the keyboard device. |
NULL and errno is set. Definition at line 85 of file kbd.c.
References atomic_fetch_add, calloc(), DEREF, kbd_t::dir, dirInodeOps, EINVAL, errno, kbd_t::eventsFile, eventsOps, free(), kbd, KBD_MOD_NONE, kbdDir, kbd_t::lock, lock_init(), MAX_NAME, kbd_t::mods, kbd_t::name, kbd_t::nameFile, nameOps, newId, NULL, snprintf(), strncpy(), sysfs_dir_new(), sysfs_file_new(), wait_queue_deinit(), wait_queue_init(), kbd_t::waitQueue, and kbd_t::writeIndex.
Referenced by ps2_kbd_init().
| void kbd_push | ( | kbd_t * | kbd, |
| kbd_event_type_t | type, | ||
| keycode_t | code | ||
| ) |
Push a keyboard event to the keyboard event queue.
The event will be made available to user space by reading the stream file.
| kbd | Pointer to the keyboard structure. |
| type | The type of the keyboard event. |
| code | The keycode of the keyboard event. |
Definition at line 172 of file kbd.c.
References EOK, kbd_t::events, kbd, KBD_CAPS_LOCK, KBD_LEFT_ALT, KBD_LEFT_CTRL, KBD_LEFT_SHIFT, KBD_LEFT_SUPER, KBD_MAX_EVENT, KBD_MOD_ALT, KBD_MOD_CAPS, KBD_MOD_CTRL, KBD_MOD_SHIFT, KBD_MOD_SUPER, KBD_RIGHT_ALT, KBD_RIGHT_CTRL, KBD_RIGHT_SHIFT, KBD_RIGHT_SUPER, kbd_update_mod(), kbd_t::lock, LOCK_SCOPE, kbd_t::mods, kbd_event_t::time, timer_uptime(), WAIT_ALL, wait_unblock(), kbd_t::waitQueue, and kbd_t::writeIndex.
Referenced by ps2_kbd_irq().