diff --git a/src/H8300.cpp b/src/H8300.cpp index 24e19d53..37beb2f3 100644 --- a/src/H8300.cpp +++ b/src/H8300.cpp @@ -100,7 +100,7 @@ int H8300::configureSerialPort(){ memset(buf, 0, sizeof(buf)); //This should be configures in options - const char *portname = "/dev/ttyUSB0"; + const char *portname = "/dev/ttyUSB1"; //sudo chmod 666 /dev/ttyUSB0 fd = open(portname, O_RDWR | O_NOCTTY | O_NDELAY); diff --git a/src/frontend/qt_sdl/.IRSettings.cpp.swp b/src/frontend/qt_sdl/.IRSettings.cpp.swp new file mode 100644 index 00000000..0d13976a Binary files /dev/null and b/src/frontend/qt_sdl/.IRSettings.cpp.swp differ diff --git a/src/frontend/qt_sdl/.IRSettings.h.swp b/src/frontend/qt_sdl/.IRSettings.h.swp new file mode 100644 index 00000000..f99474f1 Binary files /dev/null and b/src/frontend/qt_sdl/.IRSettings.h.swp differ diff --git a/src/frontend/qt_sdl/CMakeLists.txt b/src/frontend/qt_sdl/CMakeLists.txt index b0b6e5ab..c8f163dc 100644 --- a/src/frontend/qt_sdl/CMakeLists.txt +++ b/src/frontend/qt_sdl/CMakeLists.txt @@ -27,6 +27,7 @@ set(SOURCES_QT_SDL PathSettingsDialog.cpp MPSettingsDialog.cpp WifiSettingsDialog.cpp + IRSettingsDialog.cpp InterfaceSettingsDialog.cpp ROMInfoDialog.cpp RAMInfoDialog.cpp @@ -57,6 +58,7 @@ set(SOURCES_QT_SDL LANDialog.cpp NetplayDialog.cpp + ) option(USE_QT6 "Use Qt 6 instead of Qt 5" ON) diff --git a/src/frontend/qt_sdl/IRSettingsDialog.cpp b/src/frontend/qt_sdl/IRSettingsDialog.cpp new file mode 100644 index 00000000..87a4b0cf --- /dev/null +++ b/src/frontend/qt_sdl/IRSettingsDialog.cpp @@ -0,0 +1,124 @@ +/* + Copyright 2016-2024 melonDS team + + This file is part of melonDS. + + melonDS is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + melonDS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with melonDS. If not, see http://www.gnu.org/licenses/. + + @BarretKlics +*/ + +#include +#include + +#include "types.h" +#include "Platform.h" +#include "Config.h" +#include "main.h" + +#include "IRSettingsDialog.h" +#include "ui_IRSettingsDialog.h" + + +IRSettingsDialog* IRSettingsDialog::currentDlg = nullptr; + +bool IRSettingsDialog::needsReset = false; + +void NetInit(); + +IRSettingsDialog::IRSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::IRSettingsDialog) +{ + + + ui->setupUi(this); + setAttribute(Qt::WA_DeleteOnClose); + + emuInstance = ((MainWindow*)parent)->getEmuInstance(); + auto& cfg = emuInstance->getGlobalConfig(); + + + + + //ui->groupBoxSerial->setEnabled(false); + ui->groupBoxUDP->setEnabled(false); + + // connect(ui->rbSerialMode, &QRadioButton::toggled, this, &IRSettingsDialog::toggleSerialSettings); + connect(ui->rbUDPMode, &QRadioButton::toggled, this, &IRSettingsDialog::toggleUDPSettings); + + + +} + + +void IRSettingsDialog::toggleSerialSettings(bool checked) +{ + // ui->groupBoxSerial->setEnabled(checked); + +} +void IRSettingsDialog::toggleUDPSettings(bool checked){ + + ui->groupBoxUDP->setEnabled(checked); +} + + + + +IRSettingsDialog::~IRSettingsDialog() +{ + delete ui; +} + +void IRSettingsDialog::done(int r) +{ + if (!((MainWindow*)parent())->getEmuInstance()) + { + QDialog::done(r); + closeDlg(); + return; + } + + needsReset = false; + + if (r == QDialog::Accepted) + { + /* + auto& cfg = emuInstance->getGlobalConfig(); + + cfg.SetBool("LAN.IPMode", ui->rbIPMode->isChecked()); + + int sel = ui->cbxIPAdapter->currentIndex(); + if (sel < 0 || sel >= adapters.size()) sel = 0; + if (adapters.empty()) + { + //cfg.SetString("LAN.Device", ""); + } + else + { + //cfg.SetString("LAN.Device", adapters[sel].DeviceName); + } + */ + Config::Save(); + } + + //Config::Table cfg = Config::GetGlobalTable(); + //std::string devicename = cfg.GetString("LAN.Device"); + + //NetInit(); + + QDialog::done(r); + + closeDlg(); +} + + + diff --git a/src/frontend/qt_sdl/IRSettingsDialog.h b/src/frontend/qt_sdl/IRSettingsDialog.h new file mode 100644 index 00000000..40a0588f --- /dev/null +++ b/src/frontend/qt_sdl/IRSettingsDialog.h @@ -0,0 +1,74 @@ +/* + Copyright 2016-2024 melonDS team + + This file is part of melonDS. + + melonDS is free software: you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your option) + any later version. + + melonDS is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with melonDS. If not, see http://www.gnu.org/licenses/. + + + @BarretKlics +*/ + +#ifndef IRSETTINGSDIALOG_H +#define IRSETTINGSDIALOG_H + +#include +#include + +namespace Ui { class IRSettingsDialog; } +class IRSettingsDialog; + +class EmuInstance; + +class IRSettingsDialog : public QDialog +{ + Q_OBJECT + +public: + explicit IRSettingsDialog(QWidget* parent); + ~IRSettingsDialog(); + + static IRSettingsDialog* currentDlg; + static IRSettingsDialog* openDlg(QWidget* parent) + { + if (currentDlg) + { + currentDlg->activateWindow(); + return currentDlg; + } + + currentDlg = new IRSettingsDialog(parent); + currentDlg->open(); + return currentDlg; + } + static void closeDlg() + { + currentDlg = nullptr; + } + + static bool needsReset; + +private slots: + void done(int r); + void toggleSerialSettings(bool checked); + void toggleUDPSettings(bool checked); + +private: + Ui::IRSettingsDialog* ui; + EmuInstance* emuInstance; + + // void updateAdapterControls(); + // std::vector adapters; +}; + +#endif // IRSETTINGSDIALOG_H diff --git a/src/frontend/qt_sdl/IRSettingsDialog.ui b/src/frontend/qt_sdl/IRSettingsDialog.ui new file mode 100644 index 00000000..23f549f0 --- /dev/null +++ b/src/frontend/qt_sdl/IRSettingsDialog.ui @@ -0,0 +1,258 @@ + + + IRSettingsDialog + + + + 0 + 0 + 570 + 516 + + + + + 0 + 0 + + + + IR settings - melonDS + + + + QLayout::SetFixedSize + + + + + QLabel { + margin-bottom: 12px; +} + + + <html><head/><body><p>These settings control how melonDS emulates the H8/300 processor in games that support IR peripherals.</p><p>The settings you select here should be based off what peripheral you are using, and if you are emulating it and if so, what features that emulator supports.</p></body></html> + + + true + + + 0 + + + + + + + IR Mode + + + + + + <html><head/><body><p>Serial mode should be used if you have a physical IrDa adapter connected to this machine.</p></body></html> + + + Serial + + + + + + + <html><head/><body><p>IP Mode bypasses the serial connection entirely. This is designed to increase stability for use with other IR peripheral emulators that support this feature.</p></body></html> + + + UDP + + + + + + + + + + UDP Mode Settings + + + + + + [PLACEHOLDER] + + + + + + + + 0 + 0 + + + + + 300 + 0 + + + + <html><head/><body><p>Selects the network adapter through which to route network traffic under direct mode.</p></body></html> + + + Qt::LeftToRight + + + false + + + + + + + IP address: + + + + + + + Port: + + + + + + + + Running: + + + + + + + [PLACEHOLDER] + + + + + + + + UDP Mode Settings + + + + + + [PLACEHOLDER] + + + + + + + + 0 + 0 + + + + + 300 + 0 + + + + <html><head/><body><p>Selects the network adapter through which to route network traffic under direct mode.</p></body></html> + + + Qt::LeftToRight + + + false + + + + + + + IP address: + + + + + + + Port: + + + + + + + + Running: + + + + + + + [PLACEHOLDER] + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + IRSettingsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + IRSettingsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/frontend/qt_sdl/WifiSettingsDialog.cpp b/src/frontend/qt_sdl/WifiSettingsDialog.cpp index e041234b..35eba50c 100644 --- a/src/frontend/qt_sdl/WifiSettingsDialog.cpp +++ b/src/frontend/qt_sdl/WifiSettingsDialog.cpp @@ -48,6 +48,8 @@ void NetInit(); WifiSettingsDialog::WifiSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::WifiSettingsDialog) { + + printf("Hi I am wifi settings"); ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index a156a993..f05af090 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -63,6 +63,7 @@ #include "PathSettingsDialog.h" #include "MPSettingsDialog.h" #include "WifiSettingsDialog.h" +#include "IRSettingsDialog.h" #include "InterfaceSettingsDialog.h" #include "ROMInfoDialog.h" #include "RAMInfoDialog.h" @@ -634,6 +635,9 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) : actWifiSettings = menu->addAction("Wifi settings"); connect(actWifiSettings, &QAction::triggered, this, &MainWindow::onOpenWifiSettings); + actIRSettings = menu->addAction("IR settings"); + connect(actIRSettings, &QAction::triggered, this, &MainWindow::onOpenIRSettings); + actFirmwareSettings = menu->addAction("Firmware settings"); connect(actFirmwareSettings, &QAction::triggered, this, &MainWindow::onOpenFirmwareSettings); @@ -778,6 +782,7 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) : actVideoSettings->setEnabled(false); actMPSettings->setEnabled(false); actWifiSettings->setEnabled(false); + actIRSettings->setEnabled(false); actInterfaceSettings->setEnabled(false); #ifdef __APPLE__ @@ -1986,6 +1991,22 @@ void MainWindow::onWifiSettingsFinished(int res) emuThread->emuUnpause(); } +void MainWindow::onOpenIRSettings() +{ + emuThread->emuPause(); + + IRSettingsDialog* dlg = IRSettingsDialog::openDlg(this); + connect(dlg, &IRSettingsDialog::finished, this, &MainWindow::onIRSettingsFinished); +} + +void MainWindow::onIRSettingsFinished(int res) +{ + if (IRSettingsDialog::needsReset) + onReset(); + + emuThread->emuUnpause(); +} + void MainWindow::onOpenInterfaceSettings() { emuThread->emuPause(); diff --git a/src/frontend/qt_sdl/Window.h b/src/frontend/qt_sdl/Window.h index 9f652f54..377b0e0c 100644 --- a/src/frontend/qt_sdl/Window.h +++ b/src/frontend/qt_sdl/Window.h @@ -206,6 +206,8 @@ private slots: void onMPSettingsFinished(int res); void onOpenWifiSettings(); void onWifiSettingsFinished(int res); + void onOpenIRSettings(); + void onIRSettingsFinished(int res); void onOpenFirmwareSettings(); void onFirmwareSettingsFinished(int res); void onOpenPathSettings(); @@ -326,6 +328,7 @@ public: QAction* actAudioSettings; QAction* actMPSettings; QAction* actWifiSettings; + QAction* actIRSettings; QAction* actFirmwareSettings; QAction* actPathSettings; QAction* actInterfaceSettings;