From 96fc17f43c593bf760457ab4dd6a29184439ef8b Mon Sep 17 00:00:00 2001 From: Jamiras Date: Tue, 6 Oct 2020 07:47:37 -0600 Subject: [PATCH] disable frame advance; delay pause spam in hardcore --- retroarch.c | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/retroarch.c b/retroarch.c index c4a9f249e2..67fa04d72a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -39598,19 +39598,47 @@ static enum runloop_state runloop_check_state( { static bool old_frameadvance = false; static bool old_pause_pressed = false; - bool frameadvance_pressed = BIT256_GET( - current_bits, RARCH_FRAMEADVANCE); - bool pause_pressed = BIT256_GET( - current_bits, RARCH_PAUSE_TOGGLE); - bool trig_frameadvance = frameadvance_pressed && !old_frameadvance; + bool pause_pressed, frameadvance_pressed, trig_frameadvance; + +#ifdef HAVE_CHEEVOS + if (rcheevos_hardcore_active()) + { + static int unpaused_frames = 0; + + /* frame advance is not allowed when achievement hardcore is active */ + frameadvance_pressed = false; + trig_frameadvance = false; + + pause_pressed = BIT256_GET(current_bits, RARCH_PAUSE_TOGGLE); + if (!p_rarch->runloop_paused) + { + /* limit pause to approximately three times per second (depending on core framerate) */ + if (unpaused_frames < 20) + { + ++unpaused_frames; + pause_pressed = false; + } + } + else + { + unpaused_frames = 0; + } + } + else +#endif + { + pause_pressed = BIT256_GET(current_bits, RARCH_PAUSE_TOGGLE); + frameadvance_pressed = BIT256_GET(current_bits, RARCH_FRAMEADVANCE); + trig_frameadvance = frameadvance_pressed && !old_frameadvance; + + /* FRAMEADVANCE will set us into pause mode. */ + pause_pressed |= !p_rarch->runloop_paused + && trig_frameadvance; + } /* Check if libretro pause key was pressed. If so, pause or * unpause the libretro core. */ - /* FRAMEADVANCE will set us into pause mode. */ - pause_pressed |= !p_rarch->runloop_paused - && trig_frameadvance; - if (focused && pause_pressed && !old_pause_pressed) command_event(CMD_EVENT_PAUSE_TOGGLE, NULL); else if (focused && !old_focus)