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

[RFC]Real Wiimote Windows "-TR" Fix #3245

Merged
merged 3 commits into from Dec 11, 2015

Conversation

jloehr
Copy link
Contributor

@jloehr jloehr commented Nov 9, 2015

  • Fixes the IOWrite for Windows, so the newer "-TR" Wii Remotes are usable with the Microsoft Bluetooth Stack.

Important:
For "-TR" Wiimotes it is important that the sync is initiated by the Red Sync Button on the back. "1+2" Sync does not work.

Test Results:
Windows 7:

x MS-Stack Toshiba DolphinBar
non "-TR" Working Working Working
"-TR" Won't Fix Working Working

Windows 8:

x MS-Stack Toshiba DolphinBar
non "-TR" - - -
"-TR" - - -

Windows 10:

x MS-Stack Toshiba DolphinBar
non "-TR" - - -
"-TR" - - -

Known Issues/Bug:
"-TR" Support only works on Windows 8/8.1 and 10. On Windows 7 the old HidD_SetOutputReport is used, that doesn't support "-TR" Wiimotes.

Side Note:
My guess, why WriteFile works, but HidD_SetOutputReport does not. HidD_SetOutputReport may result in a Bluetooth HID "SetReport" Message via the Control Channel, which is not supported by the "-TR" Wiimotes. (Asynchronous) WriteFile result in a "Data" Message via the Interrupt/Data Channel.
For Windows 7; WriteFile needs the Buffer size to be 22 otherwise throws an error. Wiimote however doesn't take Buffer size of 22, when the Report Type is smaller and throws an error itself.

@delroth
Copy link
Member

delroth commented Nov 9, 2015

@JMC47 care to test with a DolphinBar to confirm it doesn't break compatibility? And a few other weird setups if you have time.

@dolphin-emu-bot rebuild

