Add settings for arcade I/O server.

This commit is contained in:
Jean-Philip Desjardins 2024-02-12 17:27:10 -05:00
parent c868bd5212
commit 8aa75113c6
6 changed files with 56 additions and 12 deletions

View file

@ -95,6 +95,9 @@ CPS2VM::CPS2VM()
CAppConfig::GetInstance().RegisterPreferenceInteger(PREF_AUDIO_SPUBLOCKCOUNT, 100);
ReloadSpuBlockCountImpl();
CAppConfig::GetInstance().RegisterPreferenceBoolean(PREF_PS2_ARCADE_IO_SERVER_ENABLED, false);
CAppConfig::GetInstance().RegisterPreferenceInteger(PREF_PS2_ARCADE_IO_SERVER_PORT, 9876);
}
//////////////////////////////////////////////////

View file

@ -9,6 +9,9 @@
#define PREF_PS2_HDD_DIRECTORY ("ps2.hdd.directory")
#define PREF_PS2_ARCADEROMS_DIRECTORY ("ps2.arcaderoms.directory")
#define PREF_PS2_ARCADE_IO_SERVER_ENABLED ("ps2.arcade.ioserver.enabled")
#define PREF_PS2_ARCADE_IO_SERVER_PORT ("ps2.arcade.ioserver.port")
#define PREF_PS2_LIMIT_FRAMERATE ("ps2.limitframerate")
#define PREF_AUDIO_SPUBLOCKCOUNT ("audio.spublockcount")

View file

@ -4,6 +4,7 @@
#include "StdStreamUtils.h"
#include "PathUtils.h"
#include "AppConfig.h"
#include "PS2VM_Preferences.h"
using namespace Iop;
using namespace Iop::Namco;
@ -59,7 +60,11 @@ CSys147::CSys147(CSifMan& sifMan, const std::string& gameId)
m_switchStates[SWITCH_2P_LEFT] = 0;
m_switchStates[SWITCH_2P_RIGHT] = 0;
m_ioServer = std::make_unique<Framework::CHttpServer>(9876, std::bind(&CSys147::HandleIoServerRequest, this, std::placeholders::_1));
if(CAppConfig::GetInstance().GetPreferenceBoolean(PREF_PS2_ARCADE_IO_SERVER_ENABLED))
{
uint16 port = CAppConfig::GetInstance().GetPreferenceInteger(PREF_PS2_ARCADE_IO_SERVER_PORT);
m_ioServer = std::make_unique<Framework::CHttpServer>(port, std::bind(&CSys147::HandleIoServerRequest, this, std::placeholders::_1));
}
}
std::string CSys147::GetId() const

View file

@ -113,7 +113,7 @@
<enum>QFrame::StyledPanel</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="General">
<layout class="QVBoxLayout" name="verticalLayout1">
@ -188,6 +188,20 @@
</item>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_limitFrameRate">
<property name="text">
<string>Cap Frame Rate to Video Refresh Rate</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_showEECPUUsage">
<property name="text">
<string>Show EE CPU Usage</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<property name="text">
@ -214,19 +228,22 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_limitFrameRate">
<widget class="QCheckBox" name="checkBox_enableArcadeIOServer">
<property name="text">
<string>Cap Frame Rate to Video Refresh Rate</string>
<string>Enable Arcade I/O HTTP Server</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_showEECPUUsage">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Show EE CPU Usage</string>
<string>Arcade I/O HTTP Server Port:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_arcadeIOServerPort"/>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">

View file

