From 597e0ce1ec500bd9f57a91f052b95309b3922635 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 10 Feb 2018 19:08:39 -0500 Subject: [PATCH 01/13] subsystem part 1: get the required data to load content --- content.h | 14 ++++++++++++++ intl/msg_hash_lbl.h | 2 ++ menu/cbs/menu_cbs_ok.c | 31 +++++++++++++++++++++++++++++++ menu/drivers/xmb.c | 18 ++++++++++++++++++ menu/menu_cbs.h | 1 + menu/menu_driver.h | 4 ++++ menu/widgets/menu_filebrowser.c | 21 ++++++++++++++++++++- menu/widgets/menu_filebrowser.h | 1 + msg_hash.h | 4 ++++ tasks/task_content.c | 16 ++++++++++++++++ 10 files changed, 111 insertions(+), 1 deletion(-) diff --git a/content.h b/content.h index caa641b895..495cef8a3f 100644 --- a/content.h +++ b/content.h @@ -25,6 +25,7 @@ #include #include +#include #include "frontend/frontend_driver.h" @@ -38,6 +39,12 @@ typedef struct content_ctx_info environment_get_t environ_get; /* Function passed for environment_get function */ } content_ctx_info_t; +int pending_subsystem; +int pending_subsystem_rom_id; + +char pending_subsystem_extensions[PATH_MAX_LENGTH]; +char pending_subsystem_roms[RARCH_MAX_SUBSYSTEM_ROMS][PATH_MAX_LENGTH]; + /* Load a RAM state from disk to memory. */ bool content_load_ram_file(unsigned slot); @@ -81,6 +88,13 @@ bool content_reset_savestate_backups(void); bool content_undo_load_buf_is_empty(void); bool content_undo_save_buf_is_empty(void); +/* Clears the pending subsystem rom buffer*/ +void content_clear_subsystem(void); + +/* Add a rom to the subsystem rom buffer */ +void content_add_subsystem(const char* path); + + RETRO_END_DECLS #endif diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index f895fd074e..2fe5708977 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -361,6 +361,8 @@ MSG_HASH(MENU_ENUM_LABEL_DISK_CYCLE_TRAY_STATUS, "disk_cycle_tray_status") MSG_HASH(MENU_ENUM_LABEL_DISK_IMAGE_APPEND, "disk_image_append") +MSG_HASH(MENU_ENUM_LABEL_SUBSYSTEM_ADD, + "subsystem_add") MSG_HASH(MENU_ENUM_LABEL_DISK_OPTIONS, "core_disk_options") MSG_HASH(MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST, diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index b574aaa93f..b9bae967e2 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -64,6 +64,7 @@ enum ACTION_OK_LOAD_REMAPPING_FILE, ACTION_OK_LOAD_CHEAT_FILE, ACTION_OK_APPEND_DISK_IMAGE, + ACTION_OK_SUBSYSTEM_ADD, ACTION_OK_LOAD_CONFIG_FILE, ACTION_OK_LOAD_CORE, ACTION_OK_LOAD_WALLPAPER, @@ -443,6 +444,18 @@ int generic_action_ok_displaylist_push(const char *path, info_label = label; dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE; break; + case ACTION_OK_DL_SUBSYSTEM_ADD_LIST: + filebrowser_clear_type(); + if (pending_subsystem != type - MENU_SETTINGS_SUBSYSTEM_ADD) + content_clear_subsystem(); + pending_subsystem = type - MENU_SETTINGS_SUBSYSTEM_ADD; + filebrowser_set_type(FILEBROWSER_SELECT_FILE_SUBSYSTEM); + info.type = type; + info.directory_ptr = idx; + info_path = settings->paths.directory_menu_content; + info_label = label; + dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE; + break; case ACTION_OK_DL_CHEAT_FILE: filebrowser_clear_type(); info.type = type; @@ -1168,6 +1181,10 @@ static int generic_action_ok(const char *path, command_event(CMD_EVENT_DISK_APPEND_IMAGE, action_path); generic_action_ok_command(CMD_EVENT_RESUME); break; + case ACTION_OK_SUBSYSTEM_ADD: + flush_type = MENU_SETTINGS; + content_add_subsystem(action_path); + break; case ACTION_OK_SET_DIRECTORY: flush_char = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DIRECTORY_SETTINGS_LIST); ret = set_path_generic(filebrowser_label, action_path); @@ -1246,6 +1263,7 @@ default_action_ok_set(action_ok_set_path, ACTION_OK_SET_PATH, default_action_ok_set(action_ok_load_core, ACTION_OK_LOAD_CORE, MSG_UNKNOWN) default_action_ok_set(action_ok_config_load, ACTION_OK_LOAD_CONFIG_FILE, MSG_UNKNOWN) default_action_ok_set(action_ok_disk_image_append, ACTION_OK_APPEND_DISK_IMAGE, MSG_UNKNOWN) +default_action_ok_set(action_ok_subsystem_add, ACTION_OK_SUBSYSTEM_ADD, MSG_UNKNOWN) default_action_ok_set(action_ok_cheat_file_load, ACTION_OK_LOAD_CHEAT_FILE, MENU_ENUM_LABEL_CORE_CHEAT_OPTIONS) default_action_ok_set(action_ok_record_configfile_load, ACTION_OK_LOAD_RECORD_CONFIGFILE, MENU_ENUM_LABEL_RECORDING_SETTINGS) default_action_ok_set(action_ok_remap_file_load, ACTION_OK_LOAD_REMAPPING_FILE, MENU_ENUM_LABEL_CORE_INPUT_REMAPPING_OPTIONS ) @@ -2972,6 +2990,7 @@ default_action_ok_func(action_ok_core_list, ACTION_OK_DL_CORE_LIST) default_action_ok_func(action_ok_cheat_file, ACTION_OK_DL_CHEAT_FILE) default_action_ok_func(action_ok_playlist_collection, ACTION_OK_DL_PLAYLIST_COLLECTION) default_action_ok_func(action_ok_disk_image_append_list, ACTION_OK_DL_DISK_IMAGE_APPEND_LIST) +default_action_ok_func(action_ok_subsystem_add_list, ACTION_OK_DL_SUBSYSTEM_ADD_LIST) default_action_ok_func(action_ok_record_configfile, ACTION_OK_DL_RECORD_CONFIGFILE) default_action_ok_func(action_ok_remap_file, ACTION_OK_DL_REMAP_FILE) default_action_ok_func(action_ok_shader_preset, ACTION_OK_DL_SHADER_PRESET) @@ -4088,6 +4107,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_DISK_IMAGE_APPEND: BIND_ACTION_OK(cbs, action_ok_disk_image_append_list); break; + case MENU_ENUM_LABEL_SUBSYSTEM_ADD: + BIND_ACTION_OK(cbs, action_ok_subsystem_add_list); + break; case MENU_ENUM_LABEL_CONFIGURATIONS: BIND_ACTION_OK(cbs, action_ok_configurations_list); break; @@ -4282,6 +4304,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DISK_IMAGE_APPEND: BIND_ACTION_OK(cbs, action_ok_disk_image_append_list); break; + case MENU_LABEL_SUBSYSTEM_ADD: + BIND_ACTION_OK(cbs, action_ok_subsystem_add_list); + break; case MENU_LABEL_SCREEN_RESOLUTION: BIND_ACTION_OK(cbs, action_ok_video_resolution); break; @@ -4526,6 +4551,9 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_DISK_IMAGE_APPEND: BIND_ACTION_OK(cbs, action_ok_disk_image_append); break; + case MENU_ENUM_LABEL_SUBSYSTEM_ADD: + BIND_ACTION_OK(cbs, action_ok_subsystem_add); + break; default: BIND_ACTION_OK(cbs, action_ok_file_load); break; @@ -4552,6 +4580,9 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, case MENU_LABEL_DISK_IMAGE_APPEND: BIND_ACTION_OK(cbs, action_ok_disk_image_append); break; + case MENU_LABEL_SUBSYSTEM_ADD: + BIND_ACTION_OK(cbs, action_ok_subsystem_add); + break; default: BIND_ACTION_OK(cbs, action_ok_file_load); break; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index a3829eb651..b77a5ec19e 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -4340,6 +4340,8 @@ static int xmb_list_push(void *data, void *userdata, { menu_displaylist_ctx_parse_entry_t entry; int ret = -1; + int i = 0; + int j = 0; core_info_list_t *list = NULL; menu_handle_t *menu = (menu_handle_t*)data; @@ -4435,6 +4437,22 @@ static int xmb_list_push(void *data, void *userdata, { entry.enum_idx = MENU_ENUM_LABEL_LOAD_CONTENT_LIST; menu_displaylist_ctl(DISPLAYLIST_SETTING_ENUM, &entry); + + const struct retro_subsystem_info* subsystem = NULL; + subsystem = system->subsystem.data; + if (subsystem) + { + for (i = 0; i < system->subsystem.size; i++, subsystem++) + { + char s[PATH_MAX_LENGTH]; + snprintf(s, sizeof(s), "Load: %s %c", subsystem->desc, i == pending_subsystem ? '*': ' '); + menu_entries_append_enum(info->list, + s, + msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), + MENU_ENUM_LABEL_SUBSYSTEM_ADD, + MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); + } + } } entry.enum_idx = MENU_ENUM_LABEL_ADD_CONTENT_LIST; diff --git a/menu/menu_cbs.h b/menu/menu_cbs.h index a0949104ba..befc9c9a18 100644 --- a/menu/menu_cbs.h +++ b/menu/menu_cbs.h @@ -84,6 +84,7 @@ enum ACTION_OK_DL_REMAP_FILE, ACTION_OK_DL_RECORD_CONFIGFILE, ACTION_OK_DL_DISK_IMAGE_APPEND_LIST, + ACTION_OK_DL_SUBSYSTEM_ADD_LIST, ACTION_OK_DL_PLAYLIST_COLLECTION, ACTION_OK_DL_CONTENT_COLLECTION_LIST, ACTION_OK_DL_CHEAT_FILE, diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 0eb30e254a..00d04dcdd3 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -208,6 +208,10 @@ enum menu_settings_type MENU_SETTINGS_INPUT_DESC_END = MENU_SETTINGS_INPUT_DESC_BEGIN + (MAX_USERS * (RARCH_FIRST_CUSTOM_BIND + 4)), MENU_SETTINGS_INPUT_DESC_KBD_BEGIN, MENU_SETTINGS_INPUT_DESC_KBD_END = MENU_SETTINGS_INPUT_DESC_KBD_BEGIN + 135, + + MENU_SETTINGS_SUBSYSTEM_ADD, + MENU_SETTINGS_SUBSYSTEM_LAST = MENU_SETTINGS_SUBSYSTEM_ADD + RARCH_MAX_SUBSYSTEMS, + MENU_SETTINGS_LAST }; diff --git a/menu/widgets/menu_filebrowser.c b/menu/widgets/menu_filebrowser.c index e9aecd041e..5545a52d07 100644 --- a/menu/widgets/menu_filebrowser.c +++ b/menu/widgets/menu_filebrowser.c @@ -35,6 +35,11 @@ #include "../../configuration.h" #include "../../paths.h" +#include "../../retroarch.h" +#include "../../core.h" +#include "../../content.h" +#include "../../verbosity.h" + static enum filebrowser_enums filebrowser_types = FILEBROWSER_NONE; enum filebrowser_enums filebrowser_get_type(void) @@ -75,10 +80,24 @@ void filebrowser_parse(void *data, unsigned type_data) if (info && path_is_compressed) str_list = file_archive_get_file_list(path, info->exts); - else if (!string_is_empty(path)) + else if (!string_is_empty(path) && filebrowser_types != FILEBROWSER_SELECT_FILE_SUBSYSTEM) str_list = dir_list_new(path, (filter_ext && info) ? info->exts : NULL, true, settings->bools.show_hidden_files, true, false); + else if (!string_is_empty(path) && filebrowser_types == FILEBROWSER_SELECT_FILE_SUBSYSTEM) + { + rarch_system_info_t *system = runloop_get_system_info(); + const struct retro_subsystem_info* subsystem = NULL; + subsystem = system->subsystem.data + pending_subsystem; + if (subsystem) + { + RARCH_LOG("[subsystem] valid xtensions: %s\n", subsystem->roms[pending_subsystem_rom_id].valid_extensions); + str_list = dir_list_new(path, + (filter_ext && info) ? subsystem->roms[pending_subsystem_rom_id].valid_extensions : NULL, + true, settings->bools.show_hidden_files, true, false); + } + + } switch (filebrowser_types) { diff --git a/menu/widgets/menu_filebrowser.h b/menu/widgets/menu_filebrowser.h index b5656549dc..3a5d097592 100644 --- a/menu/widgets/menu_filebrowser.h +++ b/menu/widgets/menu_filebrowser.h @@ -31,6 +31,7 @@ enum filebrowser_enums FILEBROWSER_SCAN_DIR, FILEBROWSER_SCAN_FILE, FILEBROWSER_SELECT_FILE, + FILEBROWSER_SELECT_FILE_SUBSYSTEM, FILEBROWSER_SELECT_IMAGE, FILEBROWSER_SELECT_FONT, FILEBROWSER_SELECT_COLLECTION diff --git a/msg_hash.h b/msg_hash.h index 2caddc1745..6856a60f48 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1385,6 +1385,7 @@ enum msg_hash_enums MENU_LABEL(SHUTDOWN), MENU_LABEL(REBOOT), MENU_LABEL(DISK_IMAGE_APPEND), + MENU_LABEL(SUBSYSTEM_ADD), MENU_LABEL(CORE_LIST), MENU_LABEL(MANAGEMENT), MENU_LABEL(ONLINE), @@ -1849,6 +1850,9 @@ enum msg_hash_enums #define MENU_LABEL_DISK_OPTIONS 0xc61ab5fbU #define MENU_LABEL_DISK_IMAGE_APPEND 0x5af7d709U +/* Subsystem stuff */ +#define MENU_LABEL_SUBSYSTEM_ADD 0x576da67cU + /* Menu settings */ #define MENU_LABEL_MENU_WALLPAPER 0x3b84de01U diff --git a/tasks/task_content.c b/tasks/task_content.c index 946bb0b44f..365ff6936d 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1670,6 +1670,22 @@ void content_get_status( *is_inited = _content_is_inited; } +/* Clears the pending subsystem rom buffer*/ +void content_clear_subsystem(void) +{ + pending_subsystem_rom_id = 0; + for (int i = 0; i < RARCH_MAX_SUBSYSTEM_ROMS; i++) + pending_subsystem_roms[i][0] = '\0'; +} + +/* Add a rom to the subsystem rom buffer */ +void content_add_subsystem(const char* path) +{ + strlcpy(pending_subsystem_roms[pending_subsystem_rom_id], path, sizeof(pending_subsystem_roms[pending_subsystem_rom_id])); + RARCH_LOG("[subsystem] subsystem id: %d rom id: %d, rom path: %s\n", pending_subsystem, pending_subsystem_rom_id, pending_subsystem_roms[pending_subsystem_rom_id]); + pending_subsystem_rom_id++; +} + void content_set_does_not_need_content(void) { core_does_not_need_content = true; From 788bb4de50551e48942cdb6cbe2a11766188e78d Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 10 Feb 2018 19:46:15 -0500 Subject: [PATCH 02/13] subsystem part 1: proper labels for each entry --- .vscode/settings.json | 3 ++- menu/cbs/menu_cbs_sublabel.c | 22 ++++++++++++++++++++ menu/drivers/xmb.c | 37 +++++++++++++++++++++++++++------ menu/widgets/menu_filebrowser.c | 2 +- 4 files changed, 56 insertions(+), 8 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index e90ca77e4a..ee551d7617 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,6 +12,7 @@ "files.associations": { "frontend_driver.h": "c", "*.in": "c", - "*.rh": "c" + "*.rh": "c", + "menu_driver.h": "c" }, } \ No newline at end of file diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 4210b08fe9..2bbc492b04 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -37,6 +37,9 @@ #include "../../network/netplay/netplay_discovery.h" #endif +#include "../../retroarch.h" +#include "../../content.h" + #define default_sublabel_macro(func_name, lbl) \ static int (func_name)(file_list_t *list, unsigned type, unsigned i, const char *label, const char *path, char *s, size_t len) \ { \ @@ -396,6 +399,22 @@ static int action_bind_sublabel_cheevos_entry( return 0; } +static int action_bind_sublabel_subsystem_add( + file_list_t *list, + unsigned type, unsigned i, + const char *label, const char *path, + char *s, size_t len) +{ + rarch_system_info_t *system = runloop_get_system_info(); + const struct retro_subsystem_info* subsystem = NULL; + subsystem = system->subsystem.data + (type - MENU_SETTINGS_SUBSYSTEM_ADD); + if (subsystem && pending_subsystem_rom_id < subsystem->num_roms) + snprintf(s, len, " Current Content: %s", pending_subsystem == type - MENU_SETTINGS_SUBSYSTEM_ADD ? subsystem->roms[pending_subsystem_rom_id].desc : subsystem->roms[0].desc); + return 0; +} + + + #ifdef HAVE_NETWORKING static int action_bind_sublabel_netplay_room( file_list_t *list, @@ -744,6 +763,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_DISK_IMAGE_APPEND: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_disk_image_append); break; + case MENU_ENUM_LABEL_SUBSYSTEM_ADD: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_subsystem_add); + break; case MENU_ENUM_LABEL_DISK_CYCLE_TRAY_STATUS: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_disk_cycle_tray_status); break; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index b77a5ec19e..9b85bbc773 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -4445,12 +4445,37 @@ static int xmb_list_push(void *data, void *userdata, for (i = 0; i < system->subsystem.size; i++, subsystem++) { char s[PATH_MAX_LENGTH]; - snprintf(s, sizeof(s), "Load: %s %c", subsystem->desc, i == pending_subsystem ? '*': ' '); - menu_entries_append_enum(info->list, - s, - msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), - MENU_ENUM_LABEL_SUBSYSTEM_ADD, - MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); + if (pending_subsystem == i) + { + if (pending_subsystem_rom_id < subsystem->num_roms) + { + snprintf(s, sizeof(s), "Load %s %c", subsystem->desc, i == pending_subsystem ? '*': ' '); + menu_entries_append_enum(info->list, + s, + msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), + MENU_ENUM_LABEL_SUBSYSTEM_ADD, + MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); + } + else + { + /* To-Do: replace the MENU_ENUM_LABEL_SUBSYSTEM_ADD for the proper labels and trigger the load action */ + snprintf(s, sizeof(s), "Start %s %c", subsystem->desc, i == pending_subsystem ? '*': ' '); + menu_entries_append_enum(info->list, + s, + msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), + MENU_ENUM_LABEL_SUBSYSTEM_ADD, + MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); + } + } + else + { + snprintf(s, sizeof(s), "Load %s %c", subsystem->desc, i == pending_subsystem ? '*': ' '); + menu_entries_append_enum(info->list, + s, + msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), + MENU_ENUM_LABEL_SUBSYSTEM_ADD, + MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); + } } } } diff --git a/menu/widgets/menu_filebrowser.c b/menu/widgets/menu_filebrowser.c index 5545a52d07..9431280080 100644 --- a/menu/widgets/menu_filebrowser.c +++ b/menu/widgets/menu_filebrowser.c @@ -89,7 +89,7 @@ void filebrowser_parse(void *data, unsigned type_data) rarch_system_info_t *system = runloop_get_system_info(); const struct retro_subsystem_info* subsystem = NULL; subsystem = system->subsystem.data + pending_subsystem; - if (subsystem) + if (subsystem && pending_subsystem_rom_id < subsystem->num_roms) { RARCH_LOG("[subsystem] valid xtensions: %s\n", subsystem->roms[pending_subsystem_rom_id].valid_extensions); str_list = dir_list_new(path, From 1951adeb5ba3791da141a51ca147324a37b7ce24 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 10 Feb 2018 20:23:24 -0500 Subject: [PATCH 03/13] subsystem part 2: add LABELS --- .vscode/settings.json | 3 +-- intl/msg_hash_lbl.h | 2 ++ menu/cbs/menu_cbs_ok.c | 8 ++++++++ menu/drivers/xmb.c | 8 ++++---- menu/menu_cbs.h | 1 + menu/menu_driver.h | 2 ++ msg_hash.h | 1 + 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ee551d7617..e90ca77e4a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,7 +12,6 @@ "files.associations": { "frontend_driver.h": "c", "*.in": "c", - "*.rh": "c", - "menu_driver.h": "c" + "*.rh": "c" }, } \ No newline at end of file diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 2fe5708977..1cbf32f46f 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -363,6 +363,8 @@ MSG_HASH(MENU_ENUM_LABEL_DISK_IMAGE_APPEND, "disk_image_append") MSG_HASH(MENU_ENUM_LABEL_SUBSYSTEM_ADD, "subsystem_add") +MSG_HASH(MENU_ENUM_LABEL_SUBSYSTEM_LOAD, + "subsystem_load") MSG_HASH(MENU_ENUM_LABEL_DISK_OPTIONS, "core_disk_options") MSG_HASH(MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST, diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index b9bae967e2..61f5211668 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -456,6 +456,10 @@ int generic_action_ok_displaylist_push(const char *path, info_label = label; dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE; break; + case ACTION_OK_DL_SUBSYSTEM_LOAD: + filebrowser_clear_type(); + RARCH_LOG("LOADING!!!!!!!\n"); + break; case ACTION_OK_DL_CHEAT_FILE: filebrowser_clear_type(); info.type = type; @@ -2991,6 +2995,7 @@ default_action_ok_func(action_ok_cheat_file, ACTION_OK_DL_CHEAT_FILE) default_action_ok_func(action_ok_playlist_collection, ACTION_OK_DL_PLAYLIST_COLLECTION) default_action_ok_func(action_ok_disk_image_append_list, ACTION_OK_DL_DISK_IMAGE_APPEND_LIST) default_action_ok_func(action_ok_subsystem_add_list, ACTION_OK_DL_SUBSYSTEM_ADD_LIST) +default_action_ok_func(action_ok_subsystem_add_load, ACTION_OK_DL_SUBSYSTEM_LOAD) default_action_ok_func(action_ok_record_configfile, ACTION_OK_DL_RECORD_CONFIGFILE) default_action_ok_func(action_ok_remap_file, ACTION_OK_DL_REMAP_FILE) default_action_ok_func(action_ok_shader_preset, ACTION_OK_DL_SHADER_PRESET) @@ -4110,6 +4115,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_SUBSYSTEM_ADD: BIND_ACTION_OK(cbs, action_ok_subsystem_add_list); break; + case MENU_ENUM_LABEL_SUBSYSTEM_LOAD: + BIND_ACTION_OK(cbs, action_ok_subsystem_add_load); + break; case MENU_ENUM_LABEL_CONFIGURATIONS: BIND_ACTION_OK(cbs, action_ok_configurations_list); break; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 9b85bbc773..7852ef827f 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -4462,9 +4462,9 @@ static int xmb_list_push(void *data, void *userdata, snprintf(s, sizeof(s), "Start %s %c", subsystem->desc, i == pending_subsystem ? '*': ' '); menu_entries_append_enum(info->list, s, - msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), - MENU_ENUM_LABEL_SUBSYSTEM_ADD, - MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); + msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_LOAD), + MENU_ENUM_LABEL_SUBSYSTEM_LOAD, + MENU_SETTINGS_SUBSYSTEM_LOAD, 0, 0); } } else @@ -4474,7 +4474,7 @@ static int xmb_list_push(void *data, void *userdata, s, msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), MENU_ENUM_LABEL_SUBSYSTEM_ADD, - MENU_SETTINGS_SUBSYSTEM_ADD + i, 0, 0); + MENU_SETTINGS_SUBSYSTEM_ADD, 0, 0); } } } diff --git a/menu/menu_cbs.h b/menu/menu_cbs.h index befc9c9a18..8aeac420f3 100644 --- a/menu/menu_cbs.h +++ b/menu/menu_cbs.h @@ -85,6 +85,7 @@ enum ACTION_OK_DL_RECORD_CONFIGFILE, ACTION_OK_DL_DISK_IMAGE_APPEND_LIST, ACTION_OK_DL_SUBSYSTEM_ADD_LIST, + ACTION_OK_DL_SUBSYSTEM_LOAD, ACTION_OK_DL_PLAYLIST_COLLECTION, ACTION_OK_DL_CONTENT_COLLECTION_LIST, ACTION_OK_DL_CHEAT_FILE, diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 00d04dcdd3..52610af733 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -209,6 +209,8 @@ enum menu_settings_type MENU_SETTINGS_INPUT_DESC_KBD_BEGIN, MENU_SETTINGS_INPUT_DESC_KBD_END = MENU_SETTINGS_INPUT_DESC_KBD_BEGIN + 135, + MENU_SETTINGS_SUBSYSTEM_LOAD, + MENU_SETTINGS_SUBSYSTEM_ADD, MENU_SETTINGS_SUBSYSTEM_LAST = MENU_SETTINGS_SUBSYSTEM_ADD + RARCH_MAX_SUBSYSTEMS, diff --git a/msg_hash.h b/msg_hash.h index 6856a60f48..a989f98fcb 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1386,6 +1386,7 @@ enum msg_hash_enums MENU_LABEL(REBOOT), MENU_LABEL(DISK_IMAGE_APPEND), MENU_LABEL(SUBSYSTEM_ADD), + MENU_LABEL(SUBSYSTEM_LOAD), MENU_LABEL(CORE_LIST), MENU_LABEL(MANAGEMENT), MENU_LABEL(ONLINE), From 692c8683b26de8ad543d73e413ca248339985bfe Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 10 Feb 2018 20:49:23 -0500 Subject: [PATCH 04/13] subsystem part 2: add missing define, fix typo --- libretro-common/include/retro_miscellaneous.h | 3 +++ menu/widgets/menu_filebrowser.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index e526d6ebc2..23f9ef02ac 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -23,6 +23,9 @@ #ifndef __RARCH_MISCELLANEOUS_H #define __RARCH_MISCELLANEOUS_H +#define RARCH_MAX_SUBSYSTEMS 10 +#define RARCH_MAX_SUBSYSTEM_ROMS 10 + #include #include #include diff --git a/menu/widgets/menu_filebrowser.c b/menu/widgets/menu_filebrowser.c index 9431280080..bcfec67fa7 100644 --- a/menu/widgets/menu_filebrowser.c +++ b/menu/widgets/menu_filebrowser.c @@ -91,7 +91,7 @@ void filebrowser_parse(void *data, unsigned type_data) subsystem = system->subsystem.data + pending_subsystem; if (subsystem && pending_subsystem_rom_id < subsystem->num_roms) { - RARCH_LOG("[subsystem] valid xtensions: %s\n", subsystem->roms[pending_subsystem_rom_id].valid_extensions); + RARCH_LOG("[subsystem] valid extensions: %s\n", subsystem->roms[pending_subsystem_rom_id].valid_extensions); str_list = dir_list_new(path, (filter_ext && info) ? subsystem->roms[pending_subsystem_rom_id].valid_extensions : NULL, true, settings->bools.show_hidden_files, true, false); From b212640732651f52425fb276a8180e57e02337b4 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 10 Feb 2018 21:05:41 -0500 Subject: [PATCH 05/13] subsystem part 2: add a wrapper to set the current subsystem --- content.h | 4 ++++ menu/cbs/menu_cbs_ok.c | 2 +- tasks/task_content.c | 14 +++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/content.h b/content.h index 495cef8a3f..43b6298418 100644 --- a/content.h +++ b/content.h @@ -42,6 +42,7 @@ typedef struct content_ctx_info int pending_subsystem; int pending_subsystem_rom_id; +char pending_subsystem_ident[255]; char pending_subsystem_extensions[PATH_MAX_LENGTH]; char pending_subsystem_roms[RARCH_MAX_SUBSYSTEM_ROMS][PATH_MAX_LENGTH]; @@ -91,6 +92,9 @@ bool content_undo_save_buf_is_empty(void); /* Clears the pending subsystem rom buffer*/ void content_clear_subsystem(void); +/* Set the current subsystem*/ +void content_set_subsystem(unsigned subsystem); + /* Add a rom to the subsystem rom buffer */ void content_add_subsystem(const char* path); diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 61f5211668..fc227f8247 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -448,7 +448,7 @@ int generic_action_ok_displaylist_push(const char *path, filebrowser_clear_type(); if (pending_subsystem != type - MENU_SETTINGS_SUBSYSTEM_ADD) content_clear_subsystem(); - pending_subsystem = type - MENU_SETTINGS_SUBSYSTEM_ADD; + content_set_subsystem(type - MENU_SETTINGS_SUBSYSTEM_ADD); filebrowser_set_type(FILEBROWSER_SELECT_FILE_SUBSYSTEM); info.type = type; info.directory_ptr = idx; diff --git a/tasks/task_content.c b/tasks/task_content.c index 365ff6936d..a182e88c7a 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1678,11 +1678,23 @@ void content_clear_subsystem(void) pending_subsystem_roms[i][0] = '\0'; } +/* Set the current subsystem*/ +void content_set_subsystem(unsigned sub) +{ + rarch_system_info_t *system = runloop_get_system_info(); + const struct retro_subsystem_info* subsystem = NULL; + + pending_subsystem = sub; + subsystem = system->subsystem.data + pending_subsystem; + + strlcpy(pending_subsystem_ident, subsystem->ident, sizeof(pending_subsystem_ident)); +} + /* Add a rom to the subsystem rom buffer */ void content_add_subsystem(const char* path) { strlcpy(pending_subsystem_roms[pending_subsystem_rom_id], path, sizeof(pending_subsystem_roms[pending_subsystem_rom_id])); - RARCH_LOG("[subsystem] subsystem id: %d rom id: %d, rom path: %s\n", pending_subsystem, pending_subsystem_rom_id, pending_subsystem_roms[pending_subsystem_rom_id]); + RARCH_LOG("[subsystem] subsystem id: %d subsystem ident: %s rom id: %d, rom path: %s\n", pending_subsystem, pending_subsystem_ident, pending_subsystem_rom_id, pending_subsystem_roms[pending_subsystem_rom_id]); pending_subsystem_rom_id++; } From 752e729ec2193db9929f715f650e91c9785b867f Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 10 Feb 2018 21:42:41 -0500 Subject: [PATCH 06/13] subsystem part 2: set paths --- content.h | 1 + menu/cbs/menu_cbs_ok.c | 3 ++- tasks/task_content.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/content.h b/content.h index 43b6298418..8111a41cad 100644 --- a/content.h +++ b/content.h @@ -41,6 +41,7 @@ typedef struct content_ctx_info int pending_subsystem; int pending_subsystem_rom_id; +int pending_subsystem_rom_num; char pending_subsystem_ident[255]; char pending_subsystem_extensions[PATH_MAX_LENGTH]; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index fc227f8247..1152d04992 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -458,7 +458,8 @@ int generic_action_ok_displaylist_push(const char *path, break; case ACTION_OK_DL_SUBSYSTEM_LOAD: filebrowser_clear_type(); - RARCH_LOG("LOADING!!!!!!!\n"); + path_set(RARCH_PATH_SUBSYSTEM, pending_subsystem_ident); + path_set_special((char**)pending_subsystem_roms, pending_subsystem_rom_num); break; case ACTION_OK_DL_CHEAT_FILE: filebrowser_clear_type(); diff --git a/tasks/task_content.c b/tasks/task_content.c index a182e88c7a..20e4348f1c 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -776,7 +776,6 @@ static bool content_file_init( const struct retro_subsystem_info *special = path_is_empty(RARCH_PATH_SUBSYSTEM) ? NULL : content_file_init_subsystem(content_ctx, error_string, &ret); - if ( !ret || !content_file_init_set_attribs(content, special, content_ctx, error_string)) return false; @@ -788,6 +787,7 @@ static bool content_file_init( { unsigned i; struct string_list *additional_path_allocs = string_list_new(); + ret = content_file_load(info, content, content_ctx, error_string, special, additional_path_allocs); string_list_free(additional_path_allocs); @@ -1688,6 +1688,7 @@ void content_set_subsystem(unsigned sub) subsystem = system->subsystem.data + pending_subsystem; strlcpy(pending_subsystem_ident, subsystem->ident, sizeof(pending_subsystem_ident)); + pending_subsystem_rom_num = subsystem->num_roms; } /* Add a rom to the subsystem rom buffer */ From d3484528d153244cbd87825001b721f0809fbf1a Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 10 Feb 2018 22:02:19 -0500 Subject: [PATCH 07/13] subsystem part 2: load content? --- command.c | 4 ++-- command.h | 3 +++ menu/cbs/menu_cbs_ok.c | 9 ++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/command.c b/command.c index 27ebfdeb72..1d92f19e78 100644 --- a/command.c +++ b/command.c @@ -1052,7 +1052,7 @@ static void command_event_init_controllers(void) } } -static void command_event_deinit_core(bool reinit) +void command_event_deinit_core(bool reinit) { #ifdef HAVE_CHEEVOS cheevos_unload(); @@ -1205,7 +1205,7 @@ error: free(state_base); } -static bool event_init_content(void) +bool event_init_content(void) { bool contentless = false; bool is_inited = false; diff --git a/command.h b/command.h index 86efe07bb0..eebc622f7c 100644 --- a/command.h +++ b/command.h @@ -273,6 +273,9 @@ void command_playlist_update_write( const char *label, const char *path); +bool event_init_content(void); +void command_event_deinit_core(bool reinit); + RETRO_END_DECLS #endif diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 1152d04992..1454bb8996 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -459,7 +459,14 @@ int generic_action_ok_displaylist_push(const char *path, case ACTION_OK_DL_SUBSYSTEM_LOAD: filebrowser_clear_type(); path_set(RARCH_PATH_SUBSYSTEM, pending_subsystem_ident); - path_set_special((char**)pending_subsystem_roms, pending_subsystem_rom_num); + /* hardcoded to 2 for testing */ + char* roms[2] = { pending_subsystem_roms[0], pending_subsystem_roms[1] }; + path_set_special(roms, pending_subsystem_rom_num); + content_ctx_info_t content_info = {0}; + task_push_load_content_with_core_from_menu( + NULL, &content_info, + CORE_TYPE_PLAIN, NULL, NULL); + break; case ACTION_OK_DL_CHEAT_FILE: filebrowser_clear_type(); From 9730fa5c51fa8b2d59993f76e027f33ea0b899f8 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 11 Feb 2018 00:14:40 -0500 Subject: [PATCH 08/13] subsystem part 2: load content! hacky --- content.h | 2 ++ menu/cbs/menu_cbs_ok.c | 3 +- tasks/task_content.c | 68 +++++++++++++++++++++++++++++++++++++++++- tasks/tasks_internal.h | 6 ++++ 4 files changed, 77 insertions(+), 2 deletions(-) diff --git a/content.h b/content.h index 8111a41cad..33d3d1c9ba 100644 --- a/content.h +++ b/content.h @@ -39,6 +39,8 @@ typedef struct content_ctx_info environment_get_t environ_get; /* Function passed for environment_get function */ } content_ctx_info_t; +bool pending_subsystem_init; + int pending_subsystem; int pending_subsystem_rom_id; int pending_subsystem_rom_num; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 1454bb8996..3dacfb8232 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -463,7 +463,8 @@ int generic_action_ok_displaylist_push(const char *path, char* roms[2] = { pending_subsystem_roms[0], pending_subsystem_roms[1] }; path_set_special(roms, pending_subsystem_rom_num); content_ctx_info_t content_info = {0}; - task_push_load_content_with_core_from_menu( + pending_subsystem_init = true; + task_push_load_subsystem_with_core_from_menu( NULL, &content_info, CORE_TYPE_PLAIN, NULL, NULL); diff --git a/tasks/task_content.c b/tasks/task_content.c index 20e4348f1c..a8688e1ac3 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -187,7 +187,6 @@ static void content_load_init_wrap( } #endif - if (args->sram_path) { argv[(*argc)++] = strdup("-s"); @@ -235,6 +234,7 @@ static void content_load_init_wrap( **/ static bool content_load(content_ctx_info_t *info) { + RARCH_LOG("content_load\n"); unsigned i; bool retval = true; int rarch_argc = 0; @@ -272,6 +272,11 @@ static bool content_load(content_ctx_info_t *info) retval = false; goto end; } + + { + + content_init(); + } #ifdef HAVE_MENU /* TODO/FIXME - can we get rid of this? */ @@ -861,6 +866,8 @@ static bool task_load_content(content_ctx_info_t *content_info, return false; } + + content_get_status(&contentless, &is_inited); /* Push entry to top of history playlist */ @@ -1472,6 +1479,7 @@ static bool task_load_content_callback(content_ctx_info_t *content_info, char *error_string = NULL; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); + struct string_list *content = NULL; content_ctx.check_firmware_before_loading = settings->bools.check_firmware_before_loading; content_ctx.is_ips_pref = rarch_ctl(RARCH_CTL_IS_IPS_PREF, NULL); @@ -1492,6 +1500,26 @@ static bool task_load_content_callback(content_ctx_info_t *content_info, content_ctx.subsystem.data = NULL; content_ctx.subsystem.size = 0; + rarch_system_info_t *sys_info = runloop_get_system_info(); + if (sys_info) + { + content_ctx.history_list_enable = settings->bools.history_list_enable; + content_ctx.set_supports_no_game_enable = settings->bools.set_supports_no_game_enable; + + if (!string_is_empty(settings->paths.directory_system)) + content_ctx.directory_system = strdup(settings->paths.directory_system); + if (!string_is_empty(settings->paths.directory_cache)) + content_ctx.directory_cache = strdup(settings->paths.directory_cache); + if (!string_is_empty(sys_info->info.valid_extensions)) + content_ctx.valid_extensions = strdup(sys_info->info.valid_extensions); + + content_ctx.block_extract = sys_info->info.block_extract; + content_ctx.need_fullpath = sys_info->info.need_fullpath; + + content_ctx.subsystem.data = sys_info->subsystem.data; + content_ctx.subsystem.size = sys_info->subsystem.size; + } + content_ctx.history_list_enable = settings->bools.history_list_enable; if (global) @@ -1660,6 +1688,35 @@ bool task_push_load_content_with_core_from_menu( return true; } + + +bool task_push_load_subsystem_with_core_from_menu( + const char *fullpath, + content_ctx_info_t *content_info, + enum rarch_core_type type, + retro_task_callback_t cb, + void *user_data) +{ + /* Set content path */ + path_set(RARCH_PATH_SUBSYSTEM, pending_subsystem_ident); + /* hardcoded to 2 for testing */ + char* roms[2] = { pending_subsystem_roms[0], pending_subsystem_roms[1] }; + path_set_special(roms, pending_subsystem_rom_num); + + /* Load content */ + if (!task_load_content_callback(content_info, true, false)) + { + rarch_menu_running(); + return false; + } + + /* Push quick menu onto menu stack */ + if (type != CORE_TYPE_DUMMY) + menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUICK_MENU, NULL); + + return true; +} + #endif void content_get_status( @@ -1674,6 +1731,7 @@ void content_get_status( void content_clear_subsystem(void) { pending_subsystem_rom_id = 0; + pending_subsystem_init = false; for (int i = 0; i < RARCH_MAX_SUBSYSTEM_ROMS; i++) pending_subsystem_roms[i][0] = '\0'; } @@ -1749,6 +1807,14 @@ void content_deinit(void) * selected libretro core. */ bool content_init(void) { + if (pending_subsystem_init) + { + path_set(RARCH_PATH_SUBSYSTEM, pending_subsystem_ident); + /* hardcoded to 2 for testing */ + char* roms[2] = { pending_subsystem_roms[0], pending_subsystem_roms[1] }; + path_set_special(roms, pending_subsystem_rom_num); + RARCH_LOG("********%s %s \n", pending_subsystem_ident, path_get(RARCH_PATH_SUBSYSTEM)); + } content_information_ctx_t content_ctx; bool ret = true; diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index e83455aa62..f127900160 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -209,6 +209,12 @@ bool task_push_load_content_with_core_from_menu( enum rarch_core_type type, retro_task_callback_t cb, void *user_data); +bool task_push_load_subsystem_with_core_from_menu( + const char *fullpath, + content_ctx_info_t *content_info, + enum rarch_core_type type, + retro_task_callback_t cb, + void *user_data); #endif void task_file_load_handler(retro_task_t *task); From 2a9046c06fd000b66fc1a8ba5bfe76e052066651 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 11 Feb 2018 10:00:08 -0500 Subject: [PATCH 09/13] subsystem part 3: cleanups --- content.h | 10 +++++---- menu/cbs/menu_cbs_ok.c | 20 ++++++++---------- menu/cbs/menu_cbs_sublabel.c | 4 ++-- menu/drivers/xmb.c | 10 ++++----- menu/widgets/menu_filebrowser.c | 3 +-- tasks/task_content.c | 36 ++++++++++++++++++++++++--------- 6 files changed, 49 insertions(+), 34 deletions(-) diff --git a/content.h b/content.h index 33d3d1c9ba..8ba2f8425d 100644 --- a/content.h +++ b/content.h @@ -39,11 +39,7 @@ typedef struct content_ctx_info environment_get_t environ_get; /* Function passed for environment_get function */ } content_ctx_info_t; -bool pending_subsystem_init; - -int pending_subsystem; int pending_subsystem_rom_id; -int pending_subsystem_rom_num; char pending_subsystem_ident[255]; char pending_subsystem_extensions[PATH_MAX_LENGTH]; @@ -92,12 +88,18 @@ bool content_reset_savestate_backups(void); bool content_undo_load_buf_is_empty(void); bool content_undo_save_buf_is_empty(void); +/* Clears the pending subsystem rom buffer*/ +bool content_is_subsystem_pending_load(void); + /* Clears the pending subsystem rom buffer*/ void content_clear_subsystem(void); /* Set the current subsystem*/ void content_set_subsystem(unsigned subsystem); +/* Get the current subsystem*/ +int content_get_subsystem(); + /* Add a rom to the subsystem rom buffer */ void content_add_subsystem(const char* path); diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 3dacfb8232..c88b7ae004 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -446,7 +446,7 @@ int generic_action_ok_displaylist_push(const char *path, break; case ACTION_OK_DL_SUBSYSTEM_ADD_LIST: filebrowser_clear_type(); - if (pending_subsystem != type - MENU_SETTINGS_SUBSYSTEM_ADD) + if (content_get_subsystem() != type - MENU_SETTINGS_SUBSYSTEM_ADD) content_clear_subsystem(); content_set_subsystem(type - MENU_SETTINGS_SUBSYSTEM_ADD); filebrowser_set_type(FILEBROWSER_SELECT_FILE_SUBSYSTEM); @@ -457,17 +457,13 @@ int generic_action_ok_displaylist_push(const char *path, dl_type = DISPLAYLIST_FILE_BROWSER_SELECT_FILE; break; case ACTION_OK_DL_SUBSYSTEM_LOAD: - filebrowser_clear_type(); - path_set(RARCH_PATH_SUBSYSTEM, pending_subsystem_ident); - /* hardcoded to 2 for testing */ - char* roms[2] = { pending_subsystem_roms[0], pending_subsystem_roms[1] }; - path_set_special(roms, pending_subsystem_rom_num); - content_ctx_info_t content_info = {0}; - pending_subsystem_init = true; - task_push_load_subsystem_with_core_from_menu( - NULL, &content_info, - CORE_TYPE_PLAIN, NULL, NULL); - + { + content_ctx_info_t content_info = {0}; + filebrowser_clear_type(); + task_push_load_subsystem_with_core_from_menu( + NULL, &content_info, + CORE_TYPE_PLAIN, NULL, NULL); + } break; case ACTION_OK_DL_CHEAT_FILE: filebrowser_clear_type(); diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 2bbc492b04..72fc176f60 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -409,7 +409,7 @@ static int action_bind_sublabel_subsystem_add( const struct retro_subsystem_info* subsystem = NULL; subsystem = system->subsystem.data + (type - MENU_SETTINGS_SUBSYSTEM_ADD); if (subsystem && pending_subsystem_rom_id < subsystem->num_roms) - snprintf(s, len, " Current Content: %s", pending_subsystem == type - MENU_SETTINGS_SUBSYSTEM_ADD ? subsystem->roms[pending_subsystem_rom_id].desc : subsystem->roms[0].desc); + snprintf(s, len, " Current Content: %s", content_get_subsystem() == type - MENU_SETTINGS_SUBSYSTEM_ADD ? subsystem->roms[pending_subsystem_rom_id].desc : subsystem->roms[0].desc); return 0; } @@ -428,7 +428,7 @@ static int action_bind_sublabel_netplay_room( const char *gamename = NULL; const char *core_ver = NULL; const char *frontend = NULL; - + /* This offset may cause issues if any entries are added to this menu */ unsigned offset = i - 3; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 7852ef827f..90b22d2d31 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -61,6 +61,7 @@ #include "../../tasks/tasks_internal.h" #include "../../cheevos/badges.h" +#include "../../content.h" #define XMB_RIBBON_ROWS 64 #define XMB_RIBBON_COLS 64 @@ -4445,11 +4446,11 @@ static int xmb_list_push(void *data, void *userdata, for (i = 0; i < system->subsystem.size; i++, subsystem++) { char s[PATH_MAX_LENGTH]; - if (pending_subsystem == i) + if (content_get_subsystem() == i) { if (pending_subsystem_rom_id < subsystem->num_roms) { - snprintf(s, sizeof(s), "Load %s %c", subsystem->desc, i == pending_subsystem ? '*': ' '); + snprintf(s, sizeof(s), "Load %s %s", subsystem->desc, i == content_get_subsystem() ? "\u2605" : " "); menu_entries_append_enum(info->list, s, msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), @@ -4458,8 +4459,7 @@ static int xmb_list_push(void *data, void *userdata, } else { - /* To-Do: replace the MENU_ENUM_LABEL_SUBSYSTEM_ADD for the proper labels and trigger the load action */ - snprintf(s, sizeof(s), "Start %s %c", subsystem->desc, i == pending_subsystem ? '*': ' '); + snprintf(s, sizeof(s), "Start %s %s", subsystem->desc, i == content_get_subsystem() ? "\u2605" : " "); menu_entries_append_enum(info->list, s, msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_LOAD), @@ -4469,7 +4469,7 @@ static int xmb_list_push(void *data, void *userdata, } else { - snprintf(s, sizeof(s), "Load %s %c", subsystem->desc, i == pending_subsystem ? '*': ' '); + snprintf(s, sizeof(s), "Load %s %s", subsystem->desc, i == content_get_subsystem() ? "\u2605" : " "); menu_entries_append_enum(info->list, s, msg_hash_to_str(MENU_ENUM_LABEL_SUBSYSTEM_ADD), diff --git a/menu/widgets/menu_filebrowser.c b/menu/widgets/menu_filebrowser.c index bcfec67fa7..5b641a11ac 100644 --- a/menu/widgets/menu_filebrowser.c +++ b/menu/widgets/menu_filebrowser.c @@ -88,10 +88,9 @@ void filebrowser_parse(void *data, unsigned type_data) { rarch_system_info_t *system = runloop_get_system_info(); const struct retro_subsystem_info* subsystem = NULL; - subsystem = system->subsystem.data + pending_subsystem; + subsystem = system->subsystem.data + content_get_subsystem(); if (subsystem && pending_subsystem_rom_id < subsystem->num_roms) { - RARCH_LOG("[subsystem] valid extensions: %s\n", subsystem->roms[pending_subsystem_rom_id].valid_extensions); str_list = dir_list_new(path, (filter_ext && info) ? subsystem->roms[pending_subsystem_rom_id].valid_extensions : NULL, true, settings->bools.show_hidden_files, true, false); diff --git a/tasks/task_content.c b/tasks/task_content.c index a8688e1ac3..22f84ce643 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -141,6 +141,10 @@ static bool _content_is_inited = false; static bool core_does_not_need_content = false; static uint32_t content_rom_crc = 0; +static bool pending_subsystem_init = false; +static int pending_subsystem_rom_num = 0; +static int pending_subsystem_id = 0; + static int content_file_read(const char *path, void **buf, ssize_t *length) { #ifdef HAVE_COMPRESSION @@ -272,12 +276,14 @@ static bool content_load(content_ctx_info_t *info) retval = false; goto end; } - - { + if (pending_subsystem_init) + { content_init(); + content_clear_subsystem(); } + #ifdef HAVE_MENU /* TODO/FIXME - can we get rid of this? */ menu_shader_manager_init(); @@ -1697,6 +1703,9 @@ bool task_push_load_subsystem_with_core_from_menu( retro_task_callback_t cb, void *user_data) { + + pending_subsystem_init = true; + /* Set content path */ path_set(RARCH_PATH_SUBSYSTEM, pending_subsystem_ident); /* hardcoded to 2 for testing */ @@ -1736,14 +1745,21 @@ void content_clear_subsystem(void) pending_subsystem_roms[i][0] = '\0'; } +/* Get the current subsystem */ +int content_get_subsystem() +{ + return pending_subsystem_id; +} + /* Set the current subsystem*/ -void content_set_subsystem(unsigned sub) +void content_set_subsystem(unsigned idx) { rarch_system_info_t *system = runloop_get_system_info(); const struct retro_subsystem_info* subsystem = NULL; - pending_subsystem = sub; - subsystem = system->subsystem.data + pending_subsystem; + subsystem = system->subsystem.data + pending_subsystem_id; + + pending_subsystem_id = idx; strlcpy(pending_subsystem_ident, subsystem->ident, sizeof(pending_subsystem_ident)); pending_subsystem_rom_num = subsystem->num_roms; @@ -1752,8 +1768,11 @@ void content_set_subsystem(unsigned sub) /* Add a rom to the subsystem rom buffer */ void content_add_subsystem(const char* path) { - strlcpy(pending_subsystem_roms[pending_subsystem_rom_id], path, sizeof(pending_subsystem_roms[pending_subsystem_rom_id])); - RARCH_LOG("[subsystem] subsystem id: %d subsystem ident: %s rom id: %d, rom path: %s\n", pending_subsystem, pending_subsystem_ident, pending_subsystem_rom_id, pending_subsystem_roms[pending_subsystem_rom_id]); + strlcpy(pending_subsystem_roms[pending_subsystem_rom_id], path, + sizeof(pending_subsystem_roms[pending_subsystem_rom_id])); + RARCH_LOG("[subsystem] subsystem id: %d subsystem ident: %s rom id: %d, rom path: %s\n", + pending_subsystem_id, pending_subsystem_ident, pending_subsystem_rom_id, + pending_subsystem_roms[pending_subsystem_rom_id]); pending_subsystem_rom_id++; } @@ -1810,10 +1829,9 @@ bool content_init(void) if (pending_subsystem_init) { path_set(RARCH_PATH_SUBSYSTEM, pending_subsystem_ident); - /* hardcoded to 2 for testing */ char* roms[2] = { pending_subsystem_roms[0], pending_subsystem_roms[1] }; + /* hardcoded to 2 for testing please fix */ path_set_special(roms, pending_subsystem_rom_num); - RARCH_LOG("********%s %s \n", pending_subsystem_ident, path_get(RARCH_PATH_SUBSYSTEM)); } content_information_ctx_t content_ctx; From 1b1ec37f36c30ff17d03f8ea91b54e6cedb248d7 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 11 Feb 2018 10:04:22 -0500 Subject: [PATCH 10/13] subsystem part 3: these can be static again --- command.c | 4 ++-- command.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/command.c b/command.c index 1d92f19e78..27ebfdeb72 100644 --- a/command.c +++ b/command.c @@ -1052,7 +1052,7 @@ static void command_event_init_controllers(void) } } -void command_event_deinit_core(bool reinit) +static void command_event_deinit_core(bool reinit) { #ifdef HAVE_CHEEVOS cheevos_unload(); @@ -1205,7 +1205,7 @@ error: free(state_base); } -bool event_init_content(void) +static bool event_init_content(void) { bool contentless = false; bool is_inited = false; diff --git a/command.h b/command.h index eebc622f7c..6b257d1896 100644 --- a/command.h +++ b/command.h @@ -273,8 +273,6 @@ void command_playlist_update_write( const char *label, const char *path); -bool event_init_content(void); -void command_event_deinit_core(bool reinit); RETRO_END_DECLS From 9a23ee8017a51a3fbc048666997dbf30a0a7fde5 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 11 Feb 2018 10:10:52 -0500 Subject: [PATCH 11/13] subsystem part 3: remove more globals --- command.h | 1 - content.h | 9 +++------ menu/cbs/menu_cbs_sublabel.c | 4 ++-- menu/drivers/xmb.c | 2 +- menu/widgets/menu_filebrowser.c | 4 ++-- tasks/task_content.c | 12 ++++++++++++ 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/command.h b/command.h index 6b257d1896..86efe07bb0 100644 --- a/command.h +++ b/command.h @@ -273,7 +273,6 @@ void command_playlist_update_write( const char *label, const char *path); - RETRO_END_DECLS #endif diff --git a/content.h b/content.h index 8ba2f8425d..eca57fa833 100644 --- a/content.h +++ b/content.h @@ -39,12 +39,6 @@ typedef struct content_ctx_info environment_get_t environ_get; /* Function passed for environment_get function */ } content_ctx_info_t; -int pending_subsystem_rom_id; - -char pending_subsystem_ident[255]; -char pending_subsystem_extensions[PATH_MAX_LENGTH]; -char pending_subsystem_roms[RARCH_MAX_SUBSYSTEM_ROMS][PATH_MAX_LENGTH]; - /* Load a RAM state from disk to memory. */ bool content_load_ram_file(unsigned slot); @@ -103,6 +97,9 @@ int content_get_subsystem(); /* Add a rom to the subsystem rom buffer */ void content_add_subsystem(const char* path); +/* Get the current subsystem rom id */ +int content_get_subsystem_rom_id(); + RETRO_END_DECLS diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 72fc176f60..1a2f147a24 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -408,8 +408,8 @@ static int action_bind_sublabel_subsystem_add( rarch_system_info_t *system = runloop_get_system_info(); const struct retro_subsystem_info* subsystem = NULL; subsystem = system->subsystem.data + (type - MENU_SETTINGS_SUBSYSTEM_ADD); - if (subsystem && pending_subsystem_rom_id < subsystem->num_roms) - snprintf(s, len, " Current Content: %s", content_get_subsystem() == type - MENU_SETTINGS_SUBSYSTEM_ADD ? subsystem->roms[pending_subsystem_rom_id].desc : subsystem->roms[0].desc); + if (subsystem && content_get_subsystem_rom_id() < subsystem->num_roms) + snprintf(s, len, " Current Content: %s", content_get_subsystem() == type - MENU_SETTINGS_SUBSYSTEM_ADD ? subsystem->roms[content_get_subsystem_rom_id()].desc : subsystem->roms[0].desc); return 0; } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 90b22d2d31..2e3af1ffa9 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -4448,7 +4448,7 @@ static int xmb_list_push(void *data, void *userdata, char s[PATH_MAX_LENGTH]; if (content_get_subsystem() == i) { - if (pending_subsystem_rom_id < subsystem->num_roms) + if (content_get_subsystem_rom_id() < subsystem->num_roms) { snprintf(s, sizeof(s), "Load %s %s", subsystem->desc, i == content_get_subsystem() ? "\u2605" : " "); menu_entries_append_enum(info->list, diff --git a/menu/widgets/menu_filebrowser.c b/menu/widgets/menu_filebrowser.c index 5b641a11ac..d401c23c5c 100644 --- a/menu/widgets/menu_filebrowser.c +++ b/menu/widgets/menu_filebrowser.c @@ -89,10 +89,10 @@ void filebrowser_parse(void *data, unsigned type_data) rarch_system_info_t *system = runloop_get_system_info(); const struct retro_subsystem_info* subsystem = NULL; subsystem = system->subsystem.data + content_get_subsystem(); - if (subsystem && pending_subsystem_rom_id < subsystem->num_roms) + if (subsystem && content_get_subsystem_rom_id() < subsystem->num_roms) { str_list = dir_list_new(path, - (filter_ext && info) ? subsystem->roms[pending_subsystem_rom_id].valid_extensions : NULL, + (filter_ext && info) ? subsystem->roms[content_get_subsystem_rom_id()].valid_extensions : NULL, true, settings->bools.show_hidden_files, true, false); } diff --git a/tasks/task_content.c b/tasks/task_content.c index 22f84ce643..9df179147b 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -144,6 +144,12 @@ static uint32_t content_rom_crc = 0; static bool pending_subsystem_init = false; static int pending_subsystem_rom_num = 0; static int pending_subsystem_id = 0; +static int pending_subsystem_rom_id = 0; + +static char pending_subsystem_ident[255]; +static char pending_subsystem_extensions[PATH_MAX_LENGTH]; +static char pending_subsystem_roms[RARCH_MAX_SUBSYSTEM_ROMS][PATH_MAX_LENGTH]; + static int content_file_read(const char *path, void **buf, ssize_t *length) { @@ -1776,6 +1782,12 @@ void content_add_subsystem(const char* path) pending_subsystem_rom_id++; } +/* Get the current subsystem rom id */ +int content_get_subsystem_rom_id() +{ + return pending_subsystem_rom_id; +} + void content_set_does_not_need_content(void) { core_does_not_need_content = true; From d254c3eca4ce0f7f029e56a7c7e1f15678363c6a Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 11 Feb 2018 15:18:40 -0500 Subject: [PATCH 12/13] subsystem part 3: fix saves --- CHANGES.md | 1 + command.c | 2 ++ content.h | 3 +++ paths.c | 2 -- tasks/task_content.c | 13 +++++++++---- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4ea542a340..579f137c3a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -48,6 +48,7 @@ - SHADERS: SPIRV-Cross/slang shader support for D3D11. - SHIELD ATV: Allow the remote / gamepad takeover hack to work with the 2017 gamepad - SUBSYSTEM: Subsystem saves now respect the save directory +- SUBSYSTEM: You can now load subsystem games from the menu (see https://github.com/libretro/RetroArch/pull/6282 for caveats) - VULKAN: Fix swapchain recreation bug on Nvidia GPUs with Windows 10 (resolved in Windows Nvidia driver version 390.77). - WINDOWS: Improved Unicode support (for cores/directory creation and 7zip archives). - WINDOWS: Show progress meter on taskbar for downloads (Windows 7 and up). diff --git a/command.c b/command.c index 27ebfdeb72..ec707f5285 100644 --- a/command.c +++ b/command.c @@ -1219,6 +1219,8 @@ static bool event_init_content(void) if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) return true; + content_set_subsystem_info(); + if (!contentless) path_fill_names(); diff --git a/content.h b/content.h index eca57fa833..ad4211c5a0 100644 --- a/content.h +++ b/content.h @@ -100,6 +100,9 @@ void content_add_subsystem(const char* path); /* Get the current subsystem rom id */ int content_get_subsystem_rom_id(); +/* Set environment variables before a subsystem load */ +void content_set_subsystem_info(); + RETRO_END_DECLS diff --git a/paths.c b/paths.c index ab20de391c..8b8c4c8bd4 100644 --- a/paths.c +++ b/paths.c @@ -297,7 +297,6 @@ static bool path_init_subsystem(void) if (!system || path_is_empty(RARCH_PATH_SUBSYSTEM)) return false; - /* For subsystems, we know exactly which RAM types are supported. */ info = libretro_find_subsystem_info( @@ -306,7 +305,6 @@ static bool path_init_subsystem(void) path_get(RARCH_PATH_SUBSYSTEM)); /* We'll handle this error gracefully later. */ - if (info) { unsigned num_content = MIN(info->num_roms, diff --git a/tasks/task_content.c b/tasks/task_content.c index 9df179147b..3dd32415b3 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -285,7 +285,7 @@ static bool content_load(content_ctx_info_t *info) if (pending_subsystem_init) { - content_init(); + command_event(CMD_EVENT_CORE_INIT, NULL); content_clear_subsystem(); } @@ -1834,9 +1834,8 @@ void content_deinit(void) core_does_not_need_content = false; } -/* Initializes and loads a content file for the currently - * selected libretro core. */ -bool content_init(void) +/* Set environment variables before a subsystem load */ +void content_set_subsystem_info() { if (pending_subsystem_init) { @@ -1845,6 +1844,12 @@ bool content_init(void) /* hardcoded to 2 for testing please fix */ path_set_special(roms, pending_subsystem_rom_num); } +} + +/* Initializes and loads a content file for the currently + * selected libretro core. */ +bool content_init(void) +{ content_information_ctx_t content_ctx; bool ret = true; From 1f2054d42f6ecc7bebfae2bdbb8f32caf7306139 Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 12 Feb 2018 02:34:30 -0500 Subject: [PATCH 13/13] subsystem part 3: cleanups --- tasks/task_content.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tasks/task_content.c b/tasks/task_content.c index 3dd32415b3..ae641172b9 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1712,12 +1712,6 @@ bool task_push_load_subsystem_with_core_from_menu( pending_subsystem_init = true; - /* Set content path */ - path_set(RARCH_PATH_SUBSYSTEM, pending_subsystem_ident); - /* hardcoded to 2 for testing */ - char* roms[2] = { pending_subsystem_roms[0], pending_subsystem_roms[1] }; - path_set_special(roms, pending_subsystem_rom_num); - /* Load content */ if (!task_load_content_callback(content_info, true, false)) { @@ -1774,10 +1768,10 @@ void content_set_subsystem(unsigned idx) /* Add a rom to the subsystem rom buffer */ void content_add_subsystem(const char* path) { - strlcpy(pending_subsystem_roms[pending_subsystem_rom_id], path, + strlcpy(pending_subsystem_roms[pending_subsystem_rom_id], path, sizeof(pending_subsystem_roms[pending_subsystem_rom_id])); - RARCH_LOG("[subsystem] subsystem id: %d subsystem ident: %s rom id: %d, rom path: %s\n", - pending_subsystem_id, pending_subsystem_ident, pending_subsystem_rom_id, + RARCH_LOG("[subsystem] subsystem id: %d subsystem ident: %s rom id: %d, rom path: %s\n", + pending_subsystem_id, pending_subsystem_ident, pending_subsystem_rom_id, pending_subsystem_roms[pending_subsystem_rom_id]); pending_subsystem_rom_id++; }