diff options
author | Marvin Borner | 2020-04-29 19:21:29 +0200 |
---|---|---|
committer | Marvin Borner | 2020-04-29 19:21:29 +0200 |
commit | 4546c75d685475d8b9f215b588364e1d1bbd0b79 (patch) | |
tree | 2077f72ad46dfe877f7febdd0692edc139fd7937 /src/kernel/input/ps2 | |
parent | 396d7d303d3bf0e796d0c817883ec1dec928352a (diff) |
MUCH work in libc
Also cleaned up some syscalls etc
Diffstat (limited to 'src/kernel/input/ps2')
-rw-r--r-- | src/kernel/input/ps2/keyboard.c | 115 |
1 files changed, 10 insertions, 105 deletions
diff --git a/src/kernel/input/ps2/keyboard.c b/src/kernel/input/ps2/keyboard.c index 2056045..cc0e03d 100644 --- a/src/kernel/input/ps2/keyboard.c +++ b/src/kernel/input/ps2/keyboard.c @@ -5,113 +5,11 @@ #include <kernel/lib/string.h> #include <kernel/memory/alloc.h> -int shift_pressed; -int control_pressed; - -char keymap[128] = { - 0 /*E*/, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', - '\b', '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', - '\n', 17 /*C*/, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', - 14 /*LS*/, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 14 /*RS*/, '*', - 0, // Alt key - ' ', // Space bar - 15, // Caps lock - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // F keys - 0, // Num lock - 0, // Scroll lock - 0, // Home key - 0, // Up arrow - 0, // Page up - '-', - 0, // Left arrow - 0, - 0, // Right arrow - '+', - 0, // End key - 0, // Down arrow - 0, // Page down - 0, // Insert key - 0, // Delete key - 0, 0, 0, - 0, // F11 - 0, // F12 - 0, // Other keys -}; - -char shift_keymap[128] = { - 0 /*E*/, 27, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', - '\b', '\t', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', - '\n', 17 /*C*/, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', - 14 /*LS*/, '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 14 /*RS*/, '*', - 0, // Alt key - ' ', // Space bar - 15, // Caps lock - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // F keys - 0, // Num lock - 0, // Scroll lock - 0, // Home key - 0, // Up arrow - 0, // Page up - '-', - 0, // Left arrow - 0, - 0, // Right arrow - '+', - 0, // End key - 0, // Down arrow - 0, // Page down - 0, // Insert key - 0, // Delete key - 0, 0, 0, - 0, // F11 - 0, // F12 - 0, // Other keys -}; - -char *handle_shift(int scan_code) -{ - char *current_keymap = keymap; - if (shift_pressed) - current_keymap = shift_keymap; - - if ((scan_code & 0x80) == 0) { // PRESS - // TODO: Fix caps lock deactivation when pressing shift while (locked) shifted - if (current_keymap[scan_code] == 14 || - (current_keymap[scan_code] == 15 && !shift_pressed)) { - shift_pressed = 1; - } else if (current_keymap[scan_code] == 15 && shift_pressed) { - shift_pressed = 0; - } - } else { // RELEASE - char key = current_keymap[scan_code]; - if (key == 14) - shift_pressed = 0; - } - - return current_keymap; -} +uint8_t scancode; void keyboard_handler(struct regs *r) { - unsigned char scan_code; - - scan_code = inb(0x60); - char *current_keymap = handle_shift(scan_code); - - if ((scan_code & 0x80) == 0) { // PRESS - if (current_keymap[scan_code] == 17) - control_pressed = 1; - - if (control_pressed && current_keymap[scan_code] == 'l') { - vesa_clear(); - return; - } - - keyboard_char_buffer = current_keymap[scan_code]; - } else { // RELEASE - if (current_keymap[scan_code] == (int)0xffffffb5) // TODO: IDK WHY -107?! - control_pressed = 0; - } + scancode = inb(0x60); } void keyboard_acknowledge() @@ -127,10 +25,17 @@ void keyboard_rate() outb(0x60, 0x0); // Rate{00000} Delay{00} 0 } +char wait_scancode() +{ + scancode = 0; + while (scancode == 0) { + }; + return scancode; +} + void keyboard_install() { keyboard_rate(); irq_install_handler(1, keyboard_handler); - shift_pressed = 0; info("Installed keyboard handler"); }
\ No newline at end of file |