From: <hik...@us...> - 2012-12-06 23:43:16
|
Revision: 12191 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=12191&view=rev Author: hikerstk Date: 2012-12-06 23:43:09 +0000 (Thu, 06 Dec 2012) Log Message: ----------- Fixed 'map fire to select' option by also work for gamepads, only accept fire (and not any event like steering), and remove setting the flag each frame. Modified Paths: -------------- main/trunk/src/input/device_manager.cpp main/trunk/src/input/device_manager.hpp main/trunk/src/states_screens/kart_selection.cpp main/trunk/src/states_screens/kart_selection.hpp Modified: main/trunk/src/input/device_manager.cpp =================================================================== --- main/trunk/src/input/device_manager.cpp 2012-12-06 23:21:57 UTC (rev 12190) +++ main/trunk/src/input/device_manager.cpp 2012-12-06 23:43:09 UTC (rev 12191) @@ -374,19 +374,27 @@ { case Input::IT_KEYBOARD: device = mapKeyboardInput(btnID, mode, player, action); + // If the action is not recognised, check if it's a fire key + // that should be mapped to select if(!device && m_map_fire_to_select) { device = mapKeyboardInput(btnID, InputManager::INGAME, player, action); - if(device) - { + if(device && *action == PA_FIRE) *action = PA_MENU_SELECT; - } } break; case Input::IT_STICKBUTTON: case Input::IT_STICKMOTION: - device = mapGamepadInput(type, deviceID, btnID, axisDir, value, mode, player, action); + device = mapGamepadInput(type, deviceID, btnID, axisDir, value, + mode, player, action); + if(!device && m_map_fire_to_select) + { + device = mapGamepadInput(type, deviceID, btnID, axisDir, value, + InputManager::INGAME, player, action); + if(device && *action == PA_FIRE) + *action = PA_MENU_SELECT; + } break; default: break; @@ -399,7 +407,6 @@ m_latest_used_device = device; } - m_map_fire_to_select = false; return (device != NULL); } // translateInput Modified: main/trunk/src/input/device_manager.hpp =================================================================== --- main/trunk/src/input/device_manager.hpp 2012-12-06 23:21:57 UTC (rev 12190) +++ main/trunk/src/input/device_manager.hpp 2012-12-06 23:43:09 UTC (rev 12191) @@ -156,14 +156,17 @@ void clearLatestUsedDevice(); InputDevice* getLatestUsedDevice(); + bool initialize(); + void serialize(); StateManager::ActivePlayer* getSinglePlayer() { return m_single_player; } void setSinglePlayer(StateManager::ActivePlayer* p) { m_single_player = p; } - void mapFireToSelect() {m_map_fire_to_select = true; } + // ------------------------------------------------------------------------ + /** Sets or reset the 'map fire to select' option. + */ + void mapFireToSelect(bool v) {m_map_fire_to_select = v; } - bool initialize(); - void serialize(); -}; +}; // DeviceManager #endif Modified: main/trunk/src/states_screens/kart_selection.cpp =================================================================== --- main/trunk/src/states_screens/kart_selection.cpp 2012-12-06 23:21:57 UTC (rev 12190) +++ main/trunk/src/states_screens/kart_selection.cpp 2012-12-06 23:43:09 UTC (rev 12191) @@ -1130,6 +1130,10 @@ // if kart from config not found, select the first instead w->setSelection(0, 0, true); } + // This flag will cause that a 'fire' event will be mapped to 'select' (if + // 'fire' is not assigned to a GUI event). This is done to support the old + // way of player joining by pressing 'fire' instead of 'select'. + input_manager->getDeviceList()->mapFireToSelect(true); } // init @@ -1137,6 +1141,9 @@ void KartSelectionScreen::tearDown() { + // Reset the 'map fire to select' option of the device manager + input_manager->getDeviceList()->mapFireToSelect(false); + // if a removed widget is currently shrinking down, remove it upon leaving // the screen if (m_removed_widget != NULL) @@ -1166,16 +1173,6 @@ } // ---------------------------------------------------------------------------- -void KartSelectionScreen::filterInput(Input::InputType type, int deviceID, - int btnID, int axisDir,int value) -{ - // This flag will cause that a 'fire' event will be mapped to 'select' (if - // 'fire' is not assigned to a GUI event). This is done to support the old - // way of player joining by pressing 'fire' instead of 'select'. - input_manager->getDeviceList()->mapFireToSelect(); -} // filterInput - -// ---------------------------------------------------------------------------- // Return true if event was handled successfully bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer) { Modified: main/trunk/src/states_screens/kart_selection.hpp =================================================================== --- main/trunk/src/states_screens/kart_selection.hpp 2012-12-06 23:21:57 UTC (rev 12190) +++ main/trunk/src/states_screens/kart_selection.hpp 2012-12-06 23:43:09 UTC (rev 12191) @@ -138,7 +138,4 @@ * class GUIEngine::Screen */ virtual bool onEscapePressed() OVERRIDE; - virtual void filterInput(Input::InputType type, - int deviceID, int btnID, - int axisDir,int value); -}; +}; // KartSelectionScreen This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |