Amend button behaviour
This commit is contained in:
@@ -615,3 +615,4 @@ STR_KB_HINT_LOWER_SECONDARY: "Hold SELECT for lowercase or secondary char"
|
|||||||
STR_KB_HINT_URL_SNIPPETS: "Press URL for snippets"
|
STR_KB_HINT_URL_SNIPPETS: "Press URL for snippets"
|
||||||
STR_BIONIC_READING: "Bionic Reading"
|
STR_BIONIC_READING: "Bionic Reading"
|
||||||
STR_BTN_ACT_TOGGLE_BIONIC_READING: "Toggle Bionic Reading"
|
STR_BTN_ACT_TOGGLE_BIONIC_READING: "Toggle Bionic Reading"
|
||||||
|
STR_BTN_ACT_CYCLE_FONT_SIZE: "Cycle Font Size"
|
||||||
|
|||||||
@@ -287,8 +287,9 @@ class CrossPointSettings {
|
|||||||
BTN_PREV_SECTION,
|
BTN_PREV_SECTION,
|
||||||
BTN_EXIT_READER,
|
BTN_EXIT_READER,
|
||||||
BTN_READER_MENU,
|
BTN_READER_MENU,
|
||||||
BTN_KOREADER_SYNC,
|
|
||||||
BTN_TOGGLE_BIONIC_READING,
|
BTN_TOGGLE_BIONIC_READING,
|
||||||
|
BTN_KOREADER_SYNC,
|
||||||
|
BTN_CYCLE_FONT_SIZE,
|
||||||
BUTTON_ACTION_COUNT
|
BUTTON_ACTION_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+8
-7
@@ -140,13 +140,14 @@ inline const std::vector<SettingInfo> list = {
|
|||||||
// All entries share the same ordered action-label list; the submenu groups them behind
|
// All entries share the same ordered action-label list; the submenu groups them behind
|
||||||
// a single placeholder row in the device UI.
|
// a single placeholder row in the device UI.
|
||||||
// Shared action options (everything except the first "default" entry).
|
// Shared action options (everything except the first "default" entry).
|
||||||
#define BTN_ACT_OPTIONS \
|
#define BTN_ACT_OPTIONS \
|
||||||
StrId::STR_BTN_ACT_PAGE_FORWARD, StrId::STR_BTN_ACT_PAGE_BACK, StrId::STR_BTN_ACT_PAGE_FORWARD_10, \
|
StrId::STR_BTN_ACT_PAGE_FORWARD, StrId::STR_BTN_ACT_PAGE_BACK, StrId::STR_BTN_ACT_PAGE_FORWARD_10, \
|
||||||
StrId::STR_BTN_ACT_PAGE_BACK_10, StrId::STR_BTN_ACT_GO_HOME, StrId::STR_BTN_ACT_SLEEP, \
|
StrId::STR_BTN_ACT_PAGE_BACK_10, StrId::STR_BTN_ACT_GO_HOME, StrId::STR_BTN_ACT_SLEEP, \
|
||||||
StrId::STR_BTN_ACT_FORCE_REFRESH, StrId::STR_BTN_ACT_FORCE_FAST_REFRESH, StrId::STR_BTN_ACT_OPEN_TOC, \
|
StrId::STR_BTN_ACT_FORCE_REFRESH, StrId::STR_BTN_ACT_FORCE_FAST_REFRESH, StrId::STR_BTN_ACT_OPEN_TOC, \
|
||||||
StrId::STR_BTN_ACT_OPEN_BOOKMARKS, StrId::STR_BTN_ACT_STAR_PAGE, StrId::STR_BTN_ACT_FOOTNOTES, \
|
StrId::STR_BTN_ACT_OPEN_BOOKMARKS, StrId::STR_BTN_ACT_STAR_PAGE, StrId::STR_BTN_ACT_FOOTNOTES, \
|
||||||
StrId::STR_BTN_ACT_NEXT_SECTION, StrId::STR_BTN_ACT_PREV_SECTION, StrId::STR_BTN_ACT_EXIT_READER, \
|
StrId::STR_BTN_ACT_NEXT_SECTION, StrId::STR_BTN_ACT_PREV_SECTION, StrId::STR_BTN_ACT_EXIT_READER, \
|
||||||
StrId::STR_BTN_ACT_READER_MENU, StrId::STR_BTN_ACT_TOGGLE_BIONIC_READING, StrId::STR_BTN_ACT_KOREADER_SYNC
|
StrId::STR_BTN_ACT_READER_MENU, StrId::STR_BTN_ACT_TOGGLE_BIONIC_READING, StrId::STR_BTN_ACT_KOREADER_SYNC, \
|
||||||
|
StrId::STR_BTN_ACT_CYCLE_FONT_SIZE
|
||||||
|
|
||||||
// Back button: short=exit reader, double=ignore, long=go home
|
// Back button: short=exit reader, double=ignore, long=go home
|
||||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortBack, {StrId::STR_BTN_DEF_EXIT_READER},
|
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortBack, {StrId::STR_BTN_DEF_EXIT_READER},
|
||||||
|
|||||||
@@ -2006,6 +2006,16 @@ void EpubReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION
|
|||||||
requestUpdate();
|
requestUpdate();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case BA::BTN_CYCLE_FONT_SIZE:
|
||||||
|
if (epub) {
|
||||||
|
const uint8_t current =
|
||||||
|
(bookFontSizeOverride >= 0) ? static_cast<uint8_t>(bookFontSizeOverride) : SETTINGS.fontSize;
|
||||||
|
const int8_t next = static_cast<int8_t>((current + 1) % CrossPointSettings::FONT_SIZE_COUNT);
|
||||||
|
applyBookReaderOverrides(bookEmbeddedStyleOverride, bookImageRenderingOverride, bookFontFamilyOverride,
|
||||||
|
bookSdFontFamilyOverride, next, bookBionicReadingOverride);
|
||||||
|
requestUpdate();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case BA::BTN_KOREADER_SYNC:
|
case BA::BTN_KOREADER_SYNC:
|
||||||
launchKOReaderSync(SyncLaunchMode::COMPARE);
|
launchKOReaderSync(SyncLaunchMode::COMPARE);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -539,6 +539,12 @@ void loop() {
|
|||||||
case BA::BTN_KOREADER_SYNC:
|
case BA::BTN_KOREADER_SYNC:
|
||||||
activityManager.dispatchButtonAction(BA::BTN_KOREADER_SYNC);
|
activityManager.dispatchButtonAction(BA::BTN_KOREADER_SYNC);
|
||||||
break;
|
break;
|
||||||
|
case BA::BTN_TOGGLE_BIONIC_READING:
|
||||||
|
activityManager.dispatchButtonAction(BA::BTN_TOGGLE_BIONIC_READING);
|
||||||
|
break;
|
||||||
|
case BA::BTN_CYCLE_FONT_SIZE:
|
||||||
|
activityManager.dispatchButtonAction(BA::BTN_CYCLE_FONT_SIZE);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "ButtonNavigator.h"
|
#include "ButtonNavigator.h"
|
||||||
|
|
||||||
#include "ButtonEventManager.h"
|
#include "ButtonEventManager.h"
|
||||||
|
#include "activities/ActivityManager.h"
|
||||||
|
|
||||||
const MappedInputManager* ButtonNavigator::mappedInput = nullptr;
|
const MappedInputManager* ButtonNavigator::mappedInput = nullptr;
|
||||||
|
|
||||||
@@ -42,15 +43,25 @@ void ButtonNavigator::onPress(const Buttons& buttons, const Callback& callback)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ButtonNavigator::onRelease(const Buttons& buttons, const Callback& callback) {
|
void ButtonNavigator::onRelease(const Buttons& buttons, const Callback& callback) {
|
||||||
const bool wasReleased = std::any_of(buttons.begin(), buttons.end(), [](const MappedInputManager::Button button) {
|
// The double-click FSM in ButtonEventManager delays Short events by DOUBLE_WINDOW_MS
|
||||||
if (mappedInput == nullptr || !mappedInput->wasReleased(button)) {
|
// (300ms) when a double-press action is configured for that button, so the configured
|
||||||
return false;
|
// Short and Double actions can be disambiguated. In a reader activity that gating must
|
||||||
}
|
// suppress release-based navigation during the wait, otherwise Left/Right would both
|
||||||
|
// turn the page AND fire the configured short action.
|
||||||
// If a button Short is still pending while we wait for a possible double,
|
//
|
||||||
// avoid firing release-based navigation first.
|
// In non-reader UIs (settings, file browser, etc.), only navigation reacts to release —
|
||||||
return !globalButtonEvents().isShortPending(button);
|
// the configured per-button actions are not dispatched there (see
|
||||||
});
|
// ActivityManager::dispatchButtonAction, which is reader-only). Gating on isShortPending
|
||||||
|
// there just makes Left/Right navigation feel sluggish (300ms lag) compared to Up/Down
|
||||||
|
// (which have no FSM at all). So skip the gate outside reader activities.
|
||||||
|
const bool inReader = activityManager.isReaderActivity();
|
||||||
|
const bool wasReleased =
|
||||||
|
std::any_of(buttons.begin(), buttons.end(), [inReader](const MappedInputManager::Button button) {
|
||||||
|
if (mappedInput == nullptr || !mappedInput->wasReleased(button)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !(inReader && globalButtonEvents().isShortPending(button));
|
||||||
|
});
|
||||||
|
|
||||||
if (wasReleased) {
|
if (wasReleased) {
|
||||||
if (lastContinuousNavTime == 0) {
|
if (lastContinuousNavTime == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user