mirror of
https://github.com/libretro/RetroArch.git
synced 2025-04-02 10:51:52 -04:00
Create MENU_CONTENT_CTL_FIND_FIRST_CORE
This commit is contained in:
parent
24a04ce201
commit
4e674e15ab
3 changed files with 63 additions and 43 deletions
|
@ -445,6 +445,7 @@ static int rarch_defer_core_wrapper(size_t idx, size_t entry_idx,
|
||||||
uint32_t hash_label,
|
uint32_t hash_label,
|
||||||
unsigned type, bool is_carchive)
|
unsigned type, bool is_carchive)
|
||||||
{
|
{
|
||||||
|
menu_content_ctx_defer_info_t def_info;
|
||||||
char menu_path_new[PATH_MAX_LENGTH];
|
char menu_path_new[PATH_MAX_LENGTH];
|
||||||
const char *menu_path = NULL;
|
const char *menu_path = NULL;
|
||||||
const char *menu_label = NULL;
|
const char *menu_label = NULL;
|
||||||
|
@ -477,9 +478,15 @@ static int rarch_defer_core_wrapper(size_t idx, size_t entry_idx,
|
||||||
|
|
||||||
runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list);
|
runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list);
|
||||||
|
|
||||||
ret = menu_content_defer_core(list,
|
def_info.data = list;
|
||||||
menu_path_new, path, menu_label, menu->deferred_path,
|
def_info.dir = menu_path_new;
|
||||||
sizeof(menu->deferred_path));
|
def_info.path = path;
|
||||||
|
def_info.menu_label = menu_label;
|
||||||
|
def_info.s = menu->deferred_path;
|
||||||
|
def_info.len = sizeof(menu->deferred_path);
|
||||||
|
|
||||||
|
if (menu_content_ctl(MENU_CONTENT_CTL_FIND_FIRST_CORE, &def_info))
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
if (!is_carchive && !string_is_empty(path) && !string_is_empty(menu_path_new))
|
if (!is_carchive && !string_is_empty(path) && !string_is_empty(menu_path_new))
|
||||||
fill_pathname_join(detect_content_path, menu_path_new, path,
|
fill_pathname_join(detect_content_path, menu_path_new, path,
|
||||||
|
@ -2044,6 +2051,7 @@ static int action_ok_load_archive(const char *path,
|
||||||
static int action_ok_load_archive_detect_core(const char *path,
|
static int action_ok_load_archive_detect_core(const char *path,
|
||||||
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
const char *label, unsigned type, size_t idx, size_t entry_idx)
|
||||||
{
|
{
|
||||||
|
menu_content_ctx_defer_info_t def_info;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
core_info_list_t *list = NULL;
|
core_info_list_t *list = NULL;
|
||||||
menu_handle_t *menu = menu_driver_get_ptr();
|
menu_handle_t *menu = menu_driver_get_ptr();
|
||||||
|
@ -2058,8 +2066,15 @@ static int action_ok_load_archive_detect_core(const char *path,
|
||||||
|
|
||||||
runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list);
|
runloop_ctl(RUNLOOP_CTL_CURRENT_CORE_LIST_GET, &list);
|
||||||
|
|
||||||
ret = menu_content_defer_core(list, menu_path, content_path, label,
|
def_info.data = list;
|
||||||
menu->deferred_path, sizeof(menu->deferred_path));
|
def_info.dir = menu_path;
|
||||||
|
def_info.path = content_path;
|
||||||
|
def_info.menu_label = label;
|
||||||
|
def_info.s = menu->deferred_path;
|
||||||
|
def_info.len = sizeof(menu->deferred_path);
|
||||||
|
|
||||||
|
if (menu_content_ctl(MENU_CONTENT_CTL_FIND_FIRST_CORE, &def_info))
|
||||||
|
ret = -1;
|
||||||
|
|
||||||
fill_pathname_join(detect_content_path, menu_path, content_path,
|
fill_pathname_join(detect_content_path, menu_path, content_path,
|
||||||
sizeof(detect_content_path));
|
sizeof(detect_content_path));
|
||||||
|
|
|
@ -229,31 +229,33 @@ static bool menu_content_load_from_playlist(void *data)
|
||||||
* selection needs to be made from a list, otherwise
|
* selection needs to be made from a list, otherwise
|
||||||
* returns -1 and fills in @s with path to core.
|
* returns -1 and fills in @s with path to core.
|
||||||
**/
|
**/
|
||||||
int menu_content_defer_core(void *data, const char *dir,
|
static bool menu_content_defer_core(void *data)
|
||||||
const char *path, const char *menu_label,
|
|
||||||
char *s, size_t len)
|
|
||||||
{
|
{
|
||||||
char new_core_path[PATH_MAX_LENGTH];
|
char new_core_path[PATH_MAX_LENGTH];
|
||||||
const core_info_t *info = NULL;
|
const core_info_t *info = NULL;
|
||||||
size_t supported = 0;
|
size_t supported = 0;
|
||||||
core_info_list_t *core_info = (core_info_list_t*)data;
|
menu_content_ctx_defer_info_t *def_info = (menu_content_ctx_defer_info_t *)data;
|
||||||
uint32_t menu_label_hash = menu_hash_calculate(menu_label);
|
core_info_list_t *core_info = (core_info_list_t*)def_info->data;
|
||||||
|
uint32_t menu_label_hash =
|
||||||
|
menu_hash_calculate(def_info->menu_label);
|
||||||
|
|
||||||
if (!string_is_empty(dir) && !string_is_empty(path))
|
if (!string_is_empty(def_info->dir) && !string_is_empty(def_info->path))
|
||||||
fill_pathname_join(s, dir, path, len);
|
fill_pathname_join(def_info->s,
|
||||||
|
def_info->dir, def_info->path, def_info->len);
|
||||||
|
|
||||||
#ifdef HAVE_COMPRESSION
|
#ifdef HAVE_COMPRESSION
|
||||||
if (path_is_compressed_file(dir))
|
if (path_is_compressed_file(def_info->dir))
|
||||||
{
|
{
|
||||||
/* In case of a compressed archive, we have to join with a hash */
|
/* In case of a compressed archive, we have to join with a hash */
|
||||||
/* We are going to write at the position of dir: */
|
/* We are going to write at the position of dir: */
|
||||||
retro_assert(strlen(dir) < strlen(s));
|
retro_assert(strlen(def_info->dir) < strlen(def_info->s));
|
||||||
s[strlen(dir)] = '#';
|
def_info->s[strlen(def_info->dir)] = '#';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (core_info)
|
if (core_info)
|
||||||
core_info_list_get_supported_cores(core_info, s, &info,
|
core_info_list_get_supported_cores(core_info,
|
||||||
|
def_info->s, &info,
|
||||||
&supported);
|
&supported);
|
||||||
|
|
||||||
/* We started the menu with 'Load Content', we are
|
/* We started the menu with 'Load Content', we are
|
||||||
|
@ -271,22 +273,25 @@ int menu_content_defer_core(void *data, const char *dir,
|
||||||
/* There are multiple deferred cores and a
|
/* There are multiple deferred cores and a
|
||||||
* selection needs to be made from a list, return 0. */
|
* selection needs to be made from a list, return 0. */
|
||||||
if (supported != 1)
|
if (supported != 1)
|
||||||
return 0;
|
return false;
|
||||||
|
|
||||||
if (info)
|
if (info)
|
||||||
strlcpy(new_core_path, info->path, sizeof(new_core_path));
|
strlcpy(new_core_path, info->path, sizeof(new_core_path));
|
||||||
|
|
||||||
runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, s);
|
runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, def_info->s);
|
||||||
|
|
||||||
if (path_file_exists(new_core_path))
|
if (path_file_exists(new_core_path))
|
||||||
runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, new_core_path);
|
runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, new_core_path);
|
||||||
return -1;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool menu_content_ctl(enum menu_content_ctl_state state, void *data)
|
bool menu_content_ctl(enum menu_content_ctl_state state, void *data)
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
|
case MENU_CONTENT_CTL_FIND_FIRST_CORE:
|
||||||
|
return menu_content_defer_core(data);
|
||||||
case MENU_CONTENT_CTL_LOAD:
|
case MENU_CONTENT_CTL_LOAD:
|
||||||
return menu_content_load();
|
return menu_content_load();
|
||||||
case MENU_CONTENT_CTL_LOAD_PLAYLIST:
|
case MENU_CONTENT_CTL_LOAD_PLAYLIST:
|
||||||
|
|
|
@ -36,7 +36,18 @@ enum menu_content_ctl_state
|
||||||
|
|
||||||
/* Initializes core and loads content
|
/* Initializes core and loads content
|
||||||
* (based on playlist entry). */
|
* (based on playlist entry). */
|
||||||
MENU_CONTENT_CTL_LOAD_PLAYLIST
|
MENU_CONTENT_CTL_LOAD_PLAYLIST,
|
||||||
|
|
||||||
|
/* Find first core that is compatible with the
|
||||||
|
* content.
|
||||||
|
*
|
||||||
|
* Returns false if there are multiple compatible
|
||||||
|
* cores and a selection needs to be made from
|
||||||
|
* a list.
|
||||||
|
*
|
||||||
|
* Returns true and fills in @s with path to core.
|
||||||
|
*/
|
||||||
|
MENU_CONTENT_CTL_FIND_FIRST_CORE
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct menu_content_ctx_playlist_info
|
typedef struct menu_content_ctx_playlist_info
|
||||||
|
@ -45,28 +56,17 @@ typedef struct menu_content_ctx_playlist_info
|
||||||
unsigned idx;
|
unsigned idx;
|
||||||
} menu_content_ctx_playlist_info_t;
|
} menu_content_ctx_playlist_info_t;
|
||||||
|
|
||||||
bool menu_content_ctl(enum menu_content_ctl_state state, void *data);
|
typedef struct menu_content_ctx_defer_info
|
||||||
|
{
|
||||||
|
void *data;
|
||||||
|
const char *dir;
|
||||||
|
const char *path;
|
||||||
|
const char *menu_label;
|
||||||
|
char *s;
|
||||||
|
size_t len;
|
||||||
|
} menu_content_ctx_defer_info_t;
|
||||||
|
|
||||||
/**
|
bool menu_content_ctl(enum menu_content_ctl_state state, void *data);
|
||||||
* menu_content_defer_core:
|
|
||||||
* @core_info : Core info list handle.
|
|
||||||
* @dir : Directory. Gets joined with @path.
|
|
||||||
* @path : Path. Gets joined with @dir.
|
|
||||||
* @menu_label : Label identifier of menu setting.
|
|
||||||
* @s : Deferred core path. Will be filled in
|
|
||||||
* by function.
|
|
||||||
* @len : Size of @s.
|
|
||||||
*
|
|
||||||
* Gets deferred core.
|
|
||||||
*
|
|
||||||
* Returns: 0 if there are multiple deferred cores and a
|
|
||||||
* selection needs to be made from a list, otherwise
|
|
||||||
* returns -1 and fills in @s with path to core.
|
|
||||||
**/
|
|
||||||
int menu_content_defer_core(void *data,
|
|
||||||
const char *dir, const char *path,
|
|
||||||
const char *menu_label,
|
|
||||||
char *s, size_t len);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue