From e7ae7a8ca64d88cf097205a2be9ecf83a1c31099 Mon Sep 17 00:00:00 2001 From: Alex Rice Date: Sat, 3 Aug 2019 19:55:58 +0000 Subject: [PATCH] Allow user controller bindings --- AUTHORS.md | 1 + CHANGELOG.md | 3 ++- apps/openmw/engine.cpp | 11 ++++++++++- apps/openmw/mwinput/inputmanagerimp.cpp | 7 ++++++- apps/openmw/mwinput/inputmanagerimp.hpp | 1 + 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 5b848fab4..c64b83dab 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -22,6 +22,7 @@ Programmers alexanderkjall Alexander Nadeau (wareya) Alexander Olofsson (Ace) + Alex Rice Alex S (docwest) Allofich Andrei Kortunov (akortunov) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29e310b58..a64529afd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ Bug #4384: Resist Normal Weapons only checks ammunition for ranged weapons Bug #4411: Reloading a saved game while falling prevents damage in some cases Bug #4540: Rain delay when exiting water - Bug #4600: Crash when no sound output is available or --no-sound is used. + Bug #4600: Crash when no sound output is available or --no-sound is used. Bug #4639: Black screen after completing first mages guild mission + training Bug #4701: PrisonMarker record is not hardcoded like other markers Bug #4703: Editor: it's possible to preview levelled list records @@ -153,6 +153,7 @@ Feature #5046: Gamepad thumbstick cursor speed Feature #5051: Provide a separate textures for scrollbars Feature #5094: Unix like console hotkeys + Feature #5098: Allow user controller bindings Task #4686: Upgrade media decoder to a more current FFmpeg API Task #4695: Optimize Distant Terrain memory consumption Task #4789: Optimize cell transitions diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 07127d28b..d5ab73213 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -515,8 +515,17 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) controllerFileName = "gamecontrollerdb.txt"; } + const std::string userdefault = mCfgMgr.getUserConfigPath().string() + "/" + controllerFileName; const std::string localdefault = mCfgMgr.getLocalPath().string() + "/" + controllerFileName; const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/" + controllerFileName; + + std::string userGameControllerdb; + if (boost::filesystem::exists(userdefault)){ + userGameControllerdb = userdefault; + } + else + userGameControllerdb = ""; + std::string gameControllerdb; if (boost::filesystem::exists(localdefault)) gameControllerdb = localdefault; @@ -525,7 +534,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) else gameControllerdb = ""; //if it doesn't exist, pass in an empty string - MWInput::InputManager* input = new MWInput::InputManager (mWindow, mViewer, mScreenCaptureHandler, mScreenCaptureOperation, keybinderUser, keybinderUserExists, gameControllerdb, mGrab); + MWInput::InputManager* input = new MWInput::InputManager (mWindow, mViewer, mScreenCaptureHandler, mScreenCaptureOperation, keybinderUser, keybinderUserExists, userGameControllerdb, gameControllerdb, mGrab); mEnvironment.setInputManager (input); std::string myguiResources = (mResDir / "mygui").string(); diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 581a96e7b..efe85a3bb 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -39,6 +39,7 @@ namespace MWInput osg::ref_ptr screenCaptureHandler, osgViewer::ScreenCaptureHandler::CaptureOperation *screenCaptureOperation, const std::string& userFile, bool userFileExists, + const std::string& userControllerBindingsFile, const std::string& controllerBindingsFile, bool grab) : mWindow(window) , mWindowVisible(true) @@ -113,10 +114,14 @@ namespace MWInput // Load controller mappings #if SDL_VERSION_ATLEAST(2,0,2) - if(controllerBindingsFile!="") + if(!controllerBindingsFile.empty()) { SDL_GameControllerAddMappingsFromFile(controllerBindingsFile.c_str()); } + if(!userControllerBindingsFile.empty()) + { + SDL_GameControllerAddMappingsFromFile(userControllerBindingsFile.c_str()); + } #endif // Open all presently connected sticks diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index caf57681d..eaa081f99 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -76,6 +76,7 @@ namespace MWInput osg::ref_ptr screenCaptureHandler, osgViewer::ScreenCaptureHandler::CaptureOperation *screenCaptureOperation, const std::string& userFile, bool userFileExists, + const std::string& userControllerBindingsFile, const std::string& controllerBindingsFile, bool grab); virtual ~InputManager();