diff --git a/frontend/frontend.c b/frontend/frontend.c index bb7f5880a8..256f71f0ca 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -21,9 +21,7 @@ #include "frontend_context.h" frontend_ctx_driver_t *frontend_ctx; -#if defined(__QNX__) -#include -#elif defined(__APPLE__) +#if defined(__APPLE__) #include #include #include "../apple/RetroArch/rarch_wrapper.h" @@ -76,53 +74,40 @@ static bool libretro_install_core(const char *path_prefix, return true; } -#define MAKE_DIR(x, name) { \ - RARCH_LOG("Checking directory name %s [%s]\n", name, x); \ - if (strlen(x) > 0) \ - { \ - if (!path_is_directory((x)) )\ - { \ - RARCH_WARN("Directory \"%s\" does not exists, creating\n", (x)); \ - if (mkdir((x), 0777) != 0) \ - { \ - RARCH_ERR("Could not create directory \"%s\"\n", (x)); \ - } \ - } \ - } \ +#endif + +#ifdef RARCH_CONSOLE +void rarch_make_dir(const char *x, const char *name) +{ + RARCH_LOG("Checking directory name %s [%s]\n", name, x); + if (strlen(x) > 0) + { + if (!path_is_directory(x)) + { + RARCH_WARN("Directory \"%s\" does not exists, creating\n", x); + if (mkdir((x), 0777) != 0) + RARCH_ERR("Could not create directory \"%s\"\n", x); + } + } } #endif static void rarch_get_environment(int argc, char *argv[]) { -#if defined(__QNX__) && !defined(HAVE_BB10) - strlcpy(g_settings.libretro, "app/native/lib", sizeof(g_settings.libretro)); - strlcpy(g_extern.config_path, "app/native/retroarch.cfg", sizeof(g_extern.config_path)); - strlcpy(g_settings.video.shader_dir, "app/native/shaders_glsl", sizeof(g_settings.video.shader_dir)); - - config_load(); - g_extern.verbose = true; -#elif defined(RARCH_CONSOLE) + #if defined(HAVE_LOGGER) - g_extern.verbose = true; logger_init(); #elif defined(HAVE_FILE_LOGGER) - g_extern.verbose = true; g_extern.log_file = fopen("/retroarch-log.txt", "w"); #endif - g_extern.verbose = true; - if (frontend_ctx && frontend_ctx->get_environment_settings) - frontend_ctx->get_environment_settings(argc, argv); - - MAKE_DIR(default_paths.port_dir, "port_dir"); - MAKE_DIR(default_paths.system_dir, "system_dir"); - MAKE_DIR(default_paths.savestate_dir, "savestate_dir"); - MAKE_DIR(default_paths.sram_dir, "sram_dir"); - MAKE_DIR(default_paths.input_presets_dir, "input_presets_dir"); + if (frontend_ctx && frontend_ctx->environment_get) + frontend_ctx->environment_get(argc, argv); config_load(); +#if defined(RARCH_CONSOLE) init_libretro_sym(false); rarch_init_system_info(); @@ -164,9 +149,10 @@ static void rarch_get_environment(int argc, char *argv[]) static void system_shutdown(void) { -#if defined(__QNX__) - bps_shutdown(); -#elif defined(__APPLE__) + if (frontend_ctx && frontend_ctx->shutdown) + frontend_ctx->shutdown(true); + +#if defined(__APPLE__) dispatch_async_f(dispatch_get_main_queue(), 0, apple_rarch_exited); #endif } @@ -230,11 +216,6 @@ int rarch_main(int argc, char *argv[]) if ((frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first()) == NULL) RARCH_WARN("Could not find valid frontend context.\n"); -#if defined(__QNX__) && !defined(HAVE_BB10) - //Initialize BPS libraries - bps_initialize(); -#endif - if (frontend_ctx && frontend_ctx->init) frontend_ctx->init(); diff --git a/frontend/frontend_context.c b/frontend/frontend_context.c index 9b766a9cae..1b51d9a90f 100644 --- a/frontend/frontend_context.c +++ b/frontend/frontend_context.c @@ -30,6 +30,9 @@ static const frontend_ctx_driver_t *frontend_ctx_drivers[] = { #if defined(GEKKO) &frontend_ctx_gx, #endif +#if defined(__QNX__) + &frontend_ctx_qnx, +#endif }; const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident) diff --git a/frontend/frontend_context.h b/frontend/frontend_context.h index 0a417da946..19c42c8934 100644 --- a/frontend/frontend_context.h +++ b/frontend/frontend_context.h @@ -32,7 +32,7 @@ typedef struct frontend_ctx_driver { - void (*get_environment_settings)(int argc, char *argv[]); + void (*environment_get)(int argc, char *argv[]); void (*init)(void); void (*deinit)(void); @@ -49,8 +49,13 @@ typedef struct frontend_ctx_driver 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; +extern const frontend_ctx_driver_t frontend_ctx_qnx; 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. +#ifdef RARCH_CONSOLE +extern void rarch_make_dir(const char *x, const char *name); +#endif + #endif diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index 7844c5952d..09fe66d390 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -265,6 +265,14 @@ static void get_environment_settings(int argc, char *argv[]) else gx_rom_path[0] = '\0'; #endif + +#ifndef IS_SALAMANDER + rarch_make_dir(default_paths.port_dir, "port_dir"); + rarch_make_dir(default_paths.system_dir, "system_dir"); + rarch_make_dir(default_paths.savestate_dir, "savestate_dir"); + rarch_make_dir(default_paths.sram_dir, "sram_dir"); + rarch_make_dir(default_paths.input_presets_dir, "input_presets_dir"); +#endif } extern void __exception_setreload(int t); diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index 3928aaf1fb..70a29ba855 100644 --- a/frontend/platform/platform_ps3.c +++ b/frontend/platform/platform_ps3.c @@ -277,6 +277,14 @@ static void get_environment_settings(int argc, char *argv[]) snprintf(g_extern.config_path, sizeof(g_extern.config_path), "%s/retroarch.cfg", default_paths.port_dir); #endif } + +#ifndef IS_SALAMANDER + rarch_make_dir(default_paths.port_dir, "port_dir"); + rarch_make_dir(default_paths.system_dir, "system_dir"); + rarch_make_dir(default_paths.savestate_dir, "savestate_dir"); + rarch_make_dir(default_paths.sram_dir, "sram_dir"); + rarch_make_dir(default_paths.input_presets_dir, "input_presets_dir"); +#endif } static void system_init(void) diff --git a/frontend/platform/platform_psp.c b/frontend/platform/platform_psp.c index c8a90f6fe9..83e5caaf46 100644 --- a/frontend/platform/platform_psp.c +++ b/frontend/platform/platform_psp.c @@ -67,6 +67,14 @@ static void get_environment_settings(int argc, char *argv[]) snprintf(default_paths.input_presets_dir, sizeof(default_paths.input_presets_dir), "%s/presets", default_paths.core_dir); snprintf(default_paths.border_dir, sizeof(default_paths.border_dir), "%s/borders", default_paths.core_dir); snprintf(g_extern.config_path, sizeof(g_extern.config_path), "%s/retroarch.cfg", default_paths.port_dir); + +#ifndef IS_SALAMANDER + rarch_make_dir(default_paths.port_dir, "port_dir"); + rarch_make_dir(default_paths.system_dir, "system_dir"); + rarch_make_dir(default_paths.savestate_dir, "savestate_dir"); + rarch_make_dir(default_paths.sram_dir, "sram_dir"); + rarch_make_dir(default_paths.input_presets_dir, "input_presets_dir"); +#endif } int callback_thread(SceSize args, void *argp) @@ -97,13 +105,6 @@ static void system_init(void) setup_callback(); } -static int system_process_args(int argc, char *argv[]) -{ - (void)argc; - (void)argv; - return 0; -} - static void system_deinit(void) { sceKernelExitGame(); @@ -114,7 +115,7 @@ const frontend_ctx_driver_t frontend_ctx_xdk = { system_init, /* init */ system_deinit, /* deinit */ NULL, /* exitspawn */ - system_process_args, /* process_args */ + NULL, /* process_args */ NULL, /* exec */ NULL, /* shutdown */ "psp", diff --git a/frontend/platform/platform_qnx.c b/frontend/platform/platform_qnx.c new file mode 100644 index 0000000000..b8dee63622 --- /dev/null +++ b/frontend/platform/platform_qnx.c @@ -0,0 +1,59 @@ +/* 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 . + */ + +#include + +#include +#include "../../boolean.h" +#include +#include + +static void get_environment_settings(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + +/* FIXME - should this apply for both BB10 and PB? */ +#if defined(__QNX__) && !defined(HAVE_BB10) + strlcpy(g_settings.libretro, "app/native/lib", sizeof(g_settings.libretro)); + strlcpy(g_extern.config_path, "app/native/retroarch.cfg", sizeof(g_extern.config_path)); + strlcpy(g_settings.video.shader_dir, "app/native/shaders_glsl", sizeof(g_settings.video.shader_dir)); +#endif +} + +static void system_init(void) +{ +/* FIXME - should this apply for both BB10 and PB? */ +#if defined(__QNX__) && !defined(HAVE_BB10) + bps_initialize(); +#endif +} + +static void system_shutdown(void) +{ + bps_shutdown(); +} + +const frontend_ctx_driver_t frontend_ctx_xdk = { + get_environment_settings, /* get_environment_settings */ + system_init, /* init */ + NULL, /* deinit */ + NULL, /* exitspawn */ + NULL, /* process_args */ + NULL, /* exec */ + system_shutdown, /* shutdown */ + "qnx", +}; diff --git a/frontend/platform/platform_xdk.c b/frontend/platform/platform_xdk.c index 2182fcb0bb..17c9ff7eec 100644 --- a/frontend/platform/platform_xdk.c +++ b/frontend/platform/platform_xdk.c @@ -247,6 +247,14 @@ static void get_environment_settings(int argc, char *argv[]) strlcpy(default_paths.system_dir, "game:\\system", sizeof(default_paths.system_dir)); strlcpy(default_paths.filebrowser_startup_dir, "game:", sizeof(default_paths.filebrowser_startup_dir)); #endif + +#ifndef IS_SALAMANDER + rarch_make_dir(default_paths.port_dir, "port_dir"); + rarch_make_dir(default_paths.system_dir, "system_dir"); + rarch_make_dir(default_paths.savestate_dir, "savestate_dir"); + rarch_make_dir(default_paths.sram_dir, "sram_dir"); + rarch_make_dir(default_paths.input_presets_dir, "input_presets_dir"); +#endif } static void system_init(void) diff --git a/griffin/griffin.c b/griffin/griffin.c index a20f74cd0d..3ccaaea4b0 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -456,6 +456,8 @@ FRONTEND #include "../frontend/platform/platform_xdk.c" #elif defined(PSP) #include "../frontend/platform/platform_psp.c" +#elif defined(__QNX__) +#include "../frontend/platform/platform_qnx.c" #endif /*============================================================