PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
Keyboard Abstraction

Keyboard abstraction. More...

Collaboration diagram for Keyboard Abstraction:

Detailed Description

Keyboard abstraction.

Keyboard devices are exposed as a /dev/kbd/[id]/ directory, containing the below files.

name

A read-only file that contains the driver defined name of the keyboard device.

events

A readable and pollable file that provides a stream of keyboard events represented as integer keycodes suffixed with a _ or ^ to indicate press or release respectively.

The below example shows a press of the 1 key, its subsequent release, and then a press of the A key.

30_30^5_

If no events are available to read, the read call will block until an event is available unless the file is opened in non-blocking mode in which case the read will fail with EAGAIN.

Note
The format is specified such that if scan() is used with "%u%c" the scan() call does not require any "ungets".
See also
Keyboard Keycodes for keycode definitions.

Data Structures

struct  kbd_client_t
 Keyboard event client structure. More...
 
struct  kbd_t
 Keyboard structure. More...
 

Macros

#define KBD_CLIENT_BUFFER_SIZE   512
 Size of the keyboard client buffer.
 

Functions

kbd_tkbd_new (const char *name)
 Allocate and initialize a new keyboard.
 
void kbd_free (kbd_t *kbd)
 Frees a keyboard.
 
void kbd_press (kbd_t *kbd, keycode_t code)
 Push a keyboard press event to the keyboard event queue.
 
void kbd_release (kbd_t *kbd, keycode_t code)
 Push a keyboard release event to the keyboard event queue.
 

Macro Definition Documentation

◆ KBD_CLIENT_BUFFER_SIZE

#define KBD_CLIENT_BUFFER_SIZE   512

Size of the keyboard client buffer.

Definition at line 50 of file kbd.h.

Function Documentation

◆ kbd_new()

kbd_t * kbd_new ( const char *  name)

Allocate and initialize a new keyboard.

Parameters
nameThe driver specified name of the keyboard.
Returns
On success, the new keyboard. On failure, NULL and errno is set.

Definition at line 150 of file kbd.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kbd_free()

void kbd_free ( kbd_t kbd)

Frees a keyboard.

Parameters
kbdThe keyboard to free.

Definition at line 225 of file kbd.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kbd_press()

void kbd_press ( kbd_t kbd,
keycode_t  code 
)

Push a keyboard press event to the keyboard event queue.

Parameters
kbdThe keyboard.
typeThe type of event.
codeThe keycode of the event.

Definition at line 252 of file kbd.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kbd_release()

void kbd_release ( kbd_t kbd,
keycode_t  code 
)

Push a keyboard release event to the keyboard event queue.

Parameters
kbdThe keyboard.
codeThe keycode to release.

Definition at line 270 of file kbd.c.

Here is the call graph for this function:
Here is the caller graph for this function: