OurOS 0.1
Operating System built by McGill Students
 
Loading...
Searching...
No Matches
keyboard.c File Reference
#include "keyboard.h"
#include <stddef.h>
#include "console.h"
#include "keycode.h"
#include "keymap.h"
#include "keymap_us.h"

Macros

#define EVENT_QUEUE_LEN   64
 

Functions

int keyboard_init (hal_poll_func_t hal_poll_func)
 function to initialize the kernel keyboard system
 
bool keyboard_poll (void)
 function to poll the keyboard for available events
 
bool keyboard_pop_event (struct keyboard_event *event)
 pop an event from the keyboard event queue.
 
void keyboard_push_event (struct keyboard_event event)
 push event to the keyboard event queue
 
struct keyboard_state * keyboard_get_state ()
 get the current modifier state of the keyboard
 

Variables

static struct keyboard_state state
 
static hal_poll_func_t hal_poll
 
static struct keyboard_event event_queue [EVENT_QUEUE_LEN] = {0}
 
int event_queue_idx = 0
 
int event_count = 0
 

Macro Definition Documentation

◆ EVENT_QUEUE_LEN

#define EVENT_QUEUE_LEN   64

Function Documentation

◆ keyboard_get_state()

struct keyboard_state * keyboard_get_state ( )

get the current modifier state of the keyboard

Returns
a pointer to the keyboard's struct keyboard_state

◆ keyboard_init()

int keyboard_init ( hal_poll_func_t  poll)

function to initialize the kernel keyboard system

Parameters
pollgeneric HAL keyboard polling function
Returns
whether initialization passed or failed

◆ keyboard_poll()

bool keyboard_poll ( )

function to poll the keyboard for available events

Returns
true if new data has been pushed to event queue
Note
typically is called from irq.c, direct polling is slow

◆ keyboard_pop_event()

bool keyboard_pop_event ( struct keyboard_event *  event)

pop an event from the keyboard event queue.

Parameters
eventbuffer to store new event data in
Returns
whether there was any data in queue to pop

◆ keyboard_push_event()

void keyboard_push_event ( struct keyboard_event  event)

push event to the keyboard event queue

Parameters
eventevent to push to the queue
Note
can be used to simulate keypresses.
This function is typically called directly from the HAL keyboard driver. See ps2_keyboard.c for an example.

Variable Documentation

◆ event_count

int event_count = 0

◆ event_queue

struct keyboard_event event_queue[EVENT_QUEUE_LEN] = {0}
static

◆ event_queue_idx

int event_queue_idx = 0

◆ hal_poll

hal_poll_func_t hal_poll
static

◆ state

struct keyboard_state state
static