mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
Pass more userdata handles to callbacks
This commit is contained in:
parent
4836fb06ba
commit
adc359ec7a
@ -1063,11 +1063,10 @@ static float mui_get_scroll(mui_handle_t *mui)
|
||||
return ((selection + 2 - half) * mui->line_height);
|
||||
}
|
||||
|
||||
static void mui_navigation_set(bool scroll)
|
||||
static void mui_navigation_set(void *data, bool scroll)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
mui_handle_t *mui = menu ? (mui_handle_t*)menu->userdata : NULL;
|
||||
float scroll_pos = mui_get_scroll(mui);
|
||||
mui_handle_t *mui = (mui_handle_t*)data;
|
||||
float scroll_pos = mui ? mui_get_scroll(mui) : 0.0f;
|
||||
|
||||
if (!mui || !scroll)
|
||||
return;
|
||||
@ -1076,9 +1075,9 @@ static void mui_navigation_set(bool scroll)
|
||||
&mui->scroll_y, EASING_IN_OUT_QUAD, -1, NULL);
|
||||
}
|
||||
|
||||
static void mui_list_set_selection(file_list_t *list)
|
||||
static void mui_list_set_selection(void *data, file_list_t *list)
|
||||
{
|
||||
mui_navigation_set(true);
|
||||
mui_navigation_set(data, true);
|
||||
}
|
||||
|
||||
static void mui_navigation_clear(void *data, bool pending_push)
|
||||
@ -1091,14 +1090,14 @@ static void mui_navigation_clear(void *data, bool pending_push)
|
||||
mui->scroll_y = 0;
|
||||
}
|
||||
|
||||
static void mui_navigation_set_last(void)
|
||||
static void mui_navigation_set_last(void *data)
|
||||
{
|
||||
mui_navigation_set(true);
|
||||
mui_navigation_set(data, true);
|
||||
}
|
||||
|
||||
static void mui_navigation_alphabet(size_t *unused)
|
||||
static void mui_navigation_alphabet(void *data, size_t *unused)
|
||||
{
|
||||
mui_navigation_set(true);
|
||||
mui_navigation_set(data, true);
|
||||
}
|
||||
|
||||
static void mui_populate_entries(
|
||||
|
@ -743,7 +743,7 @@ static void rgui_navigation_clear(void *data, bool pending_push)
|
||||
rgui->scroll_y = 0;
|
||||
}
|
||||
|
||||
static void rgui_navigation_set(bool scroll)
|
||||
static void rgui_navigation_set(void *data, bool scroll)
|
||||
{
|
||||
size_t selection;
|
||||
unsigned fb_width, fb_height;
|
||||
@ -765,26 +765,26 @@ static void rgui_navigation_set(bool scroll)
|
||||
menu_entries_set_start(end - RGUI_TERM_HEIGHT(fb_width, fb_height));
|
||||
}
|
||||
|
||||
static void rgui_navigation_set_last(void)
|
||||
static void rgui_navigation_set_last(void *data)
|
||||
{
|
||||
rgui_navigation_set(true);
|
||||
rgui_navigation_set(data, true);
|
||||
}
|
||||
|
||||
static void rgui_navigation_descend_alphabet(size_t *unused)
|
||||
static void rgui_navigation_descend_alphabet(void *data, size_t *unused)
|
||||
{
|
||||
rgui_navigation_set(true);
|
||||
rgui_navigation_set(data, true);
|
||||
}
|
||||
|
||||
static void rgui_navigation_ascend_alphabet(size_t *unused)
|
||||
static void rgui_navigation_ascend_alphabet(void *data, size_t *unused)
|
||||
{
|
||||
rgui_navigation_set(true);
|
||||
rgui_navigation_set(data, true);
|
||||
}
|
||||
|
||||
static void rgui_populate_entries(void *data,
|
||||
const char *path,
|
||||
const char *label, unsigned k)
|
||||
{
|
||||
rgui_navigation_set(true);
|
||||
rgui_navigation_set(data, true);
|
||||
}
|
||||
|
||||
static int rgui_environ(menu_environ_cb_t type, void *data, void *userdata)
|
||||
|
@ -625,7 +625,7 @@ static void rmenu_xui_navigation_clear(void *data, bool pending_push)
|
||||
XuiListSetCurSelVisible(m_menulist, selection);
|
||||
}
|
||||
|
||||
static void rmenu_xui_navigation_set_visible(void)
|
||||
static void rmenu_xui_navigation_set_visible(void *data)
|
||||
{
|
||||
size_t selection;
|
||||
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
|
||||
@ -634,7 +634,7 @@ static void rmenu_xui_navigation_set_visible(void)
|
||||
XuiListSetCurSelVisible(m_menulist, selection);
|
||||
}
|
||||
|
||||
static void rmenu_xui_navigation_alphabet(size_t *ptr_out)
|
||||
static void rmenu_xui_navigation_alphabet(void *data, size_t *ptr_out)
|
||||
{
|
||||
XuiListSetCurSelVisible(m_menulist, *ptr_out);
|
||||
}
|
||||
@ -668,7 +668,7 @@ static void rmenu_xui_list_clear(file_list_t *list)
|
||||
XuiListDeleteItems(m_menulist, 0, XuiListGetItemCount(m_menulist));
|
||||
}
|
||||
|
||||
static void rmenu_xui_list_set_selection(file_list_t *list)
|
||||
static void rmenu_xui_list_set_selection(void *data, file_list_t *list)
|
||||
{
|
||||
if (list)
|
||||
XuiListSetCurSel(m_menulist, file_list_get_directory_ptr(list));
|
||||
|
@ -2232,24 +2232,21 @@ static void xmb_navigation_clear(void *data, bool pending_push)
|
||||
xmb_selection_pointer_changed(xmb, true);
|
||||
}
|
||||
|
||||
static void xmb_navigation_pointer_changed(void)
|
||||
static void xmb_navigation_pointer_changed(void *data)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
xmb_handle_t *xmb = menu ? (xmb_handle_t*)menu->userdata : NULL;
|
||||
xmb_handle_t *xmb = (xmb_handle_t*)data;
|
||||
xmb_selection_pointer_changed(xmb, true);
|
||||
}
|
||||
|
||||
static void xmb_navigation_set(bool scroll)
|
||||
static void xmb_navigation_set(void *data, bool scroll)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
xmb_handle_t *xmb = menu ? (xmb_handle_t*)menu->userdata : NULL;
|
||||
xmb_handle_t *xmb = (xmb_handle_t*)data;
|
||||
xmb_selection_pointer_changed(xmb, true);
|
||||
}
|
||||
|
||||
static void xmb_navigation_alphabet(size_t *unused)
|
||||
static void xmb_navigation_alphabet(void *data, size_t *unused)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
xmb_handle_t *xmb = menu ? (xmb_handle_t*)menu->userdata : NULL;
|
||||
xmb_handle_t *xmb = (xmb_handle_t*)data;
|
||||
xmb_selection_pointer_changed(xmb, true);
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,8 @@ 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(list);
|
||||
driver->list_set_selection(
|
||||
menu_driver_data ? menu_driver_data->userdata : NULL, list);
|
||||
}
|
||||
|
||||
size_t menu_driver_list_get_selection(void)
|
||||
@ -773,6 +774,54 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
case RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT:
|
||||
menu_driver_load_no_content = false;
|
||||
break;
|
||||
case RARCH_MENU_CTL_NAVIGATION_INCREMENT:
|
||||
if (driver->navigation_increment)
|
||||
driver->navigation_increment(menu_driver_data ? menu_driver_data->userdata : NULL);
|
||||
break;
|
||||
case RARCH_MENU_CTL_NAVIGATION_DECREMENT:
|
||||
if (driver->navigation_decrement)
|
||||
driver->navigation_decrement(menu_driver_data ? menu_driver_data->userdata : NULL);
|
||||
break;
|
||||
case RARCH_MENU_CTL_NAVIGATION_SET:
|
||||
{
|
||||
bool *scroll = (bool*)data;
|
||||
|
||||
if (!scroll)
|
||||
return false;
|
||||
if (driver->navigation_set)
|
||||
driver->navigation_set(menu_driver_data ? menu_driver_data->userdata : NULL,
|
||||
*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);
|
||||
break;
|
||||
case RARCH_MENU_CTL_NAVIGATION_ASCEND_ALPHABET:
|
||||
{
|
||||
size_t *ptr_out = (size_t*)data;
|
||||
|
||||
if (!ptr_out)
|
||||
return false;
|
||||
|
||||
if (driver->navigation_ascend_alphabet)
|
||||
driver->navigation_ascend_alphabet(
|
||||
menu_driver_data ? menu_driver_data->userdata : NULL,
|
||||
ptr_out);
|
||||
}
|
||||
case RARCH_MENU_CTL_NAVIGATION_DESCEND_ALPHABET:
|
||||
{
|
||||
size_t *ptr_out = (size_t*)data;
|
||||
|
||||
if (!ptr_out)
|
||||
return false;
|
||||
|
||||
if (driver->navigation_descend_alphabet)
|
||||
driver->navigation_descend_alphabet(
|
||||
menu_driver_data ? menu_driver_data->userdata : NULL,
|
||||
ptr_out);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case RARCH_MENU_CTL_NONE:
|
||||
break;
|
||||
|
@ -90,6 +90,12 @@ typedef enum
|
||||
enum rarch_menu_ctl_state
|
||||
{
|
||||
RARCH_MENU_CTL_NONE = 0,
|
||||
RARCH_MENU_CTL_NAVIGATION_INCREMENT,
|
||||
RARCH_MENU_CTL_NAVIGATION_DECREMENT,
|
||||
RARCH_MENU_CTL_NAVIGATION_SET,
|
||||
RARCH_MENU_CTL_NAVIGATION_SET_LAST,
|
||||
RARCH_MENU_CTL_NAVIGATION_ASCEND_ALPHABET,
|
||||
RARCH_MENU_CTL_NAVIGATION_DESCEND_ALPHABET,
|
||||
RARCH_MENU_CTL_DEINIT,
|
||||
RARCH_MENU_CTL_SHADER_DEINIT,
|
||||
RARCH_MENU_CTL_SHADER_GET,
|
||||
@ -266,12 +272,12 @@ typedef struct menu_ctx_driver
|
||||
unsigned k);
|
||||
void (*toggle)(void *userdata, bool);
|
||||
void (*navigation_clear)(void *, bool);
|
||||
void (*navigation_decrement)(void);
|
||||
void (*navigation_increment)(void);
|
||||
void (*navigation_set)(bool);
|
||||
void (*navigation_set_last)(void);
|
||||
void (*navigation_descend_alphabet)(size_t *);
|
||||
void (*navigation_ascend_alphabet)(size_t *);
|
||||
void (*navigation_decrement)(void *data);
|
||||
void (*navigation_increment)(void *data);
|
||||
void (*navigation_set)(void *data, bool);
|
||||
void (*navigation_set_last)(void *data);
|
||||
void (*navigation_descend_alphabet)(void *, size_t *);
|
||||
void (*navigation_ascend_alphabet)(void *, size_t *);
|
||||
bool (*lists_init)(void*);
|
||||
void (*list_insert)(void *userdata,
|
||||
file_list_t *list, const char *, const char *, size_t);
|
||||
@ -282,7 +288,7 @@ typedef struct menu_ctx_driver
|
||||
size_t(*list_get_selection)(void *data);
|
||||
size_t(*list_get_size)(void *data, menu_list_type_t type);
|
||||
void *(*list_get_entry)(void *data, menu_list_type_t type, unsigned i);
|
||||
void (*list_set_selection)(file_list_t *list);
|
||||
void (*list_set_selection)(void *data, file_list_t *list);
|
||||
int (*bind_init)(menu_file_list_cbs_t *cbs,
|
||||
const char *path, const char *label, unsigned type, size_t idx,
|
||||
const char *elem0, const char *elem1,
|
||||
|
@ -51,7 +51,6 @@ typedef struct menu_navigation
|
||||
bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
|
||||
{
|
||||
static menu_navigation_t menu_navigation_state;
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
size_t menu_list_size = menu_entries_get_size();
|
||||
menu_navigation_t *nav = &menu_navigation_state;
|
||||
@ -113,8 +112,8 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (driver->navigation_increment)
|
||||
driver->navigation_increment();
|
||||
|
||||
menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_INCREMENT, NULL);
|
||||
}
|
||||
return true;
|
||||
case MENU_NAVIGATION_CTL_DECREMENT:
|
||||
@ -141,30 +140,18 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_DECREMENT, NULL);
|
||||
|
||||
if (driver->navigation_decrement)
|
||||
driver->navigation_decrement();
|
||||
menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_DECREMENT, NULL);
|
||||
|
||||
}
|
||||
return true;
|
||||
case MENU_NAVIGATION_CTL_SET:
|
||||
{
|
||||
bool *scroll = (bool*)data;
|
||||
|
||||
if (!scroll)
|
||||
return false;
|
||||
|
||||
if (driver->navigation_set)
|
||||
driver->navigation_set(*scroll);
|
||||
}
|
||||
menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_SET, data);
|
||||
return true;
|
||||
case MENU_NAVIGATION_CTL_SET_LAST:
|
||||
{
|
||||
size_t new_selection = menu_list_size - 1;
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &new_selection);
|
||||
|
||||
if (driver->navigation_set_last)
|
||||
driver->navigation_set_last();
|
||||
menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_SET_LAST, NULL);
|
||||
}
|
||||
return true;
|
||||
case MENU_NAVIGATION_CTL_ASCEND_ALPHABET:
|
||||
@ -185,8 +172,7 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
|
||||
i++;
|
||||
*ptr_out = nav->scroll.indices.list[i + 1];
|
||||
|
||||
if (driver->navigation_ascend_alphabet)
|
||||
driver->navigation_ascend_alphabet(ptr_out);
|
||||
menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_ASCEND_ALPHABET, ptr_out);
|
||||
}
|
||||
return true;
|
||||
case MENU_NAVIGATION_CTL_DESCEND_ALPHABET:
|
||||
@ -208,8 +194,7 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
|
||||
i--;
|
||||
*ptr_out = nav->scroll.indices.list[i - 1];
|
||||
|
||||
if (driver->navigation_descend_alphabet)
|
||||
driver->navigation_descend_alphabet(ptr_out);
|
||||
menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_DESCEND_ALPHABET, ptr_out);
|
||||
}
|
||||
return true;
|
||||
case MENU_NAVIGATION_CTL_GET_SELECTION:
|
||||
|
Loading…
x
Reference in New Issue
Block a user