From dbfa703cfa08733c0daf767ac2569cfc6459f2aa Mon Sep 17 00:00:00 2001 From: HarukiToreda <116696711+HarukiToreda@users.noreply.github.com> Date: Mon, 26 May 2025 03:00:38 -0400 Subject: [PATCH] Virtual keyboard fix --- src/graphics/images.h | 2 ++ src/modules/CannedMessageModule.cpp | 6 +++--- src/modules/CannedMessageModule.h | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/graphics/images.h b/src/graphics/images.h index 9e421dba9..a49646c06 100644 --- a/src/graphics/images.h +++ b/src/graphics/images.h @@ -281,4 +281,6 @@ static const uint8_t icon_node[] PROGMEM = { 0xFE // ####### ← device base }; + #include "img/icon.xbm" +static_assert(sizeof(icon_bits) >= 0, "Silence unused variable warning"); diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 78ca741f5..bbc1d13c9 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -596,7 +596,7 @@ bool CannedMessageModule::handleFreeTextInput(const InputEvent* event) { if (dest == 0) dest = NODENUM_BROADCAST; // Defensive: If channel isn't valid, pick the first available channel - if (channel < 0 || channel >= channels.getNumChannels()) channel = 0; + if (channel >= channels.getNumChannels()) channel = 0; payload = CANNED_MESSAGE_RUN_STATE_FREETEXT; currentMessageIndex = -1; @@ -1028,7 +1028,7 @@ int32_t CannedMessageModule::runOnce() switch (this->payload) { // code below all trigger the freetext window (where you type to send a message) or reset the // display back to the default window case 0x08: // backspace - if (this->freetext.length() > 0 && this->highlight == 0x00) { + if (this->freetext.length() > 0 && this->key_highlight == 0x00) { if (this->cursor == this->freetext.length()) { this->freetext = this->freetext.substring(0, this->freetext.length() - 1); } else { @@ -1062,7 +1062,7 @@ int32_t CannedMessageModule::runOnce() // already handled above break; default: - if (this->highlight != 0x00) { + if (this->key_highlight != 0x00) { break; } diff --git a/src/modules/CannedMessageModule.h b/src/modules/CannedMessageModule.h index 7ba537a10..c8728fd8b 100644 --- a/src/modules/CannedMessageModule.h +++ b/src/modules/CannedMessageModule.h @@ -150,6 +150,13 @@ private: String freetext; String temporaryMessage; +#if defined(USE_VIRTUAL_KEYBOARD) + bool shift = false; // True if Shift (caps/alt) is active + int charSet = 0; // 0 = alpha keyboard, 1 = numeric/symbol keyboard + int highlight = -1; // Highlighted key for UI feedback +#endif + char key_highlight = 0x00; + // === Message Storage === char messageStore[CANNED_MESSAGE_MODULE_MESSAGES_SIZE + 1]; char *messages[CANNED_MESSAGE_MODULE_MESSAGE_MAX_COUNT]; @@ -176,7 +183,6 @@ private: // === State Tracking === cannedMessageModuleRunState runState = CANNED_MESSAGE_RUN_STATE_INACTIVE; cannedMessageDestinationType destSelect = CANNED_MESSAGE_DESTINATION_TYPE_NONE; - char highlight = 0x00; char payload = 0x00; unsigned int cursor = 0; unsigned long lastTouchMillis = 0;