mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-20 12:02:21 +00:00
Alt button behavior
This commit is contained in:
parent
5ee6c0e240
commit
0692a5d8d0
@ -1365,7 +1365,7 @@ int Screen::handleInputEvent(const InputEvent *event)
|
|||||||
|
|
||||||
// If no modules are using the input, move between frames
|
// If no modules are using the input, move between frames
|
||||||
if (!inputIntercepted) {
|
if (!inputIntercepted) {
|
||||||
if (event->inputEvent == INPUT_BROKER_LEFT) {
|
if (event->inputEvent == INPUT_BROKER_LEFT || event->inputEvent == INPUT_BROKER_ALT_PRESS) {
|
||||||
showPrevFrame();
|
showPrevFrame();
|
||||||
} else if (event->inputEvent == INPUT_BROKER_RIGHT || event->inputEvent == INPUT_BROKER_USER_PRESS) {
|
} else if (event->inputEvent == INPUT_BROKER_RIGHT || event->inputEvent == INPUT_BROKER_USER_PRESS) {
|
||||||
showNextFrame();
|
showNextFrame();
|
||||||
|
@ -110,14 +110,14 @@ void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisp
|
|||||||
|
|
||||||
if (alertBannerOptions > 0) {
|
if (alertBannerOptions > 0) {
|
||||||
// respond to input
|
// respond to input
|
||||||
if (inEvent == INPUT_BROKER_UP) {
|
if (inEvent == INPUT_BROKER_UP || inEvent == INPUT_BROKER_ALT_PRESS) {
|
||||||
curSelected--;
|
curSelected--;
|
||||||
} else if (inEvent == INPUT_BROKER_DOWN || inEvent == INPUT_BROKER_USER_PRESS) {
|
} else if (inEvent == INPUT_BROKER_DOWN || inEvent == INPUT_BROKER_USER_PRESS) {
|
||||||
curSelected++;
|
curSelected++;
|
||||||
} else if (inEvent == INPUT_BROKER_SELECT) {
|
} else if (inEvent == INPUT_BROKER_SELECT) {
|
||||||
alertBannerCallback(curSelected);
|
alertBannerCallback(curSelected);
|
||||||
alertBannerMessage[0] = '\0';
|
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';
|
alertBannerMessage[0] = '\0';
|
||||||
}
|
}
|
||||||
if (curSelected == -1)
|
if (curSelected == -1)
|
||||||
@ -136,7 +136,7 @@ void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisp
|
|||||||
}
|
}
|
||||||
} else { // not in an alert with a callback
|
} else { // not in an alert with a callback
|
||||||
// TODO: check that at least a second has passed since the alert started
|
// 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
|
alertBannerMessage[0] = '\0'; // end the alert early
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ enum input_broker_event {
|
|||||||
INPUT_BROKER_CANCEL = 24,
|
INPUT_BROKER_CANCEL = 24,
|
||||||
INPUT_BROKER_BACK = 27,
|
INPUT_BROKER_BACK = 27,
|
||||||
INPUT_BROKER_USER_PRESS,
|
INPUT_BROKER_USER_PRESS,
|
||||||
|
INPUT_BROKER_ALT_PRESS,
|
||||||
|
INPUT_BROKER_ALT_LONG,
|
||||||
INPUT_BROKER_SHUTDOWN = 0x9b,
|
INPUT_BROKER_SHUTDOWN = 0x9b,
|
||||||
INPUT_BROKER_GPS_TOGGLE = 0x9e,
|
INPUT_BROKER_GPS_TOGGLE = 0x9e,
|
||||||
INPUT_BROKER_SEND_PING = 0xaf,
|
INPUT_BROKER_SEND_PING = 0xaf,
|
||||||
|
@ -972,7 +972,7 @@ void setup()
|
|||||||
BaseType_t higherWake = 0;
|
BaseType_t higherWake = 0;
|
||||||
mainDelay.interruptFromISR(&higherWake);
|
mainDelay.interruptFromISR(&higherWake);
|
||||||
},
|
},
|
||||||
INPUT_BROKER_UP, INPUT_BROKER_BACK, 500);
|
INPUT_BROKER_ALT_PRESS, INPUT_BROKER_ALT_LONG, 500);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(BUTTON_PIN)
|
#if defined(BUTTON_PIN)
|
||||||
|
@ -303,7 +303,8 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Handle UP/DOWN: activate canned message list!
|
// 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
|
// Always select the first real canned message on activation
|
||||||
int firstRealMsgIdx = 0;
|
int firstRealMsgIdx = 0;
|
||||||
for (int i = 0; i < messagesCount; ++i) {
|
for (int i = 0; i < messagesCount; ++i) {
|
||||||
@ -351,12 +352,17 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
|
|||||||
|
|
||||||
bool CannedMessageModule::isUpEvent(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)
|
bool CannedMessageModule::isDownEvent(const InputEvent *event)
|
||||||
{
|
{
|
||||||
return event->inputEvent == INPUT_BROKER_DOWN ||
|
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)
|
bool CannedMessageModule::isSelectEvent(const InputEvent *event)
|
||||||
{
|
{
|
||||||
@ -403,7 +409,7 @@ int CannedMessageModule::handleDestinationSelectionInput(const InputEvent *event
|
|||||||
runOnce(); // update filter immediately
|
runOnce(); // update filter immediately
|
||||||
lastFilterUpdate = millis();
|
lastFilterUpdate = millis();
|
||||||
}
|
}
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t numMeshNodes = filteredNodes.size();
|
size_t numMeshNodes = filteredNodes.size();
|
||||||
@ -424,7 +430,7 @@ int CannedMessageModule::handleDestinationSelectionInput(const InputEvent *event
|
|||||||
resetSearch();
|
resetSearch();
|
||||||
needsUpdate = false;
|
needsUpdate = false;
|
||||||
}
|
}
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UP
|
// UP
|
||||||
@ -436,7 +442,7 @@ int CannedMessageModule::handleDestinationSelectionInput(const InputEvent *event
|
|||||||
scrollIndex = (destIndex / columns) - visibleRows + 1;
|
scrollIndex = (destIndex / columns) - visibleRows + 1;
|
||||||
|
|
||||||
screen->forceDisplay();
|
screen->forceDisplay();
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DOWN
|
// DOWN
|
||||||
@ -446,7 +452,7 @@ int CannedMessageModule::handleDestinationSelectionInput(const InputEvent *event
|
|||||||
scrollIndex = (destIndex / columns) - visibleRows + 1;
|
scrollIndex = (destIndex / columns) - visibleRows + 1;
|
||||||
|
|
||||||
screen->forceDisplay();
|
screen->forceDisplay();
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// SELECT
|
// SELECT
|
||||||
@ -468,19 +474,20 @@ int CannedMessageModule::handleDestinationSelectionInput(const InputEvent *event
|
|||||||
runState = returnToCannedList ? CANNED_MESSAGE_RUN_STATE_ACTIVE : CANNED_MESSAGE_RUN_STATE_FREETEXT;
|
runState = returnToCannedList ? CANNED_MESSAGE_RUN_STATE_ACTIVE : CANNED_MESSAGE_RUN_STATE_FREETEXT;
|
||||||
returnToCannedList = false;
|
returnToCannedList = false;
|
||||||
screen->forceDisplay();
|
screen->forceDisplay();
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// CANCEL
|
// CANCEL
|
||||||
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;
|
runState = returnToCannedList ? CANNED_MESSAGE_RUN_STATE_ACTIVE : CANNED_MESSAGE_RUN_STATE_FREETEXT;
|
||||||
|
returnToCannedList = false;
|
||||||
searchQuery = "";
|
searchQuery = "";
|
||||||
|
|
||||||
UIFrameEvent e;
|
// UIFrameEvent e;
|
||||||
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET;
|
// e.action = UIFrameEvent::Action::REGENERATE_FRAMESET;
|
||||||
notifyObservers(&e);
|
// notifyObservers(&e);
|
||||||
screen->forceDisplay();
|
screen->forceDisplay();
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -502,7 +509,7 @@ bool CannedMessageModule::handleMessageSelectorInput(const InputEvent *event, bo
|
|||||||
|
|
||||||
// === Handle Cancel key: go inactive, clear UI state ===
|
// === Handle Cancel key: go inactive, clear UI state ===
|
||||||
if (runState != CANNED_MESSAGE_RUN_STATE_INACTIVE &&
|
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;
|
runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
||||||
freetext = "";
|
freetext = "";
|
||||||
cursor = 0;
|
cursor = 0;
|
||||||
@ -697,7 +704,7 @@ bool CannedMessageModule::handleFreeTextInput(const InputEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cancel (dismiss freetext screen)
|
// 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;
|
runState = CANNED_MESSAGE_RUN_STATE_INACTIVE;
|
||||||
UIFrameEvent e;
|
UIFrameEvent e;
|
||||||
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET;
|
e.action = UIFrameEvent::Action::REGENERATE_FRAMESET;
|
||||||
@ -766,7 +773,7 @@ int CannedMessageModule::handleEmotePickerInput(const InputEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cancel returns to freetext
|
// 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;
|
runState = CANNED_MESSAGE_RUN_STATE_FREETEXT;
|
||||||
screen->forceDisplay();
|
screen->forceDisplay();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
#define LED_PIN 13 // the red part of the RGB LED
|
#define LED_PIN 13 // the red part of the RGB LED
|
||||||
#define LED_STATE_ON 0 // State when LED is lit
|
#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_NEED_PULLUP2 TB_UP
|
||||||
#define BUTTON_PIN 0 // Circle button
|
#define BUTTON_PIN 0 // Circle button
|
||||||
#define BUTTON_NEED_PULLUP // we do need a helping hand up
|
#define BUTTON_NEED_PULLUP // we do need a helping hand up
|
||||||
|
Loading…
Reference in New Issue
Block a user