From 1315b54ffaa2833ddda7e543945c88ed5396efd6 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 4 Feb 2024 17:36:15 +0100 Subject: [PATCH] InputCommon: Use distinct values for profile key Because the last commit made us use separate folders for GCPad and GCKey profiles, we should also use separate game INI keys for them. Otherwise setting e.g. PadProfile1 in a game INI will make both GCPad and GCKey try to load it, typically with one of them succeeding and the other one showing a panic alert due to the profile not existing in its folder. Better do this breaking change for GCKeys in the same PR as the other breaking change rather than later. --- Source/Core/Core/FreeLookManager.cpp | 2 +- Source/Core/Core/HW/GBAPad.cpp | 2 +- Source/Core/Core/HW/GCKeyboard.cpp | 2 +- Source/Core/Core/HW/GCPad.cpp | 2 +- Source/Core/Core/HW/Wiimote.cpp | 3 +-- Source/Core/Core/HotkeyManager.cpp | 2 +- Source/Core/InputCommon/InputConfig.cpp | 18 ++---------------- Source/Core/InputCommon/InputConfig.h | 13 +++---------- 8 files changed, 11 insertions(+), 33 deletions(-) diff --git a/Source/Core/Core/FreeLookManager.cpp b/Source/Core/Core/FreeLookManager.cpp index fd996bdab9..d69c3cec13 100644 --- a/Source/Core/Core/FreeLookManager.cpp +++ b/Source/Core/Core/FreeLookManager.cpp @@ -313,7 +313,7 @@ void FreeLookController::UpdateInput(CameraControllerInput* camera_controller) namespace FreeLook { static InputConfig s_config("FreeLookController", _trans("FreeLook"), "FreeLookController", - InputConfig::InputClass::GC); + "FreeLookController"); InputConfig* GetInputConfig() { return &s_config; diff --git a/Source/Core/Core/HW/GBAPad.cpp b/Source/Core/Core/HW/GBAPad.cpp index 04d68c4260..77585a27f0 100644 --- a/Source/Core/Core/HW/GBAPad.cpp +++ b/Source/Core/Core/HW/GBAPad.cpp @@ -10,7 +10,7 @@ namespace Pad { -static InputConfig s_config("GBA", _trans("Pad"), "GBA", InputConfig::InputClass::GBA); +static InputConfig s_config("GBA", _trans("Pad"), "GBA", "GBA"); InputConfig* GetGBAConfig() { return &s_config; diff --git a/Source/Core/Core/HW/GCKeyboard.cpp b/Source/Core/Core/HW/GCKeyboard.cpp index 897d2d6850..4af090de70 100644 --- a/Source/Core/Core/HW/GCKeyboard.cpp +++ b/Source/Core/Core/HW/GCKeyboard.cpp @@ -17,7 +17,7 @@ namespace Keyboard { -static InputConfig s_config("GCKeyNew", _trans("Keyboard"), "GCKey", InputConfig::InputClass::GC); +static InputConfig s_config("GCKeyNew", _trans("Keyboard"), "GCKey", "GCKey"); InputConfig* GetConfig() { return &s_config; diff --git a/Source/Core/Core/HW/GCPad.cpp b/Source/Core/Core/HW/GCPad.cpp index cddb085be8..5450eea0c4 100644 --- a/Source/Core/Core/HW/GCPad.cpp +++ b/Source/Core/Core/HW/GCPad.cpp @@ -14,7 +14,7 @@ namespace Pad { -static InputConfig s_config("GCPadNew", _trans("Pad"), "GCPad", InputConfig::InputClass::GC); +static InputConfig s_config("GCPadNew", _trans("Pad"), "GCPad", "Pad"); InputConfig* GetConfig() { return &s_config; diff --git a/Source/Core/Core/HW/Wiimote.cpp b/Source/Core/Core/HW/Wiimote.cpp index 0638ab788b..2fa2270635 100644 --- a/Source/Core/Core/HW/Wiimote.cpp +++ b/Source/Core/Core/HW/Wiimote.cpp @@ -97,8 +97,7 @@ HIDWiimote* GetHIDWiimoteSource(unsigned int index) namespace Wiimote { -static InputConfig s_config(WIIMOTE_INI_NAME, _trans("Wii Remote"), "Wiimote", - InputConfig::InputClass::Wii); +static InputConfig s_config(WIIMOTE_INI_NAME, _trans("Wii Remote"), "Wiimote", "Wiimote"); InputConfig* GetConfig() { diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index 45e1c4dd9a..83b0c31616 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -207,7 +207,7 @@ static std::array s_hotkey_down; static HotkeyStatus s_hotkey; static bool s_enabled; -static InputConfig s_config("Hotkeys", _trans("Hotkeys"), "Hotkeys", InputConfig::InputClass::GC); +static InputConfig s_config("Hotkeys", _trans("Hotkeys"), "Hotkeys", "Hotkeys"); InputConfig* GetConfig() { diff --git a/Source/Core/InputCommon/InputConfig.cpp b/Source/Core/InputCommon/InputConfig.cpp index 651e2821c2..ff3f68acd0 100644 --- a/Source/Core/InputCommon/InputConfig.cpp +++ b/Source/Core/InputCommon/InputConfig.cpp @@ -20,9 +20,9 @@ #include "InputCommon/InputProfile.h" InputConfig::InputConfig(const std::string& ini_name, const std::string& gui_name, - const std::string& profile_directory_name, InputClass input_class) + const std::string& profile_directory_name, const std::string& profile_key) : m_ini_name(ini_name), m_gui_name(gui_name), m_profile_directory_name(profile_directory_name), - m_input_class(input_class) + m_profile_key(profile_key) { } @@ -159,20 +159,6 @@ bool InputConfig::ControllersNeedToBeCreated() const return m_controllers.empty(); } -std::string InputConfig::GetProfileKey() const -{ - switch (m_input_class) - { - case InputClass::GBA: - return "GBA"; - case InputClass::Wii: - return "Wiimote"; - case InputClass::GC: - default: - return "Pad"; - } -} - std::string InputConfig::GetUserProfileDirectoryPath() const { return fmt::format("{}Profiles/{}/", File::GetUserPath(D_CONFIG_IDX), GetProfileDirectoryName()); diff --git a/Source/Core/InputCommon/InputConfig.h b/Source/Core/InputCommon/InputConfig.h index ff8c4be65d..09b9f6c182 100644 --- a/Source/Core/InputCommon/InputConfig.h +++ b/Source/Core/InputCommon/InputConfig.h @@ -24,15 +24,8 @@ class EmulatedController; class InputConfig { public: - enum class InputClass - { - GC, - Wii, - GBA, - }; - InputConfig(const std::string& ini_name, const std::string& gui_name, - const std::string& profile_directory_name, InputClass input_class); + const std::string& profile_directory_name, const std::string& profile_key); ~InputConfig(); @@ -51,7 +44,7 @@ public: bool IsControllerControlledByGamepadDevice(int index) const; std::string GetGUIName() const { return m_gui_name; } - std::string GetProfileKey() const; + std::string GetProfileKey() const { return m_profile_key; } std::string GetProfileDirectoryName() const { return m_profile_directory_name; } std::string GetUserProfileDirectoryPath() const; std::string GetSysProfileDirectoryPath() const; @@ -69,6 +62,6 @@ private: const std::string m_ini_name; const std::string m_gui_name; const std::string m_profile_directory_name; - const InputClass m_input_class; + const std::string m_profile_key; InputCommon::DynamicInputTextureManager m_dynamic_input_tex_config_manager; };