mirror of
https://github.com/meshtastic/firmware.git
synced 2026-08-01 19:08:59 -04:00
Removed: - MessageStore::addFromPacket and addFromString, superseded by tryAddFromPacket - GeoCoord rangeRadiansToMeters, distanceTo, bearingTo - Router::rawSend, declared virtual with no override and no caller - ContentHandler handleHotspot, handleFs, handleAdminSettings, handleAdminSettingsApply, handleDeleteFsContent and their commented route registrations, plus the now unreachable htmlDeleteDir and the handleUpdateFs declaration that had no definition - ContentHelper replaceAll - OnScreenKeyboardModule popup chain: showPopup, clearPopup, drawPopup, drawPopupOverlay and their state, unreachable since the frame based UI was replaced by baseUI - DebugRenderer drawDebugInfoTrampoline, drawDebugInfoSettingsTrampoline and the orphaned drawFrameSettings - NodeListRenderer calculateMaxScroll, drawColumns and a stale extern haveGlyphs declaration with no definition - UIRenderer::haveGlyphs, Screen::blink, NotificationRenderer::showKeyboardMessagePopupWithTitle, VirtualKeyboard::getInputText - InkHUD touchNavLeft, touchNavRight, Applet::getActiveNodeCount, ThreadedMessageApplet::saveMessagesToFlash - TwoButton::setHandlerUp, TwoButtonExtended setHandlerUp, setJoystickDownHandlers, setJoystickUpHandlers - CannedMessageModule LaunchRepeatDestination, isCharInputAllowed, hasMessages - TrafficManagementModule resetStats, recordRouterHopPreserved, saturatingIncrement - UnitConversions::MetersPerSecondToMilesPerHour - EncryptedStorage getSessionRemainingSeconds - BMI270Sensor::writeRegisters, GPS::hasFlow, FSCommon copyFile, SerialConsole consolePrintf, buzz playLongPressLeadUp, memGet displayPercentHeapFree
152 lines
3.6 KiB
C++
152 lines
3.6 KiB
C++
#include "configuration.h"
|
|
#if HAS_SCREEN
|
|
|
|
#include "graphics/SharedUIDisplay.h"
|
|
#include "graphics/draw/NotificationRenderer.h"
|
|
#include "input/RotaryEncoderInterruptImpl1.h"
|
|
#include "input/UpDownInterruptImpl1.h"
|
|
#include "modules/OnScreenKeyboardModule.h"
|
|
#include <Arduino.h>
|
|
#include <algorithm>
|
|
|
|
namespace graphics
|
|
{
|
|
|
|
OnScreenKeyboardModule &OnScreenKeyboardModule::instance()
|
|
{
|
|
static OnScreenKeyboardModule inst;
|
|
return inst;
|
|
}
|
|
|
|
OnScreenKeyboardModule::~OnScreenKeyboardModule()
|
|
{
|
|
if (keyboard) {
|
|
delete keyboard;
|
|
keyboard = nullptr;
|
|
}
|
|
}
|
|
|
|
void OnScreenKeyboardModule::start(const char *header, const char *initialText, uint32_t durationMs,
|
|
std::function<void(const std::string &)> cb)
|
|
{
|
|
if (keyboard) {
|
|
delete keyboard;
|
|
keyboard = nullptr;
|
|
}
|
|
keyboard = new VirtualKeyboard();
|
|
callback = cb;
|
|
if (header)
|
|
keyboard->setHeader(header);
|
|
if (initialText)
|
|
keyboard->setInputText(initialText);
|
|
|
|
// Route VK submission/cancel events back into the module
|
|
keyboard->setCallback([this](const std::string &text) {
|
|
if (text.empty()) {
|
|
this->onCancel();
|
|
} else {
|
|
this->onSubmit(text);
|
|
}
|
|
});
|
|
|
|
// Maintain legacy compatibility hooks
|
|
NotificationRenderer::virtualKeyboard = keyboard;
|
|
NotificationRenderer::textInputCallback = callback;
|
|
}
|
|
|
|
void OnScreenKeyboardModule::stop(bool callEmptyCallback)
|
|
{
|
|
auto cb = callback;
|
|
callback = nullptr;
|
|
if (keyboard) {
|
|
delete keyboard;
|
|
keyboard = nullptr;
|
|
}
|
|
// Keep NotificationRenderer legacy pointers in sync
|
|
NotificationRenderer::virtualKeyboard = nullptr;
|
|
NotificationRenderer::textInputCallback = nullptr;
|
|
if (callEmptyCallback && cb)
|
|
cb("");
|
|
}
|
|
|
|
void OnScreenKeyboardModule::handleInput(const InputEvent &event)
|
|
{
|
|
if (!keyboard)
|
|
return;
|
|
|
|
if (processVirtualKeyboardInput(event, keyboard))
|
|
return;
|
|
|
|
if (event.inputEvent == INPUT_BROKER_CANCEL)
|
|
onCancel();
|
|
}
|
|
|
|
bool OnScreenKeyboardModule::processVirtualKeyboardInput(const InputEvent &event, VirtualKeyboard *targetKeyboard)
|
|
{
|
|
if (!targetKeyboard)
|
|
return false;
|
|
|
|
switch (event.inputEvent) {
|
|
case INPUT_BROKER_UP:
|
|
case INPUT_BROKER_UP_LONG:
|
|
targetKeyboard->moveCursorUp();
|
|
return true;
|
|
case INPUT_BROKER_DOWN:
|
|
case INPUT_BROKER_DOWN_LONG:
|
|
targetKeyboard->moveCursorDown();
|
|
return true;
|
|
case INPUT_BROKER_LEFT:
|
|
case INPUT_BROKER_ALT_PRESS:
|
|
targetKeyboard->moveCursorLeft();
|
|
return true;
|
|
case INPUT_BROKER_RIGHT:
|
|
case INPUT_BROKER_USER_PRESS:
|
|
targetKeyboard->moveCursorRight();
|
|
return true;
|
|
case INPUT_BROKER_SELECT:
|
|
targetKeyboard->handlePress();
|
|
return true;
|
|
case INPUT_BROKER_SELECT_LONG:
|
|
targetKeyboard->handleLongPress();
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
bool OnScreenKeyboardModule::draw(OLEDDisplay *display)
|
|
{
|
|
if (!keyboard)
|
|
return false;
|
|
|
|
// Timeout
|
|
if (keyboard->isTimedOut()) {
|
|
onCancel();
|
|
return false;
|
|
}
|
|
|
|
// Clear full screen behind keyboard
|
|
display->setColor(BLACK);
|
|
display->fillRect(0, 0, display->getWidth(), display->getHeight());
|
|
display->setColor(WHITE);
|
|
keyboard->draw(display, 0, 0);
|
|
return true;
|
|
}
|
|
|
|
void OnScreenKeyboardModule::onSubmit(const std::string &text)
|
|
{
|
|
auto cb = callback;
|
|
stop(false);
|
|
if (cb)
|
|
cb(text);
|
|
}
|
|
|
|
void OnScreenKeyboardModule::onCancel()
|
|
{
|
|
stop(true);
|
|
}
|
|
|
|
} // namespace graphics
|
|
|
|
#endif // HAS_SCREEN
|