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

Wiimote: Reconnect a disconnected Wiimote when a button is pressed. #2724

Merged

Conversation

AdmiralCurtiss
Copy link
Contributor

This reconnects an emulated Wiimote to the emulator when a key or button mapped to one of the Wiimote's buttons is pressed, similar to how a real Wiimote attempts to connect to the last known Wii when you push something on it. Mainly fixes the inconvenience of having to manually press Reconnect Wiimote after a few minutes of inactivity.

Still has a problem at the moment where a single button press can send multiple "reconnect me!" requests (presumably due to the update frequency of Wiimotes being higher than a typical game's framerate) which can freeze up the emulator for a second but technically works.

@lioncash lioncash added the WIP / do not merge Work in progress (do not merge) label Jul 9, 2015
@AdmiralCurtiss AdmiralCurtiss force-pushed the wiimote-reconnect-on-button-press branch from bea15ec to e462422 Compare July 10, 2015 02:36
@AdmiralCurtiss
Copy link
Contributor Author

Okay, if someone wants to test this now, go for it, as far as I can tell it works as it should.

Implementation notes:

  • I'm using a m_last_connect_request_counter variable to limit the frequency of reconnection requests by counting down the amount of times a Wiimote is polled after we send a request to be reconnected but before we actually are reconnected. It's only a few frames at most, but if I don't limit this somehow, you see multiple "Wiimote 1 Connected" OSD messages, which isn't very nice.
  • g_controller_interface.UpdateInput() was previously only called when at least one Wiimote was actually connected. Since I need to listen to input from disconnected Wiimotes to see when they want to be reconnected, it is now always called. As such, I was able to pull it out of Wiimote::Update() and get rid of that structure with the static variable that checks if we are in a new "input cycle", and put it into CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() instead, where Wiimote::Update() is called from.

@AdmiralCurtiss AdmiralCurtiss changed the title [WIP] Wiimote: Reconnect a disconnected emulated Wiimote when a button is pressed. Wiimote: Reconnect a disconnected emulated Wiimote when a button is pressed. Jul 10, 2015
@AdmiralCurtiss
Copy link
Contributor Author

And here is the same thing for real Wiimotes, too!

@AdmiralCurtiss AdmiralCurtiss changed the title Wiimote: Reconnect a disconnected emulated Wiimote when a button is pressed. Wiimote: Reconnect a disconnected Wiimote when a button is pressed. Jul 10, 2015
@AdmiralCurtiss AdmiralCurtiss force-pushed the wiimote-reconnect-on-button-press branch 2 times, most recently from ef178d2 to 4be80b3 Compare July 10, 2015 16:38
@JMC47
Copy link
Contributor

JMC47 commented Jul 15, 2015

Behavior is fine, everything works just like a Real Wii with connecting emulated Wiimotes now (at least, the same as it would be for a synced Wiimote.)

My only issue is that it never lets the user know when a Wiimote is forcefully disconnected, but, honestly? That isn't really worth blocking and was already an issue in the emulator.

LGTM.

…essed.

Where disconnected is defined as: The real physical device is still connected to the PC, but the emulated Wii sees the Wiimote as disconnected.
…ctWiimote() directly, dispatch an event that will call it for us in the GUI thread.

This eliminates a possible stutter/short freeze that can happen during PowerPC::Pause().
@AdmiralCurtiss AdmiralCurtiss force-pushed the wiimote-reconnect-on-button-press branch from 4be80b3 to 935292c Compare July 16, 2015 00:39
@AdmiralCurtiss
Copy link
Contributor Author

FYI, the notification about a Wiimote being disconnected should probably be added around here. Different PR territory though since getting a userfriendly message out of that seems harder than expected.

@mimimi085181
Copy link
Contributor

This is working nicely with my real wiimote. I can reconnect on Metroid Prime Trology and the Wii Sports resort WM+ video just fine. Reconnecting after a timeout works fine as well(only tested in Resident Evil 4).

I can't say anything about the implementation though, it's a bit over my head.

@JMC47
Copy link
Contributor

JMC47 commented Jul 18, 2015

Is this still WIP? It came here to kick ass and chew bubble gum, and it's all out of ass. Seriously though, I tested it, I love it, this is the best thing ever made.

@AdmiralCurtiss
Copy link
Contributor Author

Nah this is done, unless someone really wants reconnect-on-extension-press too.

@mimimi085181
Copy link
Contributor

Hm, reconnect on classic controller button press might be nice. Not sure about the rest of the extensions, like guitars and whatnot.

@BhaaLseN
Copy link
Member

We can always throw another PR for that; I'd rather get that merged sooner than later

skidau added a commit that referenced this pull request Jul 20, 2015
…ton-press

Wiimote: Reconnect a disconnected Wiimote when a button is pressed.
@skidau skidau merged commit 4b260fb into dolphin-emu:master Jul 20, 2015
@AdmiralCurtiss AdmiralCurtiss deleted the wiimote-reconnect-on-button-press branch July 20, 2015 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP / do not merge Work in progress (do not merge)
Development

Successfully merging this pull request may close these issues.

6 participants