OurOS 0.1
Operating System built by McGill Students
 
Loading...
Searching...
No Matches
keyboard.h File Reference

kernel generic keyboard interface More...

#include <stdbool.h>
#include "keycode.h"

Go to the source code of this file.

Data Structures

struct  keyboard_state
 struct to hold state of the keyboard in terms of modifier keys More...
 
struct  keyboard_event
 struct that holds a keyboard event More...
 

Typedefs

typedef bool(* hal_poll_func_t) (void)
 typedef for generic hal polling function pointer.
 

Functions

int keyboard_init (hal_poll_func_t poll)
 function to initialize the kernel keyboard system
 
bool keyboard_poll ()
 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_statekeyboard_get_state ()
 get the current modifier state of the keyboard
 

Detailed Description

kernel generic keyboard interface

Typedef Documentation

◆ hal_poll_func_t

typedef bool(* hal_poll_func_t) (void)

typedef for generic hal polling function pointer.

This allows us, when initializing the keyboard to pass a polling function (e.g. ps2_poll) dynamically.

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