Skip to content

An OpenMW mod that lets you play the whole Elder Scrolls III: Morrowind as a top-down isometric game — with full online co-op or MMO modes.

C++

Controller: a pad that goes with a stick pushed no longer pushes for good

Alan Saunders92342afe4112
diff --git a/apps/openmw/mwinput/bindingsmanager.cpp b/apps/openmw/mwinput/bindingsmanager.cpp
index f35d727..a7ad0c3 100644
--- a/apps/openmw/mwinput/bindingsmanager.cpp
+++ b/apps/openmw/mwinput/bindingsmanager.cpp
@@ -659,6 +659,11 @@ namespace MWInput
mInputBinder->controllerRemoved(arg);
}
+ void BindingsManager::resetControllerControls()
+ {
+ mInputBinder->resetJoystickControls();
+ }
+
void BindingsManager::controllerButtonPressed(int deviceID, const SDL_ControllerButtonEvent& arg)
{
mInputBinder->buttonPressed(deviceID, arg);
diff --git a/apps/openmw/mwinput/bindingsmanager.hpp b/apps/openmw/mwinput/bindingsmanager.hpp
index 96dc581..83af3f6 100644
--- a/apps/openmw/mwinput/bindingsmanager.hpp
+++ b/apps/openmw/mwinput/bindingsmanager.hpp
@@ -50,6 +50,8 @@ namespace MWInput
SDL_GameController* getControllerOrNull() const;
SDL_JoystickID getControllerUsed() const { return mControllerUsed; }
void setControllerUsed(SDL_JoystickID instanceID) { mControllerUsed = instanceID; }
+ /// Every control a stick or a button is bound to back at rest (see ControllerManager::useController)
+ void resetControllerControls();
void mousePressed(const SDL_MouseButtonEvent& evt, Uint8 deviceID);
void mouseReleased(const SDL_MouseButtonEvent& arg, Uint8 deviceID);
diff --git a/apps/openmw/mwinput/controllermanager.cpp b/apps/openmw/mwinput/controllermanager.cpp
index c8cd61e..c23ef56 100644
--- a/apps/openmw/mwinput/controllermanager.cpp
+++ b/apps/openmw/mwinput/controllermanager.cpp
@@ -257,6 +257,12 @@ namespace MWInput
return;
}
+ // Isowind: another controller's sticks say nothing (a stream's virtual pad left behind, resting off centre)
+ // until one is pushed far enough to make it the one read
+ const SDL_JoystickID used = mBindingsManager->getControllerUsed();
+ if (used != -1 && arg.which != used)
+ return;
+
if (!Settings::input().mEnableController || MWBase::Environment::get().getInputManager()->controlsDisabled())
return;
@@ -610,6 +616,9 @@ namespace MWInput
{
if (mBindingsManager->getControllerUsed() == instanceID)
return;
+ // Whatever the one read before last said is over (a stream's pad that went quiet with a stick pushed would
+ // otherwise push for good, the pointer drifting to the screen's edge)
+ mBindingsManager->resetControllerControls();
mBindingsManager->setControllerUsed(instanceID);
enableGyroSensor();
}
diff --git a/extern/oics/ICSInputControlSystem_joystick.cpp b/extern/oics/ICSInputControlSystem_joystick.cpp
index 403e7a2..0e45156 100644
--- a/extern/oics/ICSInputControlSystem_joystick.cpp
+++ b/extern/oics/ICSInputControlSystem_joystick.cpp
@@ -328,6 +328,34 @@ namespace ICS
SDL_GameControllerClose(mJoystickInstanceMap.at(args.which));
mJoystickInstanceMap.erase(args.which);
}
+ // Isowind: whatever its sticks and buttons last said is over with it: no event comes to say they were let go
+ resetJoystickControls();
+ }
+
+ void InputControlSystem::resetJoystickControls()
+ {
+ for(JoystickAxisBinderMapType::iterator device = mControlsJoystickAxisBinderMap.begin();
+ device != mControlsJoystickAxisBinderMap.end(); ++device)
+ {
+ for(ControlsAxisBinderMapType::iterator it = device->second.begin(); it != device->second.end(); ++it)
+ {
+ Control* control = it->second.control;
+ if(control)
+ {
+ control->setChangingDirection(Control::STOP);
+ control->setValue(control->getInitialValue());
+ }
+ }
+ }
+ for(JoystickButtonBinderMapType::iterator device = mControlsJoystickButtonBinderMap.begin();
+ device != mControlsJoystickButtonBinderMap.end(); ++device)
+ {
+ for(ControlsButtonBinderMapType::iterator it = device->second.begin(); it != device->second.end(); ++it)
+ {
+ if(it->second.control)
+ it->second.control->setChangingDirection(Control::STOP);
+ }
+ }
}
// joystick auto bindings
diff --git a/extern/oics/include/oics/ICSInputControlSystem.h b/extern/oics/include/oics/ICSInputControlSystem.h
index f073640..158efa9 100644
--- a/extern/oics/include/oics/ICSInputControlSystem.h
+++ b/extern/oics/include/oics/ICSInputControlSystem.h
@@ -100,6 +100,9 @@ namespace ICS
void controllerAdded (int deviceID, const SDL_ControllerDeviceEvent &args);
void controllerRemoved(const SDL_ControllerDeviceEvent &args);
+ // Isowind: every control a stick or a button is bound to back at rest (a controller gone, or another taken up:
+ // a stick left pushed when it went would push for good)
+ void resetJoystickControls();
JoystickIDList& getJoystickIdList(){ return mJoystickIDList; };
JoystickInstanceMap& getJoystickInstanceMap(){ return mJoystickInstanceMap; };