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.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12191 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-12-06 23:43:09 +00:00
parent faa62f5977
commit 05cec70d86
4 changed files with 27 additions and 23 deletions

View File

@ -374,19 +374,27 @@ bool DeviceManager::translateInput( Input::InputType type,
{ {
case Input::IT_KEYBOARD: case Input::IT_KEYBOARD:
device = mapKeyboardInput(btnID, mode, player, action); 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) if(!device && m_map_fire_to_select)
{ {
device = mapKeyboardInput(btnID, InputManager::INGAME, player, device = mapKeyboardInput(btnID, InputManager::INGAME, player,
action); action);
if(device) if(device && *action == PA_FIRE)
{
*action = PA_MENU_SELECT; *action = PA_MENU_SELECT;
} }
}
break; break;
case Input::IT_STICKBUTTON: case Input::IT_STICKBUTTON:
case Input::IT_STICKMOTION: 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; break;
default: default:
break; break;
@ -399,7 +407,6 @@ bool DeviceManager::translateInput( Input::InputType type,
m_latest_used_device = device; m_latest_used_device = device;
} }
m_map_fire_to_select = false;
return (device != NULL); return (device != NULL);
} // translateInput } // translateInput

View File

@ -156,14 +156,17 @@ public:
void clearLatestUsedDevice(); void clearLatestUsedDevice();
InputDevice* getLatestUsedDevice(); InputDevice* getLatestUsedDevice();
bool initialize();
void serialize();
StateManager::ActivePlayer* getSinglePlayer() { return m_single_player; } StateManager::ActivePlayer* getSinglePlayer() { return m_single_player; }
void setSinglePlayer(StateManager::ActivePlayer* p) { m_single_player = p; } 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(); }; // DeviceManager
void serialize();
};
#endif #endif

View File

@ -1130,6 +1130,10 @@ void KartSelectionScreen::init()
// if kart from config not found, select the first instead // if kart from config not found, select the first instead
w->setSelection(0, 0, true); 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 } // init
@ -1137,6 +1141,9 @@ void KartSelectionScreen::init()
void KartSelectionScreen::tearDown() 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 // if a removed widget is currently shrinking down, remove it upon leaving
// the screen // the screen
if (m_removed_widget != NULL) if (m_removed_widget != NULL)
@ -1165,16 +1172,6 @@ void KartSelectionScreen::unloaded()
g_dispatcher = NULL; g_dispatcher = NULL;
} }
// ----------------------------------------------------------------------------
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 // Return true if event was handled successfully
bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer) bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)

View File

@ -138,7 +138,4 @@ public:
* class GUIEngine::Screen */ * class GUIEngine::Screen */
virtual bool onEscapePressed() OVERRIDE; virtual bool onEscapePressed() OVERRIDE;
virtual void filterInput(Input::InputType type, }; // KartSelectionScreen
int deviceID, int btnID,
int axisDir,int value);
};