From 29a5465992675e4b91ffb3131b9f52523d372a01 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Tue, 24 Feb 2026 00:10:09 +0100 Subject: [PATCH] lilygo_t_display_s3: fix keyboard handling --- .../lib/mpos/board/lilygo_t_display_s3.py | 19 +++++++++++++++++-- internal_filesystem/lib/mpos/main.py | 8 +++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/internal_filesystem/lib/mpos/board/lilygo_t_display_s3.py b/internal_filesystem/lib/mpos/board/lilygo_t_display_s3.py index 1bd2e5b9..cd939eab 100644 --- a/internal_filesystem/lib/mpos/board/lilygo_t_display_s3.py +++ b/internal_filesystem/lib/mpos/board/lilygo_t_display_s3.py @@ -121,14 +121,29 @@ def keypad_read_cb(indev, data): dt_b = time.ticks_diff(current_time, last_b_down_time) if last_b_down_time else None print(f"combo guard: a={btn_a_pressed} b={btn_b_pressed} near={near_simul} wait={single_press_wait} dt_a={dt_a} dt_b={dt_b}") + # While in an on-screen keyboard, PREV button is LEFT and NEXT button is RIGHT + focus_group = lv.group_get_default() + focus_keyboard = False + if focus_group: + current_focused = focus_group.get_focused() + if isinstance(current_focused, lv.keyboard): + #print("focus is on a keyboard") + focus_keyboard = True + if near_simul: current_key = lv.KEY.ENTER elif single_press_wait: current_key = None elif btn_a_pressed: - current_key = lv.KEY.PREV + if focus_keyboard: + current_key = lv.KEY.LEFT + else: + current_key = lv.KEY.PREV elif btn_b_pressed: - current_key = lv.KEY.NEXT + if focus_keyboard: + current_key = lv.KEY.RIGHT + else: + current_key = lv.KEY.NEXT else: current_key = None diff --git a/internal_filesystem/lib/mpos/main.py b/internal_filesystem/lib/mpos/main.py index eee2a6a2..2a480e74 100644 --- a/internal_filesystem/lib/mpos/main.py +++ b/internal_filesystem/lib/mpos/main.py @@ -184,9 +184,11 @@ def custom_exception_handler(e): sys.print_exception(e) # NOQA # No need to deinit() and re-init LVGL: #mpos.ui.task_handler.deinit() # default task handler does this, but then things hang - # otherwise it does focus_next and then crashes while doing lv.deinit() - #focusgroup.remove_all_objs() - #focusgroup.delete() + #focusgroup = lv.group_get_default() + #if focusgroup: # on esp32 this may not be set + # otherwise it does focus_next and then crashes while doing lv.deinit() + #focusgroup.remove_all_objs() + #focusgroup.delete() #lv.deinit() import sys