diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 59cb9011..2c6389f3 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -16,7 +16,11 @@ }, "compilerPath": "/usr/bin/gcc", "cStandard": "c11", - "cppStandard": "c++17" + "cppStandard": "c++17", + }, + { + "name": "CMake", + "configurationProvider": "ms-vscode.cmake-tools" } ], "version": 4 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..f6680a37 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.13) + +project(lvgl_simulator) + +set(LVGL_SIMULATOR_SDL_DIR "path-to-sdl-dir" CACHE STRING "Path to the SDL directory") +set(SDL_INCLUDE_DIR ${LVGL_SIMULATOR_SDL_DIR}/include) +set(SDL_LIB_DIR ${LVGL_SIMULATOR_SDL_DIR}/lib) +set(SDL_BIN_DIR ${LVGL_SIMULATOR_SDL_DIR}/bin) + +add_subdirectory(lvgl) +target_include_directories(lvgl PUBLIC ${CMAKE_CURRENT_LIST_DIR}) + +add_subdirectory(lv_examples) +target_include_directories(lv_examples PUBLIC ${CMAKE_CURRENT_LIST_DIR}) +target_link_libraries(lv_examples lvgl) + +add_subdirectory(lv_drivers) +target_include_directories(lv_drivers PUBLIC ${CMAKE_CURRENT_LIST_DIR}) +target_include_directories(lv_drivers PUBLIC ${SDL_INCLUDE_DIR} ) + +add_executable(lv_simulator + main/src/main.c + main/src/mouse_cursor_icon.c +) +target_link_libraries(lv_simulator lvgl lv_examples lv_drivers SDL2) +target_link_directories(lv_simulator PRIVATE ${SDL_LIB_DIR}) + +# Copy SDL2 DLL to the binary dir to avoid adding SDL dir to PATH. +add_custom_command(TARGET lv_simulator POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SDL_BIN_DIR}/SDL2.dll ${CMAKE_BINARY_DIR}/. ) \ No newline at end of file diff --git a/lv_drivers b/lv_drivers index 6a39767f..909e9e88 160000 --- a/lv_drivers +++ b/lv_drivers @@ -1 +1 @@ -Subproject commit 6a39767f0676cbb8ed28ae9f6d82caf3c6ef1ea7 +Subproject commit 909e9e88ae94d282bd6699fb5c0d8cd050517e4b diff --git a/lv_examples b/lv_examples index 8aa74f49..5185d385 160000 --- a/lv_examples +++ b/lv_examples @@ -1 +1 @@ -Subproject commit 8aa74f493bac82a3078ebc98e4139b0eabd34e81 +Subproject commit 5185d3852b8749bdfae5512b625217a8619ace7d diff --git a/lvgl b/lvgl index 43771fa2..e1ac174e 160000 --- a/lvgl +++ b/lvgl @@ -1 +1 @@ -Subproject commit 43771fa2f71d5323ef9dffc1ff0aee326d59f5ce +Subproject commit e1ac174e166f07def7deccaf3b3e8e6b8f658a20 diff --git a/main/src/main.c b/main/src/main.c index 10c949c4..14111c9b 100644 --- a/main/src/main.c +++ b/main/src/main.c @@ -9,6 +9,7 @@ *********************/ #define _DEFAULT_SOURCE /* needed for usleep() */ #include +#include #include #define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" \ issue*/ @@ -16,6 +17,7 @@ #include "lvgl/lvgl.h" #include "lv_drivers/display/monitor.h" #include "lv_drivers/indev/mouse.h" +#include "lv_drivers/indev/keyboard.h" #include "lv_examples/lv_examples.h" /********************* @@ -111,6 +113,13 @@ static void hal_init(void) { lv_img_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/ lv_indev_set_cursor(mouse_indev, cursor_obj); /*Connect the image object to the driver*/ + /* Add keyboard as input device */ + lv_indev_drv_t kb_drv; + lv_indev_drv_init(&kb_drv); + kb_drv.type = LV_INDEV_TYPE_KEYPAD; + kb_drv.read_cb = keyboard_read; + lv_indev_t * kb_indev = lv_indev_drv_register(&kb_drv); + /* Tick init. * You have to call 'lv_tick_inc()' in periodically to inform LittelvGL about * how much time were elapsed Create an SDL thread to do this*/