Add RETRO_ENVIRONMENT_SET_LIBRETRO_PATH to libretro API. Also gives us opportunity

to write internal code - other libretro implementations can now just implement
this environ callback and have other external frontends of their own be able to swap
in/out libretro cores from outside
This commit is contained in:
twinaphex 2013-08-24 22:35:54 +02:00
parent 8f72a8aa46
commit 7c81f554af
7 changed files with 41 additions and 17 deletions

View File

@ -93,8 +93,6 @@ unsigned (*pretro_get_region)(void);
void *(*pretro_get_memory_data)(unsigned);
size_t (*pretro_get_memory_size)(unsigned);
static bool environment_cb(unsigned cmd, void *data);
#ifdef HAVE_DYNAMIC
#if defined(__APPLE__)
#define DYNAMIC_EXT "dylib"
@ -397,7 +395,7 @@ void init_libretro_sym(bool dummy)
load_symbols(dummy);
pretro_set_environment(environment_cb);
pretro_set_environment(rarch_environment_cb);
}
void uninit_libretro_sym(void)
@ -471,7 +469,7 @@ void dylib_close(dylib_t lib)
}
#endif
static bool environment_cb(unsigned cmd, void *data)
bool rarch_environment_cb(unsigned cmd, void *data)
{
switch (cmd)
{
@ -757,7 +755,12 @@ static bool environment_cb(unsigned cmd, void *data)
g_extern.system.frame_time = *info;
break;
}
case RETRO_ENVIRONMENT_SET_LIBRETRO_PATH:
{
struct retro_variable *var = (struct retro_variable*)data;
strlcpy(g_settings.libretro, var->value, sizeof(g_settings.libretro));
break;
}
default:
RARCH_LOG("Environ UNSUPPORTED (#%u).\n", cmd);
return false;

View File

@ -101,6 +101,8 @@ extern unsigned (*pretro_get_region)(void);
extern void *(*pretro_get_memory_data)(unsigned);
extern size_t (*pretro_get_memory_size)(unsigned);
extern bool rarch_environment_cb(unsigned cmd, void *data);
#ifdef __cplusplus
}
#endif

View File

@ -63,8 +63,11 @@ static bool libretro_install_core(const char *path_prefix,
return false;
}
strlcpy(g_settings.libretro, new_path,
sizeof(g_settings.libretro));
struct retro_variable var;
var.key = "core_path";
var.value = new_path;
rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, &var);
return true;
}

View File

@ -438,13 +438,15 @@ void load_menu_game_prepare(void)
void load_menu_game_history(unsigned game_index)
{
const char *path = NULL;
const char *core_path = NULL;
const char *core_name = NULL;
struct retro_variable var;
var.key = "core_path";
rom_history_get_index(rgui->history,
game_index, &path, &core_path, &core_name);
game_index, &path, &var.value, &core_name);
strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro));
rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, &var);
if (path)
{

View File

@ -2654,7 +2654,13 @@ int rgui_iterate(rgui_handle_t *rgui)
// Core selection on non-console just updates directory listing.
// Will take affect on new ROM load.
#elif defined(GEKKO) && defined(HW_RVL)
strlcpy(g_settings.libretro, path, sizeof(g_settings.libretro)); // Is this supposed to be here?
struct retro_variable var;
var.key = "core_path";
var.value = path;
rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, &var);
fill_pathname_join(g_extern.fullpath, default_paths.core_dir,
SALAMANDER_FILE, sizeof(g_extern.fullpath));
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME);

View File

@ -460,7 +460,6 @@ static int select_file(void *data, uint64_t input)
char extensions[128];
char comment[128];
char path[PATH_MAX];
bool ret = true;
bool pop_menu_stack = false;
font_params_t font_parms = {0};
@ -495,7 +494,7 @@ static int select_file(void *data, uint64_t input)
if (input & (1ULL << DEVICE_NAV_B))
{
if (filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_PATH_ISDIR))
ret = filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_OK);
filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_OK);
else
{
strlcpy(path, rgui->browser->current_dir.path, sizeof(path));
@ -560,9 +559,16 @@ static int select_file(void *data, uint64_t input)
true, menu_texture->width, menu_texture->height, 1.0f);
break;
case LIBRETRO_CHOICE:
strlcpy(g_settings.libretro, path, sizeof(g_settings.libretro));
g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN);
return -1;
{
struct retro_variable var;
var.key = "core_path";
var.value = path;
rarch_environment_cb(RETRO_ENVIRONMENT_SET_LIBRETRO_PATH, &var);
g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN);
return -1;
}
}
pop_menu_stack = true;

View File

@ -509,7 +509,9 @@ enum retro_mod
// Lets the core know how much time has passed since last invocation of retro_run().
// The frontend can tamper with the timing to fake fast-forward, slow-motion, frame stepping, etc.
// In this case the delta time will use the reference value in frame_time_callback..
#define RETRO_ENVIRONMENT_SET_LIBRETRO_PATH 22
// const char ** --
// Sets the absolute path for the libretro core pointed to.
// Notifies libretro that audio data should be written.
typedef void (*retro_audio_callback_t)(void);