summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerEmu/ControlGroup
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2018-12-27 19:16:37 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2018-12-27 19:16:37 -0600
commitc614f5f534cdb7a083387505aff90e8be94fed73 (patch)
treec5d752d1beaa939f715a1e67e243bb9b6723a38f /Source/Core/InputCommon/ControllerEmu/ControlGroup
parentda9bcf83efeb1ede43e1c2ac08e6869ce8a2c15a (diff)
ControllerEmu: Allow analog stick input radius greater than one. Useful for rounded-square inputs of xbox controllers.
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup')
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp
index 3f766d5e45..9db29909fd 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp
@@ -32,8 +32,10 @@ AnalogStick::AnalogStick(const char* const name_, const char* const ui_name_,
controls.emplace_back(std::make_unique<Input>(Translate, _trans("Modifier")));
// Set default input radius to that of the gate radius (no resizing)
+ // Allow radius greater than 1.0 for definitions of rounded squares
+ // This is ideal for Xbox controllers (and probably others)
numeric_settings.emplace_back(
- std::make_unique<NumericSetting>(_trans("Input Radius"), GetGateRadiusAtAngle(0.0), 0, 100));
+ std::make_unique<NumericSetting>(_trans("Input Radius"), GetGateRadiusAtAngle(0.0), 0, 140));
// Set default input shape to an octagon (no reshaping)
numeric_settings.emplace_back(
std::make_unique<NumericSetting>(_trans("Input Shape"), 0.0, 0, 50));
@@ -97,7 +99,10 @@ ControlState AnalogStick::GetDeadzoneRadiusAtAngle(double ang) const
ControlState AnalogStick::GetInputRadiusAtAngle(double ang) const
{
- return CalculateInputShapeRadiusAtAngle(ang) * numeric_settings[SETTING_INPUT_RADIUS]->GetValue();
+ const ControlState radius =
+ CalculateInputShapeRadiusAtAngle(ang) * numeric_settings[SETTING_INPUT_RADIUS]->GetValue();
+ // Clamp within the -1 to +1 square as input radius may be greater than 1.0:
+ return std::min(radius, SquareStickGate(1).GetRadiusAtAngle(ang));
}
ControlState AnalogStick::CalculateInputShapeRadiusAtAngle(double ang) const