3#ifndef _CODEX_PAD_FRAME_DECODER_H_
4#define _CODEX_PAD_FRAME_DECODER_H_
80 kUp = uint32_t{1} << 0,
482 uint32_t button_states = 0;
486 void OnFrame(
const uint8_t *data);
488 static void OnFrameReceived(
const uint8_t *data,
void *user_data);
491 Inputs current_inputs_;
493 robust_frame::Parser parser_;
CodexPad controller data frame decoding main class.
void Update()
Update the decoder state. This function must be called continuously in the main loop to feed and pars...
uint32_t button_states() const
Get all button states, return a 32-bit unsigned integer where each bit represents the state of a spec...
const uint8_t * axis_values() const
Get current values of all analog axes (returns a read-only array pointer).
bool holding(const Button button) const
check if a button is held.
bool HasAxisValueChanged(const Axis axis, const uint8_t threshold) const
check if an axis value has changed.
uint8_t axis_value(const Axis axis) const
Get the raw value (0~255) of a specified joystick axis.
static constexpr size_t kAxisValueNum
Number of axis values.
static constexpr uint8_t kAxisCenter
Center value of joystick axes (typical value at rest).
static constexpr uint8_t kPayloadType
Input report type identifier for the gamepad (the first byte of the payload).
bool released(const Button button) const
check if a button is released.
bool pressed(const Button button) const
check if a button is pressed.
Button
Gamepad button mask enumeration.
@ kTriangleY
Triangle or Y.
CodexPadFrameDecoder(Stream &stream)
Constructor.
Axis
Joystick axis index enumeration.
@ kLeftStickX
Left stick X axis.
@ kRightStickY
Right stick Y axis.
@ kLeftStickY
Left stick Y axis.
@ kRightStickX
Right stick X axis.
bool button_state(const Button button) const
check if a button is pressed or held.