mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Fix running more than one session with Wiimotes
A static var is not a good idea, when the value needs to be reset for every session. Also, the variable holds the data size, so it makes sense to set the data size, where the data is added.
This commit is contained in:
parent
bfe8b11ba8
commit
b962c1f392
@ -722,6 +722,7 @@ bool NetPlayClient::StartGame(const std::string& path)
|
||||
// Needed to prevent locking up at boot if (when) the wiimotes connect out of order.
|
||||
NetWiimote nw;
|
||||
nw.resize(4, 0);
|
||||
m_wiimote_current_data_size = {4, 4, 4, 4};
|
||||
|
||||
for (unsigned int w = 0; w < 4; ++w)
|
||||
{
|
||||
@ -923,7 +924,6 @@ bool NetPlayClient::GetNetPads(const u8 pad_nb, GCPadStatus* pad_status)
|
||||
bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const u8 size)
|
||||
{
|
||||
NetWiimote nw;
|
||||
static u8 previousSize[4] = {4, 4, 4, 4};
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lkp(m_crit.players);
|
||||
|
||||
@ -932,7 +932,7 @@ bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const u8 size)
|
||||
// does this local Wiimote map in game?
|
||||
if (in_game_num < 4)
|
||||
{
|
||||
if (previousSize[in_game_num] == size)
|
||||
if (m_wiimote_current_data_size[in_game_num] == size)
|
||||
{
|
||||
nw.assign(data, data + size);
|
||||
do
|
||||
@ -960,13 +960,13 @@ bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const u8 size)
|
||||
m_wiimote_buffer[in_game_num].Push(nw);
|
||||
m_wiimote_buffer[in_game_num].Push(nw);
|
||||
m_wiimote_buffer[in_game_num].Push(nw);
|
||||
previousSize[in_game_num] = size;
|
||||
m_wiimote_current_data_size[in_game_num] = size;
|
||||
}
|
||||
}
|
||||
|
||||
} // unlock players
|
||||
|
||||
while (previousSize[_number] == size && !m_wiimote_buffer[_number].Pop(nw))
|
||||
while (m_wiimote_current_data_size[_number] == size && !m_wiimote_buffer[_number].Pop(nw))
|
||||
{
|
||||
// wait for receiving thread to push some data
|
||||
Common::SleepCurrentThread(1);
|
||||
@ -975,7 +975,7 @@ bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const u8 size)
|
||||
}
|
||||
|
||||
// Use a blank input, since we may not have any valid input.
|
||||
if (previousSize[_number] != size)
|
||||
if (m_wiimote_current_data_size[_number] != size)
|
||||
{
|
||||
nw.resize(size, 0);
|
||||
m_wiimote_buffer[_number].Push(nw);
|
||||
@ -1012,7 +1012,7 @@ bool NetPlayClient::WiimoteUpdate(int _number, u8* data, const u8 size)
|
||||
}
|
||||
}
|
||||
|
||||
previousSize[_number] = size;
|
||||
m_wiimote_current_data_size[_number] = size;
|
||||
memcpy(data, nw.data(), size);
|
||||
return true;
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ protected:
|
||||
|
||||
std::array<Common::FifoQueue<GCPadStatus>, 4> m_pad_buffer;
|
||||
std::array<Common::FifoQueue<NetWiimote>, 4> m_wiimote_buffer;
|
||||
std::array<u32, 4> m_wiimote_current_data_size;
|
||||
|
||||
NetPlayUI* m_dialog = nullptr;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user