From f12cf51e1683bb451399a01e9297c62579a990ab Mon Sep 17 00:00:00 2001 From: LiHaohua Date: Wed, 6 May 2026 11:27:51 +0800 Subject: [PATCH] SDK: sync lv_conf demo flags, expose demos/ include, add NO_KBD_STUBS opt-out sdk/include/lv_conf.h mirrors the emulator's (music + keypad_encoder demos enabled) so apps using the SDK see the same LVGL feature set the host provides. sdk/cmake/CZApp.cmake gains: - demos/ header search path so apps can #include "widgets/lv_demo_widgets.h" etc. - NO_KBD_STUBS option for apps that want to resolve the host's real lv_sdl_keyboard_create at dlopen time (instead of the weak inert stub). Default weak stub stays for the 90% of apps that don't care about keyboard input. Co-Authored-By: Claude Opus 4.7 (1M context) --- sdk/cmake/CZApp.cmake | 21 ++++++++++++++++----- sdk/include/lv_conf.h | 4 ++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/sdk/cmake/CZApp.cmake b/sdk/cmake/CZApp.cmake index 5e86522..31a704d 100644 --- a/sdk/cmake/CZApp.cmake +++ b/sdk/cmake/CZApp.cmake @@ -36,7 +36,13 @@ if(NOT EXISTS "${CZ_LVGL_DIR}/lvgl.h") endif() function(cz_add_lvgl_app TARGET) - cmake_parse_arguments(CZA "" "" "SOURCES" ${ARGN}) + # Options: + # NO_KBD_STUBS — skip the default weak lv_sdl_keyboard_create/handler + # shim. Apps that want real keyboard input (using the + # emulator's real SDL keyboard driver) should set this so + # that the symbols stay unresolved in the .dylib/.so and + # get bound to the host at dlopen time. + cmake_parse_arguments(CZA "NO_KBD_STUBS" "" "SOURCES" ${ARGN}) if(NOT CZA_SOURCES) message(FATAL_ERROR "cz_add_lvgl_app(${TARGET}): no SOURCES given") endif() @@ -51,8 +57,9 @@ function(cz_add_lvgl_app TARGET) ) target_include_directories(${TARGET} PRIVATE - "${CZ_SDK_DIR}/include" # cz_app.h + lv_conf.h - "${CZ_LVGL_DIR}" # lvgl.h + "${CZ_SDK_DIR}/include" # cz_app.h + lv_conf.h + "${CZ_LVGL_DIR}" # lvgl.h + "${CZ_LVGL_DIR}/demos" # demos/widgets/lv_demo_widgets.h etc. ) # Pinned LVGL config — must byte-match the host's. @@ -95,13 +102,17 @@ function(cz_add_lvgl_app TARGET) ) target_sources(${TARGET} PRIVATE "${_weak}") + if(CZA_NO_KBD_STUBS) + return() + endif() + # Default weak keyboard stubs. The emulator always dlsyms # lv_sdl_keyboard_create / lv_sdl_keyboard_handler; when the app provides # neither, the emulator falls back to a bare keypad indev with no read_cb # and LVGL floods the log with "indev_read_cb is not registered". These # stubs give the emulator a real (but inert) indev so the log stays clean. - # Apps that want real keyboard input define their own strong versions and - # override the weak ones at link time. + # Apps that want real keyboard input pass NO_KBD_STUBS and let the + # emulator's real lv_sdl_keyboard_* resolve via dlopen. set(_kbd "${CMAKE_CURRENT_BINARY_DIR}/cz_${TARGET}_kbd_default.c") file(WRITE "${_kbd}" "/* Auto-generated by CZApp.cmake — default no-op SDL keyboard stubs. */\n" diff --git a/sdk/include/lv_conf.h b/sdk/include/lv_conf.h index 451f1b5..db2d93f 100644 --- a/sdk/include/lv_conf.h +++ b/sdk/include/lv_conf.h @@ -495,12 +495,12 @@ #if LV_BUILD_DEMOS #define LV_USE_DEMO_WIDGETS 1 - #define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 + #define LV_USE_DEMO_KEYPAD_AND_ENCODER 1 #define LV_USE_DEMO_BENCHMARK 0 #define LV_USE_DEMO_RENDER 0 #define LV_USE_DEMO_STRESS 0 - #define LV_USE_DEMO_MUSIC 0 + #define LV_USE_DEMO_MUSIC 1 #define LV_USE_DEMO_VECTOR_GRAPHIC 0 #define LV_USE_DEMO_GLTF 0 #define LV_USE_DEMO_FLEX_LAYOUT 0