From 99ab952a5f1b036cf700a3138d5886f0dae52131 Mon Sep 17 00:00:00 2001 From: auria Date: Sat, 30 May 2009 23:45:51 +0000 Subject: [PATCH] fixed glitch in input config + cleaned up a bit the code git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3560 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/gui/options_screen.cpp | 4 +++- src/gui/state_manager.cpp | 4 ++-- src/input/input_manager.cpp | 29 ++++++++++++++--------------- src/input/input_manager.hpp | 6 ++++-- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/gui/options_screen.cpp b/src/gui/options_screen.cpp index d1a70f35b..b14e4f009 100644 --- a/src/gui/options_screen.cpp +++ b/src/gui/options_screen.cpp @@ -259,6 +259,8 @@ namespace StateManager devices->addItem(name,internal_name,"gui/gamepad.png"); } + getCurrentScreen()->m_inited = true; + } devices->updateItemDisplay(); @@ -350,7 +352,7 @@ namespace StateManager getCurrentScreen()->showModalDialog(); //INPUT_SENSE_PREFER_AXIS, //INPUT_SENSE_PREFER_BUTTON, - input_manager->setMode(InputManager::INPUT_SENSE_PREFER_BUTTON); + input_manager->setMode(InputManager::INPUT_SENSE_KEYBOARD); std::cout << "in sensing mode\n"; } } diff --git a/src/gui/state_manager.cpp b/src/gui/state_manager.cpp index bd20ae987..48d583635 100644 --- a/src/gui/state_manager.cpp +++ b/src/gui/state_manager.cpp @@ -378,8 +378,8 @@ namespace StateManager void escapePressed() { - if(input_manager->isInMode(InputManager::INPUT_SENSE_PREFER_AXIS) || - input_manager->isInMode(InputManager::INPUT_SENSE_PREFER_BUTTON) ) + if(input_manager->isInMode(InputManager::INPUT_SENSE_KEYBOARD) || + input_manager->isInMode(InputManager::INPUT_SENSE_GAMEPAD) ) { getCurrentScreen()->dismissModalDialog(); input_manager->setMode(InputManager::MENU); diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp index 9257a5244..f2e14f47a 100644 --- a/src/input/input_manager.cpp +++ b/src/input/input_manager.cpp @@ -208,8 +208,8 @@ void InputManager::input(Input::InputType type, int deviceID, int btnID, int axi } // Act different in input sensing mode. - if (m_mode >= INPUT_SENSE_PREFER_AXIS && - m_mode <= INPUT_SENSE_PREFER_BUTTON) + if (m_mode == INPUT_SENSE_KEYBOARD || + m_mode == INPUT_SENSE_GAMEPAD) { // Input sensing should be canceled. (TODO) //if (ga == GA_LEAVE && m_sensed_input->type==Input::IT_KEYBOARD) @@ -228,13 +228,12 @@ void InputManager::input(Input::InputType type, int deviceID, int btnID, int axi // The latter is necessary since some gamepads have analog // buttons that can return two different events when pressed bool store_new = abs(value) > m_max_sensed_input || - m_max_sensed_type == Input::IT_NONE || - ( m_mode == INPUT_SENSE_PREFER_AXIS && - type == Input::IT_STICKMOTION && - m_max_sensed_type != Input::IT_STICKMOTION ) || - ( m_mode == INPUT_SENSE_PREFER_BUTTON && - type == Input::IT_STICKBUTTON && - m_max_sensed_type != Input::IT_STICKBUTTON ); + m_max_sensed_type == Input::IT_NONE || + ( m_mode == INPUT_SENSE_GAMEPAD && type == Input::IT_STICKMOTION && + m_max_sensed_type != Input::IT_STICKMOTION ); /*|| + ( m_mode == INPUT_SENSE_PREFER_BUTTON && + type == Input::IT_STICKBUTTON && + m_max_sensed_type != Input::IT_STICKBUTTON );*/ if(store_new) { m_sensed_input->type = type; @@ -417,8 +416,8 @@ bool InputManager::input(const SEvent& event) */ Input &InputManager::getSensedInput() { - assert (m_mode >= INPUT_SENSE_PREFER_AXIS && - m_mode <= INPUT_SENSE_PREFER_BUTTON ); + assert (m_mode == INPUT_SENSE_KEYBOARD || + m_mode == INPUT_SENSE_GAMEPAD ); // m_sensed_input should be available in input sense mode. assert (m_sensed_input); @@ -484,8 +483,8 @@ void InputManager::setMode(InputDriverMode new_mode) m_mode = MENU; break; - case INPUT_SENSE_PREFER_AXIS: - case INPUT_SENSE_PREFER_BUTTON: + case INPUT_SENSE_KEYBOARD: + case INPUT_SENSE_GAMEPAD: // Leaving input sense mode. irr_driver->showPointer(); @@ -528,8 +527,8 @@ void InputManager::setMode(InputDriverMode new_mode) m_mode = INGAME; break; - case INPUT_SENSE_PREFER_AXIS: - case INPUT_SENSE_PREFER_BUTTON: + case INPUT_SENSE_KEYBOARD: + case INPUT_SENSE_GAMEPAD: // We must be in menu mode now in order to switch. assert (m_mode == MENU); diff --git a/src/input/input_manager.hpp b/src/input/input_manager.hpp index 27b20192a..2fefdf6ce 100644 --- a/src/input/input_manager.hpp +++ b/src/input/input_manager.hpp @@ -36,8 +36,10 @@ public: enum InputDriverMode { MENU = 0, INGAME, - INPUT_SENSE_PREFER_AXIS, - INPUT_SENSE_PREFER_BUTTON, + INPUT_SENSE_KEYBOARD, + INPUT_SENSE_GAMEPAD, + //INPUT_SENSE_PREFER_AXIS, + //INPUT_SENSE_PREFER_BUTTON, LOWLEVEL, BOOTSTRAP };