From 17d871732d523eb0262b5651535cb1126ca55bb4 Mon Sep 17 00:00:00 2001 From: auria Date: Sun, 2 May 2010 00:22:35 +0000 Subject: [PATCH] Fixed typing player names when some letters are mapped to accelerate/brake/fire/etc... in some keyboard config. identified a FIXME and cleaned up another bit of code on the way git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5341 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/guiengine/event_handler.cpp | 2 +- src/input/input_manager.cpp | 36 +++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/guiengine/event_handler.cpp b/src/guiengine/event_handler.cpp index 3cfda0124..535241421 100644 --- a/src/guiengine/event_handler.cpp +++ b/src/guiengine/event_handler.cpp @@ -112,7 +112,7 @@ EventPropagation EventHandler::onGUIEvent(const SEvent& event) // These events are only triggered by keyboard/mouse (or so I hope...) const int playerID = input_manager->getPlayerKeyboardID(); - if (input_manager->masterPlayerOnly() && playerID != 0) break; + if (input_manager->masterPlayerOnly() && playerID != PLAYER_ID_GAME_MASTER) break; else if (playerID != -1) return onWidgetActivated(w, playerID); else break; } diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp index 2c120f2e9..688b75bea 100644 --- a/src/input/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -561,14 +561,17 @@ EventPropagation InputManager::input(const SEvent& event) } // 'backspace' in a text control must never be mapped, since user can be in a text // area trying to erase text (and if it's mapped to rescue that would dismiss the - // dialog instead of erasing a single letter). Same for spacebar. - if (key == KEY_BACK && GUIEngine::isWithinATextBox()) + // dialog instead of erasing a single letter). Same for spacebar. Same for letters. + if (GUIEngine::isWithinATextBox()) { - return EVENT_LET; - } - if (key == KEY_SPACE && GUIEngine::isWithinATextBox()) - { - return EVENT_LET; + if (key == KEY_BACK || key == KEY_SPACE || key == KEY_SHIFT) + { + return EVENT_LET; + } + if (key >= KEY_KEY_0 && key <= KEY_KEY_Z) + { + return EVENT_LET; + } } const bool wasInTextBox = GUIEngine::isWithinATextBox(); @@ -594,6 +597,21 @@ EventPropagation InputManager::input(const SEvent& event) } else { + // 'backspace' in a text control must never be mapped, since user can be in a text + // area trying to erase text (and if it's mapped to rescue that would dismiss the + // dialog instead of erasing a single letter). Same for spacebar. Same for letters. + if (GUIEngine::isWithinATextBox()) + { + if (key == KEY_BACK || key == KEY_SPACE || key == KEY_SHIFT) + { + return EVENT_LET; + } + if (key >= KEY_KEY_0 && key <= KEY_KEY_Z) + { + return EVENT_LET; + } + } + dispatchInput(Input::IT_KEYBOARD, 0, key, 0, 0); return EVENT_BLOCK; // Don't propagate key up events } @@ -623,7 +641,9 @@ EventPropagation InputManager::input(const SEvent& event) } #endif - // block events in all modes but initial menus (except in text boxes to allow typing, and except in modal dialogs in-game) + // block events in all modes but initial menus (except in text boxes to allow typing, + // and except in modal dialogs in-game) + // FIXME: 1) that's awful logic 2) that's not what the code below does, events are never blocked in menus if (getDeviceList()->getAssignMode() != NO_ASSIGN && !GUIEngine::isWithinATextBox() && (!GUIEngine::ModalDialog::isADialogActive() && StateManager::get()->getGameState() == GUIEngine::GAME)) {