Skip to content

Conversation

jordan-woyak
Copy link
Member

@jordan-woyak jordan-woyak commented Aug 17, 2025

PR #13387 causes the emulator to race through to the next presentation which can cause written Wii remote reports to have improper timing.

With this PR, writes are now performed at the proper times on a thread separate from reads.

I've done some minor code clean up, but WiimoteReal is really in need of a big overhaul.

Theoretically this would improve speaker data.
In practice it doesn't seem to help much.

This should at least eliminate any regressions introduced by #13387 (if they were even noticeable).

Copy link
Contributor

@iwubcode iwubcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM. Untested.

@Trihy
Copy link

Trihy commented Aug 18, 2025

Tried this commit but the problem I was having is still there.

This is a comparisson

Realtek 2024 drivers (every sound pretty good):

https://www.mediafire.com/file/g1z4qkfvb52hzfv/Dolphin_Emulated_TR_Realtek_2024_driver.aac/file

Realtek 2025 (every sound starts fine but ends horribly):

https://www.mediafire.com/file/0h7o7ib0k0cl9uc/Dolphin_Emulated_TR_Realtek_2025_driver.aac/file

And wiimote response seem to be blocked during the distorted audio.

I could just blame realtek drivers. But I use a program to test wiimote speaker audio and seems unaffected. Program uses ADPCM at 6000hz.

@jordan-woyak jordan-woyak added the WIP / do not merge Work in progress (do not merge) label Aug 19, 2025
@jordan-woyak
Copy link
Member Author

And wiimote response seem to be blocked during the distorted audio.

Thanks for testing. I need to fix this.

@Trihy
Copy link

Trihy commented Aug 21, 2025

Thanks. I can provide additional info if needed.

Next to this would be nice to do some refactory or rework to IOWin.cpp. Really old code left there. Some deprecated Windows 7 workarounds among other methods to detect connections or disconnections that seems odd or just temporal workarounds that has been there forever. I can help with testing.

We can properly detect when a wiimote disconnect by not receiving report data (accel data, IR data, button data, etc). And make BT stack aware it´s disconnected. There is little to no code about that. And we can detect when a wiimote is trying to connect too. Actual code just simply delete from system and re sync.

@jordan-woyak jordan-woyak removed the WIP / do not merge Work in progress (do not merge) label Sep 9, 2025
@jordan-woyak
Copy link
Member Author

And wiimote response seem to be blocked during the distorted audio.

This should be resolved now.

@Trihy
Copy link

Trihy commented Sep 10, 2025

Tested new code. Looks fine to me. Didnt notice any regression. And issues seems to be fixed.

… speaker data.
@Trihy
Copy link

Trihy commented Sep 20, 2025

The new change need additional testing? Could compile again if necessary but doesn't seem so.

@jordan-woyak
Copy link
Member Author

The new change need additional testing? Could compile again if necessary but doesn't seem so.

Not any major new changes.
I am cleaning up the Windows-specific Wii remote code now for a new PR and it would be nice to get this merged first.

@Trihy
Copy link

Trihy commented Sep 20, 2025

Great. It was just a minor change so l bet it will be fine. My PC takes a while to compile dolphin.

Mostly I delete this before compiling (in iowin.cpp)

// Removes remembered non-connected devices
bool ForgetWiimote(BLUETOOTH_DEVICE_INFO_STRUCT& btdi)
{
if (!btdi.fConnected && btdi.fRemembered)
{
// Time to avoid RemoveDevice after SetServiceState.
// Sometimes SetServiceState takes a while..
auto const avoid_forget_seconds = 5.0;

const auto pair_time = s_connect_times.find(btdi.Address.ullLong);
if (pair_time == s_connect_times.end() ||
    std::difftime(time(nullptr), pair_time->second) >= avoid_forget_seconds)
{
  // Make Windows forget about device so it will re-find it if visible.
  // This is also required to detect a disconnect for some reason..
  NOTICE_LOG_FMT(WIIMOTE, "Removing remembered Wiimote.");
  pBluetoothRemoveDevice(&btdi.Address);
  return true;
}

}

return false;
}

