fix a few maemo issues
authornotaz <notasas@gmail.com>
Sat, 29 Oct 2011 16:28:30 +0000 (19:28 +0300)
committernotaz <notasas@gmail.com>
Sun, 30 Oct 2011 21:48:09 +0000 (23:48 +0200)
g_opts clash, file_name, maemo_init and in_keystate

maemo/hildon.c
maemo/maemo_common.h [new file with mode: 0644]
maemo/main.c

index 003dfdd..dc5e497 100644 (file)
@@ -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 (file)
index 0000000..757b6f6
--- /dev/null
@@ -0,0 +1,4 @@
+void maemo_init(int *argc, char ***argv);
+
+extern char file_name[MAXPATHLEN];
+extern int g_maemo_opts;
index e5faacf..c238556 100644 (file)
@@ -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");