Merge branch 'controller-bindings' into 'master'

Allow user controller bindings

See merge request OpenMW/openmw!135
pull/541/head
Alexei Dobrohotov 5 years ago
commit 793016f163

@ -22,6 +22,7 @@ Programmers
alexanderkjall alexanderkjall
Alexander Nadeau (wareya) Alexander Nadeau (wareya)
Alexander Olofsson (Ace) Alexander Olofsson (Ace)
Alex Rice
Alex S (docwest) Alex S (docwest)
Allofich Allofich
Andrei Kortunov (akortunov) Andrei Kortunov (akortunov)

@ -153,6 +153,7 @@
Feature #5046: Gamepad thumbstick cursor speed Feature #5046: Gamepad thumbstick cursor speed
Feature #5051: Provide a separate textures for scrollbars Feature #5051: Provide a separate textures for scrollbars
Feature #5094: Unix like console hotkeys Feature #5094: Unix like console hotkeys
Feature #5098: Allow user controller bindings
Task #4686: Upgrade media decoder to a more current FFmpeg API Task #4686: Upgrade media decoder to a more current FFmpeg API
Task #4695: Optimize Distant Terrain memory consumption Task #4695: Optimize Distant Terrain memory consumption
Task #4789: Optimize cell transitions Task #4789: Optimize cell transitions

@ -515,8 +515,17 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
controllerFileName = "gamecontrollerdb.txt"; controllerFileName = "gamecontrollerdb.txt";
} }
const std::string userdefault = mCfgMgr.getUserConfigPath().string() + "/" + controllerFileName;
const std::string localdefault = mCfgMgr.getLocalPath().string() + "/" + controllerFileName; const std::string localdefault = mCfgMgr.getLocalPath().string() + "/" + controllerFileName;
const std::string globaldefault = mCfgMgr.getGlobalPath().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; std::string gameControllerdb;
if (boost::filesystem::exists(localdefault)) if (boost::filesystem::exists(localdefault))
gameControllerdb = localdefault; gameControllerdb = localdefault;
@ -525,7 +534,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
else else
gameControllerdb = ""; //if it doesn't exist, pass in an empty string 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); mEnvironment.setInputManager (input);
std::string myguiResources = (mResDir / "mygui").string(); std::string myguiResources = (mResDir / "mygui").string();

@ -39,6 +39,7 @@ namespace MWInput
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler, osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler,
osgViewer::ScreenCaptureHandler::CaptureOperation *screenCaptureOperation, osgViewer::ScreenCaptureHandler::CaptureOperation *screenCaptureOperation,
const std::string& userFile, bool userFileExists, const std::string& userFile, bool userFileExists,
const std::string& userControllerBindingsFile,
const std::string& controllerBindingsFile, bool grab) const std::string& controllerBindingsFile, bool grab)
: mWindow(window) : mWindow(window)
, mWindowVisible(true) , mWindowVisible(true)
@ -113,10 +114,14 @@ namespace MWInput
// Load controller mappings // Load controller mappings
#if SDL_VERSION_ATLEAST(2,0,2) #if SDL_VERSION_ATLEAST(2,0,2)
if(controllerBindingsFile!="") if(!controllerBindingsFile.empty())
{ {
SDL_GameControllerAddMappingsFromFile(controllerBindingsFile.c_str()); SDL_GameControllerAddMappingsFromFile(controllerBindingsFile.c_str());
} }
if(!userControllerBindingsFile.empty())
{
SDL_GameControllerAddMappingsFromFile(userControllerBindingsFile.c_str());
}
#endif #endif
// Open all presently connected sticks // Open all presently connected sticks

@ -76,6 +76,7 @@ namespace MWInput
osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler, osg::ref_ptr<osgViewer::ScreenCaptureHandler> screenCaptureHandler,
osgViewer::ScreenCaptureHandler::CaptureOperation *screenCaptureOperation, osgViewer::ScreenCaptureHandler::CaptureOperation *screenCaptureOperation,
const std::string& userFile, bool userFileExists, const std::string& userFile, bool userFileExists,
const std::string& userControllerBindingsFile,
const std::string& controllerBindingsFile, bool grab); const std::string& controllerBindingsFile, bool grab);
virtual ~InputManager(); virtual ~InputManager();

Loading…
Cancel
Save