@ -23,6 +23,8 @@ SettingsDialog::SettingsDialog(QWidget* parent)
//Not needed, as it can be set in the ui editor, but left for ease of ui edit.
ui->stackedWidget->setCurrentIndex(0);
ui->lineEdit_arcadeIOServerPort->setValidator(new QIntValidator(0, 65535, this));
// this assert is to ensure no one adds an item to the combobox through qt creator by accident
assert(ui->comboBox_gs_selection->count() == 0);
assert(ui->comboBox_vulkan_device->count() == 0);
@ -81,9 +83,11 @@ void SettingsDialog::changePage(QListWidgetItem* current, QListWidgetItem* previ
void SettingsDialog::LoadPreferences()
{
ui->comboBox_system_language->setCurrentIndex(CAppConfig::GetInstance().GetPreferenceInteger(PREF_SYSTEM_LANGUAGE));
ui->edit_arcadeRoms_dir->setText(PathToQString(CAppConfig::GetInstance().GetPreferencePath(PREF_PS2_ARCADEROMS_DIRECTORY)));
ui->checkBox_limitFrameRate->setChecked(CAppConfig::GetInstance().GetPreferenceBoolean(PREF_PS2_LIMIT_FRAMERATE));
ui->checkBox_showEECPUUsage->setChecked(CAppConfig::GetInstance().GetPreferenceBoolean(PREF_UI_SHOWEECPUUSAGE));
ui->edit_arcadeRoms_dir->setText(PathToQString(CAppConfig::GetInstance().GetPreferencePath(PREF_PS2_ARCADEROMS_DIRECTORY)));
ui->checkBox_enableArcadeIOServer->setChecked(CAppConfig::GetInstance().GetPreferenceBoolean(PREF_PS2_ARCADE_IO_SERVER_ENABLED));
ui->lineEdit_arcadeIOServerPort->setText(QString::number(CAppConfig::GetInstance().GetPreferenceInteger(PREF_PS2_ARCADE_IO_SERVER_PORT)));
int factor = CAppConfig::GetInstance().GetPreferenceInteger(PREF_CGSH_OPENGL_RESOLUTION_FACTOR);
int factor_index = std::log2(factor);
@ -105,6 +109,16 @@ void SettingsDialog::on_comboBox_system_language_currentIndexChanged(int index)
CAppConfig::GetInstance().SetPreferenceInteger(PREF_SYSTEM_LANGUAGE, index);
}
void SettingsDialog::on_checkBox_limitFrameRate_clicked(bool checked)
{
CAppConfig::GetInstance().SetPreferenceBoolean(PREF_PS2_LIMIT_FRAMERATE, checked);
}
void SettingsDialog::on_checkBox_showEECPUUsage_clicked(bool checked)
{
CAppConfig::GetInstance().SetPreferenceBoolean(PREF_UI_SHOWEECPUUSAGE, checked);
}
void SettingsDialog::on_button_browseArcadeRomsDir_clicked()
{
auto prevDir = PathToQString(CAppConfig::GetInstance().GetPreferencePath(PREF_PS2_ARCADEROMS_DIRECTORY));
@ -118,14 +132,14 @@ void SettingsDialog::on_button_browseArcadeRomsDir_clicked()
ui->edit_arcadeRoms_dir->setText(newDir);
}
void SettingsDialog::on_checkBox_limitFrameRate_clicked(bool checked)
void SettingsDialog::on_checkBox_enableArcadeIOServer_clicked(bool checked)
{
CAppConfig::GetInstance().SetPreferenceBoolean(PREF_PS2_LIMIT_FRAMERATE, checked);
CAppConfig::GetInstance().SetPreferenceBoolean(PREF_PS2_ARCADE_IO_SERVER_ENABLED, checked);
}
void SettingsDialog::on_checkBox_showEECPUUsage_clicked(bool checked)
void SettingsDialog::on_lineEdit_arcadeIOServerPort_textChanged(const QString& value)
{
CAppConfig::GetInstance().SetPreferenceBoolean(PREF_UI_SHOWEECPUUSAGE, checked);
CAppConfig::GetInstance().SetPreferenceInteger(PREF_PS2_ARCADE_IO_SERVER_PORT, value.toInt());
}
//Video Page ---------------------------------

View file

@ -33,9 +33,11 @@ private slots:
//General Page
void on_comboBox_system_language_currentIndexChanged(int index);
void on_button_browseArcadeRomsDir_clicked();
void on_checkBox_limitFrameRate_clicked(bool checked);
void on_checkBox_showEECPUUsage_clicked(bool checked);
void on_button_browseArcadeRomsDir_clicked();
void on_checkBox_enableArcadeIOServer_clicked(bool checked);
void on_lineEdit_arcadeIOServerPort_textChanged(const QString& value);
//Video Page
void on_checkBox_widescreenOutput_clicked(bool checked);