From f09f1fa66040a629dad6245e35e0a8c64066a170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 1 Nov 2004 21:46:24 +0000 Subject: [PATCH] Quick hack on our temporary keyboard driver to allow cursor movement and stuff like Control-D. For example, command line history now works in the bash :) git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9721 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../drivers/arch/x86/keyboard/keyboard.c | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/drivers/arch/x86/keyboard/keyboard.c b/src/add-ons/kernel/drivers/arch/x86/keyboard/keyboard.c index 09d551627a..970bccfadb 100644 --- a/src/add-ons/kernel/drivers/arch/x86/keyboard/keyboard.c +++ b/src/add-ons/kernel/drivers/arch/x86/keyboard/keyboard.c @@ -31,6 +31,16 @@ enum keycodes { NUM_LOCK = 69, SCR_LOCK = 70, SYS_REQ = 55, + LCONTROL = 29, + RCONTROL = 29, // dunno what it really is + + CURSOR_LEFT = 75, + CURSOR_RIGHT = 77, + CURSOR_UP = 72, + CURSOR_DOWN = 80, + + HOME = 71, + END = 79, F1 = 0x3b, F2, F3, F4, F5, F6, @@ -46,7 +56,7 @@ enum keycodes { int32 api_version = B_CUR_DRIVER_API_VERSION; -static bool shift; +static bool shift, sControl; static int leds; static sem_id keyboard_sem; static mutex keyboard_read_mutex; @@ -54,6 +64,9 @@ static char keyboard_buf[1024]; static unsigned int head, tail; static isa_module_info *gISA; +// begins with HOME, end with CURSOR_DOWN +static const char sControlKeys[] = {'@', 'A', 0, 0, 'D', 0, 'C', 0, '[', 'B'}; + // stolen from nujeffos const char unshifted_keymap[128] = { 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 8, '\t', @@ -138,6 +151,8 @@ handle_keyboard_interrupt(void *data) // key up if (key == LSHIFT + 0x80 || key == RSHIFT + 0x80) shift = false; + if (key == LCONTROL + 0x80 || key == RCONTROL + 0x80) + sControl = false; return B_HANDLED_INTERRUPT; } @@ -147,6 +162,10 @@ handle_keyboard_interrupt(void *data) case RSHIFT: shift = true; break; + case LCONTROL: + //case RCONTROL: + sControl = true; + break; case CAPS_LOCK: if (leds & LED_CAPS) leds &= ~LED_CAPS; @@ -190,10 +209,22 @@ handle_keyboard_interrupt(void *data) reboot(); break; + case HOME: + case END: + case CURSOR_DOWN: + case CURSOR_UP: + case CURSOR_LEFT: + case CURSOR_RIGHT: + insert_in_buf(0x1b); + insert_in_buf('['); + insert_in_buf(sControlKeys[key - HOME]); + retval = B_INVOKE_SCHEDULER; + break; + default: { char ascii; - if (shift) + if (shift || sControl) ascii = shifted_keymap[key]; else { if (leds & LED_CAPS) @@ -202,6 +233,9 @@ handle_keyboard_interrupt(void *data) ascii = unshifted_keymap[key]; } + if (sControl && ascii >= 64 && ascii < 96) + ascii -= 0100; + TRACE(("ascii = 0x%x, '%c'\n", ascii, ascii)); if (ascii != 0) { @@ -380,7 +414,8 @@ init_driver() if (mutex_init(&keyboard_read_mutex, "keyboard_read_mutex") < 0) panic("could not create keyboard read mutex!\n"); - shift = 0; + shift = false; + sControl = false; leds = 0; // have the scroll lock reflect the state of serial debugging