Alt button behavior

This commit is contained in:
Jonathan Bennett 2025-06-14 22:04:37 -05:00
parent 5ee6c0e240
commit 0692a5d8d0
6 changed files with 32 additions and 23 deletions

View File

@ -1365,7 +1365,7 @@ int Screen::handleInputEvent(const InputEvent *event)
// If no modules are using the input, move between frames
if (!inputIntercepted) {
if (event->inputEvent == INPUT_BROKER_LEFT) {
if (event->inputEvent == INPUT_BROKER_LEFT || event->inputEvent == INPUT_BROKER_ALT_PRESS) {
showPrevFrame();
} else if (event->inputEvent == INPUT_BROKER_RIGHT || event->inputEvent == INPUT_BROKER_USER_PRESS) {
showNextFrame();

View File

@ -110,14 +110,14 @@ void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisp
if (alertBannerOptions > 0) {
// respond to input
if (inEvent == INPUT_BROKER_UP) {
if (inEvent == INPUT_BROKER_UP || inEvent == INPUT_BROKER_ALT_PRESS) {
curSelected--;
} else if (inEvent == INPUT_BROKER_DOWN || inEvent == INPUT_BROKER_USER_PRESS) {
curSelected++;
} else if (inEvent == INPUT_BROKER_SELECT) {
alertBannerCallback(curSelected);
alertBannerMessage[0] = '\0';
} else if ((inEvent == INPUT_BROKER_CANCEL || inEvent == INPUT_BROKER_BACK) && alertBannerUntil != 0) {
} else if ((inEvent == INPUT_BROKER_CANCEL || inEvent == INPUT_BROKER_ALT_LONG) && alertBannerUntil != 0) {
alertBannerMessage[0] = '\0';
}
if (curSelected == -1)
@ -136,7 +136,7 @@ void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisp
}
} else { // not in an alert with a callback
// TODO: check that at least a second has passed since the alert started
if (inEvent == INPUT_BROKER_SELECT || inEvent == INPUT_BROKER_BACK || inEvent == INPUT_BROKER_CANCEL) {
if (inEvent == INPUT_BROKER_SELECT || inEvent == INPUT_BROKER_ALT_LONG || inEvent == INPUT_BROKER_CANCEL) {
alertBannerMessage[0] = '\0'; // end the alert early
}
}

View File

@ -11,6 +11,8 @@ enum input_broker_event {
INPUT_BROKER_CANCEL = 24,
INPUT_BROKER_BACK = 27,
INPUT_BROKER_USER_PRESS,
INPUT_BROKER_ALT_PRESS,
INPUT_BROKER_ALT_LONG,
INPUT_BROKER_SHUTDOWN = 0x9b,
INPUT_BROKER_GPS_TOGGLE = 0x9e,
INPUT_BROKER_SEND_PING = 0xaf,

View File

@ -972,7 +972,7 @@ void setup()
BaseType_t higherWake = 0;
mainDelay.interruptFromISR(&higherWake);
},
INPUT_BROKER_UP, INPUT_BROKER_BACK, 500);
INPUT_BROKER_ALT_PRESS, INPUT_BROKER_ALT_LONG, 500);
#endif
#if defined(BUTTON_PIN)

View File

@ -303,7 +303,8 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
break;
}
// Handle UP/DOWN: activate canned message list!
if (event->inputEvent == INPUT_BROKER_UP || event->inputEvent == INPUT_BROKER_DOWN) {
if (event->inputEvent == INPUT_BROKER_UP || event->inputEvent == INPUT_BROKER_DOWN ||
event->inputEvent == INPUT_BROKER_ALT_LONG) {
// Always select the first real canned message on activation
int firstRealMsgIdx = 0;
for (int i = 0; i < messagesCount; ++i) {
@ -351,12 +352,17 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
bool CannedMessageModule::isUpEvent(const InputEvent *event)
{
return event->inputEvent == INPUT_BROKER_UP;
return event->inputEvent == INPUT_BROKER_UP ||
((runState == CANNED_MESSAGE_RUN_STATE_ACTIVE || runState == CANNED_MESSAGE_RUN_STATE_EMOTE_PICKER ||
runState == CANNED_MESSAGE_RUN_STATE_DESTINATION_SELECTION) &&
event->inputEvent == INPUT_BROKER_ALT_PRESS);
}
bool CannedMessageModule::isDownEvent(const InputEvent *event)
{
return event->inputEvent == INPUT_BROKER_DOWN ||
(runState == CANNED_MESSAGE_RUN_STATE_ACTIVE && event->inputEvent == INPUT_BROKER_USER_PRESS);
((runState == CANNED_MESSAGE_RUN_STATE_ACTIVE || runState == CANNED_MESSAGE_RUN_STATE_EMOTE_PICKER ||
runState == CANNED_MESSAGE_RUN_STATE_DESTINATION_SELECTION) &&
event->inputEvent == INPUT_BROKER_USER_PRESS);
}
bool CannedMessageModule::isSelectEvent(const InputEvent *event)
{
@ -403,7 +409,7 @@ int CannedMessageModule::handleDestinationSelectionInput(const InputEvent *event
runOnce(); // update filter immediately
lastFilterUpdate = millis();
}
return 0;
return 1;
}
size_t numMeshNodes = filteredNodes.size();
@ -424,7 +430,7 @@ int CannedMessageModule::handleDestinationSelectionInput(const InputEvent *event
resetSearch();
needsUpdate = false;
}
return 0;
return 1;
}
// UP
@ -436,7 +442,7 @@ int CannedMessageModule::handleDestinationSelectionInput(const InputEvent *event
scrollIndex = (destIndex / columns) - visibleRows + 1;
screen->forceDisplay();
return 0;
return 1;
}
// DOWN
@ -446,7 +452,7 @@ int CannedMessageModule::handleDestinationSelectionInput(const InputEvent *event
scrollIndex = (destIndex / columns) - visibleRows + 1;
screen->forceDisplay();
return 0;
return 1;
}
// SELECT
@ -468,19 +474,20 @@ int CannedMessageModule::handleDestinationSelectionInput(const InputEvent *event
runState = returnToCannedList ? CANNED_MESSAGE_RUN_STATE_ACTIVE : CANNED_MESSAGE_RUN_STATE_FREETEXT;
returnToCannedList = false;
screen->forceDisplay();
return 0;
return 1;
}
// CANCEL
if (event->inputEvent == INPUT_BROKER_CANCEL || event->inputEvent == INPUT_BROKER_BACK) {
runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
if (event->inputEvent == INPUT_BROKER_CANCEL || event->inputEvent == INPUT_BROKER_ALT_LONG) {
runState = returnToCannedList ? CANNED_MESSAGE_RUN_STATE_ACTIVE : CANNED_MESSAGE_RUN_STATE_FREETEXT;
returnToCannedList = false;
searchQuery = "";
UIFrameEvent e;
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET;
notifyObservers(&e);
// UIFrameEvent e;
// e.action = UIFrameEvent::Action::REGENERATE_FRAMESET;
// notifyObservers(&e);
screen->forceDisplay();
return 0;
return 1;
}
return 0;
@ -502,7 +509,7 @@ bool CannedMessageModule::handleMessageSelectorInput(const InputEvent *event, bo
// === Handle Cancel key: go inactive, clear UI state ===
if (runState != CANNED_MESSAGE_RUN_STATE_INACTIVE &&
(event->inputEvent == INPUT_BROKER_CANCEL || event->inputEvent == INPUT_BROKER_BACK)) {
(event->inputEvent == INPUT_BROKER_CANCEL || event->inputEvent == INPUT_BROKER_ALT_LONG)) {
runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
freetext = "";
cursor = 0;
@ -697,7 +704,7 @@ bool CannedMessageModule::handleFreeTextInput(const InputEvent *event)
}
// Cancel (dismiss freetext screen)
if (event->inputEvent == INPUT_BROKER_CANCEL || event->inputEvent == INPUT_BROKER_BACK) {
if (event->inputEvent == INPUT_BROKER_CANCEL || event->inputEvent == INPUT_BROKER_ALT_LONG) {
runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
UIFrameEvent e;
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET;
@ -766,7 +773,7 @@ int CannedMessageModule::handleEmotePickerInput(const InputEvent *event)
}
// Cancel returns to freetext
if (event->inputEvent == INPUT_BROKER_CANCEL || event->inputEvent == INPUT_BROKER_BACK) {
if (event->inputEvent == INPUT_BROKER_CANCEL || event->inputEvent == INPUT_BROKER_ALT_LONG) {
runState = CANNED_MESSAGE_RUN_STATE_FREETEXT;
screen->forceDisplay();
return 1;

View File

@ -57,7 +57,7 @@
#define LED_PIN 13 // the red part of the RGB LED
#define LED_STATE_ON 0 // State when LED is lit
#define TB_UP 21 // Button 3 - square - top button in landscape mode
#define ALT_BUTTON_PIN 21 // Button 3 - square - top button in landscape mode
#define BUTTON_NEED_PULLUP2 TB_UP
#define BUTTON_PIN 0 // Circle button
#define BUTTON_NEED_PULLUP // we do need a helping hand up