Skip to main content

DeadzoneStrategy Class

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

Declaration

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

Derived Classes

classRadialDeadzoneStrategy

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

voidnormalize (float deadzone, float &x, float &y) const noexcept=0

Normalizes stick input values based on the configured deadzone. More...

floatstickNoiseThreshold () const noexcept

Retrieves the current noise threshold for stick input. More...

voidsetStickNoiseThreshold (float threshold) noexcept

Sets the noise threshold for stick inputs to handle minor hardware drift. More...

Protected Member Attributes Index

floatstickNoiseThreshold_ = DEFAULT_STICK_NOISE_THRESHOLD

Threshold used to filter out minor noise in gamepad stick input. More...

Public Static Attributes Index

static constexpr floatDEFAULT_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()

helios::input::gamepad::DeadzoneStrategy::DeadzoneStrategy ()
default

DeadzoneStrategy()

helios::input::gamepad::DeadzoneStrategy::DeadzoneStrategy (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 65 of file DeadzoneStrategy.ixx.

References stickNoiseThreshold and stickNoiseThreshold_.

Public Destructor

~DeadzoneStrategy()

virtual helios::input::gamepad::DeadzoneStrategy::~DeadzoneStrategy ()
virtual default

Virtual destructor for proper polymorphic cleanup.

Definition at line 48 of file DeadzoneStrategy.ixx.

Public Member Functions

normalize()

virtual void helios::input::gamepad::DeadzoneStrategy::normalize (float deadzone, float & x, float & y)
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()

void helios::input::gamepad::DeadzoneStrategy::setStickNoiseThreshold (float threshold)
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.

103 void setStickNoiseThreshold(float threshold) noexcept {
104 stickNoiseThreshold_ = std::clamp(threshold, 0.0f, 0.9f);
105 }

Reference stickNoiseThreshold_.

stickNoiseThreshold()

float helios::input::gamepad::DeadzoneStrategy::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.

90 [[nodiscard]] float stickNoiseThreshold() const noexcept {
92 }

Reference stickNoiseThreshold_.

Referenced by DeadzoneStrategy, helios::input::gamepad::RadialDeadzoneStrategy::normalize and helios::input::gamepad::RadialDeadzoneStrategy::RadialDeadzoneStrategy.

Protected Member Attributes

stickNoiseThreshold_

float helios::input::gamepad::DeadzoneStrategy::stickNoiseThreshold_ = DEFAULT_STICK_NOISE_THRESHOLD
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

float helios::input::gamepad::DeadzoneStrategy::DEFAULT_STICK_NOISE_THRESHOLD = 0.002f
constexpr static

Default threshold used to filter out minor noise in gamepad stick input.

Definition at line 43 of file DeadzoneStrategy.ixx.

43 static constexpr float DEFAULT_STICK_NOISE_THRESHOLD = 0.002f;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.