[sdl2] minimal UI ported to sdl2, only LCD area displayed for now

This commit is contained in:
Gwenhael Le Moine 2024-09-04 15:19:16 +02:00
parent 6d36927849
commit d8fdd2e467
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
7 changed files with 1615 additions and 40 deletions

2
.gitignore vendored
View file

@ -1,4 +1,4 @@
src/*.o
src/tools/*.o
src/legacy_tools/*.o
dist/x48ng*

View file

@ -105,6 +105,17 @@ ifeq ($(WITH_X11), yes)
DOTOS += src/ui_x11.o
endif
### SDL2 UI
ifeq ($(WITH_SDL2), yes)
WITH_SDL = no
SDLCFLAGS = $(shell "$(PKG_CONFIG)" --cflags sdl2)
SDLLIBS = $(shell "$(PKG_CONFIG)" --libs sdl2)
override CFLAGS += $(SDLCFLAGS) -DHAS_SDL2=1
LIBS += $(SDLLIBS)
DOTOS += src/ui_sdl2.o
endif
### SDL UI
ifeq ($(WITH_SDL), yes)
SDLCFLAGS = $(shell "$(PKG_CONFIG)" --cflags SDL_gfx sdl12_compat)

View file

@ -278,11 +278,12 @@ int config_init( int argc, char* argv[] )
{"debug", no_argument, &clopt_useDebugger, true },
{"sdl", no_argument, &clopt_frontend_type, FRONTEND_SDL},
{"sdl2", no_argument, &clopt_frontend_type, FRONTEND_SDL2},
{"sdl", no_argument, &clopt_frontend_type, FRONTEND_SDL },
{"no-chrome", no_argument, &clopt_hide_chrome, true },
{"fullscreen", no_argument, &clopt_show_ui_fullscreen, true },
{"x11", no_argument, &clopt_frontend_type, FRONTEND_X11},
{"x11", no_argument, &clopt_frontend_type, FRONTEND_X11 },
{"netbook", no_argument, &clopt_netbook, true },
{"visual", required_argument, NULL, 8110 },
{"small-font", required_argument, NULL, 8111 },
@ -327,6 +328,7 @@ int config_init( int argc, char* argv[] )
"%s)\n"
" -V --verbose be verbose (default: false)\n"
" --x11 use X11 front-end (default: true)\n"
" --sdl2 use SDL2 front-end (default: false)\n"
" --sdl use SDL front-end (default: false)\n"
" --tui use text front-end (default: false)\n"
" --tui-small use text small front-end (2×2 pixels per character) (default: "
@ -522,6 +524,8 @@ int config_init( int argc, char* argv[] )
lua_getglobal( config_lua_values, "frontend" );
#ifdef HAS_X11
# define DEFAULT_FRONTEND "x11"
#elif HAS_SDL2
# define DEFAULT_FRONTEND "sdl2"
#elif HAS_SDL
# define DEFAULT_FRONTEND "sdl"
#else
@ -531,6 +535,8 @@ int config_init( int argc, char* argv[] )
if ( svalue != NULL ) {
if ( strcmp( svalue, "x11" ) == 0 )
config.frontend_type = FRONTEND_X11;
if ( strcmp( svalue, "sdl2" ) == 0 )
config.frontend_type = FRONTEND_SDL2;
if ( strcmp( svalue, "sdl" ) == 0 )
config.frontend_type = FRONTEND_SDL;
if ( strcmp( svalue, "tui" ) == 0 ) {
@ -691,6 +697,9 @@ int config_init( int argc, char* argv[] )
case FRONTEND_X11:
fprintf( stdout, "x11" );
break;
case FRONTEND_SDL2:
fprintf( stdout, "sdl2" );
break;
case FRONTEND_SDL:
fprintf( stdout, "sdl" );
break;

View file

@ -3,6 +3,7 @@
#include <stdbool.h>
#define FRONTEND_SDL2 3
#define FRONTEND_SDL 0
#define FRONTEND_X11 1
#define FRONTEND_TEXT 2

View file

@ -2104,6 +2104,15 @@ void start_UI( int argc, char** argv )
break;
#endif
#if defined( HAS_SDL2 )
case FRONTEND_SDL2:
# if !defined( HAS_X11 )
default:
# endif
init_sdl2_ui( argc, argv );
break;
#endif
#if defined( HAS_SDL )
case FRONTEND_SDL:
# if !defined( HAS_X11 )
@ -2114,7 +2123,7 @@ void start_UI( int argc, char** argv )
#endif
case FRONTEND_TEXT:
#if ( !defined( HAS_X11 ) && !defined( HAS_SDL ) )
#if ( !defined( HAS_X11 ) && !defined( HAS_SDL2 ) && !defined( HAS_SDL ) )
default:
#endif
init_text_ui( argc, argv );
@ -2132,6 +2141,15 @@ void ui_stop( void )
break;
#endif
#if defined( HAS_SDL2 )
case FRONTEND_SDL2:
# if !defined( HAS_X11 )
default:
# endif
sdl2_ui_stop();
break;
#endif
#if defined( HAS_SDL )
case FRONTEND_SDL:
# if !defined( HAS_X11 )
@ -2142,7 +2160,7 @@ void ui_stop( void )
#endif
case FRONTEND_TEXT:
#if ( !defined( HAS_X11 ) && !defined( HAS_SDL ) )
#if ( !defined( HAS_X11 ) && !defined( HAS_SDL2 ) && !defined( HAS_SDL ) )
default:
#endif
text_ui_stop();

View file

@ -21,6 +21,11 @@ extern void init_x11_ui( int argc, char** argv );
extern void x11_ui_stop( void );
#endif
#ifdef HAS_SDL2
extern void init_sdl2_ui( int argc, char** argv );
extern void sdl2_ui_stop( void );
#endif
#ifdef HAS_SDL
extern void init_sdl_ui( int argc, char** argv );
extern void sdl_ui_stop( void );

1531
src/ui_sdl2.c Normal file

File diff suppressed because it is too large Load diff