ndeadly / MissionControl

Use controllers from other consoles natively on your Nintendo Switch via Bluetooth. No dongles or other external hardware neccessary.
GNU General Public License v2.0
2.53k stars 139 forks source link

Adding support for the Xbox Elite Controller 2 #3

Closed ricardoramo-s closed 3 years ago

ricardoramo-s commented 4 years ago

Since the Elite Controller 2 has native Bluetooth support and the controller is pretty similar to the regular Xbox Controller (don't quote me on that) you could add support for it?

ndeadly commented 4 years ago

I didn't realise there was a Bluetooth version of the Elite Controller. It's probably just a matter of whitelisting the hardware ID.

If you have one could you attempt to pair it via the Controllers->Change Grip/Order screen, then use btdb.nro provided with the release to dump the Bluetooth database and post a screenshot here.

shyiro commented 4 years ago

I've got the Elite Controller 2, and we can't pair him, so we can't get any enter on the Bluetooth database

ndeadly commented 4 years ago

@shyiro even though the controller might not appear to connect to the switch, it should be possible to complete the pairing process with the console and get it stored in the database. It will only show up as a connected controller if a handler gets installed for it, which requires a match against the hardware ID to determine the controller type.

shyiro commented 4 years ago

ok i see, but i've try a lot of time to pairing him, but the controller keep blink and no enter in the database for him. i don't know if it's linked, but, when i try to pairing him, and go to btdb.nro for see if he is here, sometime i get a crash of atmosphere.

ndeadly commented 4 years ago

MissionControl-0.1.0-xbox-one-elite-2.zip I've whitelisted a hardware id I found online that appears to be the Elite Controller v2. See if this build makes any difference for you. Also might be worth making sure your controller firmware is up to date

shyiro commented 4 years ago

doesn't work, Atmosphere keep crashing a few seconds after i try to pair him

ndeadly commented 4 years ago

Hmm, that's odd. Can you post the fatal report here so that I can see what's crashing and where?

shyiro commented 4 years ago

photo_2020-08-28_09-23-34

the crash come randomly after i try to pair him, if i stay in the controller menu, or in the hbmenu, anywhere i go, it's crashed a few seconds after try to pair.

ndeadly commented 4 years ago

Thanks. I'll check it out when I have some time.

For future reference, it's much better if you post the report log file that gets written to your SD card under atmosphere\fatal_reports. That way I can use automated tools to inspect it rather than having to key in the addresses manually ;)

shyiro commented 4 years ago

oh sorry, i didn't know that ^^

01598542087_010000000000002a.log

victorgneves commented 4 years ago

MissionControl-0.1.0-xbox-one-elite-2.zip I've whitelisted a hardware id I found online that appears to be the Elite Controller v2. See if this build makes any difference for you. Also might be worth making sure your controller firmware is up to date

This modification was very useful. Friend of mine only managed to connect his control with this version, and it is not an elite control. It is a normal Xbox One controller. Maybe it's a slightly different version.

ndeadly commented 4 years ago

@victorgneves that's strange, is it an official Microsoft controller? As far as I can remember, the only change I made for this build was adding the ID {0x045e, 0x0b00} to the whitelist for Xbox One controllers. Can your friend dump their Bluetooth database with btdb.nro and post it here?

ndeadly commented 4 years ago

@shyiro try this build with logging enabled, and post the resulting btdrv-mitm.log from your SD root here. Note that the log gets wiped on console boot, so if your switch crashes you will need to either pull the SD out and read it in a computer, or mount it from hekate to read it before booting.

MissionControl-0.1.0-debug-logging.zip

pblop commented 4 years ago

I've got the same controller, and get (seemingly) the same crash (I go to change grip/order, try to pair my controller, and when I try to return to the main menu, it crashes). Here's my atmosphere fatal log 01549653030_010000000000002a.log And here's my btdrv-mitm.log (from the last build you sent) btdrv-mitm.log

ndeadly commented 4 years ago

Thanks @PabloPerezRodriguez . Unfortunately, nothing too interesting in those logs. It looks like it might just try to pair twice and then crash. Could you try with this new build with more verbose logging of the pairing process?

MissionControl-0.1.0-debug-logging2.zip

elad0elad commented 4 years ago

First thank you for the great work, second I join the request to add the elite v2 to the supported list please

ndeadly commented 4 years ago

@elad0elad you could try running the build I've posted above and post your log. I can't add support if I can't figure out why it won't connect. I don't own this controller myself.

pblop commented 4 years ago

Sorry for the delay, my SD Card got corrupted and I was trying to recover my data (didnt work).

I tried again with the new build. These are the logs. btdrv-mitm.log 01550003809_010000000000002a.log I also noticed Atmosphere creates crashdumps, not sure if you want that, I'm not uploading it here because I don't know if it contains console specific info.

elad0elad commented 4 years ago

@elad0elad you could try running the build I've posted above and post your log. I can't add support if I can't figure out why it won't connect. I don't own this controller myself.

I've been trying this and still don't work friend, there is any thing I can do to help the progress?

ndeadly commented 4 years ago

Sorry guys, I'm busy preparing some other things for the next release at the moment. I want to knock you up a homebrew application to do the bluetooth pairing myself and see if we can at least avoid the crash for further debugging. Give me a day or two.

@PabloPerezRodriguez thanks for the logs. Looks like you're getting authentication failure status events before the crash. Not exactly sure what could cause this. Reading around a bit it kind of seems a bit like the QC on the elite controller is worse than the standard ones that come with the xbox. I don't think you've mentioned whether your controller is on the latest firmware or not? Make sure it's up to date as it sounds like there have been improvements to the bluetooth function over time.

You can upload the Atmosphere crashdumps too if you want. At the moment I don't really need them as the stack trace is enough, but they might prove useful if I end up having to dive deeper into the disassembly to figure out what's going wrong.

pblop commented 4 years ago

It is on the latest firmware. And don't worry about time, I can wait!

elad0elad commented 4 years ago

There is an option to add the controller by enter the Mac address manually?

ndeadly commented 4 years ago

@elad0elad no, the pairing process has to complete with the controller to exchange link keys with the console.

tomlube commented 4 years ago

I can't even get my Elite 2 to connect at all :(

symalekos commented 4 years ago

i tried so may times to pair my elite 2 controller with the console but no luck. The controller is blinking like its searching to pair but no luck.Also i try the btdb.nro program but it says no paired bluetooth devises

ndeadly commented 4 years ago

Hey guys, sorry it's taken so long. Other things have got in the way.

Here's a little homebrew app I made to reimplement the pairing process. It's not perfect and may have some bugs, but hopefully it won't crash if you try to pair the elite controller. See if you can manage to get it to do anything interesting. A successful pairing will show the device info in green. It creates a log at sdmc://bluetooth_pairing.log that you can upload here for me to take a look at.

bluetooth_pair.zip

Dallas-J commented 4 years ago

bluetooth_pairing.log

Here's a log - I left it running for a bit just in case some logs were different than others. Thanks for doing all this man!

ndeadly commented 4 years ago

@Dallas-J thanks for the log. I assume this didn't crash on you then by the looks of that log? I probably should have timestamped it.

Looks as though it's continually failing the authentication step. Here are a few versions I built tweaking the parameters to the authentication response. I don't see why this controller should be different to any other, but I guess it can't hurt to try. Let me know if you find success with any of these.

bluetooth_pair_A.zip bluetooth_pair_B.zip bluetooth_pair_C.zip bluetooth_pair_D.zip

elad0elad commented 4 years ago

bluetooth_pairing.log here's my log, allready try all 4 version and the one thet you upload earlier, nothing change

ndeadly commented 4 years ago

@elad0elad damn, this controller really doesn't want to work.

Are any of you guys able to pair this controller on linux and share the pairing info? This might help understand if there's anything different to a regular Xbox One controller. I'm also thinking a workaround might be to pair the controller under switch linux and inject the info into the database under HOS.

Dallas-J commented 4 years ago

bluetoothctl.log

I'm uploading this from switchroot - is this what you're looking for? I had just disconnected the controller so it failed to pair at first.

kylefmohr commented 4 years ago

Is this what you're looking for @ndeadly ? Let me know if I can provide additional information

hcitool info.log

ndeadly commented 4 years ago

@Dallas-J , @kylefmohr sorry if there was confusion from me asking for logs earlier. That was mostly for diagnosing what was going on under HOS. What I'm actually after from linux is the equivalent to what would get stored in the HOS bluetooth database. I don't know if it's the same across most distros, but under ubuntu this can be found at /var/lib/bluetooth/<host_address>/<client_address>/info. My hope is that I might be able to find all the necessary info in here to translate to the switch database format and inject it into the database under HOS. I'd still like to figure out why the pairing fails on HOS, but this could act as a workaround for you guys in the meantime. The ability to do this would also be useful for people running switch linux or emuMMC who want to synchronise their pairing databases.

kylefmohr commented 4 years ago

Like this?

root@kyle:/var/lib/bluetooth/98:B6:E9:AA:35:57/98:7A:14:5B:35:BF# cat info [General] Name=Xbox Elite Wireless Controller Class=0x000508 SupportedTechnologies=BR/EDR; Trusted=true Blocked=false

[DeviceID] Source=2 Vendor=1118 Product=2821 Version=1032

[LinkKey] Key=16E555BC220168E6E8C85E9C6D55A716 Type=4 PINLength=0

This was taken from L4T Ubuntu on my Switch.

ndeadly commented 4 years ago

@kylefmohr yeah that's perfect. I'll try to finish writing some tools to try this out after I'm done with work today.

kylefmohr commented 4 years ago

Hi @ndeadly, just wanted to see if there was any additional information I could provide to assist with adding this controller to MissionControl.

Thanks for all of your hard work so far. I’d be happy to send another donation once this is added 🙂

ndeadly commented 4 years ago

Hey, sorry for the lack of updates. I've written a python script to dump the database from L4T and have some basic functionality to import it back into HOS, but it doesn't seem to work in all cases for some reason. In particular I couldn't get my regular Xbox One controller to be recognised. I need to do more research. I will try to dedicate a bit more time to look into it this week. It's hard when I don't own the controller

You could check for me if any of the changes I made in 0.3.0 have made any difference to the pairing situation if you like. Thanks for your support :)

