From 782cfaa0e3f44f8c8089a7c6a148149bece0a515 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 24 Jan 2021 19:45:53 -0500 Subject: making keyboard driver spin by checking if scanbyte has changed rather than by a decrement loop --- src/kernel/kbd.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/kbd.c b/src/kernel/kbd.c index 29c0350..f7158bb 100644 --- a/src/kernel/kbd.c +++ b/src/kernel/kbd.c @@ -78,11 +78,15 @@ void init_kbd() { drives->free_file(drives, stf); } +static uint8_t last_code_byte = 0; static inline uint8_t get_next_code_byte() { - for (uint32_t spin = 0; spin < 10000000; ++spin) - ; - return inb(PS2_DATA); + uint8_t cb; + do + cb = inb(PS2_DATA); + while (cb == last_code_byte); + last_code_byte = cb; + return cb; } static enum key_modifiers_t keymods = 0; @@ -90,6 +94,7 @@ static enum key_modifiers_t keymods = 0; void on_kbd_isr() { //logf(LOG_INFO, "on_kbd_isr()"); while (inb(PS2_CMD) & PS2S_CODE_READY) { + last_code_byte = 0; uint8_t code[256]; uint8_t code_i = 0; sub_table: -- cgit v1.2.3