Review changes

This commit is contained in:
jpirnay
2026-04-27 14:38:20 +02:00
parent 2bce78c07a
commit ea99b764ce
13 changed files with 172 additions and 213 deletions
@@ -16,10 +16,6 @@
#include "components/UITheme.h" #include "components/UITheme.h"
#include "fontIds.h" #include "fontIds.h"
namespace {
constexpr unsigned long GO_HOME_MS = 1000;
} // namespace
void sortFileList(std::vector<std::string>& strs) { void sortFileList(std::vector<std::string>& strs) {
std::sort(begin(strs), end(strs), [](const std::string& str1, const std::string& str2) { std::sort(begin(strs), end(strs), [](const std::string& str1, const std::string& str2) {
// Directories first // Directories first
+34 -59
View File
@@ -219,12 +219,14 @@ void EpubReaderActivity::loop() {
} }
if (inputDrainGuard.shouldDrain(mappedInput)) { if (inputDrainGuard.shouldDrain(mappedInput)) {
buttonEvents.drain();
return; return;
} }
if (automaticPageTurnActive) { if (automaticPageTurnActive) {
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm) || if (mappedInput.wasReleased(MappedInputManager::Button::Confirm) ||
mappedInput.wasReleased(MappedInputManager::Button::Back)) { mappedInput.wasReleased(MappedInputManager::Button::Back)) {
buttonEvents.drain();
automaticPageTurnActive = false; automaticPageTurnActive = false;
// updates chapter title space to indicate page turn disabled // updates chapter title space to indicate page turn disabled
requestUpdate(); requestUpdate();
@@ -260,36 +262,7 @@ void EpubReaderActivity::loop() {
return; return;
} }
if (ev.type == ButtonEventManager::PressType::Short) { if (ev.type == ButtonEventManager::PressType::Short) {
const int currentPage = section ? section->currentPage + 1 : 0; openReaderMenu();
const int totalPages = section ? section->pageCount : 0;
float bookProgress = 0.0f;
if (epub->getBookSize() > 0 && section && section->pageCount > 0) {
const float chapterProgress =
static_cast<float>(section->currentPage) / static_cast<float>(section->pageCount);
bookProgress = epub->calculateProgress(currentSpineIndex, chapterProgress) * 100.0f;
}
const int bookProgressPercent = clampPercent(static_cast<int>(bookProgress + 0.5f));
const bool isCurrentPageStarred = section && bookmarkStore.has(static_cast<uint16_t>(currentSpineIndex),
static_cast<uint16_t>(section->currentPage));
ReaderUtils::enforceExitFullRefresh(renderer);
startActivityForResult(
std::make_unique<EpubReaderMenuActivity>(
renderer, mappedInput, epub->getTitle(), currentPage, totalPages, bookProgressPercent,
SETTINGS.orientation, !currentPageFootnotes.empty(), bookEmbeddedStyleOverride,
bookImageRenderingOverride, bookFontFamilyOverride, bookFontSizeOverride, SETTINGS.textDarkness,
!bookmarkStore.isEmpty(), isCurrentPageStarred),
[this](const ActivityResult& result) {
// Always apply orientation/darkness change even if the menu was cancelled
const auto& menu = std::get<MenuResult>(result.data);
applyOrientation(menu.orientation);
applyTextDarkness(menu.textDarkness);
toggleAutoPageTurn(menu.pageTurnOption);
applyBookReaderOverrides(menu.embeddedStyleOverride, menu.imageRenderingOverride, menu.fontFamilyOverride,
menu.fontSizeOverride);
if (!result.isCancelled) {
onReaderMenuConfirm(static_cast<EpubReaderMenuActivity::MenuAction>(menu.action));
}
});
return; return;
} }
} }
@@ -1741,6 +1714,36 @@ bool EpubReaderActivity::drawCurrentPageToBuffer(const std::string& filePath, Gf
return true; return true;
} }
void EpubReaderActivity::openReaderMenu() {
const int currentPage = section ? section->currentPage + 1 : 0;
const int totalPages = section ? section->pageCount : 0;
float bookProgress = 0.0f;
if (epub->getBookSize() > 0 && section && section->pageCount > 0) {
const float chapterProgress = static_cast<float>(section->currentPage) / static_cast<float>(section->pageCount);
bookProgress = epub->calculateProgress(currentSpineIndex, chapterProgress) * 100.0f;
}
const int bookProgressPercent = clampPercent(static_cast<int>(bookProgress + 0.5f));
const bool isCurrentPageStarred = section && bookmarkStore.has(static_cast<uint16_t>(currentSpineIndex),
static_cast<uint16_t>(section->currentPage));
ReaderUtils::enforceExitFullRefresh(renderer);
startActivityForResult(
std::make_unique<EpubReaderMenuActivity>(
renderer, mappedInput, epub->getTitle(), currentPage, totalPages, bookProgressPercent, SETTINGS.orientation,
!currentPageFootnotes.empty(), bookEmbeddedStyleOverride, bookImageRenderingOverride, bookFontFamilyOverride,
bookFontSizeOverride, SETTINGS.textDarkness, !bookmarkStore.isEmpty(), isCurrentPageStarred),
[this](const ActivityResult& result) {
const auto& menu = std::get<MenuResult>(result.data);
applyOrientation(menu.orientation);
applyTextDarkness(menu.textDarkness);
toggleAutoPageTurn(menu.pageTurnOption);
applyBookReaderOverrides(menu.embeddedStyleOverride, menu.imageRenderingOverride, menu.fontFamilyOverride,
menu.fontSizeOverride);
if (!result.isCancelled) {
onReaderMenuConfirm(static_cast<EpubReaderMenuActivity::MenuAction>(menu.action));
}
});
}
void EpubReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION action) { void EpubReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION action) {
using BA = CrossPointSettings::BUTTON_ACTION; using BA = CrossPointSettings::BUTTON_ACTION;
switch (action) { switch (action) {
@@ -1859,35 +1862,7 @@ void EpubReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION
break; break;
case BA::BTN_READER_MENU: case BA::BTN_READER_MENU:
if (epub) { if (epub) {
const int currentPage = section ? section->currentPage + 1 : 0; openReaderMenu();
const int totalPages = section ? section->pageCount : 0;
float bookProgress = 0.0f;
if (epub->getBookSize() > 0 && section && section->pageCount > 0) {
const float chapterProgress =
static_cast<float>(section->currentPage) / static_cast<float>(section->pageCount);
bookProgress = epub->calculateProgress(currentSpineIndex, chapterProgress) * 100.0f;
}
const int bookProgressPercent = clampPercent(static_cast<int>(bookProgress + 0.5f));
const bool isCurrentPageStarred = section && bookmarkStore.has(static_cast<uint16_t>(currentSpineIndex),
static_cast<uint16_t>(section->currentPage));
ReaderUtils::enforceExitFullRefresh(renderer);
startActivityForResult(
std::make_unique<EpubReaderMenuActivity>(
renderer, mappedInput, epub->getTitle(), currentPage, totalPages, bookProgressPercent,
SETTINGS.orientation, !currentPageFootnotes.empty(), bookEmbeddedStyleOverride,
bookImageRenderingOverride, bookFontFamilyOverride, bookFontSizeOverride, SETTINGS.textDarkness,
!bookmarkStore.isEmpty(), isCurrentPageStarred),
[this](const ActivityResult& result) {
const auto& menu = std::get<MenuResult>(result.data);
applyOrientation(menu.orientation);
applyTextDarkness(menu.textDarkness);
toggleAutoPageTurn(menu.pageTurnOption);
applyBookReaderOverrides(menu.embeddedStyleOverride, menu.imageRenderingOverride, menu.fontFamilyOverride,
menu.fontSizeOverride);
if (!result.isCancelled) {
onReaderMenuConfirm(static_cast<EpubReaderMenuActivity::MenuAction>(menu.action));
}
});
} }
break; break;
case BA::BTN_KOREADER_SYNC: case BA::BTN_KOREADER_SYNC:
@@ -166,6 +166,7 @@ class EpubReaderActivity final : public Activity {
void toggleAutoPageTurn(uint8_t selectedPageTurnOption); void toggleAutoPageTurn(uint8_t selectedPageTurnOption);
void applyBookReaderOverrides(int8_t embeddedStyleOverride, int8_t imageRenderingOverride, int8_t fontFamilyOverride, void applyBookReaderOverrides(int8_t embeddedStyleOverride, int8_t imageRenderingOverride, int8_t fontFamilyOverride,
int8_t fontSizeOverride); int8_t fontSizeOverride);
void openReaderMenu();
bool getEffectiveEmbeddedStyle() const; bool getEffectiveEmbeddedStyle() const;
uint8_t getEffectiveImageRendering() const; uint8_t getEffectiveImageRendering() const;
int getEffectiveReaderFontId() const; int getEffectiveReaderFontId() const;
@@ -38,50 +38,33 @@ void EpubReaderFootnotesActivity::loop() {
if ((ev.button == MappedInputManager::Button::PageBack || ev.button == MappedInputManager::Button::Left) && if ((ev.button == MappedInputManager::Button::PageBack || ev.button == MappedInputManager::Button::Left) &&
ev.type == ButtonEventManager::PressType::Short) { ev.type == ButtonEventManager::PressType::Short) {
if (!footnotes.empty()) { advanceSelection(-1);
selectedIndex = (selectedIndex - 1 + footnotes.size()) % footnotes.size();
requestUpdate();
}
return; return;
} }
if ((ev.button == MappedInputManager::Button::PageForward || ev.button == MappedInputManager::Button::Right) && if ((ev.button == MappedInputManager::Button::PageForward || ev.button == MappedInputManager::Button::Right) &&
ev.type == ButtonEventManager::PressType::Short) { ev.type == ButtonEventManager::PressType::Short) {
if (!footnotes.empty()) { advanceSelection(1);
selectedIndex = (selectedIndex + 1) % footnotes.size();
requestUpdate();
}
return; return;
} }
} }
buttonNavigator.onNextRelease([this] { buttonNavigator.onNextRelease([this] { advanceSelection(1); });
if (!footnotes.empty()) {
selectedIndex = (selectedIndex + 1) % footnotes.size();
requestUpdate();
}
});
buttonNavigator.onPreviousRelease([this] { buttonNavigator.onPreviousRelease([this] { advanceSelection(-1); });
if (!footnotes.empty()) {
selectedIndex = (selectedIndex - 1 + footnotes.size()) % footnotes.size();
requestUpdate();
}
});
buttonNavigator.onNextContinuous([this] { buttonNavigator.onNextContinuous([this] { advanceSelection(1); });
if (!footnotes.empty()) {
selectedIndex = (selectedIndex + 1) % footnotes.size();
requestUpdate();
}
});
buttonNavigator.onPreviousContinuous([this] { buttonNavigator.onPreviousContinuous([this] { advanceSelection(-1); });
if (!footnotes.empty()) { }
selectedIndex = (selectedIndex - 1 + footnotes.size()) % footnotes.size();
requestUpdate(); void EpubReaderFootnotesActivity::advanceSelection(int delta) {
} if (footnotes.empty()) {
}); return;
}
const int n = static_cast<int>(footnotes.size());
selectedIndex = ((selectedIndex + delta) % n + n) % n;
requestUpdate();
} }
void EpubReaderFootnotesActivity::render(RenderLock&&) { void EpubReaderFootnotesActivity::render(RenderLock&&) {
@@ -21,6 +21,7 @@ class EpubReaderFootnotesActivity final : public Activity {
void render(RenderLock&&) override; void render(RenderLock&&) override;
private: private:
void advanceSelection(int delta);
const std::vector<FootnoteEntry>& footnotes; const std::vector<FootnoteEntry>& footnotes;
int selectedIndex = 0; int selectedIndex = 0;
int scrollOffset = 0; int scrollOffset = 0;
@@ -38,6 +38,8 @@ static std::string flattenHeadingText(const MdParser::ParsedLine& parsed) {
void MdReaderActivity::onEnter() { void MdReaderActivity::onEnter() {
Activity::onEnter(); Activity::onEnter();
inputDrainGuard.arm();
if (!txt) { if (!txt) {
return; return;
} }
@@ -221,6 +223,11 @@ void MdReaderActivity::onExit() {
} }
void MdReaderActivity::loop() { void MdReaderActivity::loop() {
if (inputDrainGuard.shouldDrain(mappedInput)) {
buttonEvents.drain();
return;
}
ButtonEventManager::ButtonEvent ev; ButtonEventManager::ButtonEvent ev;
while (buttonEvents.consumeEvent(ev)) { while (buttonEvents.consumeEvent(ev)) {
if (ev.button == MappedInputManager::Button::Back) { if (ev.button == MappedInputManager::Button::Back) {
+2
View File
@@ -6,6 +6,7 @@
#include <vector> #include <vector>
#include "CrossPointSettings.h" #include "CrossPointSettings.h"
#include "ReaderUtils.h"
#include "activities/Activity.h" #include "activities/Activity.h"
struct MdHeading { struct MdHeading {
@@ -72,6 +73,7 @@ class MdReaderActivity final : public Activity {
void assignHeadingPageNumbers(); void assignHeadingPageNumbers();
int getHeadingIndexForOffset(size_t offset) const; int getHeadingIndexForOffset(size_t offset) const;
void jumpToHeading(bool next); void jumpToHeading(bool next);
ReaderUtils::InputDrainGuard inputDrainGuard;
// Word-wrap a parsed markdown line into one or more RenderedLines. // Word-wrap a parsed markdown line into one or more RenderedLines.
// Returns true if all content was emitted, false if truncated by maxLines. // Returns true if all content was emitted, false if truncated by maxLines.
@@ -109,20 +109,6 @@ void StarredPagesActivity::loop() {
deleteSelected(); deleteSelected();
return; 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;
@@ -137,6 +137,7 @@ void TxtReaderActivity::onExit() {
void TxtReaderActivity::loop() { void TxtReaderActivity::loop() {
if (inputDrainGuard.shouldDrain(mappedInput)) { if (inputDrainGuard.shouldDrain(mappedInput)) {
buttonEvents.drain();
return; return;
} }
+1 -7
View File
@@ -22,10 +22,6 @@
#include "XtcReaderChapterSelectionActivity.h" #include "XtcReaderChapterSelectionActivity.h"
#include "fontIds.h" #include "fontIds.h"
namespace {
constexpr unsigned long goHomeMs = 1000;
} // namespace
void XtcReaderActivity::onEnter() { void XtcReaderActivity::onEnter() {
Activity::onEnter(); Activity::onEnter();
@@ -61,6 +57,7 @@ void XtcReaderActivity::onExit() {
void XtcReaderActivity::loop() { void XtcReaderActivity::loop() {
if (inputDrainGuard.shouldDrain(mappedInput)) { if (inputDrainGuard.shouldDrain(mappedInput)) {
buttonEvents.drain();
return; return;
} }
@@ -146,9 +143,6 @@ void XtcReaderActivity::loop() {
} }
} else if (nextTriggered) { } else if (nextTriggered) {
currentPage++; currentPage++;
if (currentPage >= xtc->getPageCount()) {
currentPage = xtc->getPageCount(); // Allow showing "End of book"
}
requestUpdate(); requestUpdate();
} }
} }
@@ -5,6 +5,7 @@
#include <algorithm> #include <algorithm>
#include "ButtonEventManager.h"
#include "MappedInputManager.h" #include "MappedInputManager.h"
#include "components/UITheme.h" #include "components/UITheme.h"
#include "fontIds.h" #include "fontIds.h"
@@ -47,6 +48,10 @@ void XtcReaderChapterSelectionActivity::onEnter() {
void XtcReaderChapterSelectionActivity::onExit() { Activity::onExit(); } void XtcReaderChapterSelectionActivity::onExit() { Activity::onExit(); }
void XtcReaderChapterSelectionActivity::loop() { void XtcReaderChapterSelectionActivity::loop() {
if (!xtc) {
return;
}
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());
@@ -82,11 +87,19 @@ void XtcReaderChapterSelectionActivity::loop() {
} }
buttonNavigator.onNextRelease([this, totalItems] { buttonNavigator.onNextRelease([this, totalItems] {
if (ButtonEventManager::hasDoubleAction(MappedInputManager::Button::Right) ||
ButtonEventManager::hasDoubleAction(MappedInputManager::Button::PageForward)) {
return;
}
selectorIndex = ButtonNavigator::nextIndex(selectorIndex, totalItems); selectorIndex = ButtonNavigator::nextIndex(selectorIndex, totalItems);
requestUpdate(); requestUpdate();
}); });
buttonNavigator.onPreviousRelease([this, totalItems] { buttonNavigator.onPreviousRelease([this, totalItems] {
if (ButtonEventManager::hasDoubleAction(MappedInputManager::Button::Left) ||
ButtonEventManager::hasDoubleAction(MappedInputManager::Button::PageBack)) {
return;
}
selectorIndex = ButtonNavigator::previousIndex(selectorIndex, totalItems); selectorIndex = ButtonNavigator::previousIndex(selectorIndex, totalItems);
requestUpdate(); requestUpdate();
}); });
+16 -18
View File
@@ -388,7 +388,7 @@ void BmpViewerActivity::loop() {
// Keep CPU awake/polling so 1st click works // Keep CPU awake/polling so 1st click works
Activity::loop(); Activity::loop();
// Long press BACK (1s+) goes to home screen const bool toggleSupported = isBmpFile(filePath) ? bmpHasGreyscale : true;
ButtonEventManager::ButtonEvent ev; ButtonEventManager::ButtonEvent ev;
while (buttonEvents.consumeEvent(ev)) { while (buttonEvents.consumeEvent(ev)) {
if (ev.button == MappedInputManager::Button::Back) { if (ev.button == MappedInputManager::Button::Back) {
@@ -401,27 +401,25 @@ void BmpViewerActivity::loop() {
return; return;
} }
} }
}
// Confirm: toggle between 1-bit B&W and 4-level grayscale display. if (ev.button == MappedInputManager::Button::Confirm && ev.type == ButtonEventManager::PressType::Short) {
// For decoded images this always applies; for BMPs it only makes sense when the bitmap if (toggleSupported) {
// actually carries greyscale data (1-bit BMPs have nothing to toggle). toggleDisplayMode();
const bool toggleSupported = isBmpFile(filePath) ? bmpHasGreyscale : true; }
if (toggleSupported && mappedInput.wasReleased(MappedInputManager::Button::Confirm)) { return;
toggleDisplayMode(); }
return;
}
#ifdef ENABLE_IMAGE_DITHERING_EXTENSION #ifdef ENABLE_IMAGE_DITHERING_EXTENSION
if (!isBmpFile(filePath) && grayscaleDisplay && mappedInput.wasReleased(MappedInputManager::Button::Left)) { if (ev.button == MappedInputManager::Button::Left && ev.type == ButtonEventManager::PressType::Short &&
cycleDitherMode(); !isBmpFile(filePath) && grayscaleDisplay) {
return; cycleDitherMode();
} return;
}
#endif #endif
// Next/Right button: set this image as the sleep screen if (ev.button == MappedInputManager::Button::Right && ev.type == ButtonEventManager::PressType::Short) {
if (mappedInput.wasReleased(MappedInputManager::Button::Right)) { setAsSleepScreen();
setAsSleepScreen(); return;
return; }
} }
} }
+81 -79
View File
@@ -388,90 +388,92 @@ void loop() {
{ {
using BA = CrossPointSettings::BUTTON_ACTION; using BA = CrossPointSettings::BUTTON_ACTION;
using B = MappedInputManager::Button; using B = MappedInputManager::Button;
auto actionFor = [&](const ButtonEventManager::ButtonEvent& ev) -> uint8_t {
switch (ev.button) {
case B::Back:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortBack;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoubleBack;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongBack;
}
break;
case B::Confirm:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortConfirm;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoubleConfirm;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongConfirm;
}
break;
case B::Left:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortLeft;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoubleLeft;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongLeft;
}
break;
case B::Right:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortRight;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoubleRight;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongRight;
}
break;
case B::PageBack:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortPageBack;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoublePageBack;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongPageBack;
}
break;
case B::PageForward:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortPageForward;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoublePageForward;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongPageForward;
}
break;
case B::Power:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortPower;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoublePower;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongPower;
}
break;
default:
break; // Up/Down have no FSMs — ButtonEventManager never emits these
}
return BA::BTN_DEFAULT;
};
ButtonEventManager::ButtonEvent ev; ButtonEventManager::ButtonEvent ev;
std::vector<ButtonEventManager::ButtonEvent> defaultEvents; std::vector<ButtonEventManager::ButtonEvent> defaultEvents;
defaultEvents.reserve(8); defaultEvents.reserve(8);
while (buttonEventManager.consumeEvent(ev)) { while (buttonEventManager.consumeEvent(ev)) {
auto actionFor = [&](B btn) -> uint8_t { const uint8_t action = actionFor(ev);
switch (btn) {
case B::Back:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortBack;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoubleBack;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongBack;
}
break;
case B::Confirm:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortConfirm;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoubleConfirm;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongConfirm;
}
break;
case B::Left:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortLeft;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoubleLeft;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongLeft;
}
break;
case B::Right:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortRight;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoubleRight;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongRight;
}
break;
case B::PageBack:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortPageBack;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoublePageBack;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongPageBack;
}
break;
case B::PageForward:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortPageForward;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoublePageForward;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongPageForward;
}
break;
case B::Power:
switch (ev.type) {
case ButtonEventManager::PressType::Short:
return SETTINGS.btnShortPower;
case ButtonEventManager::PressType::Double:
return SETTINGS.btnDoublePower;
case ButtonEventManager::PressType::Long:
return SETTINGS.btnLongPower;
}
break;
default:
break; // Up/Down have no FSMs — ButtonEventManager never emits these
}
return BA::BTN_DEFAULT;
};
const uint8_t action = actionFor(ev.button);
if (action == BA::BTN_DEFAULT) { if (action == BA::BTN_DEFAULT) {
if (ev.type == ButtonEventManager::PressType::Double) {
continue;
}
defaultEvents.push_back(ev); defaultEvents.push_back(ev);
continue; continue;
} }