[sdl2] minimal UI ported to sdl2, only LCD area displayed for now
This commit is contained in:
parent
6d36927849
commit
d8fdd2e467
7 changed files with 1615 additions and 40 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
||||||
src/*.o
|
src/*.o
|
||||||
src/tools/*.o
|
src/legacy_tools/*.o
|
||||||
|
|
||||||
dist/x48ng*
|
dist/x48ng*
|
||||||
|
|
11
Makefile
11
Makefile
|
@ -105,6 +105,17 @@ ifeq ($(WITH_X11), yes)
|
||||||
DOTOS += src/ui_x11.o
|
DOTOS += src/ui_x11.o
|
||||||
endif
|
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
|
### SDL UI
|
||||||
ifeq ($(WITH_SDL), yes)
|
ifeq ($(WITH_SDL), yes)
|
||||||
SDLCFLAGS = $(shell "$(PKG_CONFIG)" --cflags SDL_gfx sdl12_compat)
|
SDLCFLAGS = $(shell "$(PKG_CONFIG)" --cflags SDL_gfx sdl12_compat)
|
||||||
|
|
83
src/config.c
83
src/config.c
|
@ -255,53 +255,54 @@ int config_init( int argc, char* argv[] )
|
||||||
|
|
||||||
const char* optstring = "c:hvVtsirT";
|
const char* optstring = "c:hvVtsirT";
|
||||||
struct option long_options[] = {
|
struct option long_options[] = {
|
||||||
{"config", required_argument, NULL, 'c' },
|
{"config", required_argument, NULL, 'c' },
|
||||||
{"config-dir", required_argument, NULL, 1000 },
|
{"config-dir", required_argument, NULL, 1000 },
|
||||||
{"rom", required_argument, NULL, 1010 },
|
{"rom", required_argument, NULL, 1010 },
|
||||||
{"ram", required_argument, NULL, 1011 },
|
{"ram", required_argument, NULL, 1011 },
|
||||||
{"state", required_argument, NULL, 1012 },
|
{"state", required_argument, NULL, 1012 },
|
||||||
{"port1", required_argument, NULL, 1013 },
|
{"port1", required_argument, NULL, 1013 },
|
||||||
{"port2", required_argument, NULL, 1014 },
|
{"port2", required_argument, NULL, 1014 },
|
||||||
|
|
||||||
{"serial-line", required_argument, NULL, 1015 },
|
{"serial-line", required_argument, NULL, 1015 },
|
||||||
|
|
||||||
{"help", no_argument, NULL, 'h' },
|
{"help", no_argument, NULL, 'h' },
|
||||||
{"version", no_argument, NULL, 'v' },
|
{"version", no_argument, NULL, 'v' },
|
||||||
|
|
||||||
{"print-config", no_argument, ( int* )&config.print_config, true },
|
{"print-config", no_argument, ( int* )&config.print_config, true },
|
||||||
{"verbose", no_argument, &clopt_verbose, true },
|
{"verbose", no_argument, &clopt_verbose, true },
|
||||||
{"terminal", no_argument, &clopt_useTerminal, true },
|
{"terminal", no_argument, &clopt_useTerminal, true },
|
||||||
{"serial", no_argument, &clopt_useSerial, true },
|
{"serial", no_argument, &clopt_useSerial, true },
|
||||||
|
|
||||||
{"reset", no_argument, ( int* )&config.resetOnStartup, true },
|
{"reset", no_argument, ( int* )&config.resetOnStartup, true },
|
||||||
{"throttle", no_argument, &clopt_throttle, true },
|
{"throttle", no_argument, &clopt_throttle, true },
|
||||||
|
|
||||||
{"debug", no_argument, &clopt_useDebugger, true },
|
{"debug", no_argument, &clopt_useDebugger, true },
|
||||||
|
|
||||||
{"sdl", no_argument, &clopt_frontend_type, FRONTEND_SDL},
|
{"sdl2", no_argument, &clopt_frontend_type, FRONTEND_SDL2},
|
||||||
{"no-chrome", no_argument, &clopt_hide_chrome, true },
|
{"sdl", no_argument, &clopt_frontend_type, FRONTEND_SDL },
|
||||||
{"fullscreen", no_argument, &clopt_show_ui_fullscreen, true },
|
{"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 },
|
{"netbook", no_argument, &clopt_netbook, true },
|
||||||
{"visual", required_argument, NULL, 8110 },
|
{"visual", required_argument, NULL, 8110 },
|
||||||
{"small-font", required_argument, NULL, 8111 },
|
{"small-font", required_argument, NULL, 8111 },
|
||||||
{"medium-font", required_argument, NULL, 8112 },
|
{"medium-font", required_argument, NULL, 8112 },
|
||||||
{"large-font", required_argument, NULL, 8113 },
|
{"large-font", required_argument, NULL, 8113 },
|
||||||
{"connection-font", required_argument, NULL, 8114 },
|
{"connection-font", required_argument, NULL, 8114 },
|
||||||
|
|
||||||
{"tui", no_argument, NULL, 9100 },
|
{"tui", no_argument, NULL, 9100 },
|
||||||
{"tui-small", no_argument, NULL, 9110 },
|
{"tui-small", no_argument, NULL, 9110 },
|
||||||
{"tui-tiny", no_argument, NULL, 9120 },
|
{"tui-tiny", no_argument, NULL, 9120 },
|
||||||
{"small", no_argument, NULL, 9109 }, /* DEPRECATED */
|
{"small", no_argument, NULL, 9109 }, /* DEPRECATED */
|
||||||
{"tiny", no_argument, NULL, 9119 }, /* DEPRECATED */
|
{"tiny", no_argument, NULL, 9119 }, /* DEPRECATED */
|
||||||
|
|
||||||
{"mono", no_argument, &clopt_mono, true },
|
{"mono", no_argument, &clopt_mono, true },
|
||||||
{"gray", no_argument, &clopt_gray, true },
|
{"gray", no_argument, &clopt_gray, true },
|
||||||
{"leave-shift-keys", no_argument, &clopt_leave_shift_keys, true },
|
{"leave-shift-keys", no_argument, &clopt_leave_shift_keys, true },
|
||||||
{"inhibit-shutdown", no_argument, &clopt_inhibit_shutdown, true },
|
{"inhibit-shutdown", no_argument, &clopt_inhibit_shutdown, true },
|
||||||
|
|
||||||
{0, 0, 0, 0 }
|
{0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* help_text = "usage: %s [options]\n"
|
const char* help_text = "usage: %s [options]\n"
|
||||||
|
@ -327,6 +328,7 @@ int config_init( int argc, char* argv[] )
|
||||||
"%s)\n"
|
"%s)\n"
|
||||||
" -V --verbose be verbose (default: false)\n"
|
" -V --verbose be verbose (default: false)\n"
|
||||||
" --x11 use X11 front-end (default: true)\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"
|
" --sdl use SDL front-end (default: false)\n"
|
||||||
" --tui use text 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: "
|
" --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" );
|
lua_getglobal( config_lua_values, "frontend" );
|
||||||
#ifdef HAS_X11
|
#ifdef HAS_X11
|
||||||
# define DEFAULT_FRONTEND "x11"
|
# define DEFAULT_FRONTEND "x11"
|
||||||
|
#elif HAS_SDL2
|
||||||
|
# define DEFAULT_FRONTEND "sdl2"
|
||||||
#elif HAS_SDL
|
#elif HAS_SDL
|
||||||
# define DEFAULT_FRONTEND "sdl"
|
# define DEFAULT_FRONTEND "sdl"
|
||||||
#else
|
#else
|
||||||
|
@ -531,6 +535,8 @@ int config_init( int argc, char* argv[] )
|
||||||
if ( svalue != NULL ) {
|
if ( svalue != NULL ) {
|
||||||
if ( strcmp( svalue, "x11" ) == 0 )
|
if ( strcmp( svalue, "x11" ) == 0 )
|
||||||
config.frontend_type = FRONTEND_X11;
|
config.frontend_type = FRONTEND_X11;
|
||||||
|
if ( strcmp( svalue, "sdl2" ) == 0 )
|
||||||
|
config.frontend_type = FRONTEND_SDL2;
|
||||||
if ( strcmp( svalue, "sdl" ) == 0 )
|
if ( strcmp( svalue, "sdl" ) == 0 )
|
||||||
config.frontend_type = FRONTEND_SDL;
|
config.frontend_type = FRONTEND_SDL;
|
||||||
if ( strcmp( svalue, "tui" ) == 0 ) {
|
if ( strcmp( svalue, "tui" ) == 0 ) {
|
||||||
|
@ -691,6 +697,9 @@ int config_init( int argc, char* argv[] )
|
||||||
case FRONTEND_X11:
|
case FRONTEND_X11:
|
||||||
fprintf( stdout, "x11" );
|
fprintf( stdout, "x11" );
|
||||||
break;
|
break;
|
||||||
|
case FRONTEND_SDL2:
|
||||||
|
fprintf( stdout, "sdl2" );
|
||||||
|
break;
|
||||||
case FRONTEND_SDL:
|
case FRONTEND_SDL:
|
||||||
fprintf( stdout, "sdl" );
|
fprintf( stdout, "sdl" );
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define FRONTEND_SDL2 3
|
||||||
#define FRONTEND_SDL 0
|
#define FRONTEND_SDL 0
|
||||||
#define FRONTEND_X11 1
|
#define FRONTEND_X11 1
|
||||||
#define FRONTEND_TEXT 2
|
#define FRONTEND_TEXT 2
|
||||||
|
|
22
src/ui.c
22
src/ui.c
|
@ -2104,6 +2104,15 @@ void start_UI( int argc, char** argv )
|
||||||
break;
|
break;
|
||||||
#endif
|
#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 )
|
#if defined( HAS_SDL )
|
||||||
case FRONTEND_SDL:
|
case FRONTEND_SDL:
|
||||||
# if !defined( HAS_X11 )
|
# if !defined( HAS_X11 )
|
||||||
|
@ -2114,7 +2123,7 @@ void start_UI( int argc, char** argv )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case FRONTEND_TEXT:
|
case FRONTEND_TEXT:
|
||||||
#if ( !defined( HAS_X11 ) && !defined( HAS_SDL ) )
|
#if ( !defined( HAS_X11 ) && !defined( HAS_SDL2 ) && !defined( HAS_SDL ) )
|
||||||
default:
|
default:
|
||||||
#endif
|
#endif
|
||||||
init_text_ui( argc, argv );
|
init_text_ui( argc, argv );
|
||||||
|
@ -2132,6 +2141,15 @@ void ui_stop( void )
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined( HAS_SDL2 )
|
||||||
|
case FRONTEND_SDL2:
|
||||||
|
# if !defined( HAS_X11 )
|
||||||
|
default:
|
||||||
|
# endif
|
||||||
|
sdl2_ui_stop();
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined( HAS_SDL )
|
#if defined( HAS_SDL )
|
||||||
case FRONTEND_SDL:
|
case FRONTEND_SDL:
|
||||||
# if !defined( HAS_X11 )
|
# if !defined( HAS_X11 )
|
||||||
|
@ -2142,7 +2160,7 @@ void ui_stop( void )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case FRONTEND_TEXT:
|
case FRONTEND_TEXT:
|
||||||
#if ( !defined( HAS_X11 ) && !defined( HAS_SDL ) )
|
#if ( !defined( HAS_X11 ) && !defined( HAS_SDL2 ) && !defined( HAS_SDL ) )
|
||||||
default:
|
default:
|
||||||
#endif
|
#endif
|
||||||
text_ui_stop();
|
text_ui_stop();
|
||||||
|
|
5
src/ui.h
5
src/ui.h
|
@ -21,6 +21,11 @@ extern void init_x11_ui( int argc, char** argv );
|
||||||
extern void x11_ui_stop( void );
|
extern void x11_ui_stop( void );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_SDL2
|
||||||
|
extern void init_sdl2_ui( int argc, char** argv );
|
||||||
|
extern void sdl2_ui_stop( void );
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_SDL
|
#ifdef HAS_SDL
|
||||||
extern void init_sdl_ui( int argc, char** argv );
|
extern void init_sdl_ui( int argc, char** argv );
|
||||||
extern void sdl_ui_stop( void );
|
extern void sdl_ui_stop( void );
|
||||||
|
|
1531
src/ui_sdl2.c
Normal file
1531
src/ui_sdl2.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue