diff options
Diffstat (limited to 'devices/pckbd.c')
-rw-r--r-- | devices/pckbd.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/devices/pckbd.c b/devices/pckbd.c new file mode 100644 index 0000000..f3dcb6c --- /dev/null +++ b/devices/pckbd.c @@ -0,0 +1,54 @@ +#include "keyboard.h" +#include "ps2_ctrl.h" +#include "vga.h" +#include <stdint.h> +#include <stdio.h> +#include <sys/io.h> + +const char scancodes[2][68] = {{'E', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', + 'T', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', + 'C', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 'L', + '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 'R', 'P', 'A', + ' ', 'C', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'}, + {'E', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b', 'T', 'Q', 'W', + 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', 'C', 'A', 'S', 'D', 'F', 'G', + 'H', 'J', 'K', 'L', ':', '"', '~', 'L', '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', + '>', '?', 'R', 'P', 'A', ' ', 'C', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'}}; +int shift_case = 0; + +void +ps2_keyboard_init() +{ +} + +void +ps2_keyboard_irq_handler() +{ + const uint8_t key = ps2_ctrl_read(); + + switch (key) { + case 0x2a: // left shift down + case 0x36: // right shift down + shift_case = 1; + return; + + case 0xaa: // left shift up + case 0xb6: // right shift up + shift_case = 0; + return; + + case 0x5b: // left meta + case 0x5c: // right meta + return; + + case 0x58: // F12 + vga_clear(VGA_COLOR_LIGHT_BLUE, VGA_COLOR_LIGHT_GREY); + return; + } + + if (key >= 0x80) return; + + if (key < (sizeof(scancodes[0]) / sizeof(const char))) printf("%c", scancodes[shift_case][key - 1]); + else + printf("key pressed: %x\n", key); +} |