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