LumaOS  v0.1.116
An experimental x86-64 OS
Loading...
Searching...
No Matches
keyboard.h File Reference

Handler and utilities for the keyboard. More...

#include <stdbool.h>
#include <arch/x86_64/io.h>
#include <stdint.h>
Include dependency graph for keyboard.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  key_event
 A decoded key event. More...

Macros

#define PS2_DATA   0x60
#define PS2_STATUS   0x64
#define PS2_COMMAND   0x64
#define KBD_BUF_SIZE   256

Functions

static void ps2_wait_write (void)
 Wait until ps/2 input buffer is empty.
static void ps2_wait_read (void)
 wait until a byte is waiting
void keyboard_init (void)
 Initialize the keyboard driver and register the handler with the IRQ handler.
int kbd_buf_pop (void)
 Pops byte from the keyboard key buffer.
bool kbd_decode (uint8_t raw, struct key_event *ev)
 Convert a keyboard byte into the correct char.
int kbd_getchar (void)
 Waits for a key to be pressed and returns the character.

Variables

bool shift_down
 Keyboard modifier key status.
bool ctrl_down
bool alt_down
bool caps_on

Detailed Description

Handler and utilities for the keyboard.

Author
Matheus Boscariol
Since
25/11/2026

Definition in file keyboard.h.

Macro Definition Documentation

◆ KBD_BUF_SIZE

#define KBD_BUF_SIZE   256

Definition at line 21 of file keyboard.h.

◆ PS2_COMMAND

#define PS2_COMMAND   0x64

Definition at line 19 of file keyboard.h.

◆ PS2_DATA

#define PS2_DATA   0x60

Definition at line 17 of file keyboard.h.

◆ PS2_STATUS

#define PS2_STATUS   0x64

Definition at line 18 of file keyboard.h.

Function Documentation

◆ kbd_buf_pop()

int kbd_buf_pop ( void )

Pops byte from the keyboard key buffer.

Returns
Byte from the key buffer (FIFO)

Definition at line 61 of file keyboard.c.

◆ kbd_decode()

bool kbd_decode ( uint8_t raw,
struct key_event * ev )

Convert a keyboard byte into the correct char.

Parameters
rawThe raw byte from the keyboard
evThe key event to write to.
Returns
true = decoding successful
false = decoding failed

Definition at line 78 of file keyboard.c.

◆ kbd_getchar()

int kbd_getchar ( void )

Waits for a key to be pressed and returns the character.

Definition at line 68 of file keyboard.c.

Here is the call graph for this function:

◆ keyboard_init()

void keyboard_init ( void )

Initialize the keyboard driver and register the handler with the IRQ handler.

Definition at line 128 of file keyboard.c.

Here is the call graph for this function:

◆ ps2_wait_read()

void ps2_wait_read ( void )
inlinestatic

wait until a byte is waiting

Definition at line 45 of file keyboard.h.

Here is the call graph for this function:

◆ ps2_wait_write()

void ps2_wait_write ( void )
inlinestatic

Wait until ps/2 input buffer is empty.

Definition at line 40 of file keyboard.h.

Here is the call graph for this function:

Variable Documentation

◆ alt_down

bool alt_down

Definition at line 35 of file keyboard.h.

◆ caps_on

bool caps_on

Definition at line 35 of file keyboard.h.

◆ ctrl_down

bool ctrl_down

Definition at line 35 of file keyboard.h.

◆ shift_down

bool shift_down
extern

Keyboard modifier key status.

Definition at line 30 of file keyboard.c.