maemo updates
authorBonapart <bonapart@programist.ru>
Fri, 28 Oct 2011 16:38:46 +0000 (20:38 +0400)
committernotaz <notasas@gmail.com>
Sun, 30 Oct 2011 21:48:09 +0000 (23:48 +0200)
accelometer support for maemo
screenshot for maemo
fullscreen streghting via GTK
disabled bios(freeze emu at start)

[notasas@gmail.com] removed some unneeded stuff

maemo/hildon.c
maemo/main.c

index 26679ed..003dfdd 100644 (file)
@@ -5,8 +5,10 @@
 #include <unistd.h>
 #include <hildon/hildon.h>
 #include "plugin_lib.h"
+
 #include "main.h"
 #include "../libpcsxcore/psemu_plugin_defs.h"
+#include "common/readpng.h"
 
 #define X_RES           800
 #define Y_RES           480
@@ -21,6 +23,10 @@ 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];
 
 // map psx4m compatible keymap to PSX keys
@@ -82,11 +88,24 @@ window_key_proxy(GtkWidget *widget,
                        break;
                case 19:
                        if (event->type == GDK_KEY_PRESS)
-                               emu_set_action(SACTION_SAVE_STATE);
+                       {
+                               emu_save_state(state_slot);
+                               char buf[MAXPATHLEN];
+                               sprintf (buf,"/opt/maemo/usr/games/screenshots%s.%3.3d",file_name,state_slot);
+                               writepng(buf, image->mem, pl_buf_w,pl_buf_h);
+                       }
                        return;
                case 20:
                        if (event->type == GDK_KEY_PRESS)
-                               emu_set_action(SACTION_LOAD_STATE);
+                               emu_load_state(state_slot);
+                       return;
+               case 21:
+                       if (event->type == GDK_KEY_PRESS)
+                               state_slot=(state_slot<9)?state_slot+1:0;
+                       return;
+               case 22:
+                       if (event->type == GDK_KEY_PRESS)
+                               state_slot=(state_slot>0)?state_slot-1:8;
                        return;
        }
 
@@ -127,6 +146,15 @@ void maemo_init(int *argc, char ***argv)
                fclose(pFile);
        }
        
+       pFile = fopen("/opt/psx4m/config", "r");
+       if (NULL != pFile) {
+               fscanf(pFile, "%d %d",&sens,&y_def);
+               fclose(pFile);
+       } else {
+               sens=150;
+               y_def=500; //near 45 degrees =)
+       }
+
        gtk_init (argc, argv);
 
        window = hildon_stackable_window_new ();
@@ -142,7 +170,10 @@ void maemo_init(int *argc, char ***argv)
                                GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
 
        actor = HILDON_ANIMATION_ACTOR (hildon_animation_actor_new());
-       hildon_animation_actor_set_position (actor, (X_RES - D_WIDTH)/2, (Y_RES - D_HEIGHT)/2 );
+       if (g_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 );
        hildon_animation_actor_set_parent (actor, GTK_WINDOW (window));
 
        drawing = gtk_image_new ();
@@ -170,11 +201,17 @@ 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);
-       hildon_animation_actor_set_scale (actor,
+       if (g_opts & 2)
+               hildon_animation_actor_set_scale (actor,
+                               (gdouble)800 / (gdouble)w,
+                               (gdouble)480 / (gdouble)h
+                               );
+       else
+               hildon_animation_actor_set_scale (actor,
                                (gdouble)D_WIDTH / (gdouble)w,
                                (gdouble)D_HEIGHT / (gdouble)h
-       );
-
+                               );
+       pl_buf_w=w;pl_buf_h=h;
        return pl_vout_buf;
 }
 
@@ -182,6 +219,25 @@ void *hildon_flip(void)
 {
        gtk_widget_queue_draw (drawing);
 
+       // process accelometer
+       if (g_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);}
+
+               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);}
+
+       }
+
        /* process GTK+ events */
        while (gtk_events_pending())
                gtk_main_iteration();
index 388e07c..e5faacf 100644 (file)
@@ -27,6 +27,7 @@ int g_opts = OPT_SHOWFPS;
 
 enum sched_action emu_action;
 void do_emu_action(void);
