mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 19:20:35 +00:00
Merge pull request #7938 from frangarcj/orbis2
[ORBIS] Some driver fixes and host filesystem support
This commit is contained in:
commit
6aa501bc70
@ -25,6 +25,7 @@ Amiga1200Gamer (amigagamer)
|
||||
Andre Leiradella (leiradel)
|
||||
Andrés (fr500)
|
||||
Anthony J. Bentley (bentley)
|
||||
Antonio Jose Ramos Marquez (psxdev)
|
||||
AridRayne
|
||||
Arto Vainiolehto (arakerlu)
|
||||
asako (asakous)
|
||||
|
@ -189,6 +189,7 @@ OBJ += frontend/frontend.o \
|
||||
$(LIBRETRO_COMM_DIR)/file/nbio/nbio_linux.o \
|
||||
$(LIBRETRO_COMM_DIR)/file/nbio/nbio_unixmmap.o \
|
||||
$(LIBRETRO_COMM_DIR)/file/nbio/nbio_windowsmmap.o \
|
||||
$(LIBRETRO_COMM_DIR)/file/nbio/nbio_orbis.o \
|
||||
$(LIBRETRO_COMM_DIR)/file/nbio/nbio_intf.o \
|
||||
$(LIBRETRO_COMM_DIR)/file/file_path.o \
|
||||
file_path_special.o \
|
||||
|
@ -29,7 +29,7 @@ else
|
||||
HAVE_RJPEG := 1
|
||||
HAVE_RBMP := 1
|
||||
HAVE_RTGA := 1
|
||||
HAVE_ZLIB := 0
|
||||
HAVE_ZLIB := 1
|
||||
HAVE_OVERLAY := 1
|
||||
HAVE_7ZIP := 1
|
||||
HAVE_EGL := 1
|
||||
@ -59,9 +59,9 @@ else
|
||||
BLACKLIST :=
|
||||
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
|
||||
|
||||
#OBJ += input/drivers/psp_input.o
|
||||
#OBJ += input/drivers_joypad/psp_joypad.o
|
||||
#OBJ += audio/drivers/psp_audio.o
|
||||
OBJ += input/drivers/ps4_input.o
|
||||
OBJ += input/drivers_joypad/ps4_joypad.o
|
||||
OBJ += audio/drivers/psp_audio.o
|
||||
#OBJ += frontend/drivers/platform_orbis.o
|
||||
endif
|
||||
|
||||
@ -120,7 +120,7 @@ ifeq ($(WHOLE_ARCHIVE_LINK), 1)
|
||||
endif
|
||||
CXXFLAGS := $(CFLAGS)
|
||||
|
||||
PS4_LIBS := -lps4link -ldebugnet -lorbisFile -lelfloader -lorbisKeyboard -lorbis2d -lpng -lz -lorbisGl -lorbisPad -lorbisAudio -lmod -lorbisAudio -lmod -lorbisFileBrowser -lorbisXbmFont -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub \
|
||||
PS4_LIBS := -lps4link -ldebugnet -lorbisFile -lelfloader -lorbisKeyboard -lorbis2d -lpng -lz -lorbisGl -lorbisPad -lorbisAudio -lmod -lorbisFileBrowser -lorbisXbmFont -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub \
|
||||
-lPs4_extension_kernel_call_standard -lPs4_extension_kernel_execute_dynlib_prepare_dlclose -lPs4_common_kernel -lPs4_common_user -lPs4_common_generic -lPs4LibCInternalAdaptive_stub -lPs4LibKernelAdaptive_stub -lSceLibcInternal_stub -lkernel_stub -lps4Kernel_stub -lPs4_base_stub_resolve_minimal -lPs4_base_kernel_dlsym_standard -lPs4_base_kernel_seek_elf_address_standard -lPs4_base_assembler_register_parameter_standard -lPs4_base_assembler_system_call_standard
|
||||
|
||||
LIBS := $(WHOLE_START) -lretro_orbis $(WHOLE_END) $(PS4_LIBS)
|
||||
|
@ -119,7 +119,7 @@ static const audio_driver_t *audio_drivers[] = {
|
||||
#ifdef EMSCRIPTEN
|
||||
&audio_rwebaudio,
|
||||
#endif
|
||||
#if defined(PSP) || defined(VITA)
|
||||
#if defined(PSP) || defined(VITA) || defined(ORBIS)
|
||||
&audio_psp,
|
||||
#endif
|
||||
#if defined(PS2)
|
||||
|
@ -16,21 +16,28 @@
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#if defined(VITA) || defined(PSP)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <rthreads/rthreads.h>
|
||||
#include <queues/fifo_queue.h>
|
||||
|
||||
#ifdef VITA
|
||||
#if defined(VITA)
|
||||
#include <psp2/kernel/processmgr.h>
|
||||
#include <psp2/kernel/threadmgr.h>
|
||||
#include <psp2/kernel/sysmem.h>
|
||||
#include <psp2/audioout.h>
|
||||
#else
|
||||
#elif defined(PSP)
|
||||
#include <pspkernel.h>
|
||||
#include <pspaudio.h>
|
||||
#elif defined(ORBIS)
|
||||
#include <audioout.h>
|
||||
#define SCE_AUDIO_OUT_PORT_TYPE_MAIN 0
|
||||
#define SCE_AUDIO_OUT_MODE_STEREO 1
|
||||
#define SceUID uint32_t
|
||||
#endif
|
||||
|
||||
#include "../audio_driver.h"
|
||||
@ -64,10 +71,14 @@ static void audioMainLoop(void *data)
|
||||
{
|
||||
psp_audio_t* psp = (psp_audio_t*)data;
|
||||
|
||||
#ifdef VITA
|
||||
#if defined(VITA)
|
||||
int port = sceAudioOutOpenPort(
|
||||
SCE_AUDIO_OUT_PORT_TYPE_MAIN, AUDIO_OUT_COUNT,
|
||||
psp->rate, SCE_AUDIO_OUT_MODE_STEREO);
|
||||
#elif defined(ORBIS)
|
||||
int port = sceAudioOutOpen(0xff,
|
||||
SCE_AUDIO_OUT_PORT_TYPE_MAIN, 0, AUDIO_OUT_COUNT,
|
||||
psp->rate, SCE_AUDIO_OUT_MODE_STEREO);
|
||||
#else
|
||||
sceAudioSRCChReserve(AUDIO_OUT_COUNT, psp->rate, 2);
|
||||
#endif
|
||||
@ -95,7 +106,7 @@ static void audioMainLoop(void *data)
|
||||
scond_signal(psp->cond);
|
||||
slock_unlock(psp->cond_lock);
|
||||
|
||||
#ifdef VITA
|
||||
#if defined(VITA) || defined(ORBIS)
|
||||
sceAudioOutOutput(port,
|
||||
cond ? (psp->zeroBuffer)
|
||||
: (psp->buffer + read_pos_2));
|
||||
@ -105,8 +116,10 @@ static void audioMainLoop(void *data)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VITA
|
||||
#if defined(VITA)
|
||||
sceAudioOutReleasePort(port);
|
||||
#elif defined(ORBIS)
|
||||
sceAudioOutClose(port);
|
||||
#else
|
||||
sceAudioSRCChRelease();
|
||||
#endif
|
||||
@ -127,12 +140,23 @@ static void *psp_audio_init(const char *device,
|
||||
(void)device;
|
||||
(void)latency;
|
||||
|
||||
#ifdef ORBIS
|
||||
psp->buffer = (uint32_t*)
|
||||
malloc(AUDIO_BUFFER_SIZE * sizeof(uint32_t));
|
||||
#else
|
||||
/* Cache aligned, not necessary but helpful. */
|
||||
psp->buffer = (uint32_t*)
|
||||
memalign(64, AUDIO_BUFFER_SIZE * sizeof(uint32_t));
|
||||
#endif
|
||||
memset(psp->buffer, 0, AUDIO_BUFFER_SIZE * sizeof(uint32_t));
|
||||
|
||||
#ifdef ORBIS
|
||||
psp->zeroBuffer = (uint32_t*)
|
||||
malloc(AUDIO_OUT_COUNT * sizeof(uint32_t));
|
||||
#else
|
||||
psp->zeroBuffer = (uint32_t*)
|
||||
memalign(64, AUDIO_OUT_COUNT * sizeof(uint32_t));
|
||||
#endif
|
||||
memset(psp->zeroBuffer, 0, AUDIO_OUT_COUNT * sizeof(uint32_t));
|
||||
|
||||
psp->read_pos = 0;
|
||||
@ -302,8 +326,10 @@ audio_driver_t audio_psp = {
|
||||
psp_audio_set_nonblock_state,
|
||||
psp_audio_free,
|
||||
psp_audio_use_float,
|
||||
#ifdef VITA
|
||||
#if defined(VITA)
|
||||
"vita",
|
||||
#elif defined(ORBIS)
|
||||
"orbis",
|
||||
#else
|
||||
"psp",
|
||||
#endif
|
||||
|
@ -405,7 +405,7 @@ static unsigned menu_toggle_gamepad_combo = INPUT_TOGGLE_L3_R3;
|
||||
static unsigned menu_toggle_gamepad_combo = INPUT_TOGGLE_HOLD_START;
|
||||
#elif defined(VITA)
|
||||
static unsigned menu_toggle_gamepad_combo = INPUT_TOGGLE_L1_R1_START_SELECT;
|
||||
#elif defined(SWITCH)
|
||||
#elif defined(SWITCH) || defined(ORBIS)
|
||||
static unsigned menu_toggle_gamepad_combo = INPUT_TOGGLE_START_SELECT;
|
||||
#else
|
||||
static unsigned menu_toggle_gamepad_combo = INPUT_TOGGLE_NONE;
|
||||
|
@ -218,6 +218,7 @@ enum input_driver_enum
|
||||
INPUT_X,
|
||||
INPUT_WAYLAND,
|
||||
INPUT_DINPUT,
|
||||
INPUT_PS4,
|
||||
INPUT_PS3,
|
||||
INPUT_PSP,
|
||||
INPUT_PS2,
|
||||
@ -244,6 +245,7 @@ enum joypad_driver_enum
|
||||
JOYPAD_GX,
|
||||
JOYPAD_WIIU,
|
||||
JOYPAD_XDK,
|
||||
JOYPAD_PS4,
|
||||
JOYPAD_PSP,
|
||||
JOYPAD_PS2,
|
||||
JOYPAD_CTR,
|
||||
@ -371,7 +373,7 @@ static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_XENON360;
|
||||
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_WII;
|
||||
#elif defined(WIIU)
|
||||
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_WIIU;
|
||||
#elif defined(PSP) || defined(VITA)
|
||||
#elif defined(PSP) || defined(VITA) || defined(ORBIS)
|
||||
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_PSP;
|
||||
#elif defined(PS2)
|
||||
static enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_PS2;
|
||||
@ -453,6 +455,8 @@ static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_SDL2;
|
||||
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_RWEBINPUT;
|
||||
#elif defined(_WIN32)
|
||||
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_DINPUT;
|
||||
#elif defined(ORBIS)
|
||||
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_PS4;
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
static enum input_driver_enum INPUT_DEFAULT_DRIVER = INPUT_PS3;
|
||||
#elif defined(PSP) || defined(VITA)
|
||||
@ -499,6 +503,8 @@ static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_GX;
|
||||
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_WIIU;
|
||||
#elif defined(_XBOX)
|
||||
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_XDK;
|
||||
#elif defined(ORBIS)
|
||||
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_PS4;
|
||||
#elif defined(PSP) || defined(VITA)
|
||||
static enum joypad_driver_enum JOYPAD_DEFAULT_DRIVER = JOYPAD_PSP;
|
||||
#elif defined(PS2)
|
||||
@ -687,8 +693,10 @@ const char *config_get_default_audio(void)
|
||||
case AUDIO_WIIU:
|
||||
return "AX";
|
||||
case AUDIO_PSP:
|
||||
#ifdef VITA
|
||||
#if defined(VITA)
|
||||
return "vita";
|
||||
#elif defined(ORBIS)
|
||||
return "orbis";
|
||||
#else
|
||||
return "psp";
|
||||
#endif
|
||||
@ -843,6 +851,8 @@ const char *config_get_default_input(void)
|
||||
{
|
||||
case INPUT_ANDROID:
|
||||
return "android";
|
||||
case INPUT_PS4:
|
||||
return "ps4";
|
||||
case INPUT_PS3:
|
||||
return "ps3";
|
||||
case INPUT_PSP:
|
||||
@ -909,6 +919,8 @@ const char *config_get_default_joypad(void)
|
||||
|
||||
switch (default_driver)
|
||||
{
|
||||
case JOYPAD_PS4:
|
||||
return "ps4";
|
||||
case JOYPAD_PS3:
|
||||
return "ps3";
|
||||
case JOYPAD_XINPUT:
|
||||
|
4
dirs.c
4
dirs.c
@ -308,7 +308,11 @@ void dir_check_defaults(void)
|
||||
/* early return for people with a custom folder setup
|
||||
so it doesn't create unnecessary directories
|
||||
*/
|
||||
#ifdef ORBIS
|
||||
if (filestream_exists("host0:app/custom.ini"))
|
||||
#else
|
||||
if (filestream_exists("custom.ini"))
|
||||
#endif
|
||||
return;
|
||||
|
||||
for (i = 0; i < DEFAULT_DIR_LAST; i++)
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <ps4link.h>
|
||||
#include <orbisKeyboard.h>
|
||||
#include <debugnet.h>
|
||||
#include <orbisFile.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
@ -106,13 +107,32 @@ static void frontend_orbis_get_environment_settings(int *argc, char *argv[],
|
||||
#if defined(HAVE_LOGGER)
|
||||
logger_init();
|
||||
#elif defined(HAVE_FILE_LOGGER)
|
||||
retro_main_log_file_init("host0:/temp/retroarch-log.txt");
|
||||
retro_main_log_file_init("host0:app/temp/retroarch-log.txt");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
strlcpy(eboot_path, "host0:/", sizeof(eboot_path));
|
||||
int ret;
|
||||
|
||||
sceSystemServiceHideSplashScreen();
|
||||
|
||||
|
||||
uintptr_t intptr=0;
|
||||
sscanf(argv[1],"%p",&intptr);
|
||||
argv[1] = NULL;
|
||||
myConf=(OrbisGlobalConf *)intptr;
|
||||
ret=ps4LinkInitWithConf(myConf->confLink);
|
||||
if(!ret)
|
||||
{
|
||||
ps4LinkFinish();
|
||||
return;
|
||||
}
|
||||
orbisFileInit();
|
||||
orbisPadInitWithConf(myConf->confPad);
|
||||
scePadClose(myConf->confPad->padHandle);
|
||||
|
||||
strlcpy(eboot_path, "host0:app", sizeof(eboot_path));
|
||||
strlcpy(g_defaults.dirs[DEFAULT_DIR_PORT], eboot_path, sizeof(g_defaults.dirs[DEFAULT_DIR_PORT]));
|
||||
strlcpy(user_path, "host0:/data/retroarch/", sizeof(user_path));
|
||||
strlcpy(user_path, "host0:app/data/retroarch/", sizeof(user_path));
|
||||
|
||||
RARCH_LOG("port dir: [%s]\n", g_defaults.dirs[DEFAULT_DIR_PORT]);
|
||||
|
||||
@ -159,7 +179,7 @@ static void frontend_orbis_get_environment_settings(int *argc, char *argv[],
|
||||
params = (struct rarch_main_wrap*)params_data;
|
||||
params->verbose = true;
|
||||
|
||||
if (!string_is_empty(argv[1]))
|
||||
if (!string_is_empty(argv[2]))
|
||||
{
|
||||
static char path[PATH_MAX_LENGTH] = {0};
|
||||
struct rarch_main_wrap *args =
|
||||
@ -167,7 +187,7 @@ static void frontend_orbis_get_environment_settings(int *argc, char *argv[],
|
||||
|
||||
if (args)
|
||||
{
|
||||
strlcpy(path, argv[1], sizeof(path));
|
||||
strlcpy(path, argv[2], sizeof(path));
|
||||
|
||||
args->touched = true;
|
||||
args->no_content = false;
|
||||
@ -182,7 +202,7 @@ static void frontend_orbis_get_environment_settings(int *argc, char *argv[],
|
||||
RARCH_LOG("argv[1]: %s\n", argv[1]);
|
||||
RARCH_LOG("argv[2]: %s\n", argv[2]);
|
||||
|
||||
RARCH_LOG("Auto-start game %s.\n", argv[1]);
|
||||
RARCH_LOG("Auto-start game %s.\n", argv[2]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -307,7 +327,7 @@ static int frontend_orbis_parse_drive_list(void *data, bool load_content)
|
||||
MSG_UNKNOWN;
|
||||
|
||||
menu_entries_append_enum(list,
|
||||
"app0",
|
||||
"host0:app",
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
|
||||
enum_idx,
|
||||
FILE_TYPE_DIRECTORY, 0, 0);
|
||||
|
@ -161,7 +161,6 @@ int rarch_main(int argc, char *argv[], void *data)
|
||||
}
|
||||
|
||||
#ifndef HAVE_MAIN
|
||||
#ifndef ORBIS
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
@ -170,4 +169,3 @@ int main(int argc, char *argv[])
|
||||
return rarch_main(argc, argv, NULL);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -85,6 +85,9 @@ static frontend_ctx_driver_t *frontend_ctx_drivers[] = {
|
||||
#endif
|
||||
#ifdef SWITCH
|
||||
&frontend_ctx_switch,
|
||||
#endif
|
||||
#if defined(ORBIS)
|
||||
&frontend_ctx_orbis,
|
||||
#endif
|
||||
&frontend_ctx_null,
|
||||
NULL
|
||||
|
@ -129,6 +129,7 @@ extern frontend_ctx_driver_t frontend_ctx_xenon;
|
||||
extern frontend_ctx_driver_t frontend_ctx_emscripten;
|
||||
extern frontend_ctx_driver_t frontend_ctx_dos;
|
||||
extern frontend_ctx_driver_t frontend_ctx_switch;
|
||||
extern frontend_ctx_driver_t frontend_ctx_orbis;
|
||||
extern frontend_ctx_driver_t frontend_ctx_null;
|
||||
|
||||
/**
|
||||
|
@ -419,7 +419,12 @@ bool egl_create_context(egl_ctx_data_t *egl, const EGLint *egl_attribs)
|
||||
|
||||
bool egl_create_surface(egl_ctx_data_t *egl, void *native_window)
|
||||
{
|
||||
egl->surf = eglCreateWindowSurface(egl->dpy, egl->config, (NativeWindowType)native_window, NULL);
|
||||
EGLint window_attribs[] = {
|
||||
EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
|
||||
EGL_NONE,
|
||||
};
|
||||
|
||||
egl->surf = eglCreateWindowSurface(egl->dpy, egl->config, (NativeWindowType)native_window, window_attribs);
|
||||
|
||||
if (egl->surf == EGL_NO_SURFACE)
|
||||
return false;
|
||||
|
@ -58,11 +58,17 @@ static void *orbis_ctx_init(video_frame_info_t *video_info, void *video_driver)
|
||||
EGLint n;
|
||||
EGLint major, minor;
|
||||
static const EGLint attribs[] = {
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
EGL_NONE};
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 16,
|
||||
EGL_STENCIL_SIZE, 0,
|
||||
EGL_SAMPLE_BUFFERS, 0,
|
||||
EGL_SAMPLES, 0,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
||||
EGL_NONE};
|
||||
#endif
|
||||
|
||||
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)calloc(1, sizeof(*ctx_orbis));
|
||||
@ -143,8 +149,8 @@ static bool orbis_ctx_set_video_mode(void *data,
|
||||
|
||||
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
|
||||
|
||||
ctx_orbis->width = ATTR_ORBISGL_HEIGHT;
|
||||
ctx_orbis->height = ATTR_ORBISGL_WIDTH;
|
||||
ctx_orbis->width = ATTR_ORBISGL_WIDTH;
|
||||
ctx_orbis->height = ATTR_ORBISGL_HEIGHT;
|
||||
|
||||
ctx_orbis->native_window.width = ctx_orbis->width;
|
||||
ctx_orbis->native_window.height = ctx_orbis->height;
|
||||
@ -218,7 +224,7 @@ static void orbis_ctx_set_swap_interval(void *data,
|
||||
orbis_ctx_data_t *ctx_orbis = (orbis_ctx_data_t *)data;
|
||||
|
||||
#ifdef HAVE_EGL
|
||||
egl_set_swap_interval(&ctx_orbis->egl, swap_interval);
|
||||
egl_set_swap_interval(&ctx_orbis->egl, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -572,6 +572,9 @@ INPUT
|
||||
#elif defined(SN_TARGET_PSP2) || defined(PSP) || defined(VITA)
|
||||
#include "../input/drivers/psp_input.c"
|
||||
#include "../input/drivers_joypad/psp_joypad.c"
|
||||
#elif defined(ORBIS)
|
||||
#include "../input/drivers/ps4_input.c"
|
||||
#include "../input/drivers_joypad/ps4_joypad.c"
|
||||
#elif defined(PS2)
|
||||
#include "../input/drivers/ps2_input.c"
|
||||
#include "../input/drivers_joypad/ps2_joypad.c"
|
||||
@ -773,7 +776,7 @@ AUDIO
|
||||
#include "../audio/drivers/wiiu_audio.c"
|
||||
#elif defined(EMSCRIPTEN)
|
||||
#include "../audio/drivers/rwebaudio.c"
|
||||
#elif defined(PSP) || defined(VITA)
|
||||
#elif defined(PSP) || defined(VITA) || defined(ORBIS)
|
||||
#include "../audio/drivers/psp_audio.c"
|
||||
#elif defined(PS2)
|
||||
#include "../audio/drivers/ps2_audio.c"
|
||||
@ -930,6 +933,7 @@ FILE
|
||||
#include "../libretro-common/file/nbio/nbio_linux.c"
|
||||
#include "../libretro-common/file/nbio/nbio_unixmmap.c"
|
||||
#include "../libretro-common/file/nbio/nbio_windowsmmap.c"
|
||||
#include "../libretro-common/file/nbio/nbio_orbis.c"
|
||||
#include "../libretro-common/file/nbio/nbio_intf.c"
|
||||
|
||||
/*============================================================
|
||||
|
155
input/drivers/ps4_input.c
Normal file
155
input/drivers/ps4_input.c
Normal file
@ -0,0 +1,155 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - 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/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
#endif
|
||||
|
||||
#include <pad.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <libretro.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
#include "../input_driver.h"
|
||||
|
||||
/* TODO/FIXME -
|
||||
* fix game focus toggle */
|
||||
|
||||
typedef struct ps4_input
|
||||
{
|
||||
bool blocked;
|
||||
const input_device_driver_t *joypad;
|
||||
} ps4_input_t;
|
||||
|
||||
static void ps4_input_poll(void *data)
|
||||
{
|
||||
ps4_input_t *ps4 = (ps4_input_t*)data;
|
||||
|
||||
if (ps4 && ps4->joypad)
|
||||
ps4->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t ps4_input_state(void *data,
|
||||
rarch_joypad_info_t joypad_info,
|
||||
const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
unsigned idx, unsigned id)
|
||||
{
|
||||
ps4_input_t *ps4 = (ps4_input_t*)data;
|
||||
|
||||
switch (device)
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
return input_joypad_pressed(ps4->joypad, joypad_info, port, binds[port], id);
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
if (binds[port])
|
||||
return input_joypad_analog(ps4->joypad, joypad_info, port, idx, id, binds[port]);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ps4_input_free_input(void *data)
|
||||
{
|
||||
ps4_input_t *ps4 = (ps4_input_t*)data;
|
||||
|
||||
if (ps4 && ps4->joypad)
|
||||
ps4->joypad->destroy();
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
static void* ps4_input_initialize(const char *joypad_driver)
|
||||
{
|
||||
ps4_input_t *ps4 = (ps4_input_t*)calloc(1, sizeof(*ps4));
|
||||
if (!ps4)
|
||||
return NULL;
|
||||
|
||||
ps4->joypad = input_joypad_init_driver(joypad_driver, ps4);
|
||||
|
||||
return ps4;
|
||||
}
|
||||
|
||||
static uint64_t ps4_input_get_capabilities(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
return (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG);
|
||||
}
|
||||
|
||||
static const input_device_driver_t *ps4_input_get_joypad_driver(void *data)
|
||||
{
|
||||
ps4_input_t *ps4 = (ps4_input_t*)data;
|
||||
if (ps4)
|
||||
return ps4->joypad;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void ps4_input_grab_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static bool ps4_input_set_rumble(void *data, unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
ps4_input_t *ps4 = (ps4_input_t*)data;
|
||||
|
||||
if (ps4 && ps4->joypad)
|
||||
return input_joypad_set_rumble(ps4->joypad,
|
||||
port, effect, strength);
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool ps4_input_keyboard_mapping_is_blocked(void *data)
|
||||
{
|
||||
ps4_input_t *ps4 = (ps4_input_t*)data;
|
||||
if (!ps4)
|
||||
return false;
|
||||
return ps4->blocked;
|
||||
}
|
||||
|
||||
static void ps4_input_keyboard_mapping_set_block(void *data, bool value)
|
||||
{
|
||||
ps4_input_t *ps4 = (ps4_input_t*)data;
|
||||
if (!ps4)
|
||||
return;
|
||||
ps4->blocked = value;
|
||||
}
|
||||
|
||||
input_driver_t input_ps4 = {
|
||||
ps4_input_initialize,
|
||||
ps4_input_poll,
|
||||
ps4_input_state,
|
||||
ps4_input_free_input,
|
||||
NULL,
|
||||
NULL,
|
||||
ps4_input_get_capabilities,
|
||||
"ps4",
|
||||
ps4_input_grab_mouse,
|
||||
NULL,
|
||||
ps4_input_set_rumble,
|
||||
ps4_input_get_joypad_driver,
|
||||
NULL,
|
||||
ps4_input_keyboard_mapping_is_blocked,
|
||||
ps4_input_keyboard_mapping_set_block,
|
||||
};
|
223
input/drivers_joypad/ps4_joypad.c
Normal file
223
input/drivers_joypad/ps4_joypad.c
Normal file
@ -0,0 +1,223 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
* Copyright (C) 2013-2014 - CatalystG
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <boolean.h>
|
||||
|
||||
#include "../input_driver.h"
|
||||
|
||||
#include "../../tasks/tasks_internal.h"
|
||||
|
||||
#include <userservice.h>
|
||||
#include <pad.h>
|
||||
|
||||
#define PS4_MAX_ORBISPADS 16
|
||||
#define SCE_USER_SERVICE_MAX_LOGIN_USERS 16
|
||||
#define SCE_USER_SERVICE_USER_ID_INVALID 0xFFFFFFFF
|
||||
#define SCE_ORBISPAD_ERROR_ALREADY_OPENED 0x80920004
|
||||
|
||||
#define ORBISPAD_L3 0x00000002
|
||||
#define ORBISPAD_R3 0x00000004
|
||||
#define ORBISPAD_OPTIONS 0x00000008
|
||||
#define ORBISPAD_UP 0x00000010
|
||||
#define ORBISPAD_RIGHT 0x00000020
|
||||
#define ORBISPAD_DOWN 0x00000040
|
||||
#define ORBISPAD_LEFT 0x00000080
|
||||
#define ORBISPAD_L2 0x00000100
|
||||
#define ORBISPAD_R2 0x00000200
|
||||
#define ORBISPAD_L1 0x00000400
|
||||
#define ORBISPAD_R1 0x00000800
|
||||
#define ORBISPAD_TRIANGLE 0x00001000
|
||||
#define ORBISPAD_CIRCLE 0x00002000
|
||||
#define ORBISPAD_CROSS 0x00004000
|
||||
#define ORBISPAD_SQUARE 0x00008000
|
||||
#define ORBISPAD_TOUCH_PAD 0x00100000
|
||||
#define ORBISPAD_INTERCEPTED 0x80000000
|
||||
|
||||
typedef struct SceUserServiceLoginUserIdList {
|
||||
int32_t userId[SCE_USER_SERVICE_MAX_LOGIN_USERS];
|
||||
} SceUserServiceLoginUserIdList;
|
||||
|
||||
int sceUserServiceGetLoginUserIdList(SceUserServiceLoginUserIdList* userIdList);
|
||||
|
||||
/*
|
||||
* Global var's
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
SceUserServiceUserId userId;
|
||||
int handle;
|
||||
bool connected;
|
||||
} ds_joypad_state;
|
||||
|
||||
static ds_joypad_state ds_joypad_states[PS4_MAX_ORBISPADS];
|
||||
static uint64_t pad_state[PS4_MAX_ORBISPADS];
|
||||
static int16_t analog_state[PS4_MAX_ORBISPADS][2][2];
|
||||
static int16_t num_players = 0;
|
||||
|
||||
|
||||
static const char *ps4_joypad_name(unsigned pad)
|
||||
{
|
||||
return "PS4 Controller";
|
||||
}
|
||||
|
||||
static bool ps4_joypad_init(void *data)
|
||||
{
|
||||
num_players = 0;
|
||||
|
||||
scePadInit();
|
||||
|
||||
SceUserServiceLoginUserIdList userIdList;
|
||||
|
||||
int result = sceUserServiceGetLoginUserIdList(&userIdList);
|
||||
RARCH_LOG("sceUserServiceGetLoginUserIdList %x ", result);
|
||||
if (result == 0)
|
||||
{
|
||||
|
||||
for (int i = 0; i < SCE_USER_SERVICE_MAX_LOGIN_USERS; i++)
|
||||
{
|
||||
SceUserServiceUserId userId = userIdList.userId[i];
|
||||
RARCH_LOG("USER %d ID %x\n", i, userId);
|
||||
if (userId != SCE_USER_SERVICE_USER_ID_INVALID)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
while(index < num_players){
|
||||
ds_joypad_states[index].userId = userId;
|
||||
index++;
|
||||
}
|
||||
|
||||
if (index == num_players)
|
||||
{
|
||||
ds_joypad_states[num_players].handle = scePadOpen(userId, 0, 0, NULL);
|
||||
RARCH_LOG("USER %x HANDLE %x\n", userId, ds_joypad_states[num_players].handle);
|
||||
if (ds_joypad_states[num_players].handle > 0){
|
||||
ds_joypad_states[num_players].connected = true;
|
||||
ds_joypad_states[num_players].userId = userId;
|
||||
RARCH_LOG("NEW PAD: num_players %x \n", num_players);
|
||||
|
||||
bool auto_configure = input_autoconfigure_connect( ps4_joypad_name(num_players),
|
||||
NULL,
|
||||
ps4_joypad.ident,
|
||||
num_players,
|
||||
0,
|
||||
0);
|
||||
if (!auto_configure) {
|
||||
input_config_set_device_name(num_players, ps4_joypad_name(num_players));
|
||||
}
|
||||
num_players++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ps4_joypad_button(unsigned port_num, uint16_t joykey)
|
||||
{
|
||||
if (port_num >= PS4_MAX_ORBISPADS)
|
||||
return false;
|
||||
return (pad_state[port_num] & (UINT64_C(1) << joykey));
|
||||
}
|
||||
|
||||
static void ps4_joypad_get_buttons(unsigned port_num, input_bits_t *state)
|
||||
{
|
||||
if (port_num < PS4_MAX_ORBISPADS)
|
||||
{
|
||||
BITS_COPY16_PTR( state, pad_state[port_num] );
|
||||
}
|
||||
else
|
||||
BIT256_CLEAR_ALL_PTR(state);
|
||||
}
|
||||
|
||||
static int16_t ps4_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ps4_joypad_poll(void)
|
||||
{
|
||||
unsigned player;
|
||||
unsigned players_count = num_players;
|
||||
ScePadData buttons;
|
||||
|
||||
for (player = 0; player < players_count; player++)
|
||||
{
|
||||
unsigned j, k;
|
||||
unsigned i = player;
|
||||
unsigned p = player;
|
||||
|
||||
int ret = scePadReadState(ds_joypad_states[player].handle,&buttons);
|
||||
if (ret == 0)
|
||||
{
|
||||
int32_t state_tmp = buttons.buttons;
|
||||
pad_state[i] = 0;
|
||||
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_LEFT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_DOWN) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_RIGHT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_UP) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_OPTIONS) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_START) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_TOUCH_PAD) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_TRIANGLE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_SQUARE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_CROSS) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_CIRCLE) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_R1) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_L1) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_R2) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_L2) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_R3) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
|
||||
pad_state[i] |= (state_tmp & ORBISPAD_L3) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static bool ps4_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
return pad < PS4_MAX_ORBISPADS && pad_state[pad];
|
||||
}
|
||||
|
||||
static bool ps4_joypad_rumble(unsigned pad,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static void ps4_joypad_destroy(void)
|
||||
{
|
||||
}
|
||||
|
||||
input_device_driver_t ps4_joypad = {
|
||||
ps4_joypad_init,
|
||||
ps4_joypad_query_pad,
|
||||
ps4_joypad_destroy,
|
||||
ps4_joypad_button,
|
||||
ps4_joypad_get_buttons,
|
||||
ps4_joypad_axis,
|
||||
ps4_joypad_poll,
|
||||
ps4_joypad_rumble,
|
||||
ps4_joypad_name,
|
||||
"ps4",
|
||||
};
|
@ -659,6 +659,9 @@ const char* const input_builtin_autoconfs[] =
|
||||
DECL_AUTOCONF_DEVICE("QNX Controller", "qnx", QNX_DEFAULT_BINDS),
|
||||
DECL_AUTOCONF_DEVICE("DS4 Controller", "qnx", QNX_DUALSHOCK_BINDS),
|
||||
#endif
|
||||
#if defined(ORBIS)
|
||||
DECL_AUTOCONF_DEVICE("PS4 Controller", "ps4", PS3INPUT_DEFAULT_BINDS),
|
||||
#endif
|
||||
#if defined(VITA) || defined(SN_TARGET_PSP2)
|
||||
DECL_AUTOCONF_DEVICE("Vita Controller", "vita", PSPINPUT_DEFAULT_BINDS),
|
||||
DECL_AUTOCONF_DEVICE("DS3 Controller", "vita", PSPINPUT_DEFAULT_BINDS),
|
||||
|
@ -80,6 +80,9 @@ void fire_connection_listener(unsigned port, input_device_driver_t *driver)
|
||||
}
|
||||
|
||||
static const input_driver_t *input_drivers[] = {
|
||||
#ifdef ORBIS
|
||||
&input_ps4,
|
||||
#endif
|
||||
#ifdef __CELLOS_LV2__
|
||||
&input_ps3,
|
||||
#endif
|
||||
@ -164,6 +167,9 @@ static input_device_driver_t *joypad_drivers[] = {
|
||||
#ifdef _XBOX
|
||||
&xdk_joypad,
|
||||
#endif
|
||||
#if defined(ORBIS)
|
||||
&ps4_joypad,
|
||||
#endif
|
||||
#if defined(PSP) || defined(VITA)
|
||||
&psp_joypad,
|
||||
#endif
|
||||
|
@ -804,6 +804,7 @@ extern input_device_driver_t parport_joypad;
|
||||
extern input_device_driver_t udev_joypad;
|
||||
extern input_device_driver_t xinput_joypad;
|
||||
extern input_device_driver_t sdl_joypad;
|
||||
extern input_device_driver_t ps4_joypad;
|
||||
extern input_device_driver_t ps3_joypad;
|
||||
extern input_device_driver_t psp_joypad;
|
||||
extern input_device_driver_t ps2_joypad;
|
||||
@ -824,6 +825,7 @@ extern input_driver_t input_android;
|
||||
extern input_driver_t input_sdl;
|
||||
extern input_driver_t input_dinput;
|
||||
extern input_driver_t input_x;
|
||||
extern input_driver_t input_ps4;
|
||||
extern input_driver_t input_ps3;
|
||||
extern input_driver_t input_psp;
|
||||
extern input_driver_t input_ps2;
|
||||
|
@ -34,7 +34,10 @@
|
||||
#elif defined(_XBOX)
|
||||
#include <xtl.h>
|
||||
#endif
|
||||
|
||||
#ifdef ORBIS
|
||||
#include <sys/fcntl.h>
|
||||
#include <orbisFile.h>
|
||||
#endif
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <compat/strl.h>
|
||||
#include <compat/posix_string.h>
|
||||
@ -413,10 +416,10 @@ static config_file_t *config_file_new_internal(
|
||||
|
||||
if (!path || !*path)
|
||||
return conf;
|
||||
|
||||
#if !defined(ORBIS)
|
||||
if (path_is_directory(path))
|
||||
goto error;
|
||||
|
||||
#endif
|
||||
conf->path = strdup(path);
|
||||
if (!conf->path)
|
||||
goto error;
|
||||
@ -980,6 +983,15 @@ bool config_file_write(config_file_t *conf, const char *path, bool sort)
|
||||
if (!string_is_empty(path))
|
||||
{
|
||||
void* buf = NULL;
|
||||
#ifdef ORBIS
|
||||
int fd = orbisOpen(path,O_RDWR|O_CREAT,0644);
|
||||
RARCH_LOG("[Config]config_file_write orbisOpen path=%s fd=%d\n", path, fd);
|
||||
if (fd<0)
|
||||
return false;
|
||||
config_file_dump_orbis(conf,fd);
|
||||
orbisClose(fd);
|
||||
RARCH_LOG("[Config]config_file_write orbisClose path=%s fd=%d\n", path, fd);
|
||||
#else
|
||||
FILE *file = (FILE*)fopen_utf8(path, "wb");
|
||||
if (!file)
|
||||
return false;
|
||||
@ -995,6 +1007,7 @@ bool config_file_write(config_file_t *conf, const char *path, bool sort)
|
||||
if (file != stdout)
|
||||
fclose(file);
|
||||
free(buf);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
config_file_dump(conf, stdout, sort);
|
||||
@ -1002,6 +1015,35 @@ bool config_file_write(config_file_t *conf, const char *path, bool sort)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef ORBIS
|
||||
void config_file_dump_orbis(config_file_t *conf, int fd)
|
||||
{
|
||||
struct config_entry_list *list = NULL;
|
||||
struct config_include_list *includes = conf->includes;
|
||||
while (includes)
|
||||
{
|
||||
char cad[256];
|
||||
sprintf(cad,"#include %s\n", includes->path);
|
||||
orbisWrite(fd,cad,strlen(cad));
|
||||
includes = includes->next;
|
||||
}
|
||||
|
||||
list = merge_sort_linked_list((struct config_entry_list*)conf->entries, config_sort_compare_func);
|
||||
conf->entries = list;
|
||||
|
||||
while (list)
|
||||
{
|
||||
if (!list->readonly && list->key)
|
||||
{
|
||||
char newlist[256];
|
||||
sprintf(newlist,"%s = %s\n", list->key, list->value);
|
||||
orbisWrite(fd,newlist,strlen(newlist));
|
||||
}
|
||||
list = list->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void config_file_dump(config_file_t *conf, FILE *file, bool sort)
|
||||
{
|
||||
struct config_entry_list *list = NULL;
|
||||
|
@ -75,6 +75,11 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(ORBIS)
|
||||
#include <orbisFile.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/dirent.h>
|
||||
#endif
|
||||
#if defined(PSP)
|
||||
#include <pspkernel.h>
|
||||
#endif
|
||||
@ -120,6 +125,9 @@ enum stat_mode
|
||||
|
||||
static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
|
||||
{
|
||||
#if defined(ORBIS)
|
||||
return false; //by now
|
||||
#endif
|
||||
#if defined(VITA) || defined(PSP)
|
||||
SceIoStat buf;
|
||||
char *tmp = strdup(path);
|
||||
@ -232,7 +240,21 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
|
||||
*/
|
||||
bool path_is_directory(const char *path)
|
||||
{
|
||||
#ifdef ORBIS
|
||||
if (!path)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int dfd = orbisDopen(path);
|
||||
if (dfd < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
orbisDclose(dfd);
|
||||
return true;
|
||||
#else
|
||||
return path_stat(path, IS_DIRECTORY, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool path_is_character_special(const char *path)
|
||||
@ -258,7 +280,7 @@ static bool path_mkdir_error(int ret)
|
||||
{
|
||||
#if defined(VITA)
|
||||
return (ret == SCE_ERROR_ERRNO_EEXIST);
|
||||
#elif defined(PSP) || defined(PS2) || defined(_3DS) || defined(WIIU) || defined(SWITCH)
|
||||
#elif defined(PSP) || defined(PS2) || defined(_3DS) || defined(WIIU) || defined(SWITCH) || defined(ORBIS)
|
||||
return (ret == -1);
|
||||
#else
|
||||
return (ret < 0 && errno == EEXIST);
|
||||
@ -329,6 +351,8 @@ bool path_mkdir(const char *dir)
|
||||
int ret = sceIoMkdir(dir, 0777);
|
||||
#elif defined(PS2)
|
||||
int ret =fileXioMkdir(dir, 0777);
|
||||
#elif defined(ORBIS)
|
||||
int ret =orbisMkdir(dir, 0755);
|
||||
#elif defined(__QNX__)
|
||||
int ret = mkdir(dir, 0777);
|
||||
#else
|
||||
|
@ -32,6 +32,7 @@
|
||||
extern nbio_intf_t nbio_linux;
|
||||
extern nbio_intf_t nbio_mmap_unix;
|
||||
extern nbio_intf_t nbio_mmap_win32;
|
||||
extern nbio_intf_t nbio_orbis;
|
||||
extern nbio_intf_t nbio_stdio;
|
||||
|
||||
#if defined(_linux__)
|
||||
@ -40,6 +41,8 @@ static nbio_intf_t *internal_nbio = &nbio_linux;
|
||||
static nbio_intf_t *internal_nbio = &nbio_mmap_unix;
|
||||
#elif defined(_WIN32) && !defined(_XBOX)
|
||||
static nbio_intf_t *internal_nbio = &nbio_mmap_win32;
|
||||
#elif defined(ORBIS)
|
||||
static nbio_intf_t *internal_nbio = &nbio_orbis;
|
||||
#else
|
||||
static nbio_intf_t *internal_nbio = &nbio_stdio;
|
||||
#endif
|
||||
|
295
libretro-common/file/nbio/nbio_orbis.c
Normal file
295
libretro-common/file/nbio/nbio_orbis.c
Normal file
@ -0,0 +1,295 @@
|
||||
/* Copyright (C) 2010-2018 The RetroArch team
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
* The following license statement only applies to this file (nbio_orbis.c).
|
||||
* ---------------------------------------------------------------------------------------
|
||||
*
|
||||
* Permission is hereby granted, free of charge,
|
||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <file/nbio.h>
|
||||
|
||||
#if defined(ORBIS)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <orbisFile.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/fcntl.h>
|
||||
|
||||
struct nbio_orbis_t
|
||||
{
|
||||
int fd;
|
||||
void* data;
|
||||
size_t progress;
|
||||
size_t len;
|
||||
/*
|
||||
* possible values:
|
||||
* NBIO_READ, NBIO_WRITE - obvious
|
||||
* -1 - currently doing nothing
|
||||
* -2 - the pointer was reallocated since the last operation
|
||||
*/
|
||||
signed char op;
|
||||
unsigned int mode;
|
||||
};
|
||||
|
||||
static void *nbio_orbis_open(const char * filename, unsigned int mode)
|
||||
{
|
||||
RARCH_LOG("[NBIO_ORBIS] open %s\n" , filename);
|
||||
static const int o_flags[] = { O_RDONLY, O_RDWR|O_CREAT|O_TRUNC, O_RDWR, O_RDONLY, O_RDWR|O_CREAT|O_TRUNC };
|
||||
void *buf = NULL;
|
||||
struct nbio_orbis_t* handle = NULL;
|
||||
size_t len = 0;
|
||||
int fd = orbisOpen(filename, o_flags[mode], 0644);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
handle = (struct nbio_orbis_t*)malloc(sizeof(struct nbio_orbis_t));
|
||||
|
||||
if (!handle)
|
||||
goto error;
|
||||
|
||||
handle->fd = fd;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case NBIO_WRITE:
|
||||
case BIO_WRITE:
|
||||
break;
|
||||
default:
|
||||
len=orbisLseek(handle->fd, 0, SEEK_END);
|
||||
orbisLseek(handle->fd, 0, SEEK_SET);
|
||||
break;
|
||||
}
|
||||
|
||||
handle->mode = mode;
|
||||
|
||||
if (len)
|
||||
buf = malloc(len);
|
||||
if (!buf)
|
||||
{
|
||||
RARCH_LOG("[NBIO_ORBIS] open error malloc %d bytes\n",len);
|
||||
}
|
||||
if (len && !buf)
|
||||
goto error;
|
||||
|
||||
handle->data = buf;
|
||||
handle->len = len;
|
||||
handle->progress = handle->len;
|
||||
handle->op = -2;
|
||||
|
||||
return handle;
|
||||
|
||||
error:
|
||||
if (handle)
|
||||
free(handle);
|
||||
RARCH_LOG("[NBIO_ORBIS] open error closing %s\n" , filename);
|
||||
orbisClose(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void nbio_orbis_begin_read(void *data)
|
||||
{
|
||||
|
||||
struct nbio_orbis_t *handle = (struct nbio_orbis_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
RARCH_LOG("[NBIO_ORBIS] begin read fd=%d\n", handle->fd );
|
||||
|
||||
if (handle->op >= 0)
|
||||
{
|
||||
RARCH_LOG("[NBIO_ORBIS] ERROR - attempted file read operation while busy\n");
|
||||
//abort();
|
||||
return;
|
||||
}
|
||||
|
||||
orbisLseek(handle->fd, 0, SEEK_SET);
|
||||
|
||||
handle->op = NBIO_READ;
|
||||
handle->progress = 0;
|
||||
}
|
||||
|
||||
static void nbio_orbis_begin_write(void *data)
|
||||
{
|
||||
struct nbio_orbis_t *handle = (struct nbio_orbis_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
RARCH_LOG("[NBIO_ORBIS] begin write fd=%d\n", handle->fd );
|
||||
|
||||
if (handle->op >= 0)
|
||||
{
|
||||
RARCH_LOG("[NBIO_ORBIS] ERROR - attempted file write operation while busy\n");
|
||||
//abort();
|
||||
return;
|
||||
}
|
||||
|
||||
orbisLseek(handle->fd, 0, SEEK_SET);
|
||||
handle->op = NBIO_WRITE;
|
||||
handle->progress = 0;
|
||||
}
|
||||
|
||||
static bool nbio_orbis_iterate(void *data)
|
||||
{
|
||||
size_t amount = 65536;
|
||||
struct nbio_orbis_t *handle = (struct nbio_orbis_t*)data;
|
||||
|
||||
if (!handle)
|
||||
return false;
|
||||
RARCH_LOG("[NBIO_ORBIS] begin iterate fd=%d\n", handle->fd );
|
||||
|
||||
if (amount > handle->len - handle->progress)
|
||||
amount = handle->len - handle->progress;
|
||||
|
||||
switch (handle->op)
|
||||
{
|
||||
case NBIO_READ:
|
||||
if (handle->mode == BIO_READ)
|
||||
{
|
||||
amount = handle->len;
|
||||
RARCH_LOG("[NBIO_ORBIS] iterate BIO_READ fd=%d readbytes=%d\n", handle->fd, orbisRead(handle->fd, (char*)handle->data, amount));
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_LOG("[NBIO_ORBIS] iterate read fd=%d handle->progress=%d readbytes=%d\n", handle->fd, handle->progress, orbisRead(handle->fd, (char*)handle->data + handle->progress, amount));
|
||||
|
||||
}
|
||||
break;
|
||||
case NBIO_WRITE:
|
||||
if (handle->mode == BIO_WRITE)
|
||||
{
|
||||
size_t written = 0;
|
||||
amount = handle->len;
|
||||
written = orbisWrite(handle->fd, (char*)handle->data, amount);
|
||||
RARCH_LOG("[NBIO_ORBIS] iterate BIO_WRITE fd=%d writebytes=%d\n", handle->fd, written);
|
||||
|
||||
if (written != amount)
|
||||
{
|
||||
RARCH_LOG("[NBIO_ORBIS] iterate BIO_WRITE error fd=%d amount=%d != writebytes=%d\n", handle->fd, amount, written);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_LOG("[NBIO_ORBIS] iterate write fd=%d writebytes=%d\n", handle->fd, orbisWrite(handle->fd, (char*)handle->data + handle->progress, amount));
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
handle->progress += amount;
|
||||
RARCH_LOG("[NBIO_ORBIS] end iterate fd=%d\n", handle->fd );
|
||||
|
||||
if (handle->progress == handle->len)
|
||||
handle->op = -1;
|
||||
return (handle->op < 0);
|
||||
}
|
||||
|
||||
static void nbio_orbis_resize(void *data, size_t len)
|
||||
{
|
||||
struct nbio_orbis_t *handle = (struct nbio_orbis_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
if (handle->op >= 0)
|
||||
{
|
||||
RARCH_LOG("[NBIO_ORBIS] ERROR - attempted file resize operation while busy\n");
|
||||
//abort();
|
||||
return;
|
||||
}
|
||||
if (len < handle->len)
|
||||
{
|
||||
RARCH_LOG("[NBIO_ORBIS] ERROR - attempted file shrink operation, not implemented");
|
||||
//abort();
|
||||
return;
|
||||
}
|
||||
|
||||
handle->len = len;
|
||||
handle->data = realloc(handle->data, handle->len);
|
||||
handle->op = -1;
|
||||
handle->progress = handle->len;
|
||||
}
|
||||
|
||||
static void *nbio_orbis_get_ptr(void *data, size_t* len)
|
||||
{
|
||||
struct nbio_orbis_t *handle = (struct nbio_orbis_t*)data;
|
||||
if (!handle)
|
||||
return NULL;
|
||||
RARCH_LOG("[NBIO_ORBIS] get pointer\n");
|
||||
if (len)
|
||||
*len = handle->len;
|
||||
if (handle->op == -1)
|
||||
return handle->data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void nbio_orbis_cancel(void *data)
|
||||
{
|
||||
struct nbio_orbis_t *handle = (struct nbio_orbis_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
RARCH_LOG("[NBIO_ORBIS] cancel \n");
|
||||
handle->op = -1;
|
||||
handle->progress = handle->len;
|
||||
}
|
||||
|
||||
static void nbio_orbis_free(void *data)
|
||||
{
|
||||
struct nbio_orbis_t *handle = (struct nbio_orbis_t*)data;
|
||||
if (!handle)
|
||||
return;
|
||||
RARCH_LOG("[NBIO_ORBIS] begin free fd=%d\n", handle->fd );
|
||||
|
||||
if (handle->op >= 0)
|
||||
{
|
||||
RARCH_LOG("[NBIO_ORBIS] ERROR - attempted free() while busy\n");
|
||||
//abort();
|
||||
return;
|
||||
}
|
||||
RARCH_LOG("[NBIO_ORBIS] free close fd=%d\n",handle->fd);
|
||||
|
||||
orbisClose(handle->fd);
|
||||
free(handle->data);
|
||||
|
||||
handle->data = NULL;
|
||||
free(handle);
|
||||
}
|
||||
|
||||
nbio_intf_t nbio_orbis = {
|
||||
nbio_orbis_open,
|
||||
nbio_orbis_begin_read,
|
||||
nbio_orbis_begin_write,
|
||||
nbio_orbis_iterate,
|
||||
nbio_orbis_resize,
|
||||
nbio_orbis_get_ptr,
|
||||
nbio_orbis_cancel,
|
||||
nbio_orbis_free,
|
||||
"nbio_orbis",
|
||||
};
|
||||
#else
|
||||
nbio_intf_t nbio_orbis = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
"nbio_orbis",
|
||||
};
|
||||
#endif
|
@ -50,6 +50,11 @@
|
||||
# include <psp2/io/fcntl.h>
|
||||
# include <psp2/io/dirent.h>
|
||||
# include <psp2/io/stat.h>
|
||||
#elif defined(ORBIS)
|
||||
# include <orbisFile.h>
|
||||
# include <ps4link.h>
|
||||
# include <sys/dirent.h>
|
||||
# include <sys/fcntl.h>
|
||||
#else
|
||||
# if defined(PSP)
|
||||
# include <pspiofilemgr.h>
|
||||
@ -98,6 +103,9 @@ struct RDIR
|
||||
CellFsErrno error;
|
||||
int directory;
|
||||
CellFsDirent entry;
|
||||
#elif defined(ORBIS)
|
||||
int directory;
|
||||
struct dirent entry;
|
||||
#else
|
||||
DIR *directory;
|
||||
const struct dirent *entry;
|
||||
@ -159,6 +167,8 @@ struct RDIR *retro_opendir(const char *name)
|
||||
rdir->entry = NULL;
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
rdir->error = cellFsOpendir(name, &rdir->directory);
|
||||
#elif defined(ORBIS)
|
||||
rdir->directory = orbisDopen(name);
|
||||
#else
|
||||
rdir->directory = opendir(name);
|
||||
rdir->entry = NULL;
|
||||
@ -175,7 +185,7 @@ bool retro_dirent_error(struct RDIR *rdir)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return (rdir->directory == INVALID_HANDLE_VALUE);
|
||||
#elif defined(VITA) || defined(PSP) || defined(PS2)
|
||||
#elif defined(VITA) || defined(PSP) || defined(PS2) || defined(ORBIS)
|
||||
return (rdir->directory < 0);
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
return (rdir->error != CELL_FS_SUCCEEDED);
|
||||
@ -207,6 +217,8 @@ int retro_readdir(struct RDIR *rdir)
|
||||
uint64_t nread;
|
||||
rdir->error = cellFsReaddir(rdir->directory, &rdir->entry, &nread);
|
||||
return (nread != 0);
|
||||
#elif defined(ORBIS)
|
||||
return (orbisDread(rdir->directory, &rdir->entry) > 0);
|
||||
#else
|
||||
return ((rdir->entry = readdir(rdir->directory)) != NULL);
|
||||
#endif
|
||||
@ -231,7 +243,7 @@ const char *retro_dirent_get_name(struct RDIR *rdir)
|
||||
free(name);
|
||||
#endif
|
||||
return (char*)rdir->entry.cFileName;
|
||||
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__)
|
||||
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) || defined(ORBIS)
|
||||
return rdir->entry.d_name;
|
||||
#elif defined(PS2)
|
||||
return rdir->entry.name;
|
||||
@ -270,6 +282,14 @@ bool retro_dirent_is_dir(struct RDIR *rdir, const char *path)
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
CellFsDirent *entry = (CellFsDirent*)&rdir->entry;
|
||||
return (entry->d_type == CELL_FS_TYPE_DIRECTORY);
|
||||
#elif defined(ORBIS)
|
||||
const struct dirent *entry = &rdir->entry;
|
||||
if (entry->d_type==DT_DIR)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!(entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK))
|
||||
return false;
|
||||
#else
|
||||
struct stat buf;
|
||||
#if defined(DT_DIR)
|
||||
@ -311,6 +331,8 @@ void retro_closedir(struct RDIR *rdir)
|
||||
fileXioDclose(rdir->directory);
|
||||
#elif defined(__CELLOS_LV2__)
|
||||
rdir->error = cellFsClosedir(rdir->directory);
|
||||
#elif defined(ORBIS)
|
||||
orbisDclose(rdir->directory);
|
||||
#else
|
||||
if (rdir->directory)
|
||||
closedir(rdir->directory);
|
||||
|
@ -183,6 +183,12 @@ bool config_file_write(config_file_t *conf, const char *path, bool val);
|
||||
|
||||
/* Dump the current config to an already opened file.
|
||||
* Does not close the file. */
|
||||
void config_file_dump(config_file_t *conf, FILE *file);
|
||||
|
||||
#ifdef ORBIS
|
||||
void config_file_dump_orbis(config_file_t *conf, int fd);
|
||||
#endif
|
||||
|
||||
void config_file_dump(config_file_t *conf, FILE *file, bool val);
|
||||
|
||||
bool config_file_exists(const char *path);
|
||||
|
@ -77,7 +77,7 @@ static INLINE bool bits_any_set(uint32_t* ptr, uint32_t count)
|
||||
#ifndef PATH_MAX_LENGTH
|
||||
#if defined(__CELLOS_LV2__)
|
||||
#define PATH_MAX_LENGTH CELL_FS_MAX_FS_PATH_LENGTH
|
||||
#elif defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(PS2) || defined(GEKKO)|| defined(WIIU)
|
||||
#elif defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(PS2) || defined(GEKKO)|| defined(WIIU) || defined(ORBIS)
|
||||
#define PATH_MAX_LENGTH 512
|
||||
#else
|
||||
#define PATH_MAX_LENGTH 4096
|
||||
|
@ -56,6 +56,10 @@
|
||||
# include <dirent.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
# if defined(ORBIS)
|
||||
# include <sys/fcntl.h>
|
||||
# include <orbisFile.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __CELLOS_LV2__
|
||||
@ -123,6 +127,7 @@ int64_t retro_vfs_file_seek_internal(libretro_vfs_implementation_file *stream, i
|
||||
goto error;
|
||||
|
||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||
{
|
||||
/* VC2005 and up have a special 64-bit fseek */
|
||||
#ifdef ATLEAST_VC2005
|
||||
return _fseeki64(stream->fp, offset, whence);
|
||||
@ -130,10 +135,22 @@ int64_t retro_vfs_file_seek_internal(libretro_vfs_implementation_file *stream, i
|
||||
return fseek(stream->fp, (long)offset, whence);
|
||||
#elif defined(PS2)
|
||||
return fioLseek(fileno(stream->fp), (off_t)offset, whence);
|
||||
#elif defined(ORBIS)
|
||||
int ret;
|
||||
ret = orbisLseek(stream->fd, offset, whence);
|
||||
RARCH_LOG("[VFS]retro_vfs_file_seek_internal orbisLseek return %d on fd=%d filename=%s\n", ret, stream->fd, stream->orig_path);
|
||||
if (ret < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
return fseeko(stream->fp, (off_t)offset, whence);
|
||||
#endif
|
||||
|
||||
}
|
||||
#ifdef HAVE_MMAP
|
||||
/* Need to check stream->mapped because this function is
|
||||
* called in filestream_open() */
|
||||
@ -236,25 +253,28 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uns
|
||||
mode_str = "wb";
|
||||
|
||||
flags = O_WRONLY | O_CREAT | O_TRUNC;
|
||||
#if !defined(ORBIS)
|
||||
#if defined(PS2)
|
||||
flags |= FIO_S_IRUSR | FIO_S_IWUSR;
|
||||
#elif !defined(_WIN32)
|
||||
flags |= S_IRUSR | S_IWUSR;
|
||||
#else
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
|
||||
case RETRO_VFS_FILE_ACCESS_READ_WRITE:
|
||||
mode_str = "w+b";
|
||||
|
||||
flags = O_RDWR | O_CREAT | O_TRUNC;
|
||||
#if !defined(ORBIS)
|
||||
#if defined(PS2)
|
||||
flags |= FIO_S_IRUSR | FIO_S_IWUSR;
|
||||
#elif !defined(_WIN32)
|
||||
flags |= S_IRUSR | S_IWUSR;
|
||||
#else
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
|
||||
@ -263,12 +283,14 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uns
|
||||
mode_str = "r+b";
|
||||
|
||||
flags = O_RDWR;
|
||||
#if !defined(ORBIS)
|
||||
#if defined(PS2)
|
||||
flags |= FIO_S_IRUSR | FIO_S_IWUSR;
|
||||
#elif !defined(_WIN32)
|
||||
flags |= S_IRUSR | S_IWUSR;
|
||||
#else
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
#endif
|
||||
break;
|
||||
|
||||
@ -278,6 +300,16 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uns
|
||||
|
||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||
{
|
||||
#ifdef ORBIS
|
||||
int fd = orbisOpen(path, flags, 0644);
|
||||
RARCH_LOG("[VFS]retro_vfs_file_open_impl orbisOpen fd=%d path=%s\n", fd, path);
|
||||
if( fd < 0)
|
||||
{
|
||||
stream->fd=-1;
|
||||
goto error;
|
||||
}
|
||||
stream->fd = fd;
|
||||
#else
|
||||
FILE *fp = (FILE*)fopen_utf8(path, mode_str);
|
||||
|
||||
if (!fp)
|
||||
@ -340,14 +372,18 @@ libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uns
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ORBIS
|
||||
stream->size = orbisLseek(stream->fd, 0, SEEK_END);
|
||||
orbisLseek(stream->fd, 0, SEEK_SET);
|
||||
RARCH_LOG("[VFS]retro_vfs_file_open_impl size=%d fd=%d path=%s\n", stream->size, stream->fd, stream->orig_path);
|
||||
#else
|
||||
retro_vfs_file_seek_internal(stream, 0, SEEK_SET);
|
||||
retro_vfs_file_seek_internal(stream, 0, SEEK_END);
|
||||
|
||||
stream->size = retro_vfs_file_tell_impl(stream);
|
||||
|
||||
retro_vfs_file_seek_internal(stream, 0, SEEK_SET);
|
||||
|
||||
#endif
|
||||
return stream;
|
||||
|
||||
error:
|
||||
@ -374,7 +410,15 @@ int retro_vfs_file_close_impl(libretro_vfs_implementation_file *stream)
|
||||
}
|
||||
|
||||
if (stream->fd > 0)
|
||||
{
|
||||
#ifdef ORBIS
|
||||
RARCH_LOG("[VFS]retro_vfs_file_close_impl orbisClose fd=%d path=%s\n", stream->fd, stream->orig_path);
|
||||
orbisClose(stream->fd);
|
||||
stream->fd=-1;
|
||||
#else
|
||||
close(stream->fd);
|
||||
#endif
|
||||
}
|
||||
if (stream->buf)
|
||||
free(stream->buf);
|
||||
if (stream->orig_path)
|
||||
@ -386,7 +430,11 @@ int retro_vfs_file_close_impl(libretro_vfs_implementation_file *stream)
|
||||
|
||||
int retro_vfs_file_error_impl(libretro_vfs_implementation_file *stream)
|
||||
{
|
||||
#ifdef ORBIS
|
||||
return 0;
|
||||
#else
|
||||
return ferror(stream->fp);
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t retro_vfs_file_size_impl(libretro_vfs_implementation_file *stream)
|
||||
@ -404,7 +452,7 @@ int64_t retro_vfs_file_truncate_impl(libretro_vfs_implementation_file *stream, i
|
||||
#ifdef _WIN32
|
||||
if(_chsize(_fileno(stream->fp), length) != 0)
|
||||
return -1;
|
||||
#elif !defined(VITA) && !defined(PSP) && !defined(PS2) && (!defined(SWITCH) || defined(HAVE_LIBNX))
|
||||
#elif !defined(VITA) && !defined(PSP) && !defined(PS2) && !defined(ORBIS) && (!defined(SWITCH) || defined(HAVE_LIBNX))
|
||||
if(ftruncate(fileno(stream->fp), length) != 0)
|
||||
return -1;
|
||||
#endif
|
||||
@ -418,13 +466,27 @@ int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream)
|
||||
return -1;
|
||||
|
||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||
{
|
||||
#ifdef ORBIS
|
||||
int64_t ret = orbisLseek(stream->fd, 0, SEEK_CUR);
|
||||
RARCH_LOG("[VFS]retro_vfs_file_tell_impl orbisLseek fd=%d path=%s ret=%d\n", stream->fd, stream->orig_path, ret);
|
||||
if(ret < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
/* VC2005 and up have a special 64-bit ftell */
|
||||
#ifdef ATLEAST_VC2005
|
||||
return _ftelli64(stream->fp);
|
||||
#else
|
||||
return ftell(stream->fp);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
#ifdef HAVE_MMAP
|
||||
/* Need to check stream->mapped because this function
|
||||
* is called in filestream_open() */
|
||||
@ -462,8 +524,22 @@ int64_t retro_vfs_file_read_impl(libretro_vfs_implementation_file *stream, void
|
||||
goto error;
|
||||
|
||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||
{
|
||||
#ifdef ORBIS
|
||||
int64_t ret = orbisRead(stream->fd, s, (size_t)len);
|
||||
RARCH_LOG("[VFS]retro_vfs_file_read_impl orbisRead fd=%d path=%s bytesread=%d\n", stream->fd, stream->orig_path, ret);
|
||||
if( ret < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
return fread(s, 1, (size_t)len, stream->fp);
|
||||
|
||||
#endif
|
||||
}
|
||||
#ifdef HAVE_MMAP
|
||||
if (stream->hints & RETRO_VFS_FILE_ACCESS_HINT_FREQUENT_ACCESS)
|
||||
{
|
||||
@ -492,8 +568,22 @@ int64_t retro_vfs_file_write_impl(libretro_vfs_implementation_file *stream, cons
|
||||
goto error;
|
||||
|
||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||
{
|
||||
#ifdef ORBIS
|
||||
int64_t ret = orbisWrite(stream->fd, s, (size_t)len);
|
||||
RARCH_LOG("[VFS]retro_vfs_file_write_impl orbisWrite fd=%d path=%s byteswrite=%d\n", stream->fd, stream->orig_path, ret);
|
||||
if( ret < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
return fwrite(s, 1, (size_t)len, stream->fp);
|
||||
|
||||
#endif
|
||||
}
|
||||
#ifdef HAVE_MMAP
|
||||
if (stream->hints & RETRO_VFS_FILE_ACCESS_HINT_FREQUENT_ACCESS)
|
||||
goto error;
|
||||
@ -508,7 +598,11 @@ int retro_vfs_file_flush_impl(libretro_vfs_implementation_file *stream)
|
||||
{
|
||||
if (!stream)
|
||||
return -1;
|
||||
#ifdef ORBIS
|
||||
return 0;
|
||||
#else
|
||||
return fflush(stream->fp)==0 ? 0 : -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int retro_vfs_file_remove_impl(const char *path)
|
||||
@ -546,9 +640,14 @@ int retro_vfs_file_remove_impl(const char *path)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#ifdef ORBIS
|
||||
//by now no remove
|
||||
return 0;
|
||||
#else
|
||||
if (remove(path) == 0)
|
||||
return 0;
|
||||
#endif
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
@ -609,9 +708,14 @@ int retro_vfs_file_rename_impl(const char *old_path, const char *new_path)
|
||||
free(new_path_wide);
|
||||
#endif
|
||||
return -1;
|
||||
#else
|
||||
#ifdef ORBIS
|
||||
//by now no remove
|
||||
return 0;
|
||||
#else
|
||||
return rename(old_path, new_path)==0 ? 0 : -1;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *retro_vfs_file_get_path_impl(libretro_vfs_implementation_file *stream)
|
||||
|
@ -4997,6 +4997,11 @@ static void xmb_context_reset_background(const char *iconpath)
|
||||
task_push_image_load(path,
|
||||
menu_display_handle_wallpaper_upload, NULL);
|
||||
|
||||
#ifdef ORBIS
|
||||
// to avoid weird behaviour on orbis with remote host
|
||||
RARCH_LOG("[XMB] after task\n");
|
||||
sleep(5);
|
||||
#endif
|
||||
if (path)
|
||||
free(path);
|
||||
}
|
||||
|
@ -739,6 +739,11 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
|
||||
optstring = "hs:fvS:A:c:U:DN:d:"
|
||||
BSV_MOVIE_ARG NETPLAY_ARG DYNAMIC_ARG FFMPEG_RECORD_ARG;
|
||||
|
||||
#ifdef ORBIS
|
||||
argv = &(argv[2]);
|
||||
argc = argc - 2;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MENU
|
||||
if (argc == 1)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user