mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 07:13:35 +00:00
Remove general.c and move functions to retroarch.c
This commit is contained in:
parent
1ddf138860
commit
a10435a476
@ -99,7 +99,6 @@ OBJ += frontend/frontend.o \
|
|||||||
rarch_compr_file_path.o \
|
rarch_compr_file_path.o \
|
||||||
hash.o \
|
hash.o \
|
||||||
driver.o \
|
driver.o \
|
||||||
general.o \
|
|
||||||
settings.o \
|
settings.o \
|
||||||
settings_list.o \
|
settings_list.o \
|
||||||
settings_data.o \
|
settings_data.o \
|
||||||
|
153
general.c
153
general.c
@ -1,153 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
|
||||||
* Copyright (C) 2012-2015 - Michael Lelli
|
|
||||||
*
|
|
||||||
* 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"
|
|
||||||
#include "settings.h"
|
|
||||||
#include "retroarch.h"
|
|
||||||
#include "dynamic.h"
|
|
||||||
#include <file/file_path.h>
|
|
||||||
|
|
||||||
void rarch_playlist_load_content(content_playlist_t *playlist,
|
|
||||||
unsigned idx)
|
|
||||||
{
|
|
||||||
const char *path = NULL;
|
|
||||||
const char *core_path = NULL;
|
|
||||||
|
|
||||||
content_playlist_get_index(playlist,
|
|
||||||
idx, &path, &core_path, NULL);
|
|
||||||
|
|
||||||
strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro));
|
|
||||||
|
|
||||||
driver.menu->load_no_content = (path) ? false : true;
|
|
||||||
|
|
||||||
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path);
|
|
||||||
|
|
||||||
rarch_main_command(RARCH_CMD_LOAD_CORE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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,
|
|
||||||
const char *path, const char *menu_label,
|
|
||||||
char *deferred_path, size_t sizeof_deferred_path)
|
|
||||||
{
|
|
||||||
char new_core_path[PATH_MAX_LENGTH];
|
|
||||||
const core_info_t *info = NULL;
|
|
||||||
size_t supported = 0;
|
|
||||||
|
|
||||||
fill_pathname_join(deferred_path, dir, path, sizeof_deferred_path);
|
|
||||||
|
|
||||||
#ifdef HAVE_COMPRESSION
|
|
||||||
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)] = '#';
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (core_info)
|
|
||||||
core_info_list_get_supported_cores(core_info, deferred_path, &info,
|
|
||||||
&supported);
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Can make a decision right now. */
|
|
||||||
if (supported == 1)
|
|
||||||
{
|
|
||||||
strlcpy(g_extern.fullpath, deferred_path,
|
|
||||||
sizeof(g_extern.fullpath));
|
|
||||||
if (path_file_exists(new_core_path))
|
|
||||||
strlcpy(g_settings.libretro, new_core_path,
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void rarch_update_system_info(struct retro_system_info *_info,
|
|
||||||
bool *load_no_content)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
12
general.h
12
general.h
@ -839,18 +839,6 @@ extern struct defaults g_defaults;
|
|||||||
/* Public functions. */
|
/* Public functions. */
|
||||||
int rarch_main(int argc, char *argv[]);
|
int rarch_main(int argc, char *argv[]);
|
||||||
|
|
||||||
bool rarch_replace_config(const char *path);
|
|
||||||
|
|
||||||
void rarch_playlist_load_content(content_playlist_t *playlist,
|
|
||||||
unsigned index);
|
|
||||||
|
|
||||||
int rarch_defer_core(core_info_list_t *data,
|
|
||||||
const char *dir, const char *path, const char *menu_label,
|
|
||||||
char *deferred_path, size_t sizeof_deferred_path);
|
|
||||||
|
|
||||||
void rarch_update_system_info(struct retro_system_info *info,
|
|
||||||
bool *load_no_content);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -611,7 +611,6 @@ MAIN
|
|||||||
/*============================================================
|
/*============================================================
|
||||||
RETROARCH
|
RETROARCH
|
||||||
============================================================ */
|
============================================================ */
|
||||||
#include "../general.c"
|
|
||||||
#include "../libretro_version_1.c"
|
#include "../libretro_version_1.c"
|
||||||
#include "../retroarch.c"
|
#include "../retroarch.c"
|
||||||
#include "../runloop.c"
|
#include "../runloop.c"
|
||||||
|
131
retroarch.c
131
retroarch.c
@ -2882,3 +2882,134 @@ void rarch_main_deinit(void)
|
|||||||
|
|
||||||
g_extern.main_is_init = false;
|
g_extern.main_is_init = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rarch_playlist_load_content(content_playlist_t *playlist,
|
||||||
|
unsigned idx)
|
||||||
|
{
|
||||||
|
const char *path = NULL;
|
||||||
|
const char *core_path = NULL;
|
||||||
|
|
||||||
|
content_playlist_get_index(playlist,
|
||||||
|
idx, &path, &core_path, NULL);
|
||||||
|
|
||||||
|
strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro));
|
||||||
|
|
||||||
|
driver.menu->load_no_content = (path) ? false : true;
|
||||||
|
|
||||||
|
rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path);
|
||||||
|
|
||||||
|
rarch_main_command(RARCH_CMD_LOAD_CORE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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,
|
||||||
|
const char *path, const char *menu_label,
|
||||||
|
char *deferred_path, size_t sizeof_deferred_path)
|
||||||
|
{
|
||||||
|
char new_core_path[PATH_MAX_LENGTH];
|
||||||
|
const core_info_t *info = NULL;
|
||||||
|
size_t supported = 0;
|
||||||
|
|
||||||
|
fill_pathname_join(deferred_path, dir, path, sizeof_deferred_path);
|
||||||
|
|
||||||
|
#ifdef HAVE_COMPRESSION
|
||||||
|
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)] = '#';
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (core_info)
|
||||||
|
core_info_list_get_supported_cores(core_info, deferred_path, &info,
|
||||||
|
&supported);
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Can make a decision right now. */
|
||||||
|
if (supported == 1)
|
||||||
|
{
|
||||||
|
strlcpy(g_extern.fullpath, deferred_path,
|
||||||
|
sizeof(g_extern.fullpath));
|
||||||
|
if (path_file_exists(new_core_path))
|
||||||
|
strlcpy(g_settings.libretro, new_core_path,
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rarch_update_system_info(struct retro_system_info *_info,
|
||||||
|
bool *load_no_content)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
12
retroarch.h
12
retroarch.h
@ -47,6 +47,18 @@ void rarch_disk_control_append_image(const char *path);
|
|||||||
void rarch_recording_dump_frame(const void *data, unsigned width,
|
void rarch_recording_dump_frame(const void *data, unsigned width,
|
||||||
unsigned height, size_t pitch);
|
unsigned height, size_t pitch);
|
||||||
|
|
||||||
|
bool rarch_replace_config(const char *path);
|
||||||
|
|
||||||
|
void rarch_playlist_load_content(content_playlist_t *playlist,
|
||||||
|
unsigned index);
|
||||||
|
|
||||||
|
int rarch_defer_core(core_info_list_t *data,
|
||||||
|
const char *dir, const char *path, const char *menu_label,
|
||||||
|
char *deferred_path, size_t sizeof_deferred_path);
|
||||||
|
|
||||||
|
void rarch_update_system_info(struct retro_system_info *info,
|
||||||
|
bool *load_no_content);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user