From 44938ed1ef61c98b1e53b2e20a63e929b0168a77 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 7 Jun 2015 23:26:29 +0200 Subject: [PATCH] Fix Load Content (Detect Core) --- menu/menu_displaylist.c | 9 +++++++-- menu/menu_displaylist.h | 1 + menu/menu_entries_cbs_deferred_push.c | 9 ++++++++- menu/menu_entries_cbs_ok.c | 26 ++++++++++++++++++++++++++ menu/menu_hash.h | 1 + 5 files changed, 43 insertions(+), 3 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 4bd6d10200..fe029f305f 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1965,6 +1965,7 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) need_push = true; break; case DISPLAYLIST_CORES_SUPPORTED: + case DISPLAYLIST_CORES_COLLECTION_SUPPORTED: menu_list_clear(info->list); need_sort = true; need_refresh = true; @@ -1985,8 +1986,12 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) for (i = 0; i < list_size; i++) { - menu_list_push(info->list, core_info[i].path, "", - MENU_FILE_CORE, 0); + if (type == DISPLAYLIST_CORES_COLLECTION_SUPPORTED) + menu_list_push(info->list, core_info[i].path, "", + MENU_FILE_CORE, 0); + else + menu_list_push(info->list, core_info[i].path, "detect_core_list_ok", + MENU_FILE_CORE, 0); menu_list_set_alt_at_offset(info->list, i, core_info[i].display_name); } diff --git a/menu/menu_displaylist.h b/menu/menu_displaylist.h index 06b6d5b915..0e4d4543d2 100644 --- a/menu/menu_displaylist.h +++ b/menu/menu_displaylist.h @@ -44,6 +44,7 @@ enum DISPLAYLIST_DEFAULT, DISPLAYLIST_CORES, DISPLAYLIST_CORES_SUPPORTED, + DISPLAYLIST_CORES_COLLECTION_SUPPORTED, DISPLAYLIST_CORES_UPDATER, DISPLAYLIST_CORES_DETECTED, DISPLAYLIST_CORE_OPTIONS, diff --git a/menu/menu_entries_cbs_deferred_push.c b/menu/menu_entries_cbs_deferred_push.c index 3939240ca9..64724159a2 100644 --- a/menu/menu_entries_cbs_deferred_push.c +++ b/menu/menu_entries_cbs_deferred_push.c @@ -63,6 +63,11 @@ static int deferred_push_core_list_deferred(menu_displaylist_info_t *info) return menu_displaylist_push_list(info, DISPLAYLIST_CORES_SUPPORTED); } +static int deferred_push_core_collection_list_deferred(menu_displaylist_info_t *info) +{ + return menu_displaylist_push_list(info, DISPLAYLIST_CORES_COLLECTION_SUPPORTED); +} + static int deferred_push_database_manager_list_deferred(menu_displaylist_info_t *info) { strlcpy(info->path_b, info->path, sizeof(info->path_b)); @@ -511,9 +516,11 @@ static int menu_entries_cbs_init_bind_deferred_push_compare_type(menu_file_list_ cbs->action_deferred_push = deferred_push_management_options; break; case MENU_LABEL_DEFERRED_CORE_LIST: - case MENU_LABEL_DEFERRED_CORE_LIST_SET: cbs->action_deferred_push = deferred_push_core_list_deferred; break; + case MENU_LABEL_DEFERRED_CORE_LIST_SET: + cbs->action_deferred_push = deferred_push_core_collection_list_deferred; + break; case MENU_LABEL_DEFERRED_VIDEO_FILTER: cbs->action_deferred_push = deferred_push_video_filter; break; diff --git a/menu/menu_entries_cbs_ok.c b/menu/menu_entries_cbs_ok.c index 9f8e935368..c64c249f0c 100644 --- a/menu/menu_entries_cbs_ok.c +++ b/menu/menu_entries_cbs_ok.c @@ -31,6 +31,7 @@ #include "../input/input_remapping.h" /* FIXME - Global variables, refactor */ +static char detect_content_path[PATH_MAX_LENGTH]; unsigned rdb_entry_start_game_selection_ptr; size_t hack_shader_pass = 0; #ifdef HAVE_NETWORKING @@ -60,6 +61,7 @@ static int action_ok_file_load_with_detect_core(const char *path, if (!menu) return -1; + menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); @@ -67,6 +69,9 @@ static int action_ok_file_load_with_detect_core(const char *path, menu_path, path, label, menu->deferred_path, sizeof(menu->deferred_path)); + fill_pathname_join(detect_content_path, menu_path, path, + sizeof(detect_content_path)); + if (ret == -1) { switch (hash_label) @@ -111,6 +116,24 @@ static int action_ok_file_load_with_detect_core(const char *path, return ret; } +static int action_ok_file_load_detect_core(const char *path, + const char *label, unsigned type, size_t idx) +{ + menu_handle_t *menu = menu_driver_get_ptr(); + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + + if (!menu) + return -1; + + strlcpy(global->fullpath, detect_content_path, sizeof(global->fullpath)); + strlcpy(settings->libretro, path, sizeof(settings->libretro)); + event_command(EVENT_CMD_LOAD_CORE); + menu_entries_common_load_content(false); + + return -1; +} + static int action_ok_playlist_entry(const char *path, const char *label, unsigned type, size_t idx) { @@ -1542,6 +1565,9 @@ static int menu_entries_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs case MENU_LABEL_DETECT_CORE_LIST: cbs->action_ok = action_ok_push_content_list; break; + case MENU_LABEL_DETECT_CORE_LIST_OK: + cbs->action_ok = action_ok_file_load_detect_core; + break; case MENU_LABEL_HISTORY_LIST: case MENU_LABEL_CURSOR_MANAGER_LIST: case MENU_LABEL_DATABASE_MANAGER_LIST: diff --git a/menu/menu_hash.h b/menu/menu_hash.h index 23040a8f23..5f4fb2fc7c 100644 --- a/menu/menu_hash.h +++ b/menu/menu_hash.h @@ -192,6 +192,7 @@ extern "C" { #define MENU_LABEL_CONTENT_ACTIONS 0xa0d76970U #define MENU_LABEL_DETECT_CORE_LIST 0xaa07c341U +#define MENU_LABEL_DETECT_CORE_LIST_OK 0xabba2a7aU #define MENU_LABEL_LOAD_CONTENT 0x5745de1fU #define MENU_LABEL_CORE_UPDATER_LIST 0x0372767dU #define MENU_LABEL_RECORD_CONFIG 0x11c3daf9U