Fixed temporarily broken keyboard support.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3816 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
f3e3206b26
commit
f12463b4c9
@ -30,6 +30,7 @@ std::string DeviceConfig::toString ()
|
||||
m_bindings[n].dir));
|
||||
returnString = returnString.append("\n");
|
||||
}
|
||||
returnString = returnString.append("\n");
|
||||
return returnString;
|
||||
}
|
||||
|
||||
@ -85,7 +86,7 @@ bool DeviceConfig::getBinding ( Input::InputType type,
|
||||
|
||||
void DeviceConfig::serialize (std::ofstream& stream)
|
||||
{
|
||||
for(int n=0; n<PA_COUNT; n++) // Start at 0?
|
||||
for(int n = 0; n < PA_COUNT; n++) // Start at 0?
|
||||
{
|
||||
stream << " "
|
||||
<< "<action "
|
||||
|
@ -12,6 +12,20 @@
|
||||
|
||||
DeviceManager::DeviceManager()
|
||||
{
|
||||
printf("================================================================================\n");
|
||||
printf("Parsing Keyboard & Gamepad Configurations\n");
|
||||
printf("================================================================================\n\n");
|
||||
deserialize();
|
||||
|
||||
m_keyboard = new KeyboardDevice(m_keyboard_configs.get(0));
|
||||
printf("Keyboard Configs:\n");
|
||||
for (int n = 0; n < m_keyboard_configs.size(); n++)
|
||||
printf("%s\n", m_keyboard_configs[n].toString().c_str());
|
||||
printf("Gamepad Configs:\n");
|
||||
for (int n = 0; n < m_gamepad_configs.size(); n++)
|
||||
printf("%s\n", m_gamepad_configs[n].toString().c_str());
|
||||
|
||||
|
||||
m_keyboard_amount = 0;
|
||||
m_gamepad_amount = 0;
|
||||
m_latest_used_device = NULL;
|
||||
@ -134,61 +148,57 @@ bool DeviceManager::mapInputToPlayerAndAction( Input::InputType type, int device
|
||||
|
||||
if(type == Input::IT_KEYBOARD)
|
||||
{
|
||||
for(unsigned int n=0; n<m_keyboard_amount; n++)
|
||||
if( m_keyboard->hasBinding(btnID, action) )
|
||||
{
|
||||
if( m_keyboard->hasBinding(btnID, action) )
|
||||
// We found which device was triggered.
|
||||
|
||||
if(m_assign_mode == NO_ASSIGN)
|
||||
{
|
||||
// We found which device was triggered.
|
||||
|
||||
if(m_assign_mode == NO_ASSIGN)
|
||||
// In no-assign mode, simply keep track of which device is used
|
||||
if(!programaticallyGenerated) m_latest_used_device = m_keyboard;
|
||||
|
||||
//if(programaticallyGenerated) std::cout << "devieManager ignores programatical event\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
// In assign mode, find to which active player this binding belongs
|
||||
if (m_keyboard->m_player != NULL)
|
||||
{
|
||||
// In no-assign mode, simply keep track of which device is used
|
||||
if(!programaticallyGenerated) m_latest_used_device = m_keyboard;
|
||||
|
||||
//if(programaticallyGenerated) std::cout << "devieManager ignores programatical event\n";
|
||||
*player = m_keyboard->m_player;
|
||||
|
||||
if (m_assign_mode == DETECT_NEW && *action == PA_RESCUE)
|
||||
{
|
||||
if (value > Input::MAX_VALUE/2) KartSelectionScreen::playerPressedRescue( *player );
|
||||
*action = PA_FIRST; // FIXME : returning PA_FIRST is quite a hackish way to tell input was handled internally
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// In assign mode, find to which active player this binding belongs
|
||||
if (m_keyboard->m_player != NULL)
|
||||
// no active player has this binding. if we want to check for new players trying to join,
|
||||
// check now
|
||||
if (m_assign_mode == DETECT_NEW)
|
||||
{
|
||||
*player = m_keyboard->m_player;
|
||||
|
||||
if (m_assign_mode == DETECT_NEW && *action == PA_RESCUE)
|
||||
PlayerAction localaction = PA_FIRST; // none
|
||||
if (m_keyboard->hasBinding(btnID, &localaction))
|
||||
{
|
||||
if (value > Input::MAX_VALUE/2) KartSelectionScreen::playerPressedRescue( *player );
|
||||
*action = PA_FIRST; // FIXME : returning PA_FIRST is quite a hackish way to tell input was handled internally
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// no active player has this binding. if we want to check for new players trying to join,
|
||||
// check now
|
||||
if (m_assign_mode == DETECT_NEW)
|
||||
{
|
||||
PlayerAction localaction = PA_FIRST; // none
|
||||
if (m_keyboard->hasBinding(btnID, &localaction))
|
||||
if(localaction == PA_FIRE)
|
||||
{
|
||||
if(localaction == PA_FIRE)
|
||||
{
|
||||
if (value > Input::MAX_VALUE/2)
|
||||
KartSelectionScreen::firePressedOnNewDevice( m_keyboard );
|
||||
}
|
||||
|
||||
*action = PA_FIRST; // FIXME : returning PA_FIRST is quite a hackish way to tell input was handled internally
|
||||
return true;
|
||||
if (value > Input::MAX_VALUE/2)
|
||||
KartSelectionScreen::firePressedOnNewDevice( m_keyboard );
|
||||
}
|
||||
|
||||
} // end if assign_mode == DETECT_NEW
|
||||
}
|
||||
|
||||
return false;
|
||||
} // end if/else NO_ASSIGN mode
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
*action = PA_FIRST; // FIXME : returning PA_FIRST is quite a hackish way to tell input was handled internally
|
||||
return true;
|
||||
}
|
||||
} // end if assign_mode == DETECT_NEW
|
||||
}
|
||||
|
||||
return false;
|
||||
} // end if/else NO_ASSIGN mode
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -277,7 +287,11 @@ bool DeviceManager::mapInputToPlayerAndAction( Input::InputType type, int device
|
||||
InputDevice* DeviceManager::getLatestUsedDevice()
|
||||
{
|
||||
// If none, probably the user clicked or used enter; give keyboard by default
|
||||
if (m_latest_used_device == NULL ) return m_keyboard;
|
||||
|
||||
if (m_latest_used_device == NULL )
|
||||
{
|
||||
return m_keyboard;
|
||||
}
|
||||
|
||||
return m_latest_used_device;
|
||||
}
|
||||
@ -361,14 +375,6 @@ bool DeviceManager::deserialize()
|
||||
if (m_keyboard_configs.size() == 0)
|
||||
m_keyboard_configs.push_back(new KeyboardConfig());
|
||||
|
||||
m_keyboard->setConfiguration(m_keyboard_configs.get(0));
|
||||
|
||||
for (int n = 0; n < m_keyboard_configs.size(); n++)
|
||||
printf("%s\n", m_keyboard_configs[n].toString().c_str());
|
||||
|
||||
for (int n = 0; n < m_gamepad_configs.size(); n++)
|
||||
printf("%s\n", m_gamepad_configs[n].toString().c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -61,7 +61,6 @@ GamePadDevice::GamePadDevice(const int irrIndex, const std::string name, const i
|
||||
m_prevAxisDirections = new Input::AxisDirection[axis_count];
|
||||
m_button_count = btnAmount;
|
||||
|
||||
printf("New Gamepad Created. Assigned the following configuration:\n%s", m_configuration->toString().c_str());
|
||||
std::cout << "(i) This gamepad has " << axis_count << " axes and " << m_button_count << " buttons\n";
|
||||
|
||||
m_index = irrIndex;
|
||||
|
@ -58,6 +58,7 @@ InputManager::InputManager() : m_sensed_input(0), m_mode(BOOTSTRAP),
|
||||
|
||||
bool something_new_to_write = false;
|
||||
|
||||
/*
|
||||
if(!m_device_manager->deserialize())
|
||||
{
|
||||
std::cerr << "Failed to read input config file, using defaults\n";
|
||||
@ -66,6 +67,7 @@ InputManager::InputManager() : m_sensed_input(0), m_mode(BOOTSTRAP),
|
||||
KeyboardDevice* default_device = new KeyboardDevice();
|
||||
something_new_to_write = true;
|
||||
}
|
||||
*/
|
||||
|
||||
if(m_device_manager->initGamePadSupport() /* returns whether a new gamepad was detected */)
|
||||
{
|
||||
|
@ -478,7 +478,7 @@ void setPlayer0Device(InputDevice* device)
|
||||
ActivePlayer* newPlayer = new ActivePlayer(UserConfigParams::m_all_players.get(0));
|
||||
StateManager::get()->addActivePlayer( newPlayer );
|
||||
newPlayer->setDevice(device);
|
||||
|
||||
device->setPlayer(newPlayer);
|
||||
input_manager->getDeviceList()->setAssignMode(DETECT_NEW);
|
||||
|
||||
// TODO : fall back in no-assign mode when aborting a game and going back to the menu
|
||||
|
@ -463,7 +463,7 @@ namespace OptionsScreen
|
||||
std::cout << "% Binding " << KartActionStrings[binding_to_set] << " : setting to keyboard key " << sensedInput->btnID << " \n\n";
|
||||
|
||||
KeyboardDevice* keyboard = input_manager->getDeviceList()->getKeyboard(0);
|
||||
keyboard->getConfiguration()->setBinding(binding_to_set, Input::IT_KEYBOARD, sensedInput->btnID, Input::AD_NEUTRAL);
|
||||
//keyboard->getConfiguration()->setBinding(binding_to_set, Input::IT_KEYBOARD, sensedInput->btnID, Input::AD_NEUTRAL);
|
||||
|
||||
// refresh display
|
||||
initInput(NULL, "init");
|
||||
|
Loading…
Reference in New Issue
Block a user