mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 23:59:27 +01:00
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:
parent
2bcf70af3f
commit
6cf55ab1ee
@ -30,7 +30,11 @@ class EmulatedController private constructor(private val pointer: Long) {
|
|||||||
|
|
||||||
external fun saveProfile(path: String)
|
external fun saveProfile(path: String)
|
||||||
|
|
||||||
external fun getProfileName(): String
|
external fun getProfileKey(): String
|
||||||
|
|
||||||
|
external fun getUserProfileDirectoryPath(): String
|
||||||
|
|
||||||
|
external fun getSysProfileDirectoryPath(): String
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
|
@ -101,11 +101,11 @@ class ProfileDialogPresenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getProfileDirectoryPath(stock: Boolean): String {
|
private fun getProfileDirectoryPath(stock: Boolean): String {
|
||||||
val profileDirectoryName = menuTag.correspondingEmulatedController.getProfileName()
|
val controller = menuTag.correspondingEmulatedController
|
||||||
return if (stock) {
|
return if (stock) {
|
||||||
"${DirectoryInitialization.getSysDirectory()}/Profiles/$profileDirectoryName/"
|
controller.getSysProfileDirectoryPath()
|
||||||
} else {
|
} else {
|
||||||
"${DirectoryInitialization.getUserDirectory()}/Config/Profiles/$profileDirectoryName/"
|
controller.getUserProfileDirectoryPath()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2237,7 +2237,7 @@ class SettingsFragmentPresenter(
|
|||||||
controllerNumber: Int
|
controllerNumber: Int
|
||||||
) {
|
) {
|
||||||
val profiles = ProfileDialogPresenter(menuTag).getProfileNames(false)
|
val profiles = ProfileDialogPresenter(menuTag).getProfileNames(false)
|
||||||
val profileKey = controller.getProfileName() + "Profile" + (controllerNumber + 1)
|
val profileKey = controller.getProfileKey() + "Profile" + (controllerNumber + 1)
|
||||||
sl.add(
|
sl.add(
|
||||||
StringSingleChoiceSetting(
|
StringSingleChoiceSetting(
|
||||||
context,
|
context,
|
||||||
|
@ -126,10 +126,26 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getProfileName(
|
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getProfileKey(
|
||||||
JNIEnv* env, jobject obj)
|
JNIEnv* env, jobject obj)
|
||||||
{
|
{
|
||||||
return ToJString(env, EmulatedControllerFromJava(env, obj)->GetConfig()->GetProfileName());
|
return ToJString(env, EmulatedControllerFromJava(env, obj)->GetConfig()->GetProfileKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL
|
||||||
|
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getUserProfileDirectoryPath(
|
||||||
|
JNIEnv* env, jobject obj)
|
||||||
|
{
|
||||||
|
return ToJString(
|
||||||
|
env, EmulatedControllerFromJava(env, obj)->GetConfig()->GetUserProfileDirectoryPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL
|
||||||
|
Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedController_getSysProfileDirectoryPath(
|
||||||
|
JNIEnv* env, jobject obj)
|
||||||
|
{
|
||||||
|
return ToJString(env,
|
||||||
|
EmulatedControllerFromJava(env, obj)->GetConfig()->GetSysProfileDirectoryPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jobject JNICALL
|
JNIEXPORT jobject JNICALL
|
||||||
|
@ -319,9 +319,8 @@ void MappingWindow::OnSaveProfilePressed()
|
|||||||
if (profile_name.isEmpty())
|
if (profile_name.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const std::string profile_path = File::GetUserPath(D_CONFIG_IDX) + PROFILES_DIR +
|
const std::string profile_path =
|
||||||
m_config->GetProfileName() + "/" + profile_name.toStdString() +
|
m_config->GetUserProfileDirectoryPath() + profile_name.toStdString() + ".ini";
|
||||||
".ini";
|
|
||||||
|
|
||||||
File::CreateFullPath(profile_path);
|
File::CreateFullPath(profile_path);
|
||||||
|
|
||||||
@ -487,8 +486,7 @@ void MappingWindow::PopulateProfileSelection()
|
|||||||
{
|
{
|
||||||
m_profiles_combo->clear();
|
m_profiles_combo->clear();
|
||||||
|
|
||||||
const std::string profiles_path =
|
const std::string profiles_path = m_config->GetUserProfileDirectoryPath();
|
||||||
File::GetUserPath(D_CONFIG_IDX) + PROFILES_DIR + m_config->GetProfileName();
|
|
||||||
for (const auto& filename : Common::DoFileSearch({profiles_path}, {".ini"}))
|
for (const auto& filename : Common::DoFileSearch({profiles_path}, {".ini"}))
|
||||||
{
|
{
|
||||||
std::string basename;
|
std::string basename;
|
||||||
@ -499,9 +497,8 @@ void MappingWindow::PopulateProfileSelection()
|
|||||||
|
|
||||||
m_profiles_combo->insertSeparator(m_profiles_combo->count());
|
m_profiles_combo->insertSeparator(m_profiles_combo->count());
|
||||||
|
|
||||||
const std::string builtin_profiles_path =
|
for (const auto& filename :
|
||||||
File::GetSysDirectory() + PROFILES_DIR + m_config->GetProfileName();
|
Common::DoFileSearch({m_config->GetSysProfileDirectoryPath()}, {".ini"}))
|
||||||
for (const auto& filename : Common::DoFileSearch({builtin_profiles_path}, {".ini"}))
|
|
||||||
{
|
{
|
||||||
std::string basename;
|
std::string basename;
|
||||||
SplitPath(filename, nullptr, &basename, nullptr);
|
SplitPath(filename, nullptr, &basename, nullptr);
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
#include "InputCommon/InputProfile.h"
|
#include "InputCommon/InputProfile.h"
|
||||||
|
|
||||||
InputConfig::InputConfig(const std::string& ini_name, const std::string& gui_name,
|
InputConfig::InputConfig(const std::string& ini_name, const std::string& gui_name,
|
||||||
const std::string& profile_name, InputClass input_class)
|
const std::string& profile_directory_name, InputClass input_class)
|
||||||
: m_ini_name(ini_name), m_gui_name(gui_name), m_profile_name(profile_name),
|
: m_ini_name(ini_name), m_gui_name(gui_name), m_profile_directory_name(profile_directory_name),
|
||||||
m_input_class(input_class)
|
m_input_class(input_class)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ bool InputConfig::LoadConfig()
|
|||||||
|
|
||||||
if (SConfig::GetInstance().GetGameID() != "00000000")
|
if (SConfig::GetInstance().GetGameID() != "00000000")
|
||||||
{
|
{
|
||||||
const std::string profile_directory = GetProfileDirectoryPath();
|
const std::string profile_directory = GetUserProfileDirectoryPath();
|
||||||
|
|
||||||
Common::IniFile game_ini = SConfig::GetInstance().LoadGameIni();
|
Common::IniFile game_ini = SConfig::GetInstance().LoadGameIni();
|
||||||
auto* control_section = game_ini.GetOrCreateSection("Controls");
|
auto* control_section = game_ini.GetOrCreateSection("Controls");
|
||||||
@ -173,25 +173,16 @@ std::string InputConfig::GetProfileKey() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string InputConfig::GetProfileDirectoryName() const
|
std::string InputConfig::GetUserProfileDirectoryPath() const
|
||||||
{
|
|
||||||
switch (m_input_class)
|
|
||||||
{
|
|
||||||
case InputClass::GBA:
|
|
||||||
return "GBA";
|
|
||||||
case InputClass::Wii:
|
|
||||||
return "Wiimote";
|
|
||||||
case InputClass::GC:
|
|
||||||
default:
|
|
||||||
return "GCPad";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string InputConfig::GetProfileDirectoryPath() const
|
|
||||||
{
|
{
|
||||||
return fmt::format("{}Profiles/{}/", File::GetUserPath(D_CONFIG_IDX), GetProfileDirectoryName());
|
return fmt::format("{}Profiles/{}/", File::GetUserPath(D_CONFIG_IDX), GetProfileDirectoryName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string InputConfig::GetSysProfileDirectoryPath() const
|
||||||
|
{
|
||||||
|
return fmt::format("{}Profiles/{}/", File::GetSysDirectory(), GetProfileDirectoryName());
|
||||||
|
}
|
||||||
|
|
||||||
int InputConfig::GetControllerCount() const
|
int InputConfig::GetControllerCount() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(m_controllers.size());
|
return static_cast<int>(m_controllers.size());
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
InputConfig(const std::string& ini_name, const std::string& gui_name,
|
InputConfig(const std::string& ini_name, const std::string& gui_name,
|
||||||
const std::string& profile_name, InputClass input_class);
|
const std::string& profile_directory_name, InputClass input_class);
|
||||||
|
|
||||||
~InputConfig();
|
~InputConfig();
|
||||||
|
|
||||||
@ -51,10 +51,10 @@ public:
|
|||||||
bool IsControllerControlledByGamepadDevice(int index) const;
|
bool IsControllerControlledByGamepadDevice(int index) const;
|
||||||
|
|
||||||
std::string GetGUIName() const { return m_gui_name; }
|
std::string GetGUIName() const { return m_gui_name; }
|
||||||
std::string GetProfileName() const { return m_profile_name; }
|
|
||||||
std::string GetProfileKey() const;
|
std::string GetProfileKey() const;
|
||||||
std::string GetProfileDirectoryName() const;
|
std::string GetProfileDirectoryName() const { return m_profile_directory_name; }
|
||||||
std::string GetProfileDirectoryPath() const;
|
std::string GetUserProfileDirectoryPath() const;
|
||||||
|
std::string GetSysProfileDirectoryPath() const;
|
||||||
int GetControllerCount() const;
|
int GetControllerCount() const;
|
||||||
|
|
||||||
// These should be used after creating all controllers and before clearing them, respectively.
|
// These should be used after creating all controllers and before clearing them, respectively.
|
||||||
@ -68,7 +68,7 @@ private:
|
|||||||
std::vector<std::unique_ptr<ControllerEmu::EmulatedController>> m_controllers;
|
std::vector<std::unique_ptr<ControllerEmu::EmulatedController>> m_controllers;
|
||||||
const std::string m_ini_name;
|
const std::string m_ini_name;
|
||||||
const std::string m_gui_name;
|
const std::string m_gui_name;
|
||||||
const std::string m_profile_name;
|
const std::string m_profile_directory_name;
|
||||||
const InputClass m_input_class;
|
const InputClass m_input_class;
|
||||||
InputCommon::DynamicInputTextureManager m_dynamic_input_tex_config_manager;
|
InputCommon::DynamicInputTextureManager m_dynamic_input_tex_config_manager;
|
||||||
};
|
};
|
||||||
|
@ -55,8 +55,8 @@ std::vector<std::string> GetProfilesFromSetting(const std::string& setting, cons
|
|||||||
|
|
||||||
std::vector<std::string> ProfileCycler::GetProfilesForDevice(InputConfig* device_configuration)
|
std::vector<std::string> ProfileCycler::GetProfilesForDevice(InputConfig* device_configuration)
|
||||||
{
|
{
|
||||||
const std::string device_profile_root_location(File::GetUserPath(D_CONFIG_IDX) + "Profiles/" +
|
const std::string device_profile_root_location(
|
||||||
device_configuration->GetProfileName());
|
device_configuration->GetUserProfileDirectoryPath());
|
||||||
return Common::DoFileSearch({device_profile_root_location}, {".ini"}, true);
|
return Common::DoFileSearch({device_profile_root_location}, {".ini"}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,8 +101,8 @@ ProfileCycler::GetMatchingProfilesFromSetting(const std::string& setting,
|
|||||||
const std::vector<std::string>& profiles,
|
const std::vector<std::string>& profiles,
|
||||||
InputConfig* device_configuration)
|
InputConfig* device_configuration)
|
||||||
{
|
{
|
||||||
const std::string device_profile_root_location(File::GetUserPath(D_CONFIG_IDX) + "Profiles/" +
|
const std::string device_profile_root_location(
|
||||||
device_configuration->GetProfileName() + "/");
|
device_configuration->GetUserProfileDirectoryPath());
|
||||||
|
|
||||||
const auto& profiles_from_setting = GetProfilesFromSetting(setting, device_profile_root_location);
|
const auto& profiles_from_setting = GetProfilesFromSetting(setting, device_profile_root_location);
|
||||||
if (profiles_from_setting.empty())
|
if (profiles_from_setting.empty())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user