diff --git a/README.md b/README.md index 2595327..8fe3ab2 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,9 @@ On distributions based on systemd, `unl0kr` can be used as a [password agent](ht # systemd-ask-password --no-tty # Unl0kr is started ``` +**Note**: SDL2 can be used as display backend for development purposes by setting the Meson option `developer` and use `backend=sdl` in the configuration file. +Other uses besides development are not supported by Buffybox. + ## Packaging Create a full package: diff --git a/f0rmz/README.md b/f0rmz/README.md index be3dd8f..8f8be94 100644 --- a/f0rmz/README.md +++ b/f0rmz/README.md @@ -115,6 +115,7 @@ hostname=mydevice - [libinput] - Input device handling - [libudev] - Device enumeration - [libxkbcommon] - Keyboard layout support +- [libdrm] - DRM backend - evdev kernel module ## Backends diff --git a/f0rmz/lv_conf.h b/f0rmz/lv_conf.h index 40d3a87..0efd1b9 100644 --- a/f0rmz/lv_conf.h +++ b/f0rmz/lv_conf.h @@ -1159,7 +1159,8 @@ *==================*/ /** Use SDL to open window on PC and handle mouse and keyboard. */ -#define LV_USE_SDL 0 +// LV_USE_SDL is defined dynamically via meson.build so we must not define it here +// #define LV_USE_SDL 0 #if LV_USE_SDL #define LV_SDL_INCLUDE_PATH #define LV_SDL_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT /**< LV_DISPLAY_RENDER_MODE_DIRECT is recommended for best performance */ @@ -1231,6 +1232,7 @@ #endif /** Driver for /dev/dri/card */ +// LV_USE_LINUX_DRM is defined dynamically via meson.build so we must not define it here //#define LV_USE_LINUX_DRM 0 #if LV_USE_LINUX_DRM diff --git a/f0rmz/meson.build b/f0rmz/meson.build index 49b52c3..fb266f1 100644 --- a/f0rmz/meson.build +++ b/f0rmz/meson.build @@ -23,6 +23,13 @@ else f0rmz_args += '-DLV_USE_LINUX_DRM=0' endif +if deplibsdl.found() + f0rmz_dependencies += deplibsdl + f0rmz_args += '-DLV_USE_SDL=1' +else + f0rmz_args += '-DLV_USE_SDL=0' +endif + executable('f0rmz', include_directories: common_include_dirs, sources: f0rmz_sources + shared_sources + shared_sources_ul_f0 + squeek2lvgl_sources + lvgl_sources, diff --git a/meson.build b/meson.build index b871d1b..23a2abb 100644 --- a/meson.build +++ b/meson.build @@ -14,6 +14,7 @@ depinih = dependency('inih') deplibinput = dependency('libinput') deplibudev = dependency('libudev') depxkbcommon = dependency('xkbcommon') # For unl0kr and f0rmz only +deplibsdl = dependency('sdl2', required: get_option('developer')) if get_option('man') depscdoc = dependency('scdoc', native: true) diff --git a/meson_options.txt b/meson_options.txt index 4fc1e4b..915beb0 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,5 @@ option('with-drm', type: 'feature', value: 'auto', description: 'Enable DRM backend') +option('developer', type: 'feature', value: 'auto', description: 'Enable developer features') option('man', type: 'boolean', value: true, description: 'Install manual pages') option('systemd-buffyboard-service', type: 'feature', value: 'auto', description: 'Install systemd service file for buffyboard') option('systemd-password-agent', type: 'feature', value: 'auto', description: 'Build a systemd password agent for touchscreens') diff --git a/shared/backends.c b/shared/backends.c index b845ea5..373ac6d 100644 --- a/shared/backends.c +++ b/shared/backends.c @@ -16,6 +16,9 @@ static const char *backends[] = { #endif #if LV_USE_LINUX_DRM "drm", +#endif +#if LV_USE_SDL + "sdl", #endif NULL }; diff --git a/shared/backends.h b/shared/backends.h index 639ec14..3ba9c36 100644 --- a/shared/backends.h +++ b/shared/backends.h @@ -9,7 +9,7 @@ #include "lv_conf.h" -#if LV_USE_LINUX_FBDEV == 0 && LV_USE_LINUX_DRM == 0 +#if LV_USE_LINUX_FBDEV == 0 && LV_USE_LINUX_DRM == 0 && LV_USE_SDL == 0 #error Neither of graphical backends is enabled #endif @@ -26,6 +26,9 @@ typedef enum { #if LV_USE_LINUX_DRM BBX_BACKENDS_BACKEND_DRM, #endif +#if LV_USE_SDL + BBX_BACKENDS_BACKEND_SDL, +#endif } bbx_backends_backend_id_t; /** diff --git a/shared/display.c b/shared/display.c index b3ec2cb..df855e8 100644 --- a/shared/display.c +++ b/shared/display.c @@ -63,6 +63,17 @@ lv_display_t *bbx_display_create(bbx_backends_backend_id_t backend_id, bbx_displ break; #endif /* LV_USE_LINUX_DRM */ +#if LV_USE_SDL + case BBX_BACKENDS_BACKEND_SDL: + bbx_log(BBX_LOG_LEVEL_VERBOSE, "Using SDL2 backend"); + disp = lv_sdl_window_create(config->hor_res > 0 ? config->hor_res: 800, config->ver_res > 0 ? config->ver_res: 480); + if (!disp) { + bbx_log(BBX_LOG_LEVEL_ERROR, "Failed to create SDL2 display"); + return NULL; + } + break; +#endif /* LV_USE_SDL */ + default: bbx_log(BBX_LOG_LEVEL_ERROR, "Unable to find suitable backend"); return NULL; diff --git a/unl0kr/lv_conf.h b/unl0kr/lv_conf.h index 40d3a87..0efd1b9 100644 --- a/unl0kr/lv_conf.h +++ b/unl0kr/lv_conf.h @@ -1159,7 +1159,8 @@ *==================*/ /** Use SDL to open window on PC and handle mouse and keyboard. */ -#define LV_USE_SDL 0 +// LV_USE_SDL is defined dynamically via meson.build so we must not define it here +// #define LV_USE_SDL 0 #if LV_USE_SDL #define LV_SDL_INCLUDE_PATH #define LV_SDL_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT /**< LV_DISPLAY_RENDER_MODE_DIRECT is recommended for best performance */ @@ -1231,6 +1232,7 @@ #endif /** Driver for /dev/dri/card */ +// LV_USE_LINUX_DRM is defined dynamically via meson.build so we must not define it here //#define LV_USE_LINUX_DRM 0 #if LV_USE_LINUX_DRM diff --git a/unl0kr/meson.build b/unl0kr/meson.build index fbffe76..1b70b34 100644 --- a/unl0kr/meson.build +++ b/unl0kr/meson.build @@ -23,6 +23,13 @@ else unl0kr_args += '-DLV_USE_LINUX_DRM=0' endif +if deplibsdl.found() + unl0kr_dependencies += deplibsdl + unl0kr_args += '-DLV_USE_SDL=1' +else + unl0kr_args += '-DLV_USE_SDL=0' +endif + executable('unl0kr', include_directories: common_include_dirs, sources: unl0kr_sources + shared_sources + shared_sources_ul_f0 + squeek2lvgl_sources + lvgl_sources,