4#ifndef GAMEPAD_INPUT_TRACKER_H
5#define GAMEPAD_INPUT_TRACKER_H
7#include "gamepad_input_state.h"
9namespace gamepad::input {
34 const State&
raw() const noexcept {
return current_; }
57 void Tick() noexcept { previous_ = current_; }
79 bool pressed(
Button button)
const noexcept {
return current_[button] && !previous_[button]; }
91 bool released(
Button button)
const noexcept {
return !current_[button] && previous_[button]; }
103 bool holding(
Button button)
const noexcept {
return current_[button] && previous_[button]; }
118 return AxisChanged(previous_[axis], current_[axis], threshold);
146 static bool AxisChanged(uint8_t previous, uint8_t current, uint8_t threshold)
noexcept {
147 if (previous == current) {
151 if (current == 0 || current == 255) {
155 const uint8_t diff = current > previous ? current - previous : previous - current;
156 return diff >= threshold;
Button
Button identifiers for a generic gamepad.