Fix to but that takes you to message selection screen

This commit is contained in:
HarukiToreda 2025-05-26 23:45:53 -04:00
parent aaf9f4011f
commit bdd03bc853

View File

@ -533,64 +533,72 @@ bool CannedMessageModule::handleMessageSelectorInput(const InputEvent* event, bo
} }
bool CannedMessageModule::handleFreeTextInput(const InputEvent* event) { bool CannedMessageModule::handleFreeTextInput(const InputEvent* event) {
#if defined(USE_VIRTUAL_KEYBOARD) // Always process only if in FREETEXT mode
if (runState != CANNED_MESSAGE_RUN_STATE_FREETEXT) return false; if (runState != CANNED_MESSAGE_RUN_STATE_FREETEXT) return false;
String keyTapped = keyForCoordinates(event->touchX, event->touchY); #if defined(USE_VIRTUAL_KEYBOARD)
bool valid = false; // Touch input (virtual keyboard) handling
// Only handle if touch coordinates present (CardKB won't set these)
if (event->touchX != 0 || event->touchY != 0) {
String keyTapped = keyForCoordinates(event->touchX, event->touchY);
bool valid = false;
if (keyTapped == "") { if (keyTapped == "") {
highlight = -1; highlight = -1;
payload = 0x00; payload = 0x00;
shift = !shift; shift = !shift;
valid = true; valid = true;
} else if (keyTapped == "") { } else if (keyTapped == "") {
#ifndef RAK14014 #ifndef RAK14014
highlight = keyTapped[0]; highlight = keyTapped[0];
#endif #endif
payload = 0x08; payload = 0x08;
shift = false; shift = false;
valid = true; valid = true;
} else if (keyTapped == "123" || keyTapped == "ABC") { } else if (keyTapped == "123" || keyTapped == "ABC") {
highlight = -1; highlight = -1;
payload = 0x00; payload = 0x00;
charSet = (charSet == 0 ? 1 : 0); charSet = (charSet == 0 ? 1 : 0);
valid = true; valid = true;
} else if (keyTapped == " ") { } else if (keyTapped == " ") {
#ifndef RAK14014 #ifndef RAK14014
highlight = keyTapped[0]; highlight = keyTapped[0];
#endif #endif
payload = keyTapped[0]; payload = keyTapped[0];
shift = false; shift = false;
valid = true; valid = true;
} }
// Touch enter/submit // Touch enter/submit
else if (keyTapped == "") { else if (keyTapped == "") {
runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT; // Send the message! runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT; // Send the message!
payload = CANNED_MESSAGE_RUN_STATE_FREETEXT; payload = CANNED_MESSAGE_RUN_STATE_FREETEXT;
currentMessageIndex = -1; currentMessageIndex = -1;
shift = false; shift = false;
valid = true; valid = true;
} else if (!keyTapped.isEmpty()) { } else if (!keyTapped.isEmpty()) {
#ifndef RAK14014 #ifndef RAK14014
highlight = keyTapped[0]; highlight = keyTapped[0];
#endif #endif
payload = shift ? keyTapped[0] : std::tolower(keyTapped[0]); payload = shift ? keyTapped[0] : std::tolower(keyTapped[0]);
shift = false; shift = false;
valid = true; valid = true;
}
if (valid) {
lastTouchMillis = millis();
return true; // STOP: We handled a VKB touch
}
} }
#endif // USE_VIRTUAL_KEYBOARD
if (valid) { // ---- All hardware keys fall through to here (CardKB, physical, etc.) ----
lastTouchMillis = millis();
return true;
}
#endif
// Confirm select (Enter)
bool isSelect = isSelectEvent(event); bool isSelect = isSelectEvent(event);
if (isSelect) {
if (runState == CANNED_MESSAGE_RUN_STATE_FREETEXT && isSelect) { LOG_DEBUG("[SELECT] handleFreeTextInput: runState=%d, dest=%u, channel=%d, freetext='%s'",
(int)runState, dest, channel, freetext.c_str());
if (dest == 0) dest = NODENUM_BROADCAST; if (dest == 0) dest = NODENUM_BROADCAST;
// Defensive: If channel isn't valid, pick the first available channel // Defensive: If channel isn't valid, pick the first available channel
if (channel < 0 || channel >= channels.getNumChannels()) channel = 0; if (channel < 0 || channel >= channels.getNumChannels()) channel = 0;
@ -598,6 +606,7 @@ bool CannedMessageModule::handleFreeTextInput(const InputEvent* event) {
currentMessageIndex = -1; currentMessageIndex = -1;
runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT; runState = CANNED_MESSAGE_RUN_STATE_ACTION_SELECT;
lastTouchMillis = millis(); lastTouchMillis = millis();
runOnce();
return true; return true;
} }