Skip to main content

GamepadSettings.ixx File

Configuration settings for gamepad input processing. More...

Included Headers

#include <algorithm>

Namespaces Index

namespacehelios
namespaceinput

Input handling and management. More...

namespacegamepad

Gamepad input handling and configuration. More...

Classes Index

classGamepadSettings

Configuration class for gamepad input normalization and axis behavior. More...

Description

Configuration settings for gamepad input processing.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file GamepadSettings.ixx
3 * @brief Configuration settings for gamepad input processing.
4 */
5module;
6
7#include <algorithm>
8
9export module helios.input.gamepad.GamepadSettings;
10
11export namespace helios::input::gamepad {
12
13 /**
14 * @brief Configuration class for gamepad input normalization and axis behavior.
15 *
16 * This class encapsulates all settings that affect how raw gamepad input is processed
17 * before being consumed by the application. It provides fluent setter methods for
18 * convenient method chaining during configuration.
19 *
20 * **Configurable options:**
21 * - **Deadzone values:** Per-stick thresholds for filtering out hardware drift.
22 * - **Axis inversion:** Individual control over X/Y axis inversion for both sticks.
23 *
24 * Deadzone values are clamped to the range [0.0, 0.9] to ensure that at least 10%
25 * of the stick's range remains usable.
26 *
27 * Example usage:
28 * ```cpp
29 * GamepadSettings settings;
30 * settings.setLeftStickDeadzone(0.15f)
31 * .setRightStickDeadzone(0.1f)
32 * .setInvertLeftY(true);
33 * ```
34 *
35 * @see DeadzoneStrategy for how deadzone values are applied during normalization.
36 */
38
39 /**
40 * @brief Deadzone threshold for the left analog stick.
41 */
42 float leftStickDeadzone_ = 0.0f;
43
44 /**
45 * @brief Deadzone threshold for the right analog stick.
46 */
47 float rightStickDeadzone_ = 0.0f;
48
49 /**
50 * @brief Flag to invert the left stick's X-axis.
51 */
52 bool invertLeftX_ = false;
53
54 /**
55 * @brief Flag to invert the left stick's Y-axis.
56 */
57 bool invertLeftY_ = false;
58
59 /**
60 * @brief Flag to invert the right stick's X-axis.
61 */
62 bool invertRightX_ = false;
63
64 /**
65 * @brief Flag to invert the right stick's Y-axis.
66 */
67 bool invertRightY_ = false;
68
69 public:
70
71 /**
72 * @brief Default destructor.
73 */
74 ~GamepadSettings() = default;
75
76 /**
77 * @brief Default constructor with zero deadzone and no axis inversion.
78 */
79 GamepadSettings() = default;
80
81 /**
82 * @brief Sets the deadzone threshold for the left analog stick.
83 *
84 * @param deadzone The deadzone value, clamped to [0.0, 0.9].
85 *
86 * @return Reference to this object for method chaining.
87 */
88 GamepadSettings& setLeftStickDeadzone(float deadzone) noexcept {
89 deadzone = std::clamp(deadzone, 0.0f, 0.9f);
90 leftStickDeadzone_ = deadzone;
91 return *this;
92 }
93
94 /**
95 * @brief Sets the deadzone threshold for the right analog stick.
96 *
97 * @param deadzone The deadzone value, clamped to [0.0, 0.9].
98 *
99 * @return Reference to this object for method chaining.
100 */
101 GamepadSettings& setRightStickDeadzone(float deadzone) noexcept {
102 deadzone = std::clamp(deadzone, 0.0f, 0.9f);
103 rightStickDeadzone_ = deadzone;
104 return *this;
105 }
106
107 /**
108 * @brief Sets whether the left stick's X-axis should be inverted.
109 *
110 * @param invert True to invert, false for normal behavior.
111 *
112 * @return Reference to this object for method chaining.
113 */
114 GamepadSettings& setInvertLeftX(bool invert) noexcept {
115 invertLeftX_ = invert;
116 return *this;
117 }
118
119 /**
120 * @brief Sets whether the left stick's Y-axis should be inverted.
121 *
122 * @param invert True to invert, false for normal behavior.
123 *
124 * @return Reference to this object for method chaining.
125 */
126 GamepadSettings& setInvertLeftY(bool invert) noexcept {
127 invertLeftY_ = invert;
128 return *this;
129 }
130
131 /**
132 * @brief Sets whether the right stick's X-axis should be inverted.
133 *
134 * @param invert True to invert, false for normal behavior.
135 *
136 * @return Reference to this object for method chaining.
137 */
138 GamepadSettings& setInvertRightX(bool invert) noexcept {
139 invertRightX_ = invert;
140 return *this;
141 }
142
143 /**
144 * @brief Sets whether the right stick's Y-axis should be inverted.
145 *
146 * @param invert True to invert, false for normal behavior.
147 *
148 * @return Reference to this object for method chaining.
149 */
150 GamepadSettings& setInvertRightY(bool invert) noexcept {
151 invertRightY_ = invert;
152 return *this;
153 }
154
155 /**
156 * @brief Returns the configured deadzone for the left stick.
157 *
158 * @return The deadzone threshold in the range [0.0, 0.9].
159 */
160 [[nodiscard]] float leftStickDeadzone() const noexcept {
161 return leftStickDeadzone_;
162 }
163
164 /**
165 * @brief Returns the configured deadzone for the right stick.
166 *
167 * @return The deadzone threshold in the range [0.0, 0.9].
168 */
169 [[nodiscard]] float rightStickDeadzone() const noexcept {
170 return rightStickDeadzone_;
171 }
172
173 /**
174 * @brief Returns whether the left stick's X-axis is inverted.
175 *
176 * @return True if inverted, false otherwise.
177 */
178 [[nodiscard]] bool invertLeftX() const noexcept {
179 return invertLeftX_;
180 }
181
182 /**
183 * @brief Returns whether the left stick's Y-axis is inverted.
184 *
185 * @return True if inverted, false otherwise.
186 */
187 [[nodiscard]] bool invertLeftY() const noexcept {
188 return invertLeftY_;
189 }
190
191 /**
192 * @brief Returns whether the right stick's X-axis is inverted.
193 *
194 * @return True if inverted, false otherwise.
195 */
196 [[nodiscard]] bool invertRightX() const noexcept {
197 return invertRightX_;
198 }
199
200 /**
201 * @brief Returns whether the right stick's Y-axis is inverted.
202 *
203 * @return True if inverted, false otherwise.
204 */
205 [[nodiscard]] bool invertRightY() const noexcept {
206 return invertRightY_;
207 }
208
209 };
210
211}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.