Project

General

Profile

Actions

Emulator Issues #4334

closed

Fix proposal for [4185] - Wiimote spurious disconnection

Added by beistin over 13 years ago.

Status:
Duplicate
Priority:
Normal
Assignee:
-
% Done:

0%

Operating system:
N/A
Issue type:
Bug
Milestone:
Regression:
No
Relates to usability:
No
Relates to performance:
No
Easy:
No
Relates to maintainability:
No
Regression start:
Fixed in:

Description

Hi,

Like describe in bug 4185, I had spurious disconnection while playing with Mario Galaxy and I could not even play with Epic Mickey, my wiimote being always declared as disconnected.

Here comes a patch proposal that that solve those two bugs.

My system is running under linux 2.6.35 fedora 15 with a quad core CPU and only one wiimote. This patch has only be tested on this system.

I tried to do the same changes in the windows portion of the modified sources, but I do not have VisualStudio to compile and tests those changes in a VM.

The modifications are:
Source/Core/Core/Src/CoreTiming.*: refactoring to have a threadsafe fifo. This is not related with those bugs, but as I tested my patch with it, I provide it.

Source/Core/Common/Src/Thread.*: new wait function with a timeout parameter for Event objects / new function to get the name of the thread under unix (windows version is only "stub")

Source/Core/Common/Src/StdConditionVariable.h: timeout parameter for Event (could not test on windows, may be it does not even build)

Source/Core/Common/Src/FifoQueue.h: I do not think that the previous implementation was threadsafe. So here is a new version.

Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.*: Use two thread. One for reading the other for sending.

Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp: connected and disconnect functions updated to handle the 2 threads. Modification of the way the returns values of read() and write() function are used.

Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp: Tried to modify the connected() and disconnect() functions to handle the 2 threads, but I can not test it.

I hope the patch will work for other system, and will be merge.
Regards.


Related issues 1 (0 open1 closed)

Is duplicate of Emulator - Emulator Issues #4185: Real wiimote disconnects in some games (due to the lag caused by sending Wiimote Speaker data?)Fixed

Actions
Actions #1

Updated by Anonymous over 13 years ago

  • Status changed from New to Duplicate
Actions #2

Updated by beistin over 13 years ago

Should I post the patch proposal in 4185 issue?

Actions #3

Updated by hatarumoroboshi over 13 years ago

Only if it works for Windows;-)

Actions #4

Updated by beistin over 13 years ago

I will be pleased to make it compile under windows if you gave me a VisualStudio licence ;-)

Actions #5

Updated by Anonymous over 13 years ago

I marked it as a duplicate, which is as close as googlecode gets to "merging" issues. You do not need to repost it.

I'll check it out on windows when i get some time, patch looks ok though.
note: perhaps in the future only make patches of the actual change, not formatting changes...they just make it hard to read :p

As for VS, you can get the express version, or download a trial of any of the other versions. Or you could just not bother, up to you.

Actions #6

Updated by beistin over 13 years ago

Sorry for the formatting change, I am used to have my code autoformated under eclipse.

I just discovered in the wiki that I could get VS express.
I am downloading it so I can make it compile under windows.

Actions #7

Updated by Anonymous over 13 years ago

So if you haven't tried it yet, it seems like your patch has a race condition that hangs/crashes dolphin on windows. I haven't debugged it yet, just letting you know that I tried it at least.

Actions #8

Updated by beistin over 13 years ago

Thanks for telling me.
I am trying to compile it under virtualbox, but it take time to setup everything.

What kind of race do you observe? Is it systematical?

Actions #9

Updated by Anonymous over 13 years ago

Here is your patch with the unrelated formatting changes removed. Unfortunately the formatting changes in the new code are still there...

Probably won't get a chance to debug the problem until the end of the day (morning where I'm at :p).

Actions #10

Updated by Anonymous over 13 years ago

Ah well, the issue was somewhere in your changes to CoreTiming.h/cpp, so I just reverted all of them. No crash now.

However, audio does not sound correct, so at the moment this is not an acceptable patch.

Actions #11

Updated by Anonymous over 13 years ago

fwiw (if you didn't pick it up from comments in the source) audio must be sent at 5-7ms intervals (or, 20ms/3packets=6.66667ms).

Actions #12

Updated by beistin over 13 years ago

Ok CoreTiming.h/cpp is not mandatory. As I explained it in the first post, I pushed it because I use it but it is not directly related to the wiimote issue. You did well to remove it.

Could you be more specific when you say audio As I did not touch any audio file? It is about the the WII speaker?

Actions #13

Updated by Anonymous over 13 years ago

wiiMOTE speaker specifically ;p

yes, the whole cause behind the "spurious" disconnects is that some games (epic mickey, dkcr, just dance 2) send a continuous stream of empty audio data to the wiimote. With the current code in svn, this effectively overloads the wiimote (it spends all it's time receiving, and not sending any status reports) which causes the emulated game to think the wiimote has vanished.

...and the cause behind the cause, so to speak, is that timing the reports such that they are sent at ~5ms is too much to ask of most desktop operating systems.

Actions #14

Updated by beistin over 13 years ago

Ok I did not notice any difference under linux. The sound on the wiimote was crappy with or without this patch :D

I am a bit puzzled by your explanation. If we were overloading the wiimote, this patch would not change anything.

I think the issue is more that the loop, as it is written, does not allow us to keep up with the report flow. We certainly miss some reports and the application believes that the wiimote is disconnect.

Having two threads in the patch, one to read and the other to send allows us to keep up with the continues flow.

The sending thread sends a packet (if not empty) as soon as it receives it. There is no time regulation, but I guess would could had something in the write loop to improve this.

Actions #15

Updated by beistin over 13 years ago

This is a new version of the patch taking into account all your advices.
It compile fine under windows, but I could not test it under my VM.

could you give it a try?

Actions

Also available in: Atom PDF