diff options
author | Marvin Borner | 2019-09-19 19:56:59 +0200 |
---|---|---|
committer | Marvin Borner | 2019-09-19 20:05:38 +0200 |
commit | 05e1fedcc9cd30d1a34a65e640da45e980b4f859 (patch) | |
tree | 9cfb7620907ac126f26cdfe9363cb73ed74ea179 /src/input | |
parent | ffd82e18b5259fab477ad375a7af8550fac526d8 (diff) |
Moved source to kernel directory
Diffstat (limited to 'src/input')
-rw-r--r-- | src/input/input.h | 10 | ||||
-rw-r--r-- | src/input/ps2/keyboard.c | 50 | ||||
-rw-r--r-- | src/input/ps2/mouse.c | 107 |
3 files changed, 0 insertions, 167 deletions
diff --git a/src/input/input.h b/src/input/input.h deleted file mode 100644 index 60d2f79..0000000 --- a/src/input/input.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef MELVIX_INPUT_H -#define MELVIX_INPUT_H - -void mouse_install(); - -char get_mouse(int n); - -void keyboard_install(); - -#endif diff --git a/src/input/ps2/keyboard.c b/src/input/ps2/keyboard.c deleted file mode 100644 index ae17675..0000000 --- a/src/input/ps2/keyboard.c +++ /dev/null @@ -1,50 +0,0 @@ -#include "../../interrupts/interrupts.h" -#include "../../io/io.h" -#include "../../graphics/graphics.h" - -unsigned 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', - 0 /*C*/, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0 /*LS*/, - '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0 /*RS*/, '*', - 0, // Alt key - ' ', // Space bar - 0, // 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 -}; - -void keyboard_handler(struct regs *r) { - unsigned char scan_code; - - scan_code = receive(0x60); - - if (scan_code & 0x80) { - // Release - } else { - terminal_put_char(keymap[scan_code]); - } -} - -/* Installs the keyboard handler into IRQ1 */ -void keyboard_install() { - irq_install_handler(1, keyboard_handler); -} diff --git a/src/input/ps2/mouse.c b/src/input/ps2/mouse.c deleted file mode 100644 index 49c5a6c..0000000 --- a/src/input/ps2/mouse.c +++ /dev/null @@ -1,107 +0,0 @@ -#include "../../io/io.h" -#include "../../interrupts/interrupts.h" - -char mouse_cycle = 0; -signed char mouse_byte[3], mouse_ex[3]; -signed char mouse_x = 0; -signed char mouse_y = 0; -int mouse_but_1 = 0; -int mouse_but_2 = 0; -int mm_n[3] = {0, 0, 0,}; - -void mouse_handler(struct regs *a_r) { - switch (mouse_cycle) { - case 0: - mouse_byte[0] = receive(0x60); - mouse_cycle++; - break; - case 1: - mouse_byte[1] = receive(0x60); - mouse_cycle++; - break; - case 2: - mouse_byte[2] = receive(0x60); - mouse_x = mouse_byte[1]; - mouse_y = mouse_byte[2]; - mouse_but_1 = (mouse_byte[0] % 2); - mouse_but_2 = ((mouse_byte[0] % 4) - (mouse_byte[0] % 2)) / 2; - mouse_cycle = 0; - mouse_ex[0] = mouse_byte[0]; - mm_n[0] = 1; - mouse_ex[1] = mouse_byte[1]; - mm_n[1] = 1; - mouse_ex[2] = mouse_byte[2]; - mm_n[2] = 1; - break; - default: - break; - } -} - -inline void mouse_wait(char a_type) { - unsigned int _time_out = 100000; - if (a_type == 0) { - while (_time_out--) { - if ((receive(0x64) & 1) == 1) { - return; - } - } - return; - } else { - while (_time_out--) { - if ((receive(0x64) & 2) == 0) { - return; - } - } - return; - } -} - -inline void mouse_write(char a_write) { - mouse_wait(1); - send(0x64, 0xD4); - mouse_wait(1); - send(0x60, a_write); -} - -char mouse_read() { - mouse_wait(0); - return receive(0x60); -} - -void mouse_install() { - char _status; - - // Enable auxiliary mouse device - mouse_wait(1); - send(0x64, 0xA8); - - // Enable interrupts - mouse_wait(1); - send(0x64, 0x20); - mouse_wait(0); - _status = (receive(0x60) | 2); - mouse_wait(1); - send(0x64, 0x60); - mouse_wait(1); - send(0x60, _status); - - // Use default settings - mouse_write(0xF6); - mouse_read(); - - // Enable mouse - mouse_write(0xF4); - mouse_read(); - - // Setup the mouse handler - irq_install_handler(2, mouse_handler); -} - -char get_mouse(int n) { - if (mm_n[n] == 1) { - mm_n[n] = 0; - return mouse_ex[n]; - } else - return 0; -}
\ No newline at end of file |