Skip to main content

RadialDeadzoneStrategy Class

Implements a radial (circular) deadzone strategy for analog stick normalization. More...

Declaration

class helios::input::gamepad::RadialDeadzoneStrategy { ... }

Base class

classDeadzoneStrategy

Abstract strategy interface for normalizing gamepad stick input with deadzone handling. More...

Public Constructors Index

RadialDeadzoneStrategy ()

Default constructor. More...

RadialDeadzoneStrategy (float stickNoiseThreshold)

Interface for applying deadzone handling to gamepad stick input. More...

Public Member Functions Index

voidnormalize (float deadzone, float &x, float &y) const noexcept override

Applies radial deadzone normalization to stick input. More...

Description

Implements a radial (circular) deadzone strategy for analog stick normalization.

This strategy treats the deadzone as a circle centered at the origin. Input vectors with a magnitude less than or equal to the deadzone threshold are zeroed out completely. Input vectors exceeding the deadzone are rescaled so that the effective input range starts at the edge of the deadzone circle, providing a smooth and consistent response.

The radial approach is generally preferred over axial deadzones because it eliminates diagonal movement artifacts and provides uniform sensitivity in all directions.

**Algorithm:** 1. Calculate the magnitude (length) of the input vector. 2. If magnitude <= deadzone, set both axes to zero. 3. If magnitude > 1.0, normalize the vector to unit length. 4. Rescale the magnitude from [deadzone, 1.0] to [0.0, 1.0]. 5. Apply the rescaled magnitude to the normalized direction vector.

See Also

DeadzoneStrategy for the abstract interface.

Definition at line 37 of file RadialDeadzoneStrategy.ixx.

Public Constructors

RadialDeadzoneStrategy()

helios::input::gamepad::RadialDeadzoneStrategy::RadialDeadzoneStrategy ()
inline

RadialDeadzoneStrategy()

helios::input::gamepad::RadialDeadzoneStrategy::RadialDeadzoneStrategy (float stickNoiseThreshold)
inline

Interface for applying deadzone handling to gamepad stick input.

Defines a method for processing and normalizing analog stick input while accounting for a deadzone. A deadzone eliminates unintended small input values caused by hardware imperfections. Implementations of this interface provide specific strategies for handling the deadzone and input normalization.

See Also

AxisDeadzoneStrategy for an axis-aligned deadzone implementation.

Definition at line 49 of file RadialDeadzoneStrategy.ixx.

References helios::input::gamepad::DeadzoneStrategy::DeadzoneStrategy and helios::input::gamepad::DeadzoneStrategy::stickNoiseThreshold.

Public Member Functions

normalize()

void helios::input::gamepad::RadialDeadzoneStrategy::normalize (float deadzone, float & x, float & y)
inline noexcept virtual

Applies radial deadzone normalization to stick input.

Modifies the input coordinates in-place. Values within the circular deadzone are zeroed, while values outside are rescaled for a smooth response curve.

Parameters
deadzone

The deadzone radius threshold in the range [0.0, 1.0].

x

Reference to the x-axis value, modified in-place.

y

Reference to the y-axis value, modified in-place.

Definition at line 61 of file RadialDeadzoneStrategy.ixx.

61 void normalize(float deadzone, float& x, float& y) const noexcept override {
62
63 auto len = std::hypot(x, y);
64
65 if (len <= stickNoiseThreshold() || len <= deadzone || deadzone >= 1.0f) {
66 x = 0;
67 y = 0;
68 return;
69 }
70
71 const float clampedLen = len > 1.0f ? 1.0f : len;
72
73 const float normalizedLen = (clampedLen - deadzone)/(1.0f - deadzone);
74
75 const float scale = normalizedLen / len;
76
77 x *= scale;
78 y *= scale;
79 }

Reference helios::input::gamepad::DeadzoneStrategy::stickNoiseThreshold.


The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.