mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-11 20:44:24 +00:00
Add frontend_context.c - use for all console platform ports
(and other possible ports in future)
This commit is contained in:
parent
1549866703
commit
69381c2735
@ -19,7 +19,7 @@ endif
|
||||
STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe
|
||||
|
||||
PPU_CFLAGS += -I. -D__CELLOS_LV2__ -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_SYSUTILS -DHAVE_SYSMODULES -DHAVE_RARCH_EXEC
|
||||
PPU_SRCS = frontend/frontend_salamander.c file_path.c compat/compat.c conf/config_file.c
|
||||
PPU_SRCS = frontend/frontend_salamander.c frontend/frontend_context.c file_path.c compat/compat.c conf/config_file.c
|
||||
|
||||
ifeq ($(HAVE_LOGGER), 1)
|
||||
PPU_CFLAGS += -DHAVE_LOGGER -Iconsole/logger
|
||||
|
@ -24,6 +24,11 @@
|
||||
#include "menu/rmenu.h"
|
||||
#endif
|
||||
|
||||
#if defined(RARCH_CONSOLE)
|
||||
#include "frontend_context.h"
|
||||
frontend_ctx_driver_t *frontend_ctx;
|
||||
#endif
|
||||
|
||||
#if defined(__QNX__)
|
||||
#include <bps/bps.h>
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
@ -108,13 +113,13 @@ static bool libretro_install_core(const char *path_prefix,
|
||||
}
|
||||
#endif
|
||||
|
||||
static void rarch_preinit(void)
|
||||
static void system_preinit(void)
|
||||
{
|
||||
#if defined(__QNX__) && !defined(HAVE_BB10)
|
||||
//Initialize BPS libraries
|
||||
bps_initialize();
|
||||
#elif defined(RARCH_CONSOLE)
|
||||
system_init();
|
||||
frontend_ctx->init();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -196,6 +201,16 @@ static void system_shutdown(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int system_ctx_init(void)
|
||||
{
|
||||
#ifdef RARCH_CONSOLE
|
||||
if ((frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first()) == NULL)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
static pthread_mutex_t apple_event_queue_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
@ -252,7 +267,10 @@ void* rarch_main(void* args)
|
||||
int rarch_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
rarch_preinit();
|
||||
if (system_ctx_init() != 0)
|
||||
return 0;
|
||||
|
||||
system_preinit();
|
||||
|
||||
#if !defined(__APPLE__)
|
||||
rarch_main_clear_state();
|
||||
@ -290,7 +308,7 @@ int rarch_main(int argc, char *argv[])
|
||||
menu_init();
|
||||
|
||||
#ifdef RARCH_CONSOLE
|
||||
system_process_args(argc, argv);
|
||||
frontend_ctx->process_args(argc, argv);
|
||||
g_extern.lifecycle_mode_state |= 1ULL << MODE_LOAD_GAME;
|
||||
#else
|
||||
g_extern.lifecycle_mode_state |= 1ULL << MODE_GAME;
|
||||
@ -419,10 +437,10 @@ int rarch_main(int argc, char *argv[])
|
||||
fclose(g_extern.log_file);
|
||||
g_extern.log_file = NULL;
|
||||
#endif
|
||||
system_deinit();
|
||||
frontend_ctx->deinit();
|
||||
|
||||
if (g_extern.lifecycle_mode_state & (1ULL << MODE_EXITSPAWN))
|
||||
system_exitspawn();
|
||||
frontend_ctx->exitspawn();
|
||||
#endif
|
||||
|
||||
rarch_main_clear_state();
|
||||
|
52
frontend/frontend_context.c
Normal file
52
frontend/frontend_context.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
||||
*
|
||||
* 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 "frontend_context.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
static const frontend_ctx_driver_t *frontend_ctx_drivers[] = {
|
||||
#if defined(__CELLOS_LV2__)
|
||||
&frontend_ctx_ps3,
|
||||
#endif
|
||||
#if defined(_XBOX)
|
||||
&frontend_ctx_xdk,
|
||||
#endif
|
||||
#if defined(GEKKO)
|
||||
&frontend_ctx_gx,
|
||||
#endif
|
||||
};
|
||||
|
||||
const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident)
|
||||
{
|
||||
for (unsigned i = 0; i < sizeof(frontend_ctx_drivers) / sizeof(frontend_ctx_drivers[0]); i++)
|
||||
{
|
||||
if (strcmp(frontend_ctx_drivers[i]->ident, ident) == 0)
|
||||
return frontend_ctx_drivers[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const frontend_ctx_driver_t *frontend_ctx_init_first(void)
|
||||
{
|
||||
for (unsigned i = 0; i < sizeof(frontend_ctx_drivers) / sizeof(frontend_ctx_drivers[0]); i++)
|
||||
return frontend_ctx_drivers[i];
|
||||
|
||||
return NULL;
|
||||
}
|
48
frontend/frontend_context.h
Normal file
48
frontend/frontend_context.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2013 - Daniel De Matteis
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef __FRONTEND_CONTEXT_H
|
||||
#define __FRONTEND_CONTEXT_H
|
||||
|
||||
#include "../boolean.h"
|
||||
#include "../driver.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
typedef struct frontend_ctx_driver
|
||||
{
|
||||
void (*get_environment_settings)(int argc, char *argv[]);
|
||||
|
||||
void (*init)(void);
|
||||
void (*deinit)(void);
|
||||
void (*exitspawn)(void);
|
||||
|
||||
int (*process_args)(int argc, char *argv[]);
|
||||
|
||||
// Human readable string.
|
||||
const char *ident;
|
||||
} frontend_ctx_driver_t;
|
||||
|
||||
extern const frontend_ctx_driver_t frontend_ctx_gx;
|
||||
extern const frontend_ctx_driver_t frontend_ctx_ps3;
|
||||
extern const frontend_ctx_driver_t frontend_ctx_xdk;
|
||||
|
||||
const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident); // Finds driver with ident. Does not initialize.
|
||||
const frontend_ctx_driver_t *frontend_ctx_init_first(void); // Finds first suitable driver and initializes.
|
||||
|
||||
#endif
|
@ -22,6 +22,11 @@
|
||||
#include "../file_ext.h"
|
||||
#include "frontend_salamander.h"
|
||||
|
||||
#if defined(RARCH_CONSOLE)
|
||||
#include "frontend_context.h"
|
||||
frontend_ctx_driver_t *frontend_ctx;
|
||||
#endif
|
||||
|
||||
#if defined(__CELLOS_LV2__)
|
||||
#include "platform/platform_ps3_exec.c"
|
||||
#include "platform/platform_ps3.c"
|
||||
@ -86,13 +91,26 @@ static void find_first_libretro_core(char *first_file,
|
||||
dir_list_free(list);
|
||||
}
|
||||
|
||||
static int system_ctx_init(void)
|
||||
{
|
||||
#ifdef RARCH_CONSOLE
|
||||
if ((frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first()) == NULL)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
system_init();
|
||||
if (system_ctx_init() != 0)
|
||||
return 0;
|
||||
|
||||
frontend_ctx->init();
|
||||
get_environment_settings(argc, argv);
|
||||
salamander_init_settings();
|
||||
system_deinit();
|
||||
system_exitspawn();
|
||||
frontend_ctx->deinit();
|
||||
frontend_ctx->exitspawn();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -338,11 +338,11 @@ static void system_deinit(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
static int system_process_args(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
// a big hack: sometimes salamander doesn't save the new core it loads on first boot,
|
||||
// so we make sure g_settings.libretro is set here
|
||||
if (!g_settings.libretro[0] && argc >= 1 && strrchr(argv[0], '/'))
|
||||
@ -354,8 +354,16 @@ static int system_process_args(int argc, char *argv[])
|
||||
"%s%s", argv[1], argv[2]);
|
||||
ret = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
const frontend_ctx_driver_t frontend_ctx_gx = {
|
||||
get_environment_settings,
|
||||
system_init,
|
||||
system_deinit,
|
||||
system_exitspawn,
|
||||
system_process_args,
|
||||
"gx",
|
||||
};
|
||||
|
@ -342,12 +342,14 @@ static void system_init(void)
|
||||
|
||||
static int system_process_args(int argc, char *argv[])
|
||||
{
|
||||
#ifndef IS_SALAMANDER
|
||||
if (argc > 1)
|
||||
{
|
||||
RARCH_LOG("Auto-start game %s.\n", argv[1]);
|
||||
strlcpy(g_extern.fullpath, argv[1], sizeof(g_extern.fullpath));
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -414,3 +416,12 @@ static void system_exitspawn(void)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
const frontend_ctx_driver_t frontend_ctx_ps3 = {
|
||||
get_environment_settings,
|
||||
system_init,
|
||||
system_deinit,
|
||||
system_exitspawn,
|
||||
system_process_args,
|
||||
"ps3",
|
||||
};
|
||||
|
@ -440,6 +440,10 @@ REWIND
|
||||
============================================================ */
|
||||
#include "../rewind.c"
|
||||
|
||||
#if defined(RARCH_CONSOLE)
|
||||
#include "../frontend/frontend_context.c"
|
||||
#endif
|
||||
|
||||
/*============================================================
|
||||
MAIN
|
||||
============================================================ */
|
||||
|
Loading…
Reference in New Issue
Block a user