From f43e3aa48aeb561f5c7e85f1b7121aab6a61decd Mon Sep 17 00:00:00 2001 From: cpasjuste Date: Wed, 22 Apr 2020 15:24:08 +0200 Subject: switch: first commit --- src/maingui.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/maingui.cpp') 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 +#include +} +#include +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 -- cgit v1.2.3-70-g09d2