aboutsummaryrefslogtreecommitdiff
path: root/devices/ps2_keyboard.c
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-11-02 09:34:31 +0200
committeraqua <aqua@iserlohn-fortress.net>2022-11-02 09:34:31 +0200
commitccaf2737f82968816c5ec962f936a593686cfb72 (patch)
tree6aa87c45c05e147c56fc4f330780386a608c33c7 /devices/ps2_keyboard.c
parentEnable interrupts after enabling the PIC (diff)
downloadkernel-ccaf2737f82968816c5ec962f936a593686cfb72.tar.xz
Add ps2_ctrl_8042
Diffstat (limited to 'devices/ps2_keyboard.c')
-rw-r--r--devices/ps2_keyboard.c69
1 files changed, 0 insertions, 69 deletions
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 <stdint.h>
-#include <stdio.h>
-#include <sys/io.h>
-
-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);
-}