feat: front button remapper#664
Conversation
There was a problem hiding this comment.
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.
|
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. 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? |
|
@aaroncunliffe thanks for the feedback! I've added migration from old settings
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 |
|
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
left a comment
There was a problem hiding this comment.
Looks great, will merge pending conflict resolution
* 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)
## 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 >**_

Summary
Additional Context
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 >