Skip to content

Commit

Permalink
Merge pull request #4124 from mimimi085181/wiimote-netplay-check-repo…
Browse files Browse the repository at this point in the history
…rting-mode

Wiimote netplay: Check the reporting mode instead of the size
  • Loading branch information
degasus committed Sep 10, 2016
2 parents a15b3fd + 111182d commit cbdda17
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp
Expand Up @@ -772,7 +772,7 @@ void Wiimote::Update()
}
if (NetPlay::IsNetPlayRunning())
{
NetPlay_GetWiimoteData(m_index, data, rptf.size);
NetPlay_GetWiimoteData(m_index, data, rptf.size, m_reporting_mode);
if (rptf.core)
m_status.buttons = *(wm_buttons*)(data + rptf.core);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
Expand Up @@ -146,7 +146,7 @@ class Wiimote : public ControllerEmu
void WriteData(const wm_write_data* const wd);
void SendReadDataReply(ReadRequest& _request);
void SpeakerData(wm_speaker_data* sd);
bool NetPlay_GetWiimoteData(int wiimote, u8* data, u8 size);
bool NetPlay_GetWiimoteData(int wiimote, u8* data, u8 size, u8 reporting_mode);

// control groups
Buttons *m_buttons, *m_dpad, *m_shake;
Expand Down
12 changes: 6 additions & 6 deletions Source/Core/Core/NetPlayClient.cpp
Expand Up @@ -1022,7 +1022,7 @@ bool NetPlayClient::GetNetPads(const u8 pad_nb, GCPadStatus* pad_status)
}

// called from ---CPU--- thread
bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const u8 size)
bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const u8 size, u8 reporting_mode)
{
NetWiimote nw;
{
Expand Down Expand Up @@ -1060,10 +1060,10 @@ bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const u8 size)

// If the reporting mode has changed, we just need to pop through the buffer,
// until we reach a good input
if (nw.size() != size)
if (nw[1] != reporting_mode)
{
u32 tries = 0;
while (nw.size() != size)
while (nw[1] != reporting_mode)
{
while (m_wiimote_buffer[_number].Size() == 0)
{
Expand All @@ -1084,7 +1084,7 @@ bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const u8 size)
}

// If it still mismatches, it surely desynced
if (size != nw.size())
if (nw[1] != reporting_mode)
{
PanicAlertT("Netplay has desynced. There is no way to recover from this.");
return false;
Expand Down Expand Up @@ -1268,12 +1268,12 @@ bool CSIDevice_GCController::NetPlay_GetInput(u8 numPAD, GCPadStatus* PadStatus)
return false;
}

bool WiimoteEmu::Wiimote::NetPlay_GetWiimoteData(int wiimote, u8* data, u8 size)
bool WiimoteEmu::Wiimote::NetPlay_GetWiimoteData(int wiimote, u8* data, u8 size, u8 reporting_mode)
{
std::lock_guard<std::mutex> lk(crit_netplay_client);

if (netplay_client)
return netplay_client->WiimoteUpdate(wiimote, data, size);
return netplay_client->WiimoteUpdate(wiimote, data, size, reporting_mode);
else
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/NetPlayClient.h
Expand Up @@ -84,7 +84,7 @@ class NetPlayClient : public TraversalClientClient
void SendChatMessage(const std::string& msg);

// Send and receive pads values
bool WiimoteUpdate(int _number, u8* data, const u8 size);
bool WiimoteUpdate(int _number, u8* data, const u8 size, u8 reporting_mode);
bool GetNetPads(const u8 pad_nb, GCPadStatus* pad_status);

void OnTraversalStateChanged() override;
Expand Down

0 comments on commit cbdda17

Please sign in to comment.