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 11, 2019
1 parent 8fbe5cb commit 274cd35
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions SourceX/main.cpp
Original file line number Diff line number Diff line change
@@ -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,20 @@ static std::string build_cmdline(int argc, char **argv)
int main(int argc, char **argv)
{
auto cmdline = build_cmdline(argc, argv);

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

return 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
}

0 comments on commit 274cd35

Please sign in to comment.