Skip to content

Commit

Permalink
InputCommon: Use distinct values for profile key
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JosJuice committed Feb 4, 2024
1 parent 6cf55ab commit 1315b54
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/FreeLookManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/GBAPad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/GCKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/GCPad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Core/HW/Wiimote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HotkeyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static std::array<u32, NUM_HOTKEY_GROUPS> 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()
{
Expand Down
18 changes: 2 additions & 16 deletions Source/Core/InputCommon/InputConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down Expand Up @@ -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());
Expand Down
13 changes: 3 additions & 10 deletions Source/Core/InputCommon/InputConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -51,7 +44,7 @@ class InputConfig
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;
Expand All @@ -69,6 +62,6 @@ class InputConfig
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;
};

0 comments on commit 1315b54

Please sign in to comment.