{
auto const overlapped_err = GetLastError();

//In case it was aborted by someone else

This comment was marked as off-topic.

@jloehr jloehr force-pushed the RealWiimote-Windows-Fix branch 2 times, most recently from 8ac2ad7 to c244c6f Compare November 9, 2015 21:10
@jloehr
Copy link
Contributor Author

jloehr commented Nov 9, 2015

Regarding the Wii U Pro Controller: When it is configured as Real Wiimote and a Button is pressed as normal, nothing happens, because it is stuck on IORead. When Dolphin is then closed, the Controller briefly vibrates and the LED is set, so it seems that the messages are somehow stalled.

@JMC47
Copy link
Contributor

JMC47 commented Nov 10, 2015

Does not work with the DolphinBar.

@JMC47
Copy link
Contributor

JMC47 commented Nov 10, 2015

I also cannot get a standard (white, no motion+) Wiimote to connect on Windows 7 via standard bluetooth.

@JMC47
Copy link
Contributor

JMC47 commented Nov 10, 2015

I'm not sure if this is a Windows 7 problem or not, but, i can't get any Wiimote to connect to my computer with this build. Sorry for the complications, but, I honestly don't know what to try next.

@jloehr
Copy link
Contributor Author

jloehr commented Nov 10, 2015

By standard you mean a official Nintendo Wiimote?

What Bluetooth Dongle/Adapter do you use? I use either a build-in adapter in my laptop or a Speedlink Dongle. Both have the same VID&PID(VID_0A12 & PID_0001) but different Revision.
From the VID&PID i can tell, that both adapters use CSR Chips.
For me the build-in worked fine with Wiimotes on Windows 8/8.1, Windows 10. And the Dongle worked fine with Wiimote on Windows 7, 8.1 & 10.

What is exactly the error? Does you adapter find the Wiimote and is it possible to successfully syn it?
Regardless of the Application that will use the Wiimote, my steps for syncing are:

  1. Init search for Bluetooth Devices on the Host System
  2. Press 1+2 or Sync button on the Wiimote
  3. Continuously press any button on the Wiimote to keep it alive
  4. Initiate Pairing on Host
  5. If asked for a PIN, leave it empty and just press "Next" (If next is grayed out abort the Sync, turn of the Wiimote and start over again)
  6. Wait for Windows to successfully connect it and load drivers, while still pressing a button
  7. When Windows finished its paring/driver thing, start any programm, that will communicate with the Wiimote and at least set the LEDs
  8. If the LEDs are set, stop pressing the button.

Lately if figured, that on Windows 10 and also Windows 8.1 the continuous button pressing is not needed, when Windows pairs and loads the drivers in an appropriate time frame. Also it seems to keep the Wiimote alive itself afterwards.

@JMC47
Copy link
Contributor

JMC47 commented Nov 10, 2015

I did all of this, in fact, I used the same bluetooth to connect it to the regular builds of Dolphin. I was using standard Nintendo Wiimotes; when I switched over to your PR builds, it just didn't work. It would stay flashing forever, I had no way to get it to connect the rest of the way for use in Dolphin.

@jloehr
Copy link
Contributor Author

jloehr commented Nov 10, 2015

As figured in IRC, seems to be a bug in the Dolphin Code Base.
Dolphin Bar as well as Wiimotes work fine on Windows 7 with Dolphin Master and my HIDAPI test program.
Some snippet from the Error log:

37:44:680 HW\WiimoteReal\IOWin.cpp:833 N[Wiimote]: Found Wiimote (28:22:a7:51:e7:e0). Enabling HID service.
37:47:682 HW\WiimoteReal\IOWin.cpp:705 W[Wiimote]: _IOWrite: Error on WriteFile: 00000057
...
37:47:683 HW\WiimoteReal\IOWin.cpp:705 W[Wiimote]: _IOWrite: Error on WriteFile: 00000057
37:47:683 HW\WiimoteReal\IOWin.cpp:705 W[Wiimote]: _IOWrite: Error on WriteFile: 000006f8
37:50:731 HW\WiimoteReal\IOWin.cpp:705 W[Wiimote]: _IOWrite: Error on WriteFile: 00000057
...
37:50:732 HW\WiimoteReal\IOWin.cpp:705 W[Wiimote]: _IOWrite: Error on WriteFile: 00000057
37:50:732 HW\WiimoteReal\IOWin.cpp:705 W[Wiimote]: _IOWrite: Error on WriteFile: 000006f8
37:53:779 HW\WiimoteReal\IOWin.cpp:893 N[Wiimote]: Removing remembered Wiimote.

0x57 is ERROR_INVALID_PARAMETER and
0x6f8 is ERROR_INVALID_USER_BUFFER

@jloehr jloehr changed the title Real Wiimote Windows "-TR" Fix | Index LED Fix [WIP]Real Wiimote Windows "-TR" Fix | Index LED Fix Nov 10, 2015
@JMC47
Copy link
Contributor

JMC47 commented Nov 11, 2015

Tried ToshibaStack as well now. All three have failed for me.
ToshibaStack.txt

@JMC47
Copy link
Contributor

JMC47 commented Nov 11, 2015

Tried a second bluetooth with a -TR Wiimote I bought, same problem.

@jloehr
Copy link
Contributor Author

jloehr commented Nov 11, 2015

What do you mean specific by

All three failed

?

Can you test it with my program always as well. As long as my program works, there's nothing wrong with the API and Dolphin will work as well.

@JMC47
Copy link
Contributor

JMC47 commented Nov 11, 2015

Your program works fine, it's just Dolphin that doesn't work at all. There has to be some setting or something I messed up, I don't get why two bluetooth (and a DolphinBar) and 3 different kinds of wiimotes wouldn't connect to Dolphin.

@jloehr
Copy link
Contributor Author

jloehr commented Nov 11, 2015

My program also works with Toshiba Stack?
I think i have to do some more major changes to get it properly working. Only problem is for me all my Wiimotes work. The question is, whether it is a problem with Windows 7 or with your different Bluetooth Dongle

@JMC47
Copy link
Contributor

JMC47 commented Nov 11, 2015

Your program worked the same as it did on the DolphinBar with Toshiba Stack (tons of inputs all the time)

I have a Windows 10 Computer in the other room; if my brother lends it to me I will test there as well.

@JMC47
Copy link
Contributor

JMC47 commented Nov 11, 2015

Wiimote successfully connected on Windows 10

@JMC47
Copy link
Contributor

JMC47 commented Nov 11, 2015

Wiimote audio is actually working properly in Wii Sports Resort with 1 Wiimote on a pretty shoddy bluetooth.

@jloehr
Copy link
Contributor Author

jloehr commented Nov 23, 2015

Updated initial post.

@JMC47
Copy link
Contributor

JMC47 commented Nov 23, 2015

Regular Wiimotes work on Windows 7, MSBT Stack now. No working Wiimote audio, though.

DolphinBar and Toshiba Stack remain broken.

@@ -395,15 +502,18 @@ void WiimoteScanner::CheckDeviceType(std::basic_string<TCHAR> &devicepath, bool
u8 const disable_enc_pt2_report[MAX_PAYLOAD] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_WRITE_DATA, 0x04, 0xa4, 0x00, 0xfb, 0x01, 0x00};

CheckDeviceType_Write(dev_handle,
write_method,

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

}

// Create a new empty device info set for the device info data
(*parent_device_info) = SetupDiCreateDeviceInfoList(NULL, NULL);

This comment was marked as off-topic.

write_method,
disable_enc_pt1_report,
sizeof(disable_enc_pt1_report),
1);

