summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerEmu/StickGate.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2019-04-09 19:30:26 -0400
committerGitHub <noreply@github.com>2019-04-09 19:30:26 -0400
commite10a472134fdf557ec35505eb5fb7c74ba9f2af7 (patch)
tree9593eb71abc3f724159693d46eb8504ede9529f0 /Source/Core/InputCommon/ControllerEmu/StickGate.cpp
parent0b8ac0a22f2fcebb7cbd00bbb36fd0c89191d34a (diff)
parent5efb717873691fa42447ca0d9d9810b5ad501b42 (diff)
Merge pull request #7936 from jordan-woyak/numeric-setting-cleanup
InputCommon: Clean up how numeric settings are handled.
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/StickGate.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerEmu/StickGate.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp
index 06abc4a64b..8e9d48467a 100644
--- a/Source/Core/InputCommon/ControllerEmu/StickGate.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/StickGate.cpp
@@ -100,13 +100,13 @@ std::optional<u32> SquareStickGate::GetIdealCalibrationSampleCount() const
ReshapableInput::ReshapableInput(std::string name, std::string ui_name, GroupType type)
: ControlGroup(std::move(name), std::move(ui_name), type)
{
- numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
+ AddDeadzoneSetting(&m_deadzone_setting, 50);
}
ControlState ReshapableInput::GetDeadzoneRadiusAtAngle(double angle) const
{
// FYI: deadzone is scaled by input radius which allows the shape to match.
- return GetInputRadiusAtAngle(angle) * numeric_settings[SETTING_DEADZONE]->GetValue();
+ return GetInputRadiusAtAngle(angle) * GetDeadzonePercentage();
}
ControlState ReshapableInput::GetInputRadiusAtAngle(double angle) const
@@ -120,6 +120,11 @@ ControlState ReshapableInput::GetInputRadiusAtAngle(double angle) const
return GetCalibrationDataRadiusAtAngle(m_calibration, angle);
}
+ControlState ReshapableInput::GetDeadzonePercentage() const
+{
+ return m_deadzone_setting.GetValue() / 100;
+}
+
ControlState ReshapableInput::GetCalibrationDataRadiusAtAngle(const CalibrationData& data,
double angle)
{
@@ -267,7 +272,7 @@ ReshapableInput::ReshapeData ReshapableInput::Reshape(ControlState x, ControlSta
}
// Apply deadzone as a percentage of the user-defined calibration shape/size:
- const ControlState deadzone = numeric_settings[SETTING_DEADZONE]->GetValue();
+ const ControlState deadzone = GetDeadzonePercentage();
dist = std::max(0.0, dist - deadzone) / (1.0 - deadzone);
// Scale to the gate shape/radius: