(menu_driver.c) Use flags instead of bools (#14500)

* (menu_driver.c) Use flags instead of bools
This commit is contained in:
LibretroAdmin 2022-10-08 22:52:18 +02:00 committed by GitHub
parent fd2a026f96
commit d506210fbe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 4520 additions and 4499 deletions

View file

@ -1582,11 +1582,13 @@ bool audio_driver_callback(void)
#ifdef HAVE_MENU
#ifdef HAVE_NETWORKING
bool core_paused = runloop_paused ||
(settings->bools.menu_pause_libretro && menu_state_get_ptr()->alive &&
netplay_driver_ctl(RARCH_NETPLAY_CTL_ALLOW_PAUSE, NULL));
( settings->bools.menu_pause_libretro
&& (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE)
&& netplay_driver_ctl(RARCH_NETPLAY_CTL_ALLOW_PAUSE, NULL));
#else
bool core_paused = runloop_paused ||
(settings->bools.menu_pause_libretro && menu_state_get_ptr()->alive);
(settings->bools.menu_pause_libretro
&& (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE));
#endif
#else
bool core_paused = runloop_paused;

View file

@ -1779,7 +1779,7 @@ void command_event_reinit(const int flags)
p_disp->flags |= GFX_DISP_FLAG_FB_DIRTY;
if (video_fullscreen)
video_driver_hide_mouse();
if ( menu_st->alive
if ( (menu_st->flags & MENU_ST_FLAG_ALIVE)
&& video_st->current_video->set_nonblock_state)
video_st->current_video->set_nonblock_state(
video_st->data, false,

View file

@ -464,7 +464,7 @@ void drivers_init(
#ifdef HAVE_MENU
/* By default, we want the menu to persist through driver reinits. */
if (menu_st)
menu_st->data_own = true;
menu_st->flags |= MENU_ST_FLAG_DATA_OWN;
#endif
if (flags & (DRIVER_VIDEO_MASK | DRIVER_AUDIO_MASK))

View file

@ -660,7 +660,7 @@ static void bottom_menu_control(void* data, bool lcd_bottom)
}
#ifdef HAVE_MENU
if (menu_state_get_ptr()->alive)
if (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE)
ctr->bottom_menu = CTR_BOTTOM_MENU_SELECT;
else
#endif
@ -1037,7 +1037,7 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
}
#ifdef HAVE_MENU
if (menu_state_get_ptr()->alive)
if (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE)
return;
#endif

View file

@ -228,7 +228,8 @@ static bool gfx_ctx_go2_drm_set_video_mode(void *data,
frontend_driver_install_signal_handler();
#ifdef HAVE_MENU
if (config_get_ptr()->bools.video_ctx_scaling && !menu_state_get_ptr()->alive)
if ( config_get_ptr()->bools.video_ctx_scaling
&& !(menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE))
{
drm->fb_width = av_info->geometry.base_width;
drm->fb_height = av_info->geometry.base_height;
@ -277,7 +278,8 @@ static void gfx_ctx_go2_drm_check_window(void *data, bool *quit,
settings_t *settings = config_get_ptr();
bool use_ctx_scaling = settings->bools.video_ctx_scaling;
if (use_ctx_scaling && !menu_state_get_ptr()->alive)
if ( use_ctx_scaling
&& !(menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE))
{
struct retro_system_av_info*
av_info = video_viewport_get_system_av_info();

View file

@ -115,11 +115,6 @@ enum gfx_display_driver_type
GFX_VIDEO_DRIVER_RSX
};
typedef struct gfx_display_frame_info
{
bool shadows_enable;
} gfx_display_frame_info_t;
typedef struct gfx_display_ctx_draw gfx_display_ctx_draw_t;
typedef struct gfx_display gfx_display_t;

View file

@ -96,11 +96,8 @@ void gfx_thumbnail_set_fade_missing(bool fade_missing)
static void gfx_thumbnail_fade_cb(void *userdata)
{
gfx_thumbnail_t *thumbnail = (gfx_thumbnail_t*)userdata;
if (!thumbnail)
return;
thumbnail->fade_active = false;
if (thumbnail)
thumbnail->flags |= GFX_THUMB_FLAG_FADE_ACTIVE;
}
/* Initialises thumbnail 'fade in' animation */
@ -124,7 +121,7 @@ static void gfx_thumbnail_init_fade(
gfx_animation_ctx_entry_t animation_entry;
thumbnail->alpha = 0.0f;
thumbnail->fade_active = true;
thumbnail->flags |= GFX_THUMB_FLAG_FADE_ACTIVE;
animation_entry.easing_enum = EASING_OUT_QUAD;
animation_entry.tag = (uintptr_t)&thumbnail->alpha;
@ -397,7 +394,7 @@ void gfx_thumbnail_reset(gfx_thumbnail_t *thumbnail)
video_driver_texture_unload(&thumbnail->texture);
/* Ensure any 'fade in' animation is killed */
if (thumbnail->fade_active)
if (thumbnail->flags & GFX_THUMB_FLAG_FADE_ACTIVE)
{
uintptr_t tag = (uintptr_t)&thumbnail->alpha;
gfx_animation_kill_by_tag(&tag);
@ -410,8 +407,8 @@ void gfx_thumbnail_reset(gfx_thumbnail_t *thumbnail)
thumbnail->height = 0;
thumbnail->alpha = 0.0f;
thumbnail->delay_timer = 0.0f;
thumbnail->fade_active = false;
thumbnail->core_aspect = false;
thumbnail->flags &= ~(GFX_THUMB_FLAG_FADE_ACTIVE
| GFX_THUMB_FLAG_CORE_ASPECT);
}
/* Stream processing */
@ -805,7 +802,8 @@ void gfx_thumbnail_get_draw_dimensions(
* differences */
display_aspect = (float)width / (float)height;
thumbnail_aspect = (float)thumbnail->width / (float)thumbnail->height;
core_aspect = (thumbnail->core_aspect && video_st)
core_aspect = ((thumbnail->flags & GFX_THUMB_FLAG_CORE_ASPECT)
&& video_st)
? video_st->av_info.geometry.aspect_ratio : thumbnail_aspect;
if (thumbnail_aspect > display_aspect)
@ -813,7 +811,7 @@ void gfx_thumbnail_get_draw_dimensions(
*draw_width = (float)width;
*draw_height = (float)thumbnail->height * (*draw_width / (float)thumbnail->width);
if (thumbnail->core_aspect)
if (thumbnail->flags & GFX_THUMB_FLAG_CORE_ASPECT)
{
*draw_height = *draw_height * (thumbnail_aspect / core_aspect);
@ -830,7 +828,7 @@ void gfx_thumbnail_get_draw_dimensions(
*draw_height = (float)height;
*draw_width = (float)thumbnail->width * (*draw_height / (float)thumbnail->height);
if (thumbnail->core_aspect)
if (thumbnail->flags & GFX_THUMB_FLAG_CORE_ASPECT)
*draw_width = *draw_width / (thumbnail_aspect / core_aspect);
}

View file

@ -63,6 +63,12 @@ enum gfx_thumbnail_shadow_type
GFX_THUMBNAIL_SHADOW_OUTLINE
};
enum gfx_thumbnail_flags
{
GFX_THUMB_FLAG_FADE_ACTIVE = (1 << 0),
GFX_THUMB_FLAG_CORE_ASPECT = (1 << 1)
};
/* Holds all runtime parameters associated with
* an entry thumbnail */
typedef struct
@ -73,8 +79,7 @@ typedef struct
float alpha;
float delay_timer;
enum gfx_thumbnail_status status;
bool fade_active;
bool core_aspect;
uint8_t flags;
} gfx_thumbnail_t;
/* Holds all configuration parameters associated

File diff suppressed because it is too large Load diff

View file

@ -670,7 +670,7 @@ static void gfx_widget_load_content_animation_frame(void *data, void *user_data)
#ifdef HAVE_MENU
/* Draw nothing if menu is currently active */
if (menu_state_get_ptr()->alive)
if (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE)
return;
#endif

View file

@ -410,7 +410,7 @@ static void winraw_update_mouse_state(winraw_input_t *wr,
* break multiple mice positions */
bool getcursorpos = (mouse->device == RETRO_DEVICE_POINTER) ? true : false;
#ifdef HAVE_MENU
if (menu_state_get_ptr()->alive)
if (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE)
getcursorpos = true;
#endif

View file

@ -210,7 +210,7 @@ static void ps3_joypad_poll(void)
*state_cur |= (state_tmp.button[CELL_PAD_BTN_OFFSET_DIGITAL2] & CELL_PAD_CTRL_SQUARE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
#ifdef HAVE_MENU
if (menu_state_get_ptr()->alive)
if (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE)
{
int value = 0;
if (cellSysutilGetSystemParamInt(CELL_SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN, &value) == 0)

View file

@ -3345,7 +3345,8 @@ static void input_overlay_loaded(retro_task_t *task,
{
#ifdef HAVE_MENU
/* We can't display when the menu is up */
if (data->hide_in_menu && menu_state_get_ptr()->alive)
if ( data->hide_in_menu
&& (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE))
goto abort_load;
#endif
@ -3461,7 +3462,8 @@ void input_overlay_init(void)
/* Cancel load if 'hide_in_menu' is enabled and
* menu is currently active */
if (overlay_hide_in_menu)
load_enabled = load_enabled && !menu_state_get_ptr()->alive;
load_enabled = load_enabled && !(menu_state_get_ptr()->flags &
MENU_ST_FLAG_ALIVE);
#endif
/* Cancel load if 'hide_when_gamepad_connected' is
@ -3735,7 +3737,8 @@ int16_t input_state_device(
BIT256_GET(input_st->overlay_ptr->overlay_state.buttons, id))
{
#ifdef HAVE_MENU
bool menu_driver_alive = menu_state_get_ptr()->alive;
bool menu_driver_alive = menu_state_get_ptr()->flags &
MENU_ST_FLAG_ALIVE;
#else
bool menu_driver_alive = false;
#endif
@ -4124,7 +4127,7 @@ void input_driver_poll(void)
#endif
#ifdef HAVE_MENU
if (!menu_state_get_ptr()->alive)
if (!(menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE))
#endif
if (input_remap_binds_enable)
{
@ -5364,7 +5367,8 @@ void input_driver_collect_system_input(input_driver_state_t *input_st,
#endif
#ifdef HAVE_MENU
bool display_kb = menu_input_dialog_get_display_kb();
bool menu_is_alive = menu_state_get_ptr()->alive;
bool menu_is_alive = menu_state_get_ptr()->flags &
MENU_ST_FLAG_ALIVE;
bool menu_input_active = menu_is_alive &&
!(settings->bools.menu_unified_controls && !display_kb);
#endif
@ -5665,7 +5669,7 @@ void input_keyboard_event(bool down, unsigned code,
* explicitly...
* Otherwise, input is ignored whenever screensaver
* is active */
if (menu_st->screensaver_active)
if (menu_st->flags & MENU_ST_FLAG_SCREENSAVER_ACTIVE)
{
if (down &&
(code != RETROK_UNKNOWN) &&
@ -5687,7 +5691,7 @@ void input_keyboard_event(bool down, unsigned code,
menu_ctx_environment_t menu_environ;
menu_environ.type = MENU_ENVIRON_DISABLE_SCREENSAVER;
menu_environ.data = NULL;
menu_st->screensaver_active = false;
menu_st->flags &= ~MENU_ST_FLAG_SCREENSAVER_ACTIVE;
menu_st->input_last_time_us = menu_st->current_time_us;
menu_driver_ctl(RARCH_MENU_CTL_ENVIRONMENT, &menu_environ);
}

View file

@ -10185,7 +10185,7 @@ static void materialui_list_insert(
node->thumbnails.primary.height = 0;
node->thumbnails.primary.alpha = 0.0f;
node->thumbnails.primary.delay_timer = 0.0f;
node->thumbnails.primary.fade_active = false;
node->thumbnails.primary.flags &= ~GFX_THUMB_FLAG_FADE_ACTIVE;
node->thumbnails.secondary.status = GFX_THUMBNAIL_STATUS_UNKNOWN;
node->thumbnails.secondary.texture = 0;
@ -10193,7 +10193,7 @@ static void materialui_list_insert(
node->thumbnails.secondary.height = 0;
node->thumbnails.secondary.alpha = 0.0f;
node->thumbnails.secondary.delay_timer = 0.0f;
node->thumbnails.secondary.fade_active = false;
node->thumbnails.secondary.flags &= ~GFX_THUMB_FLAG_FADE_ACTIVE;
}
else
{

View file

@ -3535,7 +3535,7 @@ static void ozone_update_savestate_thumbnail_image(void *data)
}
}
ozone->thumbnails.savestate.core_aspect = true;
ozone->thumbnails.savestate.flags |= GFX_THUMB_FLAG_CORE_ASPECT;
}
static void ozone_entries_update_thumbnail_bar(

View file

@ -1519,7 +1519,7 @@ static void xmb_update_savestate_thumbnail_image(void *data)
thumbnail_upscale_threshold);
}
xmb->thumbnails.savestate.core_aspect = true;
xmb->thumbnails.savestate.flags |= GFX_THUMB_FLAG_CORE_ASPECT;
}
/* Is called when the pointer position changes within a list/sub-list (vertically) */

View file

@ -4213,7 +4213,7 @@ int menu_driver_deferred_push_content_list(file_list_t *list)
bool menu_driver_screensaver_supported(void)
{
struct menu_state *menu_st = &menu_driver_state;
return menu_st->screensaver_supported;
return ((menu_st->flags & MENU_ST_FLAG_SCREENSAVER_SUPPORTED) > 0);
}
retro_time_t menu_driver_get_current_time(void)
@ -4627,9 +4627,9 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data)
bool *nonblocking = (bool*)data;
if (*nonblocking)
menu_st->entries_nonblocking_refresh = true;
menu_st->flags |= MENU_ST_FLAG_ENTRIES_NONBLOCKING_REFRESH;
else
menu_st->entries_need_refresh = true;
menu_st->flags |= MENU_ST_FLAG_ENTRIES_NEED_REFRESH;
}
break;
case MENU_ENTRIES_CTL_UNSET_REFRESH:
@ -4637,9 +4637,9 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data)
bool *nonblocking = (bool*)data;
if (*nonblocking)
menu_st->entries_nonblocking_refresh = false;
menu_st->flags &= ~MENU_ST_FLAG_ENTRIES_NONBLOCKING_REFRESH;
else
menu_st->entries_need_refresh = false;
menu_st->flags &= ~MENU_ST_FLAG_ENTRIES_NEED_REFRESH;
}
break;
case MENU_ENTRIES_CTL_SET_START:
@ -4871,13 +4871,13 @@ void menu_driver_set_thumbnail_content(char *s, size_t len)
void menu_driver_destroy(
struct menu_state *menu_st)
{
menu_st->pending_quick_menu = false;
menu_st->prevent_populate = false;
menu_st->data_own = false;
menu_st->flags &= ~(MENU_ST_FLAG_PENDING_QUICK_MENU
| MENU_ST_FLAG_PREVENT_POPULATE
| MENU_ST_FLAG_DATA_OWN
| MENU_ST_FLAG_ALIVE);
menu_st->driver_ctx = NULL;
menu_st->userdata = NULL;
menu_st->input_driver_flushing_input = 0;
menu_st->alive = false;
}
bool menu_driver_list_get_entry(menu_ctx_list_t *list)
@ -5024,7 +5024,7 @@ void menu_input_dialog_end(void)
struct menu_state *menu_st = &menu_driver_state;
menu_st->input_dialog_kb_type = 0;
menu_st->input_dialog_kb_idx = 0;
menu_st->input_dialog_kb_display = false;
menu_st->flags &= ~MENU_ST_FLAG_INP_DLG_KB_DISPLAY;
menu_st->input_dialog_kb_label[0] = '\0';
menu_st->input_dialog_kb_label_setting[0] = '\0';
@ -5177,8 +5177,11 @@ static bool menu_driver_init_internal(
menu_environ.type = MENU_ENVIRON_DISABLE_SCREENSAVER;
menu_environ.data = NULL;
menu_st->input_last_time_us = cpu_features_get_time_usec();
menu_st->screensaver_active = false;
menu_st->screensaver_supported = menu_driver_ctl(RARCH_MENU_CTL_ENVIRONMENT, &menu_environ);
menu_st->flags &= ~MENU_ST_FLAG_SCREENSAVER_ACTIVE;
if (menu_driver_ctl(RARCH_MENU_CTL_ENVIRONMENT, &menu_environ))
menu_st->flags |= MENU_ST_FLAG_SCREENSAVER_SUPPORTED;
else
menu_st->flags &= ~MENU_ST_FLAG_SCREENSAVER_SUPPORTED;
return true;
}
@ -5561,13 +5564,12 @@ bool menu_input_dialog_get_display_kb(void)
if (typing)
return false;
/* swkbd only works on "real" titles */
if ( __nx_applet_type != AppletType_Application
&& __nx_applet_type != AppletType_SystemApplication)
return menu_st->input_dialog_kb_display;
return (menu_st->flags & MENU_ST_FLAG_INP_DLG_KB_DISPLAY);
if (!menu_st->input_dialog_kb_display)
if (!(menu_st->flags & MENU_ST_FLAG_INP_DLG_KB_DISPLAY))
return false;
rc = swkbdCreate(&kbd, 0);
@ -5591,7 +5593,7 @@ bool menu_input_dialog_get_display_kb(void)
for (i = 0; i < LIBNX_SWKBD_LIMIT; i++)
{
/* In case a previous "Enter" press closed the keyboard */
if (!menu_st->input_dialog_kb_display)
if (!(menu_st->flags & MENU_ST_FLAG_INP_DLG_KB_DISPLAY))
break;
if (buf[i] == '\n' || buf[i] == '\0')
@ -5601,11 +5603,12 @@ bool menu_input_dialog_get_display_kb(void)
const char *word = &buf[i];
/* input_keyboard_line_append expects a null-terminated
string, so just make one (yes, the touch keyboard is
a list of "null-terminated characters") */
a list of "NULL-terminated characters") */
char oldchar = buf[i+1];
buf[i+1] = '\0';
input_keyboard_line_append(&input_st->keyboard_line, word, strlen(word));
input_keyboard_line_append(&input_st->keyboard_line,
word, strlen(word));
osk_update_last_codepoint(
&input_st->osk_last_codepoint,
@ -5616,7 +5619,7 @@ bool menu_input_dialog_get_display_kb(void)
}
/* fail-safe */
if (menu_st->input_dialog_kb_display)
if (menu_st->flags & MENU_ST_FLAG_INP_DLG_KB_DISPLAY)
input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD);
typing = false;
@ -5625,7 +5628,7 @@ bool menu_input_dialog_get_display_kb(void)
}
libnx_apply_overclock();
#endif /* HAVE_LIBNX */
return menu_st->input_dialog_kb_display;
return ((menu_st->flags & MENU_ST_FLAG_INP_DLG_KB_DISPLAY) > 0);
}
unsigned menu_event(
@ -5776,7 +5779,7 @@ unsigned menu_event(
/* If menu screensaver is active, any input
* is intercepted and used to switch it off */
if (menu_st->screensaver_active)
if (menu_st->flags & MENU_ST_FLAG_SCREENSAVER_ACTIVE)
{
/* Check pointer input */
bool input_active = (menu_input->pointer.type != MENU_POINTER_DISABLED) &&
@ -5795,7 +5798,7 @@ unsigned menu_event(
menu_ctx_environment_t menu_environ;
menu_environ.type = MENU_ENVIRON_DISABLE_SCREENSAVER;
menu_environ.data = NULL;
menu_st->screensaver_active = false;
menu_st->flags &= ~MENU_ST_FLAG_SCREENSAVER_ACTIVE;
menu_st->input_last_time_us = menu_st->current_time_us;
menu_driver_ctl(RARCH_MENU_CTL_ENVIRONMENT, &menu_environ);
}
@ -6822,14 +6825,14 @@ void retroarch_menu_running(void)
if (menu->driver_ctx && menu->driver_ctx->toggle)
menu->driver_ctx->toggle(menu->userdata, true);
menu_st->alive = true;
menu_st->flags |= MENU_ST_FLAG_ALIVE;
menu_driver_toggle(
video_st->current_video,
video_st->data,
menu,
menu_input,
settings,
menu_st->alive,
menu_st->flags & MENU_ST_FLAG_ALIVE,
#ifdef HAVE_OVERLAY
input_st->overlay_ptr &&
input_st->overlay_ptr->alive,
@ -6861,12 +6864,12 @@ void retroarch_menu_running(void)
/* Ensure that menu screensaver is disabled when
* first switching to the menu */
if (menu_st->screensaver_active)
if (menu_st->flags & MENU_ST_FLAG_SCREENSAVER_ACTIVE)
{
menu_ctx_environment_t menu_environ;
menu_environ.type = MENU_ENVIRON_DISABLE_SCREENSAVER;
menu_environ.data = NULL;
menu_st->screensaver_active = false;
menu_st->flags &= ~MENU_ST_FLAG_SCREENSAVER_ACTIVE;
menu_driver_ctl(RARCH_MENU_CTL_ENVIRONMENT, &menu_environ);
}
menu_st->input_last_time_us = cpu_features_get_time_usec();
@ -6891,14 +6894,14 @@ void retroarch_menu_running_finished(bool quit)
if (menu->driver_ctx && menu->driver_ctx->toggle)
menu->driver_ctx->toggle(menu->userdata, false);
menu_st->alive = false;
menu_st->flags &= ~MENU_ST_FLAG_ALIVE;
menu_driver_toggle(
video_st->current_video,
video_st->data,
menu,
menu_input,
settings,
menu_st->alive,
menu_st->flags & MENU_ST_FLAG_ALIVE,
#ifdef HAVE_OVERLAY
input_st->overlay_ptr &&
input_st->overlay_ptr->alive,
@ -6944,12 +6947,12 @@ void retroarch_menu_running_finished(bool quit)
/* Ensure that menu screensaver is disabled when
* switching off the menu */
if (menu_st->screensaver_active)
if (menu_st->flags & MENU_ST_FLAG_SCREENSAVER_ACTIVE)
{
menu_ctx_environment_t menu_environ;
menu_environ.type = MENU_ENVIRON_DISABLE_SCREENSAVER;
menu_environ.data = NULL;
menu_st->screensaver_active = false;
menu_st->flags &= ~MENU_ST_FLAG_SCREENSAVER_ACTIVE;
menu_driver_ctl(RARCH_MENU_CTL_ENVIRONMENT, &menu_environ);
}
video_driver_set_texture_enable(false, false);
@ -6972,23 +6975,23 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
bool flush_stack = !data ? true : *((bool *)data);
if (flush_stack)
menu_entries_flush_stack(NULL, MENU_SETTINGS);
menu_st->pending_quick_menu = true;
menu_st->flags |= MENU_ST_FLAG_PENDING_QUICK_MENU;
}
break;
case RARCH_MENU_CTL_SET_PREVENT_POPULATE:
menu_st->prevent_populate = true;
menu_st->flags |= MENU_ST_FLAG_PREVENT_POPULATE;
break;
case RARCH_MENU_CTL_UNSET_PREVENT_POPULATE:
menu_st->prevent_populate = false;
menu_st->flags &= ~MENU_ST_FLAG_PREVENT_POPULATE;
break;
case RARCH_MENU_CTL_IS_PREVENT_POPULATE:
return menu_st->prevent_populate;
return ((menu_st->flags & MENU_ST_FLAG_PREVENT_POPULATE) > 0);
case RARCH_MENU_CTL_DEINIT:
if ( menu_st->driver_ctx
&& menu_st->driver_ctx->context_destroy)
menu_st->driver_ctx->context_destroy(menu_st->userdata);
if (menu_st->data_own)
if (menu_st->flags & MENU_ST_FLAG_DATA_OWN)
return true;
playlist_free_cached();
@ -7054,8 +7057,8 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
free(menu_st->driver_data->core_buf);
menu_st->driver_data->core_buf = NULL;
menu_st->entries_need_refresh = false;
menu_st->entries_nonblocking_refresh = false;
menu_st->flags &= ~(MENU_ST_FLAG_ENTRIES_NEED_REFRESH
| MENU_ST_FLAG_ENTRIES_NONBLOCKING_REFRESH);
menu_st->entries.begin = 0;
command_event(CMD_EVENT_HISTORY_DEINIT, NULL);
@ -7413,7 +7416,7 @@ static int generic_menu_iterate(
menu->menu_state_msg[0] = '\0';
iterate_type = action_iterate_type(label);
menu_st->is_binding = false;
menu_st->flags &= ~MENU_ST_FLAG_IS_BINDING;
if ( action != MENU_ACTION_NOOP
|| MENU_ENTRIES_NEEDS_REFRESH(menu_st)
@ -7460,7 +7463,7 @@ static int generic_menu_iterate(
{
menu_input_ctx_bind_t bind;
menu_st->is_binding = true;
menu_st->flags |= MENU_ST_FLAG_IS_BINDING;
bind.s = menu->menu_state_msg;
bind.len = sizeof(menu->menu_state_msg);
@ -8080,10 +8083,11 @@ int generic_menu_entry_action(
}
#endif
if (menu_st->pending_close_content ||
menu_st->pending_env_shutdown_flush)
if ( (menu_st->flags & MENU_ST_FLAG_PENDING_CLOSE_CONTENT)
|| (menu_st->flags & MENU_ST_FLAG_PENDING_ENV_SHUTDOWN_FLUSH))
{
const char *content_path = menu_st->pending_env_shutdown_flush ?
const char *content_path = (menu_st->flags &
MENU_ST_FLAG_PENDING_ENV_SHUTDOWN_FLUSH) ?
menu_st->pending_env_shutdown_content_path :
path_get(RARCH_PATH_CONTENT);
const char *deferred_path = menu ? menu->deferred_path : NULL;
@ -8127,7 +8131,7 @@ int generic_menu_entry_action(
stack_offset++;
}
if (!menu_st->pending_env_shutdown_flush)
if (!(menu_st->flags & MENU_ST_FLAG_PENDING_ENV_SHUTDOWN_FLUSH))
command_event(CMD_EVENT_UNLOAD_CORE, NULL);
menu_entries_flush_stack(flush_target, 0);
@ -8141,8 +8145,8 @@ int generic_menu_entry_action(
if (reset_navigation)
menu_st->selection_ptr = 0;
menu_st->pending_close_content = false;
menu_st->pending_env_shutdown_flush = false;
menu_st->flags &= ~(MENU_ST_FLAG_PENDING_CLOSE_CONTENT
| MENU_ST_FLAG_PENDING_ENV_SHUTDOWN_FLUSH);
menu_st->pending_env_shutdown_content_path[0] = '\0';
}
@ -8188,7 +8192,7 @@ bool menu_input_dialog_start_search(void)
#ifdef HAVE_MIST
steam_open_osk();
#endif
menu_st->input_dialog_kb_display = true;
menu_st->flags |= MENU_ST_FLAG_INP_DLG_KB_DISPLAY;
strlcpy(menu_st->input_dialog_kb_label,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH),
sizeof(menu_st->input_dialog_kb_label));
@ -8239,7 +8243,7 @@ bool menu_input_dialog_start(menu_input_ctx_line_t *line)
#ifdef HAVE_MIST
steam_open_osk();
#endif
menu_st->input_dialog_kb_display = true;
menu_st->flags |= MENU_ST_FLAG_INP_DLG_KB_DISPLAY;
/* Only copy over the menu label and setting if they exist. */
if (line->label)

View file

@ -69,7 +69,7 @@ RETRO_BEGIN_DECLS
#define MENU_LIST_GET_STACK_SIZE(list, idx) ((list)->menu_stack[(idx)]->size)
#define MENU_ENTRIES_GET_SELECTION_BUF_PTR_INTERNAL(menu_st, idx) ((menu_st->entries.list) ? MENU_LIST_GET_SELECTION(menu_st->entries.list, (unsigned)idx) : NULL)
#define MENU_ENTRIES_NEEDS_REFRESH(menu_st) (!(menu_st->entries_nonblocking_refresh || !menu_st->entries_need_refresh))
#define MENU_ENTRIES_NEEDS_REFRESH(menu_st) (!((menu_st->flags & MENU_ST_FLAG_ENTRIES_NONBLOCKING_REFRESH) || !(menu_st->flags & MENU_ST_FLAG_ENTRIES_NEED_REFRESH)))
#define MENU_SETTINGS_CORE_INFO_NONE 0xffff
#define MENU_SETTINGS_CORE_OPTION_NONE 0xffff
@ -450,6 +450,32 @@ typedef struct
char detect_content_path[PATH_MAX_LENGTH];
} menu_handle_t;
enum menu_state_flags
{
MENU_ST_FLAG_ALIVE = (1 << 0),
MENU_ST_FLAG_IS_BINDING = (1 << 1),
MENU_ST_FLAG_INP_DLG_KB_DISPLAY = (1 << 2),
/* When enabled, on next iteration the 'Quick Menu'
* list will be pushed onto the stack */
MENU_ST_FLAG_PENDING_QUICK_MENU = (1 << 3),
MENU_ST_FLAG_PREVENT_POPULATE = (1 << 4),
/* The menu driver owns the userdata */
MENU_ST_FLAG_DATA_OWN = (1 << 5),
/* Flagged when menu entries need to be refreshed */
MENU_ST_FLAG_ENTRIES_NEED_REFRESH = (1 << 6),
MENU_ST_FLAG_ENTRIES_NONBLOCKING_REFRESH = (1 << 7),
/* 'Close Content'-hotkey menu resetting */
MENU_ST_FLAG_PENDING_CLOSE_CONTENT = (1 << 8),
/* Flagged when a core calls RETRO_ENVIRONMENT_SHUTDOWN,
* requiring the menu to be flushed on the next iteration */
MENU_ST_FLAG_PENDING_ENV_SHUTDOWN_FLUSH = (1 << 9),
/* Screensaver status
* - Does menu driver support screensaver functionality?
* - Is screensaver currently active? */
MENU_ST_FLAG_SCREENSAVER_SUPPORTED = (1 << 10),
MENU_ST_FLAG_SCREENSAVER_ACTIVE = (1 << 11)
};
struct menu_state
{
/* Timers */
@ -496,11 +522,12 @@ struct menu_state
unsigned input_dialog_kb_idx;
unsigned input_driver_flushing_input;
menu_dialog_t dialog_st;
enum menu_action prev_action;
/* int16_t alignment */
menu_input_pointer_hw_state_t input_pointer_hw_state;
enum menu_action prev_action;
uint16_t flags;
/* When generating a menu list in menu_displaylist_build_list(),
* the entry with a label matching 'pending_selection' will
@ -521,32 +548,8 @@ struct menu_state
char input_dialog_kb_label[256];
#endif
unsigned char kb_key_state[RETROK_LAST];
bool input_dialog_kb_display;
/* when enabled, on next iteration the 'Quick Menu' list will
* be pushed onto the stack */
bool pending_quick_menu;
bool prevent_populate;
/* The menu driver owns the userdata */
bool data_own;
/* Flagged when menu entries need to be refreshed */
bool entries_need_refresh;
bool entries_nonblocking_refresh;
/* 'Close Content'-hotkey menu resetting */
bool pending_close_content;
/* Flagged when a core calls RETRO_ENVIRONMENT_SHUTDOWN,
* requiring the menu to be flushed on the next iteration */
bool pending_env_shutdown_flush;
/* Screensaver status
* - Does menu driver support screensaver functionality?
* - Is screensaver currently active? */
bool screensaver_supported;
bool screensaver_active;
bool is_binding;
bool alive;
};
typedef struct menu_content_ctx_defer_info
{
void *data;

View file

@ -9112,7 +9112,8 @@ static void gfx_widget_netplay_chat_iterate(void *user_data,
struct netplay_chat *chat = &netplay->chat;
settings_t *settings = config_get_ptr();
#ifdef HAVE_MENU
bool menu_open = menu_state_get_ptr()->alive;
bool menu_open = menu_state_get_ptr()->flags &
MENU_ST_FLAG_ALIVE;
#endif
bool fade_chat = settings->bools.netplay_fade_chat;
@ -9240,7 +9241,8 @@ static void gfx_widget_netplay_ping_iterate(void *user_data,
netplay_t *netplay = net_st->data;
settings_t *settings = config_get_ptr();
#ifdef HAVE_MENU
bool menu_open = menu_state_get_ptr()->alive;
bool menu_open = menu_state_get_ptr()->flags &
MENU_ST_FLAG_ALIVE;
#endif
bool show_ping = settings->bools.netplay_ping_show;

View file

@ -1808,7 +1808,7 @@ bool command_event(enum event_command cmd, void *data)
break;
case CMD_EVENT_MENU_TOGGLE:
#ifdef HAVE_MENU
if (menu_st->alive)
if (menu_st->flags & MENU_ST_FLAG_ALIVE)
retroarch_menu_running_finished(false);
else
retroarch_menu_running();
@ -1983,9 +1983,9 @@ bool command_event(enum event_command cmd, void *data)
/* Closing content via hotkey requires toggling menu
* and resetting the position later on to prevent
* going to empty Quick Menu */
if (!menu_state_get_ptr()->alive)
if (!(menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE))
{
menu_state_get_ptr()->pending_close_content = true;
menu_state_get_ptr()->flags |= MENU_ST_FLAG_PENDING_CLOSE_CONTENT;
command_event(CMD_EVENT_MENU_TOGGLE, NULL);
}
#else
@ -2701,7 +2701,7 @@ bool command_event(enum event_command cmd, void *data)
break;
case CMD_EVENT_MENU_PAUSE_LIBRETRO:
#ifdef HAVE_MENU
if (menu_st->alive)
if (menu_st->flags & MENU_ST_FLAG_ALIVE)
{
#ifdef HAVE_NETWORKING
bool menu_pause_libretro = settings->bools.menu_pause_libretro &&
@ -3228,7 +3228,7 @@ bool command_event(enum event_command cmd, void *data)
#ifdef HAVE_MENU
/* If menu is currently active, disable
* 'toggle on' functionality */
if (menu_st->alive)
if (menu_st->flags & MENU_ST_FLAG_ALIVE)
input_st->game_focus_state.enabled = false;
#endif
if (input_st->game_focus_state.enabled != current_enable_state)
@ -3698,7 +3698,7 @@ void main_exit(void *args)
#ifdef HAVE_MENU
/* Do not want menu context to live any more. */
if (menu_st)
menu_st->data_own = false;
menu_st->flags &= ~MENU_ST_FLAG_DATA_OWN;
#endif
retroarch_ctl(RARCH_CTL_MAIN_DEINIT, NULL);
@ -5431,7 +5431,7 @@ bool retroarch_main_init(int argc, char *argv[])
if ( !global->launched_from_cli
|| global->cli_load_menu_on_error
#ifdef HAVE_MENU
|| menu_st->alive
|| (menu_st->flags & MENU_ST_FLAG_ALIVE)
#endif
)
#endif

View file

@ -1914,7 +1914,7 @@ bool runloop_environment_cb(unsigned cmd, void *data)
{
const char *content_path = path_get(RARCH_PATH_CONTENT);
menu_st->pending_env_shutdown_flush = true;
menu_st->flags |= MENU_ST_FLAG_PENDING_ENV_SHUTDOWN_FLUSH;
if (!string_is_empty(content_path))
strlcpy(menu_st->pending_env_shutdown_content_path,
content_path,
@ -3133,7 +3133,7 @@ bool runloop_environment_cb(unsigned cmd, void *data)
#endif
#ifdef HAVE_MENU
menu_opened = menu_state_get_ptr()->alive;
menu_opened = menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE;
if (menu_opened)
#ifdef HAVE_NETWORKING
core_paused = settings->bools.menu_pause_libretro &&
@ -6313,7 +6313,7 @@ void runloop_msg_queue_push(const char *msg,
prio,
flush,
#ifdef HAVE_MENU
menu_state_get_ptr()->alive
menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE
#else
false
#endif
@ -6441,8 +6441,9 @@ static enum runloop_state_enum runloop_check_state(
struct menu_state *menu_st = menu_state_get_ptr();
menu_handle_t *menu = menu_st->driver_data;
unsigned menu_toggle_gamepad_combo = settings->uints.input_menu_toggle_gamepad_combo;
bool menu_driver_binding_state = menu_st->is_binding;
bool menu_is_alive = menu_st->alive;
bool menu_driver_binding_state = menu_st->flags &
MENU_ST_FLAG_IS_BINDING;
bool menu_is_alive = menu_st->flags & MENU_ST_FLAG_ALIVE;
bool display_kb = menu_input_dialog_get_display_kb();
#endif
#if defined(HAVE_GFX_WIDGETS)
@ -6866,16 +6867,16 @@ static enum runloop_state_enum runloop_check_state(
}
/* Check whether menu screensaver should be enabled */
if ((screensaver_timeout > 0) &&
menu_st->screensaver_supported &&
!menu_st->screensaver_active &&
((menu_st->current_time_us - menu_st->input_last_time_us) >
if ( (screensaver_timeout > 0)
&& (menu_st->flags & MENU_ST_FLAG_SCREENSAVER_SUPPORTED)
&& (!(menu_st->flags & MENU_ST_FLAG_SCREENSAVER_ACTIVE))
&& ((menu_st->current_time_us - menu_st->input_last_time_us) >
((retro_time_t)screensaver_timeout * 1000000)))
{
menu_ctx_environment_t menu_environ;
menu_environ.type = MENU_ENVIRON_ENABLE_SCREENSAVER;
menu_environ.data = NULL;
menu_st->screensaver_active = true;
menu_st->flags |= MENU_ST_FLAG_SCREENSAVER_ACTIVE;
menu_driver_ctl(RARCH_MENU_CTL_ENVIRONMENT, &menu_environ);
}
@ -6884,7 +6885,7 @@ static enum runloop_state_enum runloop_check_state(
/* If the user had requested that the Quick Menu
* be spawned during the previous frame, do this now
* and exit the function to go to the next frame. */
if (menu_st->pending_quick_menu)
if (menu_st->flags & MENU_ST_FLAG_PENDING_QUICK_MENU)
{
menu_ctx_list_t list_info;
@ -6901,7 +6902,7 @@ static enum runloop_state_enum runloop_check_state(
"", 0, 0, 0, ACTION_OK_DL_CONTENT_SETTINGS);
menu_st->selection_ptr = 0;
menu_st->pending_quick_menu = false;
menu_st->flags &= MENU_ST_FLAG_PENDING_QUICK_MENU;
}
else if (!menu_driver_iterate(
menu_st,
@ -6967,7 +6968,8 @@ static enum runloop_state_enum runloop_check_state(
runloop_st->idle);
}
if (menu_st->alive && !runloop_st->idle)
if ( (menu_st->flags & MENU_ST_FLAG_ALIVE)
&& !(runloop_st->idle))
if (display_menu_libretro(runloop_st, input_st,
settings->floats.slowmotion_ratio,
libretro_running, current_time))
@ -7023,7 +7025,7 @@ static enum runloop_state_enum runloop_check_state(
if (menu_st->kb_key_state[RETROK_F1] == 1)
{
if (menu_st->alive)
if (menu_st->flags & MENU_ST_FLAG_ALIVE)
{
if (rarch_is_initialized && !core_type_is_dummy)
{
@ -7037,7 +7039,7 @@ static enum runloop_state_enum runloop_check_state(
(pressed && !old_pressed)) ||
core_type_is_dummy)
{
if (menu_st->alive)
if (menu_st->flags & MENU_ST_FLAG_ALIVE)
{
if (rarch_is_initialized && !core_type_is_dummy)
retroarch_menu_running_finished(false);
@ -7099,7 +7101,7 @@ static enum runloop_state_enum runloop_check_state(
HOTKEY_CHECK(RARCH_MUTE, CMD_EVENT_AUDIO_MUTE_TOGGLE, true, NULL);
#ifdef HAVE_MENU
if (menu_st->alive)
if (menu_st->flags & MENU_ST_FLAG_ALIVE)
{
float fastforward_ratio = runloop_get_fastforward_ratio(settings,
&runloop_st->fastmotion_override.current);
@ -7618,7 +7620,8 @@ int runloop_iterate(void)
#else
bool menu_pause_libretro = settings->bools.menu_pause_libretro;
#endif
bool core_paused = runloop_st->paused || (menu_pause_libretro && menu_state_get_ptr()->alive);
bool core_paused = runloop_st->paused ||
(menu_pause_libretro && (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE));
#else
bool core_paused = runloop_st->paused;
#endif
@ -8131,7 +8134,7 @@ void runloop_task_msg_queue_push(
prio,
flush,
#ifdef HAVE_MENU
menu_st->alive
menu_st->flags & MENU_ST_FLAG_ALIVE
#else
false
#endif