Skip to content

Commit c5ccc62

Browse files
committed
Only allow pausing when there is an active core
1 parent 1ad5896 commit c5ccc62

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
@@ -4232,6 +4232,10 @@ bool command_event(enum event_command cmd, void *data)
42324232
video_driver_state_t
42334233
*video_st = video_state_get_ptr();
42344234
rarch_system_info_t *sys_info = &runloop_st->system;
4235+
4236+
/* Restore unpaused state */
4237+
runloop_st->paused_hotkey = false;
4238+
command_event(CMD_EVENT_UNPAUSE, NULL);
42354239

42364240
/* The platform that uses ram_state_save calls it when the content
42374241
* ends and writes it to a file */
@@ -4743,7 +4747,9 @@ bool command_event(enum event_command cmd, void *data)
47434747
unsigned accessibility_narrator_speech_speed
47444748
= settings->uints.accessibility_narrator_speech_speed;
47454749
#endif
4746-
4750+
/* Allow pause toggling only when there is an active core. */
4751+
if (!(runloop_st->flags & RUNLOOP_FLAG_CORE_RUNNING))
4752+
break;
47474753
#ifdef HAVE_NETWORKING
47484754
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_ALLOW_PAUSE, NULL))
47494755
break;
@@ -4784,6 +4790,9 @@ bool command_event(enum event_command cmd, void *data)
47844790
runloop_pause_checks();
47854791
break;
47864792
case CMD_EVENT_PAUSE:
4793+
/* Allow pausing only when there is an active core. */
4794+
if (!(runloop_st->flags & RUNLOOP_FLAG_CORE_RUNNING))
4795+
break;
47874796
#ifdef HAVE_NETWORKING
47884797
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_ALLOW_PAUSE, NULL))
47894798
break;

runloop.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5539,7 +5539,6 @@ static bool display_menu_libretro(
55395539
}
55405540

55415541
static void runloop_pause_toggle(
5542-
bool *runloop_paused_hotkey,
55435542
bool pause_pressed, bool old_pause_pressed,
55445543
bool focused, bool old_focus)
55455544
{
@@ -5551,7 +5550,7 @@ static void runloop_pause_toggle(
55515550
{
55525551
/* Keep track of hotkey triggered pause to
55535552
* distinguish it from menu triggered pause */
5554-
*runloop_paused_hotkey = !(runloop_st->flags & RUNLOOP_FLAG_PAUSED);
5553+
runloop_st->paused_hotkey = !(runloop_st->flags & RUNLOOP_FLAG_PAUSED);
55555554
command_event(CMD_EVENT_PAUSE_TOGGLE, NULL);
55565555
}
55575556
else if (!old_focus)
@@ -5587,7 +5586,6 @@ static enum runloop_state_enum runloop_check_state(
55875586
gfx_display_t *p_disp = disp_get_ptr();
55885587
runloop_state_t *runloop_st = &runloop_state;
55895588
static bool old_focus = true;
5590-
static bool runloop_paused_hotkey = false;
55915589
struct retro_callbacks *cbs = &runloop_st->retro_ctx;
55925590
bool is_focused = false;
55935591
bool is_alive = false;
@@ -5669,10 +5667,10 @@ static enum runloop_state_enum runloop_check_state(
56695667
{
56705668
BIT256_CLEAR_ALL(current_bits);
56715669
if ( runloop_paused
5672-
&& !runloop_paused_hotkey
5670+
&& !runloop_st->paused_hotkey
56735671
&& menu_pause_libretro)
56745672
BIT256_SET(current_bits, RARCH_PAUSE_TOGGLE);
5675-
else if (runloop_paused_hotkey)
5673+
else if (runloop_st->paused_hotkey)
56765674
{
56775675
/* Restore pause if pause is triggered with both hotkey and menu,
56785676
* and restore cached video frame to continue properly to
@@ -6518,7 +6516,7 @@ static enum runloop_state_enum runloop_check_state(
65186516
bool pause_pressed = BIT256_GET(current_bits, RARCH_PAUSE_TOGGLE);
65196517

65206518
/* Decide pause hotkey */
6521-
runloop_pause_toggle(&runloop_paused_hotkey,
6519+
runloop_pause_toggle(
65226520
pause_pressed, old_pause_pressed,
65236521
focused, old_focus);
65246522

@@ -6595,7 +6593,7 @@ static enum runloop_state_enum runloop_check_state(
65956593
}
65966594

65976595
/* Decide pause hotkey */
6598-
runloop_pause_toggle(&runloop_paused_hotkey,
6596+
runloop_pause_toggle(
65996597
pause_pressed, old_pause_pressed,
66006598
focused, old_focus);
66016599

runloop.h

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

302302
bool perfcnt_enable;
303+
bool paused_hotkey;
303304
};
304305

305306
typedef struct runloop runloop_state_t;

0 commit comments

Comments
 (0)