(hopefully) correct gamecontrollerdb.txt behavior

celladd
Digmaster 10 years ago committed by scrawl
parent 796b4b01b0
commit a192836582

@ -460,6 +460,7 @@ IF(NOT WIN32 AND NOT APPLE)
INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${SYSCONFDIR}" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${SYSCONFDIR}" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "${SYSCONFDIR}" RENAME "openmw.cfg" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
INSTALL(FILES "${OpenMW_BINARY_DIR}/gamecontrollerdb.txt" DESTINATION "${SYSCONFDIR}" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw")
IF(BUILD_OPENCS)
INSTALL(FILES "${OpenMW_BINARY_DIR}/opencs.ini" DESTINATION "${SYSCONFDIR}" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "opencs")
ENDIF(BUILD_OPENCS)
@ -479,6 +480,7 @@ if(WIN32)
"${OpenMW_SOURCE_DIR}/Docs/license/DejaVu Font License.txt"
"${OpenMW_BINARY_DIR}/settings-default.cfg"
"${OpenMW_BINARY_DIR}/transparency-overrides.cfg"
"${OpenMW_BINARY_DIR}/gamecontrollerdb.txt"
"${OpenMW_BINARY_DIR}/Release/openmw.exe"
DESTINATION ".")
@ -750,6 +752,7 @@ if (APPLE)
install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/gamecontrollerdb.txt" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
install(FILES "${OpenMW_BINARY_DIR}/opencs.ini" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)

@ -368,7 +368,19 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
std::string keybinderUser = (mCfgMgr.getUserConfigPath() / "input_v2.xml").string();
bool keybinderUserExists = boost::filesystem::exists(keybinderUser);
MWInput::InputManager* input = new MWInput::InputManager (*mOgre, *this, keybinderUser, keybinderUserExists, mGrab);
// find correct path to the game controller bindings
const std::string localdefault = mCfgMgr.getLocalPath().string() + "/gamecontrollerdb.cfg";
const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/gamecontrollerdb.cfg";
std::string gameControllerdb;
if (boost::filesystem::exists(localdefault))
gameControllerdb = localdefault;
else if (boost::filesystem::exists(globaldefault))
gameControllerdb = globaldefault;
else
gameControllerdb = ""; //if it doesn't exist, pass in an empty string
MWInput::InputManager* input = new MWInput::InputManager (*mOgre, *this, keybinderUser, keybinderUserExists, gameControllerdb, mGrab);
mEnvironment.setInputManager (input);
MWGui::WindowManager* window = new MWGui::WindowManager(

@ -100,7 +100,8 @@ namespace MWInput
{
InputManager::InputManager(OEngine::Render::OgreRenderer &ogre,
OMW::Engine& engine,
const std::string& userFile, bool userFileExists, bool grab)
const std::string& userFile, bool userFileExists,
const std::string& controllerBindingsFile, bool grab)
: mOgre(ogre)
, mPlayer(NULL)
, mEngine(engine)
@ -160,19 +161,9 @@ namespace MWInput
//Load controller mappings
#if SDL_VERSION_ATLEAST(2,0,2)
Files::ConfigurationManager cfgMgr;
std::string db = cfgMgr.getLocalPath().string() + "/gamecontrollerdb.txt";
if(boost::filesystem::exists(db))
if(controllerBindingsFile!="")
{
int res = SDL_GameControllerAddMappingsFromFile(db.c_str());
if(res == -1)
{
//ICS_LOG(std::string("Error loading controller bindings: ")+SDL_GetError());
}
else
{
//ICS_LOG(std::string("Loaded ")+boost::lexical_cast<std::string>(res)+" Game controller bindings");
}
SDL_GameControllerAddMappingsFromFile(controllerBindingsFile.c_str());
}
#endif

@ -68,7 +68,8 @@ namespace MWInput
public:
InputManager(OEngine::Render::OgreRenderer &_ogre,
OMW::Engine& engine,
const std::string& userFile, bool userFileExists, bool grab);
const std::string& userFile, bool userFileExists,
const std::string& controllerBindingsFile, bool grab);
virtual ~InputManager();

Loading…
Cancel
Save