Don't reset an unbound input action to its default binding if the key/mouse button for that default binding is already used by another action (Fixes #1960)

deque
scrawl 10 years ago
parent 46adf6344a
commit f9b6cc468d

@ -936,9 +936,11 @@ namespace MWInput
{ {
clearAllBindings (control); clearAllBindings (control);
if (defaultKeyBindings.find(i) != defaultKeyBindings.end()) if (defaultKeyBindings.find(i) != defaultKeyBindings.end()
&& !mInputBinder->isKeyBound(defaultKeyBindings[i]))
mInputBinder->addKeyBinding(control, defaultKeyBindings[i], ICS::Control::INCREASE); mInputBinder->addKeyBinding(control, defaultKeyBindings[i], ICS::Control::INCREASE);
else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end()) else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end()
&& !mInputBinder->isMouseButtonBound(defaultMouseButtonBindings[i]))
mInputBinder->addMouseButtonBinding (control, defaultMouseButtonBindings[i], ICS::Control::INCREASE); mInputBinder->addMouseButtonBinding (control, defaultMouseButtonBindings[i], ICS::Control::INCREASE);
} }
} }

@ -119,8 +119,10 @@ namespace ICS
//bool sliderMoved(const OIS::JoyStickEvent &evt, int index); //bool sliderMoved(const OIS::JoyStickEvent &evt, int index);
void addKeyBinding(Control* control, SDL_Scancode key, Control::ControlChangingDirection direction); void addKeyBinding(Control* control, SDL_Scancode key, Control::ControlChangingDirection direction);
bool isKeyBound(SDL_Scancode key) const;
void addMouseAxisBinding(Control* control, NamedAxis axis, Control::ControlChangingDirection direction); void addMouseAxisBinding(Control* control, NamedAxis axis, Control::ControlChangingDirection direction);
void addMouseButtonBinding(Control* control, unsigned int button, Control::ControlChangingDirection direction); void addMouseButtonBinding(Control* control, unsigned int button, Control::ControlChangingDirection direction);
bool isMouseButtonBound(unsigned int button) const;
void addJoystickAxisBinding(Control* control, int deviceId, int axis, Control::ControlChangingDirection direction); void addJoystickAxisBinding(Control* control, int deviceId, int axis, Control::ControlChangingDirection direction);
void addJoystickButtonBinding(Control* control, int deviceId, unsigned int button, Control::ControlChangingDirection direction); void addJoystickButtonBinding(Control* control, int deviceId, unsigned int button, Control::ControlChangingDirection direction);
void addJoystickPOVBinding(Control* control, int deviceId, int index, POVAxis axis, Control::ControlChangingDirection direction); void addJoystickPOVBinding(Control* control, int deviceId, int index, POVAxis axis, Control::ControlChangingDirection direction);

@ -61,6 +61,11 @@ namespace ICS
mControlsKeyBinderMap[ key ] = controlKeyBinderItem; mControlsKeyBinderMap[ key ] = controlKeyBinderItem;
} }
bool InputControlSystem::isKeyBound(SDL_Scancode key) const
{
return mControlsKeyBinderMap.find(key) != mControlsKeyBinderMap.end();
}
void InputControlSystem::removeKeyBinding(SDL_Scancode key) void InputControlSystem::removeKeyBinding(SDL_Scancode key)
{ {
ControlsKeyBinderMapType::iterator it = mControlsKeyBinderMap.find(key); ControlsKeyBinderMapType::iterator it = mControlsKeyBinderMap.find(key);

@ -139,6 +139,11 @@ namespace ICS
mControlsMouseButtonBinderMap[ button ] = controlMouseButtonBinderItem; mControlsMouseButtonBinderMap[ button ] = controlMouseButtonBinderItem;
} }
bool InputControlSystem::isMouseButtonBound(unsigned int button) const
{
return mControlsMouseButtonBinderMap.find(button) != mControlsMouseButtonBinderMap.end();
}
// get bindings // get bindings
InputControlSystem::NamedAxis InputControlSystem::getMouseAxisBinding(Control* control, ICS::Control::ControlChangingDirection direction) InputControlSystem::NamedAxis InputControlSystem::getMouseAxisBinding(Control* control, ICS::Control::ControlChangingDirection direction)
{ {

Loading…
Cancel
Save