diff --git a/src/frontend/qt_sdl/Config.cpp b/src/frontend/qt_sdl/Config.cpp index 5997d54352..5181855013 100644 --- a/src/frontend/qt_sdl/Config.cpp +++ b/src/frontend/qt_sdl/Config.cpp @@ -309,6 +309,8 @@ LegacyEntry LegacyFile[] = {"GdbARM7BreakOnStartup", 1, "Gdb.ARM7.BreakOnStartup", true}, {"GdbARM9BreakOnStartup", 1, "Gdb.ARM9.BreakOnStartup", true}, #endif + {"PcapEnabled", 1, "Pcap.Enabled", false}, + {"PcapPath", 2, "Pcap.Path", false}, {"Camera0_InputType", 0, "DSi.Camera0.InputType", false}, {"Camera0_ImagePath", 2, "DSi.Camera0.ImagePath", false}, diff --git a/src/frontend/qt_sdl/EmuInstance.cpp b/src/frontend/qt_sdl/EmuInstance.cpp index 36ed322bcc..e086672da4 100644 --- a/src/frontend/qt_sdl/EmuInstance.cpp +++ b/src/frontend/qt_sdl/EmuInstance.cpp @@ -2056,13 +2056,16 @@ void EmuInstance::animatedROMIcon(const u8 (&data)[8][512], const u16 (&palette) void EmuInstance::startPacketCapture() { - if (!pcap) - pcap = melonDS::LibPCap::New(); - if (packetCapture != nullptr || packetCaptureDumper != nullptr) stopPacketCapture(); - std::string pcapPath = getAssetPath(false, globalCfg.GetString("PacketCapturePath"), instanceFileSuffix() + ".pcap"); + if (!globalCfg.GetBool("Pcap.Enabled")) + return; + + if (!pcap) + pcap = melonDS::LibPCap::New(); + + std::string pcapPath = getAssetPath(false, globalCfg.GetString("Pcap.Path"), instanceFileSuffix() + ".pcap"); Log(LogLevel::Debug, "Starting packet capture: %s\n", pcapPath.c_str()); packetCapture = pcap->open_dead(DLT_IEEE802_11, 1024); diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.cpp b/src/frontend/qt_sdl/EmuSettingsDialog.cpp index d612ac8358..c34402e67b 100644 --- a/src/frontend/qt_sdl/EmuSettingsDialog.cpp +++ b/src/frontend/qt_sdl/EmuSettingsDialog.cpp @@ -18,6 +18,7 @@ #include #include +#include #include "types.h" #include "Platform.h" @@ -107,9 +108,12 @@ EmuSettingsDialog::EmuSettingsDialog(QWidget* parent) : QDialog(parent), ui(new ui->cbGdbBOSA7->setDisabled(true); ui->cbGdbBOSA9->setDisabled(true); #endif + ui->cbPcapEnabled->setChecked(cfg.GetBool("Pcap.Enabled")); + ui->txtPcapPath->setText(cfg.GetQString("Pcap.Path")); on_chkEnableJIT_toggled(); on_cbGdbEnabled_toggled(); + on_cbPcapEnabled_toggled(); on_chkExternalBIOS_toggled(); const int imgsizes[] = {256, 512, 1024, 2048, 4096, 0}; @@ -292,6 +296,8 @@ void EmuSettingsDialog::done(int r) instcfg.SetBool("Gdb.ARM7.BreakOnStartup", ui->cbGdbBOSA7->isChecked()); instcfg.SetBool("Gdb.ARM9.BreakOnStartup", ui->cbGdbBOSA9->isChecked()); #endif + cfg.SetBool("Pcap.Enabled", ui->cbPcapEnabled->isChecked()); + cfg.SetQString("Pcap.Path", ui->txtPcapPath->text()); cfg.SetInt("Emu.ConsoleType", ui->cbxConsoleType->currentIndex()); cfg.SetBool("Emu.DirectBoot", ui->chkDirectBoot->isChecked()); @@ -565,6 +571,30 @@ void EmuSettingsDialog::on_cbGdbEnabled_toggled() ui->cbGdbBOSA9->setDisabled(disabled); } +void EmuSettingsDialog::on_cbPcapEnabled_toggled() +{ + bool disabled = !ui->cbPcapEnabled->isChecked(); + ui->txtPcapPath->setDisabled(disabled); + ui->btnPcapBrowse->setDisabled(disabled); +} + +void EmuSettingsDialog::on_btnPcapBrowse_clicked() +{ + QString dir = QFileDialog::getExistingDirectory(this, + "Select packet captures path...", + lastBIOSFolder); + + if (dir.isEmpty()) return; + + if (!QTemporaryFile(dir).open()) + { + QMessageBox::critical(this, "melonDS", "Unable to write to packet captures directory.\nPlease check file/folder write permissions."); + return; + } + + ui->txtPcapPath->setText(dir); +} + void EmuSettingsDialog::on_chkExternalBIOS_toggled() { bool disabled = !ui->chkExternalBIOS->isChecked(); diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.h b/src/frontend/qt_sdl/EmuSettingsDialog.h index 58a89b3a6b..314699289e 100644 --- a/src/frontend/qt_sdl/EmuSettingsDialog.h +++ b/src/frontend/qt_sdl/EmuSettingsDialog.h @@ -80,6 +80,8 @@ private slots: void on_chkExternalBIOS_toggled(); void on_cbGdbEnabled_toggled(); + void on_cbPcapEnabled_toggled(); + void on_btnPcapBrowse_clicked(); private: void verifyFirmware(); diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.ui b/src/frontend/qt_sdl/EmuSettingsDialog.ui index 2746e1da7f..546cbe7863 100644 --- a/src/frontend/qt_sdl/EmuSettingsDialog.ui +++ b/src/frontend/qt_sdl/EmuSettingsDialog.ui @@ -7,7 +7,7 @@ 0 0 575 - 416 + 456 @@ -21,7 +21,7 @@ - QLayout::SetFixedSize + QLayout::SizeConstraint::SetFixedSize @@ -59,7 +59,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -99,7 +99,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -457,7 +457,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -539,7 +539,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -573,17 +573,38 @@ Devtools - - + + - ARM9 port + ARM7 port - + + + + Break on startup + + + + + + + Packet captures are stored in .pcap format, by default in the same directory as the ROM. + + + + + + + Browse... + + + + - Qt::Vertical + Qt::Orientation::Vertical @@ -593,10 +614,10 @@ - - + + - ARM7 port + Break on startup @@ -607,28 +628,14 @@ - + Note: melonDS must be restarted in order for these changes to have effect - - - - Note: GDB stub cannot be used together with the JIT recompiler - - - - - - - Break on startup - - - - + 1000 @@ -641,7 +648,21 @@ - + + + + ARM9 port + + + + + + + + + + + 1000 @@ -654,10 +675,27 @@ - - + + - Break on startup + Note: GDB stub cannot be used together with the JIT recompiler + + + + + + + + + + Directory: + + + + + + + Enable network packet capture @@ -668,10 +706,10 @@ - Qt::Horizontal + Qt::Orientation::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok