diff --git a/internal_filesystem/lib/mpos/board/waveshare_esp32_s3_touch_lcd_2.py b/internal_filesystem/lib/mpos/board/waveshare_esp32_s3_touch_lcd_2.py index 24cf6afa..e4877906 100644 --- a/internal_filesystem/lib/mpos/board/waveshare_esp32_s3_touch_lcd_2.py +++ b/internal_filesystem/lib/mpos/board/waveshare_esp32_s3_touch_lcd_2.py @@ -11,6 +11,7 @@ import lcd_bus import lvgl as lv import machine import mpos.ui +from mpos import InputManager # Pin configuration SPI_BUS = 2 @@ -83,7 +84,8 @@ mpos.ui.main_display.set_backlight(100) # Touch handling: i2c_bus = i2c.I2C.Bus(host=I2C_BUS, scl=TP_SCL, sda=TP_SDA, freq=I2C_FREQ, use_locks=False) touch_dev = i2c.I2C.Device(bus=i2c_bus, dev_id=TP_ADDR, reg_bits=TP_REGBITS) -indev=cst816s.CST816S(touch_dev,startup_rotation=lv.DISPLAY_ROTATION._180) # button in top left, good +indev = cst816s.CST816S(touch_dev, startup_rotation=lv.DISPLAY_ROTATION._180) # button in top left, good +InputManager.register_indev(indev) mpos.ui.main_display.set_rotation(lv.DISPLAY_ROTATION._90) # must be done after initializing display and creating the touch drivers, to ensure proper handling diff --git a/internal_filesystem/lib/mpos/ui/input_manager.py b/internal_filesystem/lib/mpos/ui/input_manager.py index 95e6358f..ded60e63 100644 --- a/internal_filesystem/lib/mpos/ui/input_manager.py +++ b/internal_filesystem/lib/mpos/ui/input_manager.py @@ -7,6 +7,8 @@ focus management, and input device registration. All methods are class methods, so no instance creation is needed. """ +import lvgl as lv + class InputManager: """ @@ -68,36 +70,11 @@ class InputManager: @classmethod def has_pointer(cls): """Check if any registered input device is a pointer/touch device.""" - import lvgl as lv - if cls.has_indev_type(lv.INDEV_TYPE.POINTER): - return True - get_next = getattr(lv, "indev_get_next", None) - if get_next: - indev = get_next(None) - while indev: - try: - if indev.get_type() == lv.INDEV_TYPE.POINTER: - return True - except Exception: - pass - indev = get_next(indev) - get_active = getattr(lv, "indev_active", None) or getattr(lv, "indev_get_act", None) - if get_active: - try: - indev = get_active() - except Exception: - indev = None - if indev: - try: - return indev.get_type() == lv.INDEV_TYPE.POINTER - except Exception: - return False - return False + return cls.has_indev_type(lv.INDEV_TYPE.POINTER) @classmethod def pointer_xy(cls): """Get current pointer/touch coordinates.""" - import lvgl as lv indev = lv.indev_active() if indev: p = lv.point_t()