forked from Miroirs/x49gp
make --newrpl-keyboard a distinct option; make --text-scale steps finer (defaults at 2)
This commit is contained in:
parent
62458e2b11
commit
ed48563f14
4 changed files with 35 additions and 62 deletions
|
@ -442,11 +442,8 @@ static int flash_load( x49gp_module_t* module, GKeyFile* key )
|
|||
if ( x49gp->startup_reinit == X49GP_REINIT_FLASH_FULL )
|
||||
memset( phys_ram_base + flash->offset, 0xff, flash->size - st.st_size );
|
||||
|
||||
bootfd = x49gp_module_open_rodata( module,
|
||||
ui->calculator == UI_CALCULATOR_HP49GP || ui->calculator == UI_CALCULATOR_HP49GP_NEWRPL
|
||||
? "firmware/boot-49g+.bin"
|
||||
: "firmware/boot-50g.bin",
|
||||
&bootfile );
|
||||
bootfd = x49gp_module_open_rodata(
|
||||
module, ui->calculator == UI_CALCULATOR_HP49GP ? "firmware/boot-49g+.bin" : "firmware/boot-50g.bin", &bootfile );
|
||||
|
||||
if ( bootfd < 0 ) {
|
||||
g_free( filename );
|
||||
|
|
|
@ -20,8 +20,9 @@ struct options opt = {
|
|||
.reinit = X49GP_REINIT_NONE,
|
||||
.firmware = NULL,
|
||||
.model = MODEL_50G,
|
||||
.newrpl = false,
|
||||
.name = NULL,
|
||||
.text_scale = 1,
|
||||
.text_scale = 2,
|
||||
.display_scale = 2,
|
||||
#if defined( __linux__ )
|
||||
.font = "urw gothic l",
|
||||
|
@ -94,24 +95,22 @@ static void print_config( void )
|
|||
fprintf( stdout, "-- Configuration file for x49gpng\n" );
|
||||
fprintf( stdout, "-- This is a comment\n" );
|
||||
|
||||
fprintf( stdout, "name = \"%s\"\n", opt.name );
|
||||
fprintf( stdout, "name = \"%s\"", opt.name );
|
||||
fprintf( stdout, " -- this customize the title of the window\n" );
|
||||
|
||||
fprintf( stdout, "model = \"" );
|
||||
switch ( opt.model ) {
|
||||
case MODEL_49GP:
|
||||
fprintf( stdout, "49gp" );
|
||||
break;
|
||||
case MODEL_49GP_NEWRPL:
|
||||
fprintf( stdout, "49gp-newrpl" );
|
||||
break;
|
||||
default:
|
||||
case MODEL_50G:
|
||||
fprintf( stdout, "50g" );
|
||||
break;
|
||||
case MODEL_50G_NEWRPL:
|
||||
fprintf( stdout, "50g-newrpl" );
|
||||
break;
|
||||
}
|
||||
fprintf( stdout, "\" -- possible values: \"49gp\", \"50g\", \"49gp-newrpl\", \"50g-newrpl\"\n" );
|
||||
fprintf( stdout, "\" -- possible values: \"49gp\", \"50g\". Changes the colors and the bootloader looked for when (re-)flashing\n" );
|
||||
fprintf( stdout, "newrpl_keyboard = %s", opt.newrpl ? "true" : "false" );
|
||||
fprintf( stdout, " -- when true this makes the keyboard labels more suited to newRPL use\n" );
|
||||
fprintf( stdout, "font = \"%s\"\n", opt.font );
|
||||
fprintf( stdout, "text_scale = %i\n", opt.text_scale );
|
||||
fprintf( stdout, "display_scale = %i\n", opt.display_scale );
|
||||
|
@ -134,6 +133,7 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
char* clopt_name = NULL;
|
||||
char* clopt_font = NULL;
|
||||
int clopt_model = -1;
|
||||
int clopt_newrpl = -1;
|
||||
int clopt_text_scale = -1;
|
||||
int clopt_display_scale = -1;
|
||||
|
||||
|
@ -155,9 +155,8 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
{"reboot", no_argument, NULL, 'r' },
|
||||
|
||||
{"50g", no_argument, NULL, 506 },
|
||||
{"50g-newrpl", no_argument, NULL, 507 },
|
||||
{"49gp", no_argument, NULL, 496 },
|
||||
{"49gp-newrpl", no_argument, NULL, 497 },
|
||||
{"newrpl-keyboard", no_argument, &clopt_newrpl, true},
|
||||
{"name", required_argument, NULL, 'n' },
|
||||
{"text-scale", required_argument, NULL, 's' },
|
||||
{"display-scale", required_argument, NULL, 'S' },
|
||||
|
@ -178,13 +177,12 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
"Valid options:\n"
|
||||
" -h --help print this message and exit\n"
|
||||
" --state[=<filename>] alternate config file\n"
|
||||
" --50g show HP 50g faceplate (default)\n"
|
||||
" --50g-newrpl show HP 50g faceplate with newRPL labels\n"
|
||||
" --49gp show HP 49g+ faceplate\n"
|
||||
" --49gp-newrpl show HP 49g+ faceplate with newRPL labels\n"
|
||||
" --50g emulate an HP 50g (default)\n"
|
||||
" --49gp emulate an HP 49g+\n"
|
||||
" --newrpl-keyboard label keyboard for newRPL\n"
|
||||
" -n --name[=<name>] set alternate UI name\n"
|
||||
" -t --font[=<fontname>] set alternate UI font\n"
|
||||
" -s --text-scale[=<X>] scale text by X (default: 1)\n"
|
||||
" -s --text-scale[=<X>] scale text by X (default: 2)\n"
|
||||
" -S --display-scale[=<X>] scale LCD by X (default: 2)\n"
|
||||
" -D --enable-debug[=<port>] enable the debugger interface\n"
|
||||
" (default port: %u)\n"
|
||||
|
@ -228,21 +226,11 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
if ( clopt_name == NULL )
|
||||
clopt_name = "HP 49g+";
|
||||
break;
|
||||
case 497:
|
||||
clopt_model = MODEL_49GP_NEWRPL;
|
||||
if ( clopt_name == NULL )
|
||||
clopt_name = "HP 49g+ / newRPL";
|
||||
break;
|
||||
case 506:
|
||||
clopt_model = MODEL_50G;
|
||||
if ( clopt_name == NULL )
|
||||
clopt_name = "HP 50g";
|
||||
break;
|
||||
case 507:
|
||||
clopt_model = MODEL_50G_NEWRPL;
|
||||
if ( clopt_name == NULL )
|
||||
clopt_name = "HP 50g / newRPL";
|
||||
break;
|
||||
case 'n':
|
||||
clopt_name = strdup( optarg );
|
||||
break;
|
||||
|
@ -271,31 +259,24 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
/**********************/
|
||||
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 );
|
||||
|
||||
lua_getglobal( config_lua_values, "model" );
|
||||
const char* svalue_model = luaL_optstring( config_lua_values, -1, "50g" );
|
||||
if ( svalue_model != NULL ) {
|
||||
if ( strcmp( svalue_model, "50g" ) == 0 )
|
||||
opt.model = MODEL_50G;
|
||||
if ( strcmp( svalue_model, "50g-newrpl" ) == 0 )
|
||||
opt.model = MODEL_50G_NEWRPL;
|
||||
if ( strcmp( svalue_model, "49gp" ) == 0 )
|
||||
opt.model = MODEL_49GP;
|
||||
if ( strcmp( svalue_model, "49gp-newrpl" ) == 0 )
|
||||
opt.model = MODEL_49GP_NEWRPL;
|
||||
|
||||
switch ( opt.model ) {
|
||||
case MODEL_50G_NEWRPL:
|
||||
opt.name = "HP 50g / newRPL";
|
||||
break;
|
||||
case MODEL_49GP:
|
||||
opt.name = "HP 49g+";
|
||||
break;
|
||||
case MODEL_49GP_NEWRPL:
|
||||
opt.name = "HP 49g+ / newRPL";
|
||||
opt.name = opt.newrpl ? "HP 49g+ / newRPL" : "HP 49g+";
|
||||
break;
|
||||
case MODEL_50G:
|
||||
default:
|
||||
opt.name = "HP 50g";
|
||||
opt.name = opt.newrpl ? "HP 50g / newRPL" : "HP 50g";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -322,6 +303,8 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
opt.font = strdup( clopt_font );
|
||||
if ( clopt_model != -1 )
|
||||
opt.model = clopt_model;
|
||||
if ( clopt_newrpl != -1 )
|
||||
opt.newrpl = clopt_newrpl;
|
||||
if ( clopt_text_scale != -1 )
|
||||
opt.text_scale = clopt_text_scale;
|
||||
if ( clopt_display_scale != -1 )
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
# define PATCHLEVEL 0
|
||||
#endif
|
||||
|
||||
typedef enum { MODEL_49GP = 0, MODEL_49GP_NEWRPL, MODEL_50G, MODEL_50G_NEWRPL } x49gpng_model_t;
|
||||
typedef enum { MODEL_49GP = 0, MODEL_50G } x49gpng_model_t;
|
||||
|
||||
struct options {
|
||||
char* state_filename;
|
||||
|
@ -23,6 +23,7 @@ struct options {
|
|||
x49gp_reinit_t reinit;
|
||||
|
||||
x49gpng_model_t model;
|
||||
bool newrpl;
|
||||
char* name;
|
||||
|
||||
char* font;
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
|
||||
#define NB_KEYS 51
|
||||
|
||||
#define FONT_SIZE_SYMBOL ( 28 * opt.text_scale )
|
||||
#define FONT_SIZE_NUMBER ( 20 * opt.text_scale )
|
||||
#define FONT_SIZE_KEY ( 12 * opt.text_scale )
|
||||
#define FONT_SIZE_TINY ( 10 * opt.text_scale )
|
||||
#define FONT_SIZE_SYMBOL ( 14 * opt.text_scale )
|
||||
#define FONT_SIZE_NUMBER ( 10 * opt.text_scale )
|
||||
#define FONT_SIZE_KEY ( 7 * opt.text_scale )
|
||||
#define FONT_SIZE_TINY ( 6 * opt.text_scale )
|
||||
|
||||
#define TINY_TEXT_HEIGHT ( FONT_SIZE_TINY + 2 )
|
||||
#define TINY_TEXT_WIDTH ( TINY_TEXT_HEIGHT / 2 )
|
||||
|
@ -39,9 +39,9 @@
|
|||
#define KB_WIDTH_6_KEYS ( 36 * opt.text_scale )
|
||||
#define KB_WIDTH_5_KEYS ( 46 * opt.text_scale )
|
||||
|
||||
#define KB_HEIGHT_MENU_KEYS ( 22 * opt.text_scale )
|
||||
#define KB_HEIGHT_SMALL_KEYS ( 28 * opt.text_scale )
|
||||
#define KB_HEIGHT_BIG_KEYS ( 32 * opt.text_scale )
|
||||
#define KB_HEIGHT_MENU_KEYS ( 11 * opt.text_scale )
|
||||
#define KB_HEIGHT_SMALL_KEYS ( 14 * opt.text_scale )
|
||||
#define KB_HEIGHT_BIG_KEYS ( 16 * opt.text_scale )
|
||||
|
||||
#define KB_LINE_HEIGHT ( KB_HEIGHT_BIG_KEYS + ( 1.5 * ( TINY_TEXT_HEIGHT + 2 ) ) )
|
||||
#define KB_SPACING_KEYS TINY_TEXT_WIDTH
|
||||
|
@ -1439,18 +1439,10 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
|
|||
|
||||
/* set calculator type and name */
|
||||
switch ( opt.model ) {
|
||||
case MODEL_50G_NEWRPL:
|
||||
ui->calculator = UI_CALCULATOR_HP50G_NEWRPL;
|
||||
ui->name = opt.name != NULL ? opt.name : "HP 50g / newRPL";
|
||||
break;
|
||||
case MODEL_49GP:
|
||||
ui->calculator = UI_CALCULATOR_HP49GP;
|
||||
ui->name = opt.name != NULL ? opt.name : "HP 49g+";
|
||||
break;
|
||||
case MODEL_49GP_NEWRPL:
|
||||
ui->calculator = UI_CALCULATOR_HP49GP_NEWRPL;
|
||||
ui->name = opt.name != NULL ? opt.name : "HP 49g+ / newRPL";
|
||||
break;
|
||||
case MODEL_50G:
|
||||
default:
|
||||
ui->calculator = UI_CALCULATOR_HP50G;
|
||||
|
@ -1529,7 +1521,7 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
|
|||
|
||||
x49gp_ui_button_t* button;
|
||||
|
||||
if ( ui->calculator == UI_CALCULATOR_HP49GP_NEWRPL || ui->calculator == UI_CALCULATOR_HP50G_NEWRPL )
|
||||
if ( opt.newrpl )
|
||||
_ui_load__newrplify_ui_keys();
|
||||
|
||||
GtkWidget* rows_containers[ KB_NB_ROWS ];
|
||||
|
@ -1635,7 +1627,7 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
|
|||
char* color_bg_50g = "#272727";
|
||||
char* color_shift_left_49gp = "#4060a4";
|
||||
char* color_shift_left_50g = "#f5f5f5";
|
||||
bool is_50g = ( ui->calculator == UI_CALCULATOR_HP50G || ui->calculator == UI_CALCULATOR_HP50G_NEWRPL );
|
||||
bool is_50g = ( ui->calculator == UI_CALCULATOR_HP50G );
|
||||
char* css;
|
||||
|
||||
asprintf( &css, css_global, is_50g ? color_bg_50g : color_bg_49gp, is_50g ? color_shift_left_50g : color_shift_left_49gp,
|
||||
|
|
Loading…
Reference in a new issue