This comment was marked as off-topic.

"-TR" Wiimotes don't accept output reports via the Control Channel. HidP_SetOutputReports will send the data via the Control Channel, whereas WriteFile will send it via the Interrupt Channel. Therefore using WriteFile enables "-TR" Wiimotes on Windows. There are some issues to be aware of. First the Toshiba Bluetooth Stack needs the output report buffer to have the size of the largest output report supported by the device. This requirement is also enforced by the Windows 7 default stack. However the Toshiba Stack, will only send the actual report bytes to the device, whereas on Windows 7 the full resized buffer is sent, resulting in an error on the Wiimote. This issue renders WriteFile unusable on Windows 7 with the  default stack. On Windows 8/8.1/10 this requirement is somehow not implemented and it is possible to send smaller buffers via WriteFile to the device, enabling "-TR" Wiimotes.
@JMC47
Copy link
Contributor

JMC47 commented Dec 7, 2015

One thing I'm going to text extensively: Wiimote audio works on -TR Wiimotes, MS Bluetooth Stack, Windows 10. Regular Wiimotes DO NOT have working Wiimote audio! Also, the audio can lag depending on bandwidth, but, it's so close to perfect. It's better than a Wii in many points, except on longer sounds, where it tends to struggle.

@MayImilae
Copy link
Contributor

Here's my testing!

All tests were performed in the version of pr3245 dated as 06-Dec-2015 19:19 on https://dl.dolphin-emu.org/prs/. Continuous scanning was used throughout to make the poor little tester's life easier! Also, all tests were performed with the bluetooth adapters on my desk, with less than half a meter away from the wiimotes during testing, with line of sight between the wiimotes and the adapters.

The tests are:

  • connectivity test: connects to dolphin, shakes, and lights indicate its player number
  • Classic Controller test: loading brawl and making sure the extension works
  • Motion Plus and Nunchuk test: Checking the longterm connectivity issue on skyward sword, making sure I am about to pass the plug in motionplus/nunchuk screen either instantly or with no more than one reconnection (which can happen even on console)
  • Wiimote audio test - With Enable Speaker Data set to ON, run Mario Kart Wii and hit the home button on the wiimote during the select license menu. Go into the wii remote settings, and then raise and lower volume rapidly with the - and + buttons, noting quality and if the connection drops.
  • Three Wiimotes connectivity and game test- Connecting my non-TR, first gen TR, and wiiu gen TR wiimotes, making sure their lights correctly indicate their player positions, and loading wii sports to make sure the pointers of all three wiimotes appear on screen

The devices are:

  • MS Bluetooth Stack - Asus BT211 (which windows says is an Atheros AR3011)
  • Toshiba Stack - Azio BTD-V201
  • Dolphinbar - Running V5 firmware

Test results:

