Get rid of menu_setting_ctl

This commit is contained in:
twinaphex 2021-03-11 08:38:53 +01:00
parent 02c15dd4f5
commit 4d93ac3870
4 changed files with 46 additions and 105 deletions

View File

@ -19408,7 +19408,7 @@ static rarch_setting_t *menu_setting_new_internal(rarch_setting_info_t *list_inf
* Returns: settings list composed of all requested
* settings on success, otherwise NULL.
**/
static rarch_setting_t *menu_setting_new(void)
rarch_setting_t *menu_setting_new(void)
{
rarch_setting_t* list = NULL;
rarch_setting_info_t *list_info = (rarch_setting_info_t*)
@ -19430,75 +19430,6 @@ static rarch_setting_t *menu_setting_new(void)
return list;
}
bool menu_setting_ctl(enum menu_setting_ctl_state state, void *data)
{
uint64_t flags;
switch (state)
{
case MENU_SETTING_CTL_IS_OF_PATH_TYPE:
{
bool cbs_bound = false;
rarch_setting_t *setting = (rarch_setting_t*)data;
if (!setting)
return false;
flags = setting->flags;
if (setting->type != ST_ACTION)
return false;
if (!setting->change_handler)
return false;
cbs_bound = (setting->action_right != NULL);
cbs_bound = cbs_bound || setting->action_left;
cbs_bound = cbs_bound || setting->action_select;
if (!cbs_bound)
return false;
if (!(flags & SD_FLAG_BROWSER_ACTION))
return false;
}
break;
case MENU_SETTING_CTL_NEW:
{
rarch_setting_t **setting = (rarch_setting_t**)data;
if (!setting)
return false;
*setting = menu_setting_new();
}
break;
case MENU_SETTING_CTL_ACTION_RIGHT:
{
rarch_setting_t *setting = (rarch_setting_t*)data;
if (!setting)
return false;
if (setting->action_right)
{
int ret = setting->action_right(setting, 0, false);
menu_driver_ctl(
RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_PATH, NULL);
menu_driver_ctl(
RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_IMAGE, NULL);
if (ret == -1)
return false;
}
else
return false;
}
break;
case MENU_SETTING_CTL_NONE:
default:
break;
}
return true;
}
void video_driver_menu_settings(void **list_data, void *list_info_data,
void *group_data, void *subgroup_data, const char *parent_group)
{

View File

@ -29,14 +29,6 @@
RETRO_BEGIN_DECLS
enum menu_setting_ctl_state
{
MENU_SETTING_CTL_NONE = 0,
MENU_SETTING_CTL_NEW,
MENU_SETTING_CTL_IS_OF_PATH_TYPE,
MENU_SETTING_CTL_ACTION_RIGHT
};
enum setting_list_flags
{
SL_FLAG_MAIN_MENU = (1 << 0),
@ -98,10 +90,18 @@ enum setting_type menu_setting_get_browser_selection_type(
void setting_generic_handle_change(rarch_setting_t *setting);
void menu_setting_free(rarch_setting_t *setting);
/**
* menu_setting_new:
* @mask : Bitmask of settings to include.
*
* Request a list of settings based on @mask.
*
* Returns: settings list composed of all requested
* settings on success, otherwise NULL.
**/
rarch_setting_t *menu_setting_new(void);
bool menu_setting_ctl(
enum menu_setting_ctl_state state, void *data);
void menu_setting_free(rarch_setting_t *setting);
RETRO_END_DECLS

View File

@ -3205,20 +3205,10 @@ static bool menu_entries_init(
)
{
if (!(menu_st->entries.list = (menu_list_t*)menu_list_new(menu_driver_ctx)))
goto error;
menu_setting_ctl(MENU_SETTING_CTL_NEW, &menu_st->entries.list_settings);
if (!menu_st->entries.list_settings)
goto error;
return false;
if (!(menu_st->entries.list_settings = menu_setting_new()))
return false;
return true;
error:
menu_entries_settings_deinit(menu_st);
menu_entries_list_deinit(menu_driver_ctx, menu_st);
return false;
}
void menu_entries_append(
@ -3816,9 +3806,14 @@ static void bundle_decompressed(retro_task_t *task,
*
* Returns: menu handle on success, otherwise NULL.
**/
static bool menu_init(struct rarch_state *p_rarch)
static bool menu_init(
struct menu_state *menu_st,
const menu_ctx_driver_t *menu_driver_ctx,
menu_input_t *menu_input,
menu_input_pointer_hw_state_t *pointer_hw_state,
settings_t *settings
)
{
settings_t *settings = p_rarch->configuration_settings;
#ifdef HAVE_CONFIGFILE
bool menu_show_start_screen = settings->bools.menu_show_start_screen;
bool config_save_on_exit = settings->bools.config_save_on_exit;
@ -3826,10 +3821,14 @@ static bool menu_init(struct rarch_state *p_rarch)
/* Ensure that menu pointer input is correctly
* initialised */
menu_input_reset(p_rarch);
menu_input_reset(menu_input, pointer_hw_state);
if (!menu_entries_init(&p_rarch->menu_driver_state, p_rarch->menu_driver_ctx))
if (!menu_entries_init(menu_st, menu_driver_ctx))
{
menu_entries_settings_deinit(menu_st);
menu_entries_list_deinit(menu_driver_ctx, menu_st);
return false;
}
#ifdef HAVE_CONFIGFILE
if (menu_show_start_screen)
@ -4508,7 +4507,12 @@ static bool menu_driver_init_internal(
}
}
if (!p_rarch->menu_driver_data || !menu_init(p_rarch))
if (!p_rarch->menu_driver_data || !menu_init(
&p_rarch->menu_driver_state,
p_rarch->menu_driver_ctx,
&p_rarch->menu_input_state,
&p_rarch->menu_input_pointer_hw_state,
settings))
return false;
gfx_display_init();
@ -5225,7 +5229,10 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
for (i = 0; i < SCROLL_INDEX_SIZE; i++)
menu_st->scroll.index_list[i] = 0;
menu_input_reset(p_rarch);
menu_input_reset(
&p_rarch->menu_input_state,
&p_rarch->menu_input_pointer_hw_state
);
if ( p_rarch->menu_driver_ctx
&& p_rarch->menu_driver_ctx->free)
@ -24014,11 +24021,11 @@ void menu_input_set_pointer_y_accel(float y_accel)
menu_input->pointer.y_accel = y_accel;
}
static void menu_input_reset(struct rarch_state *p_rarch)
static void menu_input_reset(
menu_input_t *menu_input,
menu_input_pointer_hw_state_t *pointer_hw_state
)
{
menu_input_t *menu_input = &p_rarch->menu_input_state;
menu_input_pointer_hw_state_t *pointer_hw_state = &p_rarch->menu_input_pointer_hw_state;
memset(menu_input, 0, sizeof(menu_input_t));
memset(pointer_hw_state, 0, sizeof(menu_input_pointer_hw_state_t));
}

View File

@ -183,7 +183,10 @@ static int menu_input_post_iterate(
struct rarch_state *p_rarch,
unsigned action,
retro_time_t current_time);
static void menu_input_reset(struct rarch_state *p_rarch);
static void menu_input_reset(
menu_input_t *menu_input,
menu_input_pointer_hw_state_t *pointer_hw_state
);
#endif
static bool retroarch_apply_shader(