1
0
Fork 0
forked from Miroirs/x49gp

Compare commits

..

No commits in common. "846402e9dccc1394ea5ea6c5e455009e9553bac3" and "697dadda7d0e5a5c26c63d81a1f76515d9c693b4" have entirely different histories.

2 changed files with 13 additions and 6 deletions

View file

@ -14,7 +14,8 @@
struct options opt = {
.datadir = NULL,
.config_lua_filename = NULL,
.state_filename = NULL,
.debug_port = 0,
.start_debugger = false,
.reinit = X49GP_REINIT_NONE,
@ -116,6 +117,8 @@ void config_init( char* progname, int argc, char* argv[] )
int option_index;
int c = '?';
char* config_lua_filename = ( char* )"config.lua";
bool do_enable_debugger = false;
bool do_start_debugger = false;
bool do_reflash = false;
@ -216,7 +219,6 @@ void config_init( char* progname, int argc, char* argv[] )
break;
case 'f':
do_reflash = true;
opt.firmware = strdup( optarg );
break;
case 'F':
do_reflash_full = true;
@ -253,14 +255,14 @@ void config_init( char* progname, int argc, char* argv[] )
opt.datadir = g_build_filename( user_config_dir, progname, NULL );
}
const char* config_lua_filename = g_build_filename( opt.datadir, "config.lua", NULL );
opt.config_lua_filename = g_build_filename( opt.datadir, config_lua_filename, NULL );
opt.state_filename = g_build_filename( opt.datadir, "state", NULL );
/**********************/
/* 1. read config.lua */
/**********************/
bool haz_config_file = config_read( config_lua_filename );
bool haz_config_file = config_read( opt.config_lua_filename );
if ( haz_config_file ) {
lua_getglobal( config_lua_values, "newrpl_keyboard" );
opt.newrpl = lua_toboolean( config_lua_values, -1 );
@ -323,9 +325,9 @@ void config_init( char* progname, int argc, char* argv[] )
print_config();
if ( !haz_config_file ) {
fprintf( stderr, "\nConfiguration file %s doesn't seem to exist or is invalid!\n", config_lua_filename );
fprintf( stderr, "\nConfiguration file %s doesn't seem to exist or is invalid!\n", opt.config_lua_filename );
fprintf( stderr, "You can solve this by running `mkdir -p %s/ && %s --print-config >> %s`\n\n", opt.datadir, progname,
config_lua_filename );
opt.config_lua_filename );
}
if ( do_enable_debugger ) {
@ -338,6 +340,10 @@ void config_init( char* progname, int argc, char* argv[] )
if ( opt.reinit < X49GP_REINIT_FLASH )
opt.reinit = X49GP_REINIT_FLASH;
if ( opt.firmware != NULL )
fprintf( stderr, "Additional firmware file \"%s\" specified, overriding\n", optarg );
opt.firmware = optarg;
if ( do_reflash_full )
opt.reinit = X49GP_REINIT_FLASH_FULL;
}

View file

@ -31,6 +31,7 @@ struct options {
char* font;
int display_scale;
int font_size;
char* config_lua_filename;
bool verbose;
char* datadir;