mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Core: Add some libnx calls for Switch.
This commit is contained in:
parent
d0e2aa3a4f
commit
fe32ad88fb
3 changed files with 39 additions and 11 deletions
|
@ -37,6 +37,13 @@
|
||||||
#include "Core/HLE/sceKernel.h"
|
#include "Core/HLE/sceKernel.h"
|
||||||
#include "Core/HLE/sceRtc.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 is a base time that everything is relative to.
|
||||||
// This way, time doesn't move strangely with savestates, turbo speed, etc.
|
// This way, time doesn't move strangely with savestates, turbo speed, etc.
|
||||||
static PSPTimeval rtcBaseTime;
|
static PSPTimeval rtcBaseTime;
|
||||||
|
@ -494,7 +501,7 @@ static int sceRtcConvertLocalTimeToUTC(u32 tickLocalPtr,u32 tickUTCPtr)
|
||||||
long timezone_val;
|
long timezone_val;
|
||||||
_get_timezone(&timezone_val);
|
_get_timezone(&timezone_val);
|
||||||
srcTick -= -timezone_val * 1000000ULL;
|
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;
|
time_t timezone = 0;
|
||||||
tm *time = localtime(&timezone);
|
tm *time = localtime(&timezone);
|
||||||
srcTick -= time->tm_gmtoff*1000000ULL;
|
srcTick -= time->tm_gmtoff*1000000ULL;
|
||||||
|
@ -519,7 +526,7 @@ static int sceRtcConvertUtcToLocalTime(u32 tickUTCPtr,u32 tickLocalPtr)
|
||||||
long timezone_val;
|
long timezone_val;
|
||||||
_get_timezone(&timezone_val);
|
_get_timezone(&timezone_val);
|
||||||
srcTick += -timezone_val * 1000000ULL;
|
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;
|
time_t timezone = 0;
|
||||||
tm *time = localtime(&timezone);
|
tm *time = localtime(&timezone);
|
||||||
srcTick += time->tm_gmtoff*1000000ULL;
|
srcTick += time->tm_gmtoff*1000000ULL;
|
||||||
|
@ -1054,7 +1061,7 @@ static int sceRtcFormatRFC2822LocalTime(u32 outPtr, u32 srcTickPtr)
|
||||||
long timezone_val;
|
long timezone_val;
|
||||||
_get_timezone(&timezone_val);
|
_get_timezone(&timezone_val);
|
||||||
tz_seconds = -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;
|
time_t timezone = 0;
|
||||||
tm *time = localtime(&timezone);
|
tm *time = localtime(&timezone);
|
||||||
tz_seconds = time->tm_gmtoff;
|
tz_seconds = time->tm_gmtoff;
|
||||||
|
@ -1091,7 +1098,7 @@ static int sceRtcFormatRFC3339LocalTime(u32 outPtr, u32 srcTickPtr)
|
||||||
long timezone_val;
|
long timezone_val;
|
||||||
_get_timezone(&timezone_val);
|
_get_timezone(&timezone_val);
|
||||||
tz_seconds = -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;
|
time_t timezone = 0;
|
||||||
tm *time = localtime(&timezone);
|
tm *time = localtime(&timezone);
|
||||||
tz_seconds = time->tm_gmtoff;
|
tz_seconds = time->tm_gmtoff;
|
||||||
|
|
|
@ -198,8 +198,9 @@ void OpenDirectory(const char *path) {
|
||||||
|
|
||||||
void LaunchBrowser(const char *url) {
|
void LaunchBrowser(const char *url) {
|
||||||
#if PPSSPP_PLATFORM(SWITCH)
|
#if PPSSPP_PLATFORM(SWITCH)
|
||||||
|
Uuid uuid = { 0 };
|
||||||
WebWifiConfig conf;
|
WebWifiConfig conf;
|
||||||
webWifiCreate(&conf, NULL, url, 0, 0);
|
webWifiCreate(&conf, NULL, url, uuid, 0);
|
||||||
webWifiShow(&conf, NULL);
|
webWifiShow(&conf, NULL);
|
||||||
#elif defined(MOBILE_DEVICE)
|
#elif defined(MOBILE_DEVICE)
|
||||||
ILOG("Would have gone to %s but LaunchBrowser is not implemented on this platform", url);
|
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) {
|
void LaunchMarket(const char *url) {
|
||||||
#if PPSSPP_PLATFORM(SWITCH)
|
#if PPSSPP_PLATFORM(SWITCH)
|
||||||
|
Uuid uuid = { 0 };
|
||||||
WebWifiConfig conf;
|
WebWifiConfig conf;
|
||||||
webWifiCreate(&conf, NULL, url, 0, 0);
|
webWifiCreate(&conf, NULL, url, uuid, 0);
|
||||||
webWifiShow(&conf, NULL);
|
webWifiShow(&conf, NULL);
|
||||||
#elif defined(MOBILE_DEVICE)
|
#elif defined(MOBILE_DEVICE)
|
||||||
ILOG("Would have gone to %s but LaunchMarket is not implemented on this platform", url);
|
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();
|
glslang::InitializeProcess();
|
||||||
|
|
||||||
#if PPSSPP_PLATFORM(RPI)
|
#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 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;
|
mode |= SDL_WINDOW_FULLSCREEN;
|
||||||
#elif defined(USING_FBDEV)
|
#elif defined(USING_FBDEV) || PPSSPP_PLATFORM(SWITCH)
|
||||||
mode |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
mode |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||||
#else
|
#else
|
||||||
mode |= SDL_WINDOW_RESIZABLE;
|
mode |= SDL_WINDOW_RESIZABLE;
|
||||||
|
@ -592,14 +599,19 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// Mac / Linux
|
// Mac / Linux
|
||||||
char path[2048];
|
char path[2048];
|
||||||
|
#if PPSSPP_PLATFORM(SWITCH)
|
||||||
|
strcpy(path, "/switch/ppsspp/");
|
||||||
|
#else
|
||||||
const char *the_path = getenv("HOME");
|
const char *the_path = getenv("HOME");
|
||||||
if (!the_path) {
|
if (!the_path) {
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
struct passwd *pwd = getpwuid(getuid());
|
||||||
if (pwd)
|
if (pwd)
|
||||||
the_path = pwd->pw_dir;
|
the_path = pwd->pw_dir;
|
||||||
}
|
}
|
||||||
strcpy(path, the_path);
|
if (the_path)
|
||||||
if (path[strlen(path)-1] != '/')
|
strcpy(path, the_path);
|
||||||
|
#endif
|
||||||
|
if (strlen(path) > 0 && path[strlen(path) - 1] != '/')
|
||||||
strcat(path, "/");
|
strcat(path, "/");
|
||||||
|
|
||||||
NativeInit(remain_argc, (const char **)remain_argv, path, "/tmp", nullptr);
|
NativeInit(remain_argc, (const char **)remain_argv, path, "/tmp", nullptr);
|
||||||
|
@ -1139,5 +1151,8 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
glslang::FinalizeProcess();
|
glslang::FinalizeProcess();
|
||||||
ILOG("Leaving main");
|
ILOG("Leaving main");
|
||||||
|
#ifdef HAVE_LIBNX
|
||||||
|
socketExit();
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBNX
|
||||||
|
#include <switch.h>
|
||||||
|
#endif // HAVE_LIBNX
|
||||||
|
|
||||||
static double curtime = 0;
|
static double curtime = 0;
|
||||||
static float curtime_f = 0;
|
static float curtime_f = 0;
|
||||||
|
|
||||||
|
@ -79,6 +83,8 @@ int time_now_ms() {
|
||||||
void sleep_ms(int ms) {
|
void sleep_ms(int ms) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
Sleep(ms);
|
Sleep(ms);
|
||||||
|
#elif defined(HAVE_LIBNX)
|
||||||
|
svcSleepThread(ms * 1000000);
|
||||||
#else
|
#else
|
||||||
usleep(ms * 1000);
|
usleep(ms * 1000);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue