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:
parent
faa62f5977
commit
05cec70d86
@ -374,19 +374,27 @@ bool DeviceManager::translateInput( Input::InputType type,
|
||||
{
|
||||
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 @@ bool DeviceManager::translateInput( Input::InputType type,
|
||||
m_latest_used_device = device;
|
||||
}
|
||||
|
||||
m_map_fire_to_select = false;
|
||||
return (device != NULL);
|
||||
} // translateInput
|
||||
|
||||
|
@ -156,14 +156,17 @@ public:
|
||||
|
||||
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
|
||||
|
@ -1130,6 +1130,10 @@ void KartSelectionScreen::init()
|
||||
// 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::init()
|
||||
|
||||
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)
|
||||
@ -1165,16 +1172,6 @@ void KartSelectionScreen::unloaded()
|
||||
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
|
||||
bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
|
||||
|
@ -138,7 +138,4 @@ public:
|
||||
* class GUIEngine::Screen */
|
||||
virtual bool onEscapePressed() OVERRIDE;
|
||||
|
||||
virtual void filterInput(Input::InputType type,
|
||||
int deviceID, int btnID,
|
||||
int axisDir,int value);
|
||||
};
|
||||
}; // KartSelectionScreen
|
||||
|
Loading…
Reference in New Issue
Block a user