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

Adding support for the Xbox Elite Controller 2 #3

Closed
ricardoramo-s opened this issue Aug 27, 2020 · 151 comments
Closed

Adding support for the Xbox Elite Controller 2 #3

ricardoramo-s opened this issue Aug 27, 2020 · 151 comments

Comments

@ricardoramo-s
Copy link

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
Copy link
Owner

ndeadly commented Aug 27, 2020

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
Copy link

shyiro commented Aug 27, 2020

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
Copy link
Owner

ndeadly commented Aug 27, 2020

@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
Copy link

shyiro commented Aug 27, 2020

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
Copy link
Owner

ndeadly commented Aug 27, 2020

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
Copy link

shyiro commented Aug 28, 2020

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

@ndeadly
Copy link
Owner

ndeadly commented Aug 28, 2020

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

@shyiro
Copy link

shyiro commented Aug 28, 2020

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
Copy link
Owner

ndeadly commented Aug 28, 2020

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
Copy link

shyiro commented Aug 28, 2020

oh sorry, i didn't know that ^^

01598542087_010000000000002a.log

@ndeadly ndeadly added the feature request New feature or request label Aug 28, 2020
@victorgneves
Copy link

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
Copy link
Owner

ndeadly commented Aug 29, 2020

@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
Copy link
Owner

ndeadly commented Aug 29, 2020

@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
Copy link

pblop commented Sep 2, 2020

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
Copy link
Owner

ndeadly commented Sep 2, 2020

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
Copy link

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

@ndeadly
Copy link
Owner

ndeadly commented Sep 6, 2020

@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
Copy link

pblop commented Sep 6, 2020

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
Copy link

@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
Copy link
Owner

ndeadly commented Sep 7, 2020

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
Copy link

pblop commented Sep 8, 2020

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

@elad0elad
Copy link

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

@ndeadly
Copy link
Owner

ndeadly commented Sep 14, 2020

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

@tomlube
Copy link

tomlube commented Sep 16, 2020

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

@symalekos
Copy link

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
Copy link
Owner

ndeadly commented Sep 20, 2020

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
Copy link

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
Copy link
Owner

ndeadly commented Sep 21, 2020

@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

@tomlube
Copy link

tomlube commented Oct 29, 2022

Sorry, unsure what you mean by Non-LE. Controller firmware is 5.13.3143.0

@ndeadly
Copy link
Owner

ndeadly commented Oct 29, 2022

The controller firmware from 5.x.x.x onwards converts the controller to use Bluetooth LE which isn't supported by mission control. You need to downgrade for it to work

@alint77
Copy link

alint77 commented Oct 30, 2022

Need XBE2 patches for 15.0.0 tested. Can anyone confirm whether the controller can be paired on 15.0.0 with them installed? Thanks.

Hi! just tried it with my XBE2 4.x FW on 15.0.0 with patches and it crashes the CFW when you try to pair with the controller :
Screen Shot 2022-10-30 at 2 02 05 PM

@ndeadly
Copy link
Owner

ndeadly commented Oct 30, 2022

@alint77 thanks for the report. I'll have another look over my patches in conjunction with this and see if I can find where I've messed up.

@ndeadly
Copy link
Owner

ndeadly commented Oct 30, 2022

@alint77 try this

mc_1500_exefs_patches_2.zip

@alint77
Copy link

alint77 commented Oct 30, 2022

@alint77 try this

mc_1500_exefs_patches_2.zip

This time it doesn't crash but wont pair either.
DS4 works as intended

@ndeadly
Copy link
Owner

ndeadly commented Oct 30, 2022

@alint77 try this
mc_1500_exefs_patches_2.zip

This time it doesn't crash but wont pair either. DS4 works as intended

That's progress. I had a bug where a couple of branches weren't being corrected. I've looked over my patch code and offsets carefully and can't see anything obviously wrong with the code. Try this one. No actual patch logic was changed, but I swapped the order of the Wii code and the Xbox code so that the Xbox code now pretty much sits in one contiguous piece of memory. Maybe there's a bug in my script for spltting the code across free memory chunks that's messing up the logic.

And please double check the exact controller firmware you have so that neither of us is wasting our time here.

mc_1500_exefs_patches_3.zip

@alint77
Copy link

alint77 commented Oct 31, 2022

@ndeadly unfortunately i'm traveling today and can't test it. I'll be back home tomorrow.

I'm 100% sure about the firmware tho.

@alint77
Copy link

alint77 commented Nov 1, 2022

@alint77 try this
mc_1500_exefs_patches_2.zip

This time it doesn't crash but wont pair either. DS4 works as intended

That's progress. I had a bug where a couple of branches weren't being corrected. I've looked over my patch code and offsets carefully and can't see anything obviously wrong with the code. Try this one. No actual patch logic was changed, but I swapped the order of the Wii code and the Xbox code so that the Xbox code now pretty much sits in one contiguous piece of memory. Maybe there's a bug in my script for spltting the code across free memory chunks that's messing up the logic.

