naming variables/functions/fields; simplify keyboard handling
This commit is contained in:
parent
ab453314aa
commit
d12a20df29
5 changed files with 463 additions and 321 deletions
48
src/gui.c
48
src/gui.c
|
@ -19,13 +19,13 @@ SDL_Surface* surfA[ 49 ];
|
|||
SDL_Texture* textA[ 49 ];
|
||||
|
||||
SDL_Surface* surfB[ 49 ];
|
||||
SDL_Texture* textB[ 49 ];
|
||||
SDL_Texture* label_Lshift[ 49 ];
|
||||
|
||||
SDL_Surface* surfC[ 49 ];
|
||||
SDL_Texture* textC[ 49 ];
|
||||
SDL_Texture* label_Rshift[ 49 ];
|
||||
|
||||
SDL_Surface* surfD[ 49 ];
|
||||
SDL_Texture* textD[ 49 ];
|
||||
SDL_Texture* label_below[ 49 ];
|
||||
|
||||
#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_Texture* letterTexture2 = textB[ index ];
|
||||
SDL_Texture* letterTexture2 = label_Lshift[ index ];
|
||||
if ( letterSurface2 != NULL && letterTexture2 != NULL ) {
|
||||
int texW = letterSurface2->w;
|
||||
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_Texture* letterTexture3 = textC[ index ];
|
||||
SDL_Texture* letterTexture3 = label_Rshift[ index ];
|
||||
if ( letterSurface3 != NULL && letterTexture3 != NULL ) {
|
||||
int texW = letterSurface3->w;
|
||||
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_Texture* letterTexture4 = textD[ index ];
|
||||
SDL_Texture* letterTexture4 = label_below[ index ];
|
||||
if ( letterSurface4 != NULL && letterTexture4 != NULL ) {
|
||||
int texW = letterSurface4->w;
|
||||
int texH = letterSurface4->h;
|
||||
|
@ -88,11 +88,11 @@ void gui_initKeyboard( Button* calcbuttons )
|
|||
|
||||
int i = 0;
|
||||
Button* buttons = calcbuttons;
|
||||
while ( buttons->text ) {
|
||||
while ( buttons->label ) {
|
||||
SDL_Surface* s = NULL;
|
||||
SDL_Texture* t = NULL;
|
||||
if ( buttons->text && strcmp( buttons->text, "" ) != 0 ) {
|
||||
s = TTF_RenderUTF8_Blended( ttffont, buttons->text, couleurBlanche );
|
||||
if ( buttons->label && strcmp( buttons->label, "" ) != 0 ) {
|
||||
s = TTF_RenderUTF8_Blended( ttffont, buttons->label, couleurBlanche );
|
||||
if ( s ) {
|
||||
t = SDL_CreateTextureFromSurface( renderer, s );
|
||||
}
|
||||
|
@ -107,51 +107,51 @@ void gui_initKeyboard( Button* calcbuttons )
|
|||
|
||||
i = 0;
|
||||
buttons = calcbuttons;
|
||||
while ( buttons->textB ) {
|
||||
while ( buttons->label_Lshift ) {
|
||||
SDL_Surface* s = NULL;
|
||||
SDL_Texture* t = NULL;
|
||||
if ( buttons->textB && strcmp( buttons->textB, "" ) != 0 ) {
|
||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textB, couleurPurple );
|
||||
if ( buttons->label_Lshift && strcmp( buttons->label_Lshift, "" ) != 0 ) {
|
||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->label_Lshift, couleurPurple );
|
||||
if ( s ) {
|
||||
t = SDL_CreateTextureFromSurface( renderer, s );
|
||||
}
|
||||
}
|
||||
surfB[ i ] = s;
|
||||
textB[ i ] = t;
|
||||
label_Lshift[ i ] = t;
|
||||
i++;
|
||||
buttons++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
buttons = calcbuttons;
|
||||
while ( buttons->textC ) {
|
||||
while ( buttons->label_Rshift ) {
|
||||
SDL_Surface* s = NULL;
|
||||
SDL_Texture* t = NULL;
|
||||
if ( buttons->textC && strcmp( buttons->textC, "" ) != 0 ) {
|
||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textC, couleurGreen );
|
||||
if ( buttons->label_Rshift && strcmp( buttons->label_Rshift, "" ) != 0 ) {
|
||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->label_Rshift, couleurGreen );
|
||||
if ( s ) {
|
||||
t = SDL_CreateTextureFromSurface( renderer, s );
|
||||
}
|
||||
}
|
||||
surfC[ i ] = s;
|
||||
textC[ i ] = t;
|
||||
label_Rshift[ i ] = t;
|
||||
i++;
|
||||
buttons++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
buttons = calcbuttons;
|
||||
while ( buttons->textC ) {
|
||||
while ( buttons->label_Rshift ) {
|
||||
SDL_Surface* s = NULL;
|
||||
SDL_Texture* t = NULL;
|
||||
if ( buttons->textD && strcmp( buttons->textD, "" ) != 0 ) {
|
||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->textD, couleurYellow );
|
||||
if ( buttons->label_below && strcmp( buttons->label_below, "" ) != 0 ) {
|
||||
s = TTF_RenderUTF8_Blended( ttffont2, buttons->label_below, couleurYellow );
|
||||
if ( s ) {
|
||||
t = SDL_CreateTextureFromSurface( renderer, s );
|
||||
}
|
||||
}
|
||||
surfD[ i ] = s;
|
||||
textD[ i ] = t;
|
||||
label_below[ i ] = t;
|
||||
i++;
|
||||
buttons++;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ static inline void button_draw( Button* b )
|
|||
|
||||
void button_draw_all( Button* buttons )
|
||||
{
|
||||
while ( buttons->text ) {
|
||||
while ( buttons->label ) {
|
||||
button_draw( buttons );
|
||||
buttons++;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ void button_draw_all( Button* buttons )
|
|||
|
||||
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 )
|
||||
return b;
|
||||
|
||||
|
@ -241,7 +241,7 @@ int button_mouse_up( Button* buttons, int mx, int my, int mb )
|
|||
}
|
||||
}
|
||||
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 ) ) {
|
||||
b->flags &= ~BUTTON_PUSHED;
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ typedef struct {
|
|||
int x, y;
|
||||
int w, h;
|
||||
int flags;
|
||||
char* text;
|
||||
char* textB;
|
||||
char* textC;
|
||||
char* textD;
|
||||
char* label;
|
||||
char* label_Lshift;
|
||||
char* label_Rshift;
|
||||
char* label_below;
|
||||
void ( *down )( void );
|
||||
void ( *up )( void );
|
||||
} Button;
|
||||
|
|
260
src/main.c
260
src/main.c
|
@ -118,136 +118,177 @@ bool refreshSDL()
|
|||
while ( SDL_PollEvent( &event ) ) {
|
||||
switch ( event.type ) {
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
{
|
||||
// printf("mouse up %d %d\n", event.button.x, event.button.y);
|
||||
|
||||
pcalc_up( event.button.x, event.button.y, 1 );
|
||||
}
|
||||
pcalc_up( event.button.x, event.button.y, 1 );
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
{
|
||||
// printf("mouse down %d %d\n", event.button.x, event.button.y);
|
||||
|
||||
pcalc_down( event.button.x, event.button.y, 1 );
|
||||
}
|
||||
pcalc_down( event.button.x, event.button.y, 1 );
|
||||
break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
pcalc_kb_down( 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_F5:
|
||||
kbd_on_pressed();
|
||||
break;
|
||||
case SDL_SCANCODE_RETURN:
|
||||
case SDL_SCANCODE_KP_ENTER:
|
||||
kbd_key_pressed( 4, 4 );
|
||||
case SDL_SCANCODE_F1:
|
||||
press_ENTER();
|
||||
break;
|
||||
case SDL_SCANCODE_BACKSPACE:
|
||||
kbd_key_pressed( 4, 0 );
|
||||
press_BKSP();
|
||||
break;
|
||||
case SDL_SCANCODE_LEFT:
|
||||
kbd_key_pressed( 6, 2 );
|
||||
press_LEFT();
|
||||
break;
|
||||
case SDL_SCANCODE_RIGHT:
|
||||
kbd_key_pressed( 6, 0 );
|
||||
press_RIGHT();
|
||||
break;
|
||||
case SDL_SCANCODE_UP:
|
||||
kbd_key_pressed( 7, 1 );
|
||||
press_UP();
|
||||
break;
|
||||
case SDL_SCANCODE_DOWN:
|
||||
kbd_key_pressed( 6, 1 );
|
||||
press_DOWN();
|
||||
break;
|
||||
case SDL_SCANCODE_KP_PLUS:
|
||||
kbd_key_pressed( 0, 0 );
|
||||
press_PLUS();
|
||||
break;
|
||||
case SDL_SCANCODE_KP_MINUS:
|
||||
kbd_key_pressed( 1, 0 );
|
||||
press_MINUS();
|
||||
break;
|
||||
case SDL_SCANCODE_KP_MULTIPLY:
|
||||
kbd_key_pressed( 2, 0 );
|
||||
press_MULT();
|
||||
break;
|
||||
case SDL_SCANCODE_KP_DIVIDE:
|
||||
kbd_key_pressed( 3, 0 );
|
||||
press_DIV();
|
||||
break;
|
||||
case SDL_SCANCODE_A:
|
||||
kbd_key_pressed( 1, 4 );
|
||||
press_A();
|
||||
break;
|
||||
case SDL_SCANCODE_B:
|
||||
kbd_key_pressed( 8, 4 );
|
||||
press_B();
|
||||
break;
|
||||
case SDL_SCANCODE_C:
|
||||
kbd_key_pressed( 8, 3 );
|
||||
press_C();
|
||||
break;
|
||||
case SDL_SCANCODE_D:
|
||||
kbd_key_pressed( 8, 2 );
|
||||
press_D();
|
||||
break;
|
||||
case SDL_SCANCODE_E:
|
||||
kbd_key_pressed( 8, 1 );
|
||||
press_E();
|
||||
break;
|
||||
case SDL_SCANCODE_F:
|
||||
kbd_key_pressed( 8, 0 );
|
||||
press_F();
|
||||
break;
|
||||
case SDL_SCANCODE_G:
|
||||
kbd_key_pressed( 2, 4 );
|
||||
press_MTH();
|
||||
break;
|
||||
case SDL_SCANCODE_H:
|
||||
kbd_key_pressed( 7, 4 );
|
||||
press_PRG();
|
||||
break;
|
||||
case SDL_SCANCODE_I:
|
||||
kbd_key_pressed( 7, 3 );
|
||||
press_CST();
|
||||
break;
|
||||
case SDL_SCANCODE_J:
|
||||
kbd_key_pressed( 7, 2 );
|
||||
press_VAR();
|
||||
break;
|
||||
case SDL_SCANCODE_K:
|
||||
kbd_key_pressed( 7, 1 );
|
||||
press_UP();
|
||||
break;
|
||||
case SDL_SCANCODE_L:
|
||||
kbd_key_pressed( 7, 0 );
|
||||
press_NXT();
|
||||
break;
|
||||
case SDL_SCANCODE_M:
|
||||
kbd_key_pressed( 0, 4 );
|
||||
press_QUOTE();
|
||||
break;
|
||||
case SDL_SCANCODE_N:
|
||||
kbd_key_pressed( 6, 4 );
|
||||
press_STO();
|
||||
break;
|
||||
case SDL_SCANCODE_O:
|
||||
kbd_key_pressed( 6, 3 );
|
||||
press_EVAL();
|
||||
break;
|
||||
case SDL_SCANCODE_P:
|
||||
kbd_key_pressed( 6, 2 );
|
||||
press_LEFT();
|
||||
break;
|
||||
case SDL_SCANCODE_Q:
|
||||
kbd_key_pressed( 6, 1 );
|
||||
press_DOWN();
|
||||
break;
|
||||
case SDL_SCANCODE_R:
|
||||
kbd_key_pressed( 6, 0 );
|
||||
press_RIGHT();
|
||||
break;
|
||||
case SDL_SCANCODE_S:
|
||||
kbd_key_pressed( 3, 4 );
|
||||
press_SIN();
|
||||
break;
|
||||
case SDL_SCANCODE_T:
|
||||
kbd_key_pressed( 5, 4 );
|
||||
press_COS();
|
||||
break;
|
||||
case SDL_SCANCODE_U:
|
||||
kbd_key_pressed( 5, 3 );
|
||||
press_TAN();
|
||||
break;
|
||||
case SDL_SCANCODE_V:
|
||||
kbd_key_pressed( 5, 2 );
|
||||
press_SQRT();
|
||||
break;
|
||||
case SDL_SCANCODE_W:
|
||||
kbd_key_pressed( 5, 1 );
|
||||
press_POW();
|
||||
break;
|
||||
case SDL_SCANCODE_X:
|
||||
kbd_key_pressed( 5, 0 );
|
||||
press_INV();
|
||||
break;
|
||||
case SDL_SCANCODE_Y:
|
||||
kbd_key_pressed( 4, 3 );
|
||||
press_NEG();
|
||||
break;
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
|
@ -255,120 +296,165 @@ bool refreshSDL()
|
|||
break;
|
||||
|
||||
case SDL_KEYUP:
|
||||
pcalc_kb_up( 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_F5:
|
||||
kbd_on_released();
|
||||
break;
|
||||
case SDL_SCANCODE_RETURN:
|
||||
case SDL_SCANCODE_KP_ENTER:
|
||||
kbd_key_released( 4, 4 );
|
||||
case SDL_SCANCODE_F1:
|
||||
release_ENTER();
|
||||
break;
|
||||
case SDL_SCANCODE_BACKSPACE:
|
||||
kbd_key_released( 4, 0 );
|
||||
release_BKSP();
|
||||
break;
|
||||
case SDL_SCANCODE_LEFT:
|
||||
kbd_key_released( 6, 2 );
|
||||
release_LEFT();
|
||||
break;
|
||||
case SDL_SCANCODE_RIGHT:
|
||||
kbd_key_released( 6, 0 );
|
||||
release_RIGHT();
|
||||
break;
|
||||
case SDL_SCANCODE_UP:
|
||||
kbd_key_released( 7, 1 );
|
||||
release_UP();
|
||||
break;
|
||||
case SDL_SCANCODE_DOWN:
|
||||
kbd_key_released( 6, 1 );
|
||||
release_DOWN();
|
||||
break;
|
||||
case SDL_SCANCODE_KP_PLUS:
|
||||
kbd_key_released( 0, 0 );
|
||||
release_PLUS();
|
||||
break;
|
||||
case SDL_SCANCODE_KP_MINUS:
|
||||
kbd_key_released( 1, 0 );
|
||||
release_MINUS();
|
||||
break;
|
||||
case SDL_SCANCODE_KP_MULTIPLY:
|
||||
kbd_key_released( 2, 0 );
|
||||
release_MULT();
|
||||
break;
|
||||
case SDL_SCANCODE_KP_DIVIDE:
|
||||
kbd_key_released( 3, 0 );
|
||||
release_DIV();
|
||||
break;
|
||||
case SDL_SCANCODE_A:
|
||||
kbd_key_released( 1, 4 );
|
||||
release_A();
|
||||
break;
|
||||
case SDL_SCANCODE_B:
|
||||
kbd_key_released( 8, 4 );
|
||||
release_B();
|
||||
break;
|
||||
case SDL_SCANCODE_C:
|
||||
kbd_key_released( 8, 3 );
|
||||
release_C();
|
||||
break;
|
||||
case SDL_SCANCODE_D:
|
||||
kbd_key_released( 8, 2 );
|
||||
release_D();
|
||||
break;
|
||||
case SDL_SCANCODE_E:
|
||||
kbd_key_released( 8, 1 );
|
||||
release_E();
|
||||
break;
|
||||
case SDL_SCANCODE_F:
|
||||
kbd_key_released( 8, 0 );
|
||||
release_F();
|
||||
break;
|
||||
case SDL_SCANCODE_G:
|
||||
kbd_key_released( 2, 4 );
|
||||
release_MTH();
|
||||
break;
|
||||
case SDL_SCANCODE_H:
|
||||
kbd_key_released( 7, 4 );
|
||||
release_PRG();
|
||||
break;
|
||||
case SDL_SCANCODE_I:
|
||||
kbd_key_released( 7, 3 );
|
||||
release_CST();
|
||||
break;
|
||||
case SDL_SCANCODE_J:
|
||||
kbd_key_released( 7, 2 );
|
||||
release_VAR();
|
||||
break;
|
||||
case SDL_SCANCODE_K:
|
||||
kbd_key_released( 7, 1 );
|
||||
release_UP();
|
||||
break;
|
||||
case SDL_SCANCODE_L:
|
||||
kbd_key_released( 7, 0 );
|
||||
release_NXT();
|
||||
break;
|
||||
case SDL_SCANCODE_M:
|
||||
kbd_key_released( 0, 4 );
|
||||
release_QUOTE();
|
||||
break;
|
||||
case SDL_SCANCODE_N:
|
||||
kbd_key_released( 6, 4 );
|
||||
release_STO();
|
||||
break;
|
||||
case SDL_SCANCODE_O:
|
||||
kbd_key_released( 6, 3 );
|
||||
release_EVAL();
|
||||
break;
|
||||
case SDL_SCANCODE_P:
|
||||
kbd_key_released( 6, 2 );
|
||||
release_LEFT();
|
||||
break;
|
||||
case SDL_SCANCODE_Q:
|
||||
kbd_key_released( 6, 1 );
|
||||
release_DOWN();
|
||||
break;
|
||||
case SDL_SCANCODE_R:
|
||||
kbd_key_released( 6, 0 );
|
||||
release_RIGHT();
|
||||
break;
|
||||
case SDL_SCANCODE_S:
|
||||
kbd_key_released( 3, 4 );
|
||||
release_SIN();
|
||||
break;
|
||||
case SDL_SCANCODE_T:
|
||||
kbd_key_released( 5, 4 );
|
||||
release_COS();
|
||||
break;
|
||||
case SDL_SCANCODE_U:
|
||||
kbd_key_released( 5, 3 );
|
||||
release_TAN();
|
||||
break;
|
||||
case SDL_SCANCODE_V:
|
||||
kbd_key_released( 5, 2 );
|
||||
release_SQRT();
|
||||
break;
|
||||
case SDL_SCANCODE_W:
|
||||
kbd_key_released( 5, 1 );
|
||||
release_POW();
|
||||
break;
|
||||
case SDL_SCANCODE_X:
|
||||
kbd_key_released( 5, 0 );
|
||||
release_INV();
|
||||
break;
|
||||
case SDL_SCANCODE_Y:
|
||||
kbd_key_released( 4, 3 );
|
||||
release_NEG();
|
||||
break;
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
|
@ -420,7 +506,7 @@ int main( int argc, char* argv[] )
|
|||
program_init();
|
||||
emulator_init();
|
||||
|
||||
while ( please_exit == false )
|
||||
while ( !please_exit )
|
||||
mainloop();
|
||||
|
||||
emulator_exit();
|
||||
|
|
363
src/pcalc.c
363
src/pcalc.c
|
@ -7,108 +7,6 @@
|
|||
#include "pcalc.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 poy = 55;
|
||||
const int pow1 = 40;
|
||||
|
@ -122,130 +20,219 @@ const int xspacing = ( pow1 + 2 );
|
|||
const int xspacing2 = ( pow2 + 2 );
|
||||
const int enter_w = pow1 * 2 + 2;
|
||||
|
||||
static KBMapping kb_sdl_mapping[] = {
|
||||
{SDL_SCANCODE_KP_0, dn03, up03},
|
||||
{SDL_SCANCODE_KP_1, dn13, up13},
|
||||
{SDL_SCANCODE_KP_2, dn12, up12},
|
||||
{SDL_SCANCODE_KP_3, dn11, up11},
|
||||
{SDL_SCANCODE_KP_4, dn23, up23},
|
||||
{SDL_SCANCODE_KP_5, dn22, up22},
|
||||
{SDL_SCANCODE_KP_6, dn21, up21},
|
||||
{SDL_SCANCODE_KP_7, dn33, up33},
|
||||
{SDL_SCANCODE_KP_8, dn32, up32},
|
||||
{SDL_SCANCODE_KP_9, dn31, up31},
|
||||
};
|
||||
void press_PLUS( void ) { kbd_key_pressed( 0, 0 ); }
|
||||
void release_PLUS( void ) { kbd_key_released( 0, 0 ); }
|
||||
void press_SPC( void ) { kbd_key_pressed( 0, 1 ); }
|
||||
void release_SPC( void ) { kbd_key_released( 0, 1 ); }
|
||||
void press_PERIOD( void ) { kbd_key_pressed( 0, 2 ); }
|
||||
void release_PERIOD( void ) { kbd_key_released( 0, 2 ); }
|
||||
void press_0( void ) { kbd_key_pressed( 0, 3 ); }
|
||||
void release_0( void ) { kbd_key_released( 0, 3 ); }
|
||||
void press_QUOTE( void ) { kbd_key_pressed( 0, 4 ); }
|
||||
void release_QUOTE( void ) { kbd_key_released( 0, 4 ); }
|
||||
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[] = {
|
||||
{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",
|
||||
dn84, up84},
|
||||
press_B, release_B },
|
||||
{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",
|
||||
dn82, up82},
|
||||
press_D, release_D },
|
||||
{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",
|
||||
dn80, up80},
|
||||
press_F, release_F },
|
||||
|
||||
{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", "",
|
||||
"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", "",
|
||||
"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", "",
|
||||
"MEMORY", "J", dn72, up72},
|
||||
{10, pox + xstart + ( xspacing * 4 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "^", "",
|
||||
"STACK", "K", dn71, up71},
|
||||
"MEMORY", "J", press_VAR, release_VAR },
|
||||
{10, pox + xstart + ( xspacing * 4 ), ystart + ( 1 * yspacing ) + poy + 10, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "▲", "",
|
||||
"STACK", "K", press_UP, release_UP },
|
||||
{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",
|
||||
"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",
|
||||
"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",
|
||||
"->NUM", "UNDO", "O", dn63, up63},
|
||||
{15, pox + xstart + ( xspacing * 3 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "<",
|
||||
"PICTURE", "", "P", dn62, up62},
|
||||
{16, pox + xstart + ( xspacing * 4 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "v",
|
||||
"VIEW", "", "Q", dn61, up61},
|
||||
{17, pox + xstart + ( xspacing * 5 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, ">",
|
||||
"SWAP", "", "R", dn60, up60},
|
||||
"->NUM", "UNDO", "O", press_EVAL, release_EVAL },
|
||||
{15, pox + xstart + ( xspacing * 3 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "◀",
|
||||
"PICTURE", "", "P", press_LEFT, release_LEFT },
|
||||
{16, pox + xstart + ( xspacing * 4 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "▼",
|
||||
"VIEW", "", "Q", press_DOWN, release_DOWN },
|
||||
{17, pox + xstart + ( xspacing * 5 ), ystart + ( 2 * yspacing ) + poy + 20, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "▶",
|
||||
"SWAP", "", "R", press_RIGHT, release_RIGHT },
|
||||
|
||||
{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",
|
||||
"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",
|
||||
"ATAN", "Sig", "U", dn53, up53},
|
||||
{21, pox + xstart + ( xspacing * 3 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "SQ x",
|
||||
"xx", "x SQ y", "V", dn52, up52},
|
||||
{22, pox + xstart + ( xspacing * 4 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "yx",
|
||||
"10x", "LOG", "W", dn51, up51},
|
||||
"ATAN", "Sig", "U", press_TAN, release_TAN },
|
||||
{21, pox + xstart + ( xspacing * 3 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "√x", "xx",
|
||||
"x√y", "V", press_SQRT, release_SQRT },
|
||||
{22, pox + xstart + ( xspacing * 4 ), ystart + ( 3 * yspacing ) + poy + 30, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "y^x",
|
||||
"⏨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",
|
||||
"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",
|
||||
"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,
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
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",
|
||||
"USER", "ENTRY", "", dn35, up35},
|
||||
{29, pox + xstart + ( xspacing * 0 ), ystart + ( 5 * yspacing ) + poy + 50, pow1, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "α",
|
||||
"USER", "ENTRY", "", press_ALPHA, release_ALPHA },
|
||||
{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", "",
|
||||
"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", "",
|
||||
"SYMBOLIC", "", dn31, up31},
|
||||
{33, pox + xstart + ( xspacing2 * 4 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "/",
|
||||
"( )", "#", "", dn30, up30},
|
||||
"SYMBOLIC", "", press_9, release_9 },
|
||||
{33, pox + xstart + ( xspacing2 * 4 ), ystart + ( 5 * yspacing ) + poy + 50, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "÷",
|
||||
"( )", "#", "", press_DIV, release_DIV },
|
||||
|
||||
{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", "",
|
||||
"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", "",
|
||||
"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", "",
|
||||
"UNITS", "", dn21, up21},
|
||||
{38, pox + xstart + ( xspacing2 * 4 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "X",
|
||||
"[ ]", "_", "", dn20, up20},
|
||||
"UNITS", "", press_6, release_6 },
|
||||
{38, pox + xstart + ( xspacing2 * 4 ), ystart + ( 6 * yspacing ) + poy + 60, pow2, poh2, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "×",
|
||||
"[ ]", "_", "", press_MULT, release_MULT },
|
||||
|
||||
{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", "",
|
||||
"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", "",
|
||||
"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", "",
|
||||
"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, "-",
|
||||
"<< >>", "\" \"", "", dn10, up10},
|
||||
"<< >>", "\" \"", "", press_MINUS, release_MINUS },
|
||||
|
||||
{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", "=",
|
||||
"->", "", dn03, up03},
|
||||
"->", "", press_0, release_0 },
|
||||
{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",
|
||||
"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, "+", "{}",
|
||||
": :", "", dn00, up00},
|
||||
": :", "", press_PLUS, release_PLUS },
|
||||
|
||||
{49, pox + xstart, ystart + ( 9 * yspacing ) + poy + 90, 130, 20, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "Game", "", "", "", dnZelda,
|
||||
upZelda },
|
||||
{50, pox + xstart, poy, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL}
|
||||
{49, pox + xstart, ystart + ( 9 * yspacing ) + poy + 90, 130, 20, BUTTON_B1RELEASE | BUTTON_B2TOGGLE, "Game", "", "", "", press_Zelda,
|
||||
release_Zelda },
|
||||
{50, pox + xstart, poy, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
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_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++;
|
||||
}
|
||||
}
|
||||
|
|
105
src/pcalc.h
105
src/pcalc.h
|
@ -3,11 +3,106 @@
|
|||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
typedef struct {
|
||||
SDL_Keycode SDL_event_id;
|
||||
void ( *down )( void );
|
||||
void ( *up )( void );
|
||||
} KBMapping;
|
||||
extern void press_PLUS( void );
|
||||
extern void release_PLUS( void );
|
||||
extern void press_SPC( void );
|
||||
extern void release_SPC( void );
|
||||
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_show();
|
||||
|
|
Loading…
Reference in a new issue