batocera-linux / batocera.linux

batocera.linux
https://batocera.org
Other
2.02k stars 518 forks source link

Original Wii bluetooth module passtrough #10564

Open spitsie opened 11 months ago

spitsie commented 11 months ago

Batocera build version

V38

Your architecture

PC

Your Graphic Processor Unit (GPU)

None

Graphical brand

Intel

Issue description

I found a issue that paired wii controllers don't get remembered if I use the Bluetooth passtrough in Dolphin. After every restart or starting a new game, I had to pair each controller again.

I found out that it was a problem in the btusb.ko module. By blacklisting the Wii bluetooth device in there it doesn't load drivers for it, so there is no conflict if Dolphin use the Wii bluetooth in Bluetooth passtrough mode.

I did a simple hex patch, changing a existing blacklist device to the Wii bluetooth device. And removing the signature check at the end from the btusb.ko module.

After that I did a system overlay save, and now everything works as it should. The controllers get remembered.

Expected result

I don't know if it is possible, but it would be nice that in the next versions from Batocera the Wii module is already blacklisted in the btusb.ko module, not only changed a existing device that is already blacklisted. Then users don't have to patch it manually.

Reproduction steps

I opened the btusb.ko file in a HEX editor. Changed the HEX value 5C 0A 33 20 to 7E 05 05 03 and removed the module signature at the end.

HEX value 5C 0A 33 30 is in bytes 0a5c:2033 and original blacklist broadcom BCM2033 without firmware. I change it to 057e:0305 that's in HEX 7E 05 05 03 for the Wii bluetooth module.

Logs and data

No response

Tovarichtch commented 11 months ago

Where is that file btusb.ko located exactly?

spitsie commented 11 months ago

Where is that file btusb.ko located exactly?

I uploaded the patched file here

Just download and unzip the Wii patch.zip and follow the manual I added as pdf.

dmanlfc commented 11 months ago

If you patch the kernel to remove the bluetooth device, then it cannot be used for anything else, correct? If so, therefore this method isn't practical...

dmanlfc commented 11 months ago

A couple of things:

  1. 0a5c:2033 is a standard Broadcom Bluetooth adaptor used in various manufacturers devices. We practically cannot blacklist it or remove it from the kernel module in our image.
  2. When you say original Wii bluetooth module from Nintendo are you meaning the actual bluetooth module from the Wii? Or do you mean the WiiMote?
dmanlfc commented 11 months ago

a simple, yes it's the original wii bluetooth adaptor modified would have sufficed :-) i'm understanding this better now.

try these udev rules to prevent the BT module ID's from loading: first test: SUBSYSTEM=="usb", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="0305", TAG+="uaccess" second test: SUBSYSTEM=="usb", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="0305", ATTR{authorized}="0"

dmanlfc commented 11 months ago

ok doesn't look like anything we can bake into our OS to support this easily.

hankerde commented 10 months ago

Thank you for your work @spitsie . I also own the original Wii Bluetooth module and have exactly the same issue.

Any idea if your patch would work on Batocera v35 (on which I am at the moment)?

hankerde commented 10 months ago

I will create a patch for v35 with a how to setup. As soon i have some time by tomorrow, I will upload it πŸ‘

Thanks in advance, very much appreciated!

spitsie commented 10 months ago

I will create a patch for v35 with a how to setup. As soon i have some time by tomorrow, I will upload it πŸ‘

Thanks in advance, very much appreciated!

Here is the link

Choose your version and download the zip file wii bluetooth patch. Inside is a how to manual ✌️

hankerde commented 10 months ago

Here is the link .

Choose your version and download the zip file wii bluetooth patch. Inside is a how to manual ✌️

Thank you for your work, but sadly it doesn't work in my case (v35):

When I use the original btusb.ko, I have to re-pair my (original) Wiimotes each time I start Dolphin using the red button and the button on my USB-Module (I have this: https://www.abbiedoobie.com/product/bluetooth-passthrough-adapter/).

When I use the btusb.ko you provided, I can pair a Wiimote the first time I start Dolphin, but if I close it and reopen, the Wiimotes doesn't reconnect. Additionally I cannot re-pair the remote at all (the four LEDs just keep blinking)!

So I'm back to the original btusb.ko.

Perhaps you have any idea how to troubleshoot this. If not: do not hassle too much with it. I'm on an old version of Batocera and perhaps should update to v38 first.

Thanks though!

hankerde commented 10 months ago

After you placed the patched file, did you also did save the system overlay and then reboot the system? Only if you save the overlay and reboot the new patched file works.

So place the patched file. Then open the terminal in winscp and give the command batocera-save-overlay then you see a lot of text it's saving the overlay. If done, reboot batocera.

And it's also important to change the dolphin.ini file with dolphin closed.

Enter it exactly as I wrote it in de manual and save it.

I did exactly as written in your easy to follow manual. Except editing the Dolphin.ini using a Samba connection instead of WinSCP. And MobaXterm fΓΌr ssh (as I always do). batocera-save-overlay reported success. Made sure the kernel module was changed after rebooting (looked at it's date). Also tried deleting SYSCONF and rebooting like stated in the Manual.

There must have been some changes, as the Wiimote was always able to re-pair with the original btusb.ko module but never with the patched one. Strange.

I will try the further steps you wrote (I think tomorrow) and give feedback.

My Wiimotes are all originals.

spitsie commented 10 months ago

I will try the further steps you wrote (I think tomorrow) and give feedback.

My Wiimotes are all originals.

You are using a PC for batocera? That's where I made the patch for. If you use something else, like a raspberry, I don't know if the patch works. In that case send me your original btusb.ko file, so I can patch it for you.

But the only thing I patched is that the kernel doesn't load drivers for the Wii bluetooth. As the module shouldn't get drivers from the kernel, but from dolphin it self.

So probably there is something corrupted. If you follow the additional Stepps I told, it should work. Assuming you have the PC build version.

I have also to mention I tested it on a clean install from v35. So if the additional Stepps don't work for you. You can reset batocera to rename the folder system to system.old and reboot the system. Then it's like a fresh install. Then you can do all the Stepps in de manual again and test it it works. If yes, you know that there was some kind of corruption in your system.

You can easily revert the reset by deleting the new system folder and rename system.old back to system and reboot

Or you just copy the files you needed from system.old to system

But first try the additional steps I told you.

Good luck πŸ‘

hankerde commented 10 months ago

I'm on an x86_64. An i5-4690 with a GT1030, to be exact.

Just remembered: I had set up the Bluetooth adapter previously as in the Wiki of Batocera described (https://wiki.batocera.org/systems:wii#using_bluetooth_passthrough). Should I reverse something before trying again?

hankerde commented 10 months ago

Left it blank, know that document of the Dolphin Wiki (was the reason I went for the original Wii Bluetooth adapter).

Will test again as soon as I've got the time.

hankerde commented 10 months ago

So did some systematic troubleshooting.

What I expected the Wiimote to do (and perhaps this assumption was wrong): Connect automatically whenever I start a Wii game.

What I did each time I changed the btusb.ko:

Of course Dolphin was closed each time I did the above.

Behaviour with the original btusb.ko:

  1. When I start a game, I can pair a Wiimote.
  2. When I close a game and start the same or another game, the Wiimote is forgotten, but I can pair it again with the button on the Bluetooth adapter.
  3. This doesn't change after a reboot.

Behaviour with the patched btusb.ko:

  1. When I start a game the first time, I can pair a Wiimote.
  2. When I close a game and start the same or another game, the Wiimote does not reconnect. I've uploaded a short video here: https://youtu.be/xsQj7cmSjgo
  3. In this moment (having closed and opened a game), I cannot re-pair the Wiimote.
  4. After a reboot and starting any game, the Wiimote connects automatically. So it isn't forgotten.
  5. In this moment I can pair additional Wiimotes.
  6. Closing the game and opening the same or another leads to the result stated in 2.
  7. A reboot leads to the Wiimotes connecting like they should on the first start of a game, again.

Sooo... Your patch kinda works?

Did you test closing a game and restarting it without a reboot?

If this does indeed work in your case I will try resetting. Currently the system is in use by my family and they wouldn't be pleased with me messing around. ;-)

hankerde commented 10 months ago

Thanks again. Yes, I'm one step closer. πŸ˜… And do not bother with making a video about resetting and undoing a reset. Your description is really clear (and I have a little experience with Debian/Linux).

Could take a little bit until further testing (lots of work to be done the next week - including the weekend). But I will test it. Because I really like the Wii.

spitsie commented 10 months ago

Thanks again. Yes, I'm one step closer. πŸ˜… And do not bother with making a video about resetting and undoing a reset. Your description is really clear (and I have a little experience with Debian/Linux).

Could take a little bit until further testing (lots of work to be done the next week - including the weekend). But I will test it. Because I really like the Wii.

I'm just back from someone that had the same problem as you. I solved the problem and now it works for them.

Just downland the zip file again. I edited the manual inside the zip. There you see what I did to solve the problem for that person.

I guess it has something to do with the fact that they already used the Wii remotes before they used my patch. There was probably something wrong with the settings in Dolphin.

But see it your self if the new manual helps πŸ‘

n2qz commented 10 months ago

@spitsie Can you clarify what this thread is about? I'm pretty baffled, but after a month of reading this and a lot of searching, I have a guess - are you experiencing this issue when using an original Wii bluetooth module connected via USB to your computer and using that in Dolphin via passthrough?

spitsie commented 10 months ago

@spitsie Can you clarify what this thread is about? I'm pretty baffled, but after a month of reading this and a lot of searching, I have a guess - are you experiencing this issue when using an original Wii bluetooth module connected via USB to your computer and using that in Dolphin via passthrough?

Lol, I already removed some answer from me to make it shorter.

But yes if you use Dolphin in Batocera with the original bluetooth from Nintendo Wii in passtrough mode, pairings don't get remembered after you close a game.

I digged into it and found a solution and made a patched kernel to solve it. With the patched kernel the pairings are remembered.

In simple words: I blocked the original Wii bluetooth in the kernel, so it doesn't get the wrong drivers from the kernel, and now gets the Nintendo drivers if Dolphin start.

Here

you find the patch for v35 and v38 with manual. If you want to take a look.

hankerde commented 10 months ago

Greetings again!

I guess it has something to do with the fact that they already used the Wii remotes before they used my patch. There was probably something wrong with the settings in Dolphin.

But see it your self if the new manual helps πŸ‘

I had high hopes for your idea about deleting / re-initializing the Dolphin.ini, followed your steps by the letter, but encountered one problem in your HowTo (and in the end there was no change).

The problem was: If I open a game in dolphin-emu-config and Alt-Tab, I cannot select "Passthrough a Bluetooth adapter". It's greyed out. I can only select it when no game is running.

But I was able to pair my three Wiimotes nevertheless using the description. They were added in the Dolphin.ini as expected.

Sadly my problem persists: If I open a game, close it and open it (or another) again, the WiiMotes do not pair. Only after a reboot the pair, but only after the first Wii-game is started.

Could this be because of the 8bitDo-Controllers that are connected to my PC all the time (by cable, not Bluetooth)? Or that I configured them once (but not as a WiiMote) in dolphin-emu-config?

Another thing was that in the screenshots of Dolphin.ini your HowTo WiimoteContinuosScanning is set to false, in my case it always sets itself to true.

Nevertheless I think the best thing on my part will be a reset - or starting from scratch with v38. Especially the second option isn't a project for the next two weekends so please don't hold your breath until reading again from me. But I will get to it.

Thanks again for your support. BTW: No Bluetooth devices are listed as connected in my Batocera. So that's not the problem.

spitsie commented 10 months ago

Could this be because of the 8bitDo-Controllers that are connected to my PC all the time (by cable, not Bluetooth)? Or that I configured them once (but not as a WiiMote) in dolphin-emu-config?

Now you mention something that could conflict with the Wii motes indeed. In the per system settings there can be something wrong with the settings.

So if you are in the wii menu from Batocera and you open the per system settings. Then the controller settings. Custom pad profile and Wii mote emulation, all that should be set on auto. If you indeed have set to use Wii remote emulation in the settings to use a other remote. As the controller settings from batocera overwrite the settings from Dolphin if the are not set to auto.

(ps, I edited the manual how to do, and corrected the wrong values you mentioned)

gege-fr commented 9 months ago

Hello ,

Just wanted to thank you. It's working better than ever for me.

I always had difficulties connecting wiimotes in windows even thought I made the effort to solder an original Bluetooth module.

I switched to batocera hoping it would be better but it was worse.

With your fix once every device has been synced at least once, it seems to work perfectly πŸ‘

spitsie commented 9 months ago

Hello ,

Just wanted to thank you. It's working better than ever for me.

I always had difficulties connecting wiimotes in windows even thought I made the effort to solder an original Bluetooth module.

I switched to batocera hoping it would be better but it was worse.

With your fix once every device has been synced at least once, it seems to work perfectly πŸ‘

I'm glad to hear it worked for you. Don't forget if you update batocera, you lose the patch. Then you have to patch it again with the right kernel. If you used my link, there is also manual to patch the kernel from another version. πŸ‘

batoceragaming commented 8 months ago

@spitsie Thanks for your detailed guide. Is there any chance to update the patch file for Batocera V39? thanks

spitsie commented 7 months ago

@spitsie Thanks for your detailed guide. Is there any chance to update the patch file for Batocera V39? thanks

Hello, I was busy so I hadn't much time. But here you find also the patch for v39

thwonp commented 1 month ago

Hi @spitsie , any chance you could re-upload the manual you mentioned? I'd like to try this patch on Batocera 40, the links you provided have expired. Thanks!

spitsie commented 3 weeks ago

Hi @spitsie , any chance you could re-upload the manual you mentioned? I'd like to try this patch on Batocera 40, the links you provided have expired. Thanks!

Sorry for the late answer.

Here is the link. It's only up to v39. But there is a how to patch the kernel your self instruction in the zip files. So following my instructions, you can patch the kernel for v40.

I try to upload a patched kernel for v40 soon, as soon I have time to patch it.

Good luck 🀞