naming variables/functions/fields; simplify keyboard handling

This commit is contained in:
Gwenhael Le Moine 2024-04-12 15:55:01 +02:00
parent ab453314aa
commit d12a20df29
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
5 changed files with 463 additions and 321 deletions

View file

@ -19,13 +19,13 @@ SDL_Surface* surfA[ 49 ];
SDL_Texture* textA[ 49 ]; SDL_Texture* textA[ 49 ];
SDL_Surface* surfB[ 49 ]; SDL_Surface* surfB[ 49 ];
SDL_Texture* textB[ 49 ]; SDL_Texture* label_Lshift[ 49 ];
SDL_Surface* surfC[ 49 ]; SDL_Surface* surfC[ 49 ];
SDL_Texture* textC[ 49 ]; SDL_Texture* label_Rshift[ 49 ];
SDL_Surface* surfD[ 49 ]; SDL_Surface* surfD[ 49 ];
SDL_Texture* textD[ 49 ]; SDL_Texture* label_below[ 49 ];
#define PANEL_FLAG_VISIBLE 0x01 #define PANEL_FLAG_VISIBLE 0x01
@ -41,7 +41,7 @@ static inline void drawText( int index, int x, int y, int btn_w, int btn_h )
} }
SDL_Surface* letterSurface2 = surfB[ index ]; SDL_Surface* letterSurface2 = surfB[ index ];
SDL_Texture* letterTexture2 = textB[ index ]; SDL_Texture* letterTexture2 = label_Lshift[ index ];
if ( letterSurface2 != NULL && letterTexture2 != NULL ) { if ( letterSurface2 != NULL && letterTexture2 != NULL ) {
int texW = letterSurface2->w; int texW = letterSurface2->w;
int texH = letterSurface2->h; int texH = letterSurface2->h;
@ -52,7 +52,7 @@ static inline void drawText( int index, int x, int y, int btn_w, int btn_h )
} }
SDL_Surface* letterSurface3 = surfC[ index ]; SDL_Surface* letterSurface3 = surfC[ index ];
SDL_Texture* letterTexture3 = textC[ index ]; SDL_Texture* letterTexture3 = label_Rshift[ index ];
if ( letterSurface3 != NULL && letterTexture3 != NULL ) { if ( letterSurface3 != NULL && letterTexture3 != NULL ) {
int texW = letterSurface3->w; int texW = letterSurface3->w;
int texH = letterSurface3->h; int texH = letterSurface3->h;
@ -63,7 +63,7 @@ static inline void drawText( int index, int x, int y, int btn_w, int btn_h )
} }
SDL_Surface* letterSurface4 = surfD[ index ]; SDL_Surface* letterSurface4 = surfD[ index ];
SDL_Texture* letterTexture4 = textD[ index ]; SDL_Texture* letterTexture4 = label_below[ index ];
if ( letterSurface4 != NULL && letterTexture4 != NULL ) { if ( letterSurface4 != NULL && letterTexture4 != NULL ) {
int texW = letterSurface4->w; int texW = letterSurface4->w;
int texH = letterSurface4->h; int texH = letterSurface4->h;
@ -88,11 +88,11 @@ void gui_initKeyboard( Button* calcbuttons )
int i = 0; int i = 0;
Button* buttons = calcbuttons; Button* buttons = calcbuttons;
while ( buttons->text ) { while ( buttons->label ) {
SDL_Surface* s = NULL; SDL_Surface* s = NULL;
SDL_Texture* t = NULL; SDL_Texture* t = NULL;
if ( buttons->text && strcmp( buttons->text, "" ) != 0 ) { if ( buttons->label && strcmp( buttons->label, "" ) != 0 ) {
s = TTF_RenderUTF8_Blended( ttffont, buttons->text, couleurBlanche ); s = TTF_RenderUTF8_Blended( ttffont, buttons->label, couleurBlanche );
if ( s ) { if ( s ) {
t = SDL_CreateTextureFromSurface( renderer, s ); t = SDL_CreateTextureFromSurface( renderer, s );
} }
@ -107,51 +107,51 @@ void gui_initKeyboard( Button* calcbuttons )
i = 0; i = 0;
buttons = calcbuttons; buttons = calcbuttons;
while ( buttons->textB ) { while ( buttons->label_Lshift ) {
SDL_Surface* s = NULL; SDL_Surface* s = NULL;
SDL_Texture* t = NULL; SDL_Texture* t = NULL;
if ( buttons->textB && strcmp( buttons->textB, "" ) != 0 ) { if ( buttons->label_Lshift && strcmp( buttons->label_Lshift, "" ) != 0 ) {
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textB, couleurPurple ); s = TTF_RenderUTF8_Blended( ttffont2, buttons->label_Lshift, couleurPurple );
if ( s ) { if ( s ) {
t = SDL_CreateTextureFromSurface( renderer, s ); t = SDL_CreateTextureFromSurface( renderer, s );
} }
} }
surfB[ i ] = s; surfB[ i ] = s;
textB[ i ] = t; label_Lshift[ i ] = t;
i++; i++;
buttons++; buttons++;
} }
i = 0; i = 0;
buttons = calcbuttons; buttons = calcbuttons;
while ( buttons->textC ) { while ( buttons->label_Rshift ) {
SDL_Surface* s = NULL; SDL_Surface* s = NULL;
SDL_Texture* t = NULL; SDL_Texture* t = NULL;
if ( buttons->textC && strcmp( buttons->textC, "" ) != 0 ) { if ( buttons->label_Rshift && strcmp( buttons->label_Rshift, "" ) != 0 ) {
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textC, couleurGreen ); s = TTF_RenderUTF8_Blended( ttffont2, buttons->label_Rshift, couleurGreen );
if ( s ) { if ( s ) {
t = SDL_CreateTextureFromSurface( renderer, s ); t = SDL_CreateTextureFromSurface( renderer, s );
} }
} }
surfC[ i ] = s; surfC[ i ] = s;
textC[ i ] = t; label_Rshift[ i ] = t;
i++; i++;
buttons++; buttons++;
} }
i = 0; i = 0;
buttons = calcbuttons; buttons = calcbuttons;
while ( buttons->textC ) { while ( buttons->label_Rshift ) {
SDL_Surface* s = NULL; SDL_Surface* s = NULL;
SDL_Texture* t = NULL; SDL_Texture* t = NULL;
if ( buttons->textD && strcmp( buttons->textD, "" ) != 0 ) { if ( buttons->label_below && strcmp( buttons->label_below, "" ) != 0 ) {
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textD, couleurYellow ); s = TTF_RenderUTF8_Blended( ttffont2, buttons->label_below, couleurYellow );
if ( s ) { if ( s ) {
t = SDL_CreateTextureFromSurface( renderer, s ); t = SDL_CreateTextureFromSurface( renderer, s );
} }
} }
surfD[ i ] = s; surfD[ i ] = s;
textD[ i ] = t; label_below[ i ] = t;
i++; i++;
buttons++; buttons++;
} }
@ -178,7 +178,7 @@ static inline void button_draw( Button* b )
void button_draw_all( Button* buttons ) void button_draw_all( Button* buttons )
{ {
while ( buttons->text ) { while ( buttons->label ) {
button_draw( buttons ); button_draw( buttons );
buttons++; buttons++;
} }
@ -186,7 +186,7 @@ void button_draw_all( Button* buttons )
static inline Button* find_button( Button* b, int x, int y ) static inline Button* find_button( Button* b, int x, int y )
{ {
while ( b->text ) { while ( b->label ) {
if ( x >= b->x * 2 && x < b->x * 2 + b->w * 2 && y >= b->y * 2 && y < b->y * 2 + b->h * 2 ) if ( x >= b->x * 2 && x < b->x * 2 + b->w * 2 && y >= b->y * 2 && y < b->y * 2 + b->h * 2 )
return b; return b;
@ -241,7 +241,7 @@ int button_mouse_up( Button* buttons, int mx, int my, int mb )
} }
} }
if ( mb == 1 ) { if ( mb == 1 ) {
for ( b = buttons; b->text; b++ ) { for ( b = buttons; b->label; b++ ) {
if ( ( b->flags & ( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) == ( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) { if ( ( b->flags & ( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) == ( BUTTON_B1RELEASE | BUTTON_PUSHED ) ) {
b->flags &= ~BUTTON_PUSHED; b->flags &= ~BUTTON_PUSHED;

View file

@ -10,10 +10,10 @@ typedef struct {
int x, y; int x, y;
int w, h; int w, h;
int flags; int flags;
char* text; char* label;
char* textB; char* label_Lshift;
char* textC; char* label_Rshift;
char* textD; char* label_below;
void ( *down )( void ); void ( *down )( void );
void ( *up )( void ); void ( *up )( void );
} Button; } Button;

View file

@ -118,136 +118,177 @@ bool refreshSDL()
while ( SDL_PollEvent( &event ) ) { while ( SDL_PollEvent( &event ) ) {
switch ( event.type ) { switch ( event.type ) {
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
{ pcalc_up( event.button.x, event.button.y, 1 );
// printf("mouse up %d %d\n", event.button.x, event.button.y);
pcalc_up( event.button.x, event.button.y, 1 );
}
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
{ pcalc_down( event.button.x, event.button.y, 1 );
// printf("mouse down %d %d\n", event.button.x, event.button.y);
pcalc_down( event.button.x, event.button.y, 1 );
}
break; break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
pcalc_kb_down( event.key.keysym.scancode );
switch ( event.key.keysym.scancode ) { switch ( event.key.keysym.scancode ) {
case SDL_SCANCODE_KP_0:
press_0();
break;
case SDL_SCANCODE_KP_1:
press_1();
break;
case SDL_SCANCODE_KP_2:
press_2();
break;
case SDL_SCANCODE_KP_3:
press_3();
break;
case SDL_SCANCODE_KP_4:
press_4();
break;
case SDL_SCANCODE_KP_5:
press_5();
break;
case SDL_SCANCODE_KP_6:
press_6();
break;
case SDL_SCANCODE_KP_7:
press_7();
break;
case SDL_SCANCODE_KP_8:
press_8();
break;
case SDL_SCANCODE_KP_9:
press_9();
break;
case SDL_SCANCODE_KP_PERIOD:
press_PERIOD();
break;
case SDL_SCANCODE_SPACE:
press_SPC();
break;
case SDL_SCANCODE_ESCAPE: case SDL_SCANCODE_ESCAPE:
case SDL_SCANCODE_F5:
kbd_on_pressed(); kbd_on_pressed();
break; break;
case SDL_SCANCODE_RETURN: case SDL_SCANCODE_RETURN:
case SDL_SCANCODE_KP_ENTER: case SDL_SCANCODE_KP_ENTER:
kbd_key_pressed( 4, 4 ); case SDL_SCANCODE_F1:
press_ENTER();
break; break;
case SDL_SCANCODE_BACKSPACE: case SDL_SCANCODE_BACKSPACE:
kbd_key_pressed( 4, 0 ); press_BKSP();
break; break;
case SDL_SCANCODE_LEFT: case SDL_SCANCODE_LEFT:
kbd_key_pressed( 6, 2 ); press_LEFT();
break; break;
case SDL_SCANCODE_RIGHT: case SDL_SCANCODE_RIGHT:
kbd_key_pressed( 6, 0 ); press_RIGHT();
break; break;
case SDL_SCANCODE_UP: case SDL_SCANCODE_UP:
kbd_key_pressed( 7, 1 ); press_UP();
break; break;
case SDL_SCANCODE_DOWN: case SDL_SCANCODE_DOWN:
kbd_key_pressed( 6, 1 ); press_DOWN();
break; break;
case SDL_SCANCODE_KP_PLUS: case SDL_SCANCODE_KP_PLUS:
kbd_key_pressed( 0, 0 ); press_PLUS();
break; break;
case SDL_SCANCODE_KP_MINUS: case SDL_SCANCODE_KP_MINUS:
kbd_key_pressed( 1, 0 ); press_MINUS();
break; break;
case SDL_SCANCODE_KP_MULTIPLY: case SDL_SCANCODE_KP_MULTIPLY:
kbd_key_pressed( 2, 0 ); press_MULT();
break; break;
case SDL_SCANCODE_KP_DIVIDE: case SDL_SCANCODE_KP_DIVIDE:
kbd_key_pressed( 3, 0 ); press_DIV();
break; break;
case SDL_SCANCODE_A: case SDL_SCANCODE_A:
kbd_key_pressed( 1, 4 ); press_A();
break; break;
case SDL_SCANCODE_B: case SDL_SCANCODE_B:
kbd_key_pressed( 8, 4 ); press_B();
break; break;
case SDL_SCANCODE_C: case SDL_SCANCODE_C:
kbd_key_pressed( 8, 3 ); press_C();
break; break;
case SDL_SCANCODE_D: case SDL_SCANCODE_D:
kbd_key_pressed( 8, 2 ); press_D();
break; break;
case SDL_SCANCODE_E: case SDL_SCANCODE_E:
kbd_key_pressed( 8, 1 ); press_E();
break; break;
case SDL_SCANCODE_F: case SDL_SCANCODE_F:
kbd_key_pressed( 8, 0 ); press_F();
break; break;
case SDL_SCANCODE_G: case SDL_SCANCODE_G:
kbd_key_pressed( 2, 4 ); press_MTH();
break; break;
case SDL_SCANCODE_H: case SDL_SCANCODE_H:
kbd_key_pressed( 7, 4 ); press_PRG();
break; break;
case SDL_SCANCODE_I: case SDL_SCANCODE_I:
kbd_key_pressed( 7, 3 ); press_CST();
break; break;
case SDL_SCANCODE_J: case SDL_SCANCODE_J:
kbd_key_pressed( 7, 2 ); press_VAR();
break; break;
case SDL_SCANCODE_K: case SDL_SCANCODE_K:
kbd_key_pressed( 7, 1 ); press_UP();
break; break;
case SDL_SCANCODE_L: case SDL_SCANCODE_L:
kbd_key_pressed( 7, 0 ); press_NXT();
break; break;
case SDL_SCANCODE_M: case SDL_SCANCODE_M:
kbd_key_pressed( 0, 4 ); press_QUOTE();
break; break;
case SDL_SCANCODE_N: case SDL_SCANCODE_N:
kbd_key_pressed( 6, 4 ); press_STO();
break; break;
case SDL_SCANCODE_O: case SDL_SCANCODE_O:
kbd_key_pressed( 6, 3 ); press_EVAL();
break; break;
case SDL_SCANCODE_P: case SDL_SCANCODE_P:
kbd_key_pressed( 6, 2 ); press_LEFT();
break; break;
case SDL_SCANCODE_Q: case SDL_SCANCODE_Q:
kbd_key_pressed( 6, 1 ); press_DOWN();
break; break;
case SDL_SCANCODE_R: case SDL_SCANCODE_R:
kbd_key_pressed( 6, 0 ); press_RIGHT();
break; break;
case SDL_SCANCODE_S: case SDL_SCANCODE_S:
kbd_key_pressed( 3, 4 ); press_SIN();
break; break;
case SDL_SCANCODE_T: case SDL_SCANCODE_T:
kbd_key_pressed( 5, 4 ); press_COS();
break; break;
case SDL_SCANCODE_U: case SDL_SCANCODE_U:
kbd_key_pressed( 5, 3 ); press_TAN();
break; break;
case SDL_SCANCODE_V: case SDL_SCANCODE_V:
kbd_key_pressed( 5, 2 ); press_SQRT();
break; break;
case SDL_SCANCODE_W: case SDL_SCANCODE_W:
kbd_key_pressed( 5, 1 ); press_POW();
break; break;
case SDL_SCANCODE_X: case SDL_SCANCODE_X:
kbd_key_pressed( 5, 0 ); press_INV();
break; break;
case SDL_SCANCODE_Y: case SDL_SCANCODE_Y:
kbd_key_pressed( 4, 3 ); press_NEG();
break; break;
case SDL_SCANCODE_Z: case SDL_SCANCODE_Z:
kbd_key_pressed( 4, 2 ); press_EEX();
break;
case SDL_SCANCODE_F2:
press_LSHIFT();
break;
case SDL_SCANCODE_F3:
press_RSHIFT();
break;
case SDL_SCANCODE_F4:
press_ALPHA();
break;
case SDL_SCANCODE_F7:
program_exit();
exit( 0 );
break; break;
default: default:
break; break;
@ -255,120 +296,165 @@ bool refreshSDL()
break; break;
case SDL_KEYUP: case SDL_KEYUP:
pcalc_kb_up( event.key.keysym.scancode );
switch ( event.key.keysym.scancode ) { switch ( event.key.keysym.scancode ) {
case SDL_SCANCODE_KP_0:
release_0();
break;
case SDL_SCANCODE_KP_1:
release_1();
break;
case SDL_SCANCODE_KP_2:
release_2();
break;
case SDL_SCANCODE_KP_3:
release_3();
break;
case SDL_SCANCODE_KP_4:
release_4();
break;
case SDL_SCANCODE_KP_5:
release_5();
break;
case SDL_SCANCODE_KP_6:
release_6();
break;
case SDL_SCANCODE_KP_7:
release_7();
break;
case SDL_SCANCODE_KP_8:
release_8();
break;
case SDL_SCANCODE_KP_9:
release_9();
break;
case SDL_SCANCODE_KP_PERIOD:
release_PERIOD();
break;
case SDL_SCANCODE_SPACE:
release_SPC();
break;
case SDL_SCANCODE_ESCAPE: case SDL_SCANCODE_ESCAPE:
case SDL_SCANCODE_F5:
kbd_on_released(); kbd_on_released();
break; break;
case SDL_SCANCODE_RETURN: case SDL_SCANCODE_RETURN:
case SDL_SCANCODE_KP_ENTER: case SDL_SCANCODE_KP_ENTER:
kbd_key_released( 4, 4 ); case SDL_SCANCODE_F1:
release_ENTER();
break; break;
case SDL_SCANCODE_BACKSPACE: case SDL_SCANCODE_BACKSPACE:
kbd_key_released( 4, 0 ); release_BKSP();
break; break;
case SDL_SCANCODE_LEFT: case SDL_SCANCODE_LEFT:
kbd_key_released( 6, 2 ); release_LEFT();
break; break;
case SDL_SCANCODE_RIGHT: case SDL_SCANCODE_RIGHT:
kbd_key_released( 6, 0 ); release_RIGHT();
break; break;
case SDL_SCANCODE_UP: case SDL_SCANCODE_UP:
kbd_key_released( 7, 1 ); release_UP();
break; break;
case SDL_SCANCODE_DOWN: case SDL_SCANCODE_DOWN:
kbd_key_released( 6, 1 ); release_DOWN();
break; break;
case SDL_SCANCODE_KP_PLUS: case SDL_SCANCODE_KP_PLUS:
kbd_key_released( 0, 0 ); release_PLUS();
break; break;
case SDL_SCANCODE_KP_MINUS: case SDL_SCANCODE_KP_MINUS:
kbd_key_released( 1, 0 ); release_MINUS();
break; break;
case SDL_SCANCODE_KP_MULTIPLY: case SDL_SCANCODE_KP_MULTIPLY:
kbd_key_released( 2, 0 ); release_MULT();
break; break;
case SDL_SCANCODE_KP_DIVIDE: case SDL_SCANCODE_KP_DIVIDE:
kbd_key_released( 3, 0 ); release_DIV();
break; break;
case SDL_SCANCODE_A: case SDL_SCANCODE_A:
kbd_key_released( 1, 4 ); release_A();
break; break;
case SDL_SCANCODE_B: case SDL_SCANCODE_B:
kbd_key_released( 8, 4 ); release_B();
break; break;
case SDL_SCANCODE_C: case SDL_SCANCODE_C:
kbd_key_released( 8, 3 ); release_C();
break; break;
case SDL_SCANCODE_D: case SDL_SCANCODE_D:
kbd_key_released( 8, 2 ); release_D();
break; break;
case SDL_SCANCODE_E: case SDL_SCANCODE_E:
kbd_key_released( 8, 1 ); release_E();
break; break;
case SDL_SCANCODE_F: case SDL_SCANCODE_F:
kbd_key_released( 8, 0 ); release_F();
break; break;
case SDL_SCANCODE_G: case SDL_SCANCODE_G:
kbd_key_released( 2, 4 ); release_MTH();
break; break;
case SDL_SCANCODE_H: case SDL_SCANCODE_H:
kbd_key_released( 7, 4 ); release_PRG();
break; break;
case SDL_SCANCODE_I: case SDL_SCANCODE_I:
kbd_key_released( 7, 3 ); release_CST();
break; break;
case SDL_SCANCODE_J: case SDL_SCANCODE_J:
kbd_key_released( 7, 2 ); release_VAR();
break; break;
case SDL_SCANCODE_K: case SDL_SCANCODE_K:
kbd_key_released( 7, 1 ); release_UP();
break; break;
case SDL_SCANCODE_L: case SDL_SCANCODE_L:
kbd_key_released( 7, 0 ); release_NXT();
break; break;
case SDL_SCANCODE_M: case SDL_SCANCODE_M:
kbd_key_released( 0, 4 ); release_QUOTE();
break; break;
case SDL_SCANCODE_N: case SDL_SCANCODE_N:
kbd_key_released( 6, 4 ); release_STO();
break; break;
case SDL_SCANCODE_O: case SDL_SCANCODE_O:
kbd_key_released( 6, 3 ); release_EVAL();
break; break;
case SDL_SCANCODE_P: case SDL_SCANCODE_P:
kbd_key_released( 6, 2 ); release_LEFT();
break; break;
case SDL_SCANCODE_Q: case SDL_SCANCODE_Q:
kbd_key_released( 6, 1 ); release_DOWN();
break; break;
case SDL_SCANCODE_R: case SDL_SCANCODE_R:
kbd_key_released( 6, 0 ); release_RIGHT();
break; break;
case SDL_SCANCODE_S: case SDL_SCANCODE_S:
kbd_key_released( 3, 4 ); release_SIN();
break; break;
case SDL_SCANCODE_T: case SDL_SCANCODE_T:
kbd_key_released( 5, 4 ); release_COS();
break; break;
case SDL_SCANCODE_U: case SDL_SCANCODE_U:
kbd_key_released( 5, 3 ); release_TAN();
break; break;
case SDL_SCANCODE_V: case SDL_SCANCODE_V:
kbd_key_released( 5, 2 ); release_SQRT();
break; break;
case SDL_SCANCODE_W: case SDL_SCANCODE_W:
kbd_key_released( 5, 1 ); release_POW();
break; break;
case SDL_SCANCODE_X: case SDL_SCANCODE_X:
kbd_key_released( 5, 0 ); release_INV();
break; break;
case SDL_SCANCODE_Y: case SDL_SCANCODE_Y:
kbd_key_released( 4, 3 ); release_NEG();
break; break;
case SDL_SCANCODE_Z: case SDL_SCANCODE_Z:
kbd_key_released( 4, 2 ); release_EEX();
break;
case SDL_SCANCODE_F2:
release_LSHIFT();
break;
case SDL_SCANCODE_F3:
release_RSHIFT();
break;
case SDL_SCANCODE_F4:
release_ALPHA();
break; break;
default: default:
break; break;
@ -420,7 +506,7 @@ int main( int argc, char* argv[] )
program_init(); program_init();
emulator_init(); emulator_init();
while ( please_exit == false ) while ( !please_exit )
mainloop(); mainloop();
emulator_exit(); emulator_exit();

View file

@ -7,108 +7,6 @@
#include "pcalc.h" #include "pcalc.h"
#include "pfiles.h" #include "pfiles.h"
static void dn00( void ) { kbd_key_pressed( 0, 0 ); }
static void up00( void ) { kbd_key_released( 0, 0 ); }
static void dn01( void ) { kbd_key_pressed( 0, 1 ); }
static void up01( void ) { kbd_key_released( 0, 1 ); }
static void dn02( void ) { kbd_key_pressed( 0, 2 ); }
static void up02( void ) { kbd_key_released( 0, 2 ); }
static void dn03( void ) { kbd_key_pressed( 0, 3 ); }
static void up03( void ) { kbd_key_released( 0, 3 ); }
static void dn04( void ) { kbd_key_pressed( 0, 4 ); }
static void up04( void ) { kbd_key_released( 0, 4 ); }
static void dn10( void ) { kbd_key_pressed( 1, 0 ); }
static void up10( void ) { kbd_key_released( 1, 0 ); }
static void dn11( void ) { kbd_key_pressed( 1, 1 ); }
static void up11( void ) { kbd_key_released( 1, 1 ); }
static void dn12( void ) { kbd_key_pressed( 1, 2 ); }
static void up12( void ) { kbd_key_released( 1, 2 ); }
static void dn13( void ) { kbd_key_pressed( 1, 3 ); }
static void up13( void ) { kbd_key_released( 1, 3 ); }
static void dn14( void ) { kbd_key_pressed( 1, 4 ); }
static void up14( void ) { kbd_key_released( 1, 4 ); }
static void dn15( void ) { kbd_key_pressed( 1, 5 ); }
static void up15( void ) { kbd_key_released( 1, 5 ); }
static void dn20( void ) { kbd_key_pressed( 2, 0 ); }
static void up20( void ) { kbd_key_released( 2, 0 ); }
static void dn21( void ) { kbd_key_pressed( 2, 1 ); }
static void up21( void ) { kbd_key_released( 2, 1 ); }
static void dn22( void ) { kbd_key_pressed( 2, 2 ); }
static void up22( void ) { kbd_key_released( 2, 2 ); }
static void dn23( void ) { kbd_key_pressed( 2, 3 ); }
static void up23( void ) { kbd_key_released( 2, 3 ); }
static void dn24( void ) { kbd_key_pressed( 2, 4 ); }
static void up24( void ) { kbd_key_released( 2, 4 ); }
static void dn25( void ) { kbd_key_pressed( 2, 5 ); }
static void up25( void ) { kbd_key_released( 2, 5 ); }
static void dn30( void ) { kbd_key_pressed( 3, 0 ); }
static void up30( void ) { kbd_key_released( 3, 0 ); }
static void dn31( void ) { kbd_key_pressed( 3, 1 ); }
static void up31( void ) { kbd_key_released( 3, 1 ); }
static void dn32( void ) { kbd_key_pressed( 3, 2 ); }
static void up32( void ) { kbd_key_released( 3, 2 ); }
static void dn33( void ) { kbd_key_pressed( 3, 3 ); }
static void up33( void ) { kbd_key_released( 3, 3 ); }
static void dn34( void ) { kbd_key_pressed( 3, 4 ); }
static void up34( void ) { kbd_key_released( 3, 4 ); }
static void dn35( void ) { kbd_key_pressed( 3, 5 ); }
static void up35( void ) { kbd_key_released( 3, 5 ); }
static void dn40( void ) { kbd_key_pressed( 4, 0 ); }
static void up40( void ) { kbd_key_released( 4, 0 ); }
static void dn41( void ) { kbd_key_pressed( 4, 1 ); }
static void up41( void ) { kbd_key_released( 4, 1 ); }
static void dn42( void ) { kbd_key_pressed( 4, 2 ); }
static void up42( void ) { kbd_key_released( 4, 2 ); }
static void dn43( void ) { kbd_key_pressed( 4, 3 ); }
static void up43( void ) { kbd_key_released( 4, 3 ); }
static void dn44( void ) { kbd_key_pressed( 4, 4 ); }
static void up44( void ) { kbd_key_released( 4, 4 ); }
static void dn50( void ) { kbd_key_pressed( 5, 0 ); }
static void up50( void ) { kbd_key_released( 5, 0 ); }
static void dn51( void ) { kbd_key_pressed( 5, 1 ); }
static void up51( void ) { kbd_key_released( 5, 1 ); }
static void dn52( void ) { kbd_key_pressed( 5, 2 ); }
static void up52( void ) { kbd_key_released( 5, 2 ); }
static void dn53( void ) { kbd_key_pressed( 5, 3 ); }
static void up53( void ) { kbd_key_released( 5, 3 ); }
static void dn54( void ) { kbd_key_pressed( 5, 4 ); }
static void up54( void ) { kbd_key_released( 5, 4 ); }
static void dn60( void ) { kbd_key_pressed( 6, 0 ); }
static void up60( void ) { kbd_key_released( 6, 0 ); }
static void dn61( void ) { kbd_key_pressed( 6, 1 ); }
static void up61( void ) { kbd_key_released( 6, 1 ); }
static void dn62( void ) { kbd_key_pressed( 6, 2 ); }
static void up62( void ) { kbd_key_released( 6, 2 ); }
static void dn63( void ) { kbd_key_pressed( 6, 3 ); }
static void up63( void ) { kbd_key_released( 6, 3 ); }
static void dn64( void ) { kbd_key_pressed( 6, 4 ); }
static void up64( void ) { kbd_key_released( 6, 4 ); }
static void dn70( void ) { kbd_key_pressed( 7, 0 ); }
static void up70( void ) { kbd_key_released( 7, 0 ); }
static void dn71( void ) { kbd_key_pressed( 7, 1 ); }
static void up71( void ) { kbd_key_released( 7, 1 ); }
static void dn72( void ) { kbd_key_pressed( 7, 2 ); }
static void up72( void ) { kbd_key_released( 7, 2 ); }
static void dn73( void ) { kbd_key_pressed( 7, 3 ); }
static void up73( void ) { kbd_key_released( 7, 3 ); }
static void dn74( void ) { kbd_key_pressed( 7, 4 ); }
static void up74( void ) { kbd_key_released( 7, 4 ); }
static void dn80( void ) { kbd_key_pressed( 8, 0 ); }
static void up80( void ) { kbd_key_released( 8, 0 ); }
static void dn81( void ) { kbd_key_pressed( 8, 1 ); }
static void up81( void ) { kbd_key_released( 8, 1 ); }
static void dn82( void ) { kbd_key_pressed( 8, 2 ); }
static void up82( void ) { kbd_key_released( 8, 2 ); }
static void dn83( void ) { kbd_key_pressed( 8, 3 ); }
static void up83( void ) { kbd_key_released( 8, 3 ); }
static void dn84( void ) { kbd_key_pressed( 8, 4 ); }
static void up84( void ) { kbd_key_released( 8, 4 ); }
static void dnON( void ) { kbd_on_pressed(); }
static void upON( void ) { kbd_on_released(); }
static void dnZelda( void ) {}
static void upZelda( void ) { load_file( "zeldahp.dir" ); }
const int pox = 2; const int pox = 2;
const int poy = 55; const int poy = 55;
const int pow1 = 40; const int pow1 = 40;
@ -122,130 +20,219 @@ const int xspacing = ( pow1 + 2 );
const int xspacing2 = ( pow2 + 2 ); const int xspacing2 = ( pow2 + 2 );
const int enter_w = pow1 * 2 + 2; const int enter_w = pow1 * 2 + 2;
static KBMapping kb_sdl_mapping[] = { void press_PLUS( void ) { kbd_key_pressed( 0, 0 ); }
{SDL_SCANCODE_KP_0, dn03, up03}, void release_PLUS( void ) { kbd_key_released( 0, 0 ); }
{SDL_SCANCODE_KP_1, dn13, up13}, void press_SPC( void ) { kbd_key_pressed( 0, 1 ); }
{SDL_SCANCODE_KP_2, dn12, up12}, void release_SPC( void ) { kbd_key_released( 0, 1 ); }
{SDL_SCANCODE_KP_3, dn11, up11}, void press_PERIOD( void ) { kbd_key_pressed( 0, 2 ); }
{SDL_SCANCODE_KP_4, dn23, up23}, void release_PERIOD( void ) { kbd_key_released( 0, 2 ); }
{SDL_SCANCODE_KP_5, dn22, up22}, void press_0( void ) { kbd_key_pressed( 0, 3 ); }
{SDL_SCANCODE_KP_6, dn21, up21}, void release_0( void ) { kbd_key_released( 0, 3 ); }
{SDL_SCANCODE_KP_7, dn33, up33}, void press_QUOTE( void ) { kbd_key_pressed( 0, 4 ); }
{SDL_SCANCODE_KP_8, dn32, up32}, void release_QUOTE( void ) { kbd_key_released( 0, 4 ); }
{SDL_SCANCODE_KP_9, dn31, up31}, void press_MINUS( void ) { kbd_key_pressed( 1, 0 ); }
}; void release_MINUS( void ) { kbd_key_released( 1, 0 ); }
void press_3( void ) { kbd_key_pressed( 1, 1 ); }
void release_3( void ) { kbd_key_released( 1, 1 ); }
void press_2( void ) { kbd_key_pressed( 1, 2 ); }
void release_2( void ) { kbd_key_released( 1, 2 ); }
void press_1( void ) { kbd_key_pressed( 1, 3 ); }
void release_1( void ) { kbd_key_released( 1, 3 ); }
void press_A( void ) { kbd_key_pressed( 1, 4 ); }
void release_A( void ) { kbd_key_released( 1, 4 ); }
void press_RSHIFT( void ) { kbd_key_pressed( 1, 5 ); }
void release_RSHIFT( void ) { kbd_key_released( 1, 5 ); }
void press_MULT( void ) { kbd_key_pressed( 2, 0 ); }
void release_MULT( void ) { kbd_key_released( 2, 0 ); }
void press_6( void ) { kbd_key_pressed( 2, 1 ); }
void release_6( void ) { kbd_key_released( 2, 1 ); }
void press_5( void ) { kbd_key_pressed( 2, 2 ); }
void release_5( void ) { kbd_key_released( 2, 2 ); }
void press_4( void ) { kbd_key_pressed( 2, 3 ); }
void release_4( void ) { kbd_key_released( 2, 3 ); }
void press_MTH( void ) { kbd_key_pressed( 2, 4 ); }
void release_MTH( void ) { kbd_key_released( 2, 4 ); }
void press_LSHIFT( void ) { kbd_key_pressed( 2, 5 ); }
void release_LSHIFT( void ) { kbd_key_released( 2, 5 ); }
void press_DIV( void ) { kbd_key_pressed( 3, 0 ); }
void release_DIV( void ) { kbd_key_released( 3, 0 ); }
void press_9( void ) { kbd_key_pressed( 3, 1 ); }
void release_9( void ) { kbd_key_released( 3, 1 ); }
void press_8( void ) { kbd_key_pressed( 3, 2 ); }
void release_8( void ) { kbd_key_released( 3, 2 ); }
void press_7( void ) { kbd_key_pressed( 3, 3 ); }
void release_7( void ) { kbd_key_released( 3, 3 ); }
void press_SIN( void ) { kbd_key_pressed( 3, 4 ); }
void release_SIN( void ) { kbd_key_released( 3, 4 ); }
void press_ALPHA( void ) { kbd_key_pressed( 3, 5 ); }
void release_ALPHA( void ) { kbd_key_released( 3, 5 ); }
void press_BKSP( void ) { kbd_key_pressed( 4, 0 ); }
void release_BKSP( void ) { kbd_key_released( 4, 0 ); }
void press_DEL( void ) { kbd_key_pressed( 4, 1 ); }
void release_DEL( void ) { kbd_key_released( 4, 1 ); }
void press_EEX( void ) { kbd_key_pressed( 4, 2 ); }
void release_EEX( void ) { kbd_key_released( 4, 2 ); }
void press_NEG( void ) { kbd_key_pressed( 4, 3 ); }
void release_NEG( void ) { kbd_key_released( 4, 3 ); }
void press_ENTER( void ) { kbd_key_pressed( 4, 4 ); }
void release_ENTER( void ) { kbd_key_released( 4, 4 ); }
void press_INV( void ) { kbd_key_pressed( 5, 0 ); }
void release_INV( void ) { kbd_key_released( 5, 0 ); }
void press_POW( void ) { kbd_key_pressed( 5, 1 ); }
void release_POW( void ) { kbd_key_released( 5, 1 ); }
void press_SQRT( void ) { kbd_key_pressed( 5, 2 ); }
void release_SQRT( void ) { kbd_key_released( 5, 2 ); }
void press_TAN( void ) { kbd_key_pressed( 5, 3 ); }
void release_TAN( void ) { kbd_key_released( 5, 3 ); }
void press_COS( void ) { kbd_key_pressed( 5, 4 ); }
void release_COS( void ) { kbd_key_released( 5, 4 ); }
void press_RIGHT( void ) { kbd_key_pressed( 6, 0 ); }
void release_RIGHT( void ) { kbd_key_released( 6, 0 ); }
void press_DOWN( void ) { kbd_key_pressed( 6, 1 ); }
void release_DOWN( void ) { kbd_key_released( 6, 1 ); }
void press_LEFT( void ) { kbd_key_pressed( 6, 2 ); }
void release_LEFT( void ) { kbd_key_released( 6, 2 ); }
void press_EVAL( void ) { kbd_key_pressed( 6, 3 ); }
void release_EVAL( void ) { kbd_key_released( 6, 3 ); }
void press_STO( void ) { kbd_key_pressed( 6, 4 ); }
void release_STO( void ) { kbd_key_released( 6, 4 ); }
void press_NXT( void ) { kbd_key_pressed( 7, 0 ); }
void release_NXT( void ) { kbd_key_released( 7, 0 ); }
void press_UP( void ) { kbd_key_pressed( 7, 1 ); }
void release_UP( void ) { kbd_key_released( 7, 1 ); }
void press_VAR( void ) { kbd_key_pressed( 7, 2 ); }
void release_VAR( void ) { kbd_key_released( 7, 2 ); }
void press_CST( void ) { kbd_key_pressed( 7, 3 ); }
void release_CST( void ) { kbd_key_released( 7, 3 ); }
void press_PRG( void ) { kbd_key_pressed( 7, 4 ); }
void release_PRG( void ) { kbd_key_released( 7, 4 ); }
void press_F( void ) { kbd_key_pressed( 8, 0 ); }
void release_F( void ) { kbd_key_released( 8, 0 ); }
void press_E( void ) { kbd_key_pressed( 8, 1 ); }
void release_E( void ) { kbd_key_released( 8, 1 ); }
void press_D( void ) { kbd_key_pressed( 8, 2 ); }
void release_D( void ) { kbd_key_released( 8, 2 ); }
void press_C( void ) { kbd_key_pressed( 8, 3 ); }
void release_C( void ) { kbd_key_released( 8, 3 ); }
void press_B( void ) { kbd_key_pressed( 8, 4 ); }
void release_B( void ) { kbd_key_released( 8, 4 ); }
void press_ON( void ) { kbd_on_pressed(); }
void release_ON( void ) { kbd_on_released(); }
void press_Zelda( void ) {}
void release_Zelda( void ) { load_file( "zeldahp.dir" ); }
static Button calc_buttons[] = { static Button calc_buttons[] = {
{0, pox + xstart + ( xspacing * 0 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "A", {0, pox + xstart + ( xspacing * 0 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "A",
dn14, up14}, press_A, release_A },
{1, pox + xstart + ( xspacing * 1 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "B", {1, pox + xstart + ( xspacing * 1 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "B",
dn84, up84}, press_B, release_B },
{2, pox + xstart + ( xspacing * 2 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "C", {2, pox + xstart + ( xspacing * 2 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "C",
dn83, up83}, press_C, release_C },
{3, pox + xstart + ( xspacing * 3 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "D", {3, pox + xstart + ( xspacing * 3 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "D",
dn82, up82}, press_D, release_D },
{4, pox + xstart + ( xspacing * 4 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "E", {4, pox + xstart + ( xspacing * 4 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "E",
dn81, up81}, press_E, release_E },
{5, pox + xstart + ( xspacing * 5 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "F", {5, pox + xstart + ( xspacing * 5 ), ystart + ( 0 * yspacing ) + poy, pow1, poh1, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", "", "F",
dn80, up80}, press_F, release_F },
{6, pox + xstart + ( xspacing * 0 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "MTH", {6, pox + xstart + ( xspacing * 0 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "MTH",
"RAD", "POLAR", "G", dn24, up24}, "RAD", "POLAR", "G", press_MTH, release_MTH },
{7, pox + xstart + ( xspacing * 1 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "PRG", "", {7, pox + xstart + ( xspacing * 1 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "PRG", "",
"CHARS", "H", dn74, up74}, "CHARS", "H", press_PRG, release_PRG },
{8, pox + xstart + ( xspacing * 2 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "CST", "", {8, pox + xstart + ( xspacing * 2 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "CST", "",
"MODES", "I", dn73, up73}, "MODES", "I", press_CST, release_CST },
{9, pox + xstart + ( xspacing * 3 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "VAR", "", {9, pox + xstart + ( xspacing * 3 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "VAR", "",
"MEMORY", "J", dn72, up72}, "MEMORY", "J", press_VAR, release_VAR },
{10, pox + xstart + ( xspacing * 4 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "^", "", {10, pox + xstart + ( xspacing * 4 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "",
"STACK", "K", dn71, up71}, "STACK", "K", press_UP, release_UP },
{11, pox + xstart + ( xspacing * 5 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "NXT", {11, pox + xstart + ( xspacing * 5 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "NXT",
"PREV", "MENU", "L", dn70, up70}, "PREV", "MENU", "L", press_NXT, release_NXT },
{12, pox + xstart + ( xspacing * 0 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "'", "UP", {12, pox + xstart + ( xspacing * 0 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "'", "UP",
"HOME", "M", dn04, up04}, "HOME", "M", press_QUOTE, release_QUOTE },
{13, pox + xstart + ( xspacing * 1 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "STO", {13, pox + xstart + ( xspacing * 1 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "STO",
"REF", "RCL", "N", dn64, up64}, "REF", "RCL", "N", press_STO, release_STO },
{14, pox + xstart + ( xspacing * 2 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EVAL", {14, pox + xstart + ( xspacing * 2 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EVAL",
"->NUM", "UNDO", "O", dn63, up63}, "->NUM", "UNDO", "O", press_EVAL, release_EVAL },
{15, pox + xstart + ( xspacing * 3 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "<", {15, pox + xstart + ( xspacing * 3 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "",
"PICTURE", "", "P", dn62, up62}, "PICTURE", "", "P", press_LEFT, release_LEFT },
{16, pox + xstart + ( xspacing * 4 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "v", {16, pox + xstart + ( xspacing * 4 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "",
"VIEW", "", "Q", dn61, up61}, "VIEW", "", "Q", press_DOWN, release_DOWN },
{17, pox + xstart + ( xspacing * 5 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, ">", {17, pox + xstart + ( xspacing * 5 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "",
"SWAP", "", "R", dn60, up60}, "SWAP", "", "R", press_RIGHT, release_RIGHT },
{18, pox + xstart + ( xspacing * 0 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SIN", {18, pox + xstart + ( xspacing * 0 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SIN",
"ASIN", "tet", "S", dn34, up34}, "ASIN", "tet", "S", press_SIN, release_SIN },
{19, pox + xstart + ( xspacing * 1 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "COS", {19, pox + xstart + ( xspacing * 1 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "COS",
"ACOS", "", "T", dn54, up54}, "ACOS", "", "T", press_COS, release_COS },
{20, pox + xstart + ( xspacing * 2 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "TAN", {20, pox + xstart + ( xspacing * 2 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "TAN",
"ATAN", "Sig", "U", dn53, up53}, "ATAN", "Sig", "U", press_TAN, release_TAN },
{21, pox + xstart + ( xspacing * 3 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SQ x", {21, pox + xstart + ( xspacing * 3 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "√x", "xx",
"xx", "x SQ y", "V", dn52, up52}, "x√y", "V", press_SQRT, release_SQRT },
{22, pox + xstart + ( xspacing * 4 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "yx", {22, pox + xstart + ( xspacing * 4 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "y^x",
"10x", "LOG", "W", dn51, up51}, "⏨x", "LOG", "W", press_POW, release_POW },
{23, pox + xstart + ( xspacing * 5 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "1/x", {23, pox + xstart + ( xspacing * 5 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "1/x",
"ex", "LN", "X", dn50, up50}, "ex", "LN", "X", press_INV, release_INV },
{24, pox + xstart + ( xspacing * 0 ), ystart + ( 4 * yspacing ) + poy + 40, enter_w, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ENTER", {24, pox + xstart + ( xspacing * 0 ), ystart + ( 4 * yspacing ) + poy + 40, enter_w, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ENTER",
"EQUATION", "MATRIX", "", dn44, up44}, "EQUATION", "MATRIX", "", press_ENTER, release_ENTER },
{25, enter_w - pow1 + pox + xstart + ( xspacing * 1 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2, {25, enter_w - pow1 + pox + xstart + ( xspacing * 1 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "+/-", "EDIT", "CMD", "Y", dn43, up43}, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "±", "EDIT", "CMD", "Y", press_NEG, release_NEG },
{26, enter_w - pow1 + pox + xstart + ( xspacing * 2 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2, {26, enter_w - pow1 + pox + xstart + ( xspacing * 2 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EEX", "PURG", "ARG", "Z", dn42, up42}, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "EEX", "PURG", "ARG", "Z", press_EEX, release_EEX },
{27, enter_w - pow1 + pox + xstart + ( xspacing * 3 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2, {27, enter_w - pow1 + pox + xstart + ( xspacing * 3 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "DEL", "CLEAR", "", "", dn41, up41}, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "DEL", "CLEAR", "", "", press_DEL, release_DEL },
{28, enter_w - pow1 + pox + xstart + ( xspacing * 4 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2, {28, enter_w - pow1 + pox + xstart + ( xspacing * 4 ), ystart + ( 4 * yspacing ) + poy + 40, pow1, poh2,
BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "<-", "DROP", "", "", dn40, up40}, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "DROP", "", "", press_BKSP, release_BKSP },
{29, pox + xstart + ( xspacing * 0 ), ystart + ( 5 * yspacing ) + poy + 50, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "alpha", {29, pox + xstart + ( xspacing * 0 ), ystart + ( 5 * yspacing ) + poy + 50, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "α",
"USER", "ENTRY", "", dn35, up35}, "USER", "ENTRY", "", press_ALPHA, release_ALPHA },
{30, pox + xstart + ( xspacing2 * 1 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "7", "", {30, pox + xstart + ( xspacing2 * 1 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "7", "",
"SOLVE", "", dn33, up33}, "SOLVE", "", press_7, release_7 },
{31, pox + xstart + ( xspacing2 * 2 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "8", "", {31, pox + xstart + ( xspacing2 * 2 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "8", "",
"PLOT", "", dn32, up32}, "PLOT", "", press_8, release_8 },
{32, pox + xstart + ( xspacing2 * 3 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "9", "", {32, pox + xstart + ( xspacing2 * 3 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "9", "",
"SYMBOLIC", "", dn31, up31}, "SYMBOLIC", "", press_9, release_9 },
{33, pox + xstart + ( xspacing2 * 4 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "/", {33, pox + xstart + ( xspacing2 * 4 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "÷",
"( )", "#", "", dn30, up30}, "( )", "#", "", press_DIV, release_DIV },
{34, pox + xstart + ( xspacing * 0 ), ystart + ( 6 * yspacing ) + poy + 60, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "red", {34, pox + xstart + ( xspacing * 0 ), ystart + ( 6 * yspacing ) + poy + 60, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "red",
"", "", dn25, up25}, "", "", press_LSHIFT, release_LSHIFT},
{35, pox + xstart + ( xspacing2 * 1 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "4", "", {35, pox + xstart + ( xspacing2 * 1 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "4", "",
"TIME", "", dn23, up23}, "TIME", "", press_4, release_4 },
{36, pox + xstart + ( xspacing2 * 2 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "5", "", {36, pox + xstart + ( xspacing2 * 2 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "5", "",
"STAT", "", dn22, up22}, "STAT", "", press_5, release_5 },
{37, pox + xstart + ( xspacing2 * 3 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "6", "", {37, pox + xstart + ( xspacing2 * 3 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "6", "",
"UNITS", "", dn21, up21}, "UNITS", "", press_6, release_6 },
{38, pox + xstart + ( xspacing2 * 4 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "X", {38, pox + xstart + ( xspacing2 * 4 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "×",
"[ ]", "_", "", dn20, up20}, "[ ]", "_", "", press_MULT, release_MULT },
{39, pox + xstart + ( xspacing * 0 ), ystart + ( 7 * yspacing ) + poy + 70, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "", {39, pox + xstart + ( xspacing * 0 ), ystart + ( 7 * yspacing ) + poy + 70, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "", "",
"green", "", dn15, up15}, "green", "", press_RSHIFT, release_RSHIFT},
{40, pox + xstart + ( xspacing2 * 1 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "1", "", {40, pox + xstart + ( xspacing2 * 1 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "1", "",
"I/O", "", dn13, up13}, "I/O", "", press_1, release_1 },
{41, pox + xstart + ( xspacing2 * 2 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "2", "", {41, pox + xstart + ( xspacing2 * 2 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "2", "",
"LIBRARY", "", dn12, up12}, "LIBRARY", "", press_2, release_2 },
{42, pox + xstart + ( xspacing2 * 3 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "3", "", {42, pox + xstart + ( xspacing2 * 3 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "3", "",
"EQ LIB", "", dn11, up11}, "EQ LIB", "", press_3, release_3 },
{43, pox + xstart + ( xspacing2 * 4 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "-", {43, pox + xstart + ( xspacing2 * 4 ), ystart + ( 7 * yspacing ) + poy + 70, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "-",
"<< >>", "\" \"", "", dn10, up10}, "<< >>", "\" \"", "", press_MINUS, release_MINUS },
{44, pox + xstart + ( xspacing * 0 ), ystart + ( 8 * yspacing ) + poy + 80, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ON", {44, pox + xstart + ( xspacing * 0 ), ystart + ( 8 * yspacing ) + poy + 80, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "ON",
"CONT", "OFF", "CANCEL", dnON, upON}, "CONT", "OFF", "CANCEL", press_ON, release_ON },
{45, pox + xstart + ( xspacing2 * 1 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "0", "=", {45, pox + xstart + ( xspacing2 * 1 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "0", "=",
"->", "", dn03, up03}, "->", "", press_0, release_0 },
{46, pox + xstart + ( xspacing2 * 2 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, ".", ",", {46, pox + xstart + ( xspacing2 * 2 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, ".", ",",
"back", "", dn02, up02}, "back", "", press_PERIOD, release_PERIOD},
{47, pox + xstart + ( xspacing2 * 3 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SPC", {47, pox + xstart + ( xspacing2 * 3 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SPC",
"pi", "rad", "", dn01, up01}, "pi", "rad", "", press_SPC, release_SPC },
{48, pox + xstart + ( xspacing2 * 4 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "+", "{}", {48, pox + xstart + ( xspacing2 * 4 ), ystart + ( 8 * yspacing ) + poy + 80, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "+", "{}",
": :", "", dn00, up00}, ": :", "", press_PLUS, release_PLUS },
{49, pox + xstart, ystart + ( 9 * yspacing ) + poy + 90, 130, 20, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "Game", "", "", "", dnZelda, {49, pox + xstart, ystart + ( 9 * yspacing ) + poy + 90, 130, 20, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "Game", "", "", "", press_Zelda,
upZelda }, release_Zelda },
{50, pox + xstart, poy, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL} {50, pox + xstart, poy, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL }
}; };
void pcalc_init() { gui_initKeyboard( calc_buttons ); } void pcalc_init() { gui_initKeyboard( calc_buttons ); }
@ -259,29 +246,3 @@ void pcalc_show()
void pcalc_down( int mx, int my, int mb ) { button_mouse_down( calc_buttons, mx, my, mb ); } void pcalc_down( int mx, int my, int mb ) { button_mouse_down( calc_buttons, mx, my, mb ); }
void pcalc_up( int mx, int my, int mb ) { button_mouse_up( calc_buttons, mx, my, mb ); } void pcalc_up( int mx, int my, int mb ) { button_mouse_up( calc_buttons, mx, my, mb ); }
void pcalc_kb_down( SDL_Keycode sdl_event )
{
KBMapping* mapping = kb_sdl_mapping;
while ( mapping->SDL_event_id ) {
if ( sdl_event == mapping->SDL_event_id ) {
mapping->down();
break;
}
mapping++;
}
}
void pcalc_kb_up( SDL_Keycode sdl_event )
{
KBMapping* mapping = kb_sdl_mapping;
while ( mapping->SDL_event_id ) {
if ( sdl_event == mapping->SDL_event_id ) {
mapping->up();
break;
}
mapping++;
}
}

View file

@ -3,11 +3,106 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
typedef struct { extern void press_PLUS( void );
SDL_Keycode SDL_event_id; extern void release_PLUS( void );
void ( *down )( void ); extern void press_SPC( void );
void ( *up )( void ); extern void release_SPC( void );
} KBMapping; extern void press_PERIOD( void );
extern void release_PERIOD( void );
extern void press_0( void );
extern void release_0( void );
extern void press_QUOTE( void );
extern void release_QUOTE( void );
extern void press_MINUS( void );
extern void release_MINUS( void );
extern void press_3( void );
extern void release_3( void );
extern void press_2( void );
extern void release_2( void );
extern void press_1( void );
extern void release_1( void );
extern void press_A( void );
extern void release_A( void );
extern void press_RSHIFT( void );
extern void release_RSHIFT( void );
extern void press_MULT( void );
extern void release_MULT( void );
extern void press_6( void );
extern void release_6( void );
extern void press_5( void );
extern void release_5( void );
extern void press_4( void );
extern void release_4( void );
extern void press_MTH( void );
extern void release_MTH( void );
extern void press_LSHIFT( void );
extern void release_LSHIFT( void );
extern void press_DIV( void );
extern void release_DIV( void );
extern void press_9( void );
extern void release_9( void );
extern void press_8( void );
extern void release_8( void );
extern void press_7( void );
extern void release_7( void );
extern void press_SIN( void );
extern void release_SIN( void );
extern void press_ALPHA( void );
extern void release_ALPHA( void );
extern void press_BKSP( void );
extern void release_BKSP( void );
extern void press_DEL( void );
extern void release_DEL( void );
extern void press_EEX( void );
extern void release_EEX( void );
extern void press_NEG( void );
extern void release_NEG( void );
extern void press_ENTER( void );
extern void release_ENTER( void );
extern void press_INV( void );
extern void release_INV( void );
extern void press_POW( void );
extern void release_POW( void );
extern void press_SQRT( void );
extern void release_SQRT( void );
extern void press_TAN( void );
extern void release_TAN( void );
extern void press_COS( void );
extern void release_COS( void );
extern void press_RIGHT( void );
extern void release_RIGHT( void );
extern void press_DOWN( void );
extern void release_DOWN( void );
extern void press_LEFT( void );
extern void release_LEFT( void );
extern void press_EVAL( void );
extern void release_EVAL( void );
extern void press_STO( void );
extern void release_STO( void );
extern void press_NXT( void );
extern void release_NXT( void );
extern void press_UP( void );
extern void release_UP( void );
extern void press_VAR( void );
extern void release_VAR( void );
extern void press_CST( void );
extern void release_CST( void );
extern void press_PRG( void );
extern void release_PRG( void );
extern void press_F( void );
extern void release_F( void );
extern void press_E( void );
extern void release_E( void );
extern void press_D( void );
extern void release_D( void );
extern void press_C( void );
extern void release_C( void );
extern void press_B( void );
extern void release_B( void );
extern void press_ON( void );
extern void release_ON( void );
extern void press_Zelda( void );
extern void release_Zelda( void );
extern void pcalc_init(); extern void pcalc_init();
extern void pcalc_show(); extern void pcalc_show();