aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/keyboard.c
blob: 85b905e200624fc8d6e12c22be3a353d5d6509f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <cpu.h>
#include <def.h>
#include <interrupts.h>
#include <serial.h>
#include <vesa.h>

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);
}