diff --git a/src/core/netplay.cpp b/src/core/netplay.cpp
index 142651644..47ec093d6 100644
--- a/src/core/netplay.cpp
+++ b/src/core/netplay.cpp
@@ -2060,7 +2060,7 @@ void Netplay::SetInputs(Netplay::Input inputs[2])
}
}
-bool Netplay::CreateSession(std::string nickname, s32 port, s32 max_players, std::string password)
+bool Netplay::CreateSession(std::string nickname, s32 port, s32 max_players, std::string password, int inputdelay)
{
s_local_session_password = std::move(password);
@@ -2068,10 +2068,7 @@ bool Netplay::CreateSession(std::string nickname, s32 port, s32 max_players, std
// to have the same data, and we don't want to trash their local memcards. We should therefore load
// the memory cards for this game (based on game/global settings), and copy that to the temp card.
- // TODO: input delay. GGPO Should support changing it on the fly.
- const s32 input_delay = 1;
-
- if (!Netplay::Start(true, std::move(nickname), std::string(), port, input_delay))
+ if (!Netplay::Start(true, std::move(nickname), std::string(), port, inputdelay))
{
CloseSession();
return false;
@@ -2086,15 +2083,14 @@ bool Netplay::CreateSession(std::string nickname, s32 port, s32 max_players, std
}
bool Netplay::JoinSession(std::string nickname, const std::string& hostname, s32 port, std::string password,
- bool spectating)
+ bool spectating, int inputdelay)
{
s_local_session_password = std::move(password);
s_local_spectating = spectating;
-
- // TODO: input delay. GGPO Should support changing it on the fly.
- const s32 input_delay = 1;
-
- if (!Netplay::Start(false, std::move(nickname), hostname, port, input_delay))
+ Log_InfoPrint("____________");
+ Log_InfoPrintf("INPUT DELAY: %d", inputdelay);
+ Log_InfoPrint("____________");
+ if (!Netplay::Start(false, std::move(nickname), hostname, port, inputdelay))
{
CloseSession();
return false;
diff --git a/src/core/netplay.h b/src/core/netplay.h
index f72d79c86..6918b82ab 100644
--- a/src/core/netplay.h
+++ b/src/core/netplay.h
@@ -31,8 +31,8 @@ enum : u8
NUM_ENET_CHANNELS,
};
-bool CreateSession(std::string nickname, s32 port, s32 max_players, std::string password);
-bool JoinSession(std::string nickname, const std::string& hostname, s32 port, std::string password, bool spectating);
+bool CreateSession(std::string nickname, s32 port, s32 max_players, std::string password, int inputdelay);
+bool JoinSession(std::string nickname, const std::string& hostname, s32 port, std::string password, bool spectating, int inputdelay);
bool IsActive();
diff --git a/src/duckstation-qt/createnetplaysessiondialog.ui b/src/duckstation-qt/createnetplaysessiondialog.ui
index c6f8529e0..14a3ca781 100644
--- a/src/duckstation-qt/createnetplaysessiondialog.ui
+++ b/src/duckstation-qt/createnetplaysessiondialog.ui
@@ -10,7 +10,7 @@
0
0
496
- 235
+ 267
@@ -92,14 +92,14 @@
- -
+
-
Port:
- -
+
-
1
@@ -129,14 +129,14 @@
- -
+
-
Password:
- -
+
-
128
@@ -146,6 +146,16 @@
+ -
+
+
+ Input Delay:
+
+
+
+ -
+
+
-
diff --git a/src/duckstation-qt/joinnetplaysessiondialog.ui b/src/duckstation-qt/joinnetplaysessiondialog.ui
index 0a2e8d97e..8f50d0657 100644
--- a/src/duckstation-qt/joinnetplaysessiondialog.ui
+++ b/src/duckstation-qt/joinnetplaysessiondialog.ui
@@ -10,7 +10,7 @@
0
0
480
- 226
+ 254
@@ -92,14 +92,14 @@
- -
+
-
Port:
- -
+
-
1
@@ -112,28 +112,28 @@
- -
+
-
Hostname:
- -
+
-
localhost
- -
+
-
Password:
- -
+
-
128
@@ -143,6 +143,16 @@
+ -
+
+
+ Input Delay:
+
+
+
+ -
+
+
-
diff --git a/src/duckstation-qt/netplaydialogs.cpp b/src/duckstation-qt/netplaydialogs.cpp
index 8b767bc14..15942cd46 100644
--- a/src/duckstation-qt/netplaydialogs.cpp
+++ b/src/duckstation-qt/netplaydialogs.cpp
@@ -14,6 +14,7 @@ CreateNetplaySessionDialog::CreateNetplaySessionDialog(QWidget* parent) : QDialo
connect(m_ui.maxPlayers, &QSpinBox::valueChanged, this, &CreateNetplaySessionDialog::updateState);
connect(m_ui.port, &QSpinBox::valueChanged, this, &CreateNetplaySessionDialog::updateState);
+ connect(m_ui.inputDelay, &QSpinBox::valueChanged, this, &CreateNetplaySessionDialog::updateState);
connect(m_ui.nickname, &QLineEdit::textChanged, this, &CreateNetplaySessionDialog::updateState);
connect(m_ui.password, &QLineEdit::textChanged, this, &CreateNetplaySessionDialog::updateState);
@@ -34,19 +35,22 @@ void CreateNetplaySessionDialog::accept()
const int players = m_ui.maxPlayers->value();
const int port = m_ui.port->value();
+ const int inputdelay = m_ui.inputDelay->value();
const QString& nickname = m_ui.nickname->text();
const QString& password = m_ui.password->text();
QDialog::accept();
- g_emu_thread->createNetplaySession(nickname.trimmed(), port, players, password);
+ g_emu_thread->createNetplaySession(nickname.trimmed(), port, players, password, inputdelay);
}
bool CreateNetplaySessionDialog::validate()
{
const int players = m_ui.maxPlayers->value();
const int port = m_ui.port->value();
+ const int inputdelay = m_ui.inputDelay->value();
const QString& nickname = m_ui.nickname->text();
- return (!nickname.isEmpty() && players >= 2 && players <= Netplay::MAX_PLAYERS && port > 0 && port <= 65535);
+ return (!nickname.isEmpty() && players >= 2 && players <= Netplay::MAX_PLAYERS && port > 0 && port <= 65535 &&
+ inputdelay >= 0 && inputdelay <= 10);
}
void CreateNetplaySessionDialog::updateState()
@@ -59,6 +63,7 @@ JoinNetplaySessionDialog::JoinNetplaySessionDialog(QWidget* parent)
m_ui.setupUi(this);
connect(m_ui.port, &QSpinBox::valueChanged, this, &JoinNetplaySessionDialog::updateState);
+ connect(m_ui.inputDelay, &QSpinBox::valueChanged, this, &JoinNetplaySessionDialog::updateState);
connect(m_ui.nickname, &QLineEdit::textChanged, this, &JoinNetplaySessionDialog::updateState);
connect(m_ui.password, &QLineEdit::textChanged, this, &JoinNetplaySessionDialog::updateState);
connect(m_ui.hostname, &QLineEdit::textChanged, this, &JoinNetplaySessionDialog::updateState);
@@ -79,21 +84,23 @@ void JoinNetplaySessionDialog::accept()
return;
const int port = m_ui.port->value();
+ const int inputdelay = m_ui.inputDelay->value();
const QString& nickname = m_ui.nickname->text();
const QString& hostname = m_ui.hostname->text();
const QString& password = m_ui.password->text();
const bool spectating = m_ui.spectating->isChecked();
QDialog::accept();
- g_emu_thread->joinNetplaySession(nickname.trimmed(), hostname.trimmed(), port, password, spectating);
+ g_emu_thread->joinNetplaySession(nickname.trimmed(), hostname.trimmed(), port, password, spectating, inputdelay);
}
bool JoinNetplaySessionDialog::validate()
{
const int port = m_ui.port->value();
+ const int inputdelay = m_ui.inputDelay->value();
const QString& nickname = m_ui.nickname->text();
const QString& hostname = m_ui.hostname->text();
- return (!nickname.isEmpty() && !hostname.isEmpty() && port > 0 && port <= 65535);
+ return (!nickname.isEmpty() && !hostname.isEmpty() && port > 0 && port <= 65535 && inputdelay >= 0 && inputdelay <= 10);
}
void JoinNetplaySessionDialog::updateState()
diff --git a/src/duckstation-qt/qthost.cpp b/src/duckstation-qt/qthost.cpp
index c81861e1a..ed2f38ef0 100644
--- a/src/duckstation-qt/qthost.cpp
+++ b/src/duckstation-qt/qthost.cpp
@@ -1071,12 +1071,13 @@ void EmuThread::reloadPostProcessingShaders()
System::ReloadPostProcessingShaders();
}
-void EmuThread::createNetplaySession(const QString& nickname, qint32 port, qint32 max_players, const QString& password)
+void EmuThread::createNetplaySession(const QString& nickname, qint32 port, qint32 max_players, const QString& password, int inputdelay)
{
if (!isOnThread())
{
QMetaObject::invokeMethod(this, "createNetplaySession", Qt::QueuedConnection, Q_ARG(const QString&, nickname),
- Q_ARG(qint32, port), Q_ARG(qint32, max_players), Q_ARG(const QString&, password));
+ Q_ARG(qint32, port), Q_ARG(qint32, max_players), Q_ARG(const QString&, password),
+ Q_ARG(int, inputdelay));
return;
}
@@ -1084,7 +1085,7 @@ void EmuThread::createNetplaySession(const QString& nickname, qint32 port, qint3
if (!System::IsValid())
return;
- if (!Netplay::CreateSession(nickname.toStdString(), port, max_players, password.toStdString()))
+ if (!Netplay::CreateSession(nickname.toStdString(), port, max_players, password.toStdString(), inputdelay))
{
errorReported(tr("Netplay Error"), tr("Failed to create netplay session. The log may contain more information."));
return;
@@ -1092,17 +1093,18 @@ void EmuThread::createNetplaySession(const QString& nickname, qint32 port, qint3
}
void EmuThread::joinNetplaySession(const QString& nickname, const QString& hostname, qint32 port,
- const QString& password, bool spectating)
+ const QString& password, bool spectating, int inputdelay)
{
if (!isOnThread())
{
QMetaObject::invokeMethod(this, "joinNetplaySession", Qt::QueuedConnection, Q_ARG(const QString&, nickname),
Q_ARG(const QString&, hostname), Q_ARG(qint32, port), Q_ARG(const QString&, password),
- Q_ARG(bool, spectating));
+ Q_ARG(bool, spectating), Q_ARG(int, inputdelay));
return;
}
- if (!Netplay::JoinSession(nickname.toStdString(), hostname.toStdString(), port, password.toStdString(), spectating))
+ if (!Netplay::JoinSession(nickname.toStdString(), hostname.toStdString(), port, password.toStdString(), spectating,
+ inputdelay))
{
errorReported(tr("Netplay Error"), tr("Failed to join netplay session. The log may contain more information."));
return;
@@ -2243,11 +2245,11 @@ int main(int argc, char* argv[])
params->override_fast_boot = true;
params->fast_forward_to_first_frame = true;
g_emu_thread->bootSystem(std::move(params));
- g_emu_thread->createNetplaySession(nickname, port, 2, QString());
+ g_emu_thread->createNetplaySession(nickname, port, 2, QString(), 0);
}
else
{
- g_emu_thread->joinNetplaySession(nickname, remote, port, QString(), false);
+ g_emu_thread->joinNetplaySession(nickname, remote, port, QString(), false, 0);
}
});
}
diff --git a/src/duckstation-qt/qthost.h b/src/duckstation-qt/qthost.h
index cfebfe7ac..048756398 100644
--- a/src/duckstation-qt/qthost.h
+++ b/src/duckstation-qt/qthost.h
@@ -187,9 +187,10 @@ public Q_SLOTS:
void setCheatEnabled(quint32 index, bool enabled);
void applyCheat(quint32 index);
void reloadPostProcessingShaders();
- void createNetplaySession(const QString& nickname, qint32 port, qint32 max_players, const QString& password);
+ void createNetplaySession(const QString& nickname, qint32 port, qint32 max_players, const QString& password,
+ int inputdelay);
void joinNetplaySession(const QString& nickname, const QString& hostname, qint32 port, const QString& password,
- bool spectating);
+ bool spectating, int inputdelay);
private Q_SLOTS:
void stopInThread();