Skip to content

Commit a04ff9f

Browse files
authored
Only allow pausing when there is an active core (#18543)
1 parent e0fe988 commit a04ff9f

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

retroarch.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4240,6 +4240,10 @@ bool command_event(enum event_command cmd, void *data)
42404240
video_driver_state_t
42414241
*video_st = video_state_get_ptr();
42424242
rarch_system_info_t *sys_info = &runloop_st->system;
4243+
4244+
/* Restore unpaused state */
4245+
runloop_st->paused_hotkey = false;
4246+
command_event(CMD_EVENT_UNPAUSE, NULL);
42434247

42444248
/* The platform that uses ram_state_save calls it when the content
42454249
* ends and writes it to a file */
@@ -4751,7 +4755,9 @@ bool command_event(enum event_command cmd, void *data)
47514755
unsigned accessibility_narrator_speech_speed
47524756
= settings->uints.accessibility_narrator_speech_speed;
47534757
#endif
4754-
4758+
/* Allow pause toggling only when there is an active core. */
4759+
if (!(runloop_st->flags & RUNLOOP_FLAG_CORE_RUNNING))
4760+
break;
47554761
#ifdef HAVE_NETWORKING
47564762
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_ALLOW_PAUSE, NULL))
47574763
break;
@@ -4792,6 +4798,9 @@ bool command_event(enum event_command cmd, void *data)
47924798
runloop_pause_checks();
47934799
break;
47944800
case CMD_EVENT_PAUSE:
4801+
/* Allow pausing only when there is an active core. */
4802+
if (!(runloop_st->flags & RUNLOOP_FLAG_CORE_RUNNING))
4803+
break;
47954804
#ifdef HAVE_NETWORKING
47964805
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_ALLOW_PAUSE, NULL))
47974806
break;

runloop.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5536,7 +5536,6 @@ static bool display_menu_libretro(
55365536
}
55375537

55385538
static void runloop_pause_toggle(
5539-
bool *runloop_paused_hotkey,
55405539
bool pause_pressed, bool old_pause_pressed,
55415540
bool focused, bool old_focus)
55425541
{
@@ -5548,7 +5547,7 @@ static void runloop_pause_toggle(
55485547
{
55495548
/* Keep track of hotkey triggered pause to
55505549
* distinguish it from menu triggered pause */
5551-
*runloop_paused_hotkey = !(runloop_st->flags & RUNLOOP_FLAG_PAUSED);
5550+
runloop_st->paused_hotkey = !(runloop_st->flags & RUNLOOP_FLAG_PAUSED);
55525551
command_event(CMD_EVENT_PAUSE_TOGGLE, NULL);
55535552
}
55545553
else if (!old_focus)
@@ -5584,7 +5583,6 @@ static enum runloop_state_enum runloop_check_state(
55845583
gfx_display_t *p_disp = disp_get_ptr();
55855584
runloop_state_t *runloop_st = &runloop_state;
55865585
static bool old_focus = true;
5587-
static bool runloop_paused_hotkey = false;
55885586
struct retro_callbacks *cbs = &runloop_st->retro_ctx;
55895587
bool is_focused = false;
55905588
bool is_alive = false;
@@ -5666,10 +5664,10 @@ static enum runloop_state_enum runloop_check_state(
56665664
{
56675665
BIT256_CLEAR_ALL(current_bits);
56685666
if ( runloop_paused
5669-
&& !runloop_paused_hotkey
5667+
&& !runloop_st->paused_hotkey
56705668
&& menu_pause_libretro)
56715669
BIT256_SET(current_bits, RARCH_PAUSE_TOGGLE);
5672-
else if (runloop_paused_hotkey)
5670+
else if (runloop_st->paused_hotkey)
56735671
{
56745672
/* Restore pause if pause is triggered with both hotkey and menu,
56755673
* and restore cached video frame to continue properly to
@@ -6515,7 +6513,7 @@ static enum runloop_state_enum runloop_check_state(
65156513
bool pause_pressed = BIT256_GET(current_bits, RARCH_PAUSE_TOGGLE);
65166514

65176515
/* Decide pause hotkey */
6518-
runloop_pause_toggle(&runloop_paused_hotkey,
6516+
runloop_pause_toggle(
65196517
pause_pressed, old_pause_pressed,
65206518
focused, old_focus);
65216519

@@ -6592,7 +6590,7 @@ static enum runloop_state_enum runloop_check_state(
65926590
}
65936591

65946592
/* Decide pause hotkey */
6595-
runloop_pause_toggle(&runloop_paused_hotkey,
6593+
runloop_pause_toggle(
65966594
pause_pressed, old_pause_pressed,
65976595
focused, old_focus);
65986596

runloop.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ struct runloop
301301
} name;
302302

303303
bool perfcnt_enable;
304+
bool paused_hotkey;
304305
};
305306

306307
typedef struct runloop runloop_state_t;

0 commit comments

Comments
 (0)