Support for multiple keyboard players (but you can't add a 2nd keyboard through the GUI atm, it needs to be done in the config file)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4224 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2009-11-14 15:19:40 +00:00
parent cb91674631
commit bed690a4d1
2 changed files with 18 additions and 12 deletions

View File

@@ -41,10 +41,15 @@ bool DeviceManager::initialize()
m_keyboard_configs.push_back(new KeyboardConfig());
created = true;
}
m_keyboards.push_back(new KeyboardDevice(m_keyboard_configs.get(0)));
// TODO: Detect keyboard presence, if there is no keyboard, this should be false
m_keyboard_configs.get(0)->setInUse(true);
const int keyboard_amount = m_keyboard_configs.size();
for (int n=0; n<keyboard_amount; n++)
{
m_keyboards.push_back(new KeyboardDevice(m_keyboard_configs.get(n)));
// TODO: Detect keyboard presence, if there is no keyboard, this should be false
m_keyboard_configs.get(n)->setInUse(n == 0);
}
printf("Initializing gamepad support.\n");
irr_driver->getDevice()->activateJoysticks(m_irrlicht_gamepads);

View File

@@ -264,21 +264,21 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID, int btnID,
{
action = PA_FIRST;
if(btnID == KEY_UP) action = PA_ACCEL;
else if(btnID == KEY_DOWN) action = PA_BRAKE;
else if(btnID == KEY_LEFT) action = PA_LEFT;
else if(btnID == KEY_RIGHT) action = PA_RIGHT;
else if(btnID == KEY_SPACE) action = PA_FIRE;
if (btnID == KEY_UP) action = PA_ACCEL;
else if (btnID == KEY_DOWN) action = PA_BRAKE;
else if (btnID == KEY_LEFT) action = PA_LEFT;
else if (btnID == KEY_RIGHT) action = PA_RIGHT;
else if (btnID == KEY_SPACE) action = PA_FIRE;
if(btnID == KEY_RETURN && GUIEngine::ModalDialog::isADialogActive()) GUIEngine::ModalDialog::onEnterPressed();
if(action != PA_FIRST)
if (action != PA_FIRST)
{
action_found = true;
player = 0;
}
}
// Act different in input sensing mode.
if (m_mode == INPUT_SENSE_KEYBOARD ||
m_mode == INPUT_SENSE_GAMEPAD)
@@ -290,7 +290,7 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID, int btnID,
{
// If we're in the kart menu awaiting new players, do special things
// when a device presses fire or rescue
if( m_device_manager->getAssignMode() == DETECT_NEW )
if (m_device_manager->getAssignMode() == DETECT_NEW)
{
// Player is unjoining
if ((player != NULL) && (action == PA_RESCUE))
@@ -319,6 +319,7 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID, int btnID,
InputDevice *device = NULL;
if (type == Input::IT_KEYBOARD)
{
//std::cout << "==== New Player Joining with Key " << btnID << " ====" << std::endl;
device = m_device_manager->getKeyboardFromBtnID(btnID);
}
else if (type == Input::IT_STICKBUTTON || type == Input::IT_STICKMOTION)