feat: Page turn button orientation change (#1069)

Co-authored-by: Егор Мартынов <martynovegorOF@yandex.ru>
This commit is contained in:
Maciek
2026-05-04 08:56:02 +03:00
committed by GitHub
co-authored by Егор Мартынов
parent b692bad10d
commit 2e2ea6a9e8
24 changed files with 99 additions and 29 deletions
+1 -1
View File
@@ -205,7 +205,7 @@ bool CrossPointSettings::loadFromBinaryFile() {
if (++settingsRead >= fileSettingsCount) break;
readAndValidate(inputFile, hideBatteryPercentage, HIDE_BATTERY_PERCENTAGE_COUNT);
if (++settingsRead >= fileSettingsCount) break;
serialization::readPod(inputFile, longPressChapterSkip);
readAndValidate(inputFile, longPressButtonBehavior, LONG_PRESS_BUTTON_BEHAVIOR_COUNT);
if (++settingsRead >= fileSettingsCount) break;
serialization::readPod(inputFile, hyphenationEnabled);
if (++settingsRead >= fileSettingsCount) break;
+10 -2
View File
@@ -131,6 +131,14 @@ class CrossPointSettings {
// Hide battery percentage
enum HIDE_BATTERY_PERCENTAGE { HIDE_NEVER = 0, HIDE_READER = 1, HIDE_ALWAYS = 2, HIDE_BATTERY_PERCENTAGE_COUNT };
// Page turn button long press behavior
enum LONG_PRESS_BUTTON_BEHAVIOR {
OFF = 0,
CHAPTER_SKIP = 1,
ORIENTATION_CHANGE = 2,
LONG_PRESS_BUTTON_BEHAVIOR_COUNT
};
// UI Theme
enum UI_THEME { CLASSIC = 0, LYRA = 1, LYRA_3_COVERS = 2, ROUNDEDRAFF = 3 };
@@ -189,8 +197,8 @@ class CrossPointSettings {
char opdsPassword[64] = "";
// Hide battery percentage
uint8_t hideBatteryPercentage = HIDE_NEVER;
// Long-press chapter skip on side buttons
uint8_t longPressChapterSkip = 1;
// Long-press page turn button behavior
uint8_t longPressButtonBehavior = OFF;
// UI Theme
uint8_t uiTheme = LYRA;
// Sunlight fading compensation
+4 -3
View File
@@ -71,12 +71,13 @@ inline const std::vector<SettingInfo>& getSettingsList() {
// --- Controls ---
SettingInfo::Enum(StrId::STR_SIDE_BTN_LAYOUT, &CrossPointSettings::sideButtonLayout,
{StrId::STR_PREV_NEXT, StrId::STR_NEXT_PREV}, "sideButtonLayout", StrId::STR_CAT_CONTROLS),
SettingInfo::Toggle(StrId::STR_LONG_PRESS_SKIP, &CrossPointSettings::longPressChapterSkip,
"longPressChapterSkip", StrId::STR_CAT_CONTROLS),
SettingInfo::Enum(StrId::STR_LONG_PRESS_BEHAVIOR, &CrossPointSettings::longPressButtonBehavior,
{StrId::STR_LONG_PRESS_BEHAVIOR_OFF, StrId::STR_LONG_PRESS_BEHAVIOR_SKIP,
StrId::STR_LONG_PRESS_BEHAVIOR_ORIENTATION},
"longPressButtonBehavior", 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},
"shortPwrBtn", StrId::STR_CAT_CONTROLS),
// --- System ---
SettingInfo::Enum(StrId::STR_TIME_TO_SLEEP, &CrossPointSettings::sleepTimeout,
{StrId::STR_MIN_1, StrId::STR_MIN_5, StrId::STR_MIN_10, StrId::STR_MIN_15, StrId::STR_MIN_30},
+11 -3
View File
@@ -202,15 +202,14 @@ void EpubReaderActivity::loop() {
return;
}
const bool skipChapter = !fromTilt && SETTINGS.longPressChapterSkip && mappedInput.getHeldTime() > skipChapterMs;
const bool longPress = !fromTilt && mappedInput.getHeldTime() > skipChapterMs;
// Don't skip chapter after screenshot
if (gpio.wasReleased(HalGPIO::BTN_POWER) && gpio.wasReleased(HalGPIO::BTN_DOWN)) {
return;
}
if (skipChapter) {
lastPageTurnTime = millis();
if (longPress && SETTINGS.longPressButtonBehavior == SETTINGS.CHAPTER_SKIP) {
// We don't want to delete the section mid-render, so grab the semaphore
{
RenderLock lock(*this);
@@ -222,6 +221,15 @@ void EpubReaderActivity::loop() {
return;
}
if (longPress && SETTINGS.longPressButtonBehavior == SETTINGS.ORIENTATION_CHANGE) {
const uint8_t newOrientation =
nextTriggered ? (SETTINGS.orientation - 1 + SETTINGS.ORIENTATION_COUNT) % SETTINGS.ORIENTATION_COUNT
: (SETTINGS.orientation + 1) % SETTINGS.ORIENTATION_COUNT;
applyOrientation(newOrientation);
requestUpdate();
return;
}
// No current section, attempt to rerender the book
if (!section) {
requestUpdate();
+1 -1
View File
@@ -37,7 +37,7 @@ struct PageTurnResult {
};
inline PageTurnResult detectPageTurn(const MappedInputManager& input) {
const bool usePress = !SETTINGS.longPressChapterSkip;
const bool usePress = SETTINGS.longPressButtonBehavior == SETTINGS.OFF;
const bool tiltNext = SETTINGS.tiltPageTurn && halTiltSensor.wasTiltedForward();
const bool tiltPrev = SETTINGS.tiltPageTurn && halTiltSensor.wasTiltedBack();
const bool prev = tiltPrev || (usePress ? (input.wasPressed(MappedInputManager::Button::PageBack) ||
+3 -2
View File
@@ -82,7 +82,7 @@ void XtcReaderActivity::loop() {
}
// When long-press chapter skip is disabled, turn pages on press instead of release.
const bool usePressForPageTurn = !SETTINGS.longPressChapterSkip;
const bool usePressForPageTurn = SETTINGS.longPressButtonBehavior == SETTINGS.OFF;
const bool tiltNext = SETTINGS.tiltPageTurn && halTiltSensor.wasTiltedForward();
const bool tiltPrev = SETTINGS.tiltPageTurn && halTiltSensor.wasTiltedBack();
const bool prevTriggered =
@@ -114,7 +114,8 @@ void XtcReaderActivity::loop() {
}
const bool fromTilt = tiltPrev || tiltNext;
const bool skipPages = !fromTilt && SETTINGS.longPressChapterSkip && mappedInput.getHeldTime() > skipPageMs;
const bool skipPages =
!fromTilt && SETTINGS.longPressButtonBehavior == SETTINGS.CHAPTER_SKIP && mappedInput.getHeldTime() > skipPageMs;
const int skipAmount = skipPages ? 10 : 1;
if (prevTriggered) {