diff --git a/frontend/frontend.c b/frontend/frontend.c index 2963922812..37b5b434f9 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -98,7 +98,7 @@ static int main_entry_iterate_clear_input(args_type() args) (void)args; rarch_input_poll(); - if (!menu_input(driver.menu)) + if (!menu_input()) { // Restore libretro keyboard callback. g_extern.system.key_event = key_event; @@ -116,7 +116,7 @@ static int main_entry_iterate_shutdown(args_type() args) #ifdef HAVE_MENU // Load dummy core instead of exiting RetroArch completely. if (g_settings.load_dummy_on_core_shutdown) - load_menu_game_prepare_dummy(driver.menu); + load_menu_game_prepare_dummy(); else #endif return 1; @@ -146,9 +146,9 @@ static int main_entry_iterate_content(args_type() args) static int main_entry_iterate_load_content(args_type() args) { - load_menu_game_prepare(driver.menu); + load_menu_game_prepare(); - if (load_menu_game(driver.menu)) + if (load_menu_game()) { g_extern.lifecycle_state |= (1ULL << MODE_GAME); if (driver.video_data && driver.video_poke && driver.video_poke->set_aspect_ratio) @@ -342,7 +342,7 @@ returntype main_entry(signature()) // If we started a ROM directly from command line, // push it to ROM history. if (!g_extern.libretro_dummy) - menu_rom_history_push_current(driver.menu); + menu_rom_history_push_current(); } while (!main_entry_iterate(signature_expand(), args)); diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 1d0e6b2b9b..e598ab6c5b 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -56,9 +56,13 @@ static inline struct gfx_shader *shader_manager_get_current_shader(rgui_handle_t static void menu_common_entries_init(void *data, unsigned menu_type) { - rgui_handle_t *rgui = (rgui_handle_t*)data; unsigned i, last; char tmp[256]; + rgui_handle_t *rgui = (rgui_handle_t*)data; + + if (!rgui) + return; + switch (menu_type) { #ifdef HAVE_SHADER_MANAGER @@ -447,7 +451,6 @@ static void menu_common_entries_init(void *data, unsigned menu_type) if (driver.menu_ctx && driver.menu_ctx->populate_entries) driver.menu_ctx->populate_entries(rgui, menu_type); - } static int menu_start_screen_iterate(void *data, unsigned action) @@ -735,9 +738,9 @@ static int menu_settings_iterate(void *data, unsigned action) || menu_type == RGUI_SETTINGS_SHADER_PARAMETERS || menu_type == RGUI_SETTINGS_SHADER_PRESET_PARAMETERS ) - menu_common_entries_init(rgui, menu_type); + menu_common_entries_init(driver.menu, menu_type); else - menu_common_entries_init(rgui, RGUI_SETTINGS); + menu_common_entries_init(driver.menu, RGUI_SETTINGS); } if (rgui) @@ -1168,6 +1171,7 @@ static void menu_parse_and_resolve(void *data, unsigned menu_type) static int menu_custom_bind_iterate(void *data, unsigned action) { rgui_handle_t *rgui = (rgui_handle_t*)data; + (void)action; // Have to ignore action here. Only bind that should work here is Quit RetroArch or something like that. if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) @@ -1249,7 +1253,7 @@ static void menu_common_defer_decision_automatic(void *data) if (!rgui) return; - menu_flush_stack_type(rgui, RGUI_SETTINGS); + menu_flush_stack_type(RGUI_SETTINGS); rgui->msg_force = true; } @@ -1308,9 +1312,9 @@ static int menu_common_iterate(void *data, unsigned action) else if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT || menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT_2) return menu_viewport_iterate(rgui, action); else if (menu_type == RGUI_SETTINGS_CUSTOM_BIND) - return menu_custom_bind_iterate(rgui, action); + return menu_custom_bind_iterate(driver.menu, action); else if (menu_type == RGUI_SETTINGS_CUSTOM_BIND_KEYBOARD) - return menu_custom_bind_iterate_keyboard(rgui, action); + return menu_custom_bind_iterate_keyboard(driver.menu, action); if (rgui->need_refresh && action != RGUI_ACTION_MESSAGE) action = RGUI_ACTION_NOOP; @@ -1414,7 +1418,7 @@ static int menu_common_iterate(void *data, unsigned action) } // Pop stack until we hit shader manager again. - menu_flush_stack_type(rgui, RGUI_SETTINGS_SHADER_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_SHADER_OPTIONS); } else #endif @@ -1423,16 +1427,16 @@ static int menu_common_iterate(void *data, unsigned action) // FIXME: Add for consoles. strlcpy(g_settings.libretro, path, sizeof(g_settings.libretro)); strlcpy(g_extern.fullpath, rgui->deferred_path, sizeof(g_extern.fullpath)); - load_menu_game_new_core(rgui); + load_menu_game_new_core(); rgui->msg_force = true; ret = -1; - menu_flush_stack_type(rgui, RGUI_SETTINGS); + menu_flush_stack_type(RGUI_SETTINGS); } else if (menu_type == RGUI_SETTINGS_CORE) { #if defined(HAVE_DYNAMIC) fill_pathname_join(g_settings.libretro, dir, path, sizeof(g_settings.libretro)); - menu_update_system_info(rgui, &rgui->load_no_rom); + menu_update_system_info(driver.menu, &rgui->load_no_rom); // No ROM needed for this core, load game immediately. if (rgui->load_no_rom) @@ -1459,15 +1463,15 @@ static int menu_common_iterate(void *data, unsigned action) ret = -1; #endif - menu_flush_stack_type(rgui, RGUI_SETTINGS); + menu_flush_stack_type(RGUI_SETTINGS); } else if (menu_type == RGUI_SETTINGS_CONFIG) { char config[PATH_MAX]; fill_pathname_join(config, dir, path, sizeof(config)); - menu_flush_stack_type(rgui, RGUI_SETTINGS); + menu_flush_stack_type(RGUI_SETTINGS); rgui->msg_force = true; - if (menu_replace_config(rgui, config)) + if (menu_replace_config(config)) { menu_clear_navigation(rgui); ret = -1; @@ -1484,7 +1488,7 @@ static int menu_common_iterate(void *data, unsigned action) if (!driver.overlay) RARCH_ERR("Failed to load overlay.\n"); - menu_flush_stack_type(rgui, RGUI_SETTINGS_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_OPTIONS); } #endif else if (menu_type == RGUI_SETTINGS_DISK_APPEND) @@ -1495,54 +1499,54 @@ static int menu_common_iterate(void *data, unsigned action) g_extern.lifecycle_state |= 1ULL << MODE_GAME; - menu_flush_stack_type(rgui, RGUI_SETTINGS); + menu_flush_stack_type(RGUI_SETTINGS); ret = -1; } else if (menu_type == RGUI_SETTINGS_OPEN_HISTORY) { - load_menu_game_history(rgui, rgui->selection_ptr); - menu_flush_stack_type(rgui, RGUI_SETTINGS); + load_menu_game_history(rgui->selection_ptr); + menu_flush_stack_type(RGUI_SETTINGS); ret = -1; } else if (menu_type == RGUI_BROWSER_DIR_PATH) { strlcpy(g_settings.rgui_content_directory, dir, sizeof(g_settings.rgui_content_directory)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } else if (menu_type == RGUI_CONTENT_DIR_PATH) { strlcpy(g_settings.content_directory, dir, sizeof(g_settings.content_directory)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } else if (menu_type == RGUI_ASSETS_DIR_PATH) { strlcpy(g_settings.assets_directory, dir, sizeof(g_settings.assets_directory)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } #ifdef HAVE_SCREENSHOTS else if (menu_type == RGUI_SCREENSHOT_DIR_PATH) { strlcpy(g_settings.screenshot_directory, dir, sizeof(g_settings.screenshot_directory)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } #endif else if (menu_type == RGUI_SAVEFILE_DIR_PATH) { strlcpy(g_extern.savefile_dir, dir, sizeof(g_extern.savefile_dir)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } #ifdef HAVE_OVERLAY else if (menu_type == RGUI_OVERLAY_DIR_PATH) { strlcpy(g_extern.overlay_dir, dir, sizeof(g_extern.overlay_dir)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } #endif else if (menu_type == RGUI_SETTINGS_VIDEO_SOFTFILTER) { fill_pathname_join(g_settings.video.filter_path, dir, path, sizeof(g_settings.video.filter_path)); menu_reinit_context(rgui); - menu_flush_stack_type(rgui, RGUI_SETTINGS_VIDEO_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_VIDEO_OPTIONS); } else if (menu_type == RGUI_SETTINGS_AUDIO_DSP_FILTER) { @@ -1551,12 +1555,12 @@ static int menu_common_iterate(void *data, unsigned action) #endif rarch_deinit_dsp_filter(); rarch_init_dsp_filter(); - menu_flush_stack_type(rgui, RGUI_SETTINGS_AUDIO_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_AUDIO_OPTIONS); } else if (menu_type == RGUI_SAVESTATE_DIR_PATH) { strlcpy(g_extern.savestate_dir, dir, sizeof(g_extern.savestate_dir)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } else if (menu_type == RGUI_LIBRETRO_DIR_PATH) { @@ -1564,13 +1568,13 @@ static int menu_common_iterate(void *data, unsigned action) if (driver.menu_ctx && driver.menu_ctx->init_core_info) driver.menu_ctx->init_core_info(rgui); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } #ifdef HAVE_DYNAMIC else if (menu_type == RGUI_CONFIG_DIR_PATH) { strlcpy(g_settings.rgui_config_directory, dir, sizeof(g_settings.rgui_config_directory)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } #endif else if (menu_type == RGUI_LIBRETRO_INFO_DIR_PATH) @@ -1578,32 +1582,32 @@ static int menu_common_iterate(void *data, unsigned action) strlcpy(g_settings.libretro_info_path, dir, sizeof(g_settings.libretro_info_path)); if (driver.menu_ctx && driver.menu_ctx->init_core_info) driver.menu_ctx->init_core_info(rgui); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } else if (menu_type == RGUI_SHADER_DIR_PATH) { strlcpy(g_settings.video.shader_dir, dir, sizeof(g_settings.video.shader_dir)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } else if (menu_type == RGUI_FILTER_DIR_PATH) { strlcpy(g_settings.video.filter_dir, dir, sizeof(g_settings.video.filter_dir)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } else if (menu_type == RGUI_DSP_FILTER_DIR_PATH) { strlcpy(g_settings.audio.filter_dir, dir, sizeof(g_settings.audio.filter_dir)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } else if (menu_type == RGUI_SYSTEM_DIR_PATH) { strlcpy(g_settings.system_directory, dir, sizeof(g_settings.system_directory)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } else if (menu_type == RGUI_AUTOCONFIG_DIR_PATH) { strlcpy(g_settings.input.autoconfig_dir, dir, sizeof(g_settings.input.autoconfig_dir)); - menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + menu_flush_stack_type(RGUI_SETTINGS_PATH_OPTIONS); } else { @@ -1613,7 +1617,7 @@ static int menu_common_iterate(void *data, unsigned action) if (ret == -1) { - menu_update_system_info(rgui, &rgui->load_no_rom); + menu_update_system_info(driver.menu, &rgui->load_no_rom); if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->defer_decision_automatic) driver.menu_ctx->backend->defer_decision_automatic(rgui); } @@ -1628,7 +1632,7 @@ static int menu_common_iterate(void *data, unsigned action) fill_pathname_join(g_extern.fullpath, dir, path, sizeof(g_extern.fullpath)); g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME); - menu_flush_stack_type(rgui, RGUI_SETTINGS); + menu_flush_stack_type(RGUI_SETTINGS); rgui->msg_force = true; ret = -1; } @@ -1681,10 +1685,11 @@ static int menu_common_iterate(void *data, unsigned action) static void menu_common_shader_manager_init(void *data) { - (void)data; + rgui_handle_t *rgui = (rgui_handle_t*)data; + if (!rgui) + return; #ifdef HAVE_SHADER_MANAGER - rgui_handle_t *rgui = (rgui_handle_t*)data; memset(&rgui->shader, 0, sizeof(rgui->shader)); config_file_t *conf = NULL; @@ -2976,7 +2981,7 @@ static int menu_common_setting_set(void *data, unsigned setting, unsigned action rgui->binds.last = RGUI_SETTINGS_BIND_LAST; file_list_push(rgui->menu_stack, "", RGUI_SETTINGS_CUSTOM_BIND_KEYBOARD, rgui->selection_ptr); rgui->binds.timeout_end = rarch_get_time_usec() + RGUI_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; - input_keyboard_wait_keys(rgui, menu_custom_bind_keyboard_cb); + input_keyboard_wait_keys(driver.menu, menu_custom_bind_keyboard_cb); } else { @@ -3091,7 +3096,7 @@ static int menu_common_setting_set(void *data, unsigned setting, unsigned action if (rgui->bind_mode_keyboard) { rgui->binds.timeout_end = rarch_get_time_usec() + RGUI_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; - input_keyboard_wait_keys(rgui, menu_custom_bind_keyboard_cb); + input_keyboard_wait_keys(driver.menu, menu_custom_bind_keyboard_cb); } else { diff --git a/frontend/menu/backend/menu_lakka_backend.c b/frontend/menu/backend/menu_lakka_backend.c index 2beacc89e9..28662a15b4 100644 --- a/frontend/menu/backend/menu_lakka_backend.c +++ b/frontend/menu/backend/menu_lakka_backend.c @@ -120,7 +120,7 @@ static int menu_lakka_iterate(void *data, unsigned action) strlcpy(g_settings.libretro, active_category->libretro, sizeof(g_settings.libretro)); #ifdef HAVE_DYNAMIC - menu_update_system_info(rgui, &rgui->load_no_rom); + menu_update_system_info(&rgui->load_no_rom); g_extern.lifecycle_state |= (1ULL << MODE_LOAD_GAME); #else rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, (void*)g_settings.libretro); diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index f3a8b136ea..0697ba03a8 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -99,22 +99,25 @@ int menu_defer_core(void *info_, const char *dir, const char *path, char *deferr return 0; } -void menu_rom_history_push(void *data, const char *path, +void menu_rom_history_push(const char *path, const char *core_path, const char *core_name) { - rgui_handle_t *rgui = (rgui_handle_t*)data; + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; - if (rgui->history) + if (rgui && rgui->history) rom_history_push(rgui->history, path, core_path, core_name); } -void menu_rom_history_push_current(void *data) +void menu_rom_history_push_current(void) { // g_extern.fullpath can be relative here. // Ensure we're pushing absolute path. char tmp[PATH_MAX]; - rgui_handle_t *rgui = (rgui_handle_t*)data; + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; + + if (!rgui) + return; strlcpy(tmp, g_extern.fullpath, sizeof(tmp)); @@ -122,14 +125,17 @@ void menu_rom_history_push_current(void *data) path_resolve_realpath(tmp, sizeof(tmp)); if (g_extern.system.no_game || *tmp) - menu_rom_history_push(rgui, *tmp ? tmp : NULL, + menu_rom_history_push(*tmp ? tmp : NULL, g_settings.libretro, g_extern.system.info.library_name); } -void load_menu_game_prepare(void *data) +void load_menu_game_prepare(void) { - rgui_handle_t *rgui = (rgui_handle_t*)data; + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; + + if (!rgui) + return; if (*g_extern.fullpath || (rgui && rgui->load_no_rom)) { @@ -146,12 +152,11 @@ void load_menu_game_prepare(void *data) #ifdef RARCH_CONSOLE if (g_extern.system.no_game || *g_extern.fullpath) #endif - menu_rom_history_push(rgui, *g_extern.fullpath ? g_extern.fullpath : NULL, + menu_rom_history_push(*g_extern.fullpath ? g_extern.fullpath : NULL, g_settings.libretro, rgui->info.library_name ? rgui->info.library_name : ""); } -#ifdef HAVE_MENU // redraw RGUI frame rgui->old_input_state = rgui->trigger_state = 0; rgui->do_held = false; @@ -159,7 +164,6 @@ void load_menu_game_prepare(void *data) if (driver.menu_ctx && driver.menu_ctx->backend && driver.menu_ctx->backend->iterate) driver.menu_ctx->backend->iterate(rgui, RGUI_ACTION_NOOP); -#endif // Draw frame for loading message if (driver.video_data && driver.video_poke && driver.video_poke->set_texture_enable) @@ -173,14 +177,12 @@ void load_menu_game_prepare(void *data) MENU_TEXTURE_FULLSCREEN); } -void load_menu_game_history(void *data, unsigned game_index) +void load_menu_game_history(unsigned game_index) { - rgui_handle_t *rgui; const char *path = NULL; const char *core_path = NULL; const char *core_name = NULL; - - rgui = (rgui_handle_t*)data; + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; if (!rgui) return; @@ -208,7 +210,10 @@ static void menu_init_history(void *data) { rgui_handle_t *rgui = (rgui_handle_t*)data; - if (rgui && rgui->history) + if (!rgui) + return; + + if (rgui->history) { rom_history_free(rgui->history); rgui->history = NULL; @@ -250,9 +255,9 @@ static void menu_update_libretro_info(void *data) menu_update_system_info(rgui, NULL); } -void load_menu_game_prepare_dummy(void *data) +void load_menu_game_prepare_dummy(void) { - rgui_handle_t *rgui = (rgui_handle_t*)data; + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; if (!rgui) return; @@ -266,10 +271,11 @@ void load_menu_game_prepare_dummy(void *data) g_extern.system.shutdown = false; } -bool load_menu_game(void *data) +bool load_menu_game(void) { + int ret; struct rarch_main_wrap args = {0}; - rgui_handle_t *rgui = (rgui_handle_t*)data; + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; if (!rgui) return false; @@ -286,10 +292,12 @@ bool load_menu_game(void *data) args.rom_path = *g_extern.fullpath ? g_extern.fullpath : NULL; args.libretro_path = *g_settings.libretro ? g_settings.libretro : NULL; - if (rarch_main_init_wrap(&args) != 0) + ret = rarch_main_init_wrap(&args); + rgui = (rgui_handle_t*)driver.menu; + + if (ret != 0) { char name[PATH_MAX], msg[PATH_MAX]; - rgui = (rgui_handle_t*)driver.menu; fill_pathname_base(name, g_extern.fullpath, sizeof(name)); snprintf(msg, sizeof(msg), "Failed to load %s.\n", name); @@ -302,7 +310,7 @@ bool load_menu_game(void *data) RARCH_LOG("rarch_main_init_wrap() succeeded.\n"); - if ((rgui = (rgui_handle_t*)driver.menu)) + if (rgui) { // Update menu state which depends on config. menu_update_libretro_info(rgui); @@ -419,24 +427,23 @@ void menu_ticker_line(char *buf, size_t len, unsigned index, const char *str, bo } } -#ifdef HAVE_MENU -uint64_t menu_input(void *data) +uint64_t menu_input(void) { unsigned i; uint64_t input_state; - rgui_handle_t *rgui; #ifdef RARCH_CONSOLE static const struct retro_keybind *binds[] = { g_settings.input.menu_binds }; #else static const struct retro_keybind *binds[] = { g_settings.input.binds[0] }; #endif - - rgui = (rgui_handle_t*)data; - input_state = 0; + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; if (!rgui) return 0; + input_state = 0; + + input_push_analog_dpad((struct retro_keybind*)binds[0], (g_settings.input.analog_dpad_mode[0] == ANALOG_DPAD_NONE) ? ANALOG_DPAD_LSTICK : g_settings.input.analog_dpad_mode[0]); for (i = 0; i < MAX_PLAYERS; i++) input_push_analog_dpad(g_settings.input.autoconf_binds[i], g_settings.input.analog_dpad_mode[i]); @@ -473,6 +480,10 @@ uint64_t menu_input(void *data) bool menu_custom_bind_keyboard_cb(void *data, unsigned code) { rgui_handle_t *rgui = (rgui_handle_t*)data; + + if (!rgui) + return false; + rgui->binds.target->key = (enum retro_key)code; rgui->binds.begin++; rgui->binds.target++; @@ -480,10 +491,14 @@ bool menu_custom_bind_keyboard_cb(void *data, unsigned code) return rgui->binds.begin <= rgui->binds.last; } -void menu_flush_stack_type(void *data, unsigned final_type) +void menu_flush_stack_type(unsigned final_type) { - rgui_handle_t *rgui = (rgui_handle_t*)data; unsigned type; + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; + + if (!rgui) + return; + type = 0; rgui->need_refresh = true; file_list_get_last(rgui->menu_stack, NULL, &type); @@ -494,9 +509,9 @@ void menu_flush_stack_type(void *data, unsigned final_type) } } -void load_menu_game_new_core(void *data) +void load_menu_game_new_core(void) { - rgui_handle_t *rgui = (rgui_handle_t*)data; + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; if (!rgui) return; @@ -547,7 +562,7 @@ bool menu_iterate(void *data) return false; } - input_state = menu_input(rgui); + input_state = menu_input(); if (rgui->do_held) { @@ -643,17 +658,17 @@ bool menu_iterate(void *data) return true; } -#endif // Quite intrusive and error prone. // Likely to have lots of small bugs. // Cleanly exit the main loop to ensure that all the tiny details get set properly. // This should mitigate most of the smaller bugs. -bool menu_replace_config(void *data, const char *path) +bool menu_replace_config(const char *path) { - rgui_handle_t *rgui; + rgui_handle_t *rgui = (rgui_handle_t*)driver.menu; - rgui = (rgui_handle_t*)data; + if (!rgui) + return false; if (strcmp(path, g_extern.config_path) == 0 || !rgui) return false; diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index 747507b07b..9c311234d8 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -192,24 +192,24 @@ void menu_free(void *data); void menu_ticker_line(char *buf, size_t len, unsigned tick, const char *str, bool selected); -void load_menu_game_prepare(void *data); -void load_menu_game_prepare_dummy(void *data); -bool load_menu_game(void *data); -void load_menu_game_history(void *data, unsigned game_index); -extern void load_menu_game_new_core(void *data); -void menu_rom_history_push(void *data, const char *path, const char *core_path, +void load_menu_game_prepare(void); +void load_menu_game_prepare_dummy(void); +bool load_menu_game(void); +void load_menu_game_history(unsigned game_index); +extern void load_menu_game_new_core(void); +void menu_rom_history_push(const char *path, const char *core_path, const char *core_name); -void menu_rom_history_push_current(void *data); +void menu_rom_history_push_current(void); -bool menu_replace_config(void *data, const char *path); +bool menu_replace_config(const char *path); bool menu_save_new_config(void); int menu_defer_core(void *data, const char *dir, const char *path, char *deferred_path, size_t sizeof_deferred_path); -uint64_t menu_input(void *data); +uint64_t menu_input(void); -void menu_flush_stack_type(void *data, unsigned final_type); +void menu_flush_stack_type(unsigned final_type); void menu_update_system_info(void *data, bool *load_no_rom); void menu_build_scroll_indices(void *data, file_list_t *buf); diff --git a/frontend/platform/platform_apple.c b/frontend/platform/platform_apple.c index 31dc4c884e..704a0cb836 100644 --- a/frontend/platform/platform_apple.c +++ b/frontend/platform/platform_apple.c @@ -109,12 +109,8 @@ int apple_rarch_load_content(int argc, char* argv[]) if (rarch_main_init(argc, argv)) return 1; - driver.menu = (rgui_handle_t*)menu_init(); - - rgui = (rgui_handle_t*)driver.menu; - - if (!g_extern.libretro_dummy && rgui) - menu_rom_history_push_current(rgui); + if (!g_extern.libretro_dummy) + menu_rom_history_push_current(); g_extern.lifecycle_state |= 1ULL << MODE_GAME; diff --git a/frontend/platform/platform_emscripten.c b/frontend/platform/platform_emscripten.c index 2be95c0b59..6665cef1b6 100644 --- a/frontend/platform/platform_emscripten.c +++ b/frontend/platform/platform_emscripten.c @@ -45,13 +45,12 @@ int main(int argc, char *argv[]) if ((init_ret = rarch_main_init(argc, argv))) return init_ret; #ifdef HAVE_MENU - menu_init(driver.menu); g_extern.lifecycle_state |= 1ULL << MODE_GAME; // If we started a ROM directly from command line, // push it to ROM history. if (!g_extern.libretro_dummy) - menu_rom_history_push_current(driver.menu); + menu_rom_history_push_current(); #endif emscripten_set_main_loop(emscripten_mainloop, g_settings.video.vsync ? 0 : INT_MAX, 1);