From 01e46bdb18d0af8458cf04cb5b6b95dddac7b40a Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Wed, 4 Jun 2008 17:56:30 +0000 Subject: [PATCH] * Extract the KDL keymap to a separate header and provide a 'sg' swiss german keymap there too. * Add a config header where one can select what KDL keymap should be used (currently only 'us' and 'sg' are available though). * Provide a third keymap that is used when the alt modifier is used (the swiss german keymap is pretty useless without alt as all the useful keys like backslash and curly braces use alt). Our KDL is so powerful and nice to use, the only thing that bothered me was that I always had to think about where some of the special keys are located in the US keymap. So this simple compile-time keymap switching provided to be helpful for me and might be for others too. Keymaps for other layouts obviously have to be written before this becomes really useful. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25803 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- build/config_headers/kernel_debugger_config.h | 10 +++ headers/private/kernel/debugger_keymaps.h | 80 +++++++++++++++++++ .../kernel/arch/x86/arch_debug_console.c | 28 +------ 3 files changed, 94 insertions(+), 24 deletions(-) create mode 100644 build/config_headers/kernel_debugger_config.h create mode 100644 headers/private/kernel/debugger_keymaps.h diff --git a/build/config_headers/kernel_debugger_config.h b/build/config_headers/kernel_debugger_config.h new file mode 100644 index 0000000000..a92d808346 --- /dev/null +++ b/build/config_headers/kernel_debugger_config.h @@ -0,0 +1,10 @@ +#ifndef KERNEL_DEBUGGER_CONFIG_H +#define KERNEL_DEBUGGER_CONFIG_H + +// Available keymaps: +// 'us' default US keymap +// 'sg' swiss-german keymap +#define KDL_KEYMAP 'us' + + +#endif // KERNEL_DEBUGGER_CONFIG_H diff --git a/headers/private/kernel/debugger_keymaps.h b/headers/private/kernel/debugger_keymaps.h new file mode 100644 index 0000000000..fc7c97109a --- /dev/null +++ b/headers/private/kernel/debugger_keymaps.h @@ -0,0 +1,80 @@ +/* + * Copyright 2008, Michael Lotz + * Distributed under the terms of the Haiku License. + */ +#ifndef DEBUGGER_KEYMAPS_H +#define DEBUGGER_KEYMAPS_H + +#include "kernel_debugger_config.h" + +#if KDL_KEYMAP == 'sg' +const char kUnshiftedKeymap[128] = { + 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '\'', '^', 8, '\t', + 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i', 'o', 'p', 0, 0, '\n', 0, 'a', 's', + 'd', 'f', 'g', 'h', 'j', 'k', 'l', 0, 0, 0, 0, '$', 'y', 'x', 'c', 'v', + 'b', 'n', 'm', ',', '.', '-', 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, 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, 0, 0, 0, 0, 0 +}; + +static const char kShiftedKeymap[128] = { + 0, 27, '+', '"', '*', 0, '%', '&', '/', '(', ')', '=', '?', '`', 8, '\t', + 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I', 'O', 'P', 0, '!', '\n', 0, 'A', 'S', + 'D', 'F', 'G', 'H', 'J', 'K', 'L', 0, 0, 0, 0, 0, 'Y', 'X', 'C', 'V', + 'B', 'N', 'M', ';', ':', '_', 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, 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, 0, 0, 0, 0, 0, 0, 0 +}; + +static const char kAltedKeymap[128] = { + 0, 27, 0, '@', '#', 0, 0, 0, '|', 0, 0, 0, 0, '~', 8, '\t', + 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, 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, '\\', 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, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +#else // default US keymap + +static const char kUnshiftedKeymap[128] = { + 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 8, '\t', + 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0, 'a', 's', + 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\', 'z', 'x', 'c', 'v', + 'b', 'n', 'm', ',', '.', '/', 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, 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, 0, 0, 0, 0, 0, 0, 0 +}; + +static const char kShiftedKeymap[128] = { + 0, 27, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 8, '\t', + 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', 0, 'A', 'S', + 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 0, '|', 'Z', 'X', 'C', 'V', + 'B', 'N', 'M', '<', '>', '?', 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, 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, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +static const char kAltedKeymap[128] = { + 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 8, '\t', + 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0, 'a', 's', + 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\', 'z', 'x', 'c', 'v', + 'b', 'n', 'm', ',', '.', '/', 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, 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, 0, 0, 0, 0, 0, 0, 0 +}; + +#endif +#endif // DEBUGGER_KEYMAPS_H diff --git a/src/system/kernel/arch/x86/arch_debug_console.c b/src/system/kernel/arch/x86/arch_debug_console.c index 3e35bb935e..d1bfa72ecf 100644 --- a/src/system/kernel/arch/x86/arch_debug_console.c +++ b/src/system/kernel/arch/x86/arch_debug_console.c @@ -7,8 +7,7 @@ * Copyright 2001, Travis Geiselbrecht. All rights reserved. * Distributed under the terms of the NewOS License. */ - - +#include "debugger_keymaps.h" #include "ps2_defs.h" #include @@ -67,30 +66,8 @@ enum keycodes { F12 = 88, }; -static const char kUnshiftedKeymap[128] = { - 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 8, '\t', - 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0, 'a', 's', - 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\', 'z', 'x', 'c', 'v', - 'b', 'n', 'm', ',', '.', '/', 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, 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, 0, 0, 0, 0, 0, 0, 0 -}; - -static const char kShiftedKeymap[128] = { - 0, 27, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 8, '\t', - 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', 0, 'A', 'S', - 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 0, '|', 'Z', 'X', 'C', 'V', - 'B', 'N', 'M', '<', '>', '?', 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, 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, 0, 0, 0, 0, 0, 0, 0, 0 -}; static const uint32 kSerialBaudRate = 115200; - static uint16 sSerialBasePort = 0x3f8; // COM1 is the default debug output port @@ -317,6 +294,9 @@ arch_debug_blue_screen_getchar(void) return 0x1f & c; } + if (altPressed) + return kAltedKeymap[key]; + return shiftPressed ? kShiftedKeymap[key] : kUnshiftedKeymap[key]; }