k-tana-zero/k/pic/keyboard.c

22 lines
355 B
C
Raw Normal View History

2021-07-16 01:24:01 +00:00
#include "pic/keyboard.h"
#include "io.h"
#include "utils/ring_buffer.h"
2021-07-16 01:24:01 +00:00
static struct ring_buffer keyboard_buffer = { 0 };
void keyboard_handler(void)
2021-07-16 01:24:01 +00:00
{
uint8_t key = inb(KEYBOARD_IO);
write_entry(&keyboard_buffer, key);
}
int getkey(void)
{
uint8_t key = read_entry(&keyboard_buffer);
2021-07-16 01:24:01 +00:00
if (!key)
2021-07-16 01:24:01 +00:00
return -1;
return key;
}