Maintain a flag that indicates if the gamepad device name is 'useful'
(on windows we might get a dummy name, identical for all gamepads). Only add a number to the gamepad if the device has a useless default name.
This commit is contained in:
parent
dec5ac8aa2
commit
150941aad2
@ -481,6 +481,14 @@ struct SJoystickInfo
|
||||
//! The presence or absence of a hat cannot be determined.
|
||||
POV_HAT_UNKNOWN
|
||||
} PovHat;
|
||||
|
||||
//! Set if the name of the joystick is useful:
|
||||
/** On windows the default name is useless, since it's always the same
|
||||
* indepentent of what joystick is connected ("Microsoft PC-joystick driver").
|
||||
* We will try to get a better name from the registry, but if this should
|
||||
* fail this flag is set and used by STK. */
|
||||
bool HasNonDefaultName;
|
||||
|
||||
}; // struct SJoystickInfo
|
||||
|
||||
|
||||
|
@ -2038,6 +2038,7 @@ bool CIrrDeviceLinux::activateJoysticks(core::array<SJoystickInfo> & joystickInf
|
||||
|
||||
ActiveJoysticks.push_back(info);
|
||||
|
||||
returnInfo.HasNonDefaultName = true;
|
||||
returnInfo.Joystick = joystick;
|
||||
returnInfo.PovHat = SJoystickInfo::POV_HAT_UNKNOWN;
|
||||
returnInfo.Axes = info.axes;
|
||||
|
@ -557,6 +557,7 @@ bool CIrrDeviceSDL::activateJoysticks(core::array<SJoystickInfo> & joystickInfo)
|
||||
SJoystickInfo info;
|
||||
|
||||
info.Joystick = joystick;
|
||||
info.HasNonDefaultName = true;
|
||||
info.Axes = SDL_JoystickNumAxes(Joysticks[joystick]);
|
||||
info.Buttons = SDL_JoystickNumButtons(Joysticks[joystick]);
|
||||
info.Name = SDL_JoystickName(joystick);
|
||||
|
@ -368,7 +368,8 @@ void setJoystickName(int index, const JOYCAPS &caps, SJoystickInfo *joystick)
|
||||
{
|
||||
// As a default use the name given in the joystick structure
|
||||
// - though that is always the same name, independent of joystick :(
|
||||
joystick->Name = caps.szPname;
|
||||
joystick->Name = caps.szPname;
|
||||
joystick->HasNonDefaultName = true;
|
||||
|
||||
core::stringc key = core::stringc(REGSTR_PATH_JOYCONFIG)+"\\"+caps.szRegKey
|
||||
+ "\\"+REGSTR_KEY_JOYCURR;
|
||||
@ -412,6 +413,7 @@ void setJoystickName(int index, const JOYCAPS &caps, SJoystickInfo *joystick)
|
||||
regresult = RegQueryValueExA(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0,
|
||||
(LPBYTE)name, ®size );
|
||||
joystick->Name = name;
|
||||
joystick->HasNonDefaultName = false;
|
||||
} // if name
|
||||
} // if SUCCESS
|
||||
RegCloseKey(hKey);
|
||||
|
@ -1709,6 +1709,7 @@ bool CIrrDeviceMacOSX::activateJoysticks(core::array<SJoystickInfo> & joystickIn
|
||||
|
||||
SJoystickInfo returnInfo;
|
||||
returnInfo.Joystick = jindex;
|
||||
returnInfo..HasNonDefaultName = true;
|
||||
returnInfo.Axes = info.axes;
|
||||
//returnInfo.Hats = info.hats;
|
||||
returnInfo.Buttons = info.buttons;
|
||||
|
@ -101,13 +101,17 @@ bool DeviceManager::initialize()
|
||||
// Some linux systems report a disk accelerometer as a gamepad, skip that
|
||||
if (name.find("LIS3LV02DL") != -1) continue;
|
||||
|
||||
#ifdef WIN32
|
||||
// On Windows, unless we use DirectInput, all gamepads are given the
|
||||
// same name ('microsoft pc-joystick driver'). This makes configuration
|
||||
// totally useless, so append an ID to the name. We can't test for the
|
||||
// name, since the name is even translated.
|
||||
name = name + " " + StringUtils::toString(id).c_str();
|
||||
#endif
|
||||
if(!m_irrlicht_gamepads[id].HasNonDefaultName)
|
||||
{
|
||||
// On Windows all gamepads are given the same name ('microsoft
|
||||
// pc-joystick driver') - unless we add DirectInput or so as
|
||||
// dependency. We can't test for the name, since the name is even
|
||||
// translated. Irrlicht now tries to get a better name from the
|
||||
// registry, but in case this should fail we still have all
|
||||
// gamepads with the same name shown in the GUI. This makes
|
||||
// configuration totally useless, so append an ID to the name.
|
||||
name = name + " " + StringUtils::toString(id).c_str();
|
||||
}
|
||||
|
||||
if (UserConfigParams::logMisc())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user