InputManager: Fix SDL sub-options not copying to profile

This commit is contained in:
Stenzek 2025-01-10 20:42:17 +10:00
parent 7ac4a85765
commit ee33044f3d
No known key found for this signature in database
5 changed files with 32 additions and 3 deletions

View File

@ -267,4 +267,13 @@ public:
else
DeleteValue(section, key);
}
// NOTE: Writes values as strings.
ALWAYS_INLINE void CopySection(const SettingsInterface& si, const char* section)
{
ClearSection(section);
for (const auto& [key, value] : si.GetKeyValueList(section))
SetStringValue(section, key.c_str(), value.c_str());
}
};

View File

@ -1456,6 +1456,12 @@ void InputManager::CopyConfiguration(SettingsInterface* dest_si, const SettingsI
dest_si->CopyBoolValue(src_si, "InputSources",
InputManager::InputSourceToString(static_cast<InputSourceType>(type)));
}
#ifdef ENABLE_SDL
// I hate this, but there isn't a better location for it...
if (dest_si->GetBoolValue("InputSources", "SDL"))
InputSource::CopySDLSourceSettings(dest_si, src_si);
#endif
}
for (u32 port = 0; port < NUM_CONTROLLER_AND_CARD_PORTS; port++)

View File

@ -84,6 +84,7 @@ public:
#endif
#ifndef __ANDROID__
static std::unique_ptr<InputSource> CreateSDLSource();
static void CopySDLSourceSettings(SettingsInterface* dest_si, const SettingsInterface& src_si);
#else
static std::unique_ptr<InputSource> CreateAndroidSource();
#endif

View File

@ -248,11 +248,22 @@ void SDLInputSource::LoadSettings(const SettingsInterface& si)
#endif
}
void InputSource::CopySDLSourceSettings(SettingsInterface* dest_si, const SettingsInterface& src_si)
{
for (u32 i = 0; i < SDLInputSource::MAX_LED_COLORS; i++)
dest_si->CopyStringValue(src_si, "SDLExtra", TinyString::from_format("Player{}LED", i).c_str());
dest_si->CopyBoolValue(src_si, "InputSources", "SDLControllerEnhancedMode");
dest_si->CopyBoolValue(src_si, "InputSources", "SDLPS5PlayerLED");
dest_si->CopyBoolValue(src_si, "InputSources", "SDLTouchpadAsPointer");
dest_si->CopySection(src_si, "SDLHints");
}
u32 SDLInputSource::GetRGBForPlayerId(const SettingsInterface& si, u32 player_id)
{
return ParseRGBForPlayerId(
si.GetStringValue("SDLExtra", fmt::format("Player{}LED", player_id).c_str(), s_sdl_default_led_colors[player_id]),
player_id);
return ParseRGBForPlayerId(si.GetStringValue("SDLExtra", TinyString::from_format("Player{}LED", player_id).c_str(),
s_sdl_default_led_colors[player_id]),
player_id);
}
u32 SDLInputSource::ParseRGBForPlayerId(std::string_view str, u32 player_id)

View File

@ -50,6 +50,8 @@ public:
static bool IsHandledInputEvent(const SDL_Event* ev);
static void CopySettings(SettingsInterface& dest_si, const SettingsInterface& src_si);
static bool ALLOW_EVENT_POLLING;
private: