summaryrefslogtreecommitdiff
path: root/src/maingui.cpp
diff options
context:
space:
mode:
authorcpasjuste <cpasjuste@gmail.com>2020-04-22 15:24:08 +0200
committercpasjuste <cpasjuste@gmail.com>2020-04-22 15:24:08 +0200
commitf43e3aa48aeb561f5c7e85f1b7121aab6a61decd (patch)
tree1c23a1e1db2676c27a99b6385f0580442b29f7a0 /src/maingui.cpp
parentb0c696eaab501391512b08826c3c9a52023e2be7 (diff)
downloadplus-f43e3aa48aeb561f5c7e85f1b7121aab6a61decd.tar.gz
plus-f43e3aa48aeb561f5c7e85f1b7121aab6a61decd.tar.bz2
plus-f43e3aa48aeb561f5c7e85f1b7121aab6a61decd.tar.xz
plus-f43e3aa48aeb561f5c7e85f1b7121aab6a61decd.zip
switch: first commit
Diffstat (limited to 'src/maingui.cpp')
-rw-r--r--src/maingui.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/maingui.cpp b/src/maingui.cpp
index 176c5cd6e..054db6b05 100644
--- a/src/maingui.cpp
+++ b/src/maingui.cpp
@@ -97,6 +97,29 @@ PRAGMA48(GCC diagnostic pop)
#include "debug.h"
+#ifdef __SWITCH__
+extern "C" {
+#include <switch/runtime/devices/socket.h>
+#include <switch/runtime/nxlink.h>
+}
+#include <unistd.h>
+static int sock = -1;
+void initNxLink() {
+ socketInitializeDefault();
+ sock = nxlinkStdio();
+ if (sock < 0) {
+ socketExit();
+ }
+}
+void deinitNxLink() {
+ if (sock >= 0) {
+ close(sock);
+ socketExit();
+ sock = -1;
+ }
+}
+#endif
+
char *selfName = nullptr;
#ifndef UNITTESTS
@@ -107,6 +130,9 @@ int main(int argc, char *argv[])
int mainGui(int argc, char *argv[])
#endif // ANDROID
{
+#ifdef __SWITCH__
+ initNxLink();
+#endif
#if defined(__MINGW32__)
// load mingw crash handler. Won't fail if dll is not present.
// may load libray from current dir, it may not same as program dir
@@ -159,6 +185,10 @@ int mainGui(int argc, char *argv[])
IMG_Quit();
#endif // SDL_IMAGE_VERSION_ATLEAST(1, 2, 11)
+#ifdef __SWITCH__
+ deinitNxLink();
+#endif
+
return ret;
}
#else // UNITTESTS