Something went wrong. Try again.
A fork of https://github.com/crosspoint-reader/crosspoint-reader
Something went wrong. Try again.
932 B · 33 lines
C
at master
12345678910111213141516171819202122232425262728293031323334#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) {}
void update() const { gpio.update(); } 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; // Returns the raw front button index that was pressed this frame (or -1 if none). int getPressedFrontButton() const;
private: HalGPIO& gpio;
bool mapButton(Button button, bool (HalGPIO::*fn)(uint8_t) const) const;};