From 4972f247bededddafc97b6796f53b25d55be7a59 Mon Sep 17 00:00:00 2001 From: auria Date: Sat, 30 May 2009 20:54:59 +0000 Subject: [PATCH] made some keyboard keys always usable in menus (like arrows) when bindings don't use them git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3559 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/input/input_manager.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp index f0f8e1366..9257a5244 100644 --- a/src/input/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -186,9 +186,27 @@ void InputManager::input(Input::InputType type, int deviceID, int btnID, int axi int player; PlayerAction action; - const bool action_found = m_device_manager->mapInputToPlayerAndAction( type, deviceID, btnID, axisDirection, value, &player, &action ); + bool action_found = m_device_manager->mapInputToPlayerAndAction( type, deviceID, btnID, axisDirection, value, &player, &action ); + // in menus, some keyboard keys are standard + if(!StateManager::isGameState() && type == Input::IT_KEYBOARD && m_mode == MENU) + { + action = PA_FIRST; + + if(btnID == KEY_UP) action = PA_ACCEL; + else if(btnID == KEY_DOWN) action = PA_BRAKE; + else if(btnID == KEY_LEFT) action = PA_LEFT; + else if(btnID == KEY_RIGHT) action = PA_RIGHT; + else if(btnID == KEY_SPACE) action = PA_FIRE; + + if(action != PA_FIRST) + { + action_found = true; + player = 0; + } + } + // Act different in input sensing mode. if (m_mode >= INPUT_SENSE_PREFER_AXIS && m_mode <= INPUT_SENSE_PREFER_BUTTON) @@ -239,7 +257,9 @@ void InputManager::input(Input::InputType type, int deviceID, int btnID, int axi else if (action_found) { if(StateManager::isGameState()) + { RaceManager::getWorld()->getLocalPlayerKart(player)->action(action, abs(value)); + } else { // reset timer when released