SDLControllerInterface: Ship game controller db with builds

This commit is contained in:
Connor McLaughlin
2020-11-27 15:27:58 +10:00
parent bf584faa32
commit b73fd7a4e8
2 changed files with 921 additions and 2 deletions

View File

@ -30,7 +30,7 @@ bool SDLControllerInterface::Initialize(CommonHostInterface* host_interface)
FrontendCommon::EnsureSDLInitialized();
const std::string gcdb_file_name = GetGameControllerDBFileName();
if (FileSystem::FileExists(gcdb_file_name.c_str()))
if (!gcdb_file_name.empty())
{
Log_InfoPrintf("Loading game controller mappings from '%s'", gcdb_file_name.c_str());
if (SDL_GameControllerAddMappingsFromFile(gcdb_file_name.c_str()) < 0)
@ -66,7 +66,17 @@ void SDLControllerInterface::Shutdown()
std::string SDLControllerInterface::GetGameControllerDBFileName() const
{
return m_host_interface->GetUserDirectoryRelativePath("gamecontrollerdb.txt");
// prefer the userdir copy
std::string filename(m_host_interface->GetUserDirectoryRelativePath("gamecontrollerdb.txt"));
if (FileSystem::FileExists(filename.c_str()))
return filename;
filename =
m_host_interface->GetProgramDirectoryRelativePath("database" FS_OSPATH_SEPARATOR_STR "gamecontrollerdb.txt");
if (FileSystem::FileExists(filename.c_str()))
return filename;
return {};
}
void SDLControllerInterface::PollEvents()