diff --git a/src/frontend/qt_sdl/Config.cpp b/src/frontend/qt_sdl/Config.cpp index e35f6ef7..35b6e648 100644 --- a/src/frontend/qt_sdl/Config.cpp +++ b/src/frontend/qt_sdl/Config.cpp @@ -62,9 +62,6 @@ int GL_ScaleFactor; bool GL_BetterPolygons; bool GL_HiresCoordinates; -std::string LANDevice; -bool DirectLAN; - CameraConfig Camera[2]; diff --git a/src/frontend/qt_sdl/Config.h b/src/frontend/qt_sdl/Config.h index a931fd67..b5a76c5f 100644 --- a/src/frontend/qt_sdl/Config.h +++ b/src/frontend/qt_sdl/Config.h @@ -176,9 +176,6 @@ extern int GL_ScaleFactor; extern bool GL_BetterPolygons; extern bool GL_HiresCoordinates; -extern std::string LANDevice; -extern bool DirectLAN; - extern CameraConfig Camera[2]; diff --git a/src/frontend/qt_sdl/LAN_PCap.cpp b/src/frontend/qt_sdl/LAN_PCap.cpp index 4a1ebc35..f95eef45 100644 --- a/src/frontend/qt_sdl/LAN_PCap.cpp +++ b/src/frontend/qt_sdl/LAN_PCap.cpp @@ -26,6 +26,10 @@ #include "LAN_PCap.h" #include "Config.h" #include "Platform.h" +#include "main.h" + +// REMOVE ME +extern EmuInstance* testinst; #ifdef __WIN32__ #include @@ -318,10 +322,11 @@ bool Init(bool open_adapter) if (PCapAdapter) pcap_close(PCapAdapter); // open pcap device + std::string devicename = testinst->getGlobalConfig().GetString("LAN.Device"); PCapAdapterData = &Adapters[0]; for (int i = 0; i < NumAdapters; i++) { - if (!strncmp(Adapters[i].DeviceName, Config::LANDevice.c_str(), 128)) + if (!strncmp(Adapters[i].DeviceName, devicename.c_str(), 128)) PCapAdapterData = &Adapters[i]; } diff --git a/src/frontend/qt_sdl/Platform.cpp b/src/frontend/qt_sdl/Platform.cpp index 5518488f..a0aa751f 100644 --- a/src/frontend/qt_sdl/Platform.cpp +++ b/src/frontend/qt_sdl/Platform.cpp @@ -660,7 +660,7 @@ u16 MP_RecvReplies(u8* data, u64 timestamp, u16 aidmask) bool LAN_Init() { - if (Config::DirectLAN) + /*if (testinst->getGlobalConfig().GetBool("LAN.DirectMode")) { if (!LAN_PCap::Init(true)) return false; @@ -669,7 +669,7 @@ bool LAN_Init() { if (!LAN_Socket::Init()) return false; - } + }*/ return true; } @@ -681,24 +681,26 @@ void LAN_DeInit() // LAN_PCap::DeInit(); //else // LAN_Socket::DeInit(); - LAN_PCap::DeInit(); - LAN_Socket::DeInit(); + /*LAN_PCap::DeInit(); + LAN_Socket::DeInit();*/ } int LAN_SendPacket(u8* data, int len) { - if (Config::DirectLAN) + /*if (testinst->getGlobalConfig().GetBool("LAN.DirectMode")) return LAN_PCap::SendPacket(data, len); else - return LAN_Socket::SendPacket(data, len); + return LAN_Socket::SendPacket(data, len);*/ + return 0; } int LAN_RecvPacket(u8* data) { - if (Config::DirectLAN) + /*if (testinst->getGlobalConfig().GetBool("LAN.DirectMode")) return LAN_PCap::RecvPacket(data); else - return LAN_Socket::RecvPacket(data); + return LAN_Socket::RecvPacket(data);*/ + return 0; } diff --git a/src/frontend/qt_sdl/WifiSettingsDialog.cpp b/src/frontend/qt_sdl/WifiSettingsDialog.cpp index d71657a3..d7ab5d8e 100644 --- a/src/frontend/qt_sdl/WifiSettingsDialog.cpp +++ b/src/frontend/qt_sdl/WifiSettingsDialog.cpp @@ -22,6 +22,7 @@ #include "types.h" #include "Platform.h" #include "Config.h" +#include "main.h" #include "LAN_Socket.h" #include "LAN_PCap.h" @@ -50,6 +51,9 @@ WifiSettingsDialog::WifiSettingsDialog(QWidget* parent) : QDialog(parent), ui(ne ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); + emuInstance = ((MainWindow*)parent)->getEmuInstance(); + auto& cfg = emuInstance->getGlobalConfig(); + haspcap = LAN_PCap::Init(false); ui->rbDirectMode->setText("Direct mode (requires " PCAP_NAME " and ethernet connection)"); @@ -64,14 +68,15 @@ WifiSettingsDialog::WifiSettingsDialog(QWidget* parent) : QDialog(parent), ui(ne ui->cbxDirectAdapter->addItem(QString(adapter->FriendlyName)); - if (!strncmp(adapter->DeviceName, Config::LANDevice.c_str(), 128)) + if (!strncmp(adapter->DeviceName, cfg.GetString("LAN.Device").c_str(), 128)) sel = i; } ui->cbxDirectAdapter->setCurrentIndex(sel); // errrr??? - ui->rbDirectMode->setChecked(Config::DirectLAN); - ui->rbIndirectMode->setChecked(!Config::DirectLAN); + bool direct = cfg.GetBool("LAN.DirectMode"); + ui->rbDirectMode->setChecked(direct); + ui->rbIndirectMode->setChecked(!direct); if (!haspcap) ui->rbDirectMode->setEnabled(false); updateAdapterControls(); @@ -88,17 +93,19 @@ void WifiSettingsDialog::done(int r) if (r == QDialog::Accepted) { - Config::DirectLAN = ui->rbDirectMode->isChecked(); + auto& cfg = emuInstance->getGlobalConfig(); + + cfg.SetBool("LAN.DirectMode", ui->rbDirectMode->isChecked()); int sel = ui->cbxDirectAdapter->currentIndex(); if (sel < 0 || sel >= LAN_PCap::NumAdapters) sel = 0; if (LAN_PCap::NumAdapters < 1) { - Config::LANDevice = ""; + cfg.SetString("LAN.Device", ""); } else { - Config::LANDevice = LAN_PCap::Adapters[sel].DeviceName; + cfg.SetString("LAN.Device", LAN_PCap::Adapters[sel].DeviceName); } Config::Save(); diff --git a/src/frontend/qt_sdl/WifiSettingsDialog.h b/src/frontend/qt_sdl/WifiSettingsDialog.h index 82e1bd49..68d518d1 100644 --- a/src/frontend/qt_sdl/WifiSettingsDialog.h +++ b/src/frontend/qt_sdl/WifiSettingsDialog.h @@ -24,6 +24,8 @@ namespace Ui { class WifiSettingsDialog; } class WifiSettingsDialog; +class EmuInstance; + class WifiSettingsDialog : public QDialog { Q_OBJECT @@ -61,6 +63,7 @@ private slots: private: Ui::WifiSettingsDialog* ui; + EmuInstance* emuInstance; bool haspcap;