USB: Add ConfigKeyExists()

This commit is contained in:
Stenzek 2023-07-23 15:08:15 +10:00 committed by Connor McLaughlin
parent 24171787f8
commit 2703b91e41
3 changed files with 10 additions and 1 deletions

View File

@ -155,7 +155,7 @@ bool LayeredSettingsInterface::ContainsValue(const char* section, const char* ke
{
if (SettingsInterface* sif = m_layers[layer])
{
if (sif->ContainsValue(key, section))
if (sif->ContainsValue(section, key))
return true;
}
}

View File

@ -671,6 +671,12 @@ std::string USB::GetConfigSubKey(const std::string_view& device, const std::stri
return fmt::format("{}_{}", device, bind_name);
}
bool USB::ConfigKeyExists(SettingsInterface& si, u32 port, const char* devname, const char* key)
{
const std::string real_key(fmt::format("{}_{}", devname, key));
return si.ContainsValue(GetConfigSection(port).c_str(), real_key.c_str());
}
bool USB::GetConfigBool(SettingsInterface& si, u32 port, const char* devname, const char* key, bool default_value)
{
const std::string real_key(fmt::format("{}_{}", devname, key));

View File

@ -79,6 +79,9 @@ namespace USB
/// Identifies any device/subtype changes and recreates devices.
void CheckForConfigChanges(const Pcsx2Config& old_config);
/// Returns true if a device-specific configuration key exists.
bool ConfigKeyExists(SettingsInterface& si, u32 port, const char* devname, const char* key);
/// Reads a device-specific configuration boolean.
bool GetConfigBool(SettingsInterface& si, u32 port, const char* devname, const char* key, bool default_value);