From ccaf2737f82968816c5ec962f936a593686cfb72 Mon Sep 17 00:00:00 2001 From: aqua Date: Wed, 2 Nov 2022 09:34:31 +0200 Subject: Add ps2_ctrl_8042 --- devices/ps2_keyboard.c | 69 -------------------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 devices/ps2_keyboard.c (limited to 'devices/ps2_keyboard.c') diff --git a/devices/ps2_keyboard.c b/devices/ps2_keyboard.c deleted file mode 100644 index 4ebcc65..0000000 --- a/devices/ps2_keyboard.c +++ /dev/null @@ -1,69 +0,0 @@ -#include "ps2_keyboard.h" -#include "vga.h" -#include -#include -#include - -const uint8_t comm_port = 0x64; // r status register - // w command register -const uint8_t comm_enable_first_ps2 = 0xae; -const uint8_t comm_read_ctrl_config = 0x20; -const uint8_t comm_write_ctrl_config = 0x60; -const uint8_t data_port = 0x60; // rw -const uint8_t data_enable_scanning = 0xf4; - -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', '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'}}; -int shift_case = 0; - -void -ps2_keyboard_init() -{ - // eat all previous keystrikes - while (inb(comm_port) & 0x1) inb(data_port); - outb(comm_port, comm_enable_first_ps2); - outb(comm_port, comm_read_ctrl_config); - const uint8_t conf = (inb(data_port) | 1) & ~0x10; - outb(comm_port, comm_write_ctrl_config); - outb(data_port, conf); - outb(data_port, data_enable_scanning); -} - -void -ps2_keyboard_irq_handler() -{ - const uint8_t key = inb(data_port); - - 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); -} -- cgit v1.2.1