From bb6ed06a4eacf1dc0c3fa852eb9cec70e138cc11 Mon Sep 17 00:00:00 2001 From: Digmaster Date: Tue, 9 Dec 2014 14:37:32 -0600 Subject: [PATCH] read gamecontrollerdb file location from settings file --- apps/openmw/mwinput/inputmanagerimp.cpp | 4 ++-- extern/oics/ICSInputControlSystem.cpp | 21 ++++++++++++--------- extern/oics/ICSInputControlSystem.h | 3 ++- files/settings-default.cfg | 2 ++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 2dbbea662..3d1239f54 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -135,8 +135,8 @@ namespace MWInput mInputManager->setControllerEventCallback(this); std::string file = userFileExists ? userFile : ""; - mInputBinder = new ICS::InputControlSystem(file, true, this, NULL, A_Last); - + std::string controllerdb = Settings::Manager::getString("gamecontrollerdb file", "Input"); + mInputBinder = new ICS::InputControlSystem(file, true, this, NULL, controllerdb, A_Last); adjustMouseRegion (window->getWidth(), window->getHeight()); loadKeyDefaults(); diff --git a/extern/oics/ICSInputControlSystem.cpp b/extern/oics/ICSInputControlSystem.cpp index 3c719151b..4db28d3f1 100644 --- a/extern/oics/ICSInputControlSystem.cpp +++ b/extern/oics/ICSInputControlSystem.cpp @@ -30,7 +30,7 @@ namespace ICS { InputControlSystem::InputControlSystem(std::string file, bool active , DetectingBindingListener* detectingBindingListener - , InputControlSystemLog* log, size_t channelCount) + , InputControlSystemLog* log, std::string controllerdb, size_t channelCount) : mFileName(file) , mDetectingBindingListener(detectingBindingListener) , mDetectingBindingControl(NULL) @@ -279,14 +279,17 @@ namespace ICS //Load controller mappings #if SDL_VERSION_ATLEAST(2,0,2) - int res = SDL_GameControllerAddMappingsFromFile("resources/gamecontrollerdb.txt"); - if(res == -1) - { - ICS_LOG(std::string("Error loading controller bindings: ")+SDL_GetError()); - } - else - { - ICS_LOG(std::string("Loaded ")+boost::lexical_cast(res)+" Game controller bindings"); + if(!controllerdb.empty()) + { + int res = SDL_GameControllerAddMappingsFromFile(controllerdb.c_str()); + if(res == -1) + { + ICS_LOG(std::string("Error loading controller bindings: ")+SDL_GetError()); + } + else + { + ICS_LOG(std::string("Loaded ")+boost::lexical_cast(res)+" Game controller bindings"); + } } #endif diff --git a/extern/oics/ICSInputControlSystem.h b/extern/oics/ICSInputControlSystem.h index 0bdd67b34..f58d242fc 100644 --- a/extern/oics/ICSInputControlSystem.h +++ b/extern/oics/ICSInputControlSystem.h @@ -74,7 +74,8 @@ namespace ICS InputControlSystem(std::string file = "", bool active = true , DetectingBindingListener* detectingBindingListener = NULL - , InputControlSystemLog* log = NULL, size_t channelCount = 16); + , InputControlSystemLog* log = NULL, std::string controllerdb = "" + , size_t channelCount = 16); ~InputControlSystem(); std::string getFileName(){ return mFileName; }; diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 7566994e2..ae0a468cd 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -181,6 +181,8 @@ always run = false allow third person zoom = false +gamecontrollerdb file = resources/gamecontrollerdb.txt + [Game] # Always use the most powerful attack when striking with a weapon (chop, slash or thrust) best attack = false