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_HiresCoordinates;
|
||||
|
||||
std::string LANDevice;
|
||||
bool DirectLAN;
|
||||
|
||||
CameraConfig Camera[2];
|
||||
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
||||
|
|
|
@ -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 <iphlpapi.h>
|
||||
|
@ -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];
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue