Show in the options when many similar gamepads are connected

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10394 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-12-10 19:47:59 +00:00
parent 0de1c740e9
commit b0270f69d6
4 changed files with 17 additions and 11 deletions

View File

@ -271,7 +271,7 @@ void KeyboardConfig::setDefaultBinds()
KeyboardConfig::KeyboardConfig() : DeviceConfig(DEVICE_CONFIG_TYPE_KEYBOARD)
{
m_name = "Keyboard";
setPlugged(true);
m_plugged = 1;
setDefaultBinds();
}
@ -317,7 +317,7 @@ GamepadConfig::GamepadConfig ( const std::string name,
m_name = name;
m_axis_count = axis_count;
m_button_count = btnCount;
setPlugged(false);
m_plugged = 0;
setDefaultBinds();
}
@ -345,7 +345,7 @@ GamepadConfig::GamepadConfig(irr::io::IrrXMLReader* xml) : DeviceConfig( DEVICE_
m_enabled = true;
}
setPlugged(false);
m_plugged = 0;
setDefaultBinds();
}

View File

@ -46,12 +46,10 @@ enum DeviceConfigType
*/
class DeviceConfig : public NoCopy
{
private:
protected:
Binding m_bindings[PA_COUNT];
bool m_plugged; //!< Is there a device connected to the system which uses this config?
protected:
int m_plugged; //!< How many devices connected to the system which uses this config?
bool m_enabled; //!< If set to false, this device will be ignored. Currently for gamepads only
@ -96,8 +94,9 @@ public:
Input::AxisDirection direction = Input::AD_NEUTRAL,
wchar_t character=0);
void setPlugged (bool plugged) {m_plugged = plugged;}
bool isPlugged () {return m_plugged;}
void setPlugged () { m_plugged++; }
bool isPlugged () const { return m_plugged > 0; }
int getNumberOfDevices () const { return m_plugged; }
/**
* \brief Searches for a game actions associated with the given input event

View File

@ -120,7 +120,7 @@ bool DeviceManager::initialize()
printf("using existing configuration.\n");
}
gamepadConfig->setPlugged(true);
gamepadConfig->setPlugged();
gamepadDevice = new GamePadDevice(id,
name.c_str(),
m_irrlicht_gamepads[id].Axes,

View File

@ -106,7 +106,14 @@ void OptionsScreenInput::buildDeviceList()
{
// since irrLicht's list widget has the nasty tendency to put the
// icons very close to the text, I'm adding spaces to compensate.
const irr::core::stringw name = (" " + config->getName()).c_str();
irr::core::stringw name = (" " + config->getName()).c_str();
if (config->getNumberOfDevices() > 1)
{
name += core::stringw(L" (x");
name += config->getNumberOfDevices();
name += core::stringw(L")");
}
std::ostringstream gpname;
gpname << "gamepad" << i;