diff options
| author | Nick Michael <nickmichael@live.co.uk> | 2020-10-29 22:11:34 +0000 |
|---|---|---|
| committer | Nick Michael <nickmichael@live.co.uk> | 2020-11-03 22:06:27 +0000 |
| commit | 55dd3d73376746c4fc46df02d8266269a6e4537e (patch) | |
| tree | 80d468b458af58fa7597fef1b17f5281ee7edb59 /Source/Core/InputCommon/ControllerEmu/ControlGroup | |
| parent | ab8a128588b61f2651a567b42d298edb3052cefe (diff) | |
Virtual Notch settings and UI for octagonal stick
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup')
4 files changed, 24 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp index a0157eec8f..881be39471 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp @@ -65,6 +65,12 @@ OctagonAnalogStick::OctagonAnalogStick(const char* name_, const char* ui_name_, ControlState gate_radius) : AnalogStick(name_, ui_name_, std::make_unique<ControllerEmu::OctagonStickGate>(gate_radius)) { + AddVirtualNotchSetting(&m_virtual_notch_setting, 45); +} + +ControlState OctagonAnalogStick::GetVirtualNotchSize() const +{ + return m_virtual_notch_setting.GetValue() * MathUtil::TAU / 360; } } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.h index cafb1dad51..d13fd60a68 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.h +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.h @@ -33,6 +33,11 @@ class OctagonAnalogStick : public AnalogStick public: OctagonAnalogStick(const char* name, ControlState gate_radius); OctagonAnalogStick(const char* name, const char* ui_name, ControlState gate_radius); + + ControlState GetVirtualNotchSize() const override; + +private: + SettingValue<double> m_virtual_notch_setting; }; } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp index 70975937c9..ee33e32f0f 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.cpp @@ -28,6 +28,17 @@ ControlGroup::ControlGroup(std::string name_, std::string ui_name_, const GroupT { } +void ControlGroup::AddVirtualNotchSetting(SettingValue<double>* value, double max_virtual_notch_deg) +{ + AddSetting(value, + {_trans("Virtual Notches"), + // i18n: The degrees symbol. + _trans("°"), + // i18n: Snap the thumbstick position to the nearest octagonal axis. + _trans("Snap the thumbstick position to the nearest octagonal axis.")}, + 0, 0, max_virtual_notch_deg); +} + void ControlGroup::AddDeadzoneSetting(SettingValue<double>* value, double maximum_deadzone) { AddSetting(value, diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h index 46b8172d14..45c2367c10 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h @@ -82,6 +82,8 @@ public: std::make_unique<NumericSetting<T>>(value, details, default_value_, min_value, max_value)); } + void AddVirtualNotchSetting(SettingValue<double>* value, double max_virtual_notch_deg); + void AddDeadzoneSetting(SettingValue<double>* value, double maximum_deadzone); template <typename T> |
