Skip to content

Commit

Permalink
Enable networking and stdio on Switch platform
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 authored and AJenbo committed Nov 24, 2019
1 parent 2ea83f1 commit fca1d12
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion SourceX/main.cpp
@@ -1,5 +1,9 @@
#include <string>
#include <SDL.h>
#ifdef __SWITCH__
#include <switch.h>
static int nxlink_sock = -1; // for stdio on Switch
#endif

#include "devilution.h"

Expand All @@ -25,5 +29,22 @@ static std::string build_cmdline(int argc, char **argv)
int main(int argc, char **argv)
{
auto cmdline = build_cmdline(argc, argv);
return dvl::WinMain(NULL, NULL, (char *)cmdline.c_str(), 0);

#ifdef __SWITCH__
// enable network and stdio on Switch
socketInitializeDefault();
// enable error messages via nxlink on Switch
nxlink_sock = nxlinkStdio();
#endif

int rv = dvl::WinMain(NULL, NULL, (char *)cmdline.c_str(), 0);

#ifdef __SWITCH__
// disable network and stdio on Switch
if (nxlink_sock != -1)
close(nxlink_sock);
socketExit();
#endif

return rv;
}

0 comments on commit fca1d12

Please sign in to comment.