+static void do_emu_acts(uint32 acts)
+{
+ uint32 actsc = acts;
+ acts &= acts ^ prev_emu_acts;
+ prev_emu_acts = actsc;
+
+ if (acts & (3 << 30))
+ {
+ if (acts & (1 << 30))
+ {
+ FCEUI_LoadState();
+ }
+ else
+ {
+ FCEUI_SaveState();
+ }
+ }
+ else if (acts & (3 << 28)) // state slot next/prev
+ {
+ FILE *st;
+ char *fname;
+
+ CurrentState += (acts & (1 << 29)) ? 1 : -1;
+ if (CurrentState > 9) CurrentState = 0;
+ if (CurrentState < 0) CurrentState = 9;
+
+ fname = FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0);
+ st=fopen(fname,"rb");
+ free(fname);
+ FCEU_DispMessage("[%s] State Slot %i", st ? "USED" : "FREE", CurrentState);
+ if (st) fclose(st);
+ }
+ else if (acts & (1 << 27)) // FDS insert/eject
+ {
+ if(FCEUGameInfo.type == GIT_FDS)
+ FCEU_DoSimpleCommand(FCEUNPCMD_FDSINSERT);
+ }
+ else if (acts & (1 << 26)) // FDS select
+ {
+ if(FCEUGameInfo.type == GIT_FDS)
+ FCEU_DoSimpleCommand(FCEUNPCMD_FDSSELECT);
+ }
+ else if (acts & (1 << 25)) // VS Unisystem insert coin
+ {
+ if(FCEUGameInfo.type == GIT_VSUNI)
+ FCEU_DoSimpleCommand(FCEUNPCMD_VSUNICOIN);
+ }
+}
+
+
+#define down(b) (keys & GP2X_##b)
+static void do_fake_mouse(unsigned long keys)
+{
+ static int x=256/2, y=240/2;
+ int speed = 3;
+
+ if (down(A)) speed = 1;
+ if (down(Y)) speed = 5;
+
+ if (down(LEFT))
+ {
+ x -= speed;
+ if (x < 0) x = 0;
+ }
+ else if (down(RIGHT))
+ {
+ x += speed;
+ if (x > 255) x = 255;
+ }
+
+ if (down(UP))
+ {
+ y -= speed;
+ if (y < 0) y = 0;
+ }
+ else if (down(DOWN))
+ {
+ y += speed;
+ if (y > 239) y = 239;
+ }
+
+ MouseData[0] = x;
+ MouseData[1] = y;
+ MouseData[2] = 0;
+ if (down(B)) MouseData[2] |= 1;
+ if (down(X)) MouseData[2] |= 2;
+}
+