kylefmohr commented 4 years ago

No worries! I will try 0.3.0 tonight and let you know if there's any noticeable change. I'd be happy to test the L4T and HOS script for you once it's ready, if that would help.

kylefmohr commented 4 years ago

No change on 0.3.0 unfortunately, still not detected.

ndeadly commented 4 years ago

@kylefmohr yeah not all that surprising. Just wishful thinking on my part that the thread priority bug I solved in 0.3.0 may have been to blame.

Robert2282 commented 4 years ago

Hey I was wondering if you made any progress on the elite controller. I'm guessing the controller does some strange stuff when paring because I also have the mayflash switch Bluetooth adapter and I think its got a unique pairing process as it took around 15-30 seconds to pair. Also here a quote from their pairing guide for the elite controller

I hope this helps

pearagit commented 3 years ago

Hey I was wondering if you made any progress on the elite controller. I'm guessing the controller does some strange stuff when paring because I also have the mayflash switch Bluetooth adapter and I think its got a unique pairing process as it took around 15-30 seconds to pair. Also here a quote from their pairing guide for the elite controller

* It may take a longer time to connect your Xbox Elite 2 and Magic-S adapter. And the connection may be disconnected shortly (The lights on the controller and the adapter flash) and then connect again during the Bluetooth pairing process. Please wait patiently until  the LED indicators on the controller and the adapter stop flashing.

I hope this helps

To add to this line of thinking, I use switch up adapter for it's bluetooth capabilities and it pairs without delay with xbox elite controller 2 to the adapter, and then a couple second delay before the controller led stops flashing.

goodwind commented 3 years ago

Good day! Is there any progress in pairing Elite v2 Controller? If you need any assistance I could help by launching some tools or scripts and providing you it's output.

ndeadly commented 3 years ago

Hey, sorry, no major updates. I've been sick the past week or so, so not a lot of dev work being done. I'm slowly working towards having a gui application that will allow exporting and importing the controller database amongst other things. It might be possible to use this to restore the pairing info from l4t, but it's also possible that controller is being rejected by the console during connection for some other reason. It might require patching of the bluetooth service. This is a difficult problem to solve without access to the controller to be able to live debug the connection process.

kylefmohr commented 3 years ago

Is this something we could crowdfund for you? It's a very nice controller, albeit pricey. I'm in for $10, anybody else? And is this something you're interested in @ndeadly ?

Failing that, I have a fair amount of Bluetooth receivers, access to any VM you might need, and at least adequate knowledge of how all these things work (though I know almost nothing about the nitty gritty of Bluetooth connections). Would you want to remote into a VM I host and you could instruct me to put the controller in pairing/move files to the Switch as needed? Just a thought, I'm willing to help however I can.

ndeadly commented 3 years ago

@kylefmohr if people wanted to crowdfund the controller for me so that I can dig deeper I'd happily accept. It needs to be made clear though that this will not necessarily guarantee a solution. The last thing I want is people feeling that I owe them any results because of it.

While I appreciate the offer of remote access, I don't think it's really practical. A lot of this work can require staring at decompiler output for hours and messing around in gdb, but also rapid testing of new ideas and iterating upon them. The delay/overhead from having to communicate every little thing, plus needing you there the whole time on standby would quickly frustrate us both.

kylefmohr commented 3 years ago

@kylefmohr if people wanted to crowdfund the controller for me so that I can dig deeper I'd happily accept. It needs to be made clear though that this will not necessarily guarantee a solution

Yes, absolutely. Something I was taking for granted, but it's definitely a good idea to mention. Chipping in != guaranteed support for the controller (or any guarantees, really)

A lot of this work can require staring at decompiler output for hours and messing around in gdb, but also rapid testing of new ideas and iterating upon them.

That makes sense.

goodwind commented 3 years ago

plus needing you there the whole time on standby would quickly frustrate us both.

I am totally agree, but if you will need to test something or make some dump don't hesitate to contact me. I can't afford to crowdfund something with money, but I could sacrifice some of my free time

ndeadly commented 3 years ago

Just thought of something else to try...

If someone with an Android phone could try and connect the controller to their phone with the HCI snoop log enabled that might provide us with some additional info. The Android Bluetooth stack is similar to the one used by the Switch.

shyiro commented 3 years ago

here is mine btsnoop_hci.log