From d64280d6f8f3064fffd834f374900f0bfb735ac7 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 29 Oct 2011 19:28:30 +0300 Subject: [PATCH] fix a few maemo issues g_opts clash, file_name, maemo_init and in_keystate --- maemo/hildon.c | 21 ++++++++++----------- maemo/maemo_common.h | 4 ++++ maemo/main.c | 18 +++++++++--------- 3 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 maemo/maemo_common.h diff --git a/maemo/hildon.c b/maemo/hildon.c index 003dfddb..dc5e4976 100644 --- a/maemo/hildon.c +++ b/maemo/hildon.c @@ -9,6 +9,7 @@ #include "main.h" #include "../libpcsxcore/psemu_plugin_defs.h" #include "common/readpng.h" +#include "maemo_common.h" #define X_RES 800 #define Y_RES 480 @@ -23,8 +24,6 @@ static GdkImage *image; static HildonAnimationActor *actor; static GtkWidget *window, *drawing; -extern int g_opts; -extern char * file_name; static int pl_buf_w, pl_buf_h; static int sens, y_def; static int keymap[65536]; @@ -170,7 +169,7 @@ void maemo_init(int *argc, char ***argv) GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); actor = HILDON_ANIMATION_ACTOR (hildon_animation_actor_new()); - if (g_opts & 2) + if (g_maemo_opts & 2) hildon_animation_actor_set_position (actor, 0, 0 ); else hildon_animation_actor_set_position (actor, (X_RES - D_WIDTH)/2, (Y_RES - D_HEIGHT)/2 ); @@ -201,7 +200,7 @@ void *hildon_set_mode(int w, int h) gtk_image_set_from_image (GTK_IMAGE(drawing), image, NULL); gtk_window_resize (GTK_WINDOW (actor), w, h); - if (g_opts & 2) + if (g_maemo_opts & 2) hildon_animation_actor_set_scale (actor, (gdouble)800 / (gdouble)w, (gdouble)480 / (gdouble)h @@ -220,21 +219,21 @@ void *hildon_flip(void) gtk_widget_queue_draw (drawing); // process accelometer - if (g_opts & 4) { + if (g_maemo_opts & 4) { int x, y, z; FILE* f = fopen( "/sys/class/i2c-adapter/i2c-3/3-001d/coord", "r" ); if( !f ) {printf ("err in accel"); exit(1);} fscanf( f, "%d %d %d", &x, &y, &z ); fclose( f ); - if( x > sens ) keystate |= 1 << DKEY_LEFT; - else if( x < -sens ) keystate |= 1 << DKEY_RIGHT; - else {keystate &= ~(1 << DKEY_LEFT);keystate &= ~(1 << DKEY_RIGHT);} + if( x > sens ) in_keystate |= 1 << DKEY_LEFT; + else if( x < -sens ) in_keystate |= 1 << DKEY_RIGHT; + else {in_keystate &= ~(1 << DKEY_LEFT);in_keystate &= ~(1 << DKEY_RIGHT);} y+=y_def; - if( y > sens )keystate |= 1 << DKEY_UP; - else if( y < -sens ) keystate |= 1 << DKEY_DOWN; - else {keystate &= ~(1 << DKEY_DOWN);keystate &= ~(1 << DKEY_UP);} + if( y > sens )in_keystate |= 1 << DKEY_UP; + else if( y < -sens ) in_keystate |= 1 << DKEY_DOWN; + else {in_keystate &= ~(1 << DKEY_DOWN);in_keystate &= ~(1 << DKEY_UP);} } diff --git a/maemo/maemo_common.h b/maemo/maemo_common.h new file mode 100644 index 00000000..757b6f66 --- /dev/null +++ b/maemo/maemo_common.h @@ -0,0 +1,4 @@ +void maemo_init(int *argc, char ***argv); + +extern char file_name[MAXPATHLEN]; +extern int g_maemo_opts; diff --git a/maemo/main.c b/maemo/main.c index e5faacfe..c238556a 100644 --- a/maemo/main.c +++ b/maemo/main.c @@ -16,6 +16,7 @@ #include "plugin_lib.h" #include "../libpcsxcore/misc.h" #include "../libpcsxcore/new_dynarec/new_dynarec.h" +#include "maemo_common.h" // sound plugin extern int iUseReverb; @@ -24,10 +25,11 @@ extern int iSPUIRQWait; extern int iUseTimer; int g_opts = OPT_SHOWFPS; +int g_maemo_opts; +char file_name[MAXPATHLEN]; enum sched_action emu_action; void do_emu_action(void); -char* file_name; static void ChangeWorkingDirectory(char *exe) { @@ -79,8 +81,8 @@ int maemo_main(int argc, char **argv) if (tv_reg > 0) pl_rearmed_cbs.frameskip = -1; } - else if (!strcmp(argv[i],"-fullscreen")) g_opts |= 2; - else if (!strcmp(argv[i],"-accel")) g_opts |= 4; + else if (!strcmp(argv[i],"-fullscreen")) g_maemo_opts |= 2; + else if (!strcmp(argv[i],"-accel")) g_maemo_opts |= 4; else if (!strcmp(argv[i],"-sputhreaded")) iUseTimer=1; else if (!strcmp(argv[i],"-nosound")) strcpy(Config.Spu, "spunull.so"); /* unworking with r10 @@ -107,12 +109,10 @@ int maemo_main(int argc, char **argv) hildon_init(&argc, &argv); - char f_name[MAXPATHLEN]; - strcpy(f_name, strrchr(cdfile,'/')); - file_name=f_name; - - if (cdfile) + if (cdfile) { set_cd_image(cdfile); + strcpy(file_name, strrchr(cdfile,'/')); + } if (SysInit() == -1) return 1; @@ -153,7 +153,7 @@ int maemo_main(int argc, char **argv) } if (ready_to_go) - maemo_init(); + maemo_init(&argc, &argv); else { printf ("somethings goes wrong, maybe you forgot -cdfile ? \n"); -- 2.39.5