Add osk_found On-Screen Keyboard found as the global variable.

This commit is contained in:
whywilson 2025-07-28 08:27:29 +08:00
parent de5e581f1e
commit f4af02544e
5 changed files with 14 additions and 21 deletions

View File

@ -1,5 +1,6 @@
#include "RotaryEncoderInterruptImpl1.h"
#include "InputBroker.h"
extern bool osk_found;
RotaryEncoderInterruptImpl1 *rotaryEncoderInterruptImpl1;
@ -25,6 +26,7 @@ bool RotaryEncoderInterruptImpl1::init()
RotaryEncoderInterruptImpl1::handleIntA, RotaryEncoderInterruptImpl1::handleIntB,
RotaryEncoderInterruptImpl1::handleIntPressed);
inputBroker->registerSource(this);
osk_found = true;
return true;
}

View File

@ -1,5 +1,6 @@
#include "UpDownInterruptImpl1.h"
#include "InputBroker.h"
extern bool osk_found;
UpDownInterruptImpl1 *upDownInterruptImpl1;
@ -28,6 +29,7 @@ bool UpDownInterruptImpl1::init()
eventDownLong, UpDownInterruptImpl1::handleIntDown, UpDownInterruptImpl1::handleIntUp,
UpDownInterruptImpl1::handleIntPressed);
inputBroker->registerSource(this);
osk_found = true;
return true;
}

View File

@ -187,6 +187,8 @@ ScanI2C::DeviceAddress cardkb_found = ScanI2C::ADDRESS_NONE;
uint8_t kb_model;
// global bool to record that a kb is present
bool kb_found = false;
// global bool to record that on-screen keyboard (OSK) is present
bool osk_found = false;
// The I2C address of the RTC Module (if found)
ScanI2C::DeviceAddress rtc_found = ScanI2C::ADDRESS_NONE;
@ -1390,6 +1392,10 @@ void setup()
#endif
#endif
#if defined(HAS_TRACKBALL) || (defined(INPUTDRIVER_ENCODER_TYPE) && INPUTDRIVER_ENCODER_TYPE == 2)
osk_found = true;
#endif
#if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_WEBSERVER
// Start web server thread.
webServerThread = new WebServerThread();

View File

@ -32,6 +32,7 @@ extern ScanI2C::DeviceAddress screen_found;
extern ScanI2C::DeviceAddress cardkb_found;
extern uint8_t kb_model;
extern bool kb_found;
extern bool osk_found;
extern ScanI2C::DeviceAddress rtc_found;
extern ScanI2C::DeviceAddress accelerometer_found;
extern ScanI2C::FoundDevice rgb_found;

View File

@ -42,6 +42,7 @@
extern ScanI2C::DeviceAddress cardkb_found;
extern bool graphics::isMuted;
extern bool osk_found;
static const char *cannedMessagesConfigFile = "/prefs/cannedConf.proto";
@ -125,20 +126,11 @@ int CannedMessageModule::splitConfiguredMessages()
int tempCount = 0;
// Insert at position 0 (top)
tempMessages[tempCount++] = "[Select Destination]";
#if defined(USE_VIRTUAL_KEYBOARD)
// Add a "Free Text" entry at the top if using a touch screen virtual keyboard
tempMessages[tempCount++] = "[-- Free Text --]";
#else
// For devices with encoder input or trackball, also add Free Text option
#if HAS_TRACKBALL
extern TrackballInterruptImpl1 *trackballInterruptImpl1;
if (trackballInterruptImpl1) {
#else
extern RotaryEncoderInterruptImpl1 *rotaryEncoderInterruptImpl1;
extern UpDownInterruptImpl1 *upDownInterruptImpl1;
if (rotaryEncoderInterruptImpl1 || upDownInterruptImpl1) {
#endif
if (osk_found && screen) {
tempMessages[tempCount++] = "[-- Free Text --]";
}
#endif
@ -610,18 +602,9 @@ bool CannedMessageModule::handleMessageSelectorInput(const InputEvent *event, bo
}
#else
if (strcmp(current, "[-- Free Text --]") == 0) {
#if HAS_TRACKBALL
extern TrackballInterruptImpl1 *trackballInterruptImpl1;
if (trackballInterruptImpl1 && screen) {
#else
extern RotaryEncoderInterruptImpl1 *rotaryEncoderInterruptImpl1;
extern UpDownInterruptImpl1 *upDownInterruptImpl1;
if ((rotaryEncoderInterruptImpl1 || upDownInterruptImpl1) && screen) {
#endif
if (osk_found && screen) {
screen->showTextInput("Free Text", "", 300000, [this](const std::string &text) {
LOG_INFO("Free text submitted: '%s'", text.c_str());
if (!text.empty()) {
LOG_INFO("Storing message for delayed sending: '%s'", text.c_str());
this->freetext = text.c_str();
this->payload = CANNED_MESSAGE_RUN_STATE_FREETEXT;
runState = CANNED_MESSAGE_RUN_STATE_SENDING_ACTIVE;
@ -633,7 +616,6 @@ bool CannedMessageModule::handleMessageSelectorInput(const InputEvent *event, bo
screen->forceDisplay();
setIntervalFromNow(500);
LOG_INFO("Free text callback completed safely");
return;
} else {
// Don't delete virtual keyboard immediately - it might still be executing