Skip to content

Commit

Permalink
Create menu_driver_is_alive
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Jan 22, 2017
1 parent 9152d7e commit 0d5b3b9
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 24 deletions.
6 changes: 3 additions & 3 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -1878,7 +1878,7 @@ bool command_event(enum event_command cmd, void *data)
return command_event_resize_windowed_scale();
case CMD_EVENT_MENU_TOGGLE:
#ifdef HAVE_MENU
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
if (menu_driver_is_alive())
rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL);
else
rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL);
Expand Down Expand Up @@ -1969,7 +1969,7 @@ bool command_event(enum event_command cmd, void *data)
command_event(CMD_EVENT_GAME_FOCUS_TOGGLE, (void*)(intptr_t)-1);
#ifdef HAVE_MENU
menu_display_set_framebuffer_dirty_flag();
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
if (menu_driver_is_alive())
command_event(CMD_EVENT_VIDEO_SET_BLOCKING_STATE, NULL);
#endif
break;
Expand Down Expand Up @@ -2382,7 +2382,7 @@ bool command_event(enum event_command cmd, void *data)
#ifdef HAVE_MENU
settings_t *settings = config_get_ptr();

if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
if (menu_driver_is_alive())
{
if (settings->menu.pause_libretro)
command_event(CMD_EVENT_AUDIO_STOP, NULL);
Expand Down
2 changes: 1 addition & 1 deletion gfx/common/win32_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message,
HDC hdc = BeginPaint(hwnd, &ps);

#ifdef HAVE_MENU
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL) && !gdi_has_menu_frame())
if (menu_driver_is_alive() && !gdi_has_menu_frame())
{
RECT rect;
GetClientRect(hwnd, &rect);
Expand Down
2 changes: 1 addition & 1 deletion gfx/video_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2291,7 +2291,7 @@ void video_driver_build_info(video_frame_info_t *video_info)

video_info->libretro_running = false;
#ifdef HAVE_MENU
video_info->menu_is_alive = menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL);
video_info->menu_is_alive = menu_driver_is_alive();
video_info->menu_footer_opacity = settings->menu.footer.opacity;
video_info->menu_header_opacity = settings->menu.header.opacity;
video_info->materialui_color_theme = settings->menu.materialui.menu_color_theme;
Expand Down
2 changes: 1 addition & 1 deletion input/drivers_joypad/ps3_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static void ps3_joypad_poll(void)
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_TRIANGLE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0;
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_SQUARE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0;

if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
if (menu_driver_is_alive())
{
int value = 0;
if (cellSysutilGetSystemParamInt(CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN, &value) == 0)
Expand Down
2 changes: 1 addition & 1 deletion input/drivers_joypad/psp_joypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static void psp_joypad_poll(void)
#endif
#if defined(VITA)
if (psp2_model == SCE_KERNEL_MODEL_VITA
&& !menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)
&& !menu_driver_is_alive()
&& settings->input.backtouch_enable)
{
unsigned i;
Expand Down
2 changes: 1 addition & 1 deletion input/input_overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void input_overlay_loaded(void *task_data, void *user_data, const char *err)

#ifdef HAVE_MENU
/* We can't display when the menu is up */
if (data->hide_in_menu && menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
if (data->hide_in_menu && menu_driver_is_alive())
{
if (data->overlay_enable)
goto abort_load;
Expand Down
2 changes: 1 addition & 1 deletion menu/drivers/rgui.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ static void rgui_render(void *data)
msg_force = menu_display_get_msg_force();

if (menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL)
&& menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL) && !msg_force)
&& menu_driver_is_alive() && !msg_force)
return;

if (runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL))
Expand Down
2 changes: 1 addition & 1 deletion menu/drivers/xui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ static void xui_render(void *data)

if (
menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL)
&& menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)
&& menu_driver_is_alive()
&& !msg_force
)
return;
Expand Down
12 changes: 6 additions & 6 deletions menu/menu_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,7 @@ const char *menu_driver_ident(void)

void menu_driver_frame(video_frame_info_t *video_info)
{
if (!menu_driver_alive)
return;

if (menu_driver_ctx->frame)
if (menu_driver_alive && menu_driver_ctx->frame)
menu_driver_ctx->frame(menu_userdata, video_info);
}

