From 08bdef481f1685e596fc2e45597a4bfe60aae8aa Mon Sep 17 00:00:00 2001 From: StapleButter Date: Sun, 16 Jul 2017 00:57:26 +0200 Subject: add setting for whether to bind the wifi socket to any address or to loopback only --- src/Config.cpp | 4 ++++ src/Config.h | 2 ++ src/Wifi.h | 3 +++ src/wx/EmuConfig.cpp | 5 +++++ src/wx/EmuConfig.h | 1 + src/wx/Platform.cpp | 3 ++- src/wx/main.cpp | 23 ++++++++++++++++++----- 7 files changed, 35 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Config.cpp b/src/Config.cpp index 5d7661d..95013fd 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -35,6 +35,8 @@ int DirectBoot; int Threaded3D; +int SocketBindAnyAddr; + typedef struct { char Name[16]; @@ -81,6 +83,8 @@ ConfigEntry ConfigFile[] = {"Threaded3D", 0, &Threaded3D, 1, NULL, 0}, + {"SockBindAnyAddr", 0, &SocketBindAnyAddr, 0, NULL, 0}, + {"", -1, NULL, 0, NULL, 0} }; diff --git a/src/Config.h b/src/Config.h index af32130..370f102 100644 --- a/src/Config.h +++ b/src/Config.h @@ -37,6 +37,8 @@ extern int DirectBoot; extern int Threaded3D; +extern int SocketBindAnyAddr; + } #endif // CONFIG_H diff --git a/src/Wifi.h b/src/Wifi.h index 65707f2..f0bf0ad 100644 --- a/src/Wifi.h +++ b/src/Wifi.h @@ -140,6 +140,9 @@ enum }; +extern bool MPInited; + + bool Init(); void DeInit(); void Reset(); diff --git a/src/wx/EmuConfig.cpp b/src/wx/EmuConfig.cpp index bace238..a8822a6 100644 --- a/src/wx/EmuConfig.cpp +++ b/src/wx/EmuConfig.cpp @@ -40,6 +40,10 @@ EmuConfigDialog::EmuConfigDialog(wxWindow* parent) vboxmain->Add(cbThreaded3D, 0, wxALL&(~wxBOTTOM), 15); cbThreaded3D->SetValue(Config::Threaded3D != 0); + cbBindAnyAddr = new wxCheckBox(this, wxID_ANY, "Wifi: bind socket to any address"); + vboxmain->Add(cbBindAnyAddr, 0, wxALL&(~wxBOTTOM), 15); + cbBindAnyAddr->SetValue(Config::SocketBindAnyAddr != 0); + { wxPanel* p = new wxPanel(this); wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); @@ -67,6 +71,7 @@ void EmuConfigDialog::OnOk(wxCommandEvent& event) { Config::DirectBoot = cbDirectBoot->GetValue() ? 1:0; Config::Threaded3D = cbThreaded3D->GetValue() ? 1:0; + Config::SocketBindAnyAddr = cbBindAnyAddr->GetValue() ? 1:0; Config::Save(); Close(); diff --git a/src/wx/EmuConfig.h b/src/wx/EmuConfig.h index d1f22a1..907692f 100644 --- a/src/wx/EmuConfig.h +++ b/src/wx/EmuConfig.h @@ -38,6 +38,7 @@ private: wxCheckBox* cbDirectBoot; wxCheckBox* cbThreaded3D; + wxCheckBox* cbBindAnyAddr; }; #endif // WX_EMUCONFIG_H diff --git a/src/wx/Platform.cpp b/src/wx/Platform.cpp index 4085420..48c3bfa 100644 --- a/src/wx/Platform.cpp +++ b/src/wx/Platform.cpp @@ -20,6 +20,7 @@ #include #include #include "../Platform.h" +#include "../Config.h" #include #ifndef WX_PRECOMP @@ -154,7 +155,7 @@ bool MP_Init() sockaddr_t saddr; saddr.sa_family = AF_INET; - *(u32*)&saddr.sa_data[2] = htonl(INADDR_LOOPBACK);//htonl(INADDR_ANY); + *(u32*)&saddr.sa_data[2] = htonl(Config::SocketBindAnyAddr ? INADDR_ANY : INADDR_LOOPBACK); *(u16*)&saddr.sa_data[0] = htons(7064); res = bind(MPSocket, &saddr, sizeof(sockaddr_t)); if (res < 0) diff --git a/src/wx/main.cpp b/src/wx/main.cpp index 4f15b94..3c2375b 100644 --- a/src/wx/main.cpp +++ b/src/wx/main.cpp @@ -24,6 +24,8 @@ #include "../GPU.h" #include "../GPU3D.h" #include "../SPU.h" +#include "../Wifi.h" +#include "../Platform.h" #include "InputConfig.h" #include "EmuConfig.h" @@ -113,7 +115,7 @@ bool wxApp_melonDS::OnInit() "bios7.bin -- ARM7 BIOS\n" "bios9.bin -- ARM9 BIOS\n" "firmware.bin -- firmware image\n\n" - "Place the following files in the directory you run melonDS from.\n" + "Dump the files from your DS and place them in the directory you run melonDS from.\n" "Make sure that the files can be accessed.", "melonDS", wxICON_ERROR); @@ -315,15 +317,26 @@ void MainFrame::OnReset(wxCommandEvent& event) void MainFrame::OnEmuConfig(wxCommandEvent& event) { bool oldpause = emuthread->EmuIsPaused(); - if (!oldpause) emuthread->EmuPause(); + if (!oldpause && emuthread->EmuIsRunning()) + emuthread->EmuPause(); EmuConfigDialog dlg(this); dlg.ShowModal(); - // apply threaded 3D setting - GPU3D::SoftRenderer::SetupRenderThread(); + if (emuthread->EmuIsRunning()) + { + // apply threaded 3D setting + GPU3D::SoftRenderer::SetupRenderThread(); - if (!oldpause) emuthread->EmuRun(); + if (Wifi::MPInited) + { + Platform::MP_DeInit(); + Platform::MP_Init(); + } + } + + if (!oldpause && emuthread->EmuIsRunning()) + emuthread->EmuRun(); } void MainFrame::OnInputConfig(wxCommandEvent& event) -- cgit v1.2.3