From dc84e156853d9c75d80af02d22faf7ebd169b54d Mon Sep 17 00:00:00 2001 From: auria Date: Sat, 30 May 2009 18:57:25 +0000 Subject: [PATCH] cleaned up old TuxKart crap left in input module (variables id0, id1, id2, whose meaning change from device to device... how brilliant) git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3553 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/gui/state_manager.cpp | 6 +++--- src/input/device_manager.cpp | 7 +++---- src/input/input.hpp | 15 ++++++--------- src/input/input_manager.cpp | 30 +++++++++++++----------------- 4 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/gui/state_manager.cpp b/src/gui/state_manager.cpp index f90abf859..44d936175 100644 --- a/src/gui/state_manager.cpp +++ b/src/gui/state_manager.cpp @@ -394,15 +394,15 @@ namespace StateManager if(sensedInput->type == Input::IT_KEYBOARD) { - std::cout << "key " << Input::getInputAsString(Input::IT_KEYBOARD, sensedInput->id0) << std::endl; + std::cout << "key " << Input::getInputAsString(Input::IT_KEYBOARD, sensedInput->btnID) << std::endl; } else if(sensedInput->type == Input::IT_STICKMOTION) { - std::cout << "gamepad axis " << sensedInput->id0 << " " << sensedInput->id1 << " " << sensedInput->id2 << std::endl; + std::cout << "gamepad " << sensedInput->deviceID << "axis " << sensedInput->btnID << " direction=" << sensedInput->axisDirection << std::endl; } else if(sensedInput->type == Input::IT_STICKBUTTON) { - std::cout << "gamepad button " << sensedInput->id0 << " " << sensedInput->id1 << " " << sensedInput->id2 << std::endl; + std::cout << "gamepad " << sensedInput->deviceID << " button " << sensedInput->btnID << std::endl; } getCurrentScreen()->dismissModalDialog(); diff --git a/src/input/device_manager.cpp b/src/input/device_manager.cpp index ca02f09bf..98543a043 100644 --- a/src/input/device_manager.cpp +++ b/src/input/device_manager.cpp @@ -79,7 +79,7 @@ void DeviceManager::add(GamePadDevice* d) m_gamepad_amount = m_gamepads.size(); } // ----------------------------------------------------------------------------- -bool DeviceManager::mapInputToPlayerAndAction( Input::InputType type, int id0, int id1, int id2, int value, +bool DeviceManager::mapInputToPlayerAndAction( Input::InputType type, int deviceID, int btnID, int axisDir, int value, int* player /* out */, PlayerAction* action /* out */ ) { // TODO - auto-detect player ID from device @@ -89,7 +89,7 @@ bool DeviceManager::mapInputToPlayerAndAction( Input::InputType type, int id0, i { for(unsigned int n=0; nmapInputToPlayerAndAction( type, id0, id1, id2, value, &player, &action ); + const bool action_found = m_device_manager->mapInputToPlayerAndAction( type, deviceID, btnID, axisDirection, value, &player, &action ); - // std::cout << "Input code=" << id0 << " found=" << action_found << std::endl; - - //GameAction ga = m_action_map->getEntry(type, id0, id1, id2); // Act different in input sensing mode. if (m_mode >= INPUT_SENSE_PREFER_AXIS && @@ -223,9 +219,11 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2, if(store_new) { m_sensed_input->type = type; - m_sensed_input->id0 = id0; - m_sensed_input->id1 = id1; - m_sensed_input->id2 = id2; + + m_sensed_input->deviceID = deviceID; + m_sensed_input->btnID = btnID; + m_sensed_input->axisDirection = axisDirection; + m_max_sensed_input = abs(value); m_max_sensed_type = type; } @@ -236,10 +234,8 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2, StateManager::gotSensedInput(m_sensed_input); } } - } // if m_mode==INPUT_SENSE_PREFER_{AXIS,BUTTON} - else - - if (action_found) + } + else if (action_found) { if(StateManager::isGameState()) RaceManager::getWorld()->getLocalPlayerKart(player)->action(action, abs(value)); @@ -267,7 +263,7 @@ void InputManager::input(Input::InputType type, int id0, int id1, int id2, else if(type == Input::IT_KEYBOARD) { // keyboard press not handled by device manager / bindings. Check static bindings... - handleStaticAction( id0, value ); + handleStaticAction( btnID, value ); } } // input @@ -340,7 +336,7 @@ bool InputManager::input(const SEvent& event) return true; } - input(Input::IT_KEYBOARD, key, + input(Input::IT_KEYBOARD, 0, key, #ifdef HAVE_IRRLICHT // FIXME: not sure why this happens: with plib the unicode // value is 0. Since all values defined in user_config @@ -354,12 +350,12 @@ bool InputManager::input(const SEvent& event) #else ev.key.keysym.unicode, #endif - 0, MAX_VALUE); + MAX_VALUE); } else { - input(Input::IT_KEYBOARD, key, 0, 0, 0); + input(Input::IT_KEYBOARD, 0, key, 0, 0); } } #if 0 // in case we ever use mouse in-game...