GamepadState.ixx File
Representation of current gamepad input state. More...
Included Headers
#include <algorithm>
#include <helios/helios_config.h>
#include <helios.util.log.LogManager>
#include <helios.util.log.Logger>
#include <helios.math.types>
Namespaces Index
| namespace | helios |
| namespace | input |
|
Input handling and management. More... | |
| namespace | gamepad |
|
Gamepad input handling and configuration. More... | |
Classes Index
| class | GamepadState |
|
A lightweight class for transferring the state of a Gamepad. More... | |
Macro Definitions Index
| #define | HELIOS_LOG_SCOPE "helios::input::gamepad::GamepadState" |
Description
Representation of current gamepad input state.
Macro Definitions
HELIOS_LOG_SCOPE
|
Definition at line 17 of file GamepadState.ixx.
17#define HELIOS_LOG_SCOPE "helios::input::gamepad::GamepadState"
File Listing
The file content with the documentation metadata removed is:
17#define HELIOS_LOG_SCOPE "helios::input::gamepad::GamepadState"
18export namespace helios::input::gamepad {
54 class GamepadState {
60 inline static const helios::util::log::Logger& logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE);
176 mutable helios::math::vec2f left_;
181 mutable helios::math::vec2f right_;
186 mutable helios::math::vec2f trigger_;
194 left_ = helios::math::vec2f(axisLeftX_, axisLeftY_);
195 right_ = helios::math::vec2f(axisRightX_, axisRightY_);
196 trigger_ = helios::math::vec2f(triggerLeft_, triggerRight_);
202 ~GamepadState() = default;
209 GamepadState() = default;
218 explicit GamepadState(
220 float axisRightY, float triggerLeft, float triggerRight,
223 bool buttonStart, bool buttonBack, bool buttonGuide,
224 bool buttonLeftBumper, bool buttonRightBumper, bool buttonLeftThumb,
225 bool buttonRightThumb, bool buttonDpadUp, bool buttonDpadRight,
226 bool buttonDpadDown, bool buttonDpadLeft
229 updateAxes(
230 axisLeftX, axisLeftY, axisRightX, axisRightY, triggerLeft, triggerRight,
232 buttonA, buttonB, buttonX, buttonY, buttonStart, buttonBack, buttonGuide, buttonLeftBumper,
234 buttonDpadDown, buttonDpadLeft);
246 * -1 means moved all the way left/down, 0 means not moved at all, 1 means moved all the way right/up.
273 void updateAxes(
275 float triggerLeft, float triggerRight,
278 bool buttonStart, bool buttonBack, bool buttonGuide,
279 bool buttonLeftBumper, bool buttonRightBumper, bool buttonLeftThumb,
280 bool buttonRightThumb, bool buttonDpadUp, bool buttonDpadRight,
281 bool buttonDpadDown, bool buttonDpadLeft
297 if(triggerLeft < 0.0f || triggerLeft > 1.0f) {
300 if(triggerRight < 0.0f || triggerRight > 1.0f) {
309 triggerLeft_ = std::clamp(triggerLeft, 0.0f, 1.0f);
310 triggerRight_ = std::clamp(triggerRight, 0.0f, 1.0f);
312 buttonA_ = buttonA;
313 buttonB_ = buttonB;
314 buttonX_ = buttonX;
315 buttonY_ = buttonY;
316 buttonStart_ = buttonStart;
317 buttonBack_ = buttonBack;
318 buttonGuide_ = buttonGuide;
319 buttonLeftBumper_ = buttonLeftBumper;
320 buttonRightBumper_ = buttonRightBumper;
321 buttonLeftThumb_ = buttonLeftThumb;
322 buttonRightThumb_ = buttonRightThumb;
323 buttonDpadUp_ = buttonDpadUp;
324 buttonDpadRight_ = buttonDpadRight;
325 buttonDpadDown_ = buttonDpadDown;
326 buttonDpadLeft_ = buttonDpadLeft;
376 [[nodiscard]] float triggerLeft() const noexcept {
386 [[nodiscard]] float triggerRight() const noexcept {
394 * @return A helios::math::vec2f, with the first component being the x-axis, the second component the y-axis.
396 [[nodiscard]] helios::math::vec2f left() const noexcept {
407 * @return A helios::math::vec2f, with the first component being the x-axis, the second component the y-axis.
409 [[nodiscard]] helios::math::vec2f right() const noexcept {
423 [[nodiscard]] helios::math::vec2f trigger() const noexcept {
471 [[nodiscard]] bool buttonStart() const noexcept {
480 [[nodiscard]] bool buttonBack() const noexcept {
489 [[nodiscard]] bool buttonGuide() const noexcept {
498 [[nodiscard]] bool buttonLeftBumper() const noexcept {
507 [[nodiscard]] bool buttonRightBumper() const noexcept {
516 [[nodiscard]] bool buttonLeftThumb() const noexcept {
525 [[nodiscard]] bool buttonRightThumb() const noexcept {
534 [[nodiscard]] bool buttonDpadUp() const noexcept {
543 [[nodiscard]] bool buttonDpadRight() const noexcept {
552 [[nodiscard]] bool buttonDpadDown() const noexcept {
561 [[nodiscard]] bool buttonDpadLeft() const noexcept {
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.