From 4d316878991949846adf2e787fbdf3671d9dacbf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 19:00:34 +0100 Subject: [PATCH] Create menu_driver_resolve to avoid having to pass state pointer around between functions --- driver.c | 8 +- gfx/d3d/d3d.cpp | 2 +- gfx/drivers/gl.c | 2 +- gfx/drivers/sdl2_gfx.c | 2 +- menu/drivers/glui.c | 88 ++++++++++----- menu/drivers/ios.c | 12 ++- menu/drivers/rgui.c | 107 ++++++++++-------- menu/drivers/rmenu.c | 30 ++++-- menu/drivers/rmenu_xui.cpp | 73 +++++++++---- menu/drivers/xmb.c | 215 +++++++++++++++++++++++++------------ menu/menu.c | 10 +- menu/menu_driver.c | 7 ++ menu/menu_driver.h | 60 ++++++----- menu/menu_entries.c | 4 +- menu/menu_entries_cbs.c | 52 ++++----- menu/menu_input.c | 8 +- menu/menu_list.c | 14 +-- menu/menu_navigation.c | 14 +-- retroarch.c | 8 +- 19 files changed, 451 insertions(+), 265 deletions(-) diff --git a/driver.c b/driver.c index 77ca46144e..6e978c4a9f 100644 --- a/driver.c +++ b/driver.c @@ -335,8 +335,8 @@ void init_drivers(int flags) { init_menu(); - if (driver.menu && driver.menu_ctx && driver.menu_ctx->context_reset) - driver.menu_ctx->context_reset(driver.menu); + if (driver.menu_ctx && driver.menu_ctx->context_reset) + driver.menu_ctx->context_reset(); } #endif @@ -371,8 +371,8 @@ void uninit_drivers(int flags) #ifdef HAVE_MENU if (flags & DRIVER_MENU) { - if (driver.menu && driver.menu_ctx && driver.menu_ctx->context_destroy) - driver.menu_ctx->context_destroy(driver.menu); + if (driver.menu_ctx && driver.menu_ctx->context_destroy) + driver.menu_ctx->context_destroy(); if (!driver.menu_data_own) { diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index e5b9c90d0d..3ed18f9863 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1668,7 +1668,7 @@ static bool d3d_frame(void *data, const void *frame, #ifdef HAVE_MENU if (g_extern.is_menu && driver.menu_ctx && driver.menu_ctx->frame) - driver.menu_ctx->frame(driver.menu); + driver.menu_ctx->frame(); #ifdef _XBOX /* TODO - should be refactored. */ diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 9aa51de3af..2796957536 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1582,7 +1582,7 @@ static bool gl_frame(void *data, const void *frame, #if defined(HAVE_MENU) if (g_extern.is_menu && driver.menu_ctx && driver.menu_ctx->frame) - driver.menu_ctx->frame(driver.menu); + driver.menu_ctx->frame(); if (gl->menu_texture_enable) gl_draw_texture(gl); diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 4503da928a..bb2d83b1fc 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -500,7 +500,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, #ifdef HAVE_MENU if (g_extern.is_menu && driver.menu_ctx && driver.menu_ctx->frame) - driver.menu_ctx->frame(driver.menu); + driver.menu_ctx->frame(); #endif if (vid->menu.active) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 5e365cd347..1eebcbf770 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -48,12 +48,17 @@ typedef struct glui_handle } textures; } glui_handle_t; -static int glui_entry_iterate(menu_handle_t *menu, unsigned action) +static int glui_entry_iterate(unsigned action) { const char *label = NULL; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr); + menu_file_list_cbs_t *cbs = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + + cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( + menu->menu_list->selection_buf, menu->selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -197,11 +202,15 @@ static void glui_draw_cursor(gl_t *gl, glui_handle_t *glui, float x, float y) gl->coords.color = gl->white_color_ptr; } -static void glui_get_message(menu_handle_t *menu, const char *message) +static void glui_get_message(const char *message) { glui_handle_t *glui = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || !message || !*message) + if (!menu) + return; + + if (!message || !*message) return; glui = (glui_handle_t*)menu->userdata; @@ -210,15 +219,21 @@ static void glui_get_message(menu_handle_t *menu, const char *message) strlcpy(glui->box_message, message, sizeof(glui->box_message)); } -static void glui_render_messagebox(menu_handle_t *menu, const char *message) +static void glui_render_messagebox(const char *message) { unsigned i; int x, y; struct string_list *list = NULL; glui_handle_t *glui = NULL; - gl_t *gl = (gl_t*)video_driver_resolve(NULL); + gl_t *gl = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || !gl) + if (!menu) + return; + + gl = (gl_t*)video_driver_resolve(NULL); + + if (!gl) return; glui = (glui_handle_t*)menu->userdata; @@ -248,7 +263,7 @@ end: string_list_free(list); } -static void glui_frame(menu_handle_t *menu) +static void glui_frame(void) { unsigned x, y; size_t i; @@ -259,12 +274,18 @@ static void glui_frame(menu_handle_t *menu) const char *label = NULL; unsigned menu_type = 0; size_t end; - gl_t *gl = (gl_t*)video_driver_resolve(NULL); + gl_t *gl = NULL; glui_handle_t *glui = NULL; const char *core_name = NULL; const char *core_version = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || !gl) + if (!menu) + return; + + gl = (gl_t*)video_driver_resolve(NULL); + + if (!gl) return; glui = (glui_handle_t*)menu->userdata; @@ -401,7 +422,7 @@ static void glui_frame(menu_handle_t *menu) else message_queue = driver.current_msg; - glui_render_messagebox(menu, message_queue); + glui_render_messagebox(message_queue); #endif if (menu->keyboard.display) @@ -412,13 +433,13 @@ static void glui_frame(menu_handle_t *menu) str = ""; glui_render_background(gl, glui, true); snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str); - glui_render_messagebox(menu, msg); + glui_render_messagebox(msg); } if (glui->box_message[0] != '\0') { glui_render_background(gl, glui, true); - glui_render_messagebox(menu, glui->box_message); + glui_render_messagebox(glui->box_message); glui->box_message[0] = '\0'; } @@ -430,9 +451,9 @@ static void glui_frame(menu_handle_t *menu) static void *glui_init(void) { - menu_handle_t *menu; glui_handle_t *glui = NULL; const video_driver_t *video_driver = NULL; + menu_handle_t *menu = NULL; gl_t *gl = (gl_t*)video_driver_resolve(&video_driver); if (video_driver != &video_gl || !gl) @@ -474,9 +495,10 @@ static void glui_free(void *data) -static void glui_context_destroy(menu_handle_t *menu) +static void glui_context_destroy(void) { glui_handle_t *glui = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -490,9 +512,10 @@ static void glui_context_destroy(menu_handle_t *menu) glDeleteTextures(1, &glui->textures.bg.id); } -static bool glui_load_wallpaper(menu_handle_t *menu, const char *path) +static bool glui_load_wallpaper(const char *path) { glui_handle_t *glui = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return false; @@ -515,9 +538,10 @@ static bool glui_load_wallpaper(menu_handle_t *menu, const char *path) return true; } -static void glui_context_reset(menu_handle_t *menu) +static void glui_context_reset(void) { glui_handle_t *glui = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -539,18 +563,20 @@ static void glui_context_reset(menu_handle_t *menu) sizeof(glui->textures.bg.path)); if (path_file_exists(glui->textures.bg.path)) - glui_load_wallpaper(driver.menu, glui->textures.bg.path); + glui_load_wallpaper(glui->textures.bg.path); } -static void glui_navigation_clear(menu_handle_t *menu, bool pending_push) +static void glui_navigation_clear(bool pending_push) { + menu_handle_t *menu = menu_driver_resolve(); if (menu) menu->begin = 0; } -static void glui_navigation_set(menu_handle_t *menu, bool scroll) +static void glui_navigation_set(bool scroll) { glui_handle_t *glui = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -574,19 +600,25 @@ static void glui_navigation_set(menu_handle_t *menu, bool scroll) - glui->term_height; } -static void glui_navigation_set_last(menu_handle_t *menu) +static void glui_navigation_set_last(void) { - glui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + glui_navigation_set(true); } -static void glui_navigation_descend_alphabet(menu_handle_t *menu, size_t *unused) +static void glui_navigation_descend_alphabet(size_t *unused) { - glui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + glui_navigation_set(true); } -static void glui_navigation_ascend_alphabet(menu_handle_t *menu, size_t *unused) +static void glui_navigation_ascend_alphabet(size_t *unused) { - glui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + glui_navigation_set(true); } menu_ctx_driver_t menu_ctx_glui = { diff --git a/menu/drivers/ios.c b/menu/drivers/ios.c index 29a14202c4..d06a8ff50a 100644 --- a/menu/drivers/ios.c +++ b/menu/drivers/ios.c @@ -25,11 +25,17 @@ #include "ios.h" #include "../menu_input.h" -static int ios_entry_iterate(menu_handle_t *menu, unsigned action) +static int ios_entry_iterate(unsigned action) { - ios_handle_t *ios = (ios_handle_t*)menu->userdata; + ios_handle_t *ios = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (ios->switch_to_ios) + if (!menu) + return -1; + + ios = (ios_handle_t*)menu->userdata; + + if (ios && ios->switch_to_ios) ios->switch_to_ios(); return 0; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 31a95819f7..84606c315e 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -34,16 +34,19 @@ #define RGUI_TERM_WIDTH (((menu->frame_buf.width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE))) #define RGUI_TERM_HEIGHT (((menu->frame_buf.height - RGUI_TERM_START_Y - RGUI_TERM_START_X) / (FONT_HEIGHT_STRIDE)) - 1) -static int rgui_entry_iterate(menu_handle_t *menu, unsigned action) +static int rgui_entry_iterate(unsigned action) { const char *label = NULL; + menu_file_list_cbs_t *cbs = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || !menu->menu_list) + if (!menu) + return -1; + if (!menu->menu_list) return -1; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr); + cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( + menu->menu_list->selection_buf, menu->selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -107,19 +110,19 @@ static uint16_t green_filler(unsigned x, unsigned y) #endif } -static void fill_rect(menu_handle_t *menu, +static void fill_rect(menu_framebuf_t *frame_buf, unsigned x, unsigned y, unsigned width, unsigned height, uint16_t (*col)(unsigned x, unsigned y)) { unsigned i, j; - if (!menu->frame_buf.data || !col) + if (!frame_buf->data || !col) return; for (j = y; j < y + height; j++) for (i = x; i < x + width; i++) - menu->frame_buf.data[j * (menu->frame_buf.pitch >> 1) + i] = col(i, j); + frame_buf->data[j * (frame_buf->pitch >> 1) + i] = col(i, j); } static void color_rect(menu_handle_t *menu, @@ -195,13 +198,14 @@ static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf) return true; } -static bool rguidisp_init_font(void *data) +static bool rguidisp_init_font(menu_handle_t *menu) { - menu_handle_t *menu = (menu_handle_t*)data; - const uint8_t *font_bmp_buf = NULL; const uint8_t *font_bin_buf = bitmap_bin; + if (!menu) + return false; + if (font_bmp_buf) return init_font(menu, font_bmp_buf); @@ -213,29 +217,33 @@ static bool rguidisp_init_font(void *data) return true; } -static void rgui_render_background(menu_handle_t *menu) +static void rgui_render_background(void) { + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; - fill_rect(menu, 0, 0, menu->frame_buf.width, menu->frame_buf.height, gray_filler); - fill_rect(menu, 5, 5, menu->frame_buf.width - 10, 5, green_filler); - fill_rect(menu, 5, menu->frame_buf.height - 10, menu->frame_buf.width - 10, 5, + fill_rect(&menu->frame_buf, 0, 0, menu->frame_buf.width, menu->frame_buf.height, gray_filler); + fill_rect(&menu->frame_buf, 5, 5, menu->frame_buf.width - 10, 5, green_filler); + fill_rect(&menu->frame_buf, 5, menu->frame_buf.height - 10, menu->frame_buf.width - 10, 5, green_filler); - fill_rect(menu, 5, 5, 5, menu->frame_buf.height - 10, green_filler); - fill_rect(menu, menu->frame_buf.width - 10, 5, 5, menu->frame_buf.height - 10, + fill_rect(&menu->frame_buf, 5, 5, 5, menu->frame_buf.height - 10, green_filler); + fill_rect(&menu->frame_buf, menu->frame_buf.width - 10, 5, 5, menu->frame_buf.height - 10, green_filler); } -static void rgui_render_messagebox(menu_handle_t *menu, const char *message) +static void rgui_render_messagebox(const char *message) { size_t i; int x, y; unsigned width, glyphs_width, height; struct string_list *list = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || !message || !*message) + if (!menu) + return; + if (!message || !*message) return; list = string_split(message, "\n"); @@ -271,11 +279,11 @@ static void rgui_render_messagebox(menu_handle_t *menu, const char *message) x = (menu->frame_buf.width - width) / 2; y = (menu->frame_buf.height - height) / 2; - fill_rect(menu, x + 5, y + 5, width - 10, height - 10, gray_filler); - fill_rect(menu, x, y, width - 5, 5, green_filler); - fill_rect(menu, x + width - 5, y, 5, height - 5, green_filler); - fill_rect(menu, x + 5, y + height - 5, width - 5, 5, green_filler); - fill_rect(menu, x, y + 5, 5, height - 5, green_filler); + fill_rect(&menu->frame_buf, x + 5, y + 5, width - 10, height - 10, gray_filler); + fill_rect(&menu->frame_buf, x, y, width - 5, 5, green_filler); + fill_rect(&menu->frame_buf, x + width - 5, y, 5, height - 5, green_filler); + fill_rect(&menu->frame_buf, x + 5, y + height - 5, width - 5, 5, green_filler); + fill_rect(&menu->frame_buf, x, y + 5, 5, height - 5, green_filler); for (i = 0; i < list->size; i++) { @@ -298,7 +306,7 @@ static void rgui_blit_cursor(menu_handle_t *menu) color_rect(menu, x - 5, y, 11, 1, 0xFFFF); } -static void rgui_render(menu_handle_t *menu) +static void rgui_render(void) { size_t i, end; char title[256], title_buf[256], title_msg[64]; @@ -308,10 +316,12 @@ static void rgui_render(menu_handle_t *menu) const char *label = NULL; const char *core_name = NULL; const char *core_version = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || (menu->need_refresh - && g_extern.is_menu - && !menu->msg_force)) + if (!menu) + return; + if (menu->need_refresh && g_extern.is_menu + && !menu->msg_force) return; menu->mouse.ptr = menu->mouse.y / 11 - 2 + menu->begin; @@ -332,7 +342,7 @@ static void rgui_render(menu_handle_t *menu) menu->begin + RGUI_TERM_HEIGHT : menu_list_get_size(menu->menu_list); - rgui_render_background(menu); + rgui_render_background(); menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type); @@ -440,7 +450,7 @@ static void rgui_render(menu_handle_t *menu) else message_queue = driver.current_msg; - rgui_render_messagebox(menu, message_queue); + rgui_render_messagebox( message_queue); #endif if (menu->keyboard.display) @@ -450,7 +460,7 @@ static void rgui_render(menu_handle_t *menu) if (!str) str = ""; snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str); - rgui_render_messagebox(menu, msg); + rgui_render_messagebox(msg); } if (menu->mouse.enable) @@ -512,10 +522,12 @@ static void rgui_free(void *data) free((uint8_t*)menu->font); } -static void rgui_set_texture(menu_handle_t *menu) +static void rgui_set_texture(void) { + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; + if (!driver.video_data) return; if (!driver.video_poke) @@ -527,16 +539,19 @@ static void rgui_set_texture(menu_handle_t *menu) menu->frame_buf.data, false, menu->frame_buf.width, menu->frame_buf.height, 1.0f); } -static void rgui_navigation_clear(menu_handle_t *menu, bool pending_push) +static void rgui_navigation_clear(bool pending_push) { + menu_handle_t *menu = menu_driver_resolve(); if (menu) menu->begin = 0; } -static void rgui_navigation_set(menu_handle_t *menu, bool scroll) +static void rgui_navigation_set(bool scroll) { + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; + if (!scroll) return; @@ -552,25 +567,33 @@ static void rgui_navigation_set(menu_handle_t *menu, bool scroll) - RGUI_TERM_HEIGHT; } -static void rgui_navigation_set_last(menu_handle_t *menu) +static void rgui_navigation_set_last(void) { - rgui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + rgui_navigation_set(true); } -static void rgui_navigation_descend_alphabet(menu_handle_t *menu, size_t *unused) +static void rgui_navigation_descend_alphabet(size_t *unused) { - rgui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + rgui_navigation_set(true); } -static void rgui_navigation_ascend_alphabet(menu_handle_t *menu, size_t *unused) +static void rgui_navigation_ascend_alphabet(size_t *unused) { - rgui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + rgui_navigation_set(true); } -static void rgui_populate_entries(menu_handle_t *menu, const char *path, +static void rgui_populate_entries(const char *path, const char *label, unsigned k) { - rgui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + rgui_navigation_set(true); } menu_ctx_driver_t menu_ctx_rgui = { diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index ee27258954..e92c22bf43 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -64,12 +64,17 @@ struct texture_image *menu_texture; static bool render_normal = true; static bool menu_texture_inited =false; -static int rmenu_entry_iterate(menu_handle_t *menu, unsigned action) +static int rmenu_entry_iterate(unsigned action) { const char *label = NULL; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr); + menu_file_list_cbs_t *cbs = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( + menu->menu_list->selection_buf, menu->selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -83,11 +88,15 @@ static void rmenu_render_background(void) { } -static void rmenu_render_messagebox(menu_handle_t *menu, const char *message) +static void rmenu_render_messagebox(const char *message) { struct font_params font_parms; size_t i, j; struct string_list *list = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; if (!message || !*message) return; @@ -132,7 +141,7 @@ end: string_list_free(list); } -static void rmenu_render(menu_handle_t *menu) +static void rmenu_render(void) { size_t begin, end; size_t i, j; @@ -144,6 +153,7 @@ static void rmenu_render(menu_handle_t *menu) const char *core_name = NULL; const char *core_version = NULL; unsigned menu_type = 0; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -256,7 +266,7 @@ static void rmenu_render(menu_handle_t *menu) selected ? '>' : ' ', entry_title_buf); #if 0 - blit_line(menu, x, y, message, selected); + blit_line(x, y, message, selected); #endif font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET; font_parms.y = POSITION_EDGE_MIN + POSITION_RENDER_OFFSET @@ -278,8 +288,10 @@ static void rmenu_render(menu_handle_t *menu) } } -static void rmenu_set_texture(menu_handle_t *menu) +static void rmenu_set_texture(void) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return; if (menu_texture_inited) @@ -316,7 +328,7 @@ static void rmenu_wallpaper_set_defaults(char *menu_bg, size_t sizeof_menu_bg) static void rmenu_context_reset(void *data) { char menu_bg[PATH_MAX_LENGTH]; - menu_handle_t *menu = (menu_handle_t*)data; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index e71129ca29..7344c5620f 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -58,12 +58,17 @@ HXUIOBJ root_menu; HXUIOBJ current_menu; static msg_queue_t *xui_msg_queue; -static int rmenu_xui_entry_iterate(menu_handle_t *menu, unsigned action) +static int rmenu_xui_entry_iterate(unsigned action) { const char *label = NULL; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr); + menu_file_list_cbs_t *cbs = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + + cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( + menu->menu_list->selection_buf, menu->selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -406,14 +411,28 @@ end: string_list_free(list); } -static void rmenu_xui_frame(menu_handle_t *menu) +static void rmenu_xui_frame(void) { XUIMessage msg; XUIMessageRender msgRender; D3DXMATRIX matOrigView; D3DVIEWPORT vp_full; - d3d_video_t *d3d = (d3d_video_t*)driver.video_data; - LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; + LPDIRECT3DDEVICE d3dr; + d3d_video_t *d3d = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + d3d = (d3d_video_t*)driver.video_data; + + if (!d3d) + return; + + d3dr = (LPDIRECT3DDEVICE)d3d->dev; + + if (!d3dr) + return; (void)menu; @@ -464,7 +483,7 @@ static void rmenu_xui_render_background(void) XuiElementSetShow(m_background, TRUE); } -static void rmenu_xui_render_messagebox(menu_handle_t *menu, const char *message) +static void rmenu_xui_render_messagebox(const char *message) { msg_queue_clear(xui_msg_queue); msg_queue_push(xui_msg_queue, message, 2, 1); @@ -527,14 +546,17 @@ static void rmenu_xui_set_list_text(int index, const wchar_t* leftText, } } -static void rmenu_xui_render(menu_handle_t *menu) +static void rmenu_xui_render(void) { size_t end, i; char title[PATH_MAX_LENGTH]; const char *dir = NULL, *label = NULL; unsigned menu_type = 0; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || menu->need_refresh && + if (!menu) + return; + if (menu->need_refresh && g_extern.is_menu && !menu->msg_force) return; @@ -608,40 +630,46 @@ static void rmenu_xui_render(menu_handle_t *menu) if (!str) str = ""; snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str); - rmenu_xui_render_messagebox(menu, msg); + rmenu_xui_render_messagebox(msg); } } -static void rmenu_xui_populate_entries(menu_handle_t *menu, const char *path, +static void rmenu_xui_populate_entries(const char *path, const char *label, unsigned i) { - (void)menu; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + (void)label; (void)path; XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); } -static void rmenu_xui_navigation_clear(menu_handle_t *menu, bool pending_push) +static void rmenu_xui_navigation_clear(bool pending_push) { - (void)pending_push; + menu_handle_t *menu = menu_driver_resolve(); if (menu) XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); } -static void rmenu_xui_navigation_set_visible(menu_handle_t *menu) +static void rmenu_xui_navigation_set_visible(void) { - XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); + menu_handle_t *menu = menu_driver_resolve(); + + if (menu) + XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); } -static void rmenu_xui_navigation_alphabet(menu_handle_t *menu, size_t *ptr_out) +static void rmenu_xui_navigation_alphabet(size_t *ptr_out) { XuiListSetCurSelVisible(m_menulist, *ptr_out); } -static void rmenu_xui_list_insert(menu_handle_t *menu, - file_list_t *list, +static void rmenu_xui_list_insert(file_list_t *list, const char *path, const char *, size_t list_size) { wchar_t buf[PATH_MAX_LENGTH]; @@ -651,8 +679,7 @@ static void rmenu_xui_list_insert(menu_handle_t *menu, XuiListSetText(m_menulist, list_size, buf); } -static void rmenu_xui_list_delete(menu_handle_t *menu, - file_list_t *list, size_t idx, +static void rmenu_xui_list_delete(file_list_t *list, size_t idx, size_t list_size) { int x = XuiListGetItemCount( m_menulist ); @@ -665,7 +692,7 @@ static void rmenu_xui_list_delete(menu_handle_t *menu, XuiListDeleteItems(m_menulist, 0, list_size); } -static void rmenu_xui_list_clear(menu_handle_t *menu, file_list_t *list) +static void rmenu_xui_list_clear(file_list_t *list) { XuiListDeleteItems(m_menulist, 0, XuiListGetItemCount(m_menulist)); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 1cc8bf7d59..236f4e5511 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -234,10 +234,16 @@ static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current) return iy; } -static int xmb_entry_iterate(menu_handle_t *menu, unsigned action) +static int xmb_entry_iterate(unsigned action) { const char *label = NULL; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) + menu_file_list_cbs_t *cbs = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + + cbs = (menu_file_list_cbs_t*) menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, menu->selection_ptr); @@ -448,9 +454,10 @@ static void xmb_render_background(gl_t *gl, xmb_handle_t *xmb, gl->coords.color = gl->white_color_ptr; } -static void xmb_get_message(menu_handle_t *menu, const char *message) +static void xmb_get_message(const char *message) { xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -463,20 +470,26 @@ static void xmb_get_message(menu_handle_t *menu, const char *message) strlcpy(xmb->box_message, message, sizeof(xmb->box_message)); } -static void xmb_render_messagebox(menu_handle_t *menu, const char *message) +static void xmb_render_messagebox(const char *message) { int x, y; unsigned i; struct string_list *list = NULL; - gl_t *gl = (gl_t*)video_driver_resolve(NULL); + gl_t *gl = NULL; xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; - + xmb = (xmb_handle_t*)menu->userdata; - if (!gl || !xmb) + if (!xmb) + return; + + gl = (gl_t*)video_driver_resolve(NULL); + + if (!gl) return; list = string_split(message, "\n"); @@ -501,11 +514,17 @@ end: string_list_free(list); } -static void xmb_selection_pointer_changed(menu_handle_t *menu) +static void xmb_selection_pointer_changed(void) { int i; unsigned current, end; - xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata; + xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + xmb = (xmb_handle_t*)menu->userdata; if (!xmb) return; @@ -539,9 +558,13 @@ static void xmb_selection_pointer_changed(menu_handle_t *menu) } } -static void xmb_list_open_old(menu_handle_t *menu, xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) +static void xmb_list_open_old(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; for (i = 0; i < file_list_get_size(list); i++) { @@ -562,10 +585,13 @@ static void xmb_list_open_old(menu_handle_t *menu, xmb_handle_t *xmb, file_list_ } } -static void xmb_list_open_new(menu_handle_t *menu, - xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) +static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; for (i = 0; i < file_list_get_size(list); i++) { @@ -653,17 +679,27 @@ static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, int i) return node; } -static void xmb_push_animations(menu_handle_t *menu, xmb_node_t *node, float ia, float ix) +static void xmb_push_animations(xmb_node_t *node, float ia, float ix) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); menu_animation_push(menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); menu_animation_push(menu->animation, XMB_DELAY, ix, &node->x, EASING_IN_OUT_QUAD, NULL); } -static void xmb_list_switch_old(menu_handle_t *menu, xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) +static void xmb_list_switch_old(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; - size_t end = file_list_get_size(list); + size_t end = 0; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + end = file_list_get_size(list); for (i = 0; i < end; i++) { @@ -674,14 +710,20 @@ static void xmb_list_switch_old(menu_handle_t *menu, xmb_handle_t *xmb, file_lis if (!node) continue; - xmb_push_animations(menu, node, ia, -xmb->icon.spacing.horizontal * dir); + xmb_push_animations(node, ia, -xmb->icon.spacing.horizontal * dir); } } -static void xmb_list_switch_new(menu_handle_t *menu, xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) +static void xmb_list_switch_new(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; - size_t end = file_list_get_size(list); + size_t end = 0; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + end = file_list_get_size(list); for (i = 0; i < end; i++) { @@ -699,12 +741,17 @@ static void xmb_list_switch_new(menu_handle_t *menu, xmb_handle_t *xmb, file_lis if (i == current) ia = 1.0; - xmb_push_animations(menu, node, ia, 0); + xmb_push_animations(node, ia, 0); } } -static void xmb_set_title(menu_handle_t *menu, xmb_handle_t *xmb) +static void xmb_set_title(xmb_handle_t *xmb) { + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + if (menu->categories.selection_ptr == 0) { const char *dir = NULL; @@ -729,10 +776,14 @@ static void xmb_set_title(menu_handle_t *menu, xmb_handle_t *xmb) } } -static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) +static void xmb_list_open(xmb_handle_t *xmb) { unsigned j; int dir = -1; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; if (menu->categories.selection_ptr > xmb->categories.selection_ptr_old) dir = 1; @@ -766,15 +817,19 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) if (menu->categories.selection_ptr > xmb->categories.selection_ptr_old) dir = 1; - xmb_list_switch_old(menu, xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); - xmb_list_switch_new(menu, xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); + xmb_list_switch_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); + xmb_list_switch_new(xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); xmb->categories.active.idx_old = menu->categories.selection_ptr; } -static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) +static void xmb_list_switch(xmb_handle_t *xmb) { unsigned j; int dir = 0; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; xmb->depth = file_list_get_size(menu->menu_list->menu_stack); @@ -800,8 +855,8 @@ static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) &node->alpha, EASING_IN_OUT_QUAD, NULL); } - xmb_list_open_old(menu, xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); - xmb_list_open_new(menu, xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); + xmb_list_open_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); + xmb_list_open_new(xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); switch (xmb->depth) { @@ -822,14 +877,15 @@ static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) xmb->old_depth = xmb->depth; } -static void xmb_populate_entries(menu_handle_t *menu, const char *path, +static void xmb_populate_entries(const char *path, const char *label, unsigned k) { xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; - + xmb = (xmb_handle_t*)menu->userdata; if (!xmb) @@ -841,12 +897,12 @@ static void xmb_populate_entries(menu_handle_t *menu, const char *path, return; } - xmb_set_title(menu, xmb); + xmb_set_title(xmb); if (menu->categories.selection_ptr != xmb->categories.active.idx_old) - xmb_list_open(menu, xmb); + xmb_list_open(xmb); else - xmb_list_switch(menu, xmb); + xmb_list_switch(xmb); } static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, @@ -1016,17 +1072,27 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, } } -static void xmb_frame(menu_handle_t *menu) +static void xmb_frame(void) { int i, depth; char title_msg[PATH_MAX_LENGTH], timedate[PATH_MAX_LENGTH]; const char *core_name = NULL; const char *core_version = NULL; - xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata; + xmb_handle_t *xmb = NULL; + gl_t *gl = NULL; + menu_handle_t *menu = menu_driver_resolve(); - gl_t *gl = (gl_t*)video_driver_resolve(NULL); + if (!menu) + return; - if (!xmb || !gl) + xmb = (xmb_handle_t*)menu->userdata; + + if (!xmb) + return; + + gl = (gl_t*)video_driver_resolve(NULL); + + if (!gl) return; menu_animation_update(menu->animation, 0.002); @@ -1116,7 +1182,7 @@ static void xmb_frame(menu_handle_t *menu) else message_queue = driver.current_msg; - xmb_render_messagebox(menu, message_queue); + xmb_render_messagebox(message_queue); #endif if (menu->keyboard.display) @@ -1129,13 +1195,13 @@ static void xmb_frame(menu_handle_t *menu) snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str); xmb_render_background(gl, xmb, true); - xmb_render_messagebox(menu, msg); + xmb_render_messagebox(msg); } if (xmb->box_message[0] != '\0') { xmb_render_background(gl, xmb, true); - xmb_render_messagebox(menu, xmb->box_message); + xmb_render_messagebox(xmb->box_message); xmb->box_message[0] = '\0'; } @@ -1284,9 +1350,10 @@ static bool xmb_font_init_first(const gl_font_renderer_t **font_driver, font_path, xmb_font_size); } -static bool xmb_load_wallpaper(menu_handle_t *menu, const char *path) +static bool xmb_load_wallpaper(const char *path) { xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return false; @@ -1309,7 +1376,7 @@ static bool xmb_load_wallpaper(menu_handle_t *menu, const char *path) return true; } -static void xmb_context_reset(menu_handle_t *menu) +static void xmb_context_reset(void) { int i, k; char bgpath[PATH_MAX_LENGTH]; @@ -1322,6 +1389,7 @@ static void xmb_context_reset(menu_handle_t *menu) gl_t *gl = NULL; xmb_handle_t *xmb = NULL; xmb_node_t *node = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -1398,7 +1466,7 @@ static void xmb_context_reset(menu_handle_t *menu) xmb->textures.list[k].id = menu_texture_load(xmb->textures.list[k].path, TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); - xmb_load_wallpaper(driver.menu, xmb->textures.bg.path); + xmb_load_wallpaper(xmb->textures.bg.path); xmb->settings_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS].id; xmb->settings_node.alpha = xmb->categories.active.alpha; @@ -1459,52 +1527,48 @@ static void xmb_context_reset(menu_handle_t *menu) } } -static void xmb_navigation_clear(menu_handle_t *menu, bool pending_push) +static void xmb_navigation_clear(bool pending_push) { - if (!pending_push) - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_navigation_decrement(menu_handle_t *menu) +static void xmb_navigation_decrement(void) { - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_navigation_increment(menu_handle_t *menu) +static void xmb_navigation_increment(void) { - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_navigation_set(menu_handle_t *menu, bool scroll) +static void xmb_navigation_set(bool scroll) { - (void)scroll; - - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_navigation_set_last(menu_handle_t *menu) +static void xmb_navigation_set_last(void) { - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_navigation_descend_alphabet(menu_handle_t *menu, size_t *unused) +static void xmb_navigation_descend_alphabet(size_t *unused) { - (void)unused; - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_navigation_ascend_alphabet(menu_handle_t *menu, size_t *unused) +static void xmb_navigation_ascend_alphabet(size_t *unused) { - (void)unused; - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_list_insert(menu_handle_t *menu, file_list_t *list, +static void xmb_list_insert(file_list_t *list, const char *path, const char *unused, size_t list_size) { int current = 0, i = list_size; xmb_node_t *node = NULL; xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -1543,9 +1607,8 @@ static void xmb_list_insert(menu_handle_t *menu, file_list_t *list, } } -static void xmb_list_delete(menu_handle_t *menu, - file_list_t *list, size_t idx, - size_t list_size) +static void xmb_list_delete(file_list_t *list, + size_t idx, size_t list_size) { if (!list) return; @@ -1555,11 +1618,16 @@ static void xmb_list_delete(menu_handle_t *menu, list->list[idx].userdata = NULL; } -static void xmb_list_cache(menu_handle_t *menu, - bool horizontal, unsigned action) +static void xmb_list_cache(bool horizontal, unsigned action) { size_t stack_size; - xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata; + xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + xmb = (xmb_handle_t*)menu->userdata; if (!xmb) return; @@ -1599,10 +1667,11 @@ static void xmb_list_cache(menu_handle_t *menu, MENU_SETTING_HORIZONTAL_MENU; } -static void xmb_context_destroy(menu_handle_t *menu) +static void xmb_context_destroy(void) { unsigned i; xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -1627,10 +1696,16 @@ static void xmb_context_destroy(menu_handle_t *menu) } } -static void xmb_toggle(menu_handle_t *menu, bool menu_on) +static void xmb_toggle(bool menu_on) { int i; - xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata; + xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + xmb = (xmb_handle_t*)menu->userdata; if (!xmb) return; diff --git a/menu/menu.c b/menu/menu.c index 5e17ea6405..60a701ed85 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -67,7 +67,7 @@ void menu_update_libretro_info(struct retro_system_info *info) if (*g_settings.libretro_directory) g_extern.core_info = core_info_list_new(g_settings.libretro_directory); if (driver.menu_ctx && driver.menu_ctx->context_reset) - driver.menu_ctx->context_reset(driver.menu); + driver.menu_ctx->context_reset(); rarch_update_system_info(info, NULL); } @@ -131,7 +131,7 @@ bool menu_load_content(void) driver.menu->msg_force = true; if (driver.menu_ctx && driver.menu_ctx->entry_iterate) - driver.menu_ctx->entry_iterate(driver.menu, MENU_ACTION_NOOP); + driver.menu_ctx->entry_iterate(MENU_ACTION_NOOP); draw_frame(); @@ -370,12 +370,12 @@ int menu_iterate(retro_input_t input, int32_t ret = 0; unsigned action = menu_input_frame(input, trigger_input); - if (driver.menu && driver.menu_ctx) + if (driver.menu_ctx) { if (driver.menu_ctx->set_texture) - driver.menu_ctx->set_texture(driver.menu); + driver.menu_ctx->set_texture(); if (driver.menu_ctx->entry_iterate) - ret = driver.menu_ctx->entry_iterate(driver.menu, action); + ret = driver.menu_ctx->entry_iterate(action); } if (g_extern.is_menu) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 04502c23d5..46ee40bc7d 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -160,3 +160,10 @@ void init_menu(void) rarch_fail(1, "init_menu()"); } } + +menu_handle_t *menu_driver_resolve(void) +{ + if (!driver.menu) + return NULL; + return driver.menu; +} diff --git a/menu/menu_driver.h b/menu/menu_driver.h index e453b43a24..2156c9c140 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -68,6 +68,14 @@ struct menu_bind_state bool skip; }; +typedef struct menu_framebuf +{ + uint16_t *data; + unsigned width; + unsigned height; + size_t pitch; +} menu_framebuf_t; + typedef struct { void *userdata; @@ -118,13 +126,7 @@ typedef struct char default_glslp[PATH_MAX_LENGTH]; char default_cgp[PATH_MAX_LENGTH]; - struct - { - uint16_t *data; - unsigned width; - unsigned height; - size_t pitch; - } frame_buf; + menu_framebuf_t frame_buf; const uint8_t *font; bool alloc_font; @@ -195,31 +197,31 @@ typedef struct menu_file_list_cbs typedef struct menu_ctx_driver { - void (*set_texture)(menu_handle_t *menu); - void (*render_messagebox)(menu_handle_t *menu, const char *msg); - void (*render)(menu_handle_t *menu); - void (*frame)(menu_handle_t *menu); + void (*set_texture)(void); + void (*render_messagebox)(const char *msg); + void (*render)(void); + void (*frame)(void); void* (*init)(void); void (*free)(void*); - void (*context_reset)(menu_handle_t *menu); - void (*context_destroy)(menu_handle_t *menu); - void (*populate_entries)(menu_handle_t *menu, const char *path, const char *label, + void (*context_reset)(void); + void (*context_destroy)(void); + void (*populate_entries)(const char *path, const char *label, unsigned k); - void (*toggle)(menu_handle_t *menu, bool); - void (*navigation_clear)(menu_handle_t *menu, bool); - void (*navigation_decrement)(menu_handle_t *menu); - void (*navigation_increment)(menu_handle_t *menu); - void (*navigation_set)(menu_handle_t *menu, bool); - void (*navigation_set_last)(menu_handle_t *menu); - void (*navigation_descend_alphabet)(menu_handle_t *menu, size_t *); - void (*navigation_ascend_alphabet)(menu_handle_t *menu, size_t *); - void (*list_insert)(menu_handle_t *menu, file_list_t *list, const char *, const char *, size_t); - void (*list_delete)(menu_handle_t *menu, file_list_t *list, size_t, size_t); - void (*list_clear)(menu_handle_t *menu, file_list_t *list); - void (*list_cache)(menu_handle_t *menu, bool, unsigned); + void (*toggle)(bool); + void (*navigation_clear)(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 (*list_insert)(file_list_t *list, const char *, const char *, size_t); + void (*list_delete)(file_list_t *list, size_t, size_t); + void (*list_clear)(file_list_t *list); + void (*list_cache)(bool, unsigned); void (*list_set_selection)(file_list_t *list); - int (*entry_iterate)(menu_handle_t *menu, unsigned); - bool (*load_background)(menu_handle_t *menu, const char * path); + int (*entry_iterate)(unsigned); + bool (*load_background)(const char * path); const char *ident; } menu_ctx_driver_t; @@ -263,6 +265,8 @@ void find_menu_driver(void); void init_menu(void); +menu_handle_t *menu_driver_resolve(void); + #ifdef __cplusplus } #endif diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 65c453bba2..3015e8ebd1 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -122,7 +122,7 @@ int menu_entries_push_list(menu_handle_t *menu, } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -345,7 +345,7 @@ int menu_entries_parse_list( { menu_entries_parse_drive_list(list); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, dir, label, type); + driver.menu_ctx->populate_entries(dir, label, type); return 0; } #if defined(GEKKO) && defined(HW_RVL) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index eea2ff8d75..51be8db759 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -228,7 +228,7 @@ static int load_or_open_zip_iterate(menu_handle_t *menu, unsigned action) && driver.menu_ctx->render_messagebox) { if (*msg && msg[0] != '\0') - driver.menu_ctx->render_messagebox(menu, msg); + driver.menu_ctx->render_messagebox(msg); } switch (action) @@ -546,7 +546,7 @@ static int action_ok_menu_wallpaper_load(const char *path, strlcpy(g_settings.menu.wallpaper, wallpaper_path, sizeof(g_settings.menu.wallpaper)); if (driver.menu_ctx && driver.menu_ctx->load_background) - driver.menu_ctx->load_background(driver.menu, wallpaper_path); + driver.menu_ctx->load_background(wallpaper_path); end: menu_list_pop_stack_by_needle(driver.menu->menu_list, setting->name); @@ -798,7 +798,7 @@ static int deferred_push_core_information(void *data, void *userdata, MENU_SETTINGS_CORE_OPTION_NONE, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -1149,7 +1149,7 @@ static int deferred_push_rdb_entry_detail(void *data, void *userdata, 0, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, + driver.menu_ctx->populate_entries(path, str_list->elems[0].data, type); ret = 0; @@ -2104,7 +2104,7 @@ static int action_toggle_mainmenu(unsigned type, const char *label, { case 1: if (driver.menu_ctx->list_cache) - driver.menu_ctx->list_cache(menu, true, action); + driver.menu_ctx->list_cache(true, action); if (cbs && cbs->action_content_list_switch) return cbs->action_content_list_switch( @@ -2793,7 +2793,7 @@ static int deferred_push_core_information(void *data, void *userdata, MENU_SETTINGS_CORE_OPTION_NONE, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -2815,7 +2815,7 @@ static int deferred_push_performance_counters(void *data, void *userdata, MENU_SETTING_ACTION, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -2852,7 +2852,7 @@ static int deferred_push_video_shader_parameters_common(void *data, void *userda } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -2937,7 +2937,7 @@ static int deferred_push_settings(void *data, void *userdata, } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3004,7 +3004,7 @@ static int deferred_push_settings_subgroup(void *data, void *userdata, } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3066,7 +3066,7 @@ static int deferred_push_shader_options(void *data, void *userdata, } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3098,7 +3098,7 @@ static int deferred_push_options(void *data, void *userdata, MENU_SETTING_ACTION, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3122,7 +3122,7 @@ static int deferred_push_management_options(void *data, void *userdata, #endif if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3161,7 +3161,7 @@ static int push_perfcounter_generic( push_perfcounter(driver.menu, list, counters, num, ident); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3224,7 +3224,7 @@ static int deferred_push_core_cheat_options(void *data, void *userdata, } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3267,7 +3267,7 @@ static int deferred_push_core_input_remapping_options(void *data, void *userdata } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3299,7 +3299,7 @@ static int deferred_push_core_options(void *data, void *userdata, MENU_SETTINGS_CORE_OPTION_NONE, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3323,7 +3323,7 @@ static int deferred_push_disk_options(void *data, void *userdata, MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_IMAGE_APPEND, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3787,7 +3787,7 @@ static int action_iterate_help(const char *label, unsigned action) return 0; if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(menu); + driver.menu_ctx->render(); for (i = 0; i < ARRAY_SIZE(binds); i++) { @@ -3825,7 +3825,7 @@ static int action_iterate_help(const char *label, unsigned action) desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6], desc[7]); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(menu, msg); + driver.menu_ctx->render_messagebox(msg); if (action == MENU_ACTION_OK) menu_list_pop(menu->menu_list->menu_stack, NULL); @@ -3848,7 +3848,7 @@ static int action_iterate_info(const char *label, unsigned action) list = (file_list_t*)menu->menu_list->selection_buf; if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(menu); + driver.menu_ctx->render(); current_setting = (rarch_setting_t*)setting_data_find_setting( menu->list_settings, @@ -3880,7 +3880,7 @@ static int action_iterate_info(const char *label, unsigned action) driver.menu_ctx->render_messagebox) { if (*msg && msg[0] != '\0') - driver.menu_ctx->render_messagebox(menu, msg); + driver.menu_ctx->render_messagebox(msg); } if (action == MENU_ACTION_OK) @@ -4041,7 +4041,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) menu_list_get_last_stack(menu->menu_list, NULL, &label, &type); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(menu); + driver.menu_ctx->render(); if (g_settings.video.scale_integer) { @@ -4072,7 +4072,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(menu, msg); + driver.menu_ctx->render_messagebox(msg); if (!custom->width) custom->width = stride_x; @@ -4110,7 +4110,7 @@ static int action_iterate_message(const char *label, unsigned action) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(menu, menu->message_contents); + driver.menu_ctx->render_messagebox(menu->message_contents); if (action == MENU_ACTION_OK) menu_list_pop_stack(menu->menu_list); @@ -4272,7 +4272,7 @@ static int action_iterate_main(const char *label, unsigned action) ret = mouse_post_iterate(cbs, path_offset, label_offset, type_offset, action); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(menu); + driver.menu_ctx->render(); /* Have to defer it so we let settings refresh. */ if (menu->push_start_screen) diff --git a/menu/menu_input.c b/menu/menu_input.c index 94abbdc3ed..cf19ca0d28 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -359,7 +359,7 @@ int menu_input_bind_iterate(menu_handle_t *menu) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(menu); + driver.menu_ctx->render(); snprintf(msg, sizeof(msg), "[%s]\npress joypad\n(RETURN to skip)", input_config_bind_map[ @@ -367,7 +367,7 @@ int menu_input_bind_iterate(menu_handle_t *menu) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(menu, msg); + driver.menu_ctx->render_messagebox( msg); driver.block_input = true; menu_input_poll_bind_state(&binds); @@ -401,7 +401,7 @@ int menu_input_bind_iterate_keyboard(menu_handle_t *menu) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(menu); + driver.menu_ctx->render(); current = rarch_get_time_usec(); timeout = (menu->binds.timeout_end - current) / 1000000; @@ -412,7 +412,7 @@ int menu_input_bind_iterate_keyboard(menu_handle_t *menu) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(menu, msg); + driver.menu_ctx->render_messagebox(msg); if (timeout <= 0) { diff --git a/menu/menu_list.c b/menu/menu_list.c index 2ed31e94da..4cc037068d 100644 --- a/menu/menu_list.c +++ b/menu/menu_list.c @@ -136,7 +136,7 @@ void menu_list_destroy(file_list_t *list) for (i = 0; i < list->size; i++) { if (driver.menu_ctx->list_delete) - driver.menu_ctx->list_delete(driver.menu, list, i, list->size); + driver.menu_ctx->list_delete(list, i, list->size); menu_common_list_delete(list, i, list->size); } @@ -271,7 +271,7 @@ void menu_list_pop_stack(menu_list_t *list) return; if (driver.menu_ctx->list_cache) - driver.menu_ctx->list_cache(driver.menu, false, 0); + driver.menu_ctx->list_cache(false, 0); menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); driver.menu->need_refresh = true; @@ -307,7 +307,7 @@ void menu_list_pop(file_list_t *list, size_t *directory_ptr) size_t list_size = list->size - 1; if (driver.menu_ctx->list_delete) - driver.menu_ctx->list_delete(driver.menu, list, list_size, list_size); + driver.menu_ctx->list_delete(list, list_size, list_size); menu_common_list_delete(list, list_size, list_size); } @@ -329,7 +329,7 @@ void menu_list_clear(file_list_t *list) goto end; if (driver.menu_ctx->list_clear) - driver.menu_ctx->list_clear(driver.menu, list); + driver.menu_ctx->list_clear(list); end: menu_common_list_clear(list); @@ -343,7 +343,7 @@ static void menu_list_insert(file_list_t *list, return; if (driver.menu_ctx->list_insert) - driver.menu_ctx->list_insert(driver.menu, list, path, label, list->size - 1); + driver.menu_ctx->list_insert(list, path, label, list->size - 1); menu_common_list_insert(list, path, label, type, list->size - 1); } @@ -387,7 +387,7 @@ int menu_list_push_stack_refresh(menu_list_t *list, return -1; if (driver.menu_ctx->list_cache) - driver.menu_ctx->list_cache(driver.menu, false, 0); + driver.menu_ctx->list_cache(false, 0); menu_list_push_stack(list, path, label, type, directory_ptr); menu_navigation_clear(driver.menu, true); @@ -427,7 +427,7 @@ int menu_list_populate_generic(void *data, menu_entries_refresh(menu, list); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } diff --git a/menu/menu_navigation.c b/menu/menu_navigation.c index 91319321ed..14336f3aba 100644 --- a/menu/menu_navigation.c +++ b/menu/menu_navigation.c @@ -34,7 +34,7 @@ void menu_navigation_clear(menu_handle_t *menu, bool pending_push) menu->selection_ptr = 0; if (driver.menu_ctx && driver.menu_ctx->navigation_clear) - driver.menu_ctx->navigation_clear(menu, pending_push); + driver.menu_ctx->navigation_clear(pending_push); } /** @@ -48,7 +48,7 @@ void menu_navigation_decrement(menu_handle_t *menu) menu->selection_ptr--; if (driver.menu_ctx && driver.menu_ctx->navigation_decrement) - driver.menu_ctx->navigation_decrement(menu); + driver.menu_ctx->navigation_decrement(); } /** @@ -62,7 +62,7 @@ void menu_navigation_increment(menu_handle_t *menu) menu->selection_ptr++; if (driver.menu_ctx && driver.menu_ctx->navigation_increment) - driver.menu_ctx->navigation_increment(menu); + driver.menu_ctx->navigation_increment(); } /** @@ -78,7 +78,7 @@ void menu_navigation_set(menu_handle_t *menu, size_t idx, bool scroll) menu->selection_ptr = idx; if (driver.menu_ctx && driver.menu_ctx->navigation_set) - driver.menu_ctx->navigation_set(menu, scroll); + driver.menu_ctx->navigation_set(scroll); } /** @@ -92,7 +92,7 @@ void menu_navigation_set_last(menu_handle_t *menu) menu->selection_ptr = menu_list_get_size(driver.menu->menu_list) - 1; if (driver.menu_ctx && driver.menu_ctx->navigation_set_last) - driver.menu_ctx->navigation_set_last(menu); + driver.menu_ctx->navigation_set_last(); } /** @@ -124,7 +124,7 @@ void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out) *ptr_out = menu->scroll.indices.list[i - 1]; if (driver.menu_ctx && driver.menu_ctx->navigation_descend_alphabet) - driver.menu_ctx->navigation_descend_alphabet(menu, ptr_out); + driver.menu_ctx->navigation_descend_alphabet(ptr_out); } /** @@ -155,5 +155,5 @@ void menu_navigation_ascend_alphabet(menu_handle_t *menu, size_t *ptr_out) *ptr_out = menu->scroll.indices.list[i + 1]; if (driver.menu_ctx && driver.menu_ctx->navigation_descend_alphabet) - driver.menu_ctx->navigation_descend_alphabet(menu, ptr_out); + driver.menu_ctx->navigation_descend_alphabet(ptr_out); } diff --git a/retroarch.c b/retroarch.c index 06ceb70dda..f47b2fffd2 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1958,8 +1958,8 @@ void rarch_main_set_state(unsigned cmd) if (!driver.menu) return; - if (driver.menu && driver.menu_ctx && driver.menu_ctx->toggle) - driver.menu_ctx->toggle(driver.menu, true); + if (driver.menu_ctx && driver.menu_ctx->toggle) + driver.menu_ctx->toggle(true); /* Menu should always run with vsync on. */ rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE); @@ -1993,8 +1993,8 @@ void rarch_main_set_state(unsigned cmd) #ifdef HAVE_MENU menu_apply_deferred_settings(); - if (driver.menu && driver.menu_ctx && driver.menu_ctx->toggle) - driver.menu_ctx->toggle(driver.menu, false); + if (driver.menu_ctx && driver.menu_ctx->toggle) + driver.menu_ctx->toggle(false); g_extern.is_menu = false;