Skip to content

Commit

Permalink
Merge pull request #6282 from fr500/master
Browse files Browse the repository at this point in the history
Menu Subsystem Implementation
  • Loading branch information
inactive123 authored Feb 12, 2018
2 parents 521433d + 1f2054d commit c6a9967
Show file tree
Hide file tree
Showing 16 changed files with 308 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 2 additions & 0 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
23 changes: 23 additions & 0 deletions content.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include <boolean.h>
#include <retro_common_api.h>
#include <retro_miscellaneous.h>

#include "frontend/frontend_driver.h"

Expand Down Expand Up @@ -81,6 +82,28 @@ 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);

/* 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

#endif
4 changes: 4 additions & 0 deletions intl/msg_hash_lbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ 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_SUBSYSTEM_LOAD,
"subsystem_load")
MSG_HASH(MENU_ENUM_LABEL_DISK_OPTIONS,
"core_disk_options")
MSG_HASH(MENU_ENUM_LABEL_DOWNLOADED_FILE_DETECT_CORE_LIST,
Expand Down
3 changes: 3 additions & 0 deletions libretro-common/include/retro_miscellaneous.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#ifndef __RARCH_MISCELLANEOUS_H
#define __RARCH_MISCELLANEOUS_H

#define RARCH_MAX_SUBSYSTEMS 10
#define RARCH_MAX_SUBSYSTEM_ROMS 10

#include <stdint.h>
#include <boolean.h>
#include <retro_inline.h>
Expand Down
44 changes: 44 additions & 0 deletions menu/cbs/menu_cbs_ok.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -443,6 +444,27 @@ 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 (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);
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_SUBSYSTEM_LOAD:
{
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();
info.type = type;
Expand Down Expand Up @@ -1168,6 +1190,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);
Expand Down Expand Up @@ -1246,6 +1272,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 )
Expand Down Expand Up @@ -2972,6 +2999,8 @@ 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_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)
Expand Down Expand Up @@ -4088,6 +4117,12 @@ 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_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;
Expand Down Expand Up @@ -4282,6 +4317,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;
Expand Down Expand Up @@ -4526,6 +4564,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;
Expand All @@ -4552,6 +4593,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;
Expand Down
24 changes: 23 additions & 1 deletion menu/cbs/menu_cbs_sublabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
{ \
Expand Down Expand Up @@ -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 && 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;
}



#ifdef HAVE_NETWORKING
static int action_bind_sublabel_netplay_room(
file_list_t *list,
Expand All @@ -409,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;

Expand Down Expand Up @@ -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;
Expand Down
43 changes: 43 additions & 0 deletions menu/drivers/xmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -4340,6 +4341,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;

Expand Down Expand Up @@ -4435,6 +4438,46 @@ 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];
if (content_get_subsystem() == i)
{
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,
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), "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),
MENU_ENUM_LABEL_SUBSYSTEM_LOAD,
MENU_SETTINGS_SUBSYSTEM_LOAD, 0, 0);
}
}
else
{
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),
MENU_ENUM_LABEL_SUBSYSTEM_ADD,
MENU_SETTINGS_SUBSYSTEM_ADD, 0, 0);
}
}
}
}

entry.enum_idx = MENU_ENUM_LABEL_ADD_CONTENT_LIST;
Expand Down
2 changes: 2 additions & 0 deletions menu/menu_cbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ 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_SUBSYSTEM_LOAD,
ACTION_OK_DL_PLAYLIST_COLLECTION,
ACTION_OK_DL_CONTENT_COLLECTION_LIST,
ACTION_OK_DL_CHEAT_FILE,
Expand Down
6 changes: 6 additions & 0 deletions menu/menu_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ 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_LOAD,

MENU_SETTINGS_SUBSYSTEM_ADD,
MENU_SETTINGS_SUBSYSTEM_LAST = MENU_SETTINGS_SUBSYSTEM_ADD + RARCH_MAX_SUBSYSTEMS,

MENU_SETTINGS_LAST
};

Expand Down
20 changes: 19 additions & 1 deletion menu/widgets/menu_filebrowser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -75,10 +80,23 @@ 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 + content_get_subsystem();
if (subsystem && content_get_subsystem_rom_id() < subsystem->num_roms)
{
str_list = dir_list_new(path,
(filter_ext && info) ? subsystem->roms[content_get_subsystem_rom_id()].valid_extensions : NULL,
true, settings->bools.show_hidden_files, true, false);
}

}

switch (filebrowser_types)
{
Expand Down
1 change: 1 addition & 0 deletions menu/widgets/menu_filebrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions msg_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,8 @@ enum msg_hash_enums
MENU_LABEL(SHUTDOWN),
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),
Expand Down Expand Up @@ -1849,6 +1851,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
Expand Down
2 changes: 0 additions & 2 deletions paths.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down
Loading

0 comments on commit c6a9967

Please sign in to comment.