mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
(Apple) Get rid of some hacks in the frontend code.
This commit is contained in:
parent
fe08806aa5
commit
9e2e135d19
@ -45,7 +45,6 @@ static bool use_tv_mode;
|
||||
id<RetroArch_Platform> apple_platform;
|
||||
|
||||
// From frontend/frontend_ios.c
|
||||
extern void* rarch_main(void* args);
|
||||
extern void apple_frontend_post_event(void (*fn)(void*), void* userdata);
|
||||
|
||||
|
||||
@ -101,6 +100,22 @@ static bool apple_is_paused;
|
||||
static bool apple_is_running;
|
||||
static RAModuleInfo* apple_core;
|
||||
|
||||
void* rarch_main_spring(void* args)
|
||||
{
|
||||
char** argv = args;
|
||||
|
||||
uint32_t argc = 0;
|
||||
while (argv && argv[argc ++]);
|
||||
|
||||
if (rarch_main(argc, argv))
|
||||
{
|
||||
rarch_main_clear_state();
|
||||
dispatch_async_f(dispatch_get_main_queue(), (void*)1, apple_rarch_exited);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void apple_run_core(RAModuleInfo* core, const char* file)
|
||||
{
|
||||
if (!apple_is_running)
|
||||
@ -110,23 +125,24 @@ void apple_run_core(RAModuleInfo* core, const char* file)
|
||||
apple_core = core;
|
||||
apple_is_running = true;
|
||||
|
||||
struct rarch_main_wrap* load_data = malloc(sizeof(struct rarch_main_wrap));
|
||||
memset(load_data, 0, sizeof(struct rarch_main_wrap));
|
||||
|
||||
load_data->config_path = strdup(apple_platform.retroarchConfigPath.UTF8String);
|
||||
|
||||
#ifdef IOS
|
||||
load_data->sram_path = strdup(RetroArch_iOS.get.systemDirectory.UTF8String);
|
||||
load_data->state_path = strdup(RetroArch_iOS.get.systemDirectory.UTF8String);
|
||||
#endif
|
||||
|
||||
static char config_path[PATH_MAX];
|
||||
static char core_path[PATH_MAX];
|
||||
static char file_path[PATH_MAX];
|
||||
|
||||
static const char* argv[] = { "retroarch", "-c", config_path, "-L", core_path, file_path, 0 };
|
||||
|
||||
strlcpy(config_path, apple_platform.retroarchConfigPath.UTF8String, sizeof(config_path));
|
||||
|
||||
if (file && core)
|
||||
{
|
||||
load_data->libretro_path = strdup(apple_core.path.UTF8String);
|
||||
load_data->rom_path = strdup(file);
|
||||
argv[3] = "-L";
|
||||
strlcpy(core_path, apple_core.path.UTF8String, sizeof(core_path));
|
||||
strlcpy(file_path, file, sizeof(file_path));
|
||||
}
|
||||
else
|
||||
argv[3] = 0;
|
||||
|
||||
if (pthread_create(&apple_retro_thread, 0, rarch_main, load_data))
|
||||
if (pthread_create(&apple_retro_thread, 0, rarch_main_spring, argv))
|
||||
{
|
||||
apple_rarch_exited((void*)1);
|
||||
return;
|
||||
|
@ -338,6 +338,8 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
|
||||
if (config)
|
||||
{
|
||||
config_set_string(config, "system_directory", [[RetroArch_iOS get].systemDirectory UTF8String]);
|
||||
config_set_string(config, "savefile_directory", [[RetroArch_iOS get].systemDirectory UTF8String]);
|
||||
config_set_string(config, "savestate_directory", [[RetroArch_iOS get].systemDirectory UTF8String]);
|
||||
[self writeSettings:nil toConfig:config];
|
||||
config_file_write(config, [_configPath UTF8String]);
|
||||
config_file_free(config);
|
||||
|
@ -124,20 +124,13 @@ void rarch_get_environment_console(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(IOS) || defined(OSX)
|
||||
void* rarch_main(void* args)
|
||||
{
|
||||
int argc = 0;
|
||||
char *argv = NULL;
|
||||
#elif defined(HAVE_BB10)
|
||||
#if defined(IOS) || defined(OSX) || defined(HAVE_BB10)
|
||||
int rarch_main(int argc, char *argv[])
|
||||
{
|
||||
void* args = NULL;
|
||||
#else
|
||||
int main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
void* args = NULL;
|
||||
#endif
|
||||
frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first();
|
||||
|
||||
if (frontend_ctx && frontend_ctx->init)
|
||||
@ -151,31 +144,16 @@ int main(int argc, char *argv[])
|
||||
frontend_ctx->environment_get(argc, argv, args);
|
||||
|
||||
#if !defined(RARCH_CONSOLE) && !defined(HAVE_BB10)
|
||||
#if defined(__APPLE__)
|
||||
struct rarch_main_wrap* argdata = (struct rarch_main_wrap*)args;
|
||||
int init_ret = rarch_main_init_wrap(argdata);
|
||||
apple_free_main_wrap(argdata);
|
||||
|
||||
if (init_ret)
|
||||
{
|
||||
rarch_main_clear_state();
|
||||
dispatch_async_f(dispatch_get_main_queue(), (void*)1, apple_rarch_exited);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
rarch_init_msg_queue();
|
||||
int init_ret;
|
||||
if ((init_ret = rarch_main_init(argc, argv))) return init_ret;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_MENU) || defined(HAVE_BB10)
|
||||
menu_init();
|
||||
|
||||
#ifndef __APPLE__
|
||||
if (frontend_ctx && frontend_ctx->process_args)
|
||||
frontend_ctx->process_args(argc, argv, args);
|
||||
#endif
|
||||
|
||||
#if defined(RARCH_CONSOLE) || defined(HAVE_BB10)
|
||||
g_extern.lifecycle_mode_state |= 1ULL << MODE_LOAD_GAME;
|
||||
|
@ -48,20 +48,6 @@ void apple_frontend_post_event(void (*fn)(void*), void* userdata)
|
||||
pthread_mutex_unlock(&apple_event_queue_lock);
|
||||
}
|
||||
|
||||
static void apple_free_main_wrap(struct rarch_main_wrap* wrap)
|
||||
{
|
||||
if (wrap)
|
||||
{
|
||||
free((char*)wrap->libretro_path);
|
||||
free((char*)wrap->rom_path);
|
||||
free((char*)wrap->sram_path);
|
||||
free((char*)wrap->state_path);
|
||||
free((char*)wrap->config_path);
|
||||
}
|
||||
|
||||
free(wrap);
|
||||
}
|
||||
|
||||
static void process_events(void)
|
||||
{
|
||||
pthread_mutex_lock(&apple_event_queue_lock);
|
||||
@ -83,24 +69,8 @@ static void system_shutdown(bool force)
|
||||
dispatch_async_f(dispatch_get_main_queue(), 0, apple_rarch_exited);
|
||||
}
|
||||
|
||||
static void environment_get(int argc, char *argv[], void *args)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
(void)args;
|
||||
|
||||
#ifdef IOS
|
||||
char* system_directory = ios_get_rarch_system_directory();
|
||||
strlcpy(g_extern.savestate_dir, system_directory, sizeof(g_extern.savestate_dir));
|
||||
strlcpy(g_extern.savefile_dir, system_directory, sizeof(g_extern.savefile_dir));
|
||||
free(system_directory);
|
||||
|
||||
config_load();
|
||||
#endif
|
||||
}
|
||||
|
||||
const frontend_ctx_driver_t frontend_ctx_apple = {
|
||||
environment_get, /* environment_get */
|
||||
NULL, /* environment_get */
|
||||
NULL, /* init */
|
||||
NULL, /* deinit */
|
||||
NULL, /* exitspawn */
|
||||
|
@ -676,11 +676,7 @@ bool config_save_keybinds(const char *path);
|
||||
void rarch_game_reset(void);
|
||||
void rarch_main_clear_state(void);
|
||||
void rarch_init_system_info(void);
|
||||
#ifdef __APPLE__
|
||||
void * rarch_main(void *args);
|
||||
#else
|
||||
int rarch_main(int argc, char *argv[]);
|
||||
#endif
|
||||
int rarch_main_init_wrap(const struct rarch_main_wrap *args);
|
||||
int rarch_main_init(int argc, char *argv[]);
|
||||
bool rarch_main_idle_iterate(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user