From bb10b27152e1a7063f5aeb7c360ce68732b0e053 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sat, 27 Dec 2025 21:10:14 -0500 Subject: [PATCH] ps2: only read one byte per interrupt --- src/kernel/ps2.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/kernel/ps2.c b/src/kernel/ps2.c index 54506af..27854e8 100644 --- a/src/kernel/ps2.c +++ b/src/kernel/ps2.c @@ -23,9 +23,14 @@ //returns -1 if no byte available int read_ps2_byte(); -static void process_keyboard_byte(uint8_t byte) { - (void)byte; +void on_keyboard_irq() { + + int byte = read_ps2_byte(); + if (byte == -1) + return; + //TODO + } static uint8_t mouse_packet[3]; @@ -34,7 +39,11 @@ static int mouse_packet_length = 0; static int total_x = 0; static int total_y = 0; -static void process_mouse_byte(uint8_t byte) { +void on_mouse_irq() { + + int byte = read_ps2_byte(); + if (byte == -1) + return; mouse_packet[mouse_packet_length] = byte; if (mouse_packet_length < 2) { @@ -69,21 +78,3 @@ static void process_mouse_byte(uint8_t byte) { fb_base[total_y * fb_pitch + total_x * 4 + 2] = 0xff; } - -void on_keyboard_irq() { - while (1) { - int byte = read_ps2_byte(); - if (byte == -1) - return; - process_keyboard_byte(byte); - } -} - -void on_mouse_irq() { - while (1) { - int byte = read_ps2_byte(); - if (byte == -1) - return; - process_mouse_byte(byte); - } -}