PatchworkOS
Loading...
Searching...
No Matches
Keyboard Abstraction

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_tkbd_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.
 

Detailed Description

Keyboard abstraction.

Keyboard devices are exposed as /dev/kbd/[id] directories, containing the following files:

Macro Definition Documentation

◆ KBD_MAX_EVENT

#define KBD_MAX_EVENT   32

Maximum number of queued keyboard events.

Definition at line 24 of file kbd.h.

Function Documentation

◆ kbd_free()

void kbd_free ( kbd_t kbd)

Free and deinitialize a keyboard structure.

Removes the keyboard from /dev/kbd/[id].

Parameters
kbdPointer 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_new()

kbd_t * kbd_new ( const char *  name)

Allocate and initialize a keyboard structure.

Will make the keyboard available under /dev/kbd/[id].

Parameters
nameDriver specified name of the keyboard device.
Returns
On success, the new keyboard structure. On failure, 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().

◆ kbd_push()

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.

Parameters
kbdPointer to the keyboard structure.
typeThe type of the keyboard event.
codeThe 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().