mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-23 19:54:39 +00:00
Move userdata to menu_driver.c as static variable
This commit is contained in:
parent
6ae5725373
commit
00b979ba67
@ -950,7 +950,7 @@ static void mui_layout(mui_handle_t *mui)
|
||||
}
|
||||
}
|
||||
|
||||
static void *mui_init(void)
|
||||
static void *mui_init(void **userdata)
|
||||
{
|
||||
mui_handle_t *mui = NULL;
|
||||
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
||||
@ -966,11 +966,12 @@ static void *mui_init(void)
|
||||
if (!mui)
|
||||
goto error;
|
||||
|
||||
menu->userdata = mui;
|
||||
*userdata = mui;
|
||||
|
||||
mui_layout(mui);
|
||||
mui_allocate_white_texture(mui);
|
||||
|
||||
|
||||
return menu;
|
||||
error:
|
||||
if (menu)
|
||||
|
@ -626,7 +626,7 @@ static void rgui_render(void *data)
|
||||
rgui_blit_cursor();
|
||||
}
|
||||
|
||||
static void *rgui_init(void)
|
||||
static void *rgui_init(void **userdata)
|
||||
{
|
||||
size_t fb_pitch;
|
||||
unsigned fb_width, fb_height, new_font_height;
|
||||
@ -643,7 +643,7 @@ static void *rgui_init(void)
|
||||
if (!rgui)
|
||||
goto error;
|
||||
|
||||
menu->userdata = rgui;
|
||||
*userdata = rgui;
|
||||
|
||||
/* 4 extra lines to cache the checked background */
|
||||
fb_data = (uint16_t*)calloc(400 * (240 + 4), sizeof(uint16_t));
|
||||
|
@ -270,7 +270,7 @@ static void rmenu_context_reset(void)
|
||||
menu_texture_inited = false;
|
||||
}
|
||||
|
||||
static void *rmenu_init(void)
|
||||
static void *rmenu_init(void **userdata)
|
||||
{
|
||||
menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu));
|
||||
|
||||
@ -280,12 +280,14 @@ static void *rmenu_init(void)
|
||||
menu_texture = (struct texture_image*)calloc(1, sizeof(*menu_texture));
|
||||
|
||||
if (!menu_texture)
|
||||
{
|
||||
free(menu);
|
||||
return NULL;
|
||||
}
|
||||
goto error;
|
||||
|
||||
return menu;
|
||||
|
||||
error:
|
||||
if (menu)
|
||||
free(menu);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void rmenu_context_destroy(void *data)
|
||||
|
@ -266,7 +266,7 @@ cleanup:
|
||||
return hr;
|
||||
}
|
||||
|
||||
static void* rmenu_xui_init(void)
|
||||
static void* rmenu_xui_init(void **userdata)
|
||||
{
|
||||
HRESULT hr;
|
||||
d3d_video_t *d3d = NULL;
|
||||
|
@ -1890,7 +1890,7 @@ static void xmb_layout(xmb_handle_t *xmb)
|
||||
}
|
||||
}
|
||||
|
||||
static void *xmb_init(void)
|
||||
static void *xmb_init(void **userdata)
|
||||
{
|
||||
unsigned width, height;
|
||||
xmb_handle_t *xmb = NULL;
|
||||
@ -1909,7 +1909,7 @@ static void *xmb_init(void)
|
||||
if (!xmb)
|
||||
goto error;
|
||||
|
||||
menu->userdata = xmb;
|
||||
*userdata = xmb;
|
||||
|
||||
xmb->menu_stack_old = (file_list_t*)calloc(1, sizeof(file_list_t));
|
||||
|
||||
|
@ -1046,7 +1046,7 @@ static void zarch_frame(void *data)
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_UNSET_VIEWPORT, NULL);
|
||||
}
|
||||
|
||||
static void *zarch_init(void)
|
||||
static void *zarch_init(void **userdata)
|
||||
{
|
||||
int unused;
|
||||
zui_t *zui = NULL;
|
||||
@ -1064,7 +1064,7 @@ static void *zarch_init(void)
|
||||
if (!zui)
|
||||
goto error;
|
||||
|
||||
menu->userdata = zui;
|
||||
*userdata = zui;
|
||||
|
||||
if (settings->menu.mouse.enable)
|
||||
{
|
||||
|
@ -57,6 +57,7 @@ static const menu_ctx_driver_t *menu_ctx_drivers[] = {
|
||||
static menu_handle_t *menu_driver_data;
|
||||
static const menu_ctx_driver_t *menu_driver_ctx;
|
||||
static struct video_shader *menu_driver_shader;
|
||||
static void *menu_userdata;
|
||||
|
||||
/**
|
||||
* menu_driver_find_handle:
|
||||
@ -161,8 +162,7 @@ void menu_driver_list_insert(file_list_t *list, const char *path,
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver->list_insert)
|
||||
driver->list_insert(menu_driver_data ? menu_driver_data->userdata : NULL,
|
||||
list, path, label, idx);
|
||||
driver->list_insert(menu_userdata ? menu_userdata : NULL, list, path, label, idx);
|
||||
}
|
||||
|
||||
void menu_driver_list_free(file_list_t *list, size_t idx, size_t list_size)
|
||||
@ -181,7 +181,7 @@ void menu_driver_context_destroy(void)
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver && driver->context_destroy)
|
||||
driver->context_destroy(menu_driver_data ? menu_driver_data->userdata : NULL);
|
||||
driver->context_destroy(menu_userdata ? menu_userdata : NULL);
|
||||
}
|
||||
|
||||
void menu_driver_list_set_selection(file_list_t *list)
|
||||
@ -189,8 +189,7 @@ void menu_driver_list_set_selection(file_list_t *list)
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver && driver->list_set_selection)
|
||||
driver->list_set_selection(
|
||||
menu_driver_data ? menu_driver_data->userdata : NULL, list);
|
||||
driver->list_set_selection(menu_userdata ? menu_userdata : NULL, list);
|
||||
}
|
||||
|
||||
size_t menu_driver_list_get_selection(void)
|
||||
@ -198,8 +197,7 @@ size_t menu_driver_list_get_selection(void)
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver && driver->list_get_selection)
|
||||
return driver->list_get_selection(menu_driver_data
|
||||
? menu_driver_data->userdata : NULL);
|
||||
return driver->list_get_selection(menu_userdata ? menu_userdata : NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -208,8 +206,7 @@ bool menu_driver_list_push(menu_displaylist_info_t *info, unsigned type)
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver->list_push)
|
||||
if (driver->list_push(menu_driver_data,
|
||||
menu_driver_data ? menu_driver_data->userdata : NULL,
|
||||
if (driver->list_push(menu_driver_data, menu_userdata ? menu_userdata : NULL,
|
||||
info, type) == 0)
|
||||
return true;
|
||||
return false;
|
||||
@ -220,7 +217,7 @@ void menu_driver_list_cache(menu_list_type_t type, unsigned action)
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver->list_cache)
|
||||
driver->list_cache(menu_driver_data->userdata, type, action);
|
||||
driver->list_cache(menu_userdata ? menu_userdata : NULL, type, action);
|
||||
}
|
||||
|
||||
size_t menu_driver_list_get_size(menu_list_type_t type)
|
||||
@ -228,7 +225,7 @@ size_t menu_driver_list_get_size(menu_list_type_t type)
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver && driver->list_get_size)
|
||||
return driver->list_get_size(menu_driver_data->userdata, type);
|
||||
return driver->list_get_size(menu_userdata ? menu_userdata : NULL, type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -237,9 +234,7 @@ void *menu_driver_list_get_entry(menu_list_type_t type, unsigned i)
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver && driver->list_get_entry)
|
||||
return driver->list_get_entry(
|
||||
menu_driver_data ? menu_driver_data->userdata : NULL,
|
||||
type, i);
|
||||
return driver->list_get_entry(menu_userdata ? menu_userdata : NULL, type, i);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -248,7 +243,7 @@ void menu_driver_context_reset(void)
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver->context_reset)
|
||||
driver->context_reset(menu_driver_data ? menu_driver_data->userdata : NULL);
|
||||
driver->context_reset(menu_userdata ? menu_userdata : NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -272,14 +267,14 @@ void menu_driver_free(menu_handle_t *menu)
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver->free)
|
||||
driver->free(menu_driver_data ? menu_driver_data->userdata : NULL);
|
||||
driver->free(menu_userdata ? menu_userdata : NULL);
|
||||
|
||||
if (!menu_driver_data)
|
||||
return;
|
||||
|
||||
if (menu_driver_data->userdata)
|
||||
free(menu_driver_data->userdata);
|
||||
menu_driver_data->userdata = NULL;
|
||||
if (menu_userdata)
|
||||
free(menu_userdata);
|
||||
menu_userdata = NULL;
|
||||
}
|
||||
|
||||
int menu_driver_iterate(enum menu_action action)
|
||||
@ -287,8 +282,8 @@ int menu_driver_iterate(enum menu_action action)
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver->iterate)
|
||||
return driver->iterate(menu_driver_data,
|
||||
menu_driver_data ? menu_driver_data->userdata : NULL, action);
|
||||
return driver->iterate(menu_driver_data,
|
||||
menu_userdata ? menu_userdata : NULL, action);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -303,8 +298,7 @@ static void menu_driver_toggle(bool latch)
|
||||
|
||||
if (menu_driver->toggle)
|
||||
menu_driver->toggle(
|
||||
menu_driver_data ? menu_driver_data->userdata : NULL,
|
||||
latch);
|
||||
menu_userdata ? menu_userdata : NULL, latch);
|
||||
|
||||
if (latch)
|
||||
menu_driver_ctl(RARCH_MENU_CTL_SET_ALIVE, NULL);
|
||||
@ -356,7 +350,7 @@ bool menu_driver_load_image(void *data, menu_image_type_t type)
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver->load_image)
|
||||
return driver->load_image(menu_driver_data->userdata, data, type);
|
||||
return driver->load_image(menu_userdata ? menu_userdata : NULL, data, type);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -367,7 +361,7 @@ bool menu_environment_cb(menu_environ_cb_t type, void *data)
|
||||
|
||||
if (driver->environ_cb)
|
||||
{
|
||||
int ret = driver->environ_cb(type, data, menu_driver_data->userdata);
|
||||
int ret = driver->environ_cb(type, data, menu_userdata ? menu_userdata : NULL);
|
||||
if (ret == 0)
|
||||
return true;
|
||||
}
|
||||
@ -383,7 +377,7 @@ int menu_driver_pointer_tap(unsigned x, unsigned y, unsigned ptr,
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver->pointer_tap)
|
||||
ret = driver->pointer_tap(menu_driver_data->userdata, x, y, ptr, cbs, entry, action);
|
||||
ret = driver->pointer_tap(menu_userdata ? menu_userdata : NULL, x, y, ptr, cbs, entry, action);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -393,7 +387,7 @@ void menu_driver_navigation_clear(bool pending_push)
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver->navigation_clear)
|
||||
driver->navigation_clear(menu_driver_data ? menu_driver_data->userdata : NULL, pending_push);
|
||||
driver->navigation_clear(menu_userdata ? menu_userdata : NULL, pending_push);
|
||||
}
|
||||
|
||||
static void menu_environment_get(int *argc, char *argv[],
|
||||
@ -604,7 +598,7 @@ void *menu_init(const void *data)
|
||||
if (!menu_ctx)
|
||||
return NULL;
|
||||
|
||||
if (!(menu = (menu_handle_t*)menu_ctx->init()))
|
||||
if (!(menu = (menu_handle_t*)menu_ctx->init(&menu_userdata)))
|
||||
return NULL;
|
||||
|
||||
strlcpy(settings->menu.driver, menu_ctx->ident,
|
||||
@ -704,8 +698,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
memset(&menu_driver_system, 0, sizeof(struct retro_system_info));
|
||||
break;
|
||||
case RARCH_MENU_CTL_RENDER:
|
||||
menu_iterate_render(menu_driver_data,
|
||||
menu_driver_data ? menu_driver_data->userdata : NULL);
|
||||
menu_iterate_render(menu_driver_data, menu_userdata);
|
||||
break;
|
||||
case RARCH_MENU_CTL_SHADER_DEINIT:
|
||||
#ifdef HAVE_SHADER_MANAGER
|
||||
@ -726,7 +719,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
if (!menu_driver_alive)
|
||||
return false;
|
||||
if (driver->frame)
|
||||
driver->frame(menu_driver_data->userdata);
|
||||
driver->frame(menu_userdata);
|
||||
break;
|
||||
case RARCH_MENU_CTL_SET_PREVENT_POPULATE:
|
||||
menu_driver_prevent_populate = true;
|
||||
@ -788,11 +781,11 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
break;
|
||||
case RARCH_MENU_CTL_NAVIGATION_INCREMENT:
|
||||
if (driver->navigation_increment)
|
||||
driver->navigation_increment(menu_driver_data ? menu_driver_data->userdata : NULL);
|
||||
driver->navigation_increment(menu_userdata);
|
||||
break;
|
||||
case RARCH_MENU_CTL_NAVIGATION_DECREMENT:
|
||||
if (driver->navigation_decrement)
|
||||
driver->navigation_decrement(menu_driver_data ? menu_driver_data->userdata : NULL);
|
||||
driver->navigation_decrement(menu_userdata);
|
||||
break;
|
||||
case RARCH_MENU_CTL_NAVIGATION_SET:
|
||||
{
|
||||
@ -801,13 +794,12 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
if (!scroll)
|
||||
return false;
|
||||
if (driver->navigation_set)
|
||||
driver->navigation_set(menu_driver_data ? menu_driver_data->userdata : NULL,
|
||||
*scroll);
|
||||
driver->navigation_set(menu_userdata, *scroll);
|
||||
}
|
||||
return true;
|
||||
case RARCH_MENU_CTL_NAVIGATION_SET_LAST:
|
||||
if (driver->navigation_set_last)
|
||||
driver->navigation_set_last(menu_driver_data ? menu_driver_data->userdata : NULL);
|
||||
driver->navigation_set_last(menu_userdata);
|
||||
break;
|
||||
case RARCH_MENU_CTL_NAVIGATION_ASCEND_ALPHABET:
|
||||
{
|
||||
@ -817,9 +809,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
return false;
|
||||
|
||||
if (driver->navigation_ascend_alphabet)
|
||||
driver->navigation_ascend_alphabet(
|
||||
menu_driver_data ? menu_driver_data->userdata : NULL,
|
||||
ptr_out);
|
||||
driver->navigation_ascend_alphabet(menu_userdata, ptr_out);
|
||||
}
|
||||
case RARCH_MENU_CTL_NAVIGATION_DESCEND_ALPHABET:
|
||||
{
|
||||
@ -829,9 +819,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
return false;
|
||||
|
||||
if (driver->navigation_descend_alphabet)
|
||||
driver->navigation_descend_alphabet(
|
||||
menu_driver_data ? menu_driver_data->userdata : NULL,
|
||||
ptr_out);
|
||||
driver->navigation_descend_alphabet(menu_userdata, ptr_out);
|
||||
}
|
||||
break;
|
||||
case RARCH_MENU_CTL_POPULATE_ENTRIES:
|
||||
@ -842,8 +830,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
return false;
|
||||
if (driver->populate_entries)
|
||||
driver->populate_entries(
|
||||
menu_driver_data ? menu_driver_data->userdata : NULL,
|
||||
info->path, info->label, info->type);
|
||||
menu_userdata, info->path, info->label, info->type);
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
|
@ -232,8 +232,6 @@ typedef enum
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *userdata;
|
||||
|
||||
bool push_help_screen;
|
||||
unsigned help_screen_id;
|
||||
menu_help_type_t help_screen_type;
|
||||
@ -264,7 +262,7 @@ typedef struct menu_ctx_driver
|
||||
int (*iterate)(void *data, void *userdata, enum menu_action action);
|
||||
void (*render)(void *data);
|
||||
void (*frame)(void *data);
|
||||
void* (*init)(void);
|
||||
void* (*init)(void**);
|
||||
void (*free)(void*);
|
||||
void (*context_reset)(void *data);
|
||||
void (*context_destroy)(void *data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user