From e7662496ad331266b8fcc0df514523f97cb703e4 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 22 Jul 2020 22:25:28 +0200 Subject: Initial keyboard implementation --- src/drivers/keyboard.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/drivers/keyboard.c (limited to 'src/drivers/keyboard.c') diff --git a/src/drivers/keyboard.c b/src/drivers/keyboard.c new file mode 100644 index 0000000..85b905e --- /dev/null +++ b/src/drivers/keyboard.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include + +u8 scancode; + +void keyboard_handler(struct regs *r) +{ + scancode = inb(0x60); + serial_print("KEY\n"); + //struct keyboard_event *event = malloc(sizeof(struct keyboard_event)); + //event->scancode = scancode; + //event_trigger(MAP_KEYBOARD, (u8 *)event); +} + +void keyboard_acknowledge() +{ + while (inb(0x60) != 0xfa) + ; +} + +void keyboard_rate() +{ + outb(0x60, 0xF3); + keyboard_acknowledge(); + outb(0x60, 0x0); // Rate{00000} Delay{00} 0 +} + +char wait_scancode() +{ + scancode = 0; + while (scancode == 0) { + }; + return scancode; +} + +void keyboard_install() +{ + //keyboard_rate(); TODO: Fix keyboard rate? + irq_install_handler(1, keyboard_handler); +} -- cgit v1.2.3