From 0a51327f985b2b336d7d2c073cd72c8e6d6a1fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 2 Aug 2005 16:19:36 +0000 Subject: [PATCH] Fixed on-screen KDL keyboard input routine: it now works much more reliable and ignores keyboard input. Also, it now uses the definitions from the PS/2 HID driver (from ps2.h). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13881 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/arch/x86/Jamfile | 3 +- .../kernel/arch/x86/arch_debug_console.c | 39 ++++++++++++++----- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/system/kernel/arch/x86/Jamfile b/src/system/kernel/arch/x86/Jamfile index 5ce4b0802a..7fa6ac89e3 100644 --- a/src/system/kernel/arch/x86/Jamfile +++ b/src/system/kernel/arch/x86/Jamfile @@ -1,7 +1,8 @@ SubDir OBOS_TOP src system kernel arch x86 ; -# for syscall_numbers.h SubDirHdrs [ FObjectsDir src system kernel ] ; + # for syscall_numbers.h +SubDirHdrs $(OBOS_TOP) src add-ons kernel drivers input ps2_hid ; KernelStaticLibrary libx86 : arch_cpu.c diff --git a/src/system/kernel/arch/x86/arch_debug_console.c b/src/system/kernel/arch/x86/arch_debug_console.c index 2ef86437e8..f40aeb1cbc 100644 --- a/src/system/kernel/arch/x86/arch_debug_console.c +++ b/src/system/kernel/arch/x86/arch_debug_console.c @@ -9,6 +9,8 @@ */ +#include "ps2.h" + #include #include #include @@ -100,26 +102,43 @@ arch_debug_blue_screen_getchar(void) 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + enum keycodes { + LSHIFT = 42, + RSHIFT = 54, + }; static bool shift = false; static uint8 last = 0; uint8 key, ascii = 0; - do { - while ((key = in8(0x60)) == last) - ; - last = key; + while (true) { + uint8 status = in8(PS2_PORT_CTRL); + + if ((status & PS2_STATUS_OUTPUT_BUFFER_FULL) == 0) { + // no data in keyboard buffer + spin(200); + continue; + } + + spin(200); + key = in8(PS2_PORT_DATA); + + if (status & PS2_STATUS_MOUSE_DATA) { + // we read mouse data, ignore it + continue; + } + if (key & 0x80) { - if (key == (0x80 + 42) || key == (54 + 0x80)) + // key up + if (key == (0x80 | LSHIFT) || key == (0x80 | RSHIFT)) shift = false; } else { - if (key == 42 || key == 54) + // key down + if (key == LSHIFT || key == RSHIFT) shift = true; else - ascii = shift ? shifted_keymap[key] : unshifted_keymap[key]; + return shift ? shifted_keymap[key] : unshifted_keymap[key]; } - } while (!ascii); - - return ascii; + } }