X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=maemo%2Fhildon.c;h=dc5e497615ac17401c168f7b952c8f0cc802dac4;hp=26679ed3876027c257f2057a6eff41a8faaa48c3;hb=d84e376741b37109597cb3a08d31def4de3fc598;hpb=88d6397dd897815ccac8091bf7921f05ffa0b88e diff --git a/maemo/hildon.c b/maemo/hildon.c index 26679ed3..dc5e4976 100644 --- a/maemo/hildon.c +++ b/maemo/hildon.c @@ -5,8 +5,11 @@ #include #include #include "plugin_lib.h" + #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 @@ -21,6 +24,8 @@ static GdkImage *image; static HildonAnimationActor *actor; static GtkWidget *window, *drawing; +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 +87,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 +145,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 +169,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_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 ); hildon_animation_actor_set_parent (actor, GTK_WINDOW (window)); drawing = gtk_image_new (); @@ -170,11 +200,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_maemo_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 +218,25 @@ void *hildon_flip(void) { gtk_widget_queue_draw (drawing); + // process accelometer + 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 ) 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 )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);} + + } + /* process GTK+ events */ while (gtk_events_pending()) gtk_main_iteration();