DeadzoneStrategy Class
Abstract strategy interface for normalizing gamepad stick input with deadzone handling. More...
Declaration
Derived Classes
| class | RadialDeadzoneStrategy |
|
Implements a radial (circular) deadzone strategy for analog stick normalization. More... | |
Public Constructors Index
| DeadzoneStrategy ()=default | |
|
Default constructor. More... | |
| DeadzoneStrategy (float stickNoiseThreshold) | |
|
Interface for applying deadzone handling to gamepad stick input. More... | |
Public Destructor Index
| ~DeadzoneStrategy ()=default | |
|
Virtual destructor for proper polymorphic cleanup. More... | |
Public Member Functions Index
| void | normalize (float deadzone, float &x, float &y) const noexcept=0 |
|
Normalizes stick input values based on the configured deadzone. More... | |
| float | stickNoiseThreshold () const noexcept |
|
Retrieves the current noise threshold for stick input. More... | |
| void | setStickNoiseThreshold (float threshold) noexcept |
|
Sets the noise threshold for stick inputs to handle minor hardware drift. More... | |
Protected Member Attributes Index
| float | stickNoiseThreshold_ = DEFAULT_STICK_NOISE_THRESHOLD |
|
Threshold used to filter out minor noise in gamepad stick input. More... | |
Public Static Attributes Index
| static constexpr float | DEFAULT_STICK_NOISE_THRESHOLD = 0.002f |
|
Default threshold used to filter out minor noise in gamepad stick input. More... | |
Description
Abstract strategy interface for normalizing gamepad stick input with deadzone handling.
Gamepad analog sticks rarely return exactly (0, 0) when at rest due to hardware drift. A deadzone defines a threshold below which input is ignored. Implementations of this interface define how input values are normalized once they exceed the deadzone threshold.
- See Also
RadialDeadzoneStrategy for a circular deadzone implementation.
Definition at line 23 of file DeadzoneStrategy.ixx.
Public Constructors
DeadzoneStrategy()
| default |
Default constructor.
Definition at line 53 of file DeadzoneStrategy.ixx.
Referenced by helios::input::gamepad::RadialDeadzoneStrategy::RadialDeadzoneStrategy and helios::input::gamepad::RadialDeadzoneStrategy::RadialDeadzoneStrategy.
DeadzoneStrategy()
| 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 65 of file DeadzoneStrategy.ixx.
References stickNoiseThreshold and stickNoiseThreshold_.
Public Destructor
~DeadzoneStrategy()
| virtual default |
Virtual destructor for proper polymorphic cleanup.
Definition at line 48 of file DeadzoneStrategy.ixx.
Public Member Functions
normalize()
| noexcept |
Normalizes stick input values based on the configured deadzone.
This method modifies the input coordinates in-place. Values within the deadzone are typically zeroed out, while values outside are scaled to provide a smooth response curve from the edge of the deadzone to the maximum input value.
- Parameters
-
deadzone The deadzone 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 78 of file DeadzoneStrategy.ixx.
setStickNoiseThreshold()
| inline noexcept |
Sets the noise threshold for stick inputs to handle minor hardware drift.
The noise threshold defines the minimum magnitude for stick input to be considered valid. Inputs with a magnitude below this threshold are ignored to prevent unintentional movement caused by hardware noise or drift.
- Parameters
-
threshold The new stick noise threshold, typically in the range [0.0, 1.0].
Definition at line 103 of file DeadzoneStrategy.ixx.
Reference stickNoiseThreshold_.
stickNoiseThreshold()
| inline nodiscard noexcept |
Retrieves the current noise threshold for stick input.
The noise threshold determines the minimum magnitude of input required to be processed as valid. Values below this threshold are considered noise and ignored to prevent unintentional drift detection.
- Returns
The configured noise threshold value.
Definition at line 90 of file DeadzoneStrategy.ixx.
Reference stickNoiseThreshold_.
Referenced by DeadzoneStrategy, helios::input::gamepad::RadialDeadzoneStrategy::normalize and helios::input::gamepad::RadialDeadzoneStrategy::RadialDeadzoneStrategy.
Protected Member Attributes
stickNoiseThreshold_
| protected |
Threshold used to filter out minor noise in gamepad stick input.
This value represents the minimum magnitude of stick input required to be treated as valid. Input signals with a magnitude below this threshold are considered noise, helping to mitigate the effect of hardware drift or minor stick movements. Adjusting this parameter can improve input precision and reduce unintended drift behavior.
Definition at line 36 of file DeadzoneStrategy.ixx.
Referenced by DeadzoneStrategy, setStickNoiseThreshold and stickNoiseThreshold.
Public Static Attributes
DEFAULT_STICK_NOISE_THRESHOLD
| constexpr static |
Default threshold used to filter out minor noise in gamepad stick input.
Definition at line 43 of file DeadzoneStrategy.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.