Xteink-X4-crosspoint-reader/src/MappedInputManager.h
2026-01-23 23:00:32 +01:00

30 lines
755 B
C++

#pragma once
#include <HalGPIO.h>
class MappedInputManager {
public:
enum class Button { Back, Confirm, Left, Right, Up, Down, Power, PageBack, PageForward };
struct Labels {
const char* btn1;
const char* btn2;
const char* btn3;
const char* btn4;
};
explicit MappedInputManager(HalGPIO& gpio) : gpio(gpio) {}
bool wasPressed(Button button) const;
bool wasReleased(Button button) const;
bool isPressed(Button button) const;
bool wasAnyPressed() const;
bool wasAnyReleased() const;
unsigned long getHeldTime() const;
Labels mapLabels(const char* back, const char* confirm, const char* previous, const char* next) const;
private:
HalGPIO& gpio;
decltype(HalGPIO::BTN_BACK) mapButton(Button button) const;
};