GamepadInput Arduino Lib 1.2.0
Loading...
Searching...
No Matches
gamepad::input::State Struct Reference

Represents a snapshot of gamepad input state. More...

#include <gamepad_input_state.h>

Public Member Functions

void Reset () noexcept
 Reset all inputs to neutral state.
 
bool operator[] (Button button) const noexcept
 Check if a button is pressed.
 
void Set (Button button) noexcept
 Press a button.
 
void Clear (Button button) noexcept
 Release a button.
 
uint8_t & operator[] (Axis axis) noexcept
 Access analog axis value.
 
const uint8_t & operator[] (Axis axis) const noexcept
 Access analog axis value (const).
 

Static Public Member Functions

static State FromBytes (const void *data) noexcept
 Construct a State from raw memory.
 

Public Attributes

uint32_t buttons {0}
 
uint8_t axes [kAxisCount] {kAxisCenter, kAxisCenter, kAxisCenter, kAxisCenter}
 

Detailed Description

Represents a snapshot of gamepad input state.

This structure is designed to be compact and stable for serialization.

Examples
gamepad_input_state.ino, and gamepad_input_tracker.ino.

Definition at line 40 of file gamepad_input_state.h.

Member Function Documentation

◆ Clear()

void gamepad::input::State::Clear ( Button button)
inlinenoexcept

Release a button.

Definition at line 103 of file gamepad_input_state.h.

◆ FromBytes()

static State gamepad::input::State::FromBytes ( const void * data)
inlinestaticnoexcept

Construct a State from raw memory.

Parameters
dataPointer to input data

Definition at line 54 of file gamepad_input_state.h.

◆ operator[]() [1/3]

const uint8_t & gamepad::input::State::operator[] ( Axis axis) const
inlinenoexcept

Access analog axis value (const).

Definition at line 123 of file gamepad_input_state.h.

◆ operator[]() [2/3]

uint8_t & gamepad::input::State::operator[] ( Axis axis)
inlinenoexcept

Access analog axis value.

Definition at line 113 of file gamepad_input_state.h.

◆ operator[]() [3/3]

bool gamepad::input::State::operator[] ( Button button) const
inlinenoexcept

Check if a button is pressed.

Definition at line 83 of file gamepad_input_state.h.

◆ Reset()

void gamepad::input::State::Reset ( )
inlinenoexcept

Reset all inputs to neutral state.

Definition at line 68 of file gamepad_input_state.h.

◆ Set()

void gamepad::input::State::Set ( Button button)
inlinenoexcept

Press a button.

Examples
gamepad_input_state.ino, and gamepad_input_tracker.ino.

Definition at line 93 of file gamepad_input_state.h.

Member Data Documentation

◆ axes

uint8_t gamepad::input::State::axes[kAxisCount] {kAxisCenter, kAxisCenter, kAxisCenter, kAxisCenter}
Examples
gamepad_input_state.ino.

Definition at line 42 of file gamepad_input_state.h.

◆ buttons

uint32_t gamepad::input::State::buttons {0}
Examples
gamepad_input_state.ino.

Definition at line 41 of file gamepad_input_state.h.


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