Move retroarch_get_launch_arguments() function call outside

of frontend driver - should be called by Salamander too which
has no conception of RetroArch launch arguments
This commit is contained in:
twinaphex 2020-02-01 17:42:18 +01:00
parent c2852bdefe
commit 85d64602ff
17 changed files with 57 additions and 59 deletions

View File

@ -489,17 +489,17 @@ void discord_init(const char *discord_app_id)
#ifdef _WIN32 #ifdef _WIN32
fill_pathname_application_path(full_path, sizeof(full_path)); fill_pathname_application_path(full_path, sizeof(full_path));
if (strstr(get_retroarch_launch_arguments(), full_path)) if (strstr(retroarch_get_launch_arguments(), full_path))
strlcpy(command, get_retroarch_launch_arguments(), sizeof(command)); strlcpy(command, retroarch_get_launch_arguments(), sizeof(command));
else else
{ {
path_basedir(full_path); path_basedir(full_path);
snprintf(command, sizeof(command), "%s%s", snprintf(command, sizeof(command), "%s%s",
full_path, get_retroarch_launch_arguments()); full_path, retroarch_get_launch_arguments());
} }
#else #else
snprintf(command, sizeof(command), "sh -c %s", snprintf(command, sizeof(command), "sh -c %s",
get_retroarch_launch_arguments()); retroarch_get_launch_arguments());
#endif #endif
RARCH_LOG("[discord] registering startup command: %s\n", command); RARCH_LOG("[discord] registering startup command: %s\n", command);
Discord_Register(discord_app_id, command); Discord_Register(discord_app_id, command);

View File

@ -300,7 +300,7 @@ static bool frontend_ctr_set_fork(enum frontend_fork fork_mode)
} }
#endif #endif
static void frontend_ctr_exitspawn(char* s, size_t len) static void frontend_ctr_exitspawn(char* s, size_t len, char *args)
{ {
bool should_load_game = false; bool should_load_game = false;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER

View File

@ -366,7 +366,7 @@ static void frontend_gx_exec(const char *path, bool should_load_game)
#endif #endif
} }
static void frontend_gx_exitspawn(char *s, size_t len) static void frontend_gx_exitspawn(char *s, size_t len, char *args)
{ {
bool should_load_game = false; bool should_load_game = false;
#if defined(IS_SALAMANDER) #if defined(IS_SALAMANDER)

View File

@ -293,7 +293,7 @@ static bool frontend_orbis_set_fork(enum frontend_fork fork_mode)
} }
#endif #endif
static void frontend_orbis_exitspawn(char *s, size_t len) static void frontend_orbis_exitspawn(char *s, size_t len, char *args)
{ {
bool should_load_game = false; bool should_load_game = false;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER

View File

@ -298,9 +298,9 @@ static bool frontend_ps2_set_fork(enum frontend_fork fork_mode)
} }
#endif #endif
static void frontend_ps2_exitspawn(char *core_path, size_t core_path_size) static void frontend_ps2_exitspawn(char *s, size_t len, char *args)
{ {
bool should_load_game = false; bool should_load_content = false;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
if (ps2_fork_mode == FRONTEND_FORK_NONE) if (ps2_fork_mode == FRONTEND_FORK_NONE)
return; return;
@ -308,14 +308,14 @@ static void frontend_ps2_exitspawn(char *core_path, size_t core_path_size)
switch (ps2_fork_mode) switch (ps2_fork_mode)
{ {
case FRONTEND_FORK_CORE_WITH_ARGS: case FRONTEND_FORK_CORE_WITH_ARGS:
should_load_game = true; should_load_content = true;
break; break;
case FRONTEND_FORK_NONE: case FRONTEND_FORK_NONE:
default: default:
break; break;
} }
#endif #endif
frontend_ps2_exec(core_path, should_load_game); frontend_ps2_exec(s, should_load_content);
} }
static void frontend_ps2_shutdown(bool unused) static void frontend_ps2_shutdown(bool unused)

