diff options
author | Marvin Borner | 2020-05-06 22:34:38 +0200 |
---|---|---|
committer | Marvin Borner | 2020-05-06 22:34:38 +0200 |
commit | 8083536f321ad8a12ad4668c2bf41a65c3e3b2f6 (patch) | |
tree | 427d7da11944b299bdce3041259bf8fd31971ede /src/kernel/input | |
parent | d94ffac4a584dc7a4f6f2ec567b8caab05ce9253 (diff) |
Added event mapping driver
Diffstat (limited to 'src/kernel/input')
-rw-r--r-- | src/kernel/input/ps2/keyboard.c | 5 | ||||
-rw-r--r-- | src/kernel/input/ps2/mouse.c | 26 |
2 files changed, 23 insertions, 8 deletions
diff --git a/src/kernel/input/ps2/keyboard.c b/src/kernel/input/ps2/keyboard.c index dceba05..41ab1bb 100644 --- a/src/kernel/input/ps2/keyboard.c +++ b/src/kernel/input/ps2/keyboard.c @@ -1,3 +1,5 @@ +#include <common.h> +#include <events/event.h> #include <interrupts/interrupts.h> #include <io/io.h> #include <graphics/vesa.h> @@ -10,6 +12,9 @@ u8 scancode; void keyboard_handler(struct regs *r) { scancode = inb(0x60); + struct keyboard_event *event = umalloc(sizeof(struct keyboard_event)); + event->scancode = scancode; + event_trigger(MAP_KEYBOARD, (u8 *)event); } void keyboard_acknowledge() diff --git a/src/kernel/input/ps2/mouse.c b/src/kernel/input/ps2/mouse.c index c1e39ba..ce3158e 100644 --- a/src/kernel/input/ps2/mouse.c +++ b/src/kernel/input/ps2/mouse.c @@ -1,3 +1,6 @@ +#include <common.h> +#include <events/event.h> +#include <memory/alloc.h> #include <interrupts/interrupts.h> #include <io/io.h> #include <graphics/vesa.h> @@ -11,7 +14,9 @@ int mouse_but_1 = 0; int mouse_but_2 = 0; int mouse_but_3 = 0; -void mouse_handler(struct regs *a_r) +struct mouse_event *event; + +void mouse_handler(struct regs *r) { switch (mouse_cycle) { case 0: @@ -42,14 +47,18 @@ void mouse_handler(struct regs *a_r) mouse_x = vbe_width - 1; if (mouse_y > vbe_height - 1) mouse_y = vbe_height - 1; - vesa_draw_cursor(mouse_x, mouse_y); + // vesa_draw_cursor(mouse_x, mouse_y); + + event->mouse_x = mouse_x; + event->mouse_y = mouse_y; + event_trigger(MAP_MOUSE, (u8 *)event); break; default: break; } } -void mouse_wait(unsigned char a_type) +void mouse_wait(u8 a_type) { unsigned int time_out = 100000; if (a_type == 0) { @@ -65,7 +74,7 @@ void mouse_wait(unsigned char a_type) } } -void mouse_write(unsigned char a_write) +void mouse_write(u8 a_write) { mouse_wait(1); outb(0x64, 0xD4); @@ -81,7 +90,8 @@ char mouse_read() void mouse_install() { - unsigned char status; + event = umalloc(sizeof(struct mouse_event)); + u8 status; // Enable auxiliary mouse device mouse_wait(1); @@ -91,7 +101,7 @@ void mouse_install() mouse_wait(1); outb(0x64, 0x20); mouse_wait(0); - status = (unsigned char)(inb(0x60) | 3); + status = (u8)(inb(0x60) | 3); mouse_wait(1); outb(0x64, 0x60); mouse_wait(1); @@ -115,7 +125,7 @@ void mouse_install() mouse_read(); mouse_write(0xF2); mouse_read(); - status = (unsigned char)mouse_read(); + status = (u8)mouse_read(); if (status == 3) log("Scrollwheel support!"); @@ -137,7 +147,7 @@ void mouse_install() mouse_read(); mouse_write(0xF2); mouse_read(); - status = (unsigned char)mouse_read(); + status = (u8)mouse_read(); if (status == 4) log("4th and 5th mouse button support!"); |