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.39k stars 137 forks source link

Game cube controller "emulator" #149

Open cualquiercosa327 opened 3 years ago

cualquiercosa327 commented 3 years ago

Hi, excuse me, I know your program is only BT for now and wired is on the end of the Todo list. Also they are other module which simulate a pro controller wired (sys-con) but I don't know where I could ask this.

My question/doubts are related to the older gamecube + the adapter Nintendo released on Wii u for Smash, and recently they have allowed it on Mario Sunshine from Mario 3d All stars.

I would love could play this game using the analog tigers and using gyroscope for make better the pointing the aquapack. (an example would be using ds4, Dualsense,.. when they are full supported as they have analog triger and gyroscope. Sadly Nintendo drops the analog triger on Wii era and forgot about it)

If i connected the gc controller, press a key and the Switch recognized it as simply USB. I can navigate across the menu (also the homebrew ones) and launch and play some games (as Tetris 99).

I tried your programs for testing the HID but they did no detect anything (I suppose as they are only for BT devices). Also test "Device diagnostic" from the author of sys-con and it sees a new device, which I could obtain ID, pid and more data.

Would be very difficult add this option on a future with your program or it should need another kind of stuff?

A lot of thanks and excuse the question

ndeadly commented 3 years ago

No problem, this reads more as a feature request disguised as a question ;)

I've had a few people ask me about analog triggers already. I'm aware there are a few games that use them and support was recently added in an update for 3d Allstars.

I've actually been talking to one of the Yuzu devs about this just a couple of weeks ago. We're not exactly sure how it's handled by the system. There are no documented HID reports that have fields for trigger data as far as I know. The main problem is that I don't have the USB adapter or a GCN controller to figure out how the controller data is being sent over USB.

I'm hopeful it's just an undocumented format and can be generalised to Bluetooth controllers also. If this is the case it shouldn't be too hard to add support, I plan on adding the ability to pretend to be different controller types anyway. I've seen recently someone figured out how to make the Dualsense triggers emulate the travel of the real GCN controller triggers. That would be a super cool feature to add. I'm not sure whether the system would allow motion controls to be used with analog triggers though as the GCN controller doesn't have them.

If it's not possible over Bluetooth, it should at least be doable via USB once I know how it works. You'll obviously have to wait until I support that though. I don't think it would be possible with sys-con in its current state, as the virtual controller API that it uses is pretty limited and I doubt it has support for analog triggers.

Yeah, my applets for reading the HID data will only work for Bluetooth, I don't know whether the sys-con author has anything similar that can print the actual data. The devices IDs aren't of much use to me until I start implementing USB support.

cualquiercosa327 commented 3 years ago

Hi. I have a gc controller and the adapter. If you want I can make the test you need. Here you can see what the machine shows:

IMG-20201203-WA0000

and using the app sys-con has:

IMG-20201203-WA0001

I think this latest would be more useful. Anyway if you want, tell me what you need i test..

As you said I doubt the game allows motion control as the gc has not them, but they could be implemented as the right analog, making them work together to control the camera, using this output the right analog data. (Maybe a file descriptor for controller where one could create the configurations, would make it easier to support and maintaining)

ndeadly commented 3 years ago

What is more interesting to me is the actual data sent by the adapter. Packet captures of the communications would be useful if you are able to make them. This can be done on the switch using ilia, though it's a little involved to set up. You might also be able to use Wireshark to capture USB comms with a PC.

I will add some means of controller configuration in the future once the design is less prone to change. Though I can't say exactly what features it will support. I'm not sure how well motion controls -> right analog stick would work, but it could be worth looking into at some point.

cualquiercosa327 commented 3 years ago

OK, I am reading ilia documentation as I can no access to a pc during some days. Have you a compiled version of it? Thanks

About the gyro, we could ask help to gyro gaming web/discord people:

http://gyrowiki.jibbsmart.com.

ndeadly commented 3 years ago

Yeah I've got a compiled version somewhere I can give you, I'll find it later today when I'm not working. You'll need to add the offsets for the USB device calls for your firmware version to an ilia.ini file so ilia knows the commands to log. I can help you with this if you need it.

As for gyro, I don't really need any help with it I have PS4 gyro somewhat working. I just need to spend the time to figure out how to convert to the switch pro format properly and maybe deal with the calibration. It was more an issue of I don't know how well it would map to the analog stick. Games that use gyro for the camera usually reserve a button to recenter it to account for drift

cualquiercosa327 commented 3 years ago

Hi again, I remember than the program "hid to Vpad" of Wii u had a program to extract the data on any hid USB device conected: https://github.com/Maschell/hid_test Would be useful the information I could obtain from it for you?

While reading I saw than it has already supported to gamecube controller with the original adapter and others as myflash:

https://github.com/Maschell/controller_patcher/wiki/5.a-Controller-%7C-Configurate-the-GameCube-controller

ndeadly commented 3 years ago

If you can run that application it might be good enough. Depends what information it displays. It would be a good start though.

