diff --git a/src/input/device_manager.cpp b/src/input/device_manager.cpp index d052470c9..e047699c8 100644 --- a/src/input/device_manager.cpp +++ b/src/input/device_manager.cpp @@ -92,7 +92,8 @@ bool DeviceManager::checkForGamePad(const int irr_id) std::cout << " (checking...) I remember that gamepad #" << n << " is named " << m_gamepads[n].m_name.c_str() << std::endl; // FIXME - don't check only name, but also number of axes and buttons? - if((m_gamepads[n].m_name == name) && (m_gamepads[n].m_index == irr_id)) + // Only assign device IDs to gamepads which have not yet been assigned a device ID + if((m_gamepads[n].m_name == name) && (m_gamepads[n].m_index == -1)) { std::cout << "--> that's the one currently connected\n"; m_gamepads[n].open(irr_id, m_gamepads[n].m_name, m_irrlicht_gamepads[irr_id].Axes, m_irrlicht_gamepads[irr_id].Buttons); diff --git a/src/input/input_device.cpp b/src/input/input_device.cpp index 59f1b0fd4..63b162e72 100644 --- a/src/input/input_device.cpp +++ b/src/input/input_device.cpp @@ -183,6 +183,7 @@ GamePadDevice::GamePadDevice(irr::io::IrrXMLReader* xml) std::cerr << "Warning, joystick without name in config file, making it undetectable\n"; } else m_name = name_string; + m_index = -1; // Set to -1 so we can establish when a device ID has been associated for(int n=0; n