aboutsummaryrefslogtreecommitdiff
path: root/devices/ps2_keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'devices/ps2_keyboard.c')
-rw-r--r--devices/ps2_keyboard.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/devices/ps2_keyboard.c b/devices/ps2_keyboard.c
index 6171d18..e5af423 100644
--- a/devices/ps2_keyboard.c
+++ b/devices/ps2_keyboard.c
@@ -11,9 +11,16 @@ 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[] = {'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'};
+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()
@@ -32,9 +39,22 @@ 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;
+ }
+
if (key >= 0x80) return;
- if (key < 0x37) printf("%c", scancodes[key - 1]);
+ if (key < (sizeof(scancodes[0]) / sizeof(const char))) printf("%c", scancodes[shift_case][key - 1]);
else
printf("key pressed: %x\n", key);
}