OurOS 0.1
Operating System built by McGill Students
 
Loading...
Searching...
No Matches
ps2_keyboard.c File Reference
#include <stdint.h>
#include "port_io.h"
#include "keycode.h"
#include "ps2_keyboard.h"
#include "keyboard.h"

Functions

static int keyboard_available (void)
 read from ps2 status port to see if data is available
 
static uint8_t keyboard_read (void)
 read from ps2 data port
 
static bool ps2_set1_scancode_pressed (uint8_t scancode)
 checks whether scancode indicates a key was pressed or released
 
static struct keyboard_event keyboard_parse (uint8_t scancode)
 parse ps2 scancode into struct keyboard_event
 
bool ps2_poll (void)
 poll ps/2 port for available events. If event available, push to keyboard subsystem
 

Variables

static enum KEYCODE ps2_set1_scancode_to_keycode []
 table of ps2 set1 scancodes to keycodes.
 

Function Documentation

◆ keyboard_available()

static int keyboard_available ( void  )
static

read from ps2 status port to see if data is available

Returns
if bit 0 from data byte is set (indicated data is available)

◆ keyboard_parse()

static struct keyboard_event keyboard_parse ( uint8_t  scancode)
static

parse ps2 scancode into struct keyboard_event

Parameters
scancodeps/2 set1 scancode to parse
Returns
struct keyboard_event with parsed keyboard event data

◆ keyboard_read()

static uint8_t keyboard_read ( void  )
static

read from ps2 data port

Returns
ps2 scancode for what key was pressed/released

◆ ps2_poll()

bool ps2_poll ( void  )

poll ps/2 port for available events. If event available, push to keyboard subsystem

poll the ps/2 keyboard for data

Returns
whether or not a event is available

◆ ps2_set1_scancode_pressed()

static bool ps2_set1_scancode_pressed ( uint8_t  scancode)
static

checks whether scancode indicates a key was pressed or released

Parameters
scancodeset1 scancode
Returns
true if it was a press

the current implenetation is really crude and should be rewritten. It depends on a simple check whether the scancode is < 0x59. This works for the most part, as the majority of ps/2 set1 keypress scancodes are less than 0x59, however it's not always the case. Try pressing delete on your keyboard in the os and you will see. This should be rewritten to properly handle all keys.

Todo:
rewrite to properly detect all keys

Variable Documentation

◆ ps2_set1_scancode_to_keycode

enum KEYCODE ps2_set1_scancode_to_keycode[]
static

table of ps2 set1 scancodes to keycodes.

Todo:
the table does not hold any pressed/release information. Should be incorporated soon.