diff --git a/USER_GUIDE.md b/USER_GUIDE.md index e2d97c9f..681e3088 100644 --- a/USER_GUIDE.md +++ b/USER_GUIDE.md @@ -200,7 +200,7 @@ The Settings screen allows you to configure the device's behavior. There are a f #### 3.6.3 Controls - **Remap Front Buttons**: A menu for customising the function of each bottom edge button. -- **Side Button Layout (reader)**: Swap the order of the up and down volume buttons from "Prev/Next" (default) to "Next/Prev". This change is only in effect when reading. +- **Side Button Layout (reader)**: Swap the order of the up and down volume buttons from "Prev/Next" (default) to "Next/Prev". You can also disable them entirely. This change is only in effect when reading. - **Long-press Chapter Skip**: Set whether long-pressing page turn buttons skips to the next/previous chapter: - "Chapter Skip" (default) - Long-pressing skips to next/previous chapter diff --git a/lib/I18n/translations/english.yaml b/lib/I18n/translations/english.yaml index 9afbfec4..8852b95d 100644 --- a/lib/I18n/translations/english.yaml +++ b/lib/I18n/translations/english.yaml @@ -140,6 +140,7 @@ STR_INVERTED: "Inverted" STR_LANDSCAPE_CCW: "Landscape CCW" STR_PREV_NEXT: "Prev/Next" STR_NEXT_PREV: "Next/Prev" +STR_DISABLED: "Disabled" STR_NOTO_SERIF: "Noto Serif" STR_NOTO_SANS: "Noto Sans" STR_OPEN_DYSLEXIC: "Open Dyslexic" diff --git a/src/CrossPointSettings.h b/src/CrossPointSettings.h index 2be537cf..c4bbc6b5 100644 --- a/src/CrossPointSettings.h +++ b/src/CrossPointSettings.h @@ -94,9 +94,8 @@ class CrossPointSettings { }; // Side button layout options - // Default: Previous, Next - // Swapped: Next, Previous - enum SIDE_BUTTON_LAYOUT { PREV_NEXT = 0, NEXT_PREV = 1, SIDE_BUTTON_LAYOUT_COUNT }; + // Default: Up = Previous, Down = Next + enum SIDE_BUTTON_LAYOUT { PREV_NEXT = 0, NEXT_PREV = 1, SIDE_BUTTONS_DISABLED = 2, SIDE_BUTTON_LAYOUT_COUNT }; // Font family options (built-in fonts only; SD card fonts use sdFontFamilyName) enum FONT_FAMILY { NOTOSERIF = 0, NOTOSANS = 1, OPENDYSLEXIC = 2, FONT_FAMILY_COUNT }; diff --git a/src/MappedInputManager.cpp b/src/MappedInputManager.cpp index 8d8833fc..81bc5d87 100644 --- a/src/MappedInputManager.cpp +++ b/src/MappedInputManager.cpp @@ -2,24 +2,8 @@ #include "CrossPointSettings.h" -namespace { -using ButtonIndex = uint8_t; - -struct SideLayoutMap { - ButtonIndex pageBack; - ButtonIndex pageForward; -}; - -// Order matches CrossPointSettings::SIDE_BUTTON_LAYOUT. -constexpr SideLayoutMap kSideLayouts[] = { - {HalGPIO::BTN_UP, HalGPIO::BTN_DOWN}, - {HalGPIO::BTN_DOWN, HalGPIO::BTN_UP}, -}; -} // namespace - bool MappedInputManager::mapButton(const Button button, bool (HalGPIO::*fn)(uint8_t) const) const { - const auto sideLayout = static_cast(SETTINGS.sideButtonLayout); - const auto& side = kSideLayouts[sideLayout]; + const auto sideLayout = SETTINGS.sideButtonLayout; switch (button) { case Button::Back: @@ -45,10 +29,26 @@ bool MappedInputManager::mapButton(const Button button, bool (HalGPIO::*fn)(uint return (gpio.*fn)(HalGPIO::BTN_POWER); case Button::PageBack: // Reader page navigation uses side buttons and can be swapped via settings. - return (gpio.*fn)(side.pageBack); + switch (sideLayout) { + case CrossPointSettings::PREV_NEXT: + return (gpio.*fn)(HalGPIO::BTN_UP); + case CrossPointSettings::NEXT_PREV: + return (gpio.*fn)(HalGPIO::BTN_DOWN); + case CrossPointSettings::SIDE_BUTTONS_DISABLED: + default: + return false; + } case Button::PageForward: // Reader page navigation uses side buttons and can be swapped via settings. - return (gpio.*fn)(side.pageForward); + switch (sideLayout) { + case CrossPointSettings::PREV_NEXT: + return (gpio.*fn)(HalGPIO::BTN_DOWN); + case CrossPointSettings::NEXT_PREV: + return (gpio.*fn)(HalGPIO::BTN_UP); + case CrossPointSettings::SIDE_BUTTONS_DISABLED: + default: + return false; + } } return false; diff --git a/src/SettingsList.h b/src/SettingsList.h index 8ccb8614..19c31c3f 100644 --- a/src/SettingsList.h +++ b/src/SettingsList.h @@ -165,7 +165,8 @@ inline std::vector getSettingsList(const SdCardFontRegistry* regist "imageRendering", StrId::STR_CAT_READER), // --- Controls --- SettingInfo::Enum(StrId::STR_SIDE_BTN_LAYOUT, &CrossPointSettings::sideButtonLayout, - {StrId::STR_PREV_NEXT, StrId::STR_NEXT_PREV}, "sideButtonLayout", StrId::STR_CAT_CONTROLS), + {StrId::STR_PREV_NEXT, StrId::STR_NEXT_PREV, StrId::STR_DISABLED}, "sideButtonLayout", + StrId::STR_CAT_CONTROLS), SettingInfo::Toggle(StrId::STR_FRONT_BTN_FOLLOW_ORIENTATION, &CrossPointSettings::frontButtonFollowOrientation, "frontButtonFollowOrientation", StrId::STR_CAT_CONTROLS), SettingInfo::Enum(StrId::STR_LONG_PRESS_BEHAVIOR, &CrossPointSettings::longPressButtonBehavior,