move 'randomize MAC' setting to firmware settings, and add setting for changing the MAC.
make things overall betterer.
This commit is contained in:
parent
1fc775d964
commit
1472a0ec4b
|
@ -69,7 +69,6 @@ enum ConfigEntry
|
|||
DSiSD_FolderSync,
|
||||
DSiSD_FolderPath,
|
||||
|
||||
Firm_RandomizeMAC,
|
||||
Firm_OverrideSettings,
|
||||
Firm_Username,
|
||||
Firm_Language,
|
||||
|
@ -77,6 +76,8 @@ enum ConfigEntry
|
|||
Firm_BirthdayDay,
|
||||
Firm_Color,
|
||||
Firm_Message,
|
||||
Firm_MAC,
|
||||
Firm_RandomizeMAC,
|
||||
|
||||
AudioBitrate,
|
||||
};
|
||||
|
@ -84,6 +85,7 @@ enum ConfigEntry
|
|||
int GetConfigInt(ConfigEntry entry);
|
||||
bool GetConfigBool(ConfigEntry entry);
|
||||
std::string GetConfigString(ConfigEntry entry);
|
||||
bool GetConfigArray(ConfigEntry entry, void* data);
|
||||
|
||||
// fopen() wrappers
|
||||
// * OpenFile():
|
||||
|
|
41
src/SPI.cpp
41
src/SPI.cpp
|
@ -197,6 +197,7 @@ void Reset()
|
|||
if (Firmware) delete[] Firmware;
|
||||
Firmware = nullptr;
|
||||
FirmwarePath = "";
|
||||
bool firmoverride = false;
|
||||
|
||||
if (Platform::GetConfigBool(Platform::ExternalBIOSEnable))
|
||||
{
|
||||
|
@ -221,6 +222,11 @@ void Reset()
|
|||
if (FirmwarePath.empty())
|
||||
{
|
||||
LoadDefaultFirmware();
|
||||
firmoverride = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
firmoverride = Platform::GetConfigBool(Platform::Firm_OverrideSettings);
|
||||
}
|
||||
|
||||
FirmwareMask = FirmwareLength - 1;
|
||||
|
@ -234,7 +240,7 @@ void Reset()
|
|||
|
||||
UserSettings = userdata;
|
||||
|
||||
if (FirmwarePath.empty() || Platform::GetConfigBool(Platform::Firm_OverrideSettings))
|
||||
if (firmoverride)
|
||||
LoadUserSettingsFromConfig();
|
||||
|
||||
// fix touchscreen coords
|
||||
|
@ -252,17 +258,32 @@ void Reset()
|
|||
|
||||
*(u16*)&Firmware[userdata+0x72] = CRC16(&Firmware[userdata], 0x70, 0xFFFF);
|
||||
|
||||
if (Platform::GetConfigBool(Platform::Firm_RandomizeMAC))
|
||||
if (firmoverride)
|
||||
{
|
||||
// replace MAC address with random address
|
||||
Firmware[0x36] = 0x00;
|
||||
Firmware[0x37] = 0x09;
|
||||
Firmware[0x38] = 0xBF;
|
||||
Firmware[0x39] = rand()&0xFF;
|
||||
Firmware[0x3A] = rand()&0xFF;
|
||||
Firmware[0x3B] = rand()&0xFF;
|
||||
u8 mac[6];
|
||||
bool rep;
|
||||
|
||||
*(u16*)&Firmware[0x2A] = CRC16(&Firmware[0x2C], *(u16*)&Firmware[0x2C], 0x0000);
|
||||
if (Platform::GetConfigBool(Platform::Firm_RandomizeMAC))
|
||||
{
|
||||
mac[0] = 0x00;
|
||||
mac[1] = 0x09;
|
||||
mac[2] = 0xBF;
|
||||
mac[3] = rand()&0xFF;
|
||||
mac[4] = rand()&0xFF;
|
||||
mac[5] = rand()&0xFF;
|
||||
rep = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
rep = Platform::GetConfigArray(Platform::Firm_MAC, mac);
|
||||
}
|
||||
|
||||
if (rep)
|
||||
{
|
||||
memcpy(&Firmware[0x36], mac, 6);
|
||||
|
||||
*(u16*)&Firmware[0x2A] = CRC16(&Firmware[0x2C], *(u16*)&Firmware[0x2C], 0x0000);
|
||||
}
|
||||
}
|
||||
|
||||
printf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
|
||||
|
|
|
@ -98,7 +98,6 @@ int DSiSDReadOnly;
|
|||
int DSiSDFolderSync;
|
||||
char DSiSDFolderPath[1024];
|
||||
|
||||
int RandomizeMAC;
|
||||
int FirmwareOverrideSettings;
|
||||
char FirmwareUsername[64];
|
||||
int FirmwareLanguage;
|
||||
|
@ -106,6 +105,8 @@ int FirmwareBirthdayMonth;
|
|||
int FirmwareBirthdayDay;
|
||||
int FirmwareFavouriteColour;
|
||||
char FirmwareMessage[1024];
|
||||
char FirmwareMAC[18];
|
||||
int RandomizeMAC;
|
||||
|
||||
int SocketBindAnyAddr;
|
||||
char LANDevice[128];
|
||||
|
@ -255,7 +256,6 @@ ConfigEntry ConfigFile[] =
|
|||
{"DSiSDFolderSync", 0, &DSiSDFolderSync, 0, NULL, 0},
|
||||
{"DSiSDFolderPath", 1, DSiSDFolderPath, 0, "", 1023},
|
||||
|
||||
{"RandomizeMAC", 0, &RandomizeMAC, 0, NULL, 0},
|
||||
{"FirmwareOverrideSettings", 0, &FirmwareOverrideSettings, false, NULL, 0},
|
||||
{"FirmwareUsername", 1, FirmwareUsername, 0, "melonDS", 63},
|
||||
{"FirmwareLanguage", 0, &FirmwareLanguage, 1, NULL, 0},
|
||||
|
@ -263,6 +263,8 @@ ConfigEntry ConfigFile[] =
|
|||
{"FirmwareBirthdayDay", 0, &FirmwareBirthdayDay, 0, NULL, 0},
|
||||
{"FirmwareFavouriteColour", 0, &FirmwareFavouriteColour, 0, NULL, 0},
|
||||
{"FirmwareMessage", 1, FirmwareMessage, 0, "", 1023},
|
||||
{"FirmwareMAC", 1, FirmwareMAC, 0, "", 17},
|
||||
{"RandomizeMAC", 0, &RandomizeMAC, 0, NULL, 0},
|
||||
|
||||
{"SockBindAnyAddr", 0, &SocketBindAnyAddr, 0, NULL, 0},
|
||||
{"LANDevice", 1, LANDevice, 0, "", 127},
|
||||
|
|
|
@ -121,7 +121,6 @@ extern int DSiSDReadOnly;
|
|||
extern int DSiSDFolderSync;
|
||||
extern char DSiSDFolderPath[1024];
|
||||
|
||||
extern int RandomizeMAC;
|
||||
extern int FirmwareOverrideSettings;
|
||||
extern char FirmwareUsername[64];
|
||||
extern int FirmwareLanguage;
|
||||
|
@ -129,6 +128,8 @@ extern int FirmwareBirthdayMonth;
|
|||
extern int FirmwareBirthdayDay;
|
||||
extern int FirmwareFavouriteColour;
|
||||
extern char FirmwareMessage[1024];
|
||||
extern char FirmwareMAC[18];
|
||||
extern int RandomizeMAC;
|
||||
|
||||
extern int SocketBindAnyAddr;
|
||||
extern char LANDevice[128];
|
||||
|
|
|
@ -16,13 +16,20 @@
|
|||
with melonDS. If not, see http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include "FirmwareSettingsDialog.h"
|
||||
#include "ui_FirmwareSettingsDialog.h"
|
||||
|
||||
|
||||
FirmwareSettingsDialog* FirmwareSettingsDialog::currentDlg = nullptr;
|
||||
|
||||
extern bool RunningSomething;
|
||||
|
||||
bool FirmwareSettingsDialog::needsReset = false;
|
||||
|
||||
FirmwareSettingsDialog::FirmwareSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::FirmwareSettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -55,6 +62,10 @@ FirmwareSettingsDialog::FirmwareSettingsDialog(QWidget* parent) : QDialog(parent
|
|||
ui->messageEdit->setText(Config::FirmwareMessage);
|
||||
|
||||
ui->overrideFirmwareBox->setChecked(Config::FirmwareOverrideSettings);
|
||||
|
||||
ui->txtMAC->setText(Config::FirmwareMAC);
|
||||
ui->cbRandomizeMAC->setChecked(Config::RandomizeMAC != 0);
|
||||
on_cbRandomizeMAC_toggled();
|
||||
}
|
||||
|
||||
FirmwareSettingsDialog::~FirmwareSettingsDialog()
|
||||
|
@ -62,31 +73,112 @@ FirmwareSettingsDialog::~FirmwareSettingsDialog()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void FirmwareSettingsDialog::on_FirmwareSettingsDialog_accepted()
|
||||
bool FirmwareSettingsDialog::verifyMAC()
|
||||
{
|
||||
std::string newName = ui->usernameEdit->text().toStdString();
|
||||
strncpy(Config::FirmwareUsername, newName.c_str(), 63); Config::FirmwareUsername[63] = '\0';
|
||||
QString mac = ui->txtMAC->text();
|
||||
int maclen = mac.length();
|
||||
|
||||
Config::FirmwareLanguage = ui->languageBox->currentIndex();
|
||||
Config::FirmwareFavouriteColour = ui->colorsEdit->currentIndex();
|
||||
Config::FirmwareBirthdayDay = ui->cbxBirthdayDay->currentIndex() + 1;
|
||||
Config::FirmwareBirthdayMonth = ui->cbxBirthdayMonth->currentIndex() + 1;
|
||||
Config::FirmwareOverrideSettings = ui->overrideFirmwareBox->isChecked();
|
||||
// blank MAC = no MAC override
|
||||
if (maclen == 0)
|
||||
return true;
|
||||
|
||||
std::string newMessage = ui->messageEdit->text().toStdString();
|
||||
strncpy(Config::FirmwareMessage, newMessage.c_str(), 1023); Config::FirmwareMessage[1023] = '\0';
|
||||
Config::Save();
|
||||
// length should be 12 or 17 if separators are used
|
||||
if (maclen != 12 && maclen != 17)
|
||||
return false;
|
||||
|
||||
closeDlg();
|
||||
bool hassep = maclen==17;
|
||||
int pos = 0;
|
||||
for (int i = 0; i < maclen;)
|
||||
{
|
||||
QCharRef c = mac[i];
|
||||
bool good = false;
|
||||
if (c >= '0' && c <= '9') good = true;
|
||||
else if (c >= 'a' && c <= 'f') good = true;
|
||||
else if (c >= 'A' && c <= 'F') good = true;
|
||||
if (!good) return false;
|
||||
|
||||
i++;
|
||||
pos++;
|
||||
if (pos >= 2)
|
||||
{
|
||||
pos = 0;
|
||||
if (hassep) i++;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FirmwareSettingsDialog::on_FirmwareSettingsDialog_rejected()
|
||||
void FirmwareSettingsDialog::done(int r)
|
||||
{
|
||||
needsReset = false;
|
||||
|
||||
if (r == QDialog::Accepted)
|
||||
{
|
||||
if (!verifyMAC())
|
||||
{
|
||||
QMessageBox::critical(this, "Invalid MAC address",
|
||||
"The MAC address you entered isn't valid. It should contain 6 pairs of hexadecimal digits, optionally separated.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int newOverride = ui->overrideFirmwareBox->isChecked();
|
||||
|
||||
std::string newName = ui->usernameEdit->text().toStdString();
|
||||
int newLanguage = ui->languageBox->currentIndex();
|
||||
int newFavColor = ui->colorsEdit->currentIndex();
|
||||
int newBirthdayDay = ui->cbxBirthdayDay->currentIndex() + 1;
|
||||
int newBirthdayMonth = ui->cbxBirthdayMonth->currentIndex() + 1;
|
||||
std::string newMessage = ui->messageEdit->text().toStdString();
|
||||
|
||||
std::string newMAC = ui->txtMAC->text().toStdString();
|
||||
int newRandomizeMAC = ui->cbRandomizeMAC->isChecked() ? 1:0;
|
||||
|
||||
if ( newOverride != Config::FirmwareOverrideSettings
|
||||
|| strcmp(newName.c_str(), Config::FirmwareUsername) != 0
|
||||
|| newLanguage != Config::FirmwareLanguage
|
||||
|| newFavColor != Config::FirmwareFavouriteColour
|
||||
|| newBirthdayDay != Config::FirmwareBirthdayDay
|
||||
|| newBirthdayMonth != Config::FirmwareBirthdayMonth
|
||||
|| strcmp(newMessage.c_str(), Config::FirmwareMessage) != 0
|
||||
|| strcmp(newMAC.c_str(), Config::FirmwareMAC) != 0
|
||||
|| newRandomizeMAC != Config::RandomizeMAC)
|
||||
{
|
||||
if (RunningSomething
|
||||
&& QMessageBox::warning(this, "Reset necessary to apply changes",
|
||||
"The emulation will be reset for the changes to take place.",
|
||||
QMessageBox::Ok, QMessageBox::Cancel) != QMessageBox::Ok)
|
||||
return;
|
||||
|
||||
Config::FirmwareOverrideSettings = newOverride;
|
||||
|
||||
strncpy(Config::FirmwareUsername, newName.c_str(), 63); Config::FirmwareUsername[63] = '\0';
|
||||
Config::FirmwareLanguage = newLanguage;
|
||||
Config::FirmwareFavouriteColour = newFavColor;
|
||||
Config::FirmwareBirthdayDay = newBirthdayDay;
|
||||
Config::FirmwareBirthdayMonth = newBirthdayMonth;
|
||||
strncpy(Config::FirmwareMessage, newMessage.c_str(), 1023); Config::FirmwareMessage[1023] = '\0';
|
||||
|
||||
strncpy(Config::FirmwareMAC, newMAC.c_str(), 17); Config::FirmwareMAC[17] = '\0';
|
||||
Config::RandomizeMAC = newRandomizeMAC;
|
||||
|
||||
Config::Save();
|
||||
|
||||
needsReset = true;
|
||||
}
|
||||
}
|
||||
|
||||
QDialog::done(r);
|
||||
|
||||
closeDlg();
|
||||
}
|
||||
|
||||
void FirmwareSettingsDialog::on_cbxBirthdayMonth_currentIndexChanged(int idx)
|
||||
{
|
||||
// prevent spurious changes
|
||||
if (ui->cbxBirthdayMonth->count() < 12) return;
|
||||
|
||||
// the DS firmware caps the birthday day depending on the birthday month
|
||||
// for February, the limit is 29
|
||||
const int ndays[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
|
@ -109,3 +201,9 @@ void FirmwareSettingsDialog::on_cbxBirthdayMonth_currentIndexChanged(int idx)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FirmwareSettingsDialog::on_cbRandomizeMAC_toggled()
|
||||
{
|
||||
bool disable = ui->cbRandomizeMAC->isChecked();
|
||||
ui->txtMAC->setDisabled(disable);
|
||||
}
|
||||
|
|
|
@ -117,13 +117,17 @@ public:
|
|||
currentDlg = nullptr;
|
||||
}
|
||||
|
||||
static bool needsReset;
|
||||
|
||||
private slots:
|
||||
void on_FirmwareSettingsDialog_accepted();
|
||||
void on_FirmwareSettingsDialog_rejected();
|
||||
void done(int r);
|
||||
|
||||
void on_cbxBirthdayMonth_currentIndexChanged(int idx);
|
||||
void on_cbRandomizeMAC_toggled();
|
||||
|
||||
private:
|
||||
bool verifyMAC();
|
||||
|
||||
Ui::FirmwareSettingsDialog* ui;
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>511</width>
|
||||
<height>196</height>
|
||||
<height>342</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -24,78 +24,134 @@
|
|||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cbxBirthdayDay"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="usernameLabel">
|
||||
<property name="text">
|
||||
<string>Username:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Message:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Birthday:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QComboBox" name="cbxBirthdayMonth"/>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="languageBox"/>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="usernameEdit">
|
||||
<property name="text">
|
||||
<string>melonDS</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="colorsEdit"/>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="messageEdit"/>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="overrideFirmwareBox">
|
||||
<property name="text">
|
||||
<string>Override settings from external firmware</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QGroupBox" name="grpGeneral">
|
||||
<property name="title">
|
||||
<string>General</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="overrideFirmwareBox">
|
||||
<property name="text">
|
||||
<string>Override settings from external firmware</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="grpUserSettings">
|
||||
<property name="title">
|
||||
<string>User settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cbxBirthdayDay"/>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QComboBox" name="cbxBirthdayMonth"/>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="usernameEdit">
|
||||
<property name="text">
|
||||
<string>melonDS</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="usernameLabel">
|
||||
<property name="text">
|
||||
<string>Username:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Message:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="colorsEdit"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Color:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Birthday:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="messageEdit"/>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="languageBox"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="grpWifiSettings">
|
||||
<property name="title">
|
||||
<string>Network settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>MAC address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="txtMAC">
|
||||
<property name="maxLength">
|
||||
<number>17</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="cbRandomizeMAC">
|
||||
<property name="text">
|
||||
<string>Randomize</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="dialogButtons">
|
||||
|
|
|
@ -201,6 +201,43 @@ std::string GetConfigString(ConfigEntry entry)
|
|||
return "";
|
||||
}
|
||||
|
||||
bool GetConfigArray(ConfigEntry entry, void* data)
|
||||
{
|
||||
switch (entry)
|
||||
{
|
||||
case Firm_MAC:
|
||||
{
|
||||
char* mac_in = Config::FirmwareMAC;
|
||||
u8* mac_out = (u8*)data;
|
||||
|
||||
int o = 0;
|
||||
u8 tmp = 0;
|
||||
for (int i = 0; i < 18; i++)
|
||||
{
|
||||
char c = mac_in[i];
|
||||
if (c == '\0') break;
|
||||
|
||||
int n;
|
||||
if (c >= '0' && c <= '9') n = c - '0';
|
||||
else if (c >= 'a' && c <= 'f') n = c - 'a' + 10;
|
||||
else if (c >= 'A' && c <= 'F') n = c - 'A' + 10;
|
||||
else continue;
|
||||
|
||||
if (!(o & 1))
|
||||
tmp = n;
|
||||
else
|
||||
mac_out[o >> 1] = n | (tmp << 4);
|
||||
|
||||
o++;
|
||||
if (o >= 12) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
FILE* OpenFile(std::string path, std::string mode, bool mustexist)
|
||||
{
|
||||
|
|
|
@ -56,7 +56,6 @@ WifiSettingsDialog::WifiSettingsDialog(QWidget* parent) : QDialog(parent), ui(ne
|
|||
ui->rbDirectMode->setText("Direct mode (requires " PCAP_NAME " and ethernet connection)");
|
||||
|
||||
ui->cbBindAnyAddr->setChecked(Config::SocketBindAnyAddr != 0);
|
||||
ui->cbRandomizeMAC->setChecked(Config::RandomizeMAC != 0);
|
||||
|
||||
int sel = 0;
|
||||
for (int i = 0; i < LAN_PCap::NumAdapters; i++)
|
||||
|
@ -88,19 +87,7 @@ void WifiSettingsDialog::done(int r)
|
|||
|
||||
if (r == QDialog::Accepted)
|
||||
{
|
||||
int randommac = ui->cbRandomizeMAC->isChecked() ? 1:0;
|
||||
|
||||
if (randommac != Config::RandomizeMAC)
|
||||
{
|
||||
if (RunningSomething
|
||||
&& QMessageBox::warning(this, "Reset necessary to apply changes",
|
||||
"The emulation will be reset for the changes to take place.",
|
||||
QMessageBox::Ok, QMessageBox::Cancel) != QMessageBox::Ok)
|
||||
return;
|
||||
}
|
||||
|
||||
Config::SocketBindAnyAddr = ui->cbBindAnyAddr->isChecked() ? 1:0;
|
||||
Config::RandomizeMAC = randommac;
|
||||
Config::DirectLAN = ui->rbDirectMode->isChecked() ? 1:0;
|
||||
|
||||
int sel = ui->cbxDirectAdapter->currentIndex();
|
||||
|
@ -116,8 +103,6 @@ void WifiSettingsDialog::done(int r)
|
|||
}
|
||||
|
||||
Config::Save();
|
||||
|
||||
needsReset = true;
|
||||
}
|
||||
|
||||
QDialog::done(r);
|
||||
|
@ -129,10 +114,12 @@ void WifiSettingsDialog::on_rbDirectMode_clicked()
|
|||
{
|
||||
updateAdapterControls();
|
||||
}
|
||||
|
||||
void WifiSettingsDialog::on_rbIndirectMode_clicked()
|
||||
{
|
||||
updateAdapterControls();
|
||||
}
|
||||
|
||||
void WifiSettingsDialog::on_cbxDirectAdapter_currentIndexChanged(int sel)
|
||||
{
|
||||
if (!haspcap) return;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>572</width>
|
||||
<height>296</height>
|
||||
<height>273</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -39,16 +39,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="cbRandomizeMAC">
|
||||
<property name="whatsThis">
|
||||
<string><html><head/><body><p>Randomizes the console's MAC address upon reset. Required for local multiplayer if each melonDS instance uses the same firmware file.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Randomize MAC address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -2451,11 +2451,19 @@ void MainWindow::onOpenAudioSettings()
|
|||
|
||||
void MainWindow::onOpenFirmwareSettings()
|
||||
{
|
||||
emuThread->emuPause();
|
||||
|
||||
FirmwareSettingsDialog* dlg = FirmwareSettingsDialog::openDlg(this);
|
||||
connect(dlg, &FirmwareSettingsDialog::finished, this, &MainWindow::onFirmwareSettingsFinished);
|
||||
}
|
||||
|
||||
void MainWindow::onFirmwareSettingsFinished(int res) {}
|
||||
void MainWindow::onFirmwareSettingsFinished(int res)
|
||||
{
|
||||
if (FirmwareSettingsDialog::needsReset)
|
||||
onReset();
|
||||
|
||||
emuThread->emuUnpause();
|
||||
}
|
||||
|
||||
void MainWindow::onUpdateAudioSettings()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue