diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.kt index e84dd201a5..4b2c6ec92c 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.kt @@ -30,7 +30,11 @@ class EmulatedController private constructor(private val pointer: Long) { external fun saveProfile(path: String) - external fun getProfileName(): String + external fun getProfileKey(): String + + external fun getUserProfileDirectoryPath(): String + + external fun getSysProfileDirectoryPath(): String companion object { @JvmStatic diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileDialogPresenter.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileDialogPresenter.kt index 2896c815fe..5c0a50a8b8 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileDialogPresenter.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/ui/ProfileDialogPresenter.kt @@ -101,11 +101,11 @@ class ProfileDialogPresenter { } private fun getProfileDirectoryPath(stock: Boolean): String { - val profileDirectoryName = menuTag.correspondingEmulatedController.getProfileName() + val controller = menuTag.correspondingEmulatedController return if (stock) { - "${DirectoryInitialization.getSysDirectory()}/Profiles/$profileDirectoryName/" + controller.getSysProfileDirectoryPath() } else { - "${DirectoryInitialization.getUserDirectory()}/Config/Profiles/$profileDirectoryName/" + controller.getUserProfileDirectoryPath() } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt index 1051f445ae..44e2b2b915 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/ui/SettingsFragmentPresenter.kt @@ -2237,7 +2237,7 @@ class SettingsFragmentPresenter( controllerNumber: Int ) { val profiles = ProfileDialogPresenter(menuTag).getProfileNames(false) - val profileKey = controller.getProfileName() + "Profile" + (controllerNumber + 1) + val profileKey = controller.getProfileKey() + "Profile" + (controllerNumber + 1) sl.add( StringSingleChoiceSetting( context, diff --git a/Source/Android/jni/Input/EmulatedController.cpp b/Source/Android/jni/Input/EmulatedController.cpp index c1dfd7ce5d..8a76240dfd 100644 --- a/Source/Android/jni/Input/EmulatedController.cpp +++ b/Source/Android/jni/Input/EmulatedController.cpp @@ -126,10 +126,26 @@ Java_org_dolphinemu_dolphinemu_features_input_model_controlleremu_EmulatedContro } 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) { - 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 diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp index 8413db981d..6c815e4a15 100644 --- a/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/MappingWindow.cpp @@ -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); diff --git a/Source/Core/InputCommon/InputConfig.cpp b/Source/Core/InputCommon/InputConfig.cpp index 0acd67c392..651e2821c2 100644 --- a/Source/Core/InputCommon/InputConfig.cpp +++ b/Source/Core/InputCommon/InputConfig.cpp @@ -20,8 +20,8 @@ #include "InputCommon/InputProfile.h" InputConfig::InputConfig(const std::string& ini_name, const std::string& gui_name, - const std::string& profile_name, InputClass input_class) - : m_ini_name(ini_name), m_gui_name(gui_name), m_profile_name(profile_name), + const std::string& profile_directory_name, InputClass input_class) + : m_ini_name(ini_name), m_gui_name(gui_name), m_profile_directory_name(profile_directory_name), m_input_class(input_class) { } @@ -39,7 +39,7 @@ bool InputConfig::LoadConfig() if (SConfig::GetInstance().GetGameID() != "00000000") { - const std::string profile_directory = GetProfileDirectoryPath(); + const std::string profile_directory = GetUserProfileDirectoryPath(); Common::IniFile game_ini = SConfig::GetInstance().LoadGameIni(); auto* control_section = game_ini.GetOrCreateSection("Controls"); @@ -173,25 +173,16 @@ std::string InputConfig::GetProfileKey() const } } -std::string InputConfig::GetProfileDirectoryName() 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 +std::string InputConfig::GetUserProfileDirectoryPath() const { 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 { return static_cast(m_controllers.size()); diff --git a/Source/Core/InputCommon/InputConfig.h b/Source/Core/InputCommon/InputConfig.h index 85be1ad505..ff8c4be65d 100644 --- a/Source/Core/InputCommon/InputConfig.h +++ b/Source/Core/InputCommon/InputConfig.h @@ -32,7 +32,7 @@ public: }; 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(); @@ -51,10 +51,10 @@ public: bool IsControllerControlledByGamepadDevice(int index) const; std::string GetGUIName() const { return m_gui_name; } - std::string GetProfileName() const { return m_profile_name; } std::string GetProfileKey() const; - std::string GetProfileDirectoryName() const; - std::string GetProfileDirectoryPath() const; + std::string GetProfileDirectoryName() const { return m_profile_directory_name; } + std::string GetUserProfileDirectoryPath() const; + std::string GetSysProfileDirectoryPath() const; int GetControllerCount() const; // These should be used after creating all controllers and before clearing them, respectively. @@ -68,7 +68,7 @@ private: std::vector> m_controllers; const std::string m_ini_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; InputCommon::DynamicInputTextureManager m_dynamic_input_tex_config_manager; }; diff --git a/Source/Core/InputCommon/InputProfile.cpp b/Source/Core/InputCommon/InputProfile.cpp index 81d04cf75a..0d439c48e1 100644 --- a/Source/Core/InputCommon/InputProfile.cpp +++ b/Source/Core/InputCommon/InputProfile.cpp @@ -55,8 +55,8 @@ std::vector GetProfilesFromSetting(const std::string& setting, cons std::vector ProfileCycler::GetProfilesForDevice(InputConfig* device_configuration) { - const std::string device_profile_root_location(File::GetUserPath(D_CONFIG_IDX) + "Profiles/" + - device_configuration->GetProfileName()); + const std::string device_profile_root_location( + device_configuration->GetUserProfileDirectoryPath()); return Common::DoFileSearch({device_profile_root_location}, {".ini"}, true); } @@ -101,8 +101,8 @@ ProfileCycler::GetMatchingProfilesFromSetting(const std::string& setting, const std::vector& profiles, InputConfig* device_configuration) { - const std::string device_profile_root_location(File::GetUserPath(D_CONFIG_IDX) + "Profiles/" + - device_configuration->GetProfileName() + "/"); + const std::string device_profile_root_location( + device_configuration->GetUserProfileDirectoryPath()); const auto& profiles_from_setting = GetProfilesFromSetting(setting, device_profile_root_location); if (profiles_from_setting.empty())