mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 16:39:43 +00:00
Merge branch 'master' of https://github.com/Themaister/RetroArch
Conflicts: console/rarch_console_main_wrap.c console/rarch_console_main_wrap.h
This commit is contained in:
commit
d94dc34b17
@ -231,7 +231,7 @@ static void jni_get (void *data_in, void *data_out)
|
||||
|
||||
CALL_OBJ_METHOD_PARAM(in_params->env, ret_char, obj, giid, (*in_params->env)->NewStringUTF(in_params->env, out_args->in));
|
||||
|
||||
if(giid != NULL && ret_char)
|
||||
if (giid != NULL && ret_char)
|
||||
{
|
||||
const char *test_argv = (*in_params->env)->GetStringUTFChars(in_params->env, ret_char, 0);
|
||||
strncpy(out_args->out, test_argv, out_args->out_sizeof);
|
||||
@ -239,9 +239,8 @@ static void jni_get (void *data_in, void *data_out)
|
||||
}
|
||||
}
|
||||
|
||||
static int android_app_set_argv (void *data, char** argv)
|
||||
static bool android_app_start_main(struct android_app *android_app, int *init_ret)
|
||||
{
|
||||
struct android_app *android_app = (struct android_app*)data;
|
||||
char rom_path[PATH_MAX];
|
||||
char libretro_path[PATH_MAX];
|
||||
char config_file[PATH_MAX];
|
||||
@ -283,7 +282,6 @@ static int android_app_set_argv (void *data, char** argv)
|
||||
strlcpy(out_args.in, "IME", sizeof(out_args.in));
|
||||
jni_get(&in_params, &out_args);
|
||||
|
||||
|
||||
(*in_params.java_vm)->DetachCurrentThread(in_params.java_vm);
|
||||
|
||||
RARCH_LOG("Checking arguments passed ...\n");
|
||||
@ -292,26 +290,33 @@ static int android_app_set_argv (void *data, char** argv)
|
||||
RARCH_LOG("Config file: [%s].\n", config_file);
|
||||
RARCH_LOG("Current IME: [%s].\n", android_app->current_ime);
|
||||
|
||||
int argc = 0;
|
||||
struct rarch_main_wrap args = {0};
|
||||
|
||||
argv[argc++] = strdup("retroarch");
|
||||
argv[argc++] = strdup(rom_path);
|
||||
argv[argc++] = strdup("-L");
|
||||
argv[argc++] = strdup(libretro_path);
|
||||
argv[argc++] = strdup("-v");
|
||||
if (*config_file)
|
||||
args.verbose = true;
|
||||
args.config_path = config_file;
|
||||
args.sram_path = NULL;
|
||||
args.state_path = NULL;
|
||||
args.rom_path = rom_path;
|
||||
args.libretro_path = libretro_path;
|
||||
|
||||
*init_ret = rarch_main_init_wrap(&args);
|
||||
|
||||
if (*init_ret == 0)
|
||||
{
|
||||
argv[argc++] = strdup("-c");
|
||||
argv[argc++] = strdup(config_file);
|
||||
RARCH_LOG("rarch_main_init succeeded.\n");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_ERR("rarch_main_init failed.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return argc;
|
||||
}
|
||||
|
||||
static void* android_app_entry(void *data)
|
||||
static void *android_app_entry(void *data)
|
||||
{
|
||||
struct android_app* android_app = (struct android_app*)data;
|
||||
int init_ret = -1;
|
||||
int init_ret = 0;
|
||||
|
||||
android_app->config = AConfiguration_new();
|
||||
AConfiguration_fromAssetManager(android_app->config, android_app->activity->assetManager);
|
||||
@ -330,30 +335,23 @@ static void* android_app_entry(void *data)
|
||||
memset(&g_android, 0, sizeof(g_android));
|
||||
g_android = android_app;
|
||||
|
||||
char *argv[MAX_ARGS] = {NULL};
|
||||
int argc = android_app_set_argv(android_app, argv);
|
||||
|
||||
RARCH_LOG("Native Activity started.\n");
|
||||
rarch_main_clear_state();
|
||||
|
||||
g_extern.verbose = true;
|
||||
|
||||
|
||||
while (!android_app->window)
|
||||
{
|
||||
if (!android_run_events(android_app))
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if ((init_ret = rarch_main_init(argc, argv)) != 0)
|
||||
RARCH_LOG("Initialization failed.\n");
|
||||
else
|
||||
RARCH_LOG("Initializing succeeded.\n");
|
||||
rarch_init_msg_queue();
|
||||
|
||||
if (init_ret == 0)
|
||||
if (!android_app_start_main(android_app, &init_ret))
|
||||
goto exit;
|
||||
|
||||
if (g_extern.main_is_init)
|
||||
{
|
||||
RARCH_LOG("RetroArch started.\n");
|
||||
rarch_init_msg_queue();
|
||||
|
||||
while ((input_key_pressed_func(RARCH_PAUSE_TOGGLE)) ?
|
||||
android_run_events(android_app) :
|
||||
@ -366,7 +364,7 @@ exit:
|
||||
android_app->activityState = APP_CMD_DEAD;
|
||||
RARCH_LOG("Deinitializing RetroArch...\n");
|
||||
|
||||
if (init_ret == 0)
|
||||
if (g_extern.main_is_init)
|
||||
rarch_main_deinit();
|
||||
|
||||
rarch_deinit_msg_queue();
|
||||
|
@ -19,67 +19,7 @@
|
||||
|
||||
#include "rarch_console_main_wrap.h"
|
||||
|
||||
#define MAX_ARGS 32
|
||||
|
||||
static int rarch_main_init_wrap(const struct rarch_main_wrap *args)
|
||||
{
|
||||
int argc = 0;
|
||||
char *argv[MAX_ARGS] = {NULL};
|
||||
|
||||
argv[argc++] = strdup("retroarch");
|
||||
|
||||
if (args->rom_path)
|
||||
argv[argc++] = strdup(args->rom_path);
|
||||
|
||||
if (args->sram_path)
|
||||
{
|
||||
argv[argc++] = strdup("-s");
|
||||
argv[argc++] = strdup(args->sram_path);
|
||||
}
|
||||
|
||||
if (args->state_path)
|
||||
{
|
||||
argv[argc++] = strdup("-S");
|
||||
argv[argc++] = strdup(args->state_path);
|
||||
}
|
||||
|
||||
if (args->config_path)
|
||||
{
|
||||
argv[argc++] = strdup("-c");
|
||||
argv[argc++] = strdup(args->config_path);
|
||||
}
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
if (args->libretro_path)
|
||||
{
|
||||
argv[argc++] = strdup("-L");
|
||||
argv[argc++] = strdup(args->libretro_path);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (args->verbose)
|
||||
argv[argc++] = strdup("-v");
|
||||
|
||||
#ifdef HAVE_FILE_LOGGER
|
||||
RARCH_LOG("foo\n");
|
||||
for(int i = 0; i < argc; i++)
|
||||
RARCH_LOG("arg #%d: %s\n", i, argv[i]);
|
||||
RARCH_LOG("bar\n");
|
||||
#endif
|
||||
|
||||
int ret = rarch_main_init(argc, argv);
|
||||
|
||||
char **tmp = argv;
|
||||
while (*tmp)
|
||||
{
|
||||
free(*tmp);
|
||||
tmp++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool rarch_startup (void)
|
||||
bool rarch_startup (const char * config_file)
|
||||
{
|
||||
const char *config_path = g_extern.config_path;
|
||||
|
||||
@ -89,23 +29,19 @@ bool rarch_startup (void)
|
||||
struct rarch_main_wrap args = {0};
|
||||
|
||||
args.verbose = g_extern.verbose;
|
||||
args.config_path = config_path;
|
||||
args.config_path = config_file;
|
||||
args.sram_path = g_extern.console.main_wrap.state.default_sram_dir.enable ? g_extern.console.main_wrap.paths.default_sram_dir : NULL,
|
||||
args.state_path = g_extern.console.main_wrap.state.default_savestate_dir.enable ? g_extern.console.main_wrap.paths.default_savestate_dir : NULL,
|
||||
args.rom_path = g_extern.file_state.rom_path;
|
||||
args.libretro_path = g_settings.libretro;
|
||||
|
||||
int init_ret = rarch_main_init_wrap(&args);
|
||||
(void)init_ret;
|
||||
|
||||
if(init_ret == 0)
|
||||
g_extern.console.rmenu.mode = MODE_EMULATION;
|
||||
if (init_ret == 0)
|
||||
RARCH_LOG("rarch_main_init succeeded.\n");
|
||||
else
|
||||
{
|
||||
//failed to load the ROM for whatever reason
|
||||
g_extern.console.rmenu.mode = MODE_MENU;
|
||||
rarch_settings_msg(S_MSG_ROM_LOADING_ERROR, S_DELAY_180);
|
||||
|
||||
RARCH_ERR("rarch_main_init failed.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
11
general.h
11
general.h
@ -598,6 +598,16 @@ struct global
|
||||
jmp_buf error_sjlj_context;
|
||||
};
|
||||
|
||||
struct rarch_main_wrap
|
||||
{
|
||||
const char *rom_path;
|
||||
const char *sram_path;
|
||||
const char *state_path;
|
||||
const char *config_path;
|
||||
const char *libretro_path;
|
||||
bool verbose;
|
||||
};
|
||||
|
||||
// Public functions
|
||||
void config_load(void);
|
||||
void config_set_defaults(void);
|
||||
@ -616,6 +626,7 @@ bool config_save_keybinds(const char *path);
|
||||
void rarch_game_reset(void);
|
||||
void rarch_main_clear_state(void);
|
||||
int rarch_main(int argc, char *argv[]);
|
||||
int rarch_main_init_wrap(const struct rarch_main_wrap *args);
|
||||
int rarch_main_init(int argc, char *argv[]);
|
||||
bool rarch_main_iterate(void);
|
||||
void rarch_main_deinit(void);
|
||||
|
69
retroarch.c
69
retroarch.c
@ -2909,6 +2909,75 @@ static bool rarch_main_idle_iterate(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
#define MAX_ARGS 32
|
||||
int rarch_main_init_wrap(const struct rarch_main_wrap *args)
|
||||
{
|
||||
if (g_extern.main_is_init)
|
||||
rarch_main_deinit();
|
||||
|
||||
int argc = 0;
|
||||
char *argv[MAX_ARGS] = {NULL};
|
||||
char *argv_copy[MAX_ARGS];
|
||||
|
||||
argv[argc++] = strdup("retroarch");
|
||||
|
||||
if (args->rom_path)
|
||||
argv[argc++] = strdup(args->rom_path);
|
||||
|
||||
if (args->sram_path)
|
||||
{
|
||||
argv[argc++] = strdup("-s");
|
||||
argv[argc++] = strdup(args->sram_path);
|
||||
}
|
||||
|
||||
if (args->state_path)
|
||||
{
|
||||
argv[argc++] = strdup("-S");
|
||||
argv[argc++] = strdup(args->state_path);
|
||||
}
|
||||
|
||||
if (args->config_path)
|
||||
{
|
||||
argv[argc++] = strdup("-c");
|
||||
argv[argc++] = strdup(args->config_path);
|
||||
}
|
||||
|
||||
if (args->libretro_path)
|
||||
{
|
||||
argv[argc++] = strdup("-L");
|
||||
argv[argc++] = strdup(args->libretro_path);
|
||||
}
|
||||
|
||||
if (args->verbose)
|
||||
argv[argc++] = strdup("-v");
|
||||
|
||||
#ifdef HAVE_FILE_LOGGER
|
||||
for (int i = 0; i < argc; i++)
|
||||
RARCH_LOG("arg #%d: %s\n", i, argv[i]);
|
||||
#endif
|
||||
|
||||
// The pointers themselves are not const, and can be messed around with by getopt_long().
|
||||
memcpy(argv_copy, argv, sizeof(argv));
|
||||
|
||||
int ret = rarch_main_init(argc, argv);
|
||||
|
||||
#ifdef RARCH_CONSOLE
|
||||
if (ret == 0)
|
||||
g_extern.console.rmenu.mode = MODE_EMULATION;
|
||||
else
|
||||
{
|
||||
//failed to load the ROM for whatever reason
|
||||
g_extern.console.rmenu.mode = MODE_MENU;
|
||||
rarch_settings_msg(S_MSG_ROM_LOADING_ERROR, S_DELAY_180);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(argv_copy); i++)
|
||||
free(argv_copy[i]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int rarch_main(int argc, char *argv[])
|
||||
{
|
||||
int init_ret;
|
||||
|
Loading…
Reference in New Issue
Block a user