Accept 'fire' key in addition to 'select' to select a kart.

Auria, please review for potential inclusing in 0.8.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12187 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-12-06 10:58:04 +00:00
parent d77471b446
commit fe20c7d6a1
4 changed files with 35 additions and 4 deletions

View File

@ -45,9 +45,10 @@ DeviceManager::DeviceManager()
// -----------------------------------------------------------------------------
bool DeviceManager::initialize()
{
GamepadConfig *gamepadConfig = NULL;
GamePadDevice *gamepadDevice = NULL;
bool created = false;
GamepadConfig *gamepadConfig = NULL;
GamePadDevice *gamepadDevice = NULL;
m_map_fire_to_select = false;
bool created = false;
int numGamepads;
@ -373,6 +374,15 @@ bool DeviceManager::translateInput( Input::InputType type,
{
case Input::IT_KEYBOARD:
device = mapKeyboardInput(btnID, mode, player, action);
if(!device && m_map_fire_to_select)
{
device = mapKeyboardInput(btnID, InputManager::INGAME, player,
action);
if(device)
{
*action = PA_MENU_SELECT;
}
}
break;
case Input::IT_STICKBUTTON:
case Input::IT_STICKMOTION:
@ -388,6 +398,8 @@ bool DeviceManager::translateInput( Input::InputType type,
{
m_latest_used_device = device;
}
m_map_fire_to_select = false;
return (device != NULL);
} // translateInput

View File

@ -91,6 +91,11 @@ private:
InputDevice *mapKeyboardInput ( int btnID, InputManager::InputDriverMode mode,
StateManager::ActivePlayer **player /* out */,
PlayerAction *action /* out */);
/** If this is flag is set the next fire event (if the fire key is not
* mapped to anything else) will be mapped to 'select'. This is used
* in the kart select GUI to support the old way of adding players by
* pressing fire. */
bool m_map_fire_to_select;
bool deserialize();
void shutdown();
@ -154,7 +159,7 @@ public:
StateManager::ActivePlayer* getSinglePlayer() { return m_single_player; }
void setSinglePlayer(StateManager::ActivePlayer* p) { m_single_player = p; }
void mapFireToSelect() {m_map_fire_to_select = true; }
bool initialize();
void serialize();

View File

@ -1165,6 +1165,16 @@ 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)

View File

@ -137,4 +137,8 @@ public:
/** \brief implement optional callback from parent
* class GUIEngine::Screen */
virtual bool onEscapePressed() OVERRIDE;
virtual void filterInput(Input::InputType type,
int deviceID, int btnID,
int axisDir,int value);
};