From 6b18411ee5855acdbce2e0ab5dd508cb07b04706 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 8 Apr 2012 21:20:49 +0300 Subject: Allow assign keys before connecting to game. --- src/inputmanager.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/inputmanager.cpp') diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp index cc45a79cf..22af8438c 100644 --- a/src/inputmanager.cpp +++ b/src/inputmanager.cpp @@ -361,18 +361,25 @@ void InputManager::unassignKey() keyboard.update(); } +bool InputManager::handleAssignKey(const SDL_Event &event) +{ + if (setupWindow && setupWindow->isVisible() && + getNewKeyIndex() > Input::KEY_NO_VALUE) + { + setNewKey(event); + callbackNewKey(); + setNewKeyIndex(Input::KEY_NO_VALUE); + return true; + } + return false; +} + bool InputManager::handleEvent(const SDL_Event &event) { if (event.type == SDL_KEYDOWN) { - if (setupWindow && setupWindow->isVisible() && - getNewKeyIndex() > Input::KEY_NO_VALUE) - { - setNewKey(event); - callbackNewKey(); - setNewKeyIndex(Input::KEY_NO_VALUE); + if (handleAssignKey(event)) return true; - } // send straight to gui for certain windows if (quitDialog || TextDialog::isActive() || -- cgit v1.2.3-60-g2f50