mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
NetPlay: Sync power button event
This fixes the deadlock on shutdown when Wii Remotes are in use.
This commit is contained in:
@ -568,6 +568,12 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case NP_MSG_POWER_BUTTON:
|
||||||
|
{
|
||||||
|
m_dialog->OnMsgPowerButton();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case NP_MSG_PING:
|
case NP_MSG_PING:
|
||||||
{
|
{
|
||||||
u32 ping_key = 0;
|
u32 ping_key = 0;
|
||||||
@ -1701,6 +1707,13 @@ void NetPlayClient::RequestStopGame()
|
|||||||
SendStopGamePacket();
|
SendStopGamePacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetPlayClient::SendPowerButtonEvent()
|
||||||
|
{
|
||||||
|
sf::Packet packet;
|
||||||
|
packet << static_cast<MessageId>(NP_MSG_POWER_BUTTON);
|
||||||
|
SendAsync(std::move(packet));
|
||||||
|
}
|
||||||
|
|
||||||
// called from ---GUI--- thread
|
// called from ---GUI--- thread
|
||||||
bool NetPlayClient::LocalPlayerHasControllerMapped() const
|
bool NetPlayClient::LocalPlayerHasControllerMapped() const
|
||||||
{
|
{
|
||||||
@ -1883,6 +1896,12 @@ void SetSIPollBatching(bool state)
|
|||||||
s_si_poll_batching = state;
|
s_si_poll_batching = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SendPowerButtonEvent()
|
||||||
|
{
|
||||||
|
ASSERT(IsNetPlayRunning());
|
||||||
|
netplay_client->SendPowerButtonEvent();
|
||||||
|
}
|
||||||
|
|
||||||
void NetPlay_Enable(NetPlayClient* const np)
|
void NetPlay_Enable(NetPlayClient* const np)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
std::lock_guard<std::mutex> lk(crit_netplay_client);
|
||||||
|
@ -43,6 +43,7 @@ public:
|
|||||||
virtual void OnMsgChangeGame(const std::string& filename) = 0;
|
virtual void OnMsgChangeGame(const std::string& filename) = 0;
|
||||||
virtual void OnMsgStartGame() = 0;
|
virtual void OnMsgStartGame() = 0;
|
||||||
virtual void OnMsgStopGame() = 0;
|
virtual void OnMsgStopGame() = 0;
|
||||||
|
virtual void OnMsgPowerButton() = 0;
|
||||||
virtual void OnPadBufferChanged(u32 buffer) = 0;
|
virtual void OnPadBufferChanged(u32 buffer) = 0;
|
||||||
virtual void OnHostInputAuthorityChanged(bool enabled) = 0;
|
virtual void OnHostInputAuthorityChanged(bool enabled) = 0;
|
||||||
virtual void OnDesync(u32 frame, const std::string& player) = 0;
|
virtual void OnDesync(u32 frame, const std::string& player) = 0;
|
||||||
@ -102,6 +103,7 @@ public:
|
|||||||
bool ChangeGame(const std::string& game);
|
bool ChangeGame(const std::string& game);
|
||||||
void SendChatMessage(const std::string& msg);
|
void SendChatMessage(const std::string& msg);
|
||||||
void RequestStopGame();
|
void RequestStopGame();
|
||||||
|
void SendPowerButtonEvent();
|
||||||
|
|
||||||
// Send and receive pads values
|
// Send and receive pads values
|
||||||
bool WiimoteUpdate(int _number, u8* data, const u8 size, u8 reporting_mode);
|
bool WiimoteUpdate(int _number, u8* data, const u8 size, u8 reporting_mode);
|
||||||
|
@ -124,6 +124,7 @@ enum
|
|||||||
NP_MSG_GAME_STATUS = 0xA4,
|
NP_MSG_GAME_STATUS = 0xA4,
|
||||||
NP_MSG_IPL_STATUS = 0xA5,
|
NP_MSG_IPL_STATUS = 0xA5,
|
||||||
NP_MSG_HOST_INPUT_AUTHORITY = 0xA6,
|
NP_MSG_HOST_INPUT_AUTHORITY = 0xA6,
|
||||||
|
NP_MSG_POWER_BUTTON = 0xA7,
|
||||||
|
|
||||||
NP_MSG_TIMEBASE = 0xB0,
|
NP_MSG_TIMEBASE = 0xB0,
|
||||||
NP_MSG_DESYNC_DETECTED = 0xB1,
|
NP_MSG_DESYNC_DETECTED = 0xB1,
|
||||||
@ -180,4 +181,5 @@ IOS::HLE::FS::FileSystem* GetWiiSyncFS();
|
|||||||
void SetWiiSyncFS(std::unique_ptr<IOS::HLE::FS::FileSystem> fs);
|
void SetWiiSyncFS(std::unique_ptr<IOS::HLE::FS::FileSystem> fs);
|
||||||
void ClearWiiSyncFS();
|
void ClearWiiSyncFS();
|
||||||
void SetSIPollBatching(bool state);
|
void SetSIPollBatching(bool state);
|
||||||
|
void SendPowerButtonEvent();
|
||||||
} // namespace NetPlay
|
} // namespace NetPlay
|
||||||
|
@ -743,6 +743,14 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
case NP_MSG_TIMEBASE:
|
||||||
{
|
{
|
||||||
u64 timebase = Common::PacketReadU64(packet);
|
u64 timebase = Common::PacketReadU64(packet);
|
||||||
|
@ -744,6 +744,10 @@ bool MainWindow::RequestStop()
|
|||||||
if (Core::GetState() == Core::State::Paused)
|
if (Core::GetState() == Core::State::Paused)
|
||||||
Core::SetState(Core::State::Running);
|
Core::SetState(Core::State::Running);
|
||||||
|
|
||||||
|
// Tell NetPlay about the power event
|
||||||
|
if (NetPlay::IsNetPlayRunning())
|
||||||
|
NetPlay::SendPowerButtonEvent();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
|
|
||||||
#include "UICommon/DiscordPresence.h"
|
#include "UICommon/DiscordPresence.h"
|
||||||
#include "UICommon/GameFile.h"
|
#include "UICommon/GameFile.h"
|
||||||
|
#include "UICommon/UICommon.h"
|
||||||
|
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
@ -796,6 +797,13 @@ void NetPlayDialog::OnMsgStopGame()
|
|||||||
QueueOnObject(this, [this] { UpdateDiscordPresence(); });
|
QueueOnObject(this, [this] { UpdateDiscordPresence(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetPlayDialog::OnMsgPowerButton()
|
||||||
|
{
|
||||||
|
if (!Core::IsRunning())
|
||||||
|
return;
|
||||||
|
QueueOnObject(this, [] { UICommon::TriggerSTMPowerEvent(); });
|
||||||
|
}
|
||||||
|
|
||||||
void NetPlayDialog::OnPadBufferChanged(u32 buffer)
|
void NetPlayDialog::OnPadBufferChanged(u32 buffer)
|
||||||
{
|
{
|
||||||
QueueOnObject(this, [this, buffer] {
|
QueueOnObject(this, [this, buffer] {
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
void OnMsgChangeGame(const std::string& filename) override;
|
void OnMsgChangeGame(const std::string& filename) override;
|
||||||
void OnMsgStartGame() override;
|
void OnMsgStartGame() override;
|
||||||
void OnMsgStopGame() override;
|
void OnMsgStopGame() override;
|
||||||
|
void OnMsgPowerButton() override;
|
||||||
void OnPadBufferChanged(u32 buffer) override;
|
void OnPadBufferChanged(u32 buffer) override;
|
||||||
void OnHostInputAuthorityChanged(bool enabled) override;
|
void OnHostInputAuthorityChanged(bool enabled) override;
|
||||||
void OnDesync(u32 frame, const std::string& player) override;
|
void OnDesync(u32 frame, const std::string& player) override;
|
||||||
|
Reference in New Issue
Block a user