MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / mapLabels

Method mapLabels

src/MappedInputManager.cpp:89–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87unsigned long MappedInputManager::getHeldTime() const { return gpio.getHeldTime(); }
88
89MappedInputManager::Labels MappedInputManager::mapLabels(const char* back, const char* confirm, const char* previous,
90 const char* next) const {
91 // Swap previous/next labels to match the page turn direction swap in INVERTED and LANDSCAPE_CCW.
92 const bool swapLabels = isNavDirectionSwapped();
93 const char* leftLabel = swapLabels ? next : previous;
94 const char* rightLabel = swapLabels ? previous : next;
95
96 // Build the label order based on the configured hardware mapping.
97 auto labelForHardware = [&](uint8_t hw) -> const char* {
98 // Compare against configured logical roles and return the matching label.
99 if (hw == SETTINGS.frontButtonBack) {
100 return back;
101 }
102 if (hw == SETTINGS.frontButtonConfirm) {
103 return confirm;
104 }
105 if (hw == SETTINGS.frontButtonLeft) {
106 return leftLabel;
107 }
108 if (hw == SETTINGS.frontButtonRight) {
109 return rightLabel;
110 }
111 return "";
112 };
113
114 return {labelForHardware(HalGPIO::BTN_BACK), labelForHardware(HalGPIO::BTN_CONFIRM),
115 labelForHardware(HalGPIO::BTN_LEFT), labelForHardware(HalGPIO::BTN_RIGHT)};
116}
117
118int MappedInputManager::getPressedFrontButton() const {
119 // Scan the raw front buttons in hardware order.

Callers 15

renderMethod · 0.80
renderServerRunningMethod · 0.80
renderMethod · 0.80
renderNetworkListMethod · 0.80
renderConnectedMethod · 0.80
renderSavePromptMethod · 0.80
renderForgetPromptMethod · 0.80
renderMethod · 0.80
renderMethod · 0.80
renderMethod · 0.80
renderMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected