Merge pull request #7564 from Techjar/netplay-sync-wii-shutdown
NetPlay: Sync power button event
This commit is contained in:
commit
41333fa971
|
@ -569,6 +569,12 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_POWER_BUTTON:
|
||||
{
|
||||
m_dialog->OnMsgPowerButton();
|
||||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_PING:
|
||||
{
|
||||
u32 ping_key = 0;
|
||||
|
@ -1702,6 +1708,13 @@ void NetPlayClient::RequestStopGame()
|
|||
SendStopGamePacket();
|
||||
}
|
||||
|
||||
void NetPlayClient::SendPowerButtonEvent()
|
||||
{
|
||||
sf::Packet packet;
|
||||
packet << static_cast<MessageId>(NP_MSG_POWER_BUTTON);
|
||||
SendAsync(std::move(packet));
|
||||
}
|
||||
|
||||
// called from ---GUI--- thread
|
||||
bool NetPlayClient::LocalPlayerHasControllerMapped() const
|
||||
{
|
||||
|
@ -1884,6 +1897,12 @@ void SetSIPollBatching(bool state)
|
|||
s_si_poll_batching = state;
|
||||
}
|
||||
|
||||
void SendPowerButtonEvent()
|
||||
{
|
||||
ASSERT(IsNetPlayRunning());
|
||||
netplay_client->SendPowerButtonEvent();
|
||||
}
|
||||
|
||||
void NetPlay_Enable(NetPlayClient* const np)
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
virtual void OnMsgChangeGame(const std::string& filename) = 0;
|
||||
virtual void OnMsgStartGame() = 0;
|
||||
virtual void OnMsgStopGame() = 0;
|
||||
virtual void OnMsgPowerButton() = 0;
|
||||
virtual void OnPadBufferChanged(u32 buffer) = 0;
|
||||
virtual void OnHostInputAuthorityChanged(bool enabled) = 0;
|
||||
virtual void OnDesync(u32 frame, const std::string& player) = 0;
|
||||
|
@ -102,6 +103,7 @@ public:
|
|||
bool ChangeGame(const std::string& game);
|
||||
void SendChatMessage(const std::string& msg);
|
||||
void RequestStopGame();
|
||||
void SendPowerButtonEvent();
|
||||
|
||||
// Send and receive pads values
|
||||
bool WiimoteUpdate(int _number, u8* data, const u8 size, u8 reporting_mode);
|
||||
|
|
|
@ -125,6 +125,7 @@ enum
|
|||
NP_MSG_GAME_STATUS = 0xA4,
|
||||
NP_MSG_IPL_STATUS = 0xA5,
|
||||
NP_MSG_HOST_INPUT_AUTHORITY = 0xA6,
|
||||
NP_MSG_POWER_BUTTON = 0xA7,
|
||||
|
||||
NP_MSG_TIMEBASE = 0xB0,
|
||||
NP_MSG_DESYNC_DETECTED = 0xB1,
|
||||
|
@ -181,4 +182,5 @@ IOS::HLE::FS::FileSystem* GetWiiSyncFS();
|
|||
void SetWiiSyncFS(std::unique_ptr<IOS::HLE::FS::FileSystem> fs);
|
||||
void ClearWiiSyncFS();
|
||||
void SetSIPollBatching(bool state);
|
||||
void SendPowerButtonEvent();
|
||||
} // namespace NetPlay
|
||||
|
|
|
@ -743,6 +743,14 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_POWER_BUTTON:
|
||||
{
|
||||
sf::Packet spac;
|
||||
spac << static_cast<MessageId>(NP_MSG_POWER_BUTTON);
|
||||
SendToClients(spac, player.pid);
|
||||
}
|
||||
break;
|
||||
|
||||
case NP_MSG_TIMEBASE:
|
||||
{
|
||||
u64 timebase = Common::PacketReadU64(packet);
|
||||
|
|
|
@ -744,6 +744,10 @@ bool MainWindow::RequestStop()
|
|||
if (Core::GetState() == Core::State::Paused)
|
||||
Core::SetState(Core::State::Running);
|
||||
|
||||
// Tell NetPlay about the power event
|
||||
if (NetPlay::IsNetPlayRunning())
|
||||
NetPlay::SendPowerButtonEvent();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
|
||||
#include "UICommon/DiscordPresence.h"
|
||||
#include "UICommon/GameFile.h"
|
||||
#include "UICommon/UICommon.h"
|
||||
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
|
@ -797,6 +798,13 @@ void NetPlayDialog::OnMsgStopGame()
|
|||
QueueOnObject(this, [this] { UpdateDiscordPresence(); });
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnMsgPowerButton()
|
||||
{
|
||||
if (!Core::IsRunning())
|
||||
return;
|
||||
QueueOnObject(this, [] { UICommon::TriggerSTMPowerEvent(); });
|
||||
}
|
||||
|
||||
void NetPlayDialog::OnPadBufferChanged(u32 buffer)
|
||||
{
|
||||
QueueOnObject(this, [this, buffer] {
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
void OnMsgChangeGame(const std::string& filename) override;
|
||||
void OnMsgStartGame() override;
|
||||
void OnMsgStopGame() override;
|
||||
void OnMsgPowerButton() override;
|
||||
void OnPadBufferChanged(u32 buffer) override;
|
||||
void OnHostInputAuthorityChanged(bool enabled) override;
|
||||
void OnDesync(u32 frame, const std::string& player) override;
|
||||
|
|
Loading…
Reference in New Issue