From 9c7b95d6ba73c1a5c07b7e3ae970450c16daa76c Mon Sep 17 00:00:00 2001 From: BarretLaptop Date: Fri, 24 Jan 2025 10:47:14 -0700 Subject: [PATCH] Initial IR settings UI setup --- src/H8300.cpp | 2 +- src/frontend/qt_sdl/.IRSettings.cpp.swp | Bin 0 -> 20480 bytes src/frontend/qt_sdl/.IRSettings.h.swp | Bin 0 -> 12288 bytes src/frontend/qt_sdl/CMakeLists.txt | 2 + src/frontend/qt_sdl/IRSettingsDialog.cpp | 124 ++++++++++ src/frontend/qt_sdl/IRSettingsDialog.h | 74 ++++++ src/frontend/qt_sdl/IRSettingsDialog.ui | 258 +++++++++++++++++++++ src/frontend/qt_sdl/WifiSettingsDialog.cpp | 2 + src/frontend/qt_sdl/Window.cpp | 21 ++ src/frontend/qt_sdl/Window.h | 3 + 10 files changed, 485 insertions(+), 1 deletion(-) create mode 100644 src/frontend/qt_sdl/.IRSettings.cpp.swp create mode 100644 src/frontend/qt_sdl/.IRSettings.h.swp create mode 100644 src/frontend/qt_sdl/IRSettingsDialog.cpp create mode 100644 src/frontend/qt_sdl/IRSettingsDialog.h create mode 100644 src/frontend/qt_sdl/IRSettingsDialog.ui 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 0000000000000000000000000000000000000000..0d13976aa593cee4cd7d2e80e823eca247a2c139 GIT binary patch literal 20480 zcmeI2YmgjO6@WVdA3;!*hkyb%8%fP3J2RV2NZ};eIN9BV!R%(U50((a*fV`+rlF^M znC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GhRa|JsQv#zSPjR+aiGC#tm~hL$Kf%!3vPsO z!#+3fs>!Buc2TnGmALmK|f-u|m_ z2keFOVH{S#$#66*g`cvge=pnvH^O!BO(;SyB;aH?36{bV_#3wIS5RjF9)btqMz{gg z82|%(`w4BQ^J{Tyj*kFj;v)cu^Q7?+fVPtu(JT?YPsB$6g5yK}u3+?P7#{%$&iuqj z0OBJ6!JEEv7x58*aw0wgpsXN10uUboSa6geJ_7JRc?6(tmMfkZ=wGuwInY0_E;=N@ Jp$5IG{R=Qkdl~=$ literal 0 HcmV?d00001 diff --git a/src/frontend/qt_sdl/.IRSettings.h.swp b/src/frontend/qt_sdl/.IRSettings.h.swp new file mode 100644 index 0000000000000000000000000000000000000000..f99474f1de114b37a9ad9ff4752335f13cda588e GIT binary patch literal 12288 zcmeI2zi%8x6vxL1@jD~}0TMy*z>Q=1ZXG9rPuSf`W<$B&Y}#h)~c$0R1hF<{bzg|Njqu z|NoBv|Gx%bfe*m@pamWUU*5~uN8m#sz)|qoA;vxhJK$+B59R=Y$G{`tD7X#$dJkj2 zfN#M~@Hu!Jyb4|cF)&~STmWal95@MX1wY@-*iYaS@EUjtbbtp=gNMNpa2R}Z7h^ZT zJK!zwBDfBo1J8m@a0bkQ0(b~K2!6Yhu`j?I;C1ja5a1%X08W9Yzysh%X!kw%4kS9h z2kd1PunJfOtO8a6tH3`|VEo@+d>jV`ML_w@aR{ddm+JM(>bb4+j9r^$gi9O0RO)fh zsAw)dbhub6mC8QOEb?g4HSRpQ*@MpPdrJ5ecYW9J+-dycj1krKw1tUtMUsvc>%gAq{CBBB&&$LD#4WqqOfOBkwIFh@3WghnWFU+ehmxE0Awk2cpeo`O#snTo?Cc17SD>6(6 zO!^E5O`b*!oHP%UE6lr|NvCo{NMH4Lhmj?k*rQk{hJCUu_sFn6z)4DSN+h|wA^a9M zlazNXPI<6Tz6fMQ$x@W{e>Cki;WBEg|W|RE?egFyWZqO z&%?^+fslN-N7S%MjEewED%ksyO*&aUV0DNCY<4gjpZ#srs~%IU?*KvXuq0yjG<$t(U9y%0gqMT&49!b$zY2RHPb$ z`5Qlhim0O^PChrT2z3_UM!8xouhutb(=1hNi1)ZmeTfb#29fq5hAT}P>!qdY!g<)2 z&sJ6{^-Y4$&+h#;P9%;-@7IaMo22pWZRo}Ff zI)SmbRUBcpC7rT`ndpWgI(pD!)MV(a)^!_cp-_^(%Ms`Mvk&l&bRK3Y8IwF$V)lo! zBqF#t2%k<1>Tf%FfpmD3*`3W`LlZD?lt_>+a1>6w!Q M3uNSWm@~=#0Jl}E5&!@I literal 0 HcmV?d00001 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;