DolphinBar

  • Dolphinbar Win7 single non-TR wiimote - connectivity test: Pass
  • Dolphinbar Win7 single non-TR wiimote - Classic Controller test: Pass
  • Dolphinbar Win7 single non-TR wiimote - Motion Plus and Nunchuk test: Pass
  • Dolphinbar Win7 single non-TR wiimote - wiimote audio test:
    • Severe crackling, but sound was discernible as the sound. However, pressing the button rapidly resulted in mostly silence
    • No apparent lag, other than the silence when pressing rapidly which could be lag?
    • No disconnections
  • Dolphinbar Win7 single TR wiimote - connectivity test: Pass
  • Dolphinbar Win7 single TR wiimote - Classic Controller test: Pass
  • Dolphinbar Win7 single TR wiimote - wiimote audio test:
    • Crackling is significantly less than the non-TR, while not great, it is very clear what the sound is
    • No lag when pressing a single button immediately, but on pressing rapidly considerable lag built up
    • No disconnections
  • Dolphinbar Win7 three wiimotes connectivity and game test: Pass
    • (first wiimote did not vibrate, others did, all worked anyway)

Toshiba Stack

  • Toshiba Win7 single non-TR wiimote - connectivity test: Pass
  • Toshiba Win7 single non-TR wiimote - Classic Controller test: Pass
    • (wiimote did not vibrate, worked anyway)
  • Toshiba Win7 single non-TR wiimote - Motion Plus and Nunchuk test: Pass
  • Toshiba Win7 single non-TR wiimote - wiimote audio test:
    • Nothing but crackling, no discernible audio came through. It did not however lag, and did not disconnect
  • Toshiba Win7 single TR wiimote - connectivity test: Pass
  • Toshiba Win7 single TR wiimote - Classic Controller Test: Pass
  • Toshiba Win7 single TR wiimote - wiimote audio test:
    • Produces actual audio, with no discernible lag
    • Minor ringing sounds during the note, very faint, and could occur on console
    • No disconnections
  • Toshiba Win7 three wiimotes connectivity and game test:
    • Wiimote 3 was "disconnected by emulated software", pressing alt-f7 restored it and it worked
    • Retest result: Pass
    • Overal test conclusion: Pass
    • (not all wiimotes vibrated again, unable to track precisely which this time)

MS Bluetooth Stack

  • MS Win7 single non-TR wiimote - connectivity test: Pass
  • MS Win7 single non-TR wiimote - Classic Controller test: Pass
  • MS Win7 single non-TR wiimote - Motion Plus and Nunchuk test: Pass
  • MS Win7 single non-TR wiimote - wiimote audio test:
    • Sound was crackling and poor quality, lagged behind my button presses
    • The wiimote disconnected twice as I raised and lowed volume rapidly, pressing A restored the connection both times.
      • Interestingly, this means Dolphin lost the connection, and not the bluetooth adapter (the bluetooth adapter would require pressing 1+2 to reconnect) Hmm...
  • MS Win7 TR wiimote - connectivity test:
    • TR Wiimote "connected" to the MS bluetooth stack, did not get connected in dolphin
    • Running Wii Sports Resort, Wiimote 1 connected and disconnected rapidly for several times before failing, logs giving lots of [Wiimote]: IOWrite[WVM_WRITE_FILE]: Error on WriteFile:00000057 and a few [Wiimote]: IOWrite[WVM_WRITE_FILE]: Error on WriteFile:00000015
    • Retest results: Fail
    • Overall conclusion: Fail
  • Unable to perform further TR wiimote tests or the three wiimote test

