From 6eae99362dd5a2b800cdcb36148a26f793e7f563 Mon Sep 17 00:00:00 2001 From: jpirnay Date: Mon, 4 May 2026 13:27:40 +0200 Subject: [PATCH] Add orientation change to button actions --- lib/I18n/translations/english.yaml | 3 ++- src/CrossPointSettings.h | 1 + src/SettingsList.h | 2 +- src/activities/reader/EpubReaderActivity.cpp | 8 ++++++++ src/activities/reader/MdReaderActivity.cpp | 9 +++++++++ src/activities/reader/TxtReaderActivity.cpp | 9 +++++++++ src/main.cpp | 3 +++ 7 files changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/I18n/translations/english.yaml b/lib/I18n/translations/english.yaml index e4ebc982..1f2abb41 100644 --- a/lib/I18n/translations/english.yaml +++ b/lib/I18n/translations/english.yaml @@ -615,5 +615,6 @@ STR_KB_HINT_LOWER_SECONDARY: "Hold SELECT for lowercase or secondary char" STR_KB_HINT_URL_SNIPPETS: "Press URL for snippets" STR_BIONIC_READING: "Bionic Reading" STR_BTN_ACT_TOGGLE_BIONIC_READING: "Toggle Bionic Reading" -STR_BTN_ACT_CYCLE_FONT_SIZE: "Cycle Font Size" +STR_BTN_ACT_CYCLE_FONT_SIZE: "Change Font Size" +STR_BTN_ACT_CYCLE_ORIENTATION: "Change Orientation" STR_RESTART_DEVICE: "Restart Device" \ No newline at end of file diff --git a/src/CrossPointSettings.h b/src/CrossPointSettings.h index d7da625b..1797a31c 100644 --- a/src/CrossPointSettings.h +++ b/src/CrossPointSettings.h @@ -290,6 +290,7 @@ class CrossPointSettings { BTN_TOGGLE_BIONIC_READING, BTN_KOREADER_SYNC, BTN_CYCLE_FONT_SIZE, + BTN_CYCLE_ORIENTATION, BUTTON_ACTION_COUNT }; diff --git a/src/SettingsList.h b/src/SettingsList.h index 2157048b..c2ad45b0 100644 --- a/src/SettingsList.h +++ b/src/SettingsList.h @@ -147,7 +147,7 @@ inline const std::vector list = { 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_TOGGLE_BIONIC_READING, StrId::STR_BTN_ACT_KOREADER_SYNC, \ - StrId::STR_BTN_ACT_CYCLE_FONT_SIZE + StrId::STR_BTN_ACT_CYCLE_FONT_SIZE, StrId::STR_BTN_ACT_CYCLE_ORIENTATION // 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}, diff --git a/src/activities/reader/EpubReaderActivity.cpp b/src/activities/reader/EpubReaderActivity.cpp index 4d2f14c3..844fe9a5 100644 --- a/src/activities/reader/EpubReaderActivity.cpp +++ b/src/activities/reader/EpubReaderActivity.cpp @@ -2016,6 +2016,14 @@ void EpubReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION requestUpdate(); } break; + case BA::BTN_CYCLE_ORIENTATION: + if (epub) { + const uint8_t nextOrientation = + static_cast((SETTINGS.orientation + 1) % CrossPointSettings::ORIENTATION_COUNT); + applyOrientation(nextOrientation); + requestUpdate(); + } + break; case BA::BTN_KOREADER_SYNC: launchKOReaderSync(SyncLaunchMode::COMPARE); break; diff --git a/src/activities/reader/MdReaderActivity.cpp b/src/activities/reader/MdReaderActivity.cpp index c35babbc..2cda2fbc 100644 --- a/src/activities/reader/MdReaderActivity.cpp +++ b/src/activities/reader/MdReaderActivity.cpp @@ -995,6 +995,15 @@ void MdReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION ac ReaderUtils::enforceExitFullRefresh(renderer); finish(); break; + case BA::BTN_CYCLE_ORIENTATION: { + const uint8_t nextOrientation = + static_cast((SETTINGS.orientation + 1) % CrossPointSettings::ORIENTATION_COUNT); + SETTINGS.orientation = nextOrientation; + SETTINGS.saveToFile(); + ReaderUtils::applyOrientation(renderer, SETTINGS.orientation); + requestUpdate(); + break; + } default: break; } diff --git a/src/activities/reader/TxtReaderActivity.cpp b/src/activities/reader/TxtReaderActivity.cpp index a88d6549..d5840cfb 100644 --- a/src/activities/reader/TxtReaderActivity.cpp +++ b/src/activities/reader/TxtReaderActivity.cpp @@ -833,6 +833,15 @@ void TxtReaderActivity::onButtonAction(const CrossPointSettings::BUTTON_ACTION a ReaderUtils::enforceExitFullRefresh(renderer); finish(); break; + case BA::BTN_CYCLE_ORIENTATION: { + const uint8_t nextOrientation = + static_cast((SETTINGS.orientation + 1) % CrossPointSettings::ORIENTATION_COUNT); + SETTINGS.orientation = nextOrientation; + SETTINGS.saveToFile(); + ReaderUtils::applyOrientation(renderer, SETTINGS.orientation); + requestUpdate(); + break; + } default: break; } diff --git a/src/main.cpp b/src/main.cpp index 59af5978..dbc530ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -545,6 +545,9 @@ void loop() { case BA::BTN_CYCLE_FONT_SIZE: activityManager.dispatchButtonAction(BA::BTN_CYCLE_FONT_SIZE); break; + case BA::BTN_CYCLE_ORIENTATION: + activityManager.dispatchButtonAction(BA::BTN_CYCLE_ORIENTATION); + break; default: break; }