diff --git a/Documentation/ideas.md b/Documentation/ideas.md index 4d5b07a04..dc64f4e75 100644 --- a/Documentation/ideas.md +++ b/Documentation/ideas.md @@ -72,6 +72,9 @@ ## Lower Priority +- lvgl-module has a keyboard.cpp that creates a `keyboard_group`. This group is set as the default group, so it can also work with trackball(= LVGL "encoder"). + Make a separate group that is the default group. The keyboard can then use it (or use its own). + The basic idea is to invert the ownership: now the keyboard group is made the default group, but it's probably more logical to have the default group used by the keyboard. - lvgl-module's spinner relies on hard-coded spinner asset from Tactility main project. - Localize all apps - Support hot-plugging SD card (note: this is not possible if they require the CS pin hack) diff --git a/Modules/lvgl-module/source/devices/keyboard.cpp b/Modules/lvgl-module/source/devices/keyboard.cpp index 0774fcece..d8c66476f 100644 --- a/Modules/lvgl-module/source/devices/keyboard.cpp +++ b/Modules/lvgl-module/source/devices/keyboard.cpp @@ -19,6 +19,10 @@ void lvgl_keyboard_on_start_lvgl() { lvgl_lock(); keyboard_group = lv_group_create(); check(keyboard_group); + // We currently set this group as the default, so it doesn't only get (manually added) textareas, + // but gets all widgets by default. This is a temporary work-around until a proper default group is + // created to fix the trackball issue (see trackball.cpp and ideas.md, search for "group") + lv_group_set_default(keyboard_group); lvgl_unlock(); } diff --git a/Modules/lvgl-module/source/devices/trackball.cpp b/Modules/lvgl-module/source/devices/trackball.cpp index 266697f8d..6a75aeeac 100644 --- a/Modules/lvgl-module/source/devices/trackball.cpp +++ b/Modules/lvgl-module/source/devices/trackball.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 #include #include +#include #include #include @@ -154,6 +155,13 @@ error_t lvgl_trackball_add(struct Device* device, lv_display_t* display, lv_inde } recenter_cursor(ctx, indev); + // Encoder indevs are useless without a group (LVGL dispatch bails out immediately if indev->group is NULL) + // Use the keyboard group for now, until it's refactored into a proper global/shared group. See ideas.md + // When refactoring this, you probably want to remove the calls to lvgl_keyboard_* below. + if (ctx->settings.mode == LVGL_TRACKBALL_MODE_ENCODER) { + lvgl_keyboard_enable(indev); + } + *out_indev = indev; return ERROR_NONE; } @@ -196,12 +204,14 @@ error_t lvgl_trackball_set_settings(lv_indev_t* indev, const struct LvglTrackbal if (mode_changed) { if (settings->mode == LVGL_TRACKBALL_MODE_POINTER) { + lvgl_keyboard_disable(indev); lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER); recenter_cursor(ctx, indev); show_cursor(ctx, indev); } else { hide_cursor(ctx); lv_indev_set_type(indev, LV_INDEV_TYPE_ENCODER); + lvgl_keyboard_enable(indev); } }