diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2019-03-26 19:31:03 -0500 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2019-04-07 09:32:49 -0500 |
| commit | 5efb717873691fa42447ca0d9d9810b5ad501b42 (patch) | |
| tree | 4d3f306850c0a1f876489327d7de98ca1c0cba6a /Source/Core/InputCommon/ControllerEmu/StickGate.cpp | |
| parent | 75e74315e69df1dc03bbda4373528e9e26274d7d (diff) | |
InputCommon: Clean up how numeric settings are handled. Add units of measure to UI. Eliminate hidden magic values of the IR cursor.
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/StickGate.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu/StickGate.cpp | 11 |
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: |
