diff options
author | Marvin Borner | 2019-11-05 22:26:27 +0100 |
---|---|---|
committer | Marvin Borner | 2019-11-05 22:26:27 +0100 |
commit | b8b094e45ecaa7876e02e5ada246ae13e57dfe07 (patch) | |
tree | 99a32122bbea261602299cb2e85fcf45926c66c3 /src/kernel/input/ps2 | |
parent | 2180357ff5edbd4c85e125ea5c45d9b2a2026944 (diff) |
Added basic PS/2 mouse support
Diffstat (limited to 'src/kernel/input/ps2')
-rw-r--r-- | src/kernel/input/ps2/mouse.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/kernel/input/ps2/mouse.c b/src/kernel/input/ps2/mouse.c index bef226c..0ee7b2b 100644 --- a/src/kernel/input/ps2/mouse.c +++ b/src/kernel/input/ps2/mouse.c @@ -3,17 +3,19 @@ #include <kernel/graphics/vesa.h> char mouse_cycle = 0; -signed char mouse_byte[3]; -signed char mouse_x = 0; -signed char mouse_y = 0; +char mouse_byte[3]; +int mouse_x = 0; +int mouse_y = 0; int mouse_but_1 = 0; int mouse_but_2 = 0; +int mouse_but_3 = 0; void mouse_handler(struct regs *a_r) { switch (mouse_cycle) { case 0: mouse_byte[0] = receive_b(0x60); - mouse_cycle++; + if (((mouse_byte[0] >> 3) & 1) == 1) mouse_cycle++; + else mouse_cycle = 0; break; case 1: mouse_byte[1] = receive_b(0x60); @@ -21,18 +23,17 @@ void mouse_handler(struct regs *a_r) { break; case 2: mouse_byte[2] = receive_b(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_x += mouse_byte[1]; + mouse_y -= mouse_byte[2]; + mouse_but_1 = mouse_byte[0] & 1; + mouse_but_2 = (mouse_byte[0] >> 1) & 1; + mouse_but_3 = (mouse_byte[0] >> 2) & 1; mouse_cycle = 0; + vesa_draw_cursor(mouse_x, mouse_y); break; default: break; } - - if (mouse_but_1 == 1) - vesa_draw_string("CLICK!\n"); } void mouse_wait(unsigned char a_type) { @@ -88,5 +89,5 @@ void mouse_install() { mouse_read(); // Setup the mouse handler - irq_install_handler(2, mouse_handler); + irq_install_handler(12, mouse_handler); } |