summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerEmu
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2025-06-09 00:09:35 -0400
committerGitHub <noreply@github.com>2025-06-09 00:09:35 -0400
commit42d5f2b7056b3d3fb8be8320003ad836bb003fae (patch)
treedfc52a4c6e13d668c05af725e1e1ba8384888f8b /Source/Core/InputCommon/ControllerEmu
parent5064b615ba74573206008973ca9281ff0d33dd04 (diff)
parenta8eafa4ccd4fa60d1e4bd2843a00354eec8967f1 (diff)
Merge pull request #13702 from CostPerUnit/master
MappingWidget: Add Advanced Configuration Button to Point And Point Passthrough "Enable" boxes
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu')
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp26
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h10
2 files changed, 29 insertions, 7 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
index 93367649f9..b619ae1b08 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp
@@ -13,8 +13,9 @@
namespace ControllerEmu
{
-ControlGroup::ControlGroup(std::string name_, const GroupType type_, DefaultValue default_value_)
- : name(name_), ui_name(std::move(name_)), type(type_), default_value(default_value_)
+ControlGroup::ControlGroup(const std::string& name_, const GroupType type_,
+ DefaultValue default_value_)
+ : ControlGroup{name_, name_, type_, default_value_}
{
}
@@ -23,6 +24,12 @@ ControlGroup::ControlGroup(std::string name_, std::string ui_name_, const GroupT
: name(std::move(name_)), ui_name(std::move(ui_name_)), type(type_),
default_value(default_value_)
{
+ if (default_value_ != DefaultValue::AlwaysEnabled)
+ {
+ enabled_setting = std::make_unique<NumericSetting<bool>>(
+ &enabled, NumericSettingDetails{_trans("Enabled")},
+ (default_value_ == DefaultValue::Enabled), false, true);
+ }
}
void ControlGroup::AddVirtualNotchSetting(SettingValue<double>* value, double max_virtual_notch_deg)
@@ -53,8 +60,8 @@ void ControlGroup::LoadConfig(Common::IniFile::Section* sec, const std::string&
const std::string group(base + name + "/");
// enabled
- if (default_value != DefaultValue::AlwaysEnabled)
- sec->Get(group + "Enabled", &enabled, default_value != DefaultValue::Disabled);
+ if (HasEnabledSetting())
+ enabled_setting->LoadFromIni(*sec, group);
for (auto& setting : numeric_settings)
setting->LoadFromIni(*sec, group);
@@ -79,7 +86,8 @@ void ControlGroup::SaveConfig(Common::IniFile::Section* sec, const std::string&
const std::string group(base + name + "/");
// enabled
- sec->Set(group + "Enabled", enabled, default_value != DefaultValue::Disabled);
+ if (HasEnabledSetting())
+ enabled_setting->SaveToIni(*sec, group);
for (auto& setting : numeric_settings)
setting->SaveToIni(*sec, group);
@@ -99,6 +107,9 @@ void ControlGroup::SaveConfig(Common::IniFile::Section* sec, const std::string&
void ControlGroup::UpdateReferences(ciface::ExpressionParser::ControlEnvironment& env)
{
+ if (HasEnabledSetting())
+ enabled_setting->GetInputReference().UpdateReference(env);
+
for (auto& control : controls)
control->control_ref->UpdateReference(env);
@@ -126,4 +137,9 @@ void ControlGroup::AddOutput(Translatability translate, std::string name_)
controls.emplace_back(std::make_unique<Output>(translate, std::move(name_)));
}
+bool ControlGroup::HasEnabledSetting() const
+{
+ return enabled_setting != nullptr;
+}
+
} // namespace ControllerEmu
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h
index 7928fb61a9..c67b0ac132 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h
@@ -15,6 +15,7 @@
#include "Common/IniFile.h"
#include "InputCommon/ControllerEmu/Control/Control.h"
+#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
#include "InputCommon/ControllerInterface/CoreDevice.h"
namespace ControllerEmu
@@ -62,7 +63,7 @@ public:
Disabled,
};
- explicit ControlGroup(std::string name, GroupType type = GroupType::Other,
+ explicit ControlGroup(const std::string& name, GroupType type = GroupType::Other,
DefaultValue default_value = DefaultValue::AlwaysEnabled);
ControlGroup(std::string name, std::string ui_name, GroupType type = GroupType::Other,
DefaultValue default_value = DefaultValue::AlwaysEnabled);
@@ -98,12 +99,17 @@ public:
return std::copysign(std::max(T{0}, std::abs(input) - deadzone) / (T{1} - deadzone), input);
}
+ bool HasEnabledSetting() const;
+
const std::string name;
const std::string ui_name;
const GroupType type;
+
+ // The default "enabled" state.
const DefaultValue default_value;
+ SettingValue<bool> enabled;
+ std::unique_ptr<NumericSetting<bool>> enabled_setting;
- bool enabled = true;
std::vector<std::unique_ptr<Control>> controls;
std::vector<std::unique_ptr<NumericSettingBase>> numeric_settings;
};