Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Fix #746 (CLI) Auto-detect Core when -L isn't present #15458

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 124 additions & 2 deletions runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -3588,6 +3588,118 @@ bool libretro_get_system_info(
return true;
}

bool auto_load_core(const char* szFilename)
zig-for marked this conversation as resolved.
Show resolved Hide resolved
{
/* poll list of current cores */
core_info_list_t* core_info_list = NULL;

command_event(CMD_EVENT_CORE_INFO_INIT, NULL);
/*This isn't needed, is it?*/
/*command_event(CMD_EVENT_LOAD_CORE_PERSIST, NULL);*/
core_info_get_list(&core_info_list);
Comment on lines +3658 to +3660
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔



if (core_info_list)
{
size_t list_size;
content_ctx_info_t content_info = { 0 };
const core_info_t* core_info = NULL;
core_info_list_get_supported_cores(core_info_list,
(const char*)szFilename, &core_info, &list_size);

if (list_size)
{
path_set(RARCH_PATH_CONTENT, szFilename);

if (!path_is_empty(RARCH_PATH_CONTENT))
{
unsigned i;
core_info_t* current_core = NULL;
core_info_get_current_core(&current_core);

/*we already have path for libretro core */
for (i = 0; i < list_size; i++)
{
const core_info_t* info = (const core_info_t*)&core_info[i];

if (string_is_equal(path_get(RARCH_PATH_CORE), info->path))
{
/* Our previous core supports the current rom */
task_push_load_content_with_current_core_from_companion_ui(
NULL,
&content_info,
CORE_TYPE_PLAIN,
NULL, NULL);
return true;
}
}
}

/* Poll for cores for current rom since none exist. */
if (list_size == 1)
{
/*pick core that only exists and is bound to work. Ish. */
zig-for marked this conversation as resolved.
Show resolved Hide resolved
const core_info_t* info = (const core_info_t*)&core_info[0];

if (info)
{
path_set(RARCH_PATH_CORE, info->path);
return true;
}
}
else
{
/*
For now, pick the first one if there are multiple
TODO: this needs to delegate on systems like win32 that are able to
*/
if (list_size > 1)
{
const core_info_t* info = (const core_info_t*)&core_info[0];

if (info)
{
path_set(RARCH_PATH_CORE, info->path);
return true;
}
}
#if 0
bool okay = false;
settings_t* settings = config_get_ptr();
bool video_is_fs = settings->bools.video_fullscreen;
video_driver_state_t* video_st = video_state_get_ptr();

/* Fullscreen: Show mouse cursor for dialog */
if (video_is_fs)
{
if (video_st->poke
&& video_st->poke->show_mouse)
video_st->poke->show_mouse(video_st->data, true);
}

/* Pick one core that could be compatible, ew */
if (DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_PICKCORE),
main_window.hwnd, pick_core_proc, (LPARAM)NULL) == IDOK)
{
task_push_load_content_with_current_core_from_companion_ui(
NULL, &content_info, CORE_TYPE_PLAIN, NULL, NULL);
okay = true;
}

/* Fullscreen: Hide mouse cursor after dialog */
if (video_is_fs)
{
if (video_st->poke
&& video_st->poke->show_mouse)
video_st->poke->show_mouse(video_st->data, false);
}
return okay;
#endif
}
}
}
return false;
}
bool runloop_init_libretro_symbols(
void *data,
enum rarch_core_type type,
Expand Down Expand Up @@ -3615,9 +3727,19 @@ bool runloop_init_libretro_symbols(

if (string_is_empty(path))
{
RARCH_ERR("[Core]: Frontend is built for dynamic libretro cores, but "
const char* content_path = path_get(RARCH_PATH_CONTENT);
if (!string_is_empty(content_path))
{
zig-for marked this conversation as resolved.
Show resolved Hide resolved
auto_load_core(content_path);
}
path = path_get(RARCH_PATH_CORE);

if (string_is_empty(path))
{
RARCH_ERR("[Core]: Frontend is built for dynamic libretro cores, but "
"path is not set. Cannot continue.\n");
retroarch_fail(1, "init_libretro_symbols()");
retroarch_fail(1, "init_libretro_symbols()");
}
}

RARCH_LOG("[Core]: Loading dynamic libretro core from: \"%s\"\n",
Expand Down