NetPlay: Sync power button event

This fixes the deadlock on shutdown when Wii Remotes are in use.
This commit is contained in:
Techjar
2018-11-10 22:37:49 -05:00
parent 97e3200f57
commit ef89e4e70c
7 changed files with 44 additions and 0 deletions

View File

@@ -568,6 +568,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;
@@ -1701,6 +1707,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
{
@@ -1883,6 +1896,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);