View File

@ -465,7 +465,7 @@ static void frontend_ps3_exec(const char *path, bool should_load_game)
#endif #endif
} }
static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size) static void frontend_ps3_exitspawn(char *s, size_t len, char *args)
{ {
#ifdef HAVE_RARCH_EXEC #ifdef HAVE_RARCH_EXEC
bool should_load_game = false; bool should_load_game = false;
@ -495,7 +495,7 @@ static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size)
} }
#endif #endif
frontend_ps3_exec(core_path, should_load_game); frontend_ps3_exec(s, should_load_game);
#ifdef IS_SALAMANDER #ifdef IS_SALAMANDER
cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME); cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME);

View File

@ -374,9 +374,9 @@ static bool frontend_psp_set_fork(enum frontend_fork fork_mode)
} }
#endif #endif
static void frontend_psp_exitspawn(char *s, size_t len) static void frontend_psp_exitspawn(char *s, size_t len, char *args)
{ {
bool should_load_game = false; bool should_load_content = false;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
if (psp_fork_mode == FRONTEND_FORK_NONE) if (psp_fork_mode == FRONTEND_FORK_NONE)
return; return;
@ -384,14 +384,14 @@ static void frontend_psp_exitspawn(char *s, size_t len)
switch (psp_fork_mode) switch (psp_fork_mode)
{ {
case FRONTEND_FORK_CORE_WITH_ARGS: case FRONTEND_FORK_CORE_WITH_ARGS:
should_load_game = true; should_load_content = true;
break; break;
case FRONTEND_FORK_NONE: case FRONTEND_FORK_NONE:
default: default:
break; break;
} }
#endif #endif
frontend_psp_exec(s, should_load_game); frontend_psp_exec(s, should_load_content);
} }
static int frontend_psp_get_rating(void) static int frontend_psp_get_rating(void)

View File

@ -395,9 +395,9 @@ static bool frontend_switch_set_fork(enum frontend_fork fork_mode)
} }
#endif #endif
static void frontend_switch_exitspawn(char *s, size_t len) static void frontend_switch_exitspawn(char *s, size_t len, char *args)
{ {
bool should_load_game = false; bool should_load_content = false;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
if (switch_fork_mode == FRONTEND_FORK_NONE) if (switch_fork_mode == FRONTEND_FORK_NONE)
return; return;
@ -405,13 +405,13 @@ static void frontend_switch_exitspawn(char *s, size_t len)
switch (switch_fork_mode) switch (switch_fork_mode)
{ {
case FRONTEND_FORK_CORE_WITH_ARGS: case FRONTEND_FORK_CORE_WITH_ARGS:
should_load_game = true; should_load_content = true;
break; break;
default: default:
break; break;
} }
#endif #endif
frontend_switch_exec(s, should_load_game); frontend_switch_exec(s, should_load_content);
} }
#if 0 #if 0

View File

@ -2066,7 +2066,7 @@ static bool frontend_unix_set_fork(enum frontend_fork fork_mode)
return true; return true;
} }
static void frontend_unix_exec(const char *path, bool should_load_game) static void frontend_unix_exec(const char *path, bool should_load_content)
{ {
char *newargv[] = { NULL, NULL }; char *newargv[] = { NULL, NULL };
size_t len = strlen(path); size_t len = strlen(path);
@ -2078,9 +2078,9 @@ static void frontend_unix_exec(const char *path, bool should_load_game)
execv(path, newargv); execv(path, newargv);
} }
static void frontend_unix_exitspawn(char *core_path, size_t core_path_size) static void frontend_unix_exitspawn(char *s, size_t len, char *args)
{ {
bool should_load_game = false; bool should_load_content = false;
if (unix_fork_mode == FRONTEND_FORK_NONE) if (unix_fork_mode == FRONTEND_FORK_NONE)
return; return;
@ -2088,14 +2088,14 @@ static void frontend_unix_exitspawn(char *core_path, size_t core_path_size)
switch (unix_fork_mode) switch (unix_fork_mode)
{ {
case FRONTEND_FORK_CORE_WITH_ARGS: case FRONTEND_FORK_CORE_WITH_ARGS:
should_load_game = true; should_load_content = true;
break; break;
case FRONTEND_FORK_NONE: case FRONTEND_FORK_NONE:
default: default:
break; break;
} }
frontend_unix_exec(core_path, should_load_game); frontend_unix_exec(s, should_load_content);
} }
#endif #endif

View File

@ -192,7 +192,7 @@ static int frontend_wiiu_parse_drive_list(void *data, bool load_content)
return 0; return 0;
} }
static void frontend_wiiu_exec(const char *path, bool should_load_game) static void frontend_wiiu_exec(const char *path, bool should_load_content)
{ {
struct struct
@ -219,7 +219,7 @@ static void frontend_wiiu_exec(const char *path, bool should_load_game)
RARCH_LOG("Attempt to load core: [%s].\n", path); RARCH_LOG("Attempt to load core: [%s].\n", path);
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT)) if (should_load_content && !path_is_empty(RARCH_PATH_CONTENT))
{ {
strcpy(param->args + len, path_get(RARCH_PATH_CONTENT)); strcpy(param->args + len, path_get(RARCH_PATH_CONTENT));
param->argv[param->argc] = param->args + len; param->argv[param->argc] = param->args + len;
@ -273,9 +273,9 @@ static bool frontend_wiiu_set_fork(enum frontend_fork fork_mode)
} }
#endif #endif
static void frontend_wiiu_exitspawn(char *s, size_t len) static void frontend_wiiu_exitspawn(char *s, size_t len, char *args)
{ {
bool should_load_game = false; bool should_load_content = false;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
if (wiiu_fork_mode == FRONTEND_FORK_NONE) if (wiiu_fork_mode == FRONTEND_FORK_NONE)
return; return;
@ -283,13 +283,13 @@ static void frontend_wiiu_exitspawn(char *s, size_t len)
switch (wiiu_fork_mode) switch (wiiu_fork_mode)
{ {
case FRONTEND_FORK_CORE_WITH_ARGS: case FRONTEND_FORK_CORE_WITH_ARGS:
should_load_game = true; should_load_content = true;
break; break;
default: default:
break; break;
} }
#endif #endif
frontend_wiiu_exec(s, should_load_game); frontend_wiiu_exec(s, should_load_content);
} }
frontend_ctx_driver_t frontend_ctx_wiiu = frontend_ctx_driver_t frontend_ctx_wiiu =

View File

@ -45,7 +45,6 @@
#include "../frontend_driver.h" #include "../frontend_driver.h"
#include "../../configuration.h" #include "../../configuration.h"
#include "../../defaults.h" #include "../../defaults.h"
#include "../../retroarch.h"
#include "../../verbosity.h" #include "../../verbosity.h"
#include "../../ui/drivers/ui_win32.h" #include "../../ui/drivers/ui_win32.h"
#include "../../paths.h" #include "../../paths.h"
@ -69,9 +68,8 @@ static char win32_cpu_model_name[64] = {0};
VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL); VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL);
static bool dwm_composition_disabled; static bool dwm_composition_disabled = false;
static bool console_needs_free = false;
static bool console_needs_free;
#if defined(HAVE_LANGEXTRA) && !defined(_XBOX) #if defined(HAVE_LANGEXTRA) && !defined(_XBOX)
#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500) || !defined(_MSC_VER) #if (defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500) || !defined(_MSC_VER)
@ -676,7 +674,7 @@ enum retro_language frontend_win32_get_user_language(void)
#if defined(_WIN32) && !defined(_XBOX) #if defined(_WIN32) && !defined(_XBOX)
enum frontend_fork win32_fork_mode; enum frontend_fork win32_fork_mode;
static void frontend_win32_respawn(char *s, size_t len) static void frontend_win32_respawn(char *s, size_t len, char *args)
{ {
STARTUPINFO si; STARTUPINFO si;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
@ -685,17 +683,17 @@ static void frontend_win32_respawn(char *s, size_t len)
if (win32_fork_mode != FRONTEND_FORK_RESTART) if (win32_fork_mode != FRONTEND_FORK_RESTART)
return; return;
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
memset(&pi, 0, sizeof(pi));
fill_pathname_application_path(executable_path, fill_pathname_application_path(executable_path,
sizeof(executable_path)); sizeof(executable_path));
path_set(RARCH_PATH_CORE, executable_path); path_set(RARCH_PATH_CORE, executable_path);
RARCH_LOG("Restarting RetroArch with commandline: %s and %s\n", RARCH_LOG("Restarting RetroArch with commandline: %s and %s\n",
executable_path, get_retroarch_launch_arguments()); executable_path, args);
if(!CreateProcess( executable_path, get_retroarch_launch_arguments(), memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
memset(&pi, 0, sizeof(pi));
if(!CreateProcess( executable_path, args,
NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{ {
RARCH_LOG("Failed to restart RetroArch\n"); RARCH_LOG("Failed to restart RetroArch\n");

View File

@ -251,7 +251,7 @@ static void frontend_xdk_init(void *data)
#endif #endif
} }
static void frontend_xdk_exec(const char *path, bool should_load_game) static void frontend_xdk_exec(const char *path, bool should_load_content)
{ {
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
bool original_verbose = verbosity_is_enabled(); bool original_verbose = verbosity_is_enabled();
@ -261,7 +261,6 @@ static void frontend_xdk_exec(const char *path, bool should_load_game)
#elif defined(_XBOX360) #elif defined(_XBOX360)
char game_path[1024] = {0}; char game_path[1024] = {0};
#endif #endif
(void)should_load_game;
#ifdef IS_SALAMANDER #ifdef IS_SALAMANDER
if (!string_is_empty(path)) if (!string_is_empty(path))
@ -270,13 +269,13 @@ static void frontend_xdk_exec(const char *path, bool should_load_game)
#if defined(_XBOX1) #if defined(_XBOX1)
memset(&ptr, 0, sizeof(ptr)); memset(&ptr, 0, sizeof(ptr));
if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT)) if (should_load_content && !path_is_empty(RARCH_PATH_CONTENT))
snprintf((char*)ptr.Data, sizeof(ptr.Data), "%s", path_get(RARCH_PATH_CONTENT)); snprintf((char*)ptr.Data, sizeof(ptr.Data), "%s", path_get(RARCH_PATH_CONTENT));
if (!string_is_empty(path)) if (!string_is_empty(path))
XLaunchNewImage(path, !string_is_empty((const char*)ptr.Data) ? &ptr : NULL); XLaunchNewImage(path, !string_is_empty((const char*)ptr.Data) ? &ptr : NULL);
#elif defined(_XBOX360) #elif defined(_XBOX360)
if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT)) if (should_load_content && !path_is_empty(RARCH_PATH_CONTENT))
{ {
strlcpy(game_path, path_get(RARCH_PATH_CONTENT), sizeof(game_path)); strlcpy(game_path, path_get(RARCH_PATH_CONTENT), sizeof(game_path));
XSetLaunchData(game_path, MAX_LAUNCH_DATA_SIZE); XSetLaunchData(game_path, MAX_LAUNCH_DATA_SIZE);
@ -322,9 +321,9 @@ static bool frontend_xdk_set_fork(enum frontend_fork fork_mode)
} }
#endif #endif
static void frontend_xdk_exitspawn(char *s, size_t len) static void frontend_xdk_exitspawn(char *s, size_t len, char *args)
{ {
bool should_load_game = false; bool should_load_content = false;
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
if (xdk_fork_mode == FRONTEND_FORK_NONE) if (xdk_fork_mode == FRONTEND_FORK_NONE)
return; return;
@ -332,14 +331,14 @@ static void frontend_xdk_exitspawn(char *s, size_t len)
switch (xdk_fork_mode) switch (xdk_fork_mode)
{ {
case FRONTEND_FORK_CORE_WITH_ARGS: case FRONTEND_FORK_CORE_WITH_ARGS:
should_load_game = true; should_load_content = true;
break; break;
case FRONTEND_FORK_NONE: case FRONTEND_FORK_NONE:
default: default:
break; break;
} }
#endif #endif
frontend_xdk_exec(s, should_load_game); frontend_xdk_exec(s, should_load_content);
} }
static int frontend_xdk_get_rating(void) static int frontend_xdk_get_rating(void)

View File

@ -368,12 +368,12 @@ const struct video_driver *frontend_driver_get_video_driver(void)
return frontend->get_video_driver(); return frontend->get_video_driver();
} }
void frontend_driver_exitspawn(char *s, size_t len) void frontend_driver_exitspawn(char *s, size_t len, char *args)
{ {
frontend_ctx_driver_t *frontend = frontend_get_ptr(); frontend_ctx_driver_t *frontend = frontend_get_ptr();
if (!frontend || !frontend->exitspawn) if (!frontend || !frontend->exitspawn)
return; return;
frontend->exitspawn(s, len); frontend->exitspawn(s, len, args);
} }
void frontend_driver_deinit(void *args) void frontend_driver_deinit(void *args)

View File

@ -81,7 +81,7 @@ typedef struct frontend_ctx_driver
environment_get_t environment_get; environment_get_t environment_get;
void (*init)(void *data); void (*init)(void *data);
void (*deinit)(void *data); void (*deinit)(void *data);
void (*exitspawn)(char *s, size_t len); void (*exitspawn)(char *s, size_t len, char *args);
process_args_t process_args; process_args_t process_args;
void (*exec)(const char *, bool); void (*exec)(const char *, bool);
@ -185,7 +185,7 @@ void frontend_driver_shutdown(bool a);
void frontend_driver_deinit(void *args); void frontend_driver_deinit(void *args);
void frontend_driver_exitspawn(char *s, size_t len); void frontend_driver_exitspawn(char *s, size_t len, char *args);
bool frontend_driver_has_fork(void); bool frontend_driver_has_fork(void);

View File

@ -192,7 +192,7 @@ int main(int argc, char *argv[])
frontend_ctx->deinit(args); frontend_ctx->deinit(args);
if (frontend_ctx && frontend_ctx->exitspawn) if (frontend_ctx && frontend_ctx->exitspawn)
frontend_ctx->exitspawn(libretro_path, sizeof(libretro_path)); frontend_ctx->exitspawn(libretro_path, sizeof(libretro_path), NULL);
return 1; return 1;
} }

View File

@ -7949,7 +7949,8 @@ void main_exit(void *args)
frontend_driver_deinit(args); frontend_driver_deinit(args);
frontend_driver_exitspawn( frontend_driver_exitspawn(
path_get_ptr(RARCH_PATH_CORE), path_get_ptr(RARCH_PATH_CORE),
path_get_realsize(RARCH_PATH_CORE)); path_get_realsize(RARCH_PATH_CORE),
retroarch_get_launch_arguments());
has_set_username = false; has_set_username = false;
rarch_is_inited = false; rarch_is_inited = false;
@ -27795,7 +27796,7 @@ struct retro_system_info *runloop_get_libretro_system_info(void)
return &runloop_system.info; return &runloop_system.info;
} }
char *get_retroarch_launch_arguments(void) char *retroarch_get_launch_arguments(void)
{ {
return launch_arguments; return launch_arguments;
} }

View File

@ -371,7 +371,7 @@ void retroarch_menu_running(void);
void retroarch_menu_running_finished(bool quit); void retroarch_menu_running_finished(bool quit);
char *get_retroarch_launch_arguments(void); char *retroarch_get_launch_arguments(void);
rarch_system_info_t *runloop_get_system_info(void); rarch_system_info_t *runloop_get_system_info(void);