And please double check the exact controller firmware you have so that neither of us is wasting our time here.

mc_1500_exefs_patches_3.zip

ok so i just tested the new patch and still no luck.

ds4 pairs but XBE2 doesn't.

triple checked the controller firmware , it is in fact running v4.8.

controller pairs and works with my phone and my macbook.

is there any chance I'm missing something?

@Banz99
Copy link
Contributor

Banz99 commented Nov 1, 2022

@alint77 try this
mc_1500_exefs_patches_2.zip

This time it doesn't crash but wont pair either. DS4 works as intended

That's progress. I had a bug where a couple of branches weren't being corrected. I've looked over my patch code and offsets carefully and can't see anything obviously wrong with the code. Try this one. No actual patch logic was changed, but I swapped the order of the Wii code and the Xbox code so that the Xbox code now pretty much sits in one contiguous piece of memory. Maybe there's a bug in my script for spltting the code across free memory chunks that's messing up the logic.
And please double check the exact controller firmware you have so that neither of us is wasting our time here.
mc_1500_exefs_patches_3.zip

ok so i just tested the new patch and still no luck.

ds4 pairs but XBE2 doesn't.

triple checked the controller firmware , it is in fact running v4.8.

controller pairs and works with my phone and my macbook.

is there any chance I'm missing something?

Pairing of Xbox Controllers in general doesn't seem to that immediate on my end, can you try keeping it in pairing mode while on the Controllers->Change Grip/Order window for a bit longer?

@ndeadly
Copy link
Owner

ndeadly commented Nov 1, 2022

Waiting for clarification, but this user claims it's working for them #519 (comment)

is there any chance I'm missing something?

I'm not really sure, I've also checked my patches several times using various methods and I can't see anything obviously wrong or different from previous firmwares. Are you giving the controller plenty of time and trying again once it stops flashing? Xbox controllers can sometimes take a bit longer than others to get connected.

Unfortunately all of this stuff takes place deep within the bluetooth stack, so the only true way to debug it is to, well, attach a debugger while the controller is pairing. I don't own one so that's kind of out of the question. You could try my debug build of 0.8.0 and see if there's potentially some other failure independent of the actual authenitcation I'm patching. Post the mc-mitm.log file this creates on your sd card after attempting to pair the controller.

@alint77
Copy link

alint77 commented Nov 1, 2022

@alint77 try this
mc_1500_exefs_patches_2.zip

This time it doesn't crash but wont pair either. DS4 works as intended

That's progress. I had a bug where a couple of branches weren't being corrected. I've looked over my patch code and offsets carefully and can't see anything obviously wrong with the code. Try this one. No actual patch logic was changed, but I swapped the order of the Wii code and the Xbox code so that the Xbox code now pretty much sits in one contiguous piece of memory. Maybe there's a bug in my script for spltting the code across free memory chunks that's messing up the logic.
And please double check the exact controller firmware you have so that neither of us is wasting our time here.
mc_1500_exefs_patches_3.zip

ok so i just tested the new patch and still no luck.
ds4 pairs but XBE2 doesn't.
triple checked the controller firmware , it is in fact running v4.8.
controller pairs and works with my phone and my macbook.
is there any chance I'm missing something?

Pairing of Xbox Controllers in general doesn't seem to that immediate on my end, can you try keeping it in pairing mode while on the Controllers->Change Grip/Order window for a bit longer?

i waited untill controller went into idle mode.

seeing the other thread i just reinstalled Mission Control and retried patch#2 and still no luck... it's extremely odd since my switch is running the exact same version of everything as that person's...

im completely at a loss here

@ndeadly
Copy link
Owner

ndeadly commented Nov 1, 2022

@alint77 I think the other guy may have been mistaken, he said he cleared his pairing database and now it's not working. I think he might have already had the controller paired and it connected to the console rather than entering pairing mode.

I'm not really sure where to go from here, as I can't really tell what's going on without debugging on-console. Try that debug build I suggested in the previous post just to rule out some other issue that I do have some kind of control over.

@corybsa
Copy link

corybsa commented Nov 1, 2022

@ndeadly @alint77 I was mistaken. I tried the various patch files and it is not pairing. What debug build are you talking about? I'm also not afraid of poking around the code if there's any way I can help debug this. I've never done any development on the switch but I learn quick.

@ndeadly
Copy link
Owner

ndeadly commented Nov 1, 2022

@corybsa linked here #3 (comment)

It's not really an issue of development, but of debugging the running process in gdb and crossreferencing with the decompilation in IDA or Ghidra. Happy for you try, but it's a lot to have to try and explain to somebody with no familiarity.

@corybsa
Copy link

corybsa commented Nov 1, 2022

@ndeadly That does sound like a lot to explain to a noob. Here's my mc-mitm.log file.

