mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 13:20:30 +00:00
Refactor libretro_dummy mechanics
This commit is contained in:
parent
9b267e9802
commit
6f1bc69fc7
@ -639,7 +639,7 @@ static bool event_init_content(void)
|
||||
|
||||
/* No content to be loaded for dummy core,
|
||||
* just successfully exit. */
|
||||
if (global->libretro_dummy)
|
||||
if (global->core_type == CORE_TYPE_DUMMY)
|
||||
return true;
|
||||
|
||||
if (!global->libretro_no_content)
|
||||
@ -697,7 +697,7 @@ static bool event_init_core(void)
|
||||
rarch_verify_api_version();
|
||||
pretro_init();
|
||||
|
||||
global->use_sram = !global->libretro_dummy &&
|
||||
global->use_sram = (global->core_type == CORE_TYPE_PLAIN) &&
|
||||
!global->libretro_no_content;
|
||||
|
||||
if (!event_init_content())
|
||||
@ -716,7 +716,8 @@ static bool event_save_auto_state(void)
|
||||
settings_t *settings = config_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!settings->savestate_auto_save || global->libretro_dummy ||
|
||||
if (!settings->savestate_auto_save ||
|
||||
(global->core_type == CORE_TYPE_DUMMY) ||
|
||||
global->libretro_no_content)
|
||||
return false;
|
||||
|
||||
|
@ -1667,12 +1667,12 @@ static void config_load_core_specific(void)
|
||||
|
||||
*global->core_specific_config_path = '\0';
|
||||
|
||||
if (!*settings->libretro
|
||||
#ifdef HAVE_DYNAMIC
|
||||
|| global->libretro_dummy
|
||||
#endif
|
||||
)
|
||||
if (!*settings->libretro)
|
||||
return;
|
||||
#ifdef HAVE_DYNAMIC
|
||||
if (global->core_type == CORE_TYPE_DUMMY)
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (*settings->menu_config_directory)
|
||||
|
212
dynamic.c
212
dynamic.c
@ -280,103 +280,126 @@ libretro_find_controller_description(
|
||||
|
||||
/**
|
||||
* load_symbols:
|
||||
* @dummy : Load dummy symbols if true
|
||||
* @type : Type of core to be loaded.
|
||||
* If CORE_TYPE_DUMMY, will
|
||||
* load dummy symbols.
|
||||
*
|
||||
* Setup libretro callback symbols.
|
||||
**/
|
||||
static void load_symbols(bool is_dummy)
|
||||
static void load_symbols(enum rarch_core_type type)
|
||||
{
|
||||
if (is_dummy)
|
||||
{
|
||||
SYM_DUMMY(retro_init);
|
||||
SYM_DUMMY(retro_deinit);
|
||||
|
||||
SYM_DUMMY(retro_api_version);
|
||||
SYM_DUMMY(retro_get_system_info);
|
||||
SYM_DUMMY(retro_get_system_av_info);
|
||||
|
||||
SYM_DUMMY(retro_set_environment);
|
||||
SYM_DUMMY(retro_set_video_refresh);
|
||||
SYM_DUMMY(retro_set_audio_sample);
|
||||
SYM_DUMMY(retro_set_audio_sample_batch);
|
||||
SYM_DUMMY(retro_set_input_poll);
|
||||
SYM_DUMMY(retro_set_input_state);
|
||||
|
||||
SYM_DUMMY(retro_set_controller_port_device);
|
||||
|
||||
SYM_DUMMY(retro_reset);
|
||||
SYM_DUMMY(retro_run);
|
||||
|
||||
SYM_DUMMY(retro_serialize_size);
|
||||
SYM_DUMMY(retro_serialize);
|
||||
SYM_DUMMY(retro_unserialize);
|
||||
|
||||
SYM_DUMMY(retro_cheat_reset);
|
||||
SYM_DUMMY(retro_cheat_set);
|
||||
|
||||
SYM_DUMMY(retro_load_game);
|
||||
SYM_DUMMY(retro_load_game_special);
|
||||
|
||||
SYM_DUMMY(retro_unload_game);
|
||||
SYM_DUMMY(retro_get_region);
|
||||
SYM_DUMMY(retro_get_memory_data);
|
||||
SYM_DUMMY(retro_get_memory_size);
|
||||
}
|
||||
else
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CORE_TYPE_PLAIN:
|
||||
{
|
||||
#ifdef HAVE_DYNAMIC
|
||||
settings_t *settings = config_get_ptr();
|
||||
function_t sym = dylib_proc(NULL, "retro_init");
|
||||
|
||||
/* Need to use absolute path for this setting. It can be
|
||||
* saved to content history, and a relative path would
|
||||
* break in that scenario. */
|
||||
path_resolve_realpath(settings->libretro,
|
||||
sizeof(settings->libretro));
|
||||
if (sym)
|
||||
{
|
||||
/* Try to verify that -lretro was not linked in from other modules
|
||||
* since loading it dynamically and with -l will fail hard. */
|
||||
RARCH_ERR("Serious problem. RetroArch wants to load libretro dyamically, but it is already linked.\n");
|
||||
RARCH_ERR("This could happen if other modules RetroArch depends on link against libretro directly.\n");
|
||||
RARCH_ERR("Proceeding could cause a crash. Aborting ...\n");
|
||||
rarch_fail(1, "init_libretro_sym()");
|
||||
}
|
||||
|
||||
RARCH_LOG("Loading dynamic libretro from: \"%s\"\n",
|
||||
settings->libretro);
|
||||
lib_handle = dylib_load(settings->libretro);
|
||||
if (!lib_handle)
|
||||
{
|
||||
RARCH_ERR("Failed to open dynamic library: \"%s\"\n",
|
||||
settings->libretro);
|
||||
rarch_fail(1, "load_dynamic()");
|
||||
}
|
||||
if (!*settings->libretro)
|
||||
{
|
||||
RARCH_ERR("RetroArch is built for dynamic libretro, but libretro_path is not set. Cannot continue.\n");
|
||||
rarch_fail(1, "init_libretro_sym()");
|
||||
}
|
||||
|
||||
/* Need to use absolute path for this setting. It can be
|
||||
* saved to content history, and a relative path would
|
||||
* break in that scenario. */
|
||||
path_resolve_realpath(settings->libretro,
|
||||
sizeof(settings->libretro));
|
||||
|
||||
RARCH_LOG("Loading dynamic libretro from: \"%s\"\n",
|
||||
settings->libretro);
|
||||
lib_handle = dylib_load(settings->libretro);
|
||||
if (!lib_handle)
|
||||
{
|
||||
RARCH_ERR("Failed to open dynamic library: \"%s\"\n",
|
||||
settings->libretro);
|
||||
rarch_fail(1, "load_dynamic()");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
SYM(retro_init);
|
||||
SYM(retro_deinit);
|
||||
SYM(retro_init);
|
||||
SYM(retro_deinit);
|
||||
|
||||
SYM(retro_api_version);
|
||||
SYM(retro_get_system_info);
|
||||
SYM(retro_get_system_av_info);
|
||||
SYM(retro_api_version);
|
||||
SYM(retro_get_system_info);
|
||||
SYM(retro_get_system_av_info);
|
||||
|
||||
SYM(retro_set_environment);
|
||||
SYM(retro_set_video_refresh);
|
||||
SYM(retro_set_audio_sample);
|
||||
SYM(retro_set_audio_sample_batch);
|
||||
SYM(retro_set_input_poll);
|
||||
SYM(retro_set_input_state);
|
||||
SYM(retro_set_environment);
|
||||
SYM(retro_set_video_refresh);
|
||||
SYM(retro_set_audio_sample);
|
||||
SYM(retro_set_audio_sample_batch);
|
||||
SYM(retro_set_input_poll);
|
||||
SYM(retro_set_input_state);
|
||||
|
||||
SYM(retro_set_controller_port_device);
|
||||
SYM(retro_set_controller_port_device);
|
||||
|
||||
SYM(retro_reset);
|
||||
SYM(retro_run);
|
||||
SYM(retro_reset);
|
||||
SYM(retro_run);
|
||||
|
||||
SYM(retro_serialize_size);
|
||||
SYM(retro_serialize);
|
||||
SYM(retro_unserialize);
|
||||
SYM(retro_serialize_size);
|
||||
SYM(retro_serialize);
|
||||
SYM(retro_unserialize);
|
||||
|
||||
SYM(retro_cheat_reset);
|
||||
SYM(retro_cheat_set);
|
||||
SYM(retro_cheat_reset);
|
||||
SYM(retro_cheat_set);
|
||||
|
||||
SYM(retro_load_game);
|
||||
SYM(retro_load_game_special);
|
||||
SYM(retro_load_game);
|
||||
SYM(retro_load_game_special);
|
||||
|
||||
SYM(retro_unload_game);
|
||||
SYM(retro_get_region);
|
||||
SYM(retro_get_memory_data);
|
||||
SYM(retro_get_memory_size);
|
||||
SYM(retro_unload_game);
|
||||
SYM(retro_get_region);
|
||||
SYM(retro_get_memory_data);
|
||||
SYM(retro_get_memory_size);
|
||||
break;
|
||||
case CORE_TYPE_DUMMY:
|
||||
SYM_DUMMY(retro_init);
|
||||
SYM_DUMMY(retro_deinit);
|
||||
|
||||
SYM_DUMMY(retro_api_version);
|
||||
SYM_DUMMY(retro_get_system_info);
|
||||
SYM_DUMMY(retro_get_system_av_info);
|
||||
|
||||
SYM_DUMMY(retro_set_environment);
|
||||
SYM_DUMMY(retro_set_video_refresh);
|
||||
SYM_DUMMY(retro_set_audio_sample);
|
||||
SYM_DUMMY(retro_set_audio_sample_batch);
|
||||
SYM_DUMMY(retro_set_input_poll);
|
||||
SYM_DUMMY(retro_set_input_state);
|
||||
|
||||
SYM_DUMMY(retro_set_controller_port_device);
|
||||
|
||||
SYM_DUMMY(retro_reset);
|
||||
SYM_DUMMY(retro_run);
|
||||
|
||||
SYM_DUMMY(retro_serialize_size);
|
||||
SYM_DUMMY(retro_serialize);
|
||||
SYM_DUMMY(retro_unserialize);
|
||||
|
||||
SYM_DUMMY(retro_cheat_reset);
|
||||
SYM_DUMMY(retro_cheat_set);
|
||||
|
||||
SYM_DUMMY(retro_load_game);
|
||||
SYM_DUMMY(retro_load_game_special);
|
||||
|
||||
SYM_DUMMY(retro_unload_game);
|
||||
SYM_DUMMY(retro_get_region);
|
||||
SYM_DUMMY(retro_get_memory_data);
|
||||
SYM_DUMMY(retro_get_memory_size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -420,42 +443,21 @@ void libretro_get_current_core_pathname(char *name, size_t size)
|
||||
|
||||
/**
|
||||
* init_libretro_sym:
|
||||
* @dummy : Load dummy symbols if true
|
||||
* @type : Type of core to be loaded.
|
||||
* If CORE_TYPE_DUMMY, will
|
||||
* load dummy symbols.
|
||||
*
|
||||
* Initializes libretro symbols and
|
||||
* setups environment callback functions.
|
||||
**/
|
||||
void init_libretro_sym(bool dummy)
|
||||
void init_libretro_sym(enum rarch_core_type type)
|
||||
{
|
||||
/* Guarantee that we can do "dirty" casting.
|
||||
* Every OS that this program supports should pass this. */
|
||||
rarch_assert(sizeof(void*) == sizeof(void (*)(void)));
|
||||
|
||||
if (!dummy)
|
||||
{
|
||||
#ifdef HAVE_DYNAMIC
|
||||
settings_t *settings = config_get_ptr();
|
||||
function_t sym = dylib_proc(NULL, "retro_init");
|
||||
|
||||
if (sym)
|
||||
{
|
||||
/* Try to verify that -lretro was not linked in from other modules
|
||||
* since loading it dynamically and with -l will fail hard. */
|
||||
RARCH_ERR("Serious problem. RetroArch wants to load libretro dyamically, but it is already linked.\n");
|
||||
RARCH_ERR("This could happen if other modules RetroArch depends on link against libretro directly.\n");
|
||||
RARCH_ERR("Proceeding could cause a crash. Aborting ...\n");
|
||||
rarch_fail(1, "init_libretro_sym()");
|
||||
}
|
||||
|
||||
if (!*settings->libretro)
|
||||
{
|
||||
RARCH_ERR("RetroArch is built for dynamic libretro, but libretro_path is not set. Cannot continue.\n");
|
||||
rarch_fail(1, "init_libretro_sym()");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
load_symbols(dummy);
|
||||
load_symbols(type);
|
||||
|
||||
//move this to init_core, will need to be tested
|
||||
//pretro_set_environment(rarch_environment_cb);
|
||||
|
12
dynamic.h
12
dynamic.h
@ -26,6 +26,12 @@
|
||||
|
||||
#include <dynamic/dylib.h>
|
||||
|
||||
enum rarch_core_type
|
||||
{
|
||||
CORE_TYPE_PLAIN = 0,
|
||||
CORE_TYPE_DUMMY,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -168,12 +174,14 @@ extern size_t (*pretro_get_memory_size)(unsigned);
|
||||
|
||||
/**
|
||||
* init_libretro_sym:
|
||||
* @dummy : Load dummy symbols if true
|
||||
* @type : Type of core to be loaded.
|
||||
* If CORE_TYPE_DUMMY, will
|
||||
* load dummy symbols.
|
||||
*
|
||||
* Initializes libretro symbols and
|
||||
* setups environment callback functions.
|
||||
**/
|
||||
void init_libretro_sym(bool dummy);
|
||||
void init_libretro_sym(enum rarch_core_type type);
|
||||
|
||||
/**
|
||||
* uninit_libretro_sym:
|
||||
|
@ -172,7 +172,7 @@ static void history_playlist_push(content_playlist_t *playlist,
|
||||
char tmp[PATH_MAX_LENGTH] = {0};
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
if (!playlist || global->libretro_dummy || !info)
|
||||
if (!playlist || (global->core_type == CORE_TYPE_DUMMY) || !info)
|
||||
return;
|
||||
|
||||
/* Path can be relative here.
|
||||
|
@ -100,7 +100,7 @@ static INLINE void gl_menu_frame_background(
|
||||
menu_display_set_viewport();
|
||||
|
||||
if ((settings->menu.pause_libretro
|
||||
|| !global->main_is_init || global->libretro_dummy)
|
||||
|| !global->main_is_init || (global->core_type == CORE_TYPE_DUMMY))
|
||||
&& !force_transparency
|
||||
&& texture)
|
||||
coords.color = color;
|
||||
|
@ -79,7 +79,7 @@ void menu_display_fb(void)
|
||||
|
||||
if (!settings->menu.pause_libretro)
|
||||
{
|
||||
if (global->main_is_init && !global->libretro_dummy)
|
||||
if (global->main_is_init && (global->core_type != CORE_TYPE_DUMMY))
|
||||
{
|
||||
bool block_libretro_input = driver->block_libretro_input;
|
||||
driver->block_libretro_input = true;
|
||||
|
@ -1434,7 +1434,7 @@ static int menu_displaylist_parse_options(menu_displaylist_info_t *info)
|
||||
menu_hash_to_str(MENU_LABEL_VALUE_CORE_CHEAT_OPTIONS),
|
||||
menu_hash_to_str(MENU_LABEL_CORE_CHEAT_OPTIONS),
|
||||
MENU_SETTING_ACTION, 0, 0);
|
||||
if (!global->libretro_dummy && global->system.disk_control.get_num_images)
|
||||
if ((global->core_type != CORE_TYPE_DUMMY) && global->system.disk_control.get_num_images)
|
||||
menu_list_push(info->list,
|
||||
menu_hash_to_str(MENU_LABEL_VALUE_DISK_OPTIONS),
|
||||
menu_hash_to_str(MENU_LABEL_DISK_OPTIONS),
|
||||
@ -1461,7 +1461,7 @@ static int menu_displaylist_parse_horizontal_content_actions(menu_displaylist_in
|
||||
if (!menu)
|
||||
return -1;
|
||||
|
||||
if (global->main_is_init && !global->libretro_dummy &&
|
||||
if (global->main_is_init && (global->core_type != CORE_TYPE_DUMMY) &&
|
||||
!strcmp(menu->deferred_path, global->fullpath))
|
||||
{
|
||||
menu_list_push(info->list,
|
||||
|
@ -3642,7 +3642,7 @@ static bool setting_append_list_main_menu_options(
|
||||
parent_group);
|
||||
settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED);
|
||||
}
|
||||
if (global->main_is_init && !global->libretro_dummy)
|
||||
if (global->main_is_init && (global->core_type != CORE_TYPE_DUMMY))
|
||||
{
|
||||
CONFIG_ACTION(
|
||||
menu_hash_to_str(MENU_LABEL_SAVE_STATE),
|
||||
|
@ -299,7 +299,7 @@ bool recording_init(void)
|
||||
if (!global->record.enable)
|
||||
return false;
|
||||
|
||||
if (global->libretro_dummy)
|
||||
if (global->core_type == CORE_TYPE_DUMMY)
|
||||
{
|
||||
RARCH_WARN(RETRO_LOG_INIT_RECORDING_SKIPPED);
|
||||
return false;
|
||||
|
10
retroarch.c
10
retroarch.c
@ -429,7 +429,7 @@ static void parse_input(int argc, char *argv[])
|
||||
global_t *global = global_get_ptr();
|
||||
|
||||
global->libretro_no_content = false;
|
||||
global->libretro_dummy = false;
|
||||
global->core_type = CORE_TYPE_PLAIN;
|
||||
global->has_set_save_path = false;
|
||||
global->has_set_state_path = false;
|
||||
global->has_set_libretro = false;
|
||||
@ -458,7 +458,7 @@ static void parse_input(int argc, char *argv[])
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
global->libretro_dummy = true;
|
||||
global->core_type = CORE_TYPE_DUMMY;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -713,7 +713,7 @@ static void parse_input(int argc, char *argv[])
|
||||
switch (val)
|
||||
{
|
||||
case RA_OPT_MENU:
|
||||
global->libretro_dummy = true;
|
||||
global->core_type = CORE_TYPE_DUMMY;
|
||||
break;
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
@ -823,7 +823,7 @@ static void parse_input(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (global->libretro_dummy)
|
||||
if (global->core_type == CORE_TYPE_DUMMY)
|
||||
{
|
||||
if (optind < argc)
|
||||
{
|
||||
@ -1184,7 +1184,7 @@ int rarch_main_init(int argc, char *argv[])
|
||||
validate_cpu_features();
|
||||
config_load();
|
||||
|
||||
init_libretro_sym(global->libretro_dummy);
|
||||
init_libretro_sym(global->core_type);
|
||||
init_system_info();
|
||||
|
||||
init_drivers_pre();
|
||||
|
@ -425,7 +425,7 @@ static void do_state_check_menu_toggle(void)
|
||||
|
||||
if (menu_driver_alive())
|
||||
{
|
||||
if (global->main_is_init && !global->libretro_dummy)
|
||||
if (global->main_is_init && (global->core_type != CORE_TYPE_DUMMY))
|
||||
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
|
||||
return;
|
||||
}
|
||||
@ -462,7 +462,7 @@ static int do_pre_state_checks(event_cmd_state_t *cmd)
|
||||
event_command(EVENT_CMD_GRAB_MOUSE_TOGGLE);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (cmd->menu_pressed || (global->libretro_dummy))
|
||||
if (cmd->menu_pressed || (global->core_type == CORE_TYPE_DUMMY))
|
||||
do_state_check_menu_toggle();
|
||||
#endif
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "autosave.h"
|
||||
#include "movie.h"
|
||||
#include "cheats.h"
|
||||
#include "dynamic.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -319,7 +320,7 @@ typedef struct global
|
||||
jmp_buf error_sjlj_context;
|
||||
|
||||
bool libretro_no_content;
|
||||
bool libretro_dummy;
|
||||
enum rarch_core_type core_type;
|
||||
|
||||
/* Config file associated with per-core configs. */
|
||||
char core_specific_config_path[PATH_MAX_LENGTH];
|
||||
|
Loading…
x
Reference in New Issue
Block a user