Skip to content

feat: front button remapper#664

Merged
daveallie merged 8 commits intocrosspoint-reader:masterfrom
osteotek:feat-button-remapper
Feb 5, 2026
Merged

feat: front button remapper#664
daveallie merged 8 commits intocrosspoint-reader:masterfrom
osteotek:feat-button-remapper

Conversation

@osteotek
Copy link
Member

@osteotek osteotek commented Feb 2, 2026

Summary

  • Custom remapper to create any variant of front button layout.

Additional Context

image

AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? < PARTIALLY >

Copilot AI review requested due to automatic review settings February 2, 2026 11:58
@osteotek osteotek requested a review from a team February 2, 2026 12:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a flexible front button remapping wizard that replaces hardcoded button layout presets with a custom configuration system. Users can now assign any physical button to any logical role through an interactive wizard interface. This solves issue #654 by deferring button mapping changes until the user completes the wizard and exits the settings screen.

Changes:

  • Replaced enum-based front button layout selection with an interactive remap wizard
  • Added new settings fields (frontButtonBack/Confirm/Left/Right) to store custom button mappings
  • Implemented ButtonRemapActivity with duplicate detection and error handling
  • Updated MappedInputManager to use the new custom mapping fields instead of hardcoded layouts

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/activities/settings/SettingsActivity.cpp Replaced enum setting with "Remap Front Buttons" action; updated button hints to show Up/Down labels
src/activities/settings/CategorySettingsActivity.cpp Added handler to launch ButtonRemapActivity for the remap action; updated button hints
src/activities/settings/ButtonRemapActivity.h New activity header defining the button remapping wizard UI
src/activities/settings/ButtonRemapActivity.cpp Implements interactive wizard for remapping front buttons with validation and error display
src/MappedInputManager.h Added getPressedFrontButton() method for raw button input detection
src/MappedInputManager.cpp Refactored to use custom mapping fields; removed hardcoded layout arrays; added getPressedFrontButton()
src/CrossPointSettings.h Added FRONT_BUTTON_HARDWARE enum and four new mapping fields; marked legacy frontButtonLayout
src/CrossPointSettings.cpp Added validation function; incremented settings count; added serialization for new fields

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aaroncunliffe
Copy link
Contributor

I'm not sure if there has been any discussion about the settings file or if there is an agreement on what is best practice when adding or updating settings. I think some some consideration would be good for old values, especially on first boot after an update that contains this change. Users would be dropped into the reading view that has no button hints with the configuration reset.

Something like the below code is hopefully simple enough, and also easy enough to remove when the old setting is deprecated.

// CrosspointSettings.cpp

// New helper function
void applyLegacyFrontLayout(CrossPointSettings& settings) {
  switch (static_cast<CrossPointSettings::FRONT_BUTTON_LAYOUT>(settings.frontButtonLayout)) {
    case CrossPointSettings::LEFT_RIGHT_BACK_CONFIRM:
      settings.frontButtonBack = CrossPointSettings::FRONT_HW_LEFT;
      settings.frontButtonConfirm = CrossPointSettings::FRONT_HW_RIGHT;
      settings.frontButtonLeft = CrossPointSettings::FRONT_HW_BACK;
      settings.frontButtonRight = CrossPointSettings::FRONT_HW_CONFIRM;
      break;
    case CrossPointSettings::LEFT_BACK_CONFIRM_RIGHT:
      settings.frontButtonBack = CrossPointSettings::FRONT_HW_LEFT;
      settings.frontButtonConfirm = CrossPointSettings::FRONT_HW_BACK;
      settings.frontButtonLeft = CrossPointSettings::FRONT_HW_CONFIRM;
      settings.frontButtonRight = CrossPointSettings::FRONT_HW_RIGHT;
      break;
    case CrossPointSettings::BACK_CONFIRM_RIGHT_LEFT:
      settings.frontButtonBack = CrossPointSettings::FRONT_HW_BACK;
      settings.frontButtonConfirm = CrossPointSettings::FRONT_HW_CONFIRM;
      settings.frontButtonLeft = CrossPointSettings::FRONT_HW_RIGHT;
      settings.frontButtonRight = CrossPointSettings::FRONT_HW_LEFT;
      break;
    case CrossPointSettings::BACK_CONFIRM_LEFT_RIGHT:
    default:
      settings.frontButtonBack = CrossPointSettings::FRONT_HW_BACK;
      settings.frontButtonConfirm = CrossPointSettings::FRONT_HW_CONFIRM;
      settings.frontButtonLeft = CrossPointSettings::FRONT_HW_LEFT;
      settings.frontButtonRight = CrossPointSettings::FRONT_HW_RIGHT;
  }
}

// ----

// Line 215
  if (frontButtonMappingRead) {
    validateFrontButtonMapping(*this);
  } else {
    applyLegacyFrontLayout(*this);
    validateFrontButtonMapping(*this);
    // Maybe saveToFile(); here to be an actual migration
  }

Aside from that this PR works great on my device. Definitely better than the adding all of the permutations 1 by 1.

Device image:

IMG_0848

1 small nit on the reset behaviour, I read the side buttons being 'reset' as if it was reset to default, that could just be me though. It would be good to have a default option, maybe 1 of the buttons labeled as back, and the other for reset to default?

@osteotek
Copy link
Member Author

osteotek commented Feb 3, 2026

@aaroncunliffe thanks for the feedback! I've added migration from old settings

1 small nit on the reset behaviour, I read the side buttons being 'reset' as if it was reset to default, that could just be me though. It would be good to have a default option, maybe 1 of the buttons labeled as back, and the other for reset to default?

That's exactly what was intended, side button up - reset to default layout, side button down - cancel remapping without saving changes. I've changed the wording for clarity

@aaroncunliffe
Copy link
Contributor

aaroncunliffe commented Feb 3, 2026

Looks good, I've tested a few permutations of old settings and the new mapping works great.

This feature solves quite a few PRs and open issues, I'll close my PR


From what I can tell the Hal abstraction remains intact with these changes so that can still be used in the future for mocking / testing.

daveallie
daveallie previously approved these changes Feb 5, 2026
Copy link
Member

@daveallie daveallie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, will merge pending conflict resolution

@daveallie daveallie merged commit c49a819 into crosspoint-reader:master Feb 5, 2026
2 checks passed
jdk2pq added a commit to jdk2pq/crosspoint-reader that referenced this pull request Feb 5, 2026
* master:
  feat: add shift lock to KeyboardEntryActivity (crosspoint-reader#513)
  feat: rename and move in file manager (crosspoint-reader#630)
  feat: Implement fix for sunlight fading issue (crosspoint-reader#603)
  chore: Add PR title check on sync (crosspoint-reader#698)
  feat: Go To Position for epubs (crosspoint-reader#666)
  feat: Calibre Web Automated (CWA) koreader sync server support (crosspoint-reader#594)
  chore: Add CI check job to consolidate status (crosspoint-reader#696)
  chore: CI Build Summary - firmware stats, firmware artifact (crosspoint-reader#601)
  feat: quick rotate option in epub reader menu (crosspoint-reader#685)
  feat(settings): add "Cover + Custom" sleep screen mode (crosspoint-reader#582)
  fix: Artifacts on Thumb on Home Screen (crosspoint-reader#662)
  feat: holding back button while booting, boots to home screen as a mean of escaping boot loop (crosspoint-reader#587)
  docs: Add small SCOPE.md and GOVERNANCE.md documents (crosspoint-reader#640)
  feat: front button remapper (crosspoint-reader#664)
  feat: UI themes, Lyra (crosspoint-reader#528)
  feat: Add CSS parsing and CSS support in EPUBs (crosspoint-reader#411)
  fix: move http upload state to heap (crosspoint-reader#657)
Unintendedsideeffects pushed a commit to Unintendedsideeffects/crosspoint-reader that referenced this pull request Feb 17, 2026
## Summary

* Custom remapper to create any variant of front button layout.

## Additional Context

* Included migration from previous frontlayout setting
* This will solve:
    *  crosspoint-reader#654
    * crosspoint-reader#652
    * crosspoint-reader#620
    * crosspoint-reader#468

<img width="860" height="1147" alt="image"
src="https://github.com/user-attachments/assets/457356ed-7a7d-4e1c-8683-e187a1df47c0"
/>



---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _**< PARTIALLY >**_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants