port WifiSettings -- still needs porting the LAN stuff
This commit is contained in:
parent
c0c78553e6
commit
7b709e6847
|
@ -62,9 +62,6 @@ int GL_ScaleFactor;
|
||||||
bool GL_BetterPolygons;
|
bool GL_BetterPolygons;
|
||||||
bool GL_HiresCoordinates;
|
bool GL_HiresCoordinates;
|
||||||
|
|
||||||
std::string LANDevice;
|
|
||||||
bool DirectLAN;
|
|
||||||
|
|
||||||
CameraConfig Camera[2];
|
CameraConfig Camera[2];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -176,9 +176,6 @@ extern int GL_ScaleFactor;
|
||||||
extern bool GL_BetterPolygons;
|
extern bool GL_BetterPolygons;
|
||||||
extern bool GL_HiresCoordinates;
|
extern bool GL_HiresCoordinates;
|
||||||
|
|
||||||
extern std::string LANDevice;
|
|
||||||
extern bool DirectLAN;
|
|
||||||
|
|
||||||
extern CameraConfig Camera[2];
|
extern CameraConfig Camera[2];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
#include "LAN_PCap.h"
|
#include "LAN_PCap.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
// REMOVE ME
|
||||||
|
extern EmuInstance* testinst;
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
|
@ -318,10 +322,11 @@ bool Init(bool open_adapter)
|
||||||
if (PCapAdapter) pcap_close(PCapAdapter);
|
if (PCapAdapter) pcap_close(PCapAdapter);
|
||||||
|
|
||||||
// open pcap device
|
// open pcap device
|
||||||
|
std::string devicename = testinst->getGlobalConfig().GetString("LAN.Device");
|
||||||
PCapAdapterData = &Adapters[0];
|
PCapAdapterData = &Adapters[0];
|
||||||
for (int i = 0; i < NumAdapters; i++)
|
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];
|
PCapAdapterData = &Adapters[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -660,7 +660,7 @@ u16 MP_RecvReplies(u8* data, u64 timestamp, u16 aidmask)
|
||||||
|
|
||||||
bool LAN_Init()
|
bool LAN_Init()
|
||||||
{
|
{
|
||||||
if (Config::DirectLAN)
|
/*if (testinst->getGlobalConfig().GetBool("LAN.DirectMode"))
|
||||||
{
|
{
|
||||||
if (!LAN_PCap::Init(true))
|
if (!LAN_PCap::Init(true))
|
||||||
return false;
|
return false;
|
||||||
|
@ -669,7 +669,7 @@ bool LAN_Init()
|
||||||
{
|
{
|
||||||
if (!LAN_Socket::Init())
|
if (!LAN_Socket::Init())
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -681,24 +681,26 @@ void LAN_DeInit()
|
||||||
// LAN_PCap::DeInit();
|
// LAN_PCap::DeInit();
|
||||||
//else
|
//else
|
||||||
// LAN_Socket::DeInit();
|
// LAN_Socket::DeInit();
|
||||||
LAN_PCap::DeInit();
|
/*LAN_PCap::DeInit();
|
||||||
LAN_Socket::DeInit();
|
LAN_Socket::DeInit();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
int LAN_SendPacket(u8* data, int len)
|
int LAN_SendPacket(u8* data, int len)
|
||||||
{
|
{
|
||||||
if (Config::DirectLAN)
|
/*if (testinst->getGlobalConfig().GetBool("LAN.DirectMode"))
|
||||||
return LAN_PCap::SendPacket(data, len);
|
return LAN_PCap::SendPacket(data, len);
|
||||||
else
|
else
|
||||||
return LAN_Socket::SendPacket(data, len);
|
return LAN_Socket::SendPacket(data, len);*/
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LAN_RecvPacket(u8* data)
|
int LAN_RecvPacket(u8* data)
|
||||||
{
|
{
|
||||||
if (Config::DirectLAN)
|
/*if (testinst->getGlobalConfig().GetBool("LAN.DirectMode"))
|
||||||
return LAN_PCap::RecvPacket(data);
|
return LAN_PCap::RecvPacket(data);
|
||||||
else
|
else
|
||||||
return LAN_Socket::RecvPacket(data);
|
return LAN_Socket::RecvPacket(data);*/
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
#include "LAN_Socket.h"
|
#include "LAN_Socket.h"
|
||||||
#include "LAN_PCap.h"
|
#include "LAN_PCap.h"
|
||||||
|
@ -50,6 +51,9 @@ WifiSettingsDialog::WifiSettingsDialog(QWidget* parent) : QDialog(parent), ui(ne
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
|
emuInstance = ((MainWindow*)parent)->getEmuInstance();
|
||||||
|
auto& cfg = emuInstance->getGlobalConfig();
|
||||||
|
|
||||||
haspcap = LAN_PCap::Init(false);
|
haspcap = LAN_PCap::Init(false);
|
||||||
|
|
||||||
ui->rbDirectMode->setText("Direct mode (requires " PCAP_NAME " and ethernet connection)");
|
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));
|
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;
|
sel = i;
|
||||||
}
|
}
|
||||||
ui->cbxDirectAdapter->setCurrentIndex(sel);
|
ui->cbxDirectAdapter->setCurrentIndex(sel);
|
||||||
|
|
||||||
// errrr???
|
// errrr???
|
||||||
ui->rbDirectMode->setChecked(Config::DirectLAN);
|
bool direct = cfg.GetBool("LAN.DirectMode");
|
||||||
ui->rbIndirectMode->setChecked(!Config::DirectLAN);
|
ui->rbDirectMode->setChecked(direct);
|
||||||
|
ui->rbIndirectMode->setChecked(!direct);
|
||||||
if (!haspcap) ui->rbDirectMode->setEnabled(false);
|
if (!haspcap) ui->rbDirectMode->setEnabled(false);
|
||||||
|
|
||||||
updateAdapterControls();
|
updateAdapterControls();
|
||||||
|
@ -88,17 +93,19 @@ void WifiSettingsDialog::done(int r)
|
||||||
|
|
||||||
if (r == QDialog::Accepted)
|
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();
|
int sel = ui->cbxDirectAdapter->currentIndex();
|
||||||
if (sel < 0 || sel >= LAN_PCap::NumAdapters) sel = 0;
|
if (sel < 0 || sel >= LAN_PCap::NumAdapters) sel = 0;
|
||||||
if (LAN_PCap::NumAdapters < 1)
|
if (LAN_PCap::NumAdapters < 1)
|
||||||
{
|
{
|
||||||
Config::LANDevice = "";
|
cfg.SetString("LAN.Device", "");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Config::LANDevice = LAN_PCap::Adapters[sel].DeviceName;
|
cfg.SetString("LAN.Device", LAN_PCap::Adapters[sel].DeviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::Save();
|
Config::Save();
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
namespace Ui { class WifiSettingsDialog; }
|
namespace Ui { class WifiSettingsDialog; }
|
||||||
class WifiSettingsDialog;
|
class WifiSettingsDialog;
|
||||||
|
|
||||||
|
class EmuInstance;
|
||||||
|
|
||||||
class WifiSettingsDialog : public QDialog
|
class WifiSettingsDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -61,6 +63,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::WifiSettingsDialog* ui;
|
Ui::WifiSettingsDialog* ui;
|
||||||
|
EmuInstance* emuInstance;
|
||||||
|
|
||||||
bool haspcap;
|
bool haspcap;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue