## Summary
* Custom remapper to create any variant of front button layout.
## Additional Context
* Included migration from previous frontlayout setting
* This will solve:
* https://github.com/crosspoint-reader/crosspoint-reader/issues/654
* https://github.com/crosspoint-reader/crosspoint-reader/issues/652
* https://github.com/crosspoint-reader/crosspoint-reader/issues/620
* https://github.com/crosspoint-reader/crosspoint-reader/issues/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 >**_
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
#pragma once
|
|
#include <freertos/FreeRTOS.h>
|
|
#include <freertos/semphr.h>
|
|
#include <freertos/task.h>
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
|
|
#include "activities/Activity.h"
|
|
|
|
class ButtonRemapActivity final : public Activity {
|
|
public:
|
|
explicit ButtonRemapActivity(GfxRenderer& renderer, MappedInputManager& mappedInput,
|
|
const std::function<void()>& onBack)
|
|
: Activity("ButtonRemap", renderer, mappedInput), onBack(onBack) {}
|
|
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
void loop() override;
|
|
|
|
private:
|
|
// Rendering task state.
|
|
TaskHandle_t displayTaskHandle = nullptr;
|
|
SemaphoreHandle_t renderingMutex = nullptr;
|
|
bool updateRequired = false;
|
|
|
|
// Callback used to exit the remap flow back to the settings list.
|
|
const std::function<void()> onBack;
|
|
// Index of the logical role currently awaiting input.
|
|
uint8_t currentStep = 0;
|
|
// Temporary mapping from logical role -> hardware button index.
|
|
uint8_t tempMapping[4] = {0xFF, 0xFF, 0xFF, 0xFF};
|
|
// Error banner timing (used when reassigning duplicate buttons).
|
|
unsigned long errorUntil = 0;
|
|
std::string errorMessage;
|
|
|
|
// FreeRTOS task helpers.
|
|
static void taskTrampoline(void* param);
|
|
[[noreturn]] void displayTaskLoop();
|
|
void render();
|
|
|
|
// Commit temporary mapping to settings.
|
|
void applyTempMapping();
|
|
// Returns false if a hardware button is already assigned to a different role.
|
|
bool validateUnassigned(uint8_t pressedButton);
|
|
// Labels for UI display.
|
|
const char* getRoleName(uint8_t roleIndex) const;
|
|
const char* getHardwareName(uint8_t buttonIndex) const;
|
|
};
|