So um, basically, no regressions, and everything worked as expected on Windows 7. All as this PR brings lots of benefits to other operating systems (which I can't test...) Everything seems fine to me!

@JMC47
Copy link
Contributor

JMC47 commented Dec 7, 2015

Everything works as good or better than before. LGTM.

@JMC47
Copy link
Contributor

JMC47 commented Dec 7, 2015

Tested Wii Balance Board as well, it works.

@mbc07
Copy link
Contributor

mbc07 commented Dec 7, 2015

Well, I saw you guys saying this PR improved Wiimote Audio as well so I gave it a try and while everything is working as expected, Wiimote audio still sounds like a noisy mess (just like before). I tested the latest build of this PR on Windows 10 with both MS Stack (with an Atheros AR5B22 combo card -- identified as Atheros AR3012 Bluetooth 4.0 on Device Manager) and DolphinBar. Am I missing something or that's expected?

(BTW, great work @jloehr)

@JMC47
Copy link
Contributor

JMC47 commented Dec 8, 2015

Audio only is improved on -tr wiimotes.

On Mon, Dec 7, 2015, 11:30 AM Mateus B. Cassiano notifications@github.com
wrote:

Well, I saw you guys saying this PR improved Wiimote Audio as well so I
gave it a try and while everything is working as expected, Wiimote audio
still sounds like a noisy mess (just like before). I tested the latest
build of this PR on Windows 10 with both MS Stack (with an Atheros AR5B22
combo card -- identified as Atheros AR3012 Bluetooth 4.0 on Device Manager)
and DolphinBar. Am I missing something or that's expected?

(BTW, great work @jloehr https://github.com/jloehr)


Reply to this email directly or view it on GitHub
#3245 (comment).

@mbc07
Copy link
Contributor

mbc07 commented Dec 8, 2015

Gotcha, now it makes sense (my wiimotes are all non-TR)...

@JMC47
Copy link
Contributor

JMC47 commented Dec 11, 2015

Is there any reason not to merge this now? I'm not sure if the code has all been looked at, but we're pretty certain this is a huge improvement for Wiimotes.

delroth added a commit that referenced this pull request Dec 11, 2015
[RFC]Real Wiimote Windows "-TR" Fix
@delroth delroth merged commit 8acf8cf into dolphin-emu:master Dec 11, 2015
@MayImilae
Copy link
Contributor

@jloehr can you give me a summary of these changes? A kind of before and after of what does not work and what works for each operating system? It would be really helpful for the progress report!

@jloehr
Copy link
Contributor Author

jloehr commented Dec 13, 2015

@MaJoRoesch:

Short: It changes the way of communication/used API on Windows 8 and higher.

Long: The distinction between Microsoft and Bluesoleil Bluetooth Stack(old code) was cleaned up, and a new API for Windows 8 and higher was implemented (the same that is used for the Toshiba Stack, but slightly different parameters to get it working). The new way/API is unfortunately not working for Windows 7 due to a bug in the Windows HID Class Driver, otherwise all those changes would also effect Windows 7. A distinction detection for the Toshiba Stack was implemented, by examining the Provider Name of the Class Driver of the HID Device.

Overall: Code for branching according to the provided Stack was changed.
Toshiba and Windows 7: uses same method as before
Windows 8 and higher (including Dolphin Bar on those Systems): use of new API (same as Toshiba, but slightly different)

Therefore behavior on Windows 8 and higher with MS default stack changes:

  • "-TR" Wiimotes are now working with MS Stack
  • Audio for "-TR" Wiimotes now works almost perfectly (according to others)
  • Audio for non-"TR" Wiimotes seem to not work anymore (as i understand the others, it worked before merging my PR, but i am not totally sure)

If the behavior for the DolphinBar changed in any way, someone else need to add those as i don't have a DolphinBar and don't whether and what changed.

Hope i didn't miss something, if so, others shall feel free to add comments of what change as well.

@JMC47
Copy link
Contributor

JMC47 commented Dec 13, 2015

Nah, old Wiimote audio never worked. There is no regression in old wiimotes. They're unchanged. -TR wiimotes now work, old are unchanged.

Only change with DolphinBar is that audio now sorta works on -TR wiimotes, but it's definitely laggier than a good bluetooth. I bet it's due to the bluetooth being lower quality.

@RandomDolphinUser
Copy link

Tested with :
Dolphin current dev build : 4.0-8329

x H/S
OS Win 8.1
BT A random adapter "Sitecom" branded recognized as a "Generic Bluetooth Radio"
x MS-Stack
non "-TR" Working
"-TR" Working

Ps : thanks, i can finally play Skyward on 1080p 😄

@jloehr jloehr deleted the RealWiimote-Windows-Fix branch January 13, 2016 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet