Core: Add some libnx calls for Switch.

This commit is contained in:
M4xw 2020-03-15 07:56:38 -07:00 committed by Unknown W. Brackets
parent d0e2aa3a4f
commit fe32ad88fb
3 changed files with 39 additions and 11 deletions

View file

@ -37,6 +37,13 @@
#include "Core/HLE/sceKernel.h"
#include "Core/HLE/sceRtc.h"
#ifdef HAVE_LIBNX
// I guess that works...
#define setenv(x, y, z) (void*)0
#define tzset() (void*)0
#define unsetenv(x) (void*)0
#endif // HAVE_LIBNX
// This is a base time that everything is relative to.
// This way, time doesn't move strangely with savestates, turbo speed, etc.
static PSPTimeval rtcBaseTime;
@ -494,7 +501,7 @@ static int sceRtcConvertLocalTimeToUTC(u32 tickLocalPtr,u32 tickUTCPtr)
long timezone_val;
_get_timezone(&timezone_val);
srcTick -= -timezone_val * 1000000ULL;
#elif !defined(_AIX) && !defined(__sgi) && !defined(__hpux)
#elif !defined(_AIX) && !defined(__sgi) && !defined(__hpux) && !defined(HAVE_LIBNX)
time_t timezone = 0;
tm *time = localtime(&timezone);
srcTick -= time->tm_gmtoff*1000000ULL;
@ -519,7 +526,7 @@ static int sceRtcConvertUtcToLocalTime(u32 tickUTCPtr,u32 tickLocalPtr)
long timezone_val;
_get_timezone(&timezone_val);
srcTick += -timezone_val * 1000000ULL;
#elif !defined(_AIX) && !defined(__sgi) && !defined(__hpux)
#elif !defined(_AIX) && !defined(__sgi) && !defined(__hpux) && !defined(HAVE_LIBNX)
time_t timezone = 0;
tm *time = localtime(&timezone);
srcTick += time->tm_gmtoff*1000000ULL;
@ -1054,7 +1061,7 @@ static int sceRtcFormatRFC2822LocalTime(u32 outPtr, u32 srcTickPtr)
long timezone_val;
_get_timezone(&timezone_val);
tz_seconds = -timezone_val;
#elif !defined(_AIX) && !defined(__sgi) && !defined(__hpux)
#elif !defined(_AIX) && !defined(__sgi) && !defined(__hpux) && !defined(HAVE_LIBNX)
time_t timezone = 0;
tm *time = localtime(&timezone);
tz_seconds = time->tm_gmtoff;
@ -1091,7 +1098,7 @@ static int sceRtcFormatRFC3339LocalTime(u32 outPtr, u32 srcTickPtr)
long timezone_val;
_get_timezone(&timezone_val);
tz_seconds = -timezone_val;
#elif !defined(_AIX) && !defined(__sgi) && !defined(__hpux)
#elif !defined(_AIX) && !defined(__sgi) && !defined(__hpux) && !defined(HAVE_LIBNX)
time_t timezone = 0;
tm *time = localtime(&timezone);
tz_seconds = time->tm_gmtoff;

View file

@ -198,8 +198,9 @@ void OpenDirectory(const char *path) {
void LaunchBrowser(const char *url) {
#if PPSSPP_PLATFORM(SWITCH)
Uuid uuid = { 0 };
WebWifiConfig conf;
webWifiCreate(&conf, NULL, url, 0, 0);
webWifiCreate(&conf, NULL, url, uuid, 0);
webWifiShow(&conf, NULL);
#elif defined(MOBILE_DEVICE)
ILOG("Would have gone to %s but LaunchBrowser is not implemented on this platform", url);
@ -220,8 +221,9 @@ void LaunchBrowser(const char *url) {
void LaunchMarket(const char *url) {
#if PPSSPP_PLATFORM(SWITCH)
Uuid uuid = { 0 };
WebWifiConfig conf;
webWifiCreate(&conf, NULL, url, 0, 0);
webWifiCreate(&conf, NULL, url, uuid, 0);
webWifiShow(&conf, NULL);
#elif defined(MOBILE_DEVICE)
ILOG("Would have gone to %s but LaunchMarket is not implemented on this platform", url);
@ -448,6 +450,11 @@ int main(int argc, char *argv[]) {
}
}
#ifdef HAVE_LIBNX
socketInitializeDefault();
nxlinkStdio();
#endif // HAVE_LIBNX
glslang::InitializeProcess();
#if PPSSPP_PLATFORM(RPI)
@ -544,9 +551,9 @@ int main(int argc, char *argv[]) {
}
// If we're on mobile, don't try for windowed either.
#if defined(MOBILE_DEVICE)
#if defined(MOBILE_DEVICE) && !PPSSPP_PLATFORM(SWITCH)
mode |= SDL_WINDOW_FULLSCREEN;
#elif defined(USING_FBDEV)
#elif defined(USING_FBDEV) || PPSSPP_PLATFORM(SWITCH)
mode |= SDL_WINDOW_FULLSCREEN_DESKTOP;
#else
mode |= SDL_WINDOW_RESIZABLE;
@ -592,14 +599,19 @@ int main(int argc, char *argv[]) {
// Mac / Linux
char path[2048];
#if PPSSPP_PLATFORM(SWITCH)
strcpy(path, "/switch/ppsspp/");
#else
const char *the_path = getenv("HOME");
if (!the_path) {
struct passwd* pwd = getpwuid(getuid());
struct passwd *pwd = getpwuid(getuid());
if (pwd)
the_path = pwd->pw_dir;
}
strcpy(path, the_path);
if (path[strlen(path)-1] != '/')
if (the_path)
strcpy(path, the_path);
#endif
if (strlen(path) > 0 && path[strlen(path) - 1] != '/')
strcat(path, "/");
NativeInit(remain_argc, (const char **)remain_argv, path, "/tmp", nullptr);
@ -1139,5 +1151,8 @@ int main(int argc, char *argv[]) {
glslang::FinalizeProcess();
ILOG("Leaving main");
#ifdef HAVE_LIBNX
socketExit();
#endif
return 0;
}

View file

@ -11,6 +11,10 @@
#include <unistd.h>
#endif
#ifdef HAVE_LIBNX
#include <switch.h>
#endif // HAVE_LIBNX
static double curtime = 0;
static float curtime_f = 0;
@ -79,6 +83,8 @@ int time_now_ms() {
void sleep_ms(int ms) {
#ifdef _WIN32
Sleep(ms);
#elif defined(HAVE_LIBNX)
svcSleepThread(ms * 1000000);
#else
usleep(ms * 1000);
#endif