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

22 lines
356 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 add_key_to_buffer(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;
}