+char* file_name;
 
 static void ChangeWorkingDirectory(char *exe)
 {
@@ -60,7 +61,6 @@ int maemo_main(int argc, char **argv)
                else if (!strcmp(argv[i], "-load")) loadst = atol(argv[++i]);
                else if (!strcmp(argv[i], "-cdfile")) {
                        char isofilename[MAXPATHLEN];
-
                        if (i+1 >= argc) break;
                        strncpy(isofilename, argv[++i], MAXPATHLEN);
                        if (isofilename[0] != '/') {
@@ -72,60 +72,28 @@ int maemo_main(int argc, char **argv)
                                } else
                                        isofilename[0] = 0;
                        }
-
                        cdfile = isofilename;
                }
                else if (!strcmp(argv[i],"-frameskip")) {
-
                        int tv_reg = atol(argv[++i]);
                        if (tv_reg > 0)
-                               pl_rearmed_cbs.frameskip = 1;
-               }
-               else if (!strcmp(argv[i],"-sputhreaded")) {
-                       iUseTimer=1;
-               }
-               else if (!strcmp(argv[i],"-nosound")) {
-                       strcpy(Config.Spu, "spunull.so");
-               }
-               else if(!strcmp(argv[i], "-bdir"))      sprintf(Config.BiosDir, "%s", argv[++i]);
-               else if(!strcmp(argv[i], "-bios"))      sprintf(Config.Bios, "%s", argv[++i]);
-               else if (!strcmp(argv[i],"-gles")){
-                       strcpy(Config.Gpu, "gpuGLES.so");
+                               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],"-sputhreaded"))               iUseTimer=1;
+               else if (!strcmp(argv[i],"-nosound"))           strcpy(Config.Spu, "spunull.so");
+               /* unworking with r10
+               else if(!strcmp(argv[i], "-bdir"))                      sprintf(Config.BiosDir, "%s", argv[++i]);
+               else if(!strcmp(argv[i], "-bios"))                      sprintf(Config.Bios, "%s", argv[++i]);
+               else if (!strcmp(argv[i],"-gles"))                      strcpy(Config.Gpu, "gpuGLES.so");
+               */
                else if (!strcmp(argv[i], "-cdda"))             Config.Cdda = 1;
                else if (!strcmp(argv[i], "-xa"))               Config.Xa = 1;
                else if (!strcmp(argv[i], "-rcnt"))             Config.RCntFix = 1 ;
                else if (!strcmp(argv[i], "-sio"))              Config.Sio = 1;
                else if (!strcmp(argv[i], "-spuirq"))   Config.SpuIrq = 1;
                else if (!strcmp(argv[i], "-vsync"))    Config.VSyncWA = 1;
-               else if (!strcmp(argv[i], "-h") ||
-                        !strcmp(argv[i], "-help") ||
-                        !strcmp(argv[i], "--help")) {
-                        printf(PACKAGE_NAME " " PACKAGE_VERSION "\n");
-                        printf("%s\n", _(
-                                                       " pcsx [options] [file]\n"
-                                                       "\toptions:\n"
-                                                       "\t-cdfile FILE\tRuns a CD image file\n"
-                                                       "\t-psxout\t\tEnable PSX output\n"
-                                                       "\t-nosound\t\tDisable sound using spunull plugin\n"
-                                                       "\t-sputhreaded\t\tMove sound to separate thread\n"
-                                                       "\t-frameskip\t\tEnable frameskip\n"
-                                                       "\t-load STATENUM\tLoads savestate STATENUM (1-5)\n"
-                                                       "\t-h -help\tDisplay this message\n"
-                                                       "\tfile\t\tLoads file\n"));
-                        return 0;
-               } else {
-                       strncpy(file, argv[i], MAXPATHLEN);
-                       if (file[0] != '/') {
-                               getcwd(path, MAXPATHLEN);
-                               if (strlen(path) + strlen(file) + 1 < MAXPATHLEN) {
-                                       strcat(path, "/");
-                                       strcat(path, file);
-                                       strcpy(file, path);
-                               } else
-                                       file[0] = 0;
-                       }
-               }
        }
 
        pl_rearmed_cbs.gpu_peops.dwActFixes = 1<<7;
@@ -139,6 +107,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)
                set_cd_image(cdfile);