1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 15:29:55 +00:00

Fix joystick binding for an action being discarded when default for another action is loaded (Bug #3900)

This commit is contained in:
scrawl 2017-06-25 14:43:56 +02:00
parent ca5b351eef
commit 8d17565efd
3 changed files with 24 additions and 3 deletions

View file

@ -1243,7 +1243,7 @@ namespace MWInput
if (!controlExists)
{
float initial;
if (defaultButtonBindings.find(i) != defaultButtonBindings.end())
if (defaultAxisBindings.find(i) == defaultAxisBindings.end())
initial = 0.0f;
else initial = 0.5f;
control = new ICS::Control(std::to_string(i), false, true, initial, ICS::ICS_MAX, ICS::ICS_MAX);
@ -1259,12 +1259,13 @@ namespace MWInput
{
clearAllControllerBindings(control);
if (defaultButtonBindings.find(i) != defaultButtonBindings.end())
if (defaultButtonBindings.find(i) != defaultButtonBindings.end()
&& !mInputBinder->isJoystickButtonBound(mFakeDeviceID, defaultButtonBindings[i]))
{
control->setInitialValue(0.0f);
mInputBinder->addJoystickButtonBinding(control, mFakeDeviceID, defaultButtonBindings[i], ICS::Control::INCREASE);
}
else if (defaultAxisBindings.find(i) != defaultAxisBindings.end())
else if (defaultAxisBindings.find(i) != defaultAxisBindings.end() && !mInputBinder->isJoystickAxisBound(mFakeDeviceID, defaultAxisBindings[i]))
{
control->setValue(0.5f);
control->setInitialValue(0.5f);

View file

@ -120,6 +120,8 @@ namespace ICS
bool isMouseButtonBound(unsigned int button) const;
void addJoystickAxisBinding(Control* control, int deviceID, int axis, Control::ControlChangingDirection direction);
void addJoystickButtonBinding(Control* control, int deviceID, unsigned int button, Control::ControlChangingDirection direction);
bool isJoystickButtonBound(int deviceID, unsigned int button) const;
bool isJoystickAxisBound(int deviceID, unsigned int axis) const;
void removeKeyBinding(SDL_Scancode key);
void removeMouseAxisBinding(NamedAxis axis);
void removeMouseButtonBinding(unsigned int button);

View file

@ -110,6 +110,24 @@ namespace ICS
mControlsJoystickButtonBinderMap[deviceID][button] = controlJoystickButtonBinderItem;
}
bool InputControlSystem::isJoystickButtonBound(int deviceID, unsigned int button) const
{
JoystickButtonBinderMapType::const_iterator found = mControlsJoystickButtonBinderMap.find(deviceID);
if (found == mControlsJoystickButtonBinderMap.end())
return false;
return (found->second.find(button) != found->second.end());
}
bool InputControlSystem::isJoystickAxisBound(int deviceID, unsigned int axis) const
{
JoystickAxisBinderMapType::const_iterator found = mControlsJoystickAxisBinderMap.find(deviceID);
if (found == mControlsJoystickAxisBinderMap.end())
return false;
return (found->second.find(axis) != found->second.end());
}
// get bindings
int InputControlSystem::getJoystickAxisBinding(Control* control, int deviceID, ICS::Control::ControlChangingDirection direction)
{