From f9b6cc468db9d826f260fdc1d893b4c323ffd9ab Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 1 Oct 2014 17:54:18 +0200 Subject: [PATCH] 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) --- apps/openmw/mwinput/inputmanagerimp.cpp | 6 ++++-- extern/oics/ICSInputControlSystem.h | 4 +++- extern/oics/ICSInputControlSystem_keyboard.cpp | 5 +++++ extern/oics/ICSInputControlSystem_mouse.cpp | 5 +++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 3cd30819c..10cd34749 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -936,9 +936,11 @@ namespace MWInput { 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); - 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); } } diff --git a/extern/oics/ICSInputControlSystem.h b/extern/oics/ICSInputControlSystem.h index f874abaf8..6a6a6bf09 100644 --- a/extern/oics/ICSInputControlSystem.h +++ b/extern/oics/ICSInputControlSystem.h @@ -119,9 +119,11 @@ namespace ICS //bool sliderMoved(const OIS::JoyStickEvent &evt, int index); 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 addMouseButtonBinding(Control* control, unsigned int button, Control::ControlChangingDirection direction); - void addJoystickAxisBinding(Control* control, int deviceId, int axis, Control::ControlChangingDirection direction); + 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); void addJoystickPOVBinding(Control* control, int deviceId, int index, POVAxis axis, Control::ControlChangingDirection direction); void addJoystickSliderBinding(Control* control, int deviceId, int index, Control::ControlChangingDirection direction); diff --git a/extern/oics/ICSInputControlSystem_keyboard.cpp b/extern/oics/ICSInputControlSystem_keyboard.cpp index af0eec82a..ed35d9870 100644 --- a/extern/oics/ICSInputControlSystem_keyboard.cpp +++ b/extern/oics/ICSInputControlSystem_keyboard.cpp @@ -61,6 +61,11 @@ namespace ICS mControlsKeyBinderMap[ key ] = controlKeyBinderItem; } + bool InputControlSystem::isKeyBound(SDL_Scancode key) const + { + return mControlsKeyBinderMap.find(key) != mControlsKeyBinderMap.end(); + } + void InputControlSystem::removeKeyBinding(SDL_Scancode key) { ControlsKeyBinderMapType::iterator it = mControlsKeyBinderMap.find(key); diff --git a/extern/oics/ICSInputControlSystem_mouse.cpp b/extern/oics/ICSInputControlSystem_mouse.cpp index d1ef721b2..9742d389c 100644 --- a/extern/oics/ICSInputControlSystem_mouse.cpp +++ b/extern/oics/ICSInputControlSystem_mouse.cpp @@ -139,6 +139,11 @@ namespace ICS mControlsMouseButtonBinderMap[ button ] = controlMouseButtonBinderItem; } + bool InputControlSystem::isMouseButtonBound(unsigned int button) const + { + return mControlsMouseButtonBinderMap.find(button) != mControlsMouseButtonBinderMap.end(); + } + // get bindings InputControlSystem::NamedAxis InputControlSystem::getMouseAxisBinding(Control* control, ICS::Control::ControlChangingDirection direction) {