Code: Select all
char scancode_to_char(unsigned char scancode) {
static const char ascii_map[] = {
0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b',
'\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n',
0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`',
0, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0,
'*', 0, ' ', 0
};
if (scancode < sizeof(ascii_map)) {
return ascii_map[scancode];
} else {
return 0;
}
}
extern void keyboard_interrupt_handler() {
uint8_t scancode = inb(0x60);
outb(PIC1_COMMAND_PORT, PIC_EOI);
print(scancode_to_char(scancode));
}