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.name = NULL;
opt.text_scale = 1;
opt.display_scale = 1;
opt.display_scale = 2;
#if defined( __linux__ )
opt.font = "urw gothic l";
@ -39,27 +39,27 @@ void config_init( char* progname, int argc, char* argv[] )
const char* optstring = "hrc:D:df:Fn:t:";
struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
{"help", no_argument, NULL, 'h'},
{"config", required_argument, NULL, 'c'},
{"config", required_argument, NULL, 'c'},
{"enable-debug", required_argument, NULL, 'D'},
{"debug", no_argument, NULL, 'd'},
{"reflash", required_argument, NULL, 'f'},
{"reflash-full", no_argument, NULL, 'F'},
{"reboot", no_argument, NULL, 'r'},
{"enable-debug", required_argument, NULL, 'D'},
{"debug", no_argument, NULL, 'd'},
{"reflash", required_argument, NULL, 'f'},
{"reflash-full", no_argument, NULL, 'F'},
{"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},
{"name", required_argument, NULL, 'n'},
{"text-scale", required_argument, NULL, 's'},
{"display-scale", required_argument, NULL, 'S'},
{"50g", no_argument, NULL, 506},
{"50g-newrpl", no_argument, NULL, 507},
{"49gp", no_argument, NULL, 496},
{"49gp-newrpl", no_argument, NULL, 497},
{"name", required_argument, NULL, 'n'},
{"text-scale", required_argument, NULL, 's'},
{"display-scale", required_argument, NULL, 'S'},
{"font", required_argument, NULL, 't'},
{"font", required_argument, NULL, 't'},
{0, 0, 0, 0 }
{0, 0, 0, 0 }
};
while ( c != EOF ) {
@ -79,8 +79,8 @@ void config_init( char* progname, int argc, char* argv[] )
" --49gp-newrpl show HP 49g+ faceplate with newRPL labels\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\n"
" -S --display-scale[=<X>] scale LCD by X\n"
" -s --text-scale[=<X>] scale text by X (default: 1)\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"
" -d --debug use along -D to also start the debugger immediately\n"

View file

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

View file

@ -34,6 +34,69 @@ typedef enum {
UI_CALCULATOR_HP50G_NEWRPL
} 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 {
const char* css_class;
const char* label;