Skip to main content

RadialDeadzoneStrategy.ixx File

Radial (circular) deadzone strategy for gamepad analog stick input. More...

Included Headers

#include <cmath> #include <helios.math.utils> #include <helios.engine.input.gamepad.DeadzoneStrategy>

Namespaces Index

namespacehelios
namespaceengine
namespaceinput
namespacegamepad

Classes Index

classRadialDeadzoneStrategy

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

Description

Radial (circular) deadzone strategy for gamepad analog stick input.

File Listing

The file content with the documentation metadata removed is:

1
5module;
6
7#include <cmath>
8
9export module helios.engine.input.gamepad.RadialDeadzoneStrategy;
10
11import helios.engine.input.gamepad.DeadzoneStrategy;
12import helios.math.utils;
13
14
15export namespace helios::engine::input::gamepad {
16
38
39 public:
40
45
50
61 void normalize(float deadzone, float& x, float& y) const noexcept override {
62
63 auto len = std::hypot(x, y);
64
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 }
80
81
82 };
83
84
85}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.