treewide: add Wayland and SDL2 backends

This commit is contained in:
Dylan Van Assche 2025-11-29 21:37:51 +01:00 committed by Johannes Marbach
parent 271cdf8534
commit e69bcf5dc2
11 changed files with 44 additions and 3 deletions

View file

@ -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:

View file

@ -115,6 +115,7 @@ hostname=mydevice
- [libinput] - Input device handling
- [libudev] - Device enumeration
- [libxkbcommon] - Keyboard layout support
- [libdrm] - DRM backend
- evdev kernel module
## Backends

View file

@ -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 <SDL2/SDL.h>
#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

View file

@ -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,

View file

@ -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)

View file

@ -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')

View file

@ -16,6 +16,9 @@ static const char *backends[] = {
#endif
#if LV_USE_LINUX_DRM
"drm",
#endif
#if LV_USE_SDL
"sdl",
#endif
NULL
};

View file

@ -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;
/**

View file

@ -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;

View file

@ -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 <SDL2/SDL.h>
#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

View file

@ -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,