Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Netplay: Fix synchronization for the Wiinote netplay #4016

Merged
merged 1 commit into from Jul 17, 2016

Conversation

mimimi085181
Copy link
Contributor

@mimimi085181 mimimi085181 commented Jul 16, 2016

The old implementation always polled the local 1st Wiimote and used that as input for the Wiimote that is mapped to the player. But the reporting mode for Wiimotes can be different, even when using the same extensions. So an input for Wiimote 1 with a data size 4 could be used for Wiimote 2, which actually requires data size 7 at that time for example.

The 2nd problem was that the code added a dummy input into the buffer, when the reporting mode changed. But when the data from the other player hasn't arrived yet, the data in the buffer is out of order. Well, i think this is the problem, i'm not 100% sure, because i don't fully understand how the buffer works. But on the other hand, i'm pretty sure this will just force sync the players on reporting mode changes, instead of allowing them to be apart.

Pros:

  • No more desyncs caused by big bugs in the code.
  • Can use different extensions for different players.

Cons:

  • Higher latency, because instead of polling 1 controller per player at once, all controllers are polled in order, send to the other players, before the next is processed.
  • Have to setup the Wiimote, which the player is going to use, instead of the 1st one.

Now, if the controller config could temporarily be overridden with the one from another slot, the 2nd problem could be fixed. But at the same time, we would lose the ability to use different extensions. (unless we hack around it somehow, or properly send the used extension to the other players)


This change is Reviewable

The old implementation always polled the local 1st Wiimote and used that as input for the Wiimote that is mapped to the player. But the reporting mode for Wiimotes can be different, even when using the same extensions. So an input for Wiimote 1 with a data size 4 could be used for Wiimote 2, which actually requires data size 7 at that time for example.

The 2nd problem was that the code added a dummy input into the buffer, when the reporting mode changed. But when the data from the other player hasn't arrived yet, the data in the buffer is out of order. Well, i think this is the problem, i'm not 100% sure, because i don't fully understand how the buffer works. But on the other hand, i'm pretty sure this will just force sync the players on reporting mode changes, instead of allowing them to be apart.

Pros:
- No more desyncs caused by big bugs in the code.
- Can use different extensions for different players.

Cons:
- Higher latency, because instead of polling 1 controller per player at once, all controllers are polled in order, send to the other players, before the next is processed.
- Have to setup the Wiimote, which the player is going to use, instead of the 1st one.

Now, if the controller config could temporarily be overridden with the one from another slot, the 2nd problem could be fixed. But at the same time, we would lose the ability to use different extensions. (unless we hack around it somehow, or properly send the used extension to the other players)
@delroth
Copy link
Member

delroth commented Jul 16, 2016

The code LGTM, if @JMC47 confirms this does what it should, we can merge.

@mimimi085181
Copy link
Contributor Author

Yes, i'm waiting for JMC to test this. I'm really interested in a case where both players are apart as much as possible with a large buffer. And then the reporting mode is changed, like by going to the home menu on new super mario bros. If it works as i think it does, it will make the player, who is ahead, wait for the other, before continuing.

@JMC47
Copy link
Contributor

JMC47 commented Jul 16, 2016

This works for games that let Wiimotes stay connected at all times. There are still a lot of weird behaviors, but, those were pre-existing issues.

}

} // unlock players

while (m_wiimote_current_data_size[_number] == size && !m_wiimote_buffer[_number].Pop(nw))
while (!m_wiimote_buffer[_number].Pop(nw))
{
// wait for receiving thread to push some data
Common::SleepCurrentThread(1);

This comment was marked as off-topic.

@delroth delroth merged commit 92594e0 into dolphin-emu:master Jul 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants