2025-12-08 19:40:30 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "configuration.h"
|
|
|
|
|
#if HAS_SCREEN
|
|
|
|
|
|
|
|
|
|
#include "graphics/Screen.h" // InputEvent
|
|
|
|
|
#include "graphics/VirtualKeyboard.h"
|
|
|
|
|
#include <OLEDDisplay.h>
|
|
|
|
|
#include <functional>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
namespace graphics {
|
|
|
|
|
class OnScreenKeyboardModule {
|
|
|
|
|
public:
|
|
|
|
|
static OnScreenKeyboardModule &instance();
|
2025-12-08 19:40:30 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
void start(const char *header, const char *initialText, uint32_t durationMs, std::function<void(const std::string &)> callback);
|
2025-12-08 19:40:30 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
void stop(bool callEmptyCallback);
|
2025-12-08 19:40:30 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
void handleInput(const InputEvent &event);
|
|
|
|
|
static bool processVirtualKeyboardInput(const InputEvent &event, VirtualKeyboard *keyboard);
|
|
|
|
|
bool draw(OLEDDisplay *display);
|
2025-12-08 19:40:30 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
void showPopup(const char *title, const char *content, uint32_t durationMs);
|
|
|
|
|
void clearPopup();
|
|
|
|
|
// Draw only the popup overlay (used when legacy virtualKeyboard draws the keyboard)
|
|
|
|
|
void drawPopupOverlay(OLEDDisplay *display);
|
2025-12-08 19:40:30 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
private:
|
|
|
|
|
OnScreenKeyboardModule() = default;
|
|
|
|
|
~OnScreenKeyboardModule();
|
|
|
|
|
OnScreenKeyboardModule(const OnScreenKeyboardModule &) = delete;
|
|
|
|
|
OnScreenKeyboardModule &operator=(const OnScreenKeyboardModule &) = delete;
|
2025-12-08 19:40:30 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
void onSubmit(const std::string &text);
|
|
|
|
|
void onCancel();
|
2025-12-08 19:40:30 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
void drawPopup(OLEDDisplay *display);
|
2025-12-08 19:40:30 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
VirtualKeyboard *keyboard = nullptr;
|
|
|
|
|
std::function<void(const std::string &)> callback;
|
2025-12-08 19:40:30 +08:00
|
|
|
|
2026-01-03 21:19:24 +01:00
|
|
|
char popupTitle[64] = {0};
|
|
|
|
|
char popupMessage[256] = {0};
|
|
|
|
|
uint32_t popupUntil = 0;
|
|
|
|
|
bool popupVisible = false;
|
2025-12-08 19:40:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace graphics
|
|
|
|
|
|
|
|
|
|
#endif // HAS_SCREEN
|