From 65a48bc3eeb7aee1bff57239b18c526f25f9e843 Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Fri, 7 Apr 2006 11:38:12 +0000 Subject: [PATCH] Console hides immediately / Cleaned up controller hook SVN-Revision: 3258 --- src/console.cpp | 2 +- src/control/joystickkeyboardcontroller.cpp | 37 ++++++++++++++---------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/console.cpp b/src/console.cpp index 307f9b223..78acb1e2b 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -102,7 +102,7 @@ void Console::hide() { focused = false; - ticks = 0; + height = 0; } void diff --git a/src/control/joystickkeyboardcontroller.cpp b/src/control/joystickkeyboardcontroller.cpp index c90191c69..84426649e 100644 --- a/src/control/joystickkeyboardcontroller.cpp +++ b/src/control/joystickkeyboardcontroller.cpp @@ -246,36 +246,33 @@ JoystickKeyboardController::process_event(const SDL_Event& event) switch(event.type) { case SDL_KEYUP: case SDL_KEYDOWN: - if(event.type == SDL_KEYDOWN && (event.key.keysym.unicode & 0xFF80) == 0) { - if (Console::hasFocus()) { - // if the Console is open, send keys there - char c = event.key.keysym.unicode; + if (event.key.keysym.unicode == '\t') { + // console key was pressed - toggle console + if (event.type == SDL_KEYDOWN) { + if (Console::hasFocus()) { + Console::hide(); + } else { + Console::show(); + } + } + } else if (Console::hasFocus()) { + // console is open - send key there + int c = event.key.keysym.unicode; + if (event.type == SDL_KEYDOWN) { if ((c >= 32) && (c <= 126)) { - Console::input << c; + Console::input << (char)c; } if ((c == '\n') || (c == '\r')) { Console::input << std::endl; } - if (c == '\t') { - Console::hide(); - } - } else { - char c = event.key.keysym.unicode; - if (c == '\t') { - Console::show(); - } } - } - - if(Console::hasFocus()) { - // console is open - ignore key } - else if(Menu::current()) { - // menu mode + else if (Menu::current()) { + // menu mode - send key there process_menu_key_event(event); return; } else { - // normal mode, find key in keymap + // normal mode - find key in keymap KeyMap::iterator i = keymap.find(event.key.keysym.sym); if(i == keymap.end()) { msg_debug("Pressed key without mapping"); -- 2.11.0