X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fgp2x%2Finput.c;h=e1046bdc20b5219f2e54aa70ac7b6efbbcd99dae;hb=282becab483a0e14ab9d59e659e190f962947220;hp=6a51264ac4695b0bdf0c2c7cafe931c8457a0e9d;hpb=9b4514550544ca3d0a451ba0a08eeb502961ec1c;p=fceu.git diff --git a/drivers/gp2x/input.c b/drivers/gp2x/input.c index 6a51264..e1046bd 100644 --- a/drivers/gp2x/input.c +++ b/drivers/gp2x/input.c @@ -22,8 +22,6 @@ #include "../../video.h" #include "usbjoy.h" -extern int FSkip; - /* UsrInputType[] is user-specified. InputType[] is current (game loading can override user settings) */ @@ -49,6 +47,13 @@ static void setsoundvol(int soundvolume) { int soundvolIndex; static char soundvolmeter[24]; + static int prev_snd_on = 0; + + if ((!!soundvolume) ^ prev_snd_on) + { + FCEUI_Sound(Settings.sound_rate); + prev_snd_on = !!soundvolume; + } // draw on screen :D gp2x_sound_volume(soundvolume, soundvolume); @@ -88,7 +93,7 @@ static void do_emu_acts(uint32 acts) FCEUD_Update(XBuf+8,NULL,0); while( !((keys = gp2x_joystick_read(1)) & (GP2X_X|GP2X_Y)) ) usleep(50*1024); if (keys & GP2X_X) do_it = 0; - FCEU_DispMessage(""); + FCEU_CancelDispMessage(); } if (do_it) FCEUI_LoadState(); } @@ -107,7 +112,7 @@ static void do_emu_acts(uint32 acts) FCEUD_Update(XBuf+8,NULL,0); while( !((keys = gp2x_joystick_read(1)) & (GP2X_X|GP2X_Y)) ) usleep(50*1024); if (keys & GP2X_X) do_it = 0; - FCEU_DispMessage(""); + FCEU_CancelDispMessage(); } } if (do_it) FCEUI_SaveState(); @@ -194,10 +199,9 @@ static void FCEUD_UpdateInput(void) uint32 all_acts[2] = {0,0}; int i; - if ((down(VOL_DOWN) && down(VOL_UP)) || (keys & (GP2X_L|GP2X_L|GP2X_START)) == (GP2X_L|GP2X_L|GP2X_START)) + if ((down(VOL_DOWN) && down(VOL_UP)) || (keys & (GP2X_L|GP2X_START)) == (GP2X_L|GP2X_START)) { Exit = 1; - FSkip = 0; /* force rendering the last frame for menu */ return; } else if (down(VOL_UP)) @@ -247,6 +251,7 @@ static void FCEUD_UpdateInput(void) if ((keys & (1 << u)) && (Settings.KeyBinds[u] & acts)) { keys &= ~(1 << u); + acts &= Settings.KeyBinds[u]; break; } } @@ -346,33 +351,38 @@ static void InitOtherInput(void) static void PrepareOtherInput(void) { - uint32 act, key, seen_acts; + uint32 act; - combo_acts = combo_keys = prev_emu_acts = seen_acts = 0; + combo_acts = combo_keys = prev_emu_acts = 0; - // find combo_acts - for (act = 1; act; act <<= 1) + for (act = 0; act < 32; act++) { - for (key = 1; key < 32; key++) + int u, keyc = 0, keyc2 = 0; + if (act == 16 || act == 17) continue; // player2 flag + if (act > 17) { - if (Settings.KeyBinds[key] & act) - { - if (seen_acts & act) combo_acts |= act; - else seen_acts |= act; - } + for (u = 0; u < 32; u++) + if (Settings.KeyBinds[u] & (1 << act)) keyc++; } - } - - combo_acts &= ~0x00030000; // don't take player_id bits - - // find combo_keys - for (act = 1; act; act <<= 1) - { - for (key = 0; key < 32; key++) + else { - if (Settings.KeyBinds[key] & combo_acts) + for (u = 0; u < 32; u++) + if ((Settings.KeyBinds[u] & 0x30000) == 0 && // pl. 1 + (Settings.KeyBinds[u] & (1 << act))) keyc++; + for (u = 0; u < 32; u++) + if ((Settings.KeyBinds[u] & 0x30000) == 1 && // pl. 2 + (Settings.KeyBinds[u] & (1 << act))) keyc2++; + if (keyc2 > keyc) keyc = keyc2; + } + if (keyc > 1) + { + // loop again and mark those keys and actions as combo + for (u = 0; u < 32; u++) { - combo_keys |= 1 << key; + if (Settings.KeyBinds[u] & (1 << act)) { + combo_keys |= 1 << u; + combo_acts |= 1 << act; + } } } }