CommonHostInterface: Fix controller masking for Start Disc

This commit is contained in:
Connor McLaughlin 2021-05-13 03:22:28 +10:00
parent 301bbb4924
commit 172ba1fc32
3 changed files with 38 additions and 8 deletions

View file

@ -2926,16 +2926,14 @@ void CommonHostInterface::GetGameInfo(const char* path, CDImage* image, std::str
{
GameDatabase database;
GameDatabaseEntry database_entry;
if (database.Load() && database.GetEntryForDisc(image, &database_entry))
if (m_game_list->GetDatabaseEntryForDisc(image, &database_entry))
{
*code = std::move(database_entry.serial);
*title = std::move(database_entry.title);
return;
}
else
{
*code = System::GetGameCodeForImage(image, true);
}
*code = System::GetGameCodeForImage(image, true);
}
*title = FileSystem::GetFileTitleFromPath(path);
@ -3054,11 +3052,20 @@ void CommonHostInterface::ApplyGameSettings(bool display_osd_messages)
const GameListEntry* ge = m_game_list->GetEntryForPath(System::GetRunningPath().c_str());
if (ge)
{
ApplyControllerCompatibilitySettings(ge->supported_controllers, display_osd_messages);
ge->settings.ApplySettings(display_osd_messages);
}
else
{
GameDatabaseEntry db_entry;
if (m_game_list->GetDatabaseEntryForCode(System::GetRunningCode(), &db_entry))
ApplyControllerCompatibilitySettings(db_entry.supported_controllers_mask, display_osd_messages);
const GameSettings::Entry* gs = m_game_list->GetGameSettings(System::GetRunningPath(), System::GetRunningCode());
if (gs)
gs->ApplySettings(display_osd_messages);
const GameSettings::Entry* gs = m_game_list->GetGameSettingsForCode(System::GetRunningCode());
if (gs)
gs->ApplySettings(display_osd_messages);
}
}
void CommonHostInterface::ApplyRendererFromGameSettings(const std::string& boot_filename)

View file

@ -580,6 +580,18 @@ const GameListCompatibilityEntry* GameList::GetCompatibilityEntryForCode(const s
return (iter != m_compatibility_list.end()) ? &iter->second : nullptr;
}
bool GameList::GetDatabaseEntryForCode(const std::string_view& code, GameDatabaseEntry* entry)
{
LoadDatabase();
return m_database.GetEntryForCode(code, entry);
}
bool GameList::GetDatabaseEntryForDisc(CDImage* image, GameDatabaseEntry* entry)
{
LoadDatabase();
return m_database.GetEntryForDisc(image, entry);
}
void GameList::SetSearchDirectoriesFromSettings(SettingsInterface& si)
{
m_search_directories.clear();
@ -1012,6 +1024,14 @@ const GameSettings::Entry* GameList::GetGameSettings(const std::string& filename
return m_game_settings.GetEntry(game_code);
}
const GameSettings::Entry* GameList::GetGameSettingsForCode(const std::string& game_code)
{
if (!m_game_settings_load_tried)
LoadGameSettings();
return m_game_settings.GetEntry(game_code);
}
void GameList::UpdateGameSettings(const std::string& filename, const std::string& game_code,
const std::string& game_title, const GameSettings::Entry& new_entry,
bool save_to_list /* = true */)

View file

@ -102,6 +102,8 @@ public:
const GameListEntry* GetEntryForPath(const char* path) const;
const GameListCompatibilityEntry* GetCompatibilityEntryForCode(const std::string& code) const;
bool GetDatabaseEntryForCode(const std::string_view& code, GameDatabaseEntry* entry);
bool GetDatabaseEntryForDisc(CDImage* image, GameDatabaseEntry* entry);
void SetCacheFilename(std::string filename) { m_cache_filename = std::move(filename); }
void SetUserCompatibilityListFilename(std::string filename)
@ -119,6 +121,7 @@ public:
static std::string ExportCompatibilityEntry(const GameListCompatibilityEntry* entry);
const GameSettings::Entry* GetGameSettings(const std::string& filename, const std::string& game_code);
const GameSettings::Entry* GetGameSettingsForCode(const std::string& game_code);
void UpdateGameSettings(const std::string& filename, const std::string& game_code, const std::string& game_title,
const GameSettings::Entry& new_entry, bool save_to_list = true);