HostInterface: Support per-controller-type settings

This commit is contained in:
Connor McLaughlin
2020-07-01 00:33:45 +10:00
parent f3b2953e40
commit 4dc9e10777
17 changed files with 247 additions and 7 deletions

View File

@ -480,6 +480,9 @@ void HostInterface::CheckForSettingsChanges(const Settings& old_settings)
OnControllerTypeChanged(i);
}
if (m_system && !controllers_updated)
m_system->UpdateControllerSettings();
}
if (m_display && m_settings.display_linear_filtering != old_settings.display_linear_filtering)
@ -566,6 +569,36 @@ std::string HostInterface::GetGameMemoryCardPath(const char* game_code, u32 slot
return GetUserDirectoryRelativePath("memcards/%s_%d.mcd", game_code, slot + 1);
}
bool HostInterface::GetBooleanSettingValue(const char* section, const char* key, bool default_value /*= false*/)
{
std::string value = GetSettingValue(section, key, "");
if (value.empty())
return default_value;
std::optional<bool> bool_value = StringUtil::FromChars<bool>(value);
return bool_value.value_or(default_value);
}
bool HostInterface::GetIntegerSettingValue(const char* section, const char* key, s32 default_value /*= 0*/)
{
std::string value = GetSettingValue(section, key, "");
if (value.empty())
return default_value;
std::optional<s32> int_value = StringUtil::FromChars<s32>(value);
return int_value.value_or(default_value);
}
bool HostInterface::GetFloatSettingValue(const char* section, const char* key, float default_value /*= 0.0f*/)
{
std::string value = GetSettingValue(section, key, "");
if (value.empty())
return default_value;
std::optional<float> float_value = StringUtil::FromChars<float>(value);
return float_value.value_or(default_value);
}
void HostInterface::ToggleSoftwareRendering()
{
if (!m_system || m_settings.gpu_renderer == GPURenderer::Software)