@ndeadly
Copy link
Owner

ndeadly commented Nov 1, 2022

@ndeadly That does sound like a lot to explain to a noob. Here's my mc-mitm.log file.

Yeah, it's just trying to connect over and over with a generic pairing failure code.

Soooo... there may have been an off by one error in my branches. Try this new one
mc_1500_exefs_patches_4.zip

@alint77
Copy link

alint77 commented Nov 1, 2022

@ndeadly That does sound like a lot to explain to a noob. Here's my mc-mitm.log file.

Yeah, it's just trying to connect over and over with a generic pairing failure code.

Soooo... there may have been an off by one error in my branches. Try this new one mc_1500_exefs_patches_4.zip

Hallelujah!

it works ! took around 30 seconds to connect...

i salute you sir 🥇

@corybsa
Copy link

corybsa commented Nov 1, 2022

@ndeadly That patch works for me too! Only took a few seconds to connect for me.

@ndeadly
Copy link
Owner

ndeadly commented Nov 1, 2022

Nice! Can one of you confirm that this also works? I just swapped the order of the patches back again
mc_1500_exefs_patches_5.zip

And for future me, and anyone else wondering what happened - when installing a hook/detour you need to overwrite an instruction to branch to your injected code. Upon returning to the original function you need to execute this overwritten instruction so as not to change the original code behaviour. In restructuring my patches I had to tweak the way some branch offsets were computed and referred back to my comments that said "jump forward to return statement". While this is technically correct regarding the operation of my code, it ignores the fact that we have this extra instruction to execute prior to returning. Derp.

@corybsa
Copy link

corybsa commented Nov 1, 2022

Just to make sure, I wiped my bluetooth pairing database before installing patch 5, and reverted back to the non-debug build. The controller still successfully pairs.

@alint77
Copy link

alint77 commented Nov 1, 2022

Nice! Can one of you confirm that this also works? I just swapped the order of the patches back again mc_1500_exefs_patches_5.zip

And for future me, and anyone else wondering what happened - when installing a hook/detour you need to overwrite an instruction to branch to your injected code. Upon returning to the original function you need to execute this overwritten instruction so as not to change the original code behaviour. In restructuring my patches I had to tweak the way some branch offsets were computed and referred back to my comments that said "jump forward to return statement". While this is technically correct regarding the operation of my code, it ignores the fact that we have this extra instruction to execute prior to returning. Derp.

i did the same as @corybsa and it does indeed connect after 20 or so seconds.

@ndeadly
Copy link
Owner

ndeadly commented Nov 1, 2022

Perfect! I think we can conclude that my patch generation scripts are working correctly now. Should be just a matter of finding the new offsets going forward. Big thanks to both of you 😘

it does indeed connect after 20 or so seconds.

Strange, I wonder why yours takes so much longer

@corybsa
Copy link

corybsa commented Nov 1, 2022

No problem, glad to help!

I think the pairing time has something to do with the controller. Mine does take longer to pair sometimes and has actually taken a few pairing attempts in the past. But as long as I can use my fancy Xbox controller on my Switch I won't complain!

@alint77
Copy link

alint77 commented Nov 1, 2022

Perfect! I think we can conclude that my patch generation scripts are working correctly now. Should be just a matter of finding the new offsets going forward. Big thanks to both of you 😘

it does indeed connect after 20 or so seconds.

Strange, I wonder why yours takes so much longer

Thank you for your dedication and this awesome piece of software.
i wish i could somehow help with the code too but this is way out of my depth unfortunately...

as to why it takes longer , i have no idea but the least i can do is to install the debug version and send you the log file if you think it could help.

@ndeadly
Copy link
Owner

ndeadly commented Nov 1, 2022

No problem. Good testing is important too.

i have no idea but the least i can do is to install the debug version and send you the log file if you think it could help.

No point. It will be something deeper in the stack that I can't log, probably related to the parameters used by the controller. Any chance of improving it would involve further debugging of the process with the controller attached and likely more patching. Absolutely not worth the time so that someone can save a few seconds waiting for the controller to pair.

@alint77
Copy link

alint77 commented Nov 1, 2022

No problem. Good testing is important too.

i have no idea but the least i can do is to install the debug version and send you the log file if you think it could help.

No point. It will be something deeper in the stack that I can't log, probably related to the parameters used by the controller. Any chance of improving it would involve further debugging of the process with the controller attached and likely more patching. Absolutely not worth the time so that someone can save a few seconds waiting for the controller to pair.

yes that's true. also i just installed the debug build and it paired much faster , around 4-5 seconds which made me think maybe there's some level of randomness involved , either way its a waste of time.

@ndeadly
Copy link
Owner

ndeadly commented Nov 1, 2022

It's probably some function of the scan interval used by the console vs the advertise interval used by the controller + other factors. I imagine the interval used console-side is optimised for the switch controllers so I doubt I'd want to mess with that anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests