1
0
Fork 0
forked from Miroirs/x49gp

Compare commits

...

3 commits

Author SHA1 Message Date
Gwenhael Le Moine
c7d1a1700e
better keyboard building and scaling 2024-11-10 15:51:49 +01:00
Gwenhael Le Moine
9a74c61462
use opt.display_scale directly as LCD_PIXEL_SCALE 2024-11-10 15:50:05 +01:00
Gwenhael Le Moine
57bb8bd3b8
enum to indek hpkeys 2024-11-10 15:49:03 +01:00
3 changed files with 215 additions and 148 deletions

View file

@ -29,7 +29,7 @@ void config_init( char* progname, int argc, char* argv[] )
opt.model = MODEL_50G; opt.model = MODEL_50G;
opt.name = NULL; opt.name = NULL;
opt.text_scale = 1; opt.text_scale = 1;
opt.display_scale = 1; opt.display_scale = 2;
#if defined( __linux__ ) #if defined( __linux__ )
opt.font = "urw gothic l"; opt.font = "urw gothic l";
@ -79,8 +79,8 @@ void config_init( char* progname, int argc, char* argv[] )
" --49gp-newrpl show HP 49g+ faceplate with newRPL labels\n" " --49gp-newrpl show HP 49g+ faceplate with newRPL labels\n"
" -n --name[=<name>] set alternate UI name\n" " -n --name[=<name>] set alternate UI name\n"
" -t --font[=<fontname>] set alternate UI font\n" " -t --font[=<fontname>] set alternate UI font\n"
" -s --text-scale[=<X>] scale text by X\n" " -s --text-scale[=<X>] scale text by X (default: 1)\n"
" -S --display-scale[=<X>] scale LCD by X\n" " -S --display-scale[=<X>] scale LCD by X (default: 2)\n"
" -D --enable-debug[=<port>] enable the debugger interface\n" " -D --enable-debug[=<port>] enable the debugger interface\n"
" (default port: %u)\n" " (default port: %u)\n"
" -d --debug use along -D to also start the debugger immediately\n" " -d --debug use along -D to also start the debugger immediately\n"

View file

@ -24,10 +24,10 @@
#define NB_KEYS 51 #define NB_KEYS 51
#define FONT_SIZE_SYMBOL ( ( int )( 28 * opt.text_scale ) ) #define FONT_SIZE_SYMBOL ( 28 * opt.text_scale )
#define FONT_SIZE_NUMBER ( ( int )( 20 * opt.text_scale ) ) #define FONT_SIZE_NUMBER ( 20 * opt.text_scale )
#define FONT_SIZE_KEY ( ( int )( 12 * opt.text_scale ) ) #define FONT_SIZE_KEY ( 12 * opt.text_scale )
#define FONT_SIZE_TINY ( ( int )( 10 * opt.text_scale ) ) #define FONT_SIZE_TINY ( 10 * opt.text_scale )
#define TINY_TEXT_HEIGHT ( FONT_SIZE_TINY + 2 ) #define TINY_TEXT_HEIGHT ( FONT_SIZE_TINY + 2 )
#define TINY_TEXT_WIDTH ( TINY_TEXT_HEIGHT / 2 ) #define TINY_TEXT_WIDTH ( TINY_TEXT_HEIGHT / 2 )
@ -36,15 +36,15 @@
#define KB_NB_COLS_MENU 6 #define KB_NB_COLS_MENU 6
#define KB_NB_COLS 5 #define KB_NB_COLS 5
#define KB_WIDTH_6_KEYS 36 #define KB_WIDTH_6_KEYS ( 36 * opt.text_scale )
#define KB_WIDTH_5_KEYS 46 #define KB_WIDTH_5_KEYS ( 46 * opt.text_scale )
#define KB_HEIGHT_MENU_KEYS 22 #define KB_HEIGHT_MENU_KEYS ( 22 * opt.text_scale )
#define KB_HEIGHT_SMALL_KEYS 28 #define KB_HEIGHT_SMALL_KEYS ( 28 * opt.text_scale )
#define KB_HEIGHT_BIG_KEYS 32 #define KB_HEIGHT_BIG_KEYS ( 32 * opt.text_scale )
#define KB_LINE_HEIGHT ( KB_HEIGHT_BIG_KEYS + ( 1.5 * ( TINY_TEXT_HEIGHT + 2 ) ) ) #define KB_LINE_HEIGHT ( KB_HEIGHT_BIG_KEYS + ( 1.5 * ( TINY_TEXT_HEIGHT + 2 ) ) )
#define KB_SPACING_KEYS ( 3 * TINY_TEXT_WIDTH ) #define KB_SPACING_KEYS TINY_TEXT_WIDTH
#define KB_COLUMN_WIDTH_6_KEYS ( KB_WIDTH_6_KEYS + KB_SPACING_KEYS ) #define KB_COLUMN_WIDTH_6_KEYS ( KB_WIDTH_6_KEYS + KB_SPACING_KEYS )
#define KB_COLUMN_WIDTH_5_KEYS ( KB_WIDTH_5_KEYS + KB_SPACING_KEYS ) #define KB_COLUMN_WIDTH_5_KEYS ( KB_WIDTH_5_KEYS + KB_SPACING_KEYS )
@ -52,7 +52,7 @@
#define ANNUNCIATOR_HEIGHT 16 #define ANNUNCIATOR_HEIGHT 16
#define ANNUNCIATORS_HEIGHT ANNUNCIATOR_HEIGHT #define ANNUNCIATORS_HEIGHT ANNUNCIATOR_HEIGHT
#define LCD_PIXEL_SCALE ( ( int )( 2 * opt.display_scale ) ) #define LCD_PIXEL_SCALE opt.display_scale
#define LCD_WIDTH ( 131 * LCD_PIXEL_SCALE ) #define LCD_WIDTH ( 131 * LCD_PIXEL_SCALE )
#define LCD_HEIGHT ( 80 * LCD_PIXEL_SCALE ) #define LCD_HEIGHT ( 80 * LCD_PIXEL_SCALE )
@ -68,7 +68,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "A", .letter = "A",
.left = "Y=", .left = "Y=",
.right = NULL, .right = NULL,
.below = "", .below = NULL,
.column = 5, .column = 5,
.row = 1, .row = 1,
.columnbit = ( 1 << 5 ), .columnbit = ( 1 << 5 ),
@ -79,7 +79,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "B", .letter = "B",
.left = "WIN", .left = "WIN",
.right = NULL, .right = NULL,
.below = "", .below = NULL,
.column = 5, .column = 5,
.row = 2, .row = 2,
.columnbit = ( 1 << 5 ), .columnbit = ( 1 << 5 ),
@ -90,7 +90,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "C", .letter = "C",
.left = "GRAPH", .left = "GRAPH",
.right = NULL, .right = NULL,
.below = "", .below = NULL,
.column = 5, .column = 5,
.row = 3, .row = 3,
.columnbit = ( 1 << 5 ), .columnbit = ( 1 << 5 ),
@ -101,7 +101,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "D", .letter = "D",
.left = "2D/3D", .left = "2D/3D",
.right = NULL, .right = NULL,
.below = "", .below = NULL,
.column = 5, .column = 5,
.row = 4, .row = 4,
.columnbit = ( 1 << 5 ), .columnbit = ( 1 << 5 ),
@ -112,7 +112,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "E", .letter = "E",
.left = "TBLSET", .left = "TBLSET",
.right = NULL, .right = NULL,
.below = "", .below = NULL,
.column = 5, .column = 5,
.row = 5, .row = 5,
.columnbit = ( 1 << 5 ), .columnbit = ( 1 << 5 ),
@ -123,7 +123,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "F", .letter = "F",
.left = "TABLE", .left = "TABLE",
.right = NULL, .right = NULL,
.below = "", .below = NULL,
.column = 5, .column = 5,
.row = 6, .row = 6,
.columnbit = ( 1 << 5 ), .columnbit = ( 1 << 5 ),
@ -135,7 +135,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "G", .letter = "G",
.left = "FILES", .left = "FILES",
.right = "BEGIN", .right = "BEGIN",
.below = "", .below = NULL,
.column = 5, .column = 5,
.row = 7, .row = 7,
.columnbit = ( 1 << 5 ), .columnbit = ( 1 << 5 ),
@ -146,7 +146,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "H", .letter = "H",
.left = "CUSTOM", .left = "CUSTOM",
.right = "END", .right = "END",
.below = "", .below = NULL,
.column = 6, .column = 6,
.row = 5, .row = 5,
.columnbit = ( 1 << 6 ), .columnbit = ( 1 << 6 ),
@ -157,7 +157,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "I", .letter = "I",
.left = "i", .left = "i",
.right = "I", .right = "I",
.below = "", .below = NULL,
.column = 6, .column = 6,
.row = 6, .row = 6,
.columnbit = ( 1 << 6 ), .columnbit = ( 1 << 6 ),
@ -168,7 +168,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "", .left = "",
.right = NULL, .right = NULL,
.below = "", .below = NULL,
.column = 6, .column = 6,
.row = 1, .row = 1,
.columnbit = ( 1 << 6 ), .columnbit = ( 1 << 6 ),
@ -179,7 +179,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "J", .letter = "J",
.left = "UPDIR", .left = "UPDIR",
.right = "COPY", .right = "COPY",
.below = "", .below = NULL,
.column = 6, .column = 6,
.row = 7, .row = 7,
.columnbit = ( 1 << 6 ), .columnbit = ( 1 << 6 ),
@ -190,7 +190,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "K", .letter = "K",
.left = "RCL", .left = "RCL",
.right = "CUT", .right = "CUT",
.below = "", .below = NULL,
.column = 7, .column = 7,
.row = 1, .row = 1,
.columnbit = ( 1 << 7 ), .columnbit = ( 1 << 7 ),
@ -201,7 +201,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "L", .letter = "L",
.left = "PREV", .left = "PREV",
.right = "PASTE", .right = "PASTE",
.below = "", .below = NULL,
.column = 7, .column = 7,
.row = 2, .row = 2,
.columnbit = ( 1 << 7 ), .columnbit = ( 1 << 7 ),
@ -213,7 +213,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "", .left = "",
.right = NULL, .right = NULL,
.below = "", .below = NULL,
.column = 6, .column = 6,
.row = 2, .row = 2,
.columnbit = ( 1 << 6 ), .columnbit = ( 1 << 6 ),
@ -224,7 +224,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "", .left = "",
.right = NULL, .right = NULL,
.below = "", .below = NULL,
.column = 6, .column = 6,
.row = 3, .row = 3,
.columnbit = ( 1 << 6 ), .columnbit = ( 1 << 6 ),
@ -235,7 +235,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "", .left = "",
.right = NULL, .right = NULL,
.below = "", .below = NULL,
.column = 6, .column = 6,
.row = 4, .row = 4,
.columnbit = ( 1 << 6 ), .columnbit = ( 1 << 6 ),
@ -247,7 +247,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "M", .letter = "M",
.left = "CMD", .left = "CMD",
.right = "UNDO", .right = "UNDO",
.below = "", .below = NULL,
.column = 4, .column = 4,
.row = 1, .row = 1,
.columnbit = ( 1 << 4 ), .columnbit = ( 1 << 4 ),
@ -258,7 +258,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "N", .letter = "N",
.left = "PRG", .left = "PRG",
.right = "CHARS", .right = "CHARS",
.below = "", .below = NULL,
.column = 3, .column = 3,
.row = 1, .row = 1,
.columnbit = ( 1 << 3 ), .columnbit = ( 1 << 3 ),
@ -269,7 +269,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "O", .letter = "O",
.left = "MTRW", .left = "MTRW",
.right = "EQW", .right = "EQW",
.below = "", .below = NULL,
.column = 2, .column = 2,
.row = 1, .row = 1,
.columnbit = ( 1 << 2 ), .columnbit = ( 1 << 2 ),
@ -280,7 +280,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "P", .letter = "P",
.left = "MTH", .left = "MTH",
.right = "CAT", .right = "CAT",
.below = "", .below = NULL,
.column = 1, .column = 1,
.row = 1, .row = 1,
.columnbit = ( 1 << 1 ), .columnbit = ( 1 << 1 ),
@ -291,7 +291,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "DEL", .left = "DEL",
.right = "CLEAR", .right = "CLEAR",
.below = "", .below = NULL,
.column = 0, .column = 0,
.row = 1, .row = 1,
.columnbit = ( 1 << 0 ), .columnbit = ( 1 << 0 ),
@ -303,7 +303,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "Q", .letter = "Q",
.left = "𝑒<sup>x</sup>", .left = "𝑒<sup>x</sup>",
.right = "LN", .right = "LN",
.below = "", .below = NULL,
.column = 4, .column = 4,
.row = 2, .row = 2,
.columnbit = ( 1 << 4 ), .columnbit = ( 1 << 4 ),
@ -314,7 +314,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "R", .letter = "R",
.left = "𝓍<sup>2</sup>", .left = "𝓍<sup>2</sup>",
.right = "<sup>x</sup>√𝓎", .right = "<sup>x</sup>√𝓎",
.below = "", .below = NULL,
.column = 3, .column = 3,
.row = 2, .row = 2,
.columnbit = ( 1 << 3 ), .columnbit = ( 1 << 3 ),
@ -325,7 +325,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "S", .letter = "S",
.left = "ASIN", .left = "ASIN",
.right = "", .right = "",
.below = "", .below = NULL,
.column = 2, .column = 2,
.row = 2, .row = 2,
.columnbit = ( 1 << 2 ), .columnbit = ( 1 << 2 ),
@ -336,7 +336,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "T", .letter = "T",
.left = "ACOS", .left = "ACOS",
.right = "", .right = "",
.below = "", .below = NULL,
.column = 1, .column = 1,
.row = 2, .row = 2,
.columnbit = ( 1 << 1 ), .columnbit = ( 1 << 1 ),
@ -347,7 +347,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "U", .letter = "U",
.left = "ATAN", .left = "ATAN",
.right = "", .right = "",
.below = "", .below = NULL,
.column = 0, .column = 0,
.row = 2, .row = 2,
.columnbit = ( 1 << 0 ), .columnbit = ( 1 << 0 ),
@ -359,7 +359,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "V", .letter = "V",
.left = "10<sup>𝓍</sup>", .left = "10<sup>𝓍</sup>",
.right = "LOG", .right = "LOG",
.below = "", .below = NULL,
.column = 4, .column = 4,
.row = 3, .row = 3,
.columnbit = ( 1 << 4 ), .columnbit = ( 1 << 4 ),
@ -370,7 +370,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "W", .letter = "W",
.left = "", .left = "",
.right = "=", .right = "=",
.below = "", .below = NULL,
.column = 3, .column = 3,
.row = 3, .row = 3,
.columnbit = ( 1 << 3 ), .columnbit = ( 1 << 3 ),
@ -381,7 +381,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "X", .letter = "X",
.left = "", .left = "",
.right = "&gt;", .right = "&gt;",
.below = "", .below = NULL,
.column = 2, .column = 2,
.row = 3, .row = 3,
.columnbit = ( 1 << 2 ), .columnbit = ( 1 << 2 ),
@ -392,7 +392,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "Y", .letter = "Y",
.left = "", .left = "",
.right = ">", .right = ">",
.below = "", .below = NULL,
.column = 1, .column = 1,
.row = 3, .row = 3,
.columnbit = ( 1 << 1 ), .columnbit = ( 1 << 1 ),
@ -403,7 +403,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "Z", .letter = "Z",
.left = "ABS", .left = "ABS",
.right = "ARG", .right = "ARG",
.below = "", .below = NULL,
.column = 0, .column = 0,
.row = 3, .row = 3,
.columnbit = ( 1 << 0 ), .columnbit = ( 1 << 0 ),
@ -415,7 +415,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "USER", .left = "USER",
.right = "ENTRY", .right = "ENTRY",
.below = "", .below = NULL,
.column = 0, .column = 0,
.row = 0, .row = 0,
.columnbit = 0, .columnbit = 0,
@ -426,7 +426,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "S.SLV", .left = "S.SLV",
.right = "NUM.SLV", .right = "NUM.SLV",
.below = "", .below = NULL,
.column = 3, .column = 3,
.row = 4, .row = 4,
.columnbit = ( 1 << 3 ), .columnbit = ( 1 << 3 ),
@ -437,7 +437,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "EXP&amp;LN", .left = "EXP&amp;LN",
.right = "TRIG", .right = "TRIG",
.below = "", .below = NULL,
.column = 2, .column = 2,
.row = 4, .row = 4,
.columnbit = ( 1 << 2 ), .columnbit = ( 1 << 2 ),
@ -448,7 +448,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "FINANCE", .left = "FINANCE",
.right = "TIME", .right = "TIME",
.below = "", .below = NULL,
.column = 1, .column = 1,
.row = 4, .row = 4,
.columnbit = ( 1 << 1 ), .columnbit = ( 1 << 1 ),
@ -459,7 +459,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "[ ]", .left = "[ ]",
.right = "\" \"", .right = "\" \"",
.below = "", .below = NULL,
.column = 0, .column = 0,
.row = 4, .row = 4,
.columnbit = ( 1 << 0 ), .columnbit = ( 1 << 0 ),
@ -471,7 +471,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "", .left = "",
.right = NULL, .right = NULL,
.below = "", .below = NULL,
.column = 0, .column = 0,
.row = 0, .row = 0,
.columnbit = 0, .columnbit = 0,
@ -482,7 +482,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "CALC", .left = "CALC",
.right = "ALG", .right = "ALG",
.below = "", .below = NULL,
.column = 3, .column = 3,
.row = 5, .row = 5,
.columnbit = ( 1 << 3 ), .columnbit = ( 1 << 3 ),
@ -493,7 +493,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "MATRICES", .left = "MATRICES",
.right = "STAT", .right = "STAT",
.below = "", .below = NULL,
.column = 2, .column = 2,
.row = 5, .row = 5,
.columnbit = ( 1 << 2 ), .columnbit = ( 1 << 2 ),
@ -504,7 +504,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "CONVERT", .left = "CONVERT",
.right = "UNITS", .right = "UNITS",
.below = "", .below = NULL,
.column = 1, .column = 1,
.row = 5, .row = 5,
.columnbit = ( 1 << 1 ), .columnbit = ( 1 << 1 ),
@ -515,7 +515,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "( )", .left = "( )",
.right = "_", .right = "_",
.below = "", .below = NULL,
.column = 0, .column = 0,
.row = 5, .row = 5,
.columnbit = ( 1 << 0 ), .columnbit = ( 1 << 0 ),
@ -527,7 +527,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "", .left = "",
.right = NULL, .right = NULL,
.below = "", .below = NULL,
.column = 0, .column = 0,
.row = 0, .row = 0,
.columnbit = 0, .columnbit = 0,
@ -538,7 +538,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "ARITH", .left = "ARITH",
.right = "CMPLX", .right = "CMPLX",
.below = "", .below = NULL,
.column = 3, .column = 3,
.row = 6, .row = 6,
.columnbit = ( 1 << 3 ), .columnbit = ( 1 << 3 ),
@ -549,7 +549,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "DEF", .left = "DEF",
.right = "LIB", .right = "LIB",
.below = "", .below = NULL,
.column = 2, .column = 2,
.row = 6, .row = 6,
.columnbit = ( 1 << 2 ), .columnbit = ( 1 << 2 ),
@ -560,7 +560,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "#", .left = "#",
.right = "BASE", .right = "BASE",
.below = "", .below = NULL,
.column = 1, .column = 1,
.row = 6, .row = 6,
.columnbit = ( 1 << 1 ), .columnbit = ( 1 << 1 ),
@ -571,7 +571,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "{ }", .left = "{ }",
.right = "« »", .right = "« »",
.below = "", .below = NULL,
.column = 0, .column = 0,
.row = 6, .row = 6,
.columnbit = ( 1 << 0 ), .columnbit = ( 1 << 0 ),
@ -594,7 +594,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "", .left = "",
.right = "", .right = "",
.below = "", .below = NULL,
.column = 3, .column = 3,
.row = 7, .row = 7,
.columnbit = ( 1 << 3 ), .columnbit = ( 1 << 3 ),
@ -605,7 +605,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = ": :", .left = ": :",
.right = "", .right = "",
.below = "", .below = NULL,
.column = 2, .column = 2,
.row = 7, .row = 7,
.columnbit = ( 1 << 2 ), .columnbit = ( 1 << 2 ),
@ -616,7 +616,7 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.letter = "", .letter = "",
.left = "𝚷", .left = "𝚷",
.right = ",", .right = ",",
.below = "", .below = NULL,
.column = 1, .column = 1,
.row = 7, .row = 7,
.columnbit = ( 1 << 1 ), .columnbit = ( 1 << 1 ),
@ -624,10 +624,10 @@ static x49gp_ui_key_t ui_keys[ NB_KEYS ] = {
.eint = 7}, .eint = 7},
{.css_class = "core", {.css_class = "core",
.label = "ENTER", .label = "ENTER",
.letter = "", .letter = NULL,
.left = "ANS", .left = "ANS",
.right = "→NUM", .right = "→NUM",
.below = "", .below = NULL,
.column = 0, .column = 0,
.row = 7, .row = 7,
.columnbit = ( 1 << 0 ), .columnbit = ( 1 << 0 ),
@ -651,6 +651,8 @@ char* css_global = "window {"
"button {" "button {"
" background-image: none;" " background-image: none;"
" padding: 0px;" " padding: 0px;"
" margin-left: 5px;"
" margin-right: 5px;"
"}" "}"
"button.menu {" "button.menu {"
" background-color: #a9a9a9;" " background-color: #a9a9a9;"
@ -660,6 +662,7 @@ char* css_global = "window {"
"}" "}"
"button.arrow {" "button.arrow {"
" background-color: #e0e0e0;" " background-color: #e0e0e0;"
" border-radius: 33%;"
"}" "}"
"button.alpha {" "button.alpha {"
" background-color: #fae82c;" " background-color: #fae82c;"
@ -943,219 +946,217 @@ static gboolean react_to_key_event( GtkWidget* widget, GdkEventKey* event, gpoin
switch ( keyval ) { switch ( keyval ) {
case GDK_KEY_a: case GDK_KEY_a:
case GDK_KEY_F1: case GDK_KEY_F1:
index = 0; index = HPKEY_A;
break; break;
case GDK_KEY_b: case GDK_KEY_b:
case GDK_KEY_F2: case GDK_KEY_F2:
index = 1; index = HPKEY_B;
break; break;
case GDK_KEY_c: case GDK_KEY_c:
case GDK_KEY_F3: case GDK_KEY_F3:
index = 2; index = HPKEY_C;
break; break;
case GDK_KEY_d: case GDK_KEY_d:
case GDK_KEY_F4: case GDK_KEY_F4:
index = 3; index = HPKEY_D;
break; break;
case GDK_KEY_e: case GDK_KEY_e:
case GDK_KEY_F5: case GDK_KEY_F5:
index = 4; index = HPKEY_E;
break; break;
case GDK_KEY_f: case GDK_KEY_f:
case GDK_KEY_F6: case GDK_KEY_F6:
index = 5; index = HPKEY_F;
break; break;
case GDK_KEY_g: case GDK_KEY_g:
index = 6; index = HPKEY_G;
break; break;
case GDK_KEY_h: case GDK_KEY_h:
index = 7; index = HPKEY_H;
break; break;
case GDK_KEY_i: case GDK_KEY_i:
index = 8; index = HPKEY_I;
break; break;
case GDK_KEY_j: case GDK_KEY_j:
index = 9; index = HPKEY_J;
break; break;
case GDK_KEY_k: case GDK_KEY_k:
index = 10; index = HPKEY_K;
break; break;
case GDK_KEY_l: case GDK_KEY_l:
index = 11; index = HPKEY_L;
break; break;
case GDK_KEY_Up: case GDK_KEY_Up:
case GDK_KEY_KP_Up: case GDK_KEY_KP_Up:
index = 12; index = HPKEY_UP;
break; break;
case GDK_KEY_Left: case GDK_KEY_Left:
case GDK_KEY_KP_Left: case GDK_KEY_KP_Left:
index = 13; index = HPKEY_LEFT;
break; break;
case GDK_KEY_Down: case GDK_KEY_Down:
case GDK_KEY_KP_Down: case GDK_KEY_KP_Down:
index = 14; index = HPKEY_DOWN;
break; break;
case GDK_KEY_Right: case GDK_KEY_Right:
case GDK_KEY_KP_Right: case GDK_KEY_KP_Right:
index = 15; index = HPKEY_RIGHT;
break; break;
case GDK_KEY_m: case GDK_KEY_m:
index = 16; index = HPKEY_M;
break; break;
case GDK_KEY_n: case GDK_KEY_n:
index = 17; index = HPKEY_N;
break; break;
case GDK_KEY_o: case GDK_KEY_o:
case GDK_KEY_apostrophe: case GDK_KEY_apostrophe:
index = 18; index = HPKEY_O;
break; break;
case GDK_KEY_p: case GDK_KEY_p:
index = 19; index = HPKEY_P;
break; break;
case GDK_KEY_BackSpace: case GDK_KEY_BackSpace:
case GDK_KEY_Delete: case GDK_KEY_Delete:
case GDK_KEY_KP_Delete: case GDK_KEY_KP_Delete:
index = 20; index = HPKEY_BACKSPACE;
break; break;
case GDK_KEY_dead_circumflex: case GDK_KEY_dead_circumflex:
case GDK_KEY_asciicircum: case GDK_KEY_asciicircum:
case GDK_KEY_q: case GDK_KEY_q:
case GDK_KEY_caret: case GDK_KEY_caret:
index = 21; index = HPKEY_Q;
break; break;
case GDK_KEY_r: case GDK_KEY_r:
index = 22; index = HPKEY_R;
break; break;
case GDK_KEY_s: case GDK_KEY_s:
index = 23; index = HPKEY_S;
break; break;
case GDK_KEY_t: case GDK_KEY_t:
index = 24; index = HPKEY_T;
break; break;
case GDK_KEY_u: case GDK_KEY_u:
index = 25; index = HPKEY_U;
break; break;
case GDK_KEY_v: case GDK_KEY_v:
index = 26; index = HPKEY_V;
break; break;
case GDK_KEY_w: case GDK_KEY_w:
index = 27; index = HPKEY_W;
break; break;
case GDK_KEY_x: case GDK_KEY_x:
index = 28; index = HPKEY_X;
break; break;
case GDK_KEY_y: case GDK_KEY_y:
index = 29; index = HPKEY_Y;
break; break;
case GDK_KEY_z: case GDK_KEY_z:
case GDK_KEY_slash: case GDK_KEY_slash:
case GDK_KEY_KP_Divide: case GDK_KEY_KP_Divide:
index = 30; index = HPKEY_Z;
break; break;
case GDK_KEY_Tab: case GDK_KEY_Tab:
index = 31;
break;
#ifndef __APPLE__ #ifndef __APPLE__
case GDK_KEY_Alt_L: case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R: case GDK_KEY_Alt_R:
case GDK_KEY_Meta_L: case GDK_KEY_Meta_L:
case GDK_KEY_Meta_R: case GDK_KEY_Meta_R:
case GDK_KEY_Mode_switch: case GDK_KEY_Mode_switch:
index = 31;
break;
#endif #endif
index = HPKEY_ALPHA;
break;
case GDK_KEY_7: case GDK_KEY_7:
case GDK_KEY_KP_7: case GDK_KEY_KP_7:
index = 32; index = HPKEY_7;
break; break;
case GDK_KEY_8: case GDK_KEY_8:
case GDK_KEY_KP_8: case GDK_KEY_KP_8:
index = 33; index = HPKEY_8;
break; break;
case GDK_KEY_9: case GDK_KEY_9:
case GDK_KEY_KP_9: case GDK_KEY_KP_9:
index = 34; index = HPKEY_9;
break; break;
case GDK_KEY_multiply: case GDK_KEY_multiply:
case GDK_KEY_KP_Multiply: case GDK_KEY_KP_Multiply:
index = 35; index = HPKEY_MULTIPLY;
break; break;
case GDK_KEY_Shift_L: case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R: case GDK_KEY_Shift_R:
index = 36; index = HPKEY_SHIFT_LEFT;
break; break;
case GDK_KEY_4: case GDK_KEY_4:
case GDK_KEY_KP_4: case GDK_KEY_KP_4:
index = 37; index = HPKEY_4;
break; break;
case GDK_KEY_5: case GDK_KEY_5:
case GDK_KEY_KP_5: case GDK_KEY_KP_5:
index = 38; index = HPKEY_5;
break; break;
case GDK_KEY_6: case GDK_KEY_6:
case GDK_KEY_KP_6: case GDK_KEY_KP_6:
index = 39; index = HPKEY_6;
break; break;
case GDK_KEY_minus: case GDK_KEY_minus:
case GDK_KEY_KP_Subtract: case GDK_KEY_KP_Subtract:
index = 40; index = HPKEY_MINUS;
break; break;
case GDK_KEY_Control_L: case GDK_KEY_Control_L:
case GDK_KEY_Control_R: case GDK_KEY_Control_R:
index = 41; index = HPKEY_SHIFT_RIGHT;
break; break;
case GDK_KEY_1: case GDK_KEY_1:
case GDK_KEY_KP_1: case GDK_KEY_KP_1:
index = 42; index = HPKEY_1;
break; break;
case GDK_KEY_2: case GDK_KEY_2:
case GDK_KEY_KP_2: case GDK_KEY_KP_2:
index = 43; index = HPKEY_2;
break; break;
case GDK_KEY_3: case GDK_KEY_3:
case GDK_KEY_KP_3: case GDK_KEY_KP_3:
index = 44; index = HPKEY_3;
break; break;
case GDK_KEY_plus: case GDK_KEY_plus:
case GDK_KEY_KP_Add: case GDK_KEY_KP_Add:
index = 45; index = HPKEY_PLUS;
break; break;
case GDK_KEY_Escape: case GDK_KEY_Escape:
index = 46; index = HPKEY_ON;
break; break;
case GDK_KEY_0: case GDK_KEY_0:
case GDK_KEY_KP_0: case GDK_KEY_KP_0:
index = 47; index = HPKEY_0;
break; break;
case GDK_KEY_period: case GDK_KEY_period:
case GDK_KEY_comma: case GDK_KEY_comma:
case GDK_KEY_KP_Decimal: case GDK_KEY_KP_Decimal:
case GDK_KEY_KP_Separator: case GDK_KEY_KP_Separator:
index = 48; index = HPKEY_PERIOD;
break; break;
case GDK_KEY_space: case GDK_KEY_space:
case GDK_KEY_KP_Space: case GDK_KEY_KP_Space:
index = 49; index = HPKEY_SPACE;
break; break;
case GDK_KEY_Return: case GDK_KEY_Return:
case GDK_KEY_KP_Enter: case GDK_KEY_KP_Enter:
index = 50; index = HPKEY_ENTER;
break; break;
/* QWERTY compat: US English, UK English, International English */ /* QWERTY compat: US English, UK English, International English */
case GDK_KEY_backslash: case GDK_KEY_backslash:
index = 35; index = HPKEY_MULTIPLY;
break; break;
case GDK_KEY_equal: case GDK_KEY_equal:
index = 45; index = HPKEY_PLUS;
break; break;
/* QWERTZ compat: German */ /* QWERTZ compat: German */
case GDK_KEY_ssharp: case GDK_KEY_ssharp:
index = 30; index = HPKEY_Z;
break; break;
case GDK_KEY_numbersign: case GDK_KEY_numbersign:
index = 35; index = HPKEY_MULTIPLY;
break; break;
case GDK_KEY_F7: case GDK_KEY_F7:
@ -1387,7 +1388,7 @@ static inline void _ui_load__newrplify_ui_keys()
ui_keys[ 43 ].left = ""; ui_keys[ 43 ].left = "";
ui_keys[ 46 ].left = ""; ui_keys[ 46 ].left = "";
ui_keys[ 46 ].below = ""; ui_keys[ 46 ].below = NULL;
ui_keys[ 50 ].left = ""; ui_keys[ 50 ].left = "";
} }
@ -1458,7 +1459,6 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
} }
// create window and widgets/stuff // create window and widgets/stuff
GtkWidget* window_container = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
ui->ui_ann_left = _ui_load__create_annunciator_widget( ui, "" ); ui->ui_ann_left = _ui_load__create_annunciator_widget( ui, "" );
ui->ui_ann_right = _ui_load__create_annunciator_widget( ui, "" ); ui->ui_ann_right = _ui_load__create_annunciator_widget( ui, "" );
ui->ui_ann_alpha = _ui_load__create_annunciator_widget( ui, "α" ); ui->ui_ann_alpha = _ui_load__create_annunciator_widget( ui, "α" );
@ -1472,9 +1472,9 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
gtk_window_set_decorated( GTK_WINDOW( ui->window ), true ); gtk_window_set_decorated( GTK_WINDOW( ui->window ), true );
gtk_window_set_resizable( GTK_WINDOW( ui->window ), true ); gtk_window_set_resizable( GTK_WINDOW( ui->window ), true );
gtk_window_set_title( GTK_WINDOW( ui->window ), ui->name ); gtk_window_set_title( GTK_WINDOW( ui->window ), ui->name );
gtk_widget_realize( ui->window );
GtkWidget* window_container = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
gtk_container_add( GTK_CONTAINER( ui->window ), window_container ); gtk_container_add( GTK_CONTAINER( ui->window ), window_container );
gtk_style_context_add_class( gtk_widget_get_style_context( ui->window ), "main-window" );
g_signal_connect( G_OBJECT( ui->window ), "focus-out-event", G_CALLBACK( react_to_focus_lost ), x49gp ); g_signal_connect( G_OBJECT( ui->window ), "focus-out-event", G_CALLBACK( react_to_focus_lost ), x49gp );
g_signal_connect( G_OBJECT( ui->window ), "key-press-event", G_CALLBACK( react_to_key_event ), x49gp ); g_signal_connect( G_OBJECT( ui->window ), "key-press-event", G_CALLBACK( react_to_key_event ), x49gp );
@ -1543,7 +1543,7 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
gtk_container_add( GTK_CONTAINER( keyboard_container ), rows_containers[ row ] ); gtk_container_add( GTK_CONTAINER( keyboard_container ), rows_containers[ row ] );
for ( int column = 0; column < ( ( row == 0 ) ? KB_NB_COLS_MENU : KB_NB_COLS ); column++ ) { for ( int column = 0; column < ( ( row == 0 ) ? KB_NB_COLS_MENU : KB_NB_COLS ); column++ ) {
keys_containers[ key_index ] = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 ); keys_containers[ key_index ] = gtk_box_new( GTK_ORIENTATION_VERTICAL, 3 );
gtk_box_set_homogeneous( GTK_BOX( keys_containers[ key_index ] ), false ); gtk_box_set_homogeneous( GTK_BOX( keys_containers[ key_index ] ), false );
gtk_container_add( GTK_CONTAINER( rows_containers[ row ] ), keys_containers[ key_index ] ); gtk_container_add( GTK_CONTAINER( rows_containers[ row ] ), keys_containers[ key_index ] );
@ -1567,6 +1567,10 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
button->button = gtk_button_new(); button->button = gtk_button_new();
gtk_style_context_add_class( gtk_widget_get_style_context( button->button ), button->key->css_class ); gtk_style_context_add_class( gtk_widget_get_style_context( button->button ), button->key->css_class );
gtk_widget_set_size_request( button->button, ( row == 0 ) ? KB_WIDTH_6_KEYS : KB_WIDTH_5_KEYS,
( row == 0 ) ? KB_HEIGHT_MENU_KEYS
: ( key_index < 40 ) ? KB_HEIGHT_SMALL_KEYS
: KB_HEIGHT_BIG_KEYS );
gtk_widget_set_can_focus( button->button, false ); gtk_widget_set_can_focus( button->button, false );
gtk_widget_add_events( button->button, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK ); gtk_widget_add_events( button->button, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK );
g_signal_connect( G_OBJECT( button->button ), "button-press-event", G_CALLBACK( react_to_button_press ), button ); g_signal_connect( G_OBJECT( button->button ), "button-press-event", G_CALLBACK( react_to_button_press ), button );
@ -1577,13 +1581,12 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
gtk_container_add( GTK_CONTAINER( keys_containers[ key_index ] ), button->button ); gtk_container_add( GTK_CONTAINER( keys_containers[ key_index ] ), button->button );
if ( button->key->letter )
gtk_container_add( GTK_CONTAINER( keys_containers[ key_index ] ),
_ui_load__create_label( "label-letter", button->key->letter ) );
if ( button->key->below ) if ( button->key->below )
gtk_container_add( GTK_CONTAINER( keys_containers[ key_index ] ), gtk_container_add( GTK_CONTAINER( keys_containers[ key_index ] ),
_ui_load__create_label( "label-below", button->key->below ) ); _ui_load__create_label( "label-below", button->key->below ) );
if ( button->key->letter )
gtk_container_add( GTK_CONTAINER( keys_containers[ key_index ] ),
_ui_load__create_label( "label-letter", button->key->letter ) );
key_index++; key_index++;
} }
@ -1646,6 +1649,7 @@ static int ui_load( x49gp_module_t* module, GKeyFile* keyfile )
g_object_unref( style_provider ); g_object_unref( style_provider );
// finally show the window // finally show the window
gtk_widget_realize( ui->window );
gtk_widget_show_all( ui->window ); gtk_widget_show_all( ui->window );
return 0; return 0;

View file

@ -34,6 +34,69 @@ typedef enum {
UI_CALCULATOR_HP50G_NEWRPL UI_CALCULATOR_HP50G_NEWRPL
} x49gp_ui_calculator_t; } x49gp_ui_calculator_t;
typedef enum {
HPKEY_A = 0,
HPKEY_B,
HPKEY_C,
HPKEY_D,
HPKEY_E,
HPKEY_F,
HPKEY_G,
HPKEY_H,
HPKEY_I,
HPKEY_UP,
HPKEY_J, /* 10 */
HPKEY_K,
HPKEY_L,
HPKEY_LEFT,
HPKEY_DOWN,
HPKEY_RIGHT,
HPKEY_M,
HPKEY_N,
HPKEY_O,
HPKEY_P,
HPKEY_BACKSPACE, /* 20 */
HPKEY_Q,
HPKEY_R,
HPKEY_S,
HPKEY_T,
HPKEY_U,
HPKEY_V,
HPKEY_W,
HPKEY_X,
HPKEY_Y,
HPKEY_Z, /* 30 */
HPKEY_ALPHA,
HPKEY_7,
HPKEY_8,
HPKEY_9,
HPKEY_MULTIPLY,
HPKEY_SHIFT_LEFT,
HPKEY_4,
HPKEY_5,
HPKEY_6,
HPKEY_MINUS, /* 40 */
HPKEY_SHIFT_RIGHT,
HPKEY_1,
HPKEY_2,
HPKEY_3,
HPKEY_PLUS,
HPKEY_ON,
HPKEY_0,
HPKEY_PERIOD,
HPKEY_SPACE,
HPKEY_ENTER, /* 50 */
} x49gp_ui_hpkey_t;
typedef struct { typedef struct {
const char* css_class; const char* css_class;
const char* label; const char* label;