From 5868ba15c5415786675b2e21269ba6e58345fde4 Mon Sep 17 00:00:00 2001 From: Ken Van Hoeylandt Date: Wed, 13 Aug 2025 21:19:29 +0200 Subject: [PATCH] Create wrapper for lv_textare_create to automatically support hardware keyboards --- CMakeLists.txt | 1 + .../Tactility/app/serialconsole/ConnectView.h | 1 - .../Tactility/app/serialconsole/ConsoleView.h | 2 -- Tactility/Include/Tactility/lvgl/Keyboard.h | 8 -------- Tactility/Source/app/chat/ChatApp.cpp | 1 - Tactility/Source/app/fileselection/View.cpp | 1 - Tactility/Source/app/inputdialog/InputDialog.cpp | 1 - Tactility/Source/app/notes/Notes.cpp | 2 -- Tactility/Source/app/screenshot/Screenshot.cpp | 3 --- Tactility/Source/app/timezone/TimeZone.cpp | 1 - Tactility/Source/app/wificonnect/View.cpp | 4 ---- Tactility/Source/lvgl/Keyboard.cpp | 4 ---- Tactility/Source/lvgl/Wrappers.cpp | 14 ++++++++++++++ TactilityC/Include/tt_lvgl_keyboard.h | 8 -------- TactilityC/Source/tt_init.cpp | 1 - TactilityC/Source/tt_lvgl_keyboard.cpp | 4 ---- 16 files changed, 15 insertions(+), 41 deletions(-) create mode 100644 Tactility/Source/lvgl/Wrappers.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ff5f4c5..50938ae7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ if (DEFINED ENV{ESP_IDF_VERSION}) add_compile_definitions(LV_CONF_PATH="${LVGL_CONFIG_FULL_PATH}/lv_conf_kconfig.h") idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_panic_handler" APPEND) idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=esp_log_write" APPEND) + idf_build_set_property(LINK_OPTIONS "-Wl,--wrap=lv_textarea_create" APPEND) else () message("Building for sim target") add_compile_definitions(CONFIG_TT_BOARD_ID="simulator") diff --git a/Tactility/Include/Tactility/app/serialconsole/ConnectView.h b/Tactility/Include/Tactility/app/serialconsole/ConnectView.h index 4ac49152..6a45b06c 100644 --- a/Tactility/Include/Tactility/app/serialconsole/ConnectView.h +++ b/Tactility/Include/Tactility/app/serialconsole/ConnectView.h @@ -117,7 +117,6 @@ public: lv_textarea_set_one_line(speedTextarea, true); lv_obj_set_width(speedTextarea, LV_PCT(50)); lv_obj_align(speedTextarea, LV_ALIGN_TOP_RIGHT, 0, 40); - service::gui::keyboardAddTextArea(speedTextarea); auto* baud_rate_label = lv_label_create(wrapper); lv_obj_align(baud_rate_label, LV_ALIGN_TOP_LEFT, 0, 50); diff --git a/Tactility/Include/Tactility/app/serialconsole/ConsoleView.h b/Tactility/Include/Tactility/app/serialconsole/ConsoleView.h index df6dee2a..d824dc6b 100644 --- a/Tactility/Include/Tactility/app/serialconsole/ConsoleView.h +++ b/Tactility/Include/Tactility/app/serialconsole/ConsoleView.h @@ -186,7 +186,6 @@ public: lv_obj_set_width(logTextarea, LV_PCT(100)); lv_obj_add_state(logTextarea, LV_STATE_DISABLED); lv_obj_set_style_margin_ver(logTextarea, 0, 0); - service::gui::keyboardAddTextArea(logTextarea); auto* input_wrapper = lv_obj_create(parent); lv_obj_set_size(input_wrapper, LV_PCT(100), LV_SIZE_CONTENT); @@ -200,7 +199,6 @@ public: lv_textarea_set_placeholder_text(inputTextarea, "Text to send"); lv_obj_set_width(inputTextarea, LV_PCT(100)); lv_obj_set_flex_grow(inputTextarea, 1); - service::gui::keyboardAddTextArea(inputTextarea); auto* terminator_dropdown = lv_dropdown_create(input_wrapper); lv_dropdown_set_options(terminator_dropdown, "\\n\n\\r\\n"); diff --git a/Tactility/Include/Tactility/lvgl/Keyboard.h b/Tactility/Include/Tactility/lvgl/Keyboard.h index 92534363..83482e7f 100644 --- a/Tactility/Include/Tactility/lvgl/Keyboard.h +++ b/Tactility/Include/Tactility/lvgl/Keyboard.h @@ -48,12 +48,4 @@ bool hardware_keyboard_is_available(); */ void hardware_keyboard_set_indev(lv_indev_t* device); -/** - * Glue code for the on-screen keyboard and the hardware keyboard: - * - Attach automatic hide/show parameters for the on-screen keyboard. - * - Registers the textarea to the default lv_group_t for hardware keyboards. - * @param[in] textarea - */ -void keyboard_add_textarea(lv_obj_t* textarea); - } \ No newline at end of file diff --git a/Tactility/Source/app/chat/ChatApp.cpp b/Tactility/Source/app/chat/ChatApp.cpp index f0bb1749..9567d6cc 100644 --- a/Tactility/Source/app/chat/ChatApp.cpp +++ b/Tactility/Source/app/chat/ChatApp.cpp @@ -154,7 +154,6 @@ public: lv_obj_set_height(input_field, LV_PCT(100)); lv_textarea_set_placeholder_text(input_field, "Type a message..."); lv_textarea_set_one_line(input_field, true); - service::gui::keyboardAddTextArea(input_field); // Send button auto* send_btn = lv_btn_create(input_panel); diff --git a/Tactility/Source/app/fileselection/View.cpp b/Tactility/Source/app/fileselection/View.cpp index 10513923..87376ed7 100644 --- a/Tactility/Source/app/fileselection/View.cpp +++ b/Tactility/Source/app/fileselection/View.cpp @@ -200,7 +200,6 @@ void View::init(lv_obj_t* parent, Mode mode) { path_textarea = lv_textarea_create(bottom_wrapper); lv_textarea_set_one_line(path_textarea, true); lv_obj_set_flex_grow(path_textarea, 1); - service::gui::keyboardAddTextArea(path_textarea); lv_obj_add_event_cb(path_textarea, onPathTextChanged, LV_EVENT_VALUE_CHANGED, this); select_button = lv_button_create(bottom_wrapper); diff --git a/Tactility/Source/app/inputdialog/InputDialog.cpp b/Tactility/Source/app/inputdialog/InputDialog.cpp index 749b11a6..ebdc7f65 100644 --- a/Tactility/Source/app/inputdialog/InputDialog.cpp +++ b/Tactility/Source/app/inputdialog/InputDialog.cpp @@ -106,7 +106,6 @@ public: if (parameters->optString(PARAMETER_BUNDLE_KEY_PREFILLED, prefilled)) { lv_textarea_set_text(textarea, prefilled.c_str()); } - service::gui::keyboardAddTextArea(textarea); auto* button_wrapper = lv_obj_create(parent); lv_obj_set_flex_flow(button_wrapper, LV_FLEX_FLOW_ROW); diff --git a/Tactility/Source/app/notes/Notes.cpp b/Tactility/Source/app/notes/Notes.cpp index b35e3f12..985bcd94 100644 --- a/Tactility/Source/app/notes/Notes.cpp +++ b/Tactility/Source/app/notes/Notes.cpp @@ -172,8 +172,6 @@ class NotesApp : public App { if (!file::findOrCreateDirectory(context.getPaths()->getDataDirectory(), 0777)) { TT_LOG_E(TAG, "Failed to find or create path %s", context.getPaths()->getDataDirectory().c_str()); } - - lvgl::keyboard_add_textarea(uiNoteText); } void onResult(AppContext& appContext, LaunchId launchId, Result result, std::unique_ptr resultData) override { diff --git a/Tactility/Source/app/screenshot/Screenshot.cpp b/Tactility/Source/app/screenshot/Screenshot.cpp index c414c775..6ced9a23 100644 --- a/Tactility/Source/app/screenshot/Screenshot.cpp +++ b/Tactility/Source/app/screenshot/Screenshot.cpp @@ -271,9 +271,6 @@ void ScreenshotApp::onShow(AppContext& appContext, lv_obj_t* parent) { createFilePathWidgets(wrapper); createTimerSettingsWidgets(wrapper); - service::gui::keyboardAddTextArea(delayTextArea); - service::gui::keyboardAddTextArea(pathTextArea); - updateScreenshotMode(); if (!updateTimer->isRunning()) { diff --git a/Tactility/Source/app/timezone/TimeZone.cpp b/Tactility/Source/app/timezone/TimeZone.cpp index f95326f7..e770ac17 100644 --- a/Tactility/Source/app/timezone/TimeZone.cpp +++ b/Tactility/Source/app/timezone/TimeZone.cpp @@ -221,7 +221,6 @@ public: lv_obj_add_event_cb(textarea, onTextareaValueChangedCallback, LV_EVENT_VALUE_CHANGED, this); filterTextareaWidget = textarea; lv_obj_set_flex_grow(textarea, 1); - service::gui::keyboardAddTextArea(textarea); auto* list = lv_list_create(parent); lv_obj_set_width(list, LV_PCT(100)); diff --git a/Tactility/Source/app/wificonnect/View.cpp b/Tactility/Source/app/wificonnect/View.cpp index e01717f3..d4d4e586 100644 --- a/Tactility/Source/app/wificonnect/View.cpp +++ b/Tactility/Source/app/wificonnect/View.cpp @@ -187,10 +187,6 @@ void View::init(AppContext& app, lv_obj_t* parent) { // Bottom buttons createBottomButtons(wrapper); - // Keyboard bindings - service::gui::keyboardAddTextArea(ssid_textarea); - service::gui::keyboardAddTextArea(password_textarea); - // Init from app parameters auto bundle = app.getParameters(); if (bundle != nullptr) { diff --git a/Tactility/Source/lvgl/Keyboard.cpp b/Tactility/Source/lvgl/Keyboard.cpp index 34783226..abd20004 100644 --- a/Tactility/Source/lvgl/Keyboard.cpp +++ b/Tactility/Source/lvgl/Keyboard.cpp @@ -37,8 +37,4 @@ void hardware_keyboard_set_indev(lv_indev_t* device) { keyboard_device = device; } -void keyboard_add_textarea(lv_obj_t* textarea) { - service::gui::keyboardAddTextArea(textarea); -} - } diff --git a/Tactility/Source/lvgl/Wrappers.cpp b/Tactility/Source/lvgl/Wrappers.cpp new file mode 100644 index 00000000..27e88cba --- /dev/null +++ b/Tactility/Source/lvgl/Wrappers.cpp @@ -0,0 +1,14 @@ +#include +#include + +extern "C" { + +extern lv_obj_t * __real_lv_textarea_create(lv_obj_t * parent); + +lv_obj_t * __wrap_lv_textarea_create(lv_obj_t * parent) { + auto textarea = __real_lv_textarea_create(parent); + tt::service::gui::keyboardAddTextArea(textarea); + return textarea; +} + +} \ No newline at end of file diff --git a/TactilityC/Include/tt_lvgl_keyboard.h b/TactilityC/Include/tt_lvgl_keyboard.h index b7469c9c..78c162c0 100644 --- a/TactilityC/Include/tt_lvgl_keyboard.h +++ b/TactilityC/Include/tt_lvgl_keyboard.h @@ -50,14 +50,6 @@ bool tt_lvgl_hardware_keyboard_is_available(); */ void tt_lvgl_hardware_keyboard_set_indev(lv_indev_t* device); -/** - * Glue code for the on-screen keyboard and the hardware keyboard: - * - Attach automatic hide/show parameters for the on-screen keyboard. - * - Registers the textarea to the default lv_group_t for hardware keyboards. - * @param[in] textarea - */ -void tt_lvgl_keyboard_add_textarea(lv_obj_t* textarea); - #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/TactilityC/Source/tt_init.cpp b/TactilityC/Source/tt_init.cpp index afb75cd0..8a35c66f 100644 --- a/TactilityC/Source/tt_init.cpp +++ b/TactilityC/Source/tt_init.cpp @@ -139,7 +139,6 @@ const struct esp_elfsym elf_symbols[] { ESP_ELFSYM_EXPORT(tt_lvgl_software_keyboard_deactivate), ESP_ELFSYM_EXPORT(tt_lvgl_hardware_keyboard_is_available), ESP_ELFSYM_EXPORT(tt_lvgl_hardware_keyboard_set_indev), - ESP_ELFSYM_EXPORT(tt_lvgl_keyboard_add_textarea), ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_create), ESP_ELFSYM_EXPORT(tt_lvgl_toolbar_create_for_app), ESP_ELFSYM_EXPORT(tt_message_queue_alloc), diff --git a/TactilityC/Source/tt_lvgl_keyboard.cpp b/TactilityC/Source/tt_lvgl_keyboard.cpp index 1a46ce40..db9e3cb2 100644 --- a/TactilityC/Source/tt_lvgl_keyboard.cpp +++ b/TactilityC/Source/tt_lvgl_keyboard.cpp @@ -30,8 +30,4 @@ void tt_lvgl_hardware_keyboard_set_indev(lv_indev_t* device) { tt::lvgl::hardware_keyboard_set_indev(device); } -void tt_lvgl_keyboard_add_textarea(lv_obj_t* textarea) { - tt::lvgl::keyboard_add_textarea(textarea); -} - }