From ad54e095934d0660308c8e9fe21aa9c6d9b916af Mon Sep 17 00:00:00 2001 From: Digmaster Date: Tue, 9 Dec 2014 11:16:17 -0600 Subject: [PATCH] Inital value for joysticks is 0.5 --- apps/openmw/mwinput/inputmanagerimp.cpp | 16 ++++++++++++++-- extern/oics/ICSControl.h | 7 ++++--- extern/oics/ICSInputControlSystem.cpp | 2 ++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 2cb9075bd..633ae10d4 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -1120,11 +1120,13 @@ namespace MWInput if (defaultKeyBindings.find(i) != defaultKeyBindings.end() && !mInputBinder->isKeyBound(defaultKeyBindings[i])) { + control->setInitialValue(0.0f); mInputBinder->addKeyBinding(control, defaultKeyBindings[i], ICS::Control::INCREASE); } else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end() && !mInputBinder->isMouseButtonBound(defaultMouseButtonBindings[i])) { + control->setInitialValue(0.0f); mInputBinder->addMouseButtonBinding (control, defaultMouseButtonBindings[i], ICS::Control::INCREASE); } } @@ -1167,7 +1169,11 @@ namespace MWInput bool controlExists = mInputBinder->getChannel(i)->getControlsCount () != 0; if (!controlExists) { - control = new ICS::Control(boost::lexical_cast(i), false, true, 0, ICS::ICS_MAX, ICS::ICS_MAX); + int inital; + if (defaultButtonBindings.find(i) != defaultButtonBindings.end()) + inital = 0.0f; + else inital = 0.5f; + control = new ICS::Control(boost::lexical_cast(i), false, true, inital, ICS::ICS_MAX, ICS::ICS_MAX); mInputBinder->addControl(control); control->attachChannel(mInputBinder->getChannel(i), ICS::Channel::DIRECT); } @@ -1182,11 +1188,13 @@ namespace MWInput if (defaultButtonBindings.find(i) != defaultButtonBindings.end()) { - control->setValue(0.5f); + control->setInitialValue(0.0f); mInputBinder->addJoystickButtonBinding(control, defaultButtonBindings[i], ICS::Control::INCREASE); } else if (defaultAxisBindings.find(i) != defaultAxisBindings.end()) { + control->setValue(0.5f); + control->setInitialValue(0.5f); mInputBinder->addJoystickAxisBinding(control, defaultAxisBindings[i], ICS::Control::INCREASE); } } @@ -1426,6 +1434,7 @@ namespace MWInput return; clearAllKeyBindings(control); + control->setInitialValue(0.0f); ICS::DetectingBindingListener::keyBindingDetected (ICS, control, key, direction); MWBase::Environment::get().getWindowManager ()->notifyInputActionBound (); } @@ -1436,6 +1445,7 @@ namespace MWInput if(!mDetectingKeyboard) return; clearAllKeyBindings(control); + control->setInitialValue(0.0f); ICS::DetectingBindingListener::mouseButtonBindingDetected (ICS, control, button, direction); MWBase::Environment::get().getWindowManager ()->notifyInputActionBound (); } @@ -1451,6 +1461,7 @@ namespace MWInput clearAllControllerBindings(control); control->setValue(0.5f); //axis bindings must start at 0.5 + control->setInitialValue(0.5f); ICS::DetectingBindingListener::joystickAxisBindingDetected (ICS, control, axis, direction); MWBase::Environment::get().getWindowManager ()->notifyInputActionBound (); } @@ -1461,6 +1472,7 @@ namespace MWInput if(mDetectingKeyboard) return; clearAllControllerBindings(control); + control->setInitialValue(0.0f); ICS::DetectingBindingListener::joystickButtonBindingDetected (ICS, control, button, direction); MWBase::Environment::get().getWindowManager ()->notifyInputActionBound (); } diff --git a/extern/oics/ICSControl.h b/extern/oics/ICSControl.h index ebf75a3fe..1ed437652 100644 --- a/extern/oics/ICSControl.h +++ b/extern/oics/ICSControl.h @@ -34,7 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. namespace ICS { - + class DllExport Control { public: @@ -52,9 +52,10 @@ namespace ICS void setValue(float value); inline float getValue(){ return mValue; }; - inline float getInitialValue(){ return mInitialValue; }; + inline float getInitialValue(){ return mInitialValue; }; + inline void setInitialValue(float i) {mInitialValue = i;}; - void attachChannel(Channel* channel, Channel::ChannelDirection direction, float percentage = 1.0); + void attachChannel(Channel* channel, Channel::ChannelDirection direction, float percentage = 1.0); std::list getAttachedChannels(){ return mAttachedChannels; }; inline float getStepSize(){ return mStepSize; }; diff --git a/extern/oics/ICSInputControlSystem.cpp b/extern/oics/ICSInputControlSystem.cpp index 4237060bb..3c719151b 100644 --- a/extern/oics/ICSInputControlSystem.cpp +++ b/extern/oics/ICSInputControlSystem.cpp @@ -278,6 +278,7 @@ namespace ICS /* Joystick Init */ //Load controller mappings +#if SDL_VERSION_ATLEAST(2,0,2) int res = SDL_GameControllerAddMappingsFromFile("resources/gamecontrollerdb.txt"); if(res == -1) { @@ -287,6 +288,7 @@ namespace ICS { ICS_LOG(std::string("Loaded ")+boost::lexical_cast(res)+" Game controller bindings"); } +#endif //Open all presently connected sticks int numSticks = SDL_NumJoysticks();