mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Merge pull request #13702 from CostPerUnit/master
MappingWidget: Add Advanced Configuration Button to Point And Point Passthrough "Enable" boxes
This commit is contained in:
@ -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
|
||||
|
@ -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;
|
||||
const DefaultValue default_value;
|
||||
|
||||
bool enabled = true;
|
||||
// The default "enabled" state.
|
||||
const DefaultValue default_value;
|
||||
SettingValue<bool> enabled;
|
||||
std::unique_ptr<NumericSetting<bool>> enabled_setting;
|
||||
|
||||
std::vector<std::unique_ptr<Control>> controls;
|
||||
std::vector<std::unique_ptr<NumericSettingBase>> numeric_settings;
|
||||
};
|
||||
|
Reference in New Issue
Block a user