There still might be an initialisation process that takes place that I would need to emulate. It's possible there are different reporting modes and we would need to see how it behaves on switch.

cualquiercosa327 commented 3 years ago

OK, I will test it. If you can, compile ilia and I will test on Switch to see the initialisation process

ndeadly commented 3 years ago

Here's a build of ilia and an example .ini file with some USB offsets for 10.0.0 I was messing around with a while ago. The .ini goes in the root of your sd card. From memory something was causing crashes so I might have one or more of the offsets incorrect. You probably don't actually need to log from all of those interfaces. I don't know enough about USB to say which are the interesting ones though.

ilia.zip ilia-ini.zip

Edit: I just noticed I forgot to uncomment the title ID line in ilia.ini. Remove the ; from this line -> ;[title 0100000000000006]

cualquiercosa327 commented 3 years ago

Hi, oK I will test when I arrive to home. About the gyro, I think the website I posted (or simply the files from there) could help a lot as they have created a little library (JoyShockLibrary) and a program (JoyShockMapper) to support joycon, switch Pro and ds4 gyroscope data and it is ready to support other devices with gyroscope easily without change the code. From it you can use this info to convert any gyro data to switch pro format and the calibration.

https://github.com/JibbSmart

cualquiercosa327 commented 3 years ago

Hi, I tried it but it is unable to run Atmosphere. (I used two different versions of atmosphere but the result is the same) IMG-20201204-WA0000 IMG-20201204-WA0001

ndeadly commented 3 years ago

@cualquiercosa327 I would first make sure you don't have anything connected via USB, and comment out all the offset entries in ilia.ini and see if you can boot in order to rule out a compatibility issue with your HOS or Atmosphere versions.

If you're able to boot with that then I would add the offsets back in one at a time until you're not able to boot anymore. As I said earlier, some of them may be incorrect. I can't remember what state things were in when I was last messing with USB. Another possibility is that USB has changed in 10.0.2 and all my offsets are wrong. I'm 90% sure I located them on 10.0.0. Do you know what you're doing enough to be able to locate them by yourself and check?

cualquiercosa327 commented 3 years ago

Hi, I have test it and all the offsets are changed :-(. If I comment them, the system works (and it seems the process is using the ilia.ini as I can not delete directly on Switch with homebrew).

I have never do it, but I can try to locale them.

cualquiercosa327 commented 3 years ago

Hi, excuse me the delay : I have been too busy this week. Here is the file you asked. It was my fault as I did no "Remove the ; from this line -> ;[title 0100000000000006]" I had to comment this nn::usb::hs::IClientIfSession = 0xA06A0; nn::usb::hs::IClientEpSession = 0xA06A8; as they crash atmosphere when I connect the USB (I also have the Atmosphere report if you want) report.zip

ndeadly commented 3 years ago

@cualquiercosa327 no problem. I've actually been trying to capture USB traffic on 11.0.0 myself this week. As it turns out, there was a bug in Atmosphere's fatal service that was being triggered by this. That's now fixed in the latest Atmosphere release, but the USB module is still crashing when a controller is connected with Ilia running. I think the offsets are fine and it's an issue with something Ilia is doing. I'm hoping to try and resolve the issue with the help of the Ilia dev. Will keep you posted on any progress.

cualquiercosa327 commented 3 years ago

This is what happens if "nn::usb::hs::IClientIfSession = 0xA06A0; nn::usb::hs::IClientEpSession = 0xA06A8;" are no commented. This is the error than my switch shows: IMG-20201211-WA0002

Once I have commented them, everything is fine. If it was an issue of Atmosphere, would no be interesting content to Atmosphere's github?

If you need I make more test, only tell it. Ah, thanks for your great work!

ndeadly commented 3 years ago

Yeah, this is the error in fatal (title 0100000000000034) I mentioned above. It was fixed a day or two ago in Atmosphere. If you install the latest Atmosphere release (0.16.1) this should go away, and you should instead see a blue Atmosphere fatal error screen with the real error in the usb module (title 0100000000000006).

The issue has something to do with whatever Ilia is doing to make logging from those interfaces possible. When you comment out the lines specifying the offsets of those interfaces you are telling Ilia not to log anything, so it's similar to if you weren't running it at all.

RitschiRitsch commented 3 years ago

Is there any update on this? Adding support of analog triggers would definitely be great. Especially if it could be used with streaming clients like moonlight-nx. That would make the switch the perfect in-home streaming device.

ndeadly commented 3 years ago

@RitschiRitsch no, unfortunately not. There's currently an issue with Ilia when logging from the USB interfaces that prevents us from observing how the gamecube adapter communicates with the console. I've spoken with the dev about it but still waiting on a fix to be implemented. I'm hoping to find that there is a reporting format used that will also be accepted if sent via Bluetooth. If not then it may not be possible to make the Switch read the analog data.

As for clients like moonlight-nx, I would assume they would need to be modified to take the analog data into account too. There were recent-ish changes to libnx documenting some of the gamecube hid stuff, but I'm not sure whether anyone has looked into using it. I don't own a gamecube controller or the adapter to investigate myself.