InputCommon: Unify GetProfileName and GetProfileDirectoryName

After reading the previous commit, you might think "hold on, what's the
difference between GetProfileName and GetProfileDirectoryName"? These
two are being used for the exact same thing - figuring out where
profiles are stored - yet they return different values for certain
controllers like GC keyboards! As far as I can tell, the existing code
has been broken for GC keyboards since they were introduced a decade
ago. The GUI (and more recently, also InputCycler) would write and read
profiles in one location, and our code for loading profiles specified in
a game INI file would read profiles in another location.

This commit gets rid of the set of values used by the game INI code in
favor of the other set. This does breaking existing setups where a
GCKey profile has been configured in a game INI, but I think the number
of working such setups is vanishingly small. The alternative would make
existing GCKey profiles go missing from the profile dropdown in the GUI,
which I think would be more disruptive. The alternative would also force
new GCKey profiles into the same directory as GCPad profiles.

This commit also fixes a regression from d6c0f8e749. The Android GUI was
using GetProfileName to figure out what key to use in the game INI,
which made it use incorrect game INI entries for GameCube controller
profiles but not Wii Remote profiles. Now the Android GUI uses
GetProfileKey for this, fixing the problem.
This commit is contained in:
JosJuice
2024-02-04 16:31:15 +01:00
parent 2bcf70af3f
commit 6cf55ab1ee
8 changed files with 50 additions and 42 deletions

View File

@ -319,9 +319,8 @@ void MappingWindow::OnSaveProfilePressed()
if (profile_name.isEmpty())
return;
const std::string profile_path = File::GetUserPath(D_CONFIG_IDX) + PROFILES_DIR +
m_config->GetProfileName() + "/" + profile_name.toStdString() +
".ini";
const std::string profile_path =
m_config->GetUserProfileDirectoryPath() + profile_name.toStdString() + ".ini";
File::CreateFullPath(profile_path);
@ -487,8 +486,7 @@ void MappingWindow::PopulateProfileSelection()
{
m_profiles_combo->clear();
const std::string profiles_path =
File::GetUserPath(D_CONFIG_IDX) + PROFILES_DIR + m_config->GetProfileName();
const std::string profiles_path = m_config->GetUserProfileDirectoryPath();
for (const auto& filename : Common::DoFileSearch({profiles_path}, {".ini"}))
{
std::string basename;
@ -499,9 +497,8 @@ void MappingWindow::PopulateProfileSelection()
m_profiles_combo->insertSeparator(m_profiles_combo->count());
const std::string builtin_profiles_path =
File::GetSysDirectory() + PROFILES_DIR + m_config->GetProfileName();
for (const auto& filename : Common::DoFileSearch({builtin_profiles_path}, {".ini"}))
for (const auto& filename :
Common::DoFileSearch({m_config->GetSysProfileDirectoryPath()}, {".ini"}))
{
std::string basename;
SplitPath(filename, nullptr, &basename, nullptr);