Another fix attempt

This commit is contained in:
jpirnay
2026-05-03 00:17:33 +02:00
parent 876e1c807d
commit ccd82c32fc
4 changed files with 29 additions and 10 deletions
+15
View File
@@ -5,6 +5,15 @@
// Required for constexpr array out-of-class definition (C++14).
constexpr ButtonEventManager::Button ButtonEventManager::ALL_BUTTONS[ButtonEventManager::NUM_BUTTONS];
int ButtonEventManager::buttonToIndex(const Button button) {
for (int i = 0; i < NUM_BUTTONS; i++) {
if (ALL_BUTTONS[i] == button) {
return i;
}
}
return -1;
}
bool ButtonEventManager::hasDoubleAction(const Button button) {
using BA = CrossPointSettings::BUTTON_ACTION;
switch (button) {
@@ -40,6 +49,12 @@ void ButtonEventManager::pushEventFront(const Button button, const PressType typ
eventBuf[eventHead] = {button, type};
}
bool ButtonEventManager::isShortPending(const Button button) const {
const int idx = buttonToIndex(button);
if (idx < 0) return false;
return buttons[idx].state == State::ReleasedOnce;
}
bool ButtonEventManager::consumeEvent(ButtonEvent& out) {
if (eventHead == eventTail) return false;
out = eventBuf[eventHead];