GamepadState.ixx File
Representation of current gamepad input state. More...
Included Headers
#include <algorithm>
#include <cassert>
#include <helios/helios_config.h>
#include <helios.input.types.Gamepad>
#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 20 of file GamepadState.ixx.
20#define HELIOS_LOG_SCOPE "helios::input::gamepad::GamepadState"
File Listing
The file content with the documentation metadata removed is:
20#define HELIOS_LOG_SCOPE "helios::input::gamepad::GamepadState"
22using namespace helios::input::types;
24export namespace helios::input::gamepad {
60 class GamepadState {
69 inline static const helios::util::log::Logger& logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE);
191 mutable helios::math::vec2f left_;
196 mutable helios::math::vec2f right_;
201 mutable helios::math::vec2f trigger_;
209 left_ = helios::math::vec2f(axisLeftX_, axisLeftY_);
210 right_ = helios::math::vec2f(axisRightX_, axisRightY_);
211 trigger_ = helios::math::vec2f(triggerLeft_, triggerRight_);
217 ~GamepadState() = default;
224 GamepadState() = default;
233 explicit GamepadState(
235 float axisRightY, float triggerLeft, float triggerRight,
238 bool buttonStart, bool buttonBack, bool buttonGuide,
239 bool buttonLeftBumper, bool buttonRightBumper, bool buttonLeftThumb,
240 bool buttonRightThumb, bool buttonDpadUp, bool buttonDpadRight,
241 bool buttonDpadDown, bool buttonDpadLeft
244 updateAxes(
245 axisLeftX, axisLeftY, axisRightX, axisRightY, triggerLeft, triggerRight,
247 buttonA, buttonB, buttonX, buttonY, buttonStart, buttonBack, buttonGuide, buttonLeftBumper,
249 buttonDpadDown, buttonDpadLeft);
261 * -1 means moved all the way left/down, 0 means not moved at all, 1 means moved all the way right/up.
288 void updateAxes(
290 float triggerLeft, float triggerRight,
293 bool buttonStart, bool buttonBack, bool buttonGuide,
294 bool buttonLeftBumper, bool buttonRightBumper, bool buttonLeftThumb,
295 bool buttonRightThumb, bool buttonDpadUp, bool buttonDpadRight,
296 bool buttonDpadDown, bool buttonDpadLeft
312 if(triggerLeft < 0.0f || triggerLeft > 1.0f) {
315 if(triggerRight < 0.0f || triggerRight > 1.0f) {
324 triggerLeft_ = std::clamp(triggerLeft, 0.0f, 1.0f);
325 triggerRight_ = std::clamp(triggerRight, 0.0f, 1.0f);
329 buttonA_ = buttonA;
332 buttonB_ = buttonB;
334 buttonX_ = buttonX;
336 buttonY_ = buttonY;
339 buttonStart_ = buttonStart;
341 buttonBack_ = buttonBack;
343 buttonGuide_ = buttonGuide;
345 buttonLeftBumper_ = buttonLeftBumper;
347 buttonRightBumper_ = buttonRightBumper;
349 buttonLeftThumb_ = buttonLeftThumb;
351 buttonRightThumb_ = buttonRightThumb;
354 buttonDpadUp_ = buttonDpadUp;
356 buttonDpadRight_ = buttonDpadRight;
359 buttonDpadDown_ = buttonDpadDown;
361 buttonDpadLeft_ = buttonDpadLeft;
411 [[nodiscard]] float triggerLeft() const noexcept {
421 [[nodiscard]] float triggerRight() const noexcept {
429 * @return A helios::math::vec2f, with the first component being the x-axis, the second component the y-axis.
431 [[nodiscard]] helios::math::vec2f left() const noexcept {
442 * @return A helios::math::vec2f, with the first component being the x-axis, the second component the y-axis.
444 [[nodiscard]] helios::math::vec2f right() const noexcept {
458 [[nodiscard]] helios::math::vec2f trigger() const noexcept {
509 [[nodiscard]] bool isButtonDown(const GamepadInput input) const {
510 switch (input) {
511 case GamepadInput::Start:
513 case GamepadInput::Down:
515 case GamepadInput::Up:
517 case GamepadInput::A:
519 case GamepadInput::B:
535 [[nodiscard]] bool isButtonHeld(const GamepadInput input) const {
536 switch (input) {
537 case GamepadInput::Start:
539 case GamepadInput::Down:
541 case GamepadInput::Up:
543 case GamepadInput::A:
545 case GamepadInput::B:
561 [[nodiscard]] bool isButtonUp(const GamepadInput input) const {
562 switch (input) {
563 case GamepadInput::Start:
565 case GamepadInput::Down:
567 case GamepadInput::Up:
569 case GamepadInput::A:
571 case GamepadInput::B:
588 [[nodiscard]] bool isButtonPressed(const GamepadInput input) const {
589 switch (input) {
590 case GamepadInput::Start:
592 case GamepadInput::Down:
594 case GamepadInput::Up:
596 case GamepadInput::A:
598 case GamepadInput::B:
613 [[nodiscard]] bool buttonStart() const noexcept {
622 [[nodiscard]] bool buttonPressedStart() const noexcept {
631 [[nodiscard]] bool buttonBack() const noexcept {
640 [[nodiscard]] bool buttonGuide() const noexcept {
649 [[nodiscard]] bool buttonLeftBumper() const noexcept {
658 [[nodiscard]] bool buttonRightBumper() const noexcept {
667 [[nodiscard]] bool buttonLeftThumb() const noexcept {
676 [[nodiscard]] bool buttonRightThumb() const noexcept {
685 [[nodiscard]] bool buttonDpadUp() const noexcept {
694 [[nodiscard]] bool buttonDpadRight() const noexcept {
703 [[nodiscard]] bool buttonDpadDown() const noexcept {
712 [[nodiscard]] bool buttonDpadLeft() const noexcept {
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.