It keep deleting all my non connected wiimotes from my system. I use them for other stuff and because of that I have to re sync them all the time.

I just cheat changing this
If (!btdi.fConnected && btdi.fRemembered)
to this
if (!btdi.fConnected && !btdi.fRemembered)

So the sentence now makes no sense and stop messing with my Wiimotes.

I think we have better ways to detect disconnections/connections/tryingtoconnect now instead of that workaround.

Count me in for some Windows Wiimote code testing :)

@jordan-woyak
Copy link
Member Author

@Trihy
Yes, I'm hoping to clean that all up and make it work less terribly (in the new PR).

@jordan-woyak
Copy link
Member Author

jordan-woyak commented Sep 21, 2025

It keep deleting all my non connected wiimotes from my system. I use them for other stuff and because of that I have to re sync them all the time.

Why specifically do you need the devices installed when they aren't connected?

With BluetoothRemoveDevice removed, BluetoothSetServiceState refuses to re-connect existing remotes for me.

I am looking for alternative methods to connect remotes, but Microsoft's documentation isn't the best.

Is there some open source application you know of that is able to pair remotes more properly?

@Trihy
Copy link

Trihy commented Sep 21, 2025

Hi. If you re sync them every time, it will get another Windows ID. So many software wont recognize the previous configuration.

And also for one button reconnect. Since I deleted that part of the code, I connect my wiimotes with a single button press (after syncing with sync button). But I sync them with other software, since Im not sure if dolphin does permanent pairing using the BT dongle mac backwards as pairing key ( I mean this "If connecting by holding down the 1+2 buttons, the PIN is the bluetooth address of the wiimote backwards, if connecting by pressing the "sync" button on the back of the wiimote, then the PIN is the bluetooth address of the host backwards.")

This software once synced with sync button, will re connect with one button press every single time. You can turn wiimote off, take batteries out, restart the system, etc and single button press will reconnect.

https://github.com/Trihy/Touchmote/tree/ryochan7_lightgun

Sync and connect routines are under WiiCPP folder. And It´s based on WiiPair.

I was trying to understand how it works to help dolphin, but can´t understand what it does once a remote stop sending reports, to make Windows aware it´s disconnected. I noticed sometimes when you turn a wiimote off on dolphin, Windows still think It´s connected (you can go to BT devices and say it´s connected) and takes some time to realize it´s disconnected. With this software it´s instantly and 100% successs every time.

@Trihy
Copy link

Trihy commented Sep 21, 2025

To make it clear, last time I synced my wiimotes with Sync button was like a year ago. They just connect with a single button press. And I use them daily.

Oh BTW, all I commented is valid for most BT dongles and built in ones. There is an exception for TPLINK UB500 since it has a bug in their drivers. In case you are testing with that one, additional info I have to add.

@Trihy
Copy link

Trihy commented Sep 22, 2025

Look at this flawless experience reconnecting wiimotes.

Link removed. Already been worked on.

Windows 11 built in realtek BT. Using touchmote (WiiPair based) Just turn them off with wiimote power button and then just pressed any button. In this case was the dpad. I can repeat this 10 times and wont miss a single beat reconnecting them. We can figure it out how to make dolphin equal great for emulated mode.

Really great to use the wiimotes that way. Wii console experience.

@jordan-woyak
Copy link
Member Author

I have pairing working locally now in Dolphin, but semi-unrelated ControllerInterface things are causing frequent deadlocks so I have to fix up all of that code to really experience the benefits.

@Trihy
Copy link

Trihy commented Sep 22, 2025

Great. I been dealing with wiimotes since the old days of toshiba stack. Looks like win10 and 11 can handle them correctly. Dolphin was a little behind. Lets make things easier again for end user.

@JMC47 JMC47 merged commit d33c634 into dolphin-emu:master Sep 26, 2025
11 of 13 checks passed
@jordan-woyak jordan-woyak deleted the wiimote-report-timing branch September 26, 2025 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants