2014-09-19 05:34:34 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2012-2015 - Michael Lelli
|
2014-09-19 05:34:34 +00:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "general.h"
|
2015-01-09 15:56:21 +00:00
|
|
|
#include "settings.h"
|
2015-01-09 16:40:47 +00:00
|
|
|
#include "retroarch.h"
|
2014-10-22 02:27:51 +00:00
|
|
|
#include "dynamic.h"
|
2014-10-21 22:23:06 +00:00
|
|
|
#include <file/file_path.h>
|
2014-09-19 05:34:34 +00:00
|
|
|
|
|
|
|
void rarch_playlist_load_content(content_playlist_t *playlist,
|
2014-10-20 17:22:33 +00:00
|
|
|
unsigned idx)
|
2014-09-19 05:34:34 +00:00
|
|
|
{
|
|
|
|
const char *path = NULL;
|
|
|
|
const char *core_path = NULL;
|
|
|
|
|
|
|
|
content_playlist_get_index(playlist,
|
2014-10-20 17:22:33 +00:00
|
|
|
idx, &path, &core_path, NULL);
|
2014-09-19 05:34:34 +00:00
|
|
|
|
|
|
|
strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro));
|
2014-10-14 01:29:26 +00:00
|
|
|
|
|
|
|
driver.menu->load_no_content = (path) ? false : true;
|
|
|
|
|
2014-09-19 05:34:34 +00:00
|
|
|
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path);
|
|
|
|
|
|
|
|
rarch_main_command(RARCH_CMD_LOAD_CORE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void rarch_main_init_wrap(const struct rarch_main_wrap *args,
|
|
|
|
int *argc, char **argv)
|
|
|
|
{
|
|
|
|
*argc = 0;
|
|
|
|
argv[(*argc)++] = strdup("retroarch");
|
|
|
|
|
|
|
|
if (!args->no_content)
|
|
|
|
{
|
|
|
|
if (args->content_path)
|
|
|
|
{
|
|
|
|
RARCH_LOG("Using content: %s.\n", args->content_path);
|
|
|
|
argv[(*argc)++] = strdup(args->content_path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
RARCH_LOG("No content, starting dummy core.\n");
|
|
|
|
argv[(*argc)++] = strdup("--menu");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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_DYNAMIC
|
|
|
|
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
|
|
|
|
for (i = 0; i < *argc; i++)
|
|
|
|
RARCH_LOG("arg #%d: %s\n", i, argv[i]);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* When selection is presented back, returns 0.
|
|
|
|
* If it can make a decision right now, returns -1. */
|
|
|
|
|
|
|
|
int rarch_defer_core(core_info_list_t *core_info, const char *dir,
|
2014-12-22 17:56:58 +00:00
|
|
|
const char *path, const char *menu_label,
|
|
|
|
char *deferred_path, size_t sizeof_deferred_path)
|
2014-09-19 05:34:34 +00:00
|
|
|
{
|
2015-01-07 19:42:36 +00:00
|
|
|
char new_core_path[PATH_MAX_LENGTH];
|
2014-09-19 05:34:34 +00:00
|
|
|
const core_info_t *info = NULL;
|
|
|
|
size_t supported = 0;
|
|
|
|
|
|
|
|
fill_pathname_join(deferred_path, dir, path, sizeof_deferred_path);
|
|
|
|
|
2014-12-15 16:29:29 +00:00
|
|
|
#ifdef HAVE_COMPRESSION
|
2014-09-21 15:37:23 +00:00
|
|
|
if (path_is_compressed_file(dir))
|
|
|
|
{
|
|
|
|
/* In case of a compressed archive, we have to join with a hash */
|
|
|
|
/* We are going to write at the position of dir: */
|
|
|
|
rarch_assert(strlen(dir) < strlen(deferred_path));
|
|
|
|
deferred_path[strlen(dir)] = '#';
|
|
|
|
}
|
2014-12-15 16:29:29 +00:00
|
|
|
#endif
|
2014-09-21 15:37:23 +00:00
|
|
|
|
2014-09-19 05:34:34 +00:00
|
|
|
if (core_info)
|
|
|
|
core_info_list_get_supported_cores(core_info, deferred_path, &info,
|
|
|
|
&supported);
|
|
|
|
|
2014-12-22 17:56:58 +00:00
|
|
|
if (!strcmp(menu_label, "load_content"))
|
|
|
|
{
|
|
|
|
strlcpy(new_core_path, g_extern.core_info_current->path, sizeof(new_core_path));
|
|
|
|
supported = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strlcpy(new_core_path, info->path, sizeof(new_core_path));
|
|
|
|
}
|
|
|
|
|
2014-09-19 05:34:34 +00:00
|
|
|
/* Can make a decision right now. */
|
|
|
|
if (supported == 1)
|
|
|
|
{
|
|
|
|
strlcpy(g_extern.fullpath, deferred_path,
|
|
|
|
sizeof(g_extern.fullpath));
|
2014-12-22 17:56:58 +00:00
|
|
|
if (path_file_exists(new_core_path))
|
|
|
|
strlcpy(g_settings.libretro, new_core_path,
|
2014-09-19 05:34:34 +00:00
|
|
|
sizeof(g_settings.libretro));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Quite intrusive and error prone.
|
|
|
|
* Likely to have lots of small bugs.
|
|
|
|
* Cleanly exit the main loop to ensure that all the tiny details
|
|
|
|
* get set properly.
|
|
|
|
*
|
|
|
|
* This should mitigate most of the smaller bugs. */
|
|
|
|
|
|
|
|
bool rarch_replace_config(const char *path)
|
|
|
|
{
|
|
|
|
/* If config file to be replaced is the same as the
|
|
|
|
* current config file, exit. */
|
|
|
|
if (!strcmp(path, g_extern.config_path))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (g_settings.config_save_on_exit && *g_extern.config_path)
|
|
|
|
config_save_file(g_extern.config_path);
|
|
|
|
|
|
|
|
strlcpy(g_extern.config_path, path, sizeof(g_extern.config_path));
|
|
|
|
g_extern.block_config_read = false;
|
|
|
|
*g_settings.libretro = '\0'; /* Load core in new config. */
|
|
|
|
|
|
|
|
rarch_main_command(RARCH_CMD_PREPARE_DUMMY);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-09-19 05:55:02 +00:00
|
|
|
void rarch_update_system_info(struct retro_system_info *_info,
|
|
|
|
bool *load_no_content)
|
2014-09-19 05:34:34 +00:00
|
|
|
{
|
|
|
|
const core_info_t *info = NULL;
|
|
|
|
#if defined(HAVE_DYNAMIC)
|
|
|
|
libretro_free_system_info(_info);
|
|
|
|
if (!(*g_settings.libretro))
|
|
|
|
return;
|
|
|
|
|
|
|
|
libretro_get_system_info(g_settings.libretro, _info,
|
|
|
|
load_no_content);
|
|
|
|
#endif
|
|
|
|
if (!g_extern.core_info)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!core_info_list_get_info(g_extern.core_info,
|
|
|
|
g_extern.core_info_current, g_settings.libretro))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Keep track of info for the currently selected core. */
|
|
|
|
info = (const core_info_t*)g_extern.core_info_current;
|
|
|
|
|
|
|
|
if (!g_extern.verbosity)
|
|
|
|
return;
|
|
|
|
|
|
|
|
RARCH_LOG("[Core Info]:\n");
|
|
|
|
if (info->display_name)
|
|
|
|
RARCH_LOG("Display Name = %s\n", info->display_name);
|
|
|
|
if (info->supported_extensions)
|
|
|
|
RARCH_LOG("Supported Extensions = %s\n",
|
|
|
|
info->supported_extensions);
|
|
|
|
if (info->authors)
|
|
|
|
RARCH_LOG("Authors = %s\n", info->authors);
|
|
|
|
if (info->permissions)
|
|
|
|
RARCH_LOG("Permissions = %s\n", info->permissions);
|
|
|
|
}
|