Some fixes
This commit is contained in:
@@ -33,6 +33,13 @@ void ButtonEventManager::pushEvent(const Button button, const PressType type) {
|
|||||||
eventTail = next;
|
eventTail = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ButtonEventManager::pushEventFront(const Button button, const PressType type) {
|
||||||
|
const int prev = (eventHead - 1 + EVENT_BUF) % EVENT_BUF;
|
||||||
|
if (prev == eventTail) return; // buffer full
|
||||||
|
eventHead = prev;
|
||||||
|
eventBuf[eventHead] = {button, type};
|
||||||
|
}
|
||||||
|
|
||||||
bool ButtonEventManager::consumeEvent(ButtonEvent& out) {
|
bool ButtonEventManager::consumeEvent(ButtonEvent& out) {
|
||||||
if (eventHead == eventTail) return false;
|
if (eventHead == eventTail) return false;
|
||||||
out = eventBuf[eventHead];
|
out = eventBuf[eventHead];
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class ButtonEventManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Timing constants (milliseconds)
|
// Timing constants (milliseconds)
|
||||||
static constexpr unsigned long LONG_PRESS_MS = 600;
|
static constexpr unsigned long LONG_PRESS_MS = 1000;
|
||||||
static constexpr unsigned long DOUBLE_WINDOW_MS = 300;
|
static constexpr unsigned long DOUBLE_WINDOW_MS = 300;
|
||||||
|
|
||||||
explicit ButtonEventManager(MappedInputManager& input) : input(input) {}
|
explicit ButtonEventManager(MappedInputManager& input) : input(input) {}
|
||||||
@@ -49,6 +49,10 @@ class ButtonEventManager {
|
|||||||
// Reset all per-button FSMs. Call on activity transitions to prevent bleed-through.
|
// Reset all per-button FSMs. Call on activity transitions to prevent bleed-through.
|
||||||
void drain();
|
void drain();
|
||||||
|
|
||||||
|
// Preserve a default event for activity processing after main loop dispatch.
|
||||||
|
// This is used when the configured action is BTN_DEFAULT.
|
||||||
|
void pushEventFront(Button button, PressType type);
|
||||||
|
|
||||||
// Returns true if a double-click action is configured for this button.
|
// Returns true if a double-click action is configured for this button.
|
||||||
// ButtonEventManager queries CrossPointSettings internally.
|
// ButtonEventManager queries CrossPointSettings internally.
|
||||||
static bool hasDoubleAction(Button button);
|
static bool hasDoubleAction(Button button);
|
||||||
|
|||||||
@@ -42,22 +42,40 @@ void EpubReaderChapterSelectionActivity::loop() {
|
|||||||
const int pageItems = getPageItems();
|
const int pageItems = getPageItems();
|
||||||
const int totalItems = getTotalItems();
|
const int totalItems = getTotalItems();
|
||||||
|
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
ButtonEventManager::ButtonEvent ev;
|
||||||
const auto newSpineIndex = epub->getSpineIndexForTocIndex(selectorIndex);
|
while (buttonEvents.consumeEvent(ev)) {
|
||||||
if (newSpineIndex == -1) {
|
if (ev.button == MappedInputManager::Button::Confirm && ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
const auto newSpineIndex = epub->getSpineIndexForTocIndex(selectorIndex);
|
||||||
|
if (newSpineIndex == -1) {
|
||||||
|
ActivityResult result;
|
||||||
|
result.isCancelled = true;
|
||||||
|
setResult(std::move(result));
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
setResult(ChapterResult{newSpineIndex, selectorIndex});
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ev.button == MappedInputManager::Button::Back && ev.type == ButtonEventManager::PressType::Short) {
|
||||||
ActivityResult result;
|
ActivityResult result;
|
||||||
result.isCancelled = true;
|
result.isCancelled = true;
|
||||||
setResult(std::move(result));
|
setResult(std::move(result));
|
||||||
finish();
|
finish();
|
||||||
} else {
|
return;
|
||||||
setResult(ChapterResult{newSpineIndex, selectorIndex});
|
}
|
||||||
finish();
|
if ((ev.button == MappedInputManager::Button::PageBack || ev.button == MappedInputManager::Button::Left) &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
selectorIndex = ButtonNavigator::previousIndex(selectorIndex, totalItems);
|
||||||
|
requestUpdate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((ev.button == MappedInputManager::Button::PageForward || ev.button == MappedInputManager::Button::Right) &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
selectorIndex = ButtonNavigator::nextIndex(selectorIndex, totalItems);
|
||||||
|
requestUpdate();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
|
|
||||||
ActivityResult result;
|
|
||||||
result.isCancelled = true;
|
|
||||||
setResult(std::move(result));
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonNavigator.onNextRelease([this, totalItems] {
|
buttonNavigator.onNextRelease([this, totalItems] {
|
||||||
|
|||||||
@@ -18,30 +18,65 @@ void EpubReaderFootnotesActivity::onEnter() {
|
|||||||
void EpubReaderFootnotesActivity::onExit() { Activity::onExit(); }
|
void EpubReaderFootnotesActivity::onExit() { Activity::onExit(); }
|
||||||
|
|
||||||
void EpubReaderFootnotesActivity::loop() {
|
void EpubReaderFootnotesActivity::loop() {
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
|
ButtonEventManager::ButtonEvent ev;
|
||||||
ActivityResult result;
|
while (buttonEvents.consumeEvent(ev)) {
|
||||||
result.isCancelled = true;
|
if (ev.button == MappedInputManager::Button::Back && ev.type == ButtonEventManager::PressType::Short) {
|
||||||
setResult(std::move(result));
|
ActivityResult result;
|
||||||
finish();
|
result.isCancelled = true;
|
||||||
return;
|
setResult(std::move(result));
|
||||||
}
|
|
||||||
|
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
|
||||||
if (selectedIndex >= 0 && selectedIndex < static_cast<int>(footnotes.size())) {
|
|
||||||
setResult(FootnoteResult{footnotes[selectedIndex].href});
|
|
||||||
finish();
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ev.button == MappedInputManager::Button::Confirm && ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
if (selectedIndex >= 0 && selectedIndex < static_cast<int>(footnotes.size())) {
|
||||||
|
setResult(FootnoteResult{footnotes[selectedIndex].href});
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ev.button == MappedInputManager::Button::PageBack || ev.button == MappedInputManager::Button::Left) &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
if (!footnotes.empty()) {
|
||||||
|
selectedIndex = (selectedIndex - 1 + footnotes.size()) % footnotes.size();
|
||||||
|
requestUpdate();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ev.button == MappedInputManager::Button::PageForward || ev.button == MappedInputManager::Button::Right) &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
if (!footnotes.empty()) {
|
||||||
|
selectedIndex = (selectedIndex + 1) % footnotes.size();
|
||||||
|
requestUpdate();
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonNavigator.onNext([this] {
|
buttonNavigator.onNextRelease([this] {
|
||||||
if (!footnotes.empty()) {
|
if (!footnotes.empty()) {
|
||||||
selectedIndex = (selectedIndex + 1) % footnotes.size();
|
selectedIndex = (selectedIndex + 1) % footnotes.size();
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
buttonNavigator.onPrevious([this] {
|
buttonNavigator.onPreviousRelease([this] {
|
||||||
|
if (!footnotes.empty()) {
|
||||||
|
selectedIndex = (selectedIndex - 1 + footnotes.size()) % footnotes.size();
|
||||||
|
requestUpdate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonNavigator.onNextContinuous([this] {
|
||||||
|
if (!footnotes.empty()) {
|
||||||
|
selectedIndex = (selectedIndex + 1) % footnotes.size();
|
||||||
|
requestUpdate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonNavigator.onPreviousContinuous([this] {
|
||||||
if (!footnotes.empty()) {
|
if (!footnotes.empty()) {
|
||||||
selectedIndex = (selectedIndex - 1 + footnotes.size()) % footnotes.size();
|
selectedIndex = (selectedIndex - 1 + footnotes.size()) % footnotes.size();
|
||||||
requestUpdate();
|
requestUpdate();
|
||||||
|
|||||||
@@ -34,22 +34,34 @@ void EpubReaderPercentSelectionActivity::adjustPercent(const int delta) {
|
|||||||
|
|
||||||
void EpubReaderPercentSelectionActivity::loop() {
|
void EpubReaderPercentSelectionActivity::loop() {
|
||||||
// Back cancels, confirm selects, arrows adjust the percent.
|
// Back cancels, confirm selects, arrows adjust the percent.
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
|
ButtonEventManager::ButtonEvent ev;
|
||||||
ActivityResult result;
|
while (buttonEvents.consumeEvent(ev)) {
|
||||||
result.isCancelled = true;
|
if (ev.button == MappedInputManager::Button::Back && ev.type == ButtonEventManager::PressType::Short) {
|
||||||
setResult(std::move(result));
|
ActivityResult result;
|
||||||
finish();
|
result.isCancelled = true;
|
||||||
return;
|
setResult(std::move(result));
|
||||||
}
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
if (ev.button == MappedInputManager::Button::Confirm && ev.type == ButtonEventManager::PressType::Short) {
|
||||||
setResult(PercentResult{percent});
|
setResult(PercentResult{percent});
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonNavigator.onPressAndContinuous({MappedInputManager::Button::Left}, [this] { adjustPercent(-kSmallStep); });
|
if ((ev.button == MappedInputManager::Button::PageBack || ev.button == MappedInputManager::Button::Left) &&
|
||||||
buttonNavigator.onPressAndContinuous({MappedInputManager::Button::Right}, [this] { adjustPercent(kSmallStep); });
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
adjustPercent(-kSmallStep);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((ev.button == MappedInputManager::Button::PageForward || ev.button == MappedInputManager::Button::Right) &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
adjustPercent(kSmallStep);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buttonNavigator.onPressAndContinuous({MappedInputManager::Button::Up}, [this] { adjustPercent(kLargeStep); });
|
buttonNavigator.onPressAndContinuous({MappedInputManager::Button::Up}, [this] { adjustPercent(kLargeStep); });
|
||||||
buttonNavigator.onPressAndContinuous({MappedInputManager::Button::Down}, [this] { adjustPercent(-kLargeStep); });
|
buttonNavigator.onPressAndContinuous({MappedInputManager::Button::Down}, [this] { adjustPercent(-kLargeStep); });
|
||||||
|
|||||||
@@ -34,24 +34,41 @@ void MdReaderTocSelectionActivity::loop() {
|
|||||||
const int pageItems = getPageItems();
|
const int pageItems = getPageItems();
|
||||||
const int totalItems = getTotalItems();
|
const int totalItems = getTotalItems();
|
||||||
|
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
ButtonEventManager::ButtonEvent ev;
|
||||||
if (selectorIndex >= 0 && selectorIndex < totalItems) {
|
while (buttonEvents.consumeEvent(ev)) {
|
||||||
setResult(PageResult{static_cast<uint32_t>(headings[selectorIndex].pageIndex)});
|
if (ev.button == MappedInputManager::Button::Confirm && ev.type == ButtonEventManager::PressType::Short) {
|
||||||
} else {
|
if (selectorIndex >= 0 && selectorIndex < totalItems) {
|
||||||
|
setResult(PageResult{static_cast<uint32_t>(headings[selectorIndex].pageIndex)});
|
||||||
|
} else {
|
||||||
|
ActivityResult result;
|
||||||
|
result.isCancelled = true;
|
||||||
|
setResult(std::move(result));
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ev.button == MappedInputManager::Button::Back && ev.type == ButtonEventManager::PressType::Short) {
|
||||||
ActivityResult result;
|
ActivityResult result;
|
||||||
result.isCancelled = true;
|
result.isCancelled = true;
|
||||||
setResult(std::move(result));
|
setResult(std::move(result));
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
|
if ((ev.button == MappedInputManager::Button::PageBack || ev.button == MappedInputManager::Button::Left) &&
|
||||||
ActivityResult result;
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
result.isCancelled = true;
|
selectorIndex = ButtonNavigator::previousIndex(selectorIndex, totalItems);
|
||||||
setResult(std::move(result));
|
requestUpdate();
|
||||||
finish();
|
return;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
if ((ev.button == MappedInputManager::Button::PageForward || ev.button == MappedInputManager::Button::Right) &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
selectorIndex = ButtonNavigator::nextIndex(selectorIndex, totalItems);
|
||||||
|
requestUpdate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonNavigator.onNextRelease([this, totalItems] {
|
buttonNavigator.onNextRelease([this, totalItems] {
|
||||||
|
|||||||
@@ -16,10 +16,13 @@ void QrDisplayActivity::onEnter() {
|
|||||||
void QrDisplayActivity::onExit() { Activity::onExit(); }
|
void QrDisplayActivity::onExit() { Activity::onExit(); }
|
||||||
|
|
||||||
void QrDisplayActivity::loop() {
|
void QrDisplayActivity::loop() {
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Back) ||
|
ButtonEventManager::ButtonEvent ev;
|
||||||
mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
while (buttonEvents.consumeEvent(ev)) {
|
||||||
finish();
|
if ((ev.button == MappedInputManager::Button::Back || ev.button == MappedInputManager::Button::Confirm) &&
|
||||||
return;
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,33 +78,55 @@ void StarredPagesActivity::deleteSelected() {
|
|||||||
void StarredPagesActivity::loop() {
|
void StarredPagesActivity::loop() {
|
||||||
const int totalItems = static_cast<int>(bookmarkStore.getAll().size());
|
const int totalItems = static_cast<int>(bookmarkStore.getAll().size());
|
||||||
|
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
|
ButtonEventManager::ButtonEvent ev;
|
||||||
ActivityResult result;
|
while (buttonEvents.consumeEvent(ev)) {
|
||||||
result.isCancelled = true;
|
if (ev.button == MappedInputManager::Button::Back && ev.type == ButtonEventManager::PressType::Short) {
|
||||||
setResult(std::move(result));
|
ActivityResult result;
|
||||||
finish();
|
result.isCancelled = true;
|
||||||
return;
|
setResult(std::move(result));
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalItems > 0 && ev.button == MappedInputManager::Button::Confirm &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
const auto& bm = bookmarkStore.getAll()[selectorIndex];
|
||||||
|
setResult(StarredPageResult{bm.spineIndex, bm.pageNumber});
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalItems > 0 &&
|
||||||
|
(ev.button == MappedInputManager::Button::PageBack || ev.button == MappedInputManager::Button::Left) &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
startRename();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalItems > 0 &&
|
||||||
|
(ev.button == MappedInputManager::Button::PageForward || ev.button == MappedInputManager::Button::Right) &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
deleteSelected();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalItems > 0 && ev.button == MappedInputManager::Button::PageBack &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
selectorIndex = ButtonNavigator::previousIndex(selectorIndex, totalItems);
|
||||||
|
requestUpdate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalItems > 0 && ev.button == MappedInputManager::Button::PageForward &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
selectorIndex = ButtonNavigator::nextIndex(selectorIndex, totalItems);
|
||||||
|
requestUpdate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (totalItems == 0) return;
|
if (totalItems == 0) return;
|
||||||
|
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
|
||||||
const auto& bm = bookmarkStore.getAll()[selectorIndex];
|
|
||||||
setResult(StarredPageResult{bm.spineIndex, bm.pageNumber});
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Left)) {
|
|
||||||
startRename();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Right)) {
|
|
||||||
deleteSelected();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int pageItems = UITheme::getInstance().getNumberOfItemsPerPage(renderer, true, false, true, false);
|
const int pageItems = UITheme::getInstance().getNumberOfItemsPerPage(renderer, true, false, true, false);
|
||||||
|
|
||||||
buttonNavigator.onNextRelease([this, totalItems] {
|
buttonNavigator.onNextRelease([this, totalItems] {
|
||||||
|
|||||||
@@ -50,17 +50,35 @@ void XtcReaderChapterSelectionActivity::loop() {
|
|||||||
const int pageItems = getPageItems();
|
const int pageItems = getPageItems();
|
||||||
const int totalItems = static_cast<int>(xtc->getChapters().size());
|
const int totalItems = static_cast<int>(xtc->getChapters().size());
|
||||||
|
|
||||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm)) {
|
ButtonEventManager::ButtonEvent ev;
|
||||||
const auto& chapters = xtc->getChapters();
|
while (buttonEvents.consumeEvent(ev)) {
|
||||||
if (!chapters.empty() && selectorIndex >= 0 && selectorIndex < static_cast<int>(chapters.size())) {
|
if (ev.button == MappedInputManager::Button::Confirm && ev.type == ButtonEventManager::PressType::Short) {
|
||||||
setResult(PageResult{chapters[selectorIndex].startPage});
|
const auto& chapters = xtc->getChapters();
|
||||||
|
if (!chapters.empty() && selectorIndex >= 0 && selectorIndex < static_cast<int>(chapters.size())) {
|
||||||
|
setResult(PageResult{chapters[selectorIndex].startPage});
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ev.button == MappedInputManager::Button::Back && ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
ActivityResult result;
|
||||||
|
result.isCancelled = true;
|
||||||
|
setResult(std::move(result));
|
||||||
finish();
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((ev.button == MappedInputManager::Button::PageBack || ev.button == MappedInputManager::Button::Left) &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
selectorIndex = ButtonNavigator::previousIndex(selectorIndex, totalItems);
|
||||||
|
requestUpdate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((ev.button == MappedInputManager::Button::PageForward || ev.button == MappedInputManager::Button::Right) &&
|
||||||
|
ev.type == ButtonEventManager::PressType::Short) {
|
||||||
|
selectorIndex = ButtonNavigator::nextIndex(selectorIndex, totalItems);
|
||||||
|
requestUpdate();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else if (mappedInput.wasReleased(MappedInputManager::Button::Back)) {
|
|
||||||
ActivityResult result;
|
|
||||||
result.isCancelled = true;
|
|
||||||
setResult(std::move(result));
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonNavigator.onNextRelease([this, totalItems] {
|
buttonNavigator.onNextRelease([this, totalItems] {
|
||||||
|
|||||||
+11
-1
@@ -16,6 +16,7 @@
|
|||||||
#include <esp_ota_ops.h>
|
#include <esp_ota_ops.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "ButtonEventManager.h"
|
#include "ButtonEventManager.h"
|
||||||
#include "CrossPointSettings.h"
|
#include "CrossPointSettings.h"
|
||||||
@@ -388,6 +389,8 @@ void loop() {
|
|||||||
using BA = CrossPointSettings::BUTTON_ACTION;
|
using BA = CrossPointSettings::BUTTON_ACTION;
|
||||||
using B = MappedInputManager::Button;
|
using B = MappedInputManager::Button;
|
||||||
ButtonEventManager::ButtonEvent ev;
|
ButtonEventManager::ButtonEvent ev;
|
||||||
|
std::vector<ButtonEventManager::ButtonEvent> defaultEvents;
|
||||||
|
defaultEvents.reserve(8);
|
||||||
while (buttonEventManager.consumeEvent(ev)) {
|
while (buttonEventManager.consumeEvent(ev)) {
|
||||||
auto actionFor = [&](B btn) -> uint8_t {
|
auto actionFor = [&](B btn) -> uint8_t {
|
||||||
switch (btn) {
|
switch (btn) {
|
||||||
@@ -468,7 +471,10 @@ void loop() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t action = actionFor(ev.button);
|
const uint8_t action = actionFor(ev.button);
|
||||||
if (action == BA::BTN_DEFAULT) continue;
|
if (action == BA::BTN_DEFAULT) {
|
||||||
|
defaultEvents.push_back(ev);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (static_cast<BA>(action)) {
|
switch (static_cast<BA>(action)) {
|
||||||
case BA::BTN_PAGE_FORWARD:
|
case BA::BTN_PAGE_FORWARD:
|
||||||
@@ -525,6 +531,10 @@ void loop() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto it = defaultEvents.rbegin(); it != defaultEvents.rend(); ++it) {
|
||||||
|
buttonEventManager.pushEventFront(it->button, it->type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned long activityStartTime = millis();
|
const unsigned long activityStartTime = millis();
|
||||||
|
|||||||
Reference in New Issue
Block a user