Fix for trackball

This commit is contained in:
Ken Van Hoeylandt 2026-08-11 21:48:15 +02:00
parent c9452b8aeb
commit 1d0aea255c
3 changed files with 17 additions and 0 deletions

View File

@ -72,6 +72,9 @@
## Lower Priority ## 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. - lvgl-module's spinner relies on hard-coded spinner asset from Tactility main project.
- Localize all apps - Localize all apps
- Support hot-plugging SD card (note: this is not possible if they require the CS pin hack) - Support hot-plugging SD card (note: this is not possible if they require the CS pin hack)

View File

@ -19,6 +19,10 @@ void lvgl_keyboard_on_start_lvgl() {
lvgl_lock(); lvgl_lock();
keyboard_group = lv_group_create(); keyboard_group = lv_group_create();
check(keyboard_group); 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(); lvgl_unlock();
} }

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
#include <lvgl/devices/trackball.h> #include <lvgl/devices/trackball.h>
#include <lvgl/devices/device_context.h> #include <lvgl/devices/device_context.h>
#include <lvgl/devices/keyboard.h>
#include <lvgl/lvgl.h> #include <lvgl/lvgl.h>
#include <tactility/drivers/trackball.h> #include <tactility/drivers/trackball.h>
@ -154,6 +155,13 @@ error_t lvgl_trackball_add(struct Device* device, lv_display_t* display, lv_inde
} }
recenter_cursor(ctx, indev); 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; *out_indev = indev;
return ERROR_NONE; return ERROR_NONE;
} }
@ -196,12 +204,14 @@ error_t lvgl_trackball_set_settings(lv_indev_t* indev, const struct LvglTrackbal
if (mode_changed) { if (mode_changed) {
if (settings->mode == LVGL_TRACKBALL_MODE_POINTER) { if (settings->mode == LVGL_TRACKBALL_MODE_POINTER) {
lvgl_keyboard_disable(indev);
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER); lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
recenter_cursor(ctx, indev); recenter_cursor(ctx, indev);
show_cursor(ctx, indev); show_cursor(ctx, indev);
} else { } else {
hide_cursor(ctx); hide_cursor(ctx);
lv_indev_set_type(indev, LV_INDEV_TYPE_ENCODER); lv_indev_set_type(indev, LV_INDEV_TYPE_ENCODER);
lvgl_keyboard_enable(indev);
} }
} }