Update logic to avoid collision
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -2,11 +2,16 @@
|
||||
|
||||
#include "CrossPointSettings.h"
|
||||
|
||||
// Required for constexpr array definition in .cpp
|
||||
// Required for constexpr array out-of-class definition (C++14).
|
||||
constexpr ButtonEventManager::Button ButtonEventManager::ALL_BUTTONS[ButtonEventManager::NUM_BUTTONS];
|
||||
|
||||
bool ButtonEventManager::hasDoubleAction(const Button button) {
|
||||
using BA = CrossPointSettings::BUTTON_ACTION;
|
||||
// Up/Down share physical pins with PageBack/PageForward via sideButtonLayout.
|
||||
// Their double-action settings must be consulted when checking the PageBack/PageForward FSMs
|
||||
// so that the disambiguation delay is applied when either role has a double action.
|
||||
const bool prevNext = static_cast<CrossPointSettings::SIDE_BUTTON_LAYOUT>(SETTINGS.sideButtonLayout) ==
|
||||
CrossPointSettings::SIDE_BUTTON_LAYOUT::PREV_NEXT;
|
||||
switch (button) {
|
||||
case Button::Back:
|
||||
return SETTINGS.btnDoubleBack != BA::BTN_DEFAULT;
|
||||
@@ -17,13 +22,16 @@ bool ButtonEventManager::hasDoubleAction(const Button button) {
|
||||
case Button::Right:
|
||||
return SETTINGS.btnDoubleRight != BA::BTN_DEFAULT;
|
||||
case Button::Up:
|
||||
return SETTINGS.btnDoubleUp != BA::BTN_DEFAULT;
|
||||
case Button::Down:
|
||||
return SETTINGS.btnDoubleDown != BA::BTN_DEFAULT;
|
||||
return false; // Up/Down have no dedicated FSM; handled via PageBack/PageForward
|
||||
case Button::PageBack:
|
||||
return SETTINGS.btnDoublePageBack != BA::BTN_DEFAULT;
|
||||
// PREV_NEXT: BTN_UP = PageBack; NEXT_PREV: BTN_DOWN = PageBack
|
||||
return SETTINGS.btnDoublePageBack != BA::BTN_DEFAULT ||
|
||||
(prevNext ? SETTINGS.btnDoubleUp : SETTINGS.btnDoubleDown) != BA::BTN_DEFAULT;
|
||||
case Button::PageForward:
|
||||
return SETTINGS.btnDoublePageForward != BA::BTN_DEFAULT;
|
||||
// PREV_NEXT: BTN_DOWN = PageForward; NEXT_PREV: BTN_UP = PageForward
|
||||
return SETTINGS.btnDoublePageForward != BA::BTN_DEFAULT ||
|
||||
(prevNext ? SETTINGS.btnDoubleDown : SETTINGS.btnDoubleUp) != BA::BTN_DEFAULT;
|
||||
case Button::Power:
|
||||
return SETTINGS.btnDoublePower != BA::BTN_DEFAULT;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ class ButtonEventManager {
|
||||
public:
|
||||
using Button = MappedInputManager::Button;
|
||||
|
||||
static constexpr int NUM_BUTTONS = 9; // matches MappedInputManager::Button count
|
||||
|
||||
enum class PressType { Short, Double, Long };
|
||||
|
||||
struct ButtonEvent {
|
||||
@@ -56,9 +54,13 @@ class ButtonEventManager {
|
||||
static bool hasDoubleAction(Button button);
|
||||
|
||||
private:
|
||||
// Up and Down alias the same physical GPIO pins as PageBack/PageForward (via sideButtonLayout).
|
||||
// Running separate FSMs for both would double-fire on every side button press.
|
||||
// Up/Down are therefore excluded here; their configurable actions are resolved in main.cpp
|
||||
// by treating a PageBack/PageForward event as the canonical side-button event.
|
||||
static constexpr int NUM_BUTTONS = 7;
|
||||
static constexpr Button ALL_BUTTONS[NUM_BUTTONS] = {
|
||||
Button::Back, Button::Confirm, Button::Left, Button::Right, Button::Up,
|
||||
Button::Down, Button::PageBack, Button::PageForward, Button::Power,
|
||||
Button::Back, Button::Confirm, Button::Left, Button::Right, Button::PageBack, Button::PageForward, Button::Power,
|
||||
};
|
||||
|
||||
enum class State { Idle, Pressed, ReleasedOnce, DoublePressed };
|
||||
|
||||
@@ -140,7 +140,10 @@ bool CrossPointSettings::loadFromBinaryFile() {
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
serialization::readPod(inputFile, extraParagraphSpacing);
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
readAndValidate(inputFile, shortPwrBtn, SHORT_PWRBTN_COUNT);
|
||||
{
|
||||
uint8_t ignored;
|
||||
serialization::readPod(inputFile, ignored);
|
||||
} // legacy shortPwrBtn field
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
readAndValidate(inputFile, statusBar, STATUS_BAR_MODE_COUNT); // legacy
|
||||
if (++settingsRead >= fileSettingsCount) break;
|
||||
|
||||
@@ -127,17 +127,6 @@ class CrossPointSettings {
|
||||
REFRESH_FREQUENCY_COUNT
|
||||
};
|
||||
|
||||
// Short power button press actions
|
||||
enum SHORT_PWRBTN {
|
||||
IGNORE = 0,
|
||||
SLEEP = 1,
|
||||
PAGE_TURN = 2,
|
||||
FORCE_REFRESH = 3,
|
||||
FOOTNOTES = 4,
|
||||
STAR_PAGE = 5,
|
||||
SHORT_PWRBTN_COUNT
|
||||
};
|
||||
|
||||
// Hide battery percentage
|
||||
enum HIDE_BATTERY_PERCENTAGE { HIDE_NEVER = 0, HIDE_READER = 1, HIDE_ALWAYS = 2, HIDE_BATTERY_PERCENTAGE_COUNT };
|
||||
|
||||
@@ -214,8 +203,6 @@ class CrossPointSettings {
|
||||
// Text darkness (0 = normal, 1 = dark, 2 = extra dark). Default 1 preserves
|
||||
// historical AA rendering (both grayscale shades drawn in the MSB pass).
|
||||
uint8_t textDarkness = DARKNESS_DARK;
|
||||
// Short power button click behaviour
|
||||
uint8_t shortPwrBtn = IGNORE;
|
||||
// EPUB reading orientation settings
|
||||
// 0 = portrait (default), 1 = landscape clockwise, 2 = inverted, 3 = landscape counter-clockwise
|
||||
uint8_t orientation = PORTRAIT;
|
||||
@@ -294,6 +281,9 @@ class CrossPointSettings {
|
||||
BTN_FOOTNOTES,
|
||||
BTN_NEXT_SECTION,
|
||||
BTN_PREV_SECTION,
|
||||
BTN_EXIT_READER,
|
||||
BTN_READER_MENU,
|
||||
BTN_KOREADER_SYNC,
|
||||
BUTTON_ACTION_COUNT
|
||||
};
|
||||
|
||||
@@ -335,9 +325,7 @@ class CrossPointSettings {
|
||||
// Get singleton instance
|
||||
static CrossPointSettings& getInstance() { return instance; }
|
||||
|
||||
uint16_t getPowerButtonDuration() const {
|
||||
return (shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::SLEEP) ? 10 : 400;
|
||||
}
|
||||
uint16_t getPowerButtonDuration() const { return 400; }
|
||||
int getReaderFontId() const;
|
||||
|
||||
// If count_only is true, returns the number of settings items that would be written.
|
||||
|
||||
+98
-109
@@ -132,123 +132,112 @@ inline const std::vector<SettingInfo> list = {
|
||||
|
||||
// --- Controls ---
|
||||
SettingInfo::Enum(StrId::STR_SIDE_BTN_LAYOUT, &CrossPointSettings::sideButtonLayout,
|
||||
{StrId::STR_PREV_NEXT, StrId::STR_NEXT_PREV}, "sideButtonLayout", StrId::STR_CAT_CONTROLS),
|
||||
SettingInfo::Enum(StrId::STR_SHORT_PWR_BTN, &CrossPointSettings::shortPwrBtn,
|
||||
{StrId::STR_IGNORE, StrId::STR_SLEEP, StrId::STR_PAGE_TURN, StrId::STR_FORCE_REFRESH,
|
||||
StrId::STR_FOOTNOTES, StrId::STR_STAR_PAGE},
|
||||
"shortPwrBtn", StrId::STR_CAT_CONTROLS),
|
||||
{StrId::STR_PREV_NEXT, StrId::STR_NEXT_PREV}, "sideButtonLayout", StrId::STR_CAT_CONTROLS)
|
||||
.withSubcategory(StrId::STR_MENU_BTN_PHYSICAL),
|
||||
|
||||
// --- Button Actions (short / double / long press per logical button) ---
|
||||
// All entries share the same ordered action-label list; the submenu groups them behind
|
||||
// a single placeholder row in the device UI.
|
||||
#define BTN_ACTION_ENUM_VALUES \
|
||||
{StrId::STR_BTN_ACT_DEFAULT, 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_FORCE_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_NEXT_SECTION, StrId::STR_BTN_ACT_PREV_SECTION}
|
||||
// Shared action options (everything except the first "default" entry).
|
||||
#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_BACK_10, StrId::STR_BTN_ACT_GO_HOME, StrId::STR_BTN_ACT_SLEEP, \
|
||||
StrId::STR_BTN_ACT_FORCE_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_NEXT_SECTION, \
|
||||
StrId::STR_BTN_ACT_PREV_SECTION, StrId::STR_BTN_ACT_EXIT_READER, StrId::STR_BTN_ACT_READER_MENU, \
|
||||
StrId::STR_BTN_ACT_KOREADER_SYNC
|
||||
|
||||
// Back button
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortBack, BTN_ACTION_ENUM_VALUES,
|
||||
"btnShortBack", StrId::STR_CAT_CONTROLS)
|
||||
.withSubcategory(StrId::STR_BTN_BACK)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoubleBack, BTN_ACTION_ENUM_VALUES,
|
||||
"btnDoubleBack", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongBack, BTN_ACTION_ENUM_VALUES,
|
||||
"btnLongBack", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
// Confirm button
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortConfirm, BTN_ACTION_ENUM_VALUES,
|
||||
"btnShortConfirm", StrId::STR_CAT_CONTROLS)
|
||||
.withSubcategory(StrId::STR_BTN_CONFIRM)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoubleConfirm, BTN_ACTION_ENUM_VALUES,
|
||||
"btnDoubleConfirm", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongConfirm, BTN_ACTION_ENUM_VALUES,
|
||||
"btnLongConfirm", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
// Left button
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortLeft, BTN_ACTION_ENUM_VALUES,
|
||||
"btnShortLeft", StrId::STR_CAT_CONTROLS)
|
||||
.withSubcategory(StrId::STR_BTN_LEFT)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoubleLeft, BTN_ACTION_ENUM_VALUES,
|
||||
"btnDoubleLeft", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongLeft, BTN_ACTION_ENUM_VALUES,
|
||||
"btnLongLeft", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
// Right button
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortRight, BTN_ACTION_ENUM_VALUES,
|
||||
"btnShortRight", StrId::STR_CAT_CONTROLS)
|
||||
.withSubcategory(StrId::STR_BTN_RIGHT)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoubleRight, BTN_ACTION_ENUM_VALUES,
|
||||
"btnDoubleRight", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongRight, BTN_ACTION_ENUM_VALUES,
|
||||
"btnLongRight", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
// Up button
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortUp, BTN_ACTION_ENUM_VALUES, "btnShortUp",
|
||||
// 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, BTN_ACT_OPTIONS}, "btnShortBack", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_BACK),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoubleBack,
|
||||
{StrId::STR_BTN_DEF_IGNORE, BTN_ACT_OPTIONS}, "btnDoubleBack", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_BACK),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongBack,
|
||||
{StrId::STR_BTN_DEF_GO_HOME, BTN_ACT_OPTIONS}, "btnLongBack", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_BACK),
|
||||
// Confirm button: short=reader menu, double=ignore, long=KOReader sync
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortConfirm,
|
||||
{StrId::STR_BTN_DEF_READER_MENU, BTN_ACT_OPTIONS}, "btnShortConfirm", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_CONFIRM),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoubleConfirm,
|
||||
{StrId::STR_BTN_DEF_IGNORE, BTN_ACT_OPTIONS}, "btnDoubleConfirm", StrId::STR_CAT_CONTROLS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongConfirm,
|
||||
{StrId::STR_BTN_DEF_KOREADER_SYNC, BTN_ACT_OPTIONS}, "btnLongConfirm", StrId::STR_CAT_CONTROLS),
|
||||
// Left button: short=previous page, double=ignore, long=chapter back
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortLeft,
|
||||
{StrId::STR_BTN_DEF_PREV_PAGE, BTN_ACT_OPTIONS}, "btnShortLeft", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_LEFT),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoubleLeft,
|
||||
{StrId::STR_BTN_DEF_IGNORE, BTN_ACT_OPTIONS}, "btnDoubleLeft", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_LEFT),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongLeft,
|
||||
{StrId::STR_BTN_DEF_CHAPTER_BACK, BTN_ACT_OPTIONS}, "btnLongLeft", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_LEFT),
|
||||
// Right button: short=next page, double=ignore, long=chapter forward
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortRight,
|
||||
{StrId::STR_BTN_DEF_NEXT_PAGE, BTN_ACT_OPTIONS}, "btnShortRight", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_RIGHT),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoubleRight,
|
||||
{StrId::STR_BTN_DEF_IGNORE, BTN_ACT_OPTIONS}, "btnDoubleRight", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_RIGHT),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongRight,
|
||||
{StrId::STR_BTN_DEF_CHAPTER_FORWARD, BTN_ACT_OPTIONS}, "btnLongRight", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_RIGHT),
|
||||
// Up button: short=previous page, double=ignore, long=chapter back
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortUp,
|
||||
{StrId::STR_BTN_DEF_PREV_PAGE, BTN_ACT_OPTIONS}, "btnShortUp", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_UP),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoubleUp,
|
||||
{StrId::STR_BTN_DEF_IGNORE, BTN_ACT_OPTIONS}, "btnDoubleUp", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_UP),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongUp,
|
||||
{StrId::STR_BTN_DEF_CHAPTER_BACK, BTN_ACT_OPTIONS}, "btnLongUp", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_UP),
|
||||
// Down button: short=next page, double=ignore, long=chapter forward
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortDown,
|
||||
{StrId::STR_BTN_DEF_NEXT_PAGE, BTN_ACT_OPTIONS}, "btnShortDown", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_DOWN),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoubleDown,
|
||||
{StrId::STR_BTN_DEF_IGNORE, BTN_ACT_OPTIONS}, "btnDoubleDown", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_DOWN),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongDown,
|
||||
{StrId::STR_BTN_DEF_CHAPTER_FORWARD, BTN_ACT_OPTIONS}, "btnLongDown", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_DOWN),
|
||||
// Page Back button: short=previous page, double=ignore, long=chapter back
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortPageBack,
|
||||
{StrId::STR_BTN_DEF_PREV_PAGE, BTN_ACT_OPTIONS}, "btnShortPageBack", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_PAGE_BACK),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoublePageBack,
|
||||
{StrId::STR_BTN_DEF_IGNORE, BTN_ACT_OPTIONS}, "btnDoublePageBack", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_PAGE_BACK),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongPageBack,
|
||||
{StrId::STR_BTN_DEF_CHAPTER_BACK, BTN_ACT_OPTIONS}, "btnLongPageBack", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_PAGE_BACK),
|
||||
// Page Forward button: short=next page, double=ignore, long=chapter forward
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortPageForward,
|
||||
{StrId::STR_BTN_DEF_NEXT_PAGE, BTN_ACT_OPTIONS}, "btnShortPageForward", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_PAGE_FORWARD),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoublePageForward,
|
||||
{StrId::STR_BTN_DEF_IGNORE, BTN_ACT_OPTIONS}, "btnDoublePageForward", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_PAGE_FORWARD),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongPageForward,
|
||||
{StrId::STR_BTN_DEF_CHAPTER_FORWARD, BTN_ACT_OPTIONS}, "btnLongPageForward",
|
||||
StrId::STR_CAT_CONTROLS)
|
||||
.withSubcategory(StrId::STR_BTN_UP)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoubleUp, BTN_ACTION_ENUM_VALUES,
|
||||
"btnDoubleUp", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongUp, BTN_ACTION_ENUM_VALUES, "btnLongUp",
|
||||
StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
// Down button
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortDown, BTN_ACTION_ENUM_VALUES,
|
||||
"btnShortDown", StrId::STR_CAT_CONTROLS)
|
||||
.withSubcategory(StrId::STR_BTN_DOWN)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoubleDown, BTN_ACTION_ENUM_VALUES,
|
||||
"btnDoubleDown", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongDown, BTN_ACTION_ENUM_VALUES,
|
||||
"btnLongDown", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
// Page Back button
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortPageBack, BTN_ACTION_ENUM_VALUES,
|
||||
"btnShortPageBack", StrId::STR_CAT_CONTROLS)
|
||||
.withSubcategory(StrId::STR_BTN_PAGE_BACK)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoublePageBack, BTN_ACTION_ENUM_VALUES,
|
||||
"btnDoublePageBack", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongPageBack, BTN_ACTION_ENUM_VALUES,
|
||||
"btnLongPageBack", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
// Page Forward button
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortPageForward, BTN_ACTION_ENUM_VALUES,
|
||||
"btnShortPageForward", StrId::STR_CAT_CONTROLS)
|
||||
.withSubcategory(StrId::STR_BTN_PAGE_FORWARD)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoublePageForward, BTN_ACTION_ENUM_VALUES,
|
||||
"btnDoublePageForward", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongPageForward, BTN_ACTION_ENUM_VALUES,
|
||||
"btnLongPageForward", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
// Power button
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortPower, BTN_ACTION_ENUM_VALUES,
|
||||
"btnShortPower", StrId::STR_CAT_CONTROLS)
|
||||
.withSubcategory(StrId::STR_BTN_POWER)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoublePower, BTN_ACTION_ENUM_VALUES,
|
||||
"btnDoublePower", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongPower, BTN_ACTION_ENUM_VALUES,
|
||||
.withSubmenu(StrId::STR_BTN_PAGE_FORWARD),
|
||||
// Power button: short=ignore, double=ignore, long=sleep (via hold timer, not event system)
|
||||
SettingInfo::Enum(StrId::STR_BTN_SHORT_PRESS, &CrossPointSettings::btnShortPower,
|
||||
{StrId::STR_BTN_DEF_IGNORE, BTN_ACT_OPTIONS}, "btnShortPower", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_POWER),
|
||||
SettingInfo::Enum(StrId::STR_BTN_DOUBLE_PRESS, &CrossPointSettings::btnDoublePower,
|
||||
{StrId::STR_BTN_DEF_IGNORE, BTN_ACT_OPTIONS}, "btnDoublePower", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_BTN_POWER),
|
||||
SettingInfo::Enum(StrId::STR_BTN_LONG_PRESS, &CrossPointSettings::btnLongPower, {StrId::STR_BTN_DEF_SLEEP},
|
||||
"btnLongPower", StrId::STR_CAT_CONTROLS)
|
||||
.withSubmenu(StrId::STR_MENU_BTN_ACTIONS),
|
||||
.withSubmenu(StrId::STR_BTN_POWER),
|
||||
|
||||
#undef BTN_ACTION_ENUM_VALUES
|
||||
#undef BTN_ACT_OPTIONS
|
||||
|
||||
// --- System ---
|
||||
SettingInfo::Toggle(StrId::STR_SHOW_HIDDEN_FILES, &CrossPointSettings::showHiddenFiles, "showHiddenFiles",
|
||||
|
||||
@@ -295,37 +295,6 @@ void EpubReaderActivity::loop() {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool screenshotChordReleased = gpio.wasReleased(HalGPIO::BTN_POWER) && gpio.wasReleased(HalGPIO::BTN_DOWN);
|
||||
|
||||
// Handle short power button press for footnotes
|
||||
if (SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::FOOTNOTES &&
|
||||
mappedInput.wasReleased(MappedInputManager::Button::Power) && !screenshotChordReleased) {
|
||||
if (currentPageFootnotes.size() == 1) {
|
||||
navigateToHref(currentPageFootnotes[0].href, true);
|
||||
} else if (currentPageFootnotes.size() > 1) {
|
||||
ReaderUtils::enforceExitFullRefresh(renderer);
|
||||
startActivityForResult(std::make_unique<EpubReaderFootnotesActivity>(renderer, mappedInput, currentPageFootnotes),
|
||||
[this](const ActivityResult& result) {
|
||||
if (!result.isCancelled) {
|
||||
const auto& footnoteResult = std::get<FootnoteResult>(result.data);
|
||||
navigateToHref(footnoteResult.href, true);
|
||||
}
|
||||
requestUpdate();
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Star page toggle via short power button press
|
||||
if (SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::STAR_PAGE &&
|
||||
mappedInput.wasReleased(MappedInputManager::Button::Power)) {
|
||||
if (section && section->currentPage >= 0 && section->currentPage < section->pageCount) {
|
||||
bookmarkStore.toggle(static_cast<uint16_t>(currentSpineIndex), static_cast<uint16_t>(section->currentPage));
|
||||
requestUpdate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
auto [prevTriggered, nextTriggered] = ReaderUtils::detectPageTurn(mappedInput);
|
||||
if (!prevTriggered && !nextTriggered) {
|
||||
return;
|
||||
@@ -1905,6 +1874,46 @@ void EpubReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION
|
||||
requestUpdate();
|
||||
break;
|
||||
}
|
||||
case BA::BTN_EXIT_READER:
|
||||
ReaderUtils::enforceExitFullRefresh(renderer);
|
||||
finish();
|
||||
break;
|
||||
case BA::BTN_READER_MENU:
|
||||
if (epub) {
|
||||
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));
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case BA::BTN_KOREADER_SYNC:
|
||||
launchKOReaderSync(SyncLaunchMode::COMPARE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -947,6 +947,10 @@ void MdReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION ac
|
||||
});
|
||||
}
|
||||
break;
|
||||
case BA::BTN_EXIT_READER:
|
||||
ReaderUtils::enforceExitFullRefresh(renderer);
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -64,9 +64,7 @@ struct PageTurnResult {
|
||||
inline PageTurnResult detectPageTurn(const MappedInputManager& input) {
|
||||
const bool prev =
|
||||
input.wasReleased(MappedInputManager::Button::PageBack) || input.wasReleased(MappedInputManager::Button::Left);
|
||||
const bool powerTurn = SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::PAGE_TURN &&
|
||||
input.wasReleased(MappedInputManager::Button::Power);
|
||||
const bool next = input.wasReleased(MappedInputManager::Button::PageForward) || powerTurn ||
|
||||
const bool next = input.wasReleased(MappedInputManager::Button::PageForward) ||
|
||||
input.wasReleased(MappedInputManager::Button::Right);
|
||||
return {prev, next};
|
||||
}
|
||||
|
||||
@@ -155,16 +155,6 @@ void TxtReaderActivity::loop() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Star page toggle via short power button press
|
||||
if (SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::STAR_PAGE &&
|
||||
mappedInput.wasReleased(MappedInputManager::Button::Power)) {
|
||||
if (currentPage >= 0) {
|
||||
bookmarkStore.toggle(0, static_cast<uint16_t>(currentPage));
|
||||
}
|
||||
requestUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
// Open starred pages list via Confirm button
|
||||
if (mappedInput.wasReleased(MappedInputManager::Button::Confirm) && !bookmarkStore.isEmpty()) {
|
||||
ReaderUtils::enforceExitFullRefresh(renderer);
|
||||
@@ -826,6 +816,10 @@ void TxtReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION a
|
||||
clampPage();
|
||||
requestUpdate();
|
||||
break;
|
||||
case BA::BTN_EXIT_READER:
|
||||
ReaderUtils::enforceExitFullRefresh(renderer);
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -94,9 +94,7 @@ void XtcReaderActivity::loop() {
|
||||
|
||||
const bool prevTriggered = mappedInput.wasReleased(MappedInputManager::Button::PageBack) ||
|
||||
mappedInput.wasReleased(MappedInputManager::Button::Left);
|
||||
const bool powerPageTurn = SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::PAGE_TURN &&
|
||||
mappedInput.wasReleased(MappedInputManager::Button::Power);
|
||||
const bool nextTriggered = mappedInput.wasReleased(MappedInputManager::Button::PageForward) || powerPageTurn ||
|
||||
const bool nextTriggered = mappedInput.wasReleased(MappedInputManager::Button::PageForward) ||
|
||||
mappedInput.wasReleased(MappedInputManager::Button::Right);
|
||||
|
||||
if (!prevTriggered && !nextTriggered) {
|
||||
@@ -469,6 +467,10 @@ void XtcReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION a
|
||||
currentPage = (currentPage >= 10) ? currentPage - 10 : 0;
|
||||
requestUpdate();
|
||||
break;
|
||||
case BA::BTN_EXIT_READER:
|
||||
ReaderUtils::enforceExitFullRefresh(renderer);
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
+40
-20
@@ -370,14 +370,6 @@ void loop() {
|
||||
}
|
||||
}
|
||||
|
||||
// Refresh screen when power button is short-pressed with FORCE_REFRESH setting.
|
||||
if (SETTINGS.shortPwrBtn == CrossPointSettings::SHORT_PWRBTN::FORCE_REFRESH &&
|
||||
mappedInputManager.wasReleased(MappedInputManager::Button::Power)) {
|
||||
LOG_DBG("MAIN", "Manual screen refresh triggered");
|
||||
RenderLock lock;
|
||||
renderer.displayBuffer(HalDisplay::HALF_REFRESH);
|
||||
}
|
||||
|
||||
if (!gpio.isPressed(HalGPIO::BTN_POWER)) {
|
||||
powerHoldStart = 0;
|
||||
}
|
||||
@@ -395,6 +387,13 @@ void loop() {
|
||||
using B = MappedInputManager::Button;
|
||||
ButtonEventManager::ButtonEvent ev;
|
||||
while (buttonEventManager.consumeEvent(ev)) {
|
||||
// Up/Down share physical pins with PageBack/PageForward via sideButtonLayout.
|
||||
// ButtonEventManager only runs FSMs for PageBack/PageForward (not Up/Down) to avoid
|
||||
// double-firing. Here we resolve Up/Down settings as aliases of the side-button events:
|
||||
// with PREV_NEXT layout, PageBack = BTN_UP and PageForward = BTN_DOWN, so the
|
||||
// btnShort/Double/LongUp/Down settings apply when PageBack/PageForward fires.
|
||||
const bool prevNext = static_cast<CrossPointSettings::SIDE_BUTTON_LAYOUT>(SETTINGS.sideButtonLayout) ==
|
||||
CrossPointSettings::SIDE_BUTTON_LAYOUT::PREV_NEXT;
|
||||
auto actionFor = [&](B btn) -> uint8_t {
|
||||
switch (ev.type) {
|
||||
case ButtonEventManager::PressType::Short:
|
||||
@@ -408,13 +407,15 @@ void loop() {
|
||||
case B::Right:
|
||||
return SETTINGS.btnShortRight;
|
||||
case B::Up:
|
||||
return SETTINGS.btnShortUp;
|
||||
return BA::BTN_DEFAULT; // no dedicated FSM
|
||||
case B::Down:
|
||||
return SETTINGS.btnShortDown;
|
||||
return BA::BTN_DEFAULT; // no dedicated FSM
|
||||
case B::PageBack:
|
||||
return SETTINGS.btnShortPageBack;
|
||||
if (SETTINGS.btnShortPageBack != BA::BTN_DEFAULT) return SETTINGS.btnShortPageBack;
|
||||
return prevNext ? SETTINGS.btnShortUp : SETTINGS.btnShortDown;
|
||||
case B::PageForward:
|
||||
return SETTINGS.btnShortPageForward;
|
||||
if (SETTINGS.btnShortPageForward != BA::BTN_DEFAULT) return SETTINGS.btnShortPageForward;
|
||||
return prevNext ? SETTINGS.btnShortDown : SETTINGS.btnShortUp;
|
||||
case B::Power:
|
||||
return SETTINGS.btnShortPower;
|
||||
}
|
||||
@@ -430,13 +431,15 @@ void loop() {
|
||||
case B::Right:
|
||||
return SETTINGS.btnDoubleRight;
|
||||
case B::Up:
|
||||
return SETTINGS.btnDoubleUp;
|
||||
return BA::BTN_DEFAULT; // no dedicated FSM
|
||||
case B::Down:
|
||||
return SETTINGS.btnDoubleDown;
|
||||
return BA::BTN_DEFAULT; // no dedicated FSM
|
||||
case B::PageBack:
|
||||
return SETTINGS.btnDoublePageBack;
|
||||
if (SETTINGS.btnDoublePageBack != BA::BTN_DEFAULT) return SETTINGS.btnDoublePageBack;
|
||||
return prevNext ? SETTINGS.btnDoubleUp : SETTINGS.btnDoubleDown;
|
||||
case B::PageForward:
|
||||
return SETTINGS.btnDoublePageForward;
|
||||
if (SETTINGS.btnDoublePageForward != BA::BTN_DEFAULT) return SETTINGS.btnDoublePageForward;
|
||||
return prevNext ? SETTINGS.btnDoubleDown : SETTINGS.btnDoubleUp;
|
||||
case B::Power:
|
||||
return SETTINGS.btnDoublePower;
|
||||
}
|
||||
@@ -452,13 +455,15 @@ void loop() {
|
||||
case B::Right:
|
||||
return SETTINGS.btnLongRight;
|
||||
case B::Up:
|
||||
return SETTINGS.btnLongUp;
|
||||
return BA::BTN_DEFAULT; // no dedicated FSM
|
||||
case B::Down:
|
||||
return SETTINGS.btnLongDown;
|
||||
return BA::BTN_DEFAULT; // no dedicated FSM
|
||||
case B::PageBack:
|
||||
return SETTINGS.btnLongPageBack;
|
||||
if (SETTINGS.btnLongPageBack != BA::BTN_DEFAULT) return SETTINGS.btnLongPageBack;
|
||||
return prevNext ? SETTINGS.btnLongUp : SETTINGS.btnLongDown;
|
||||
case B::PageForward:
|
||||
return SETTINGS.btnLongPageForward;
|
||||
if (SETTINGS.btnLongPageForward != BA::BTN_DEFAULT) return SETTINGS.btnLongPageForward;
|
||||
return prevNext ? SETTINGS.btnLongDown : SETTINGS.btnLongUp;
|
||||
case B::Power:
|
||||
return SETTINGS.btnLongPower;
|
||||
}
|
||||
@@ -506,6 +511,21 @@ void loop() {
|
||||
case BA::BTN_FOOTNOTES:
|
||||
activityManager.dispatchButtonAction(BA::BTN_FOOTNOTES);
|
||||
break;
|
||||
case BA::BTN_NEXT_SECTION:
|
||||
activityManager.dispatchButtonAction(BA::BTN_NEXT_SECTION);
|
||||
break;
|
||||
case BA::BTN_PREV_SECTION:
|
||||
activityManager.dispatchButtonAction(BA::BTN_PREV_SECTION);
|
||||
break;
|
||||
case BA::BTN_EXIT_READER:
|
||||
activityManager.dispatchButtonAction(BA::BTN_EXIT_READER);
|
||||
break;
|
||||
case BA::BTN_READER_MENU:
|
||||
activityManager.dispatchButtonAction(BA::BTN_READER_MENU);
|
||||
break;
|
||||
case BA::BTN_KOREADER_SYNC:
|
||||
activityManager.dispatchButtonAction(BA::BTN_KOREADER_SYNC);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user