diff --git a/CHANGELOG.md b/CHANGELOG.md
index cd7be8561d..b20cdd75ec 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -32,6 +32,7 @@
Feature #2229: Improve pathfinding AI
Feature #3442: Default values for fallbacks from ini file
Feature #3610: Option to invert X axis
+ Feature #3980: In-game option to disable controller
Feature #4209: Editor: Faction rank sub-table
Feature #4673: Weapon sheathing
Feature #4730: Native animated containers support
diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp
index be1301aacf..3251a387cc 100644
--- a/apps/openmw/mwinput/inputmanagerimp.cpp
+++ b/apps/openmw/mwinput/inputmanagerimp.cpp
@@ -55,6 +55,7 @@ namespace MWInput
, mInvertX (Settings::Manager::getBool("invert x axis", "Input"))
, mInvertY (Settings::Manager::getBool("invert y axis", "Input"))
, mControlsDisabled(false)
+ , mJoystickEnabled (Settings::Manager::getBool("enable controller", "Input"))
, mCameraSensitivity (Settings::Manager::getFloat("camera sensitivity", "Input"))
, mCameraYMultiplier (Settings::Manager::getFloat("camera y multiplier", "Input"))
, mPreviewPOVDelay(0.f)
@@ -659,6 +660,9 @@ namespace MWInput
if (it->first == "Input" && it->second == "grab cursor")
mGrabCursor = Settings::Manager::getBool("grab cursor", "Input");
+ if (it->first == "Input" && it->second == "enable controller")
+ mJoystickEnabled = Settings::Manager::getBool("enable controller", "Input");
+
if (it->first == "Video" && (
it->second == "resolution x"
|| it->second == "resolution y"
@@ -858,6 +862,9 @@ namespace MWInput
void InputManager::buttonPressed(int deviceID, const SDL_ControllerButtonEvent &arg )
{
+ if (!mJoystickEnabled)
+ return;
+
mJoystickLastUsed = true;
bool guiMode = false;
@@ -892,6 +899,9 @@ namespace MWInput
void InputManager::buttonReleased(int deviceID, const SDL_ControllerButtonEvent &arg )
{
+ if (!mJoystickEnabled)
+ return;
+
mJoystickLastUsed = true;
if(mInputBinder->detectingBindingState())
mInputBinder->buttonReleased(deviceID, arg);
@@ -915,7 +925,7 @@ namespace MWInput
void InputManager::axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg )
{
- if (!mControlsDisabled)
+ if (!mControlsDisabled && mJoystickEnabled)
mInputBinder->axisMoved(deviceID, arg);
}
diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp
index 361babec49..41b0bd4040 100644
--- a/apps/openmw/mwinput/inputmanagerimp.hpp
+++ b/apps/openmw/mwinput/inputmanagerimp.hpp
@@ -179,6 +179,7 @@ namespace MWInput
bool mInvertY;
bool mControlsDisabled;
+ bool mJoystickEnabled;
float mCameraSensitivity;
float mCameraYMultiplier;
diff --git a/docs/source/reference/modding/settings/input.rst b/docs/source/reference/modding/settings/input.rst
index 321c28afdc..51c72e15dd 100644
--- a/docs/source/reference/modding/settings/input.rst
+++ b/docs/source/reference/modding/settings/input.rst
@@ -120,3 +120,16 @@ If this setting is true, moving the mouse away from the player will look down,
while moving it towards the player will look up. This setting does not affect cursor movement in GUI mode.
This setting can be toggled in game with the Invert Y Axis button in the Controls panel of the Options menu.
+
+enable controller
+-----------------
+
+:Type: boolean
+:Range: True/False
+:Default: True
+
+Enable support of controller input — or rather not ignore controller events,
+which are always sent if a controller is present and detected.
+Disabling this setting can be useful for working around controller-related issues or for setting up split-screen gameplay configurations.
+
+This setting can be toggled in game with the Enable Joystick button in the Controls panel of the Options menu.
diff --git a/files/mygui/openmw_settings_window.layout b/files/mygui/openmw_settings_window.layout
index 8062980ffe..2d9c13bc92 100644
--- a/files/mygui/openmw_settings_window.layout
+++ b/files/mygui/openmw_settings_window.layout
@@ -222,21 +222,19 @@
-
-
-
+
-
+
-
+
-
+
@@ -246,14 +244,24 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/files/settings-default.cfg b/files/settings-default.cfg
index 89f4f82ea6..a6616ecc11 100644
--- a/files/settings-default.cfg
+++ b/files/settings-default.cfg
@@ -339,6 +339,9 @@ invert x axis = false
# Invert the vertical axis while not in GUI mode.
invert y axis = false
+# Enable controller support.
+enable controller = true
+
[Saves]
# Name of last character played, and default for loading save files.