Expand Down Expand Up @@ -376,6 +373,11 @@ bool menu_driver_render(bool is_idle)
return true;
}

bool menu_driver_is_alive(void)
{
return menu_driver_alive;
}

bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
{
switch (state)
Expand Down Expand Up @@ -507,8 +509,6 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
case RARCH_MENU_CTL_UNSET_TOGGLE:
menu_driver_toggle(false);
break;
case RARCH_MENU_CTL_IS_ALIVE:
return menu_driver_alive;
case RARCH_MENU_CTL_SET_OWN_DRIVER:
menu_driver_data_own = true;
break;
Expand Down
3 changes: 2 additions & 1 deletion menu/menu_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ enum rarch_menu_ctl_state
RARCH_MENU_CTL_IS_TOGGLE,
RARCH_MENU_CTL_SET_TOGGLE,
RARCH_MENU_CTL_UNSET_TOGGLE,
RARCH_MENU_CTL_IS_ALIVE,
RARCH_MENU_CTL_DESTROY,
RARCH_MENU_CTL_IS_SET_TEXTURE,
RARCH_MENU_CTL_SET_OWN_DRIVER,
Expand Down Expand Up @@ -392,6 +391,8 @@ void menu_driver_set_binding_state(bool on);

void menu_driver_frame(video_frame_info_t *video_info);

bool menu_driver_is_alive(void);

extern menu_ctx_driver_t menu_ctx_xui;
extern menu_ctx_driver_t menu_ctx_rgui;
extern menu_ctx_driver_t menu_ctx_mui;
Expand Down
2 changes: 1 addition & 1 deletion retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ bool retroarch_main_init(int argc, char *argv[])
{
#ifdef HAVE_MENU
/* Check if menu was active prior to core initialization */
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
if (menu_driver_is_alive())
{
/* Attempt initializing dummy core */
current_core_type = CORE_TYPE_DUMMY;
Expand Down
12 changes: 6 additions & 6 deletions runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ static enum runloop_state runloop_check_state(

if (runloop_cmd_triggered(trigger_input, RARCH_FULLSCREEN_TOGGLE_KEY))
{
bool fullscreen_toggled = !runloop_paused || menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL);
bool fullscreen_toggled = !runloop_paused || menu_driver_is_alive();

if (fullscreen_toggled)
command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL);
Expand Down Expand Up @@ -757,7 +757,7 @@ static enum runloop_state runloop_check_state(
}

#ifdef HAVE_MENU
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
if (menu_driver_is_alive())
{
menu_ctx_iterate_t iter;
core_poll();
Expand Down Expand Up @@ -794,7 +794,7 @@ static enum runloop_state runloop_check_state(
#ifdef HAVE_MENU
if (menu_event_kb_is_set(RETROK_F1) == 1)
{
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
if (menu_driver_is_alive())
{
if (rarch_ctl(RARCH_CTL_IS_INITED, NULL) &&
!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
Expand All @@ -808,7 +808,7 @@ static enum runloop_state runloop_check_state(
runloop_cmd_triggered(trigger_input, RARCH_MENU_TOGGLE)) ||
rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
{
if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
if (menu_driver_is_alive())
{
if (rarch_ctl(RARCH_CTL_IS_INITED, NULL) &&
!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
Expand All @@ -823,7 +823,7 @@ static enum runloop_state runloop_check_state(
else
menu_event_kb_set(false, RETROK_F1);

if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL))
if (menu_driver_is_alive())
{
if (!settings->menu.throttle_framerate && !settings->fastforward_ratio)
return RUNLOOP_STATE_MENU_ITERATE;
Expand Down Expand Up @@ -1043,7 +1043,7 @@ int runloop_iterate(unsigned *sleep_ms)
settings_t *settings = config_get_ptr();
uint64_t old_input = last_input;
#ifdef HAVE_MENU
bool menu_is_alive = menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL);
bool menu_is_alive = menu_driver_is_alive();
#else
bool menu_is_alive = false;
#endif
Expand Down

0 comments on commit 0d5b3b9

Please sign in to comment.