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.54k stars 139 forks source link

[Feature Request]: Unlock remapping of Gamecube controllers via the official adapter (or otherwise) #432

Open MutantAura opened 2 years ago

MutantAura commented 2 years ago

Feature Description

Removal of the, fairly arbitrary, restriction to not allow Gamecube Controllers to be remapped via HOS.

Rationale

As a speedrunner/strat finder of a couple of N64 games it would be really helpful to actually be able to use a GCC on the NSO services and beyond in a normal manner. As an example in a game like Ocarina of Time it is currently impossible to press "Z" or target on a Gamecube controller due to some unfortunate mapping choices.

If there is a technical reason why the official GCC adapter + OEM controller cannot remap like this, I also wondered about the "PC Mode" of certain 3rd party adapters such as the Mayflash variant here. This also displays as "cannot be remapped" even though I'm fairly confident the Mayflash should just be reporting it as a generic HID controller.

Additional Details

My apologies if this has been asked to death! I can find an issue relating to the Gamecube controller and another simply on 3rd party pro controllers that seem to share this issue. I'm willing to put in some time to test things etc. if this is helpful. The above adapter I linked is what I'm currently using but I also got myself an 8bitdo as well to get around the issue. This isnt ideal however as lots of people have a regular USB adapter and don't really want to buy a switch specific one just for this :)

Masamune3210 commented 2 years ago

Unofficial controllers get mapped in as Pro Controllers, as that's the type of controller most third party adapters already map into, so that's probably at least part of the choice, that and its the one that most closely matches most controllers

ndeadly commented 2 years ago

I suspect that achieving this may be quite a bit more complex than you might expect.

Currently, I see the following problems:

  1. As of now, Mission Control only supports Bluetooth Controllers. As far as I am aware, Gamecube controllers can only be connected via a USB adapter? While USB support is planned for the future, I currently have no mechanism for intercepting data coming from USB controllers.

  2. Gamecube controllers are handled as a special case in HOS, separately to all other controller types. It's probably possibly to masquerade them as a Pro Controller for example via intercepting the initial USB packets and some other mitm shennanigans, but then they would be handled via the code path for regular controllers. You would lose support for analog triggers and probably break rumble too.

  3. Being handled as a spedial case may also be the reason that remapping is disabled in the first place. It's quite likely the remapping code wasn't designed with Gamecube controllers in mind and doesn't get called in the code for handling them. I doubt it's as simple as just setting a boolean value to switch it on/off. You would probably have to patch in code for remapping from the data format used by these controllers. The Gamecube layout would also not be reflected by the remapping GUI. This would require a bunch of RE work to the hid module and possible some of the system applets for handling controllers too.

If there is a technical reason why the official GCC adapter + OEM controller cannot remap like this, I also wondered about the "PC Mode" of certain 3rd party adapters such as the Mayflash variant here. This also displays as "cannot be remapped" even though I'm fairly confident the Mayflash should just be reporting it as a generic HID controller.

PC Mode is probably just sending input reports in a more standard DINPUT/XINPUT format for PCs to read, rather than Nintendo's own format. I don't know what the Mayflash adapter looks like to the console, but if it's anything other than an official Pro controller this is probably the reason. They don't even allow remapping for officially licensed third party Pro Controllers. This is probably something that can be addressed via mitm once I support USB.

I understand the value in a feature like this, and will keep this open in case this becomes more feasible in the future or somebody else wants to investigate, but right now something like this is pretty low priority for me with given the amount of work vs the utility to the average user.

impeeza commented 2 years ago

You can use the 8bitDo GBros. Wireless Adapter for Switch to connect an original wired GameCube controller to switch by wireless, the switch sees it as a Pro Controller so can be mapped.

If you use a USB adapter also emulates a Pro Controller.

If you are thinking about the "Nintendo Game Cube Controller Super Smash Bros." that controller should not be intercepted by Mission Control for the same reason the Pro Controller isn't, is better to do not mess with the original protocol and will affect any other original controller including the Joy Cons.

MutantAura commented 2 years ago

I suspect that achieving this may be quite a bit more complex than you might expect.

Currently, I see the following problems:

  1. As of now, Mission Control only supports Bluetooth Controllers. As far as I am aware, Gamecube controllers can only be connected via a USB adapter? While USB support is planned for the future, I currently have no mechanism for intercepting data coming from USB controllers.
  2. Gamecube controllers are handled as a special case in HOS, separately to all other controller types. It's probably possibly to masquerade them as a Pro Controller for example via intercepting the initial USB packets and some other mitm shennanigans, but then they would be handled via the code path for regular controllers. You would lose support for analog triggers and probably break rumble too.
  3. Being handled as a spedial case may also be the reason that remapping is disabled in the first place. It's quite likely the remapping code wasn't designed with Gamecube controllers in mind and doesn't get called in the code for handling them. I doubt it's as simple as just setting a boolean value to switch it on/off. You would probably have to patch in code for remapping from the data format used by these controllers. The Gamecube layout would also not be reflected by the remapping GUI. This would require a bunch of RE work to the hid module and possible some of the system applets for handling controllers too.

If there is a technical reason why the official GCC adapter + OEM controller cannot remap like this, I also wondered about the "PC Mode" of certain 3rd party adapters such as the Mayflash variant here. This also displays as "cannot be remapped" even though I'm fairly confident the Mayflash should just be reporting it as a generic HID controller.

PC Mode is probably just sending input reports in a more standard DINPUT/XINPUT format for PCs to read, rather than Nintendo's own format. I don't know what the Mayflash adapter looks like to the console, but if it's anything other than an official Pro controller this is probably the reason. They don't even allow remapping for officially licensed third party Pro Controllers. This is probably something that can be addressed via mitm once I support USB.

I understand the value in a feature like this, and will keep this open in case this becomes more feasible in the future or somebody else wants to investigate, but right now something like this is pretty low priority for me with given the amount of work vs the utility to the average user.

Thank you for the quick response and I totally understand the priority! I'm happy to leave this open as like I say I personally already have a somewhat viable solution to this in the form of a GCC -> Pro controller adapter anyway.

You can use the 8bitDo GBros. Wireless Adapter for Switch to connect an original wired GameCube controller to switch by wireless, the switch sees it as a Pro Controller so can be mapped.

If you use a USB adapter also emulates a Pro Controller.

If you are thinking about the "Nintendo Game Cube Controller Super Smash Bros." that controller should not be intercepted by Mission Control for the same reason the Pro Controller isn't, is better to do not mess with the original protocol and will affect any other original controller including the Joy Cons.

I guess this depends on what the maintainers vision for the tool is. A lot of other HID projects have semi-died and I perhaps naively assumed that MC would eventually want to become the "All-in-one" controller homebrew at some arbitrary point in time. Either way I'll leave the issue open if for nothing else than to stop others opening similar :)

ndeadly commented 2 years ago

I guess this depends on what the maintainers vision for the tool is. A lot of other HID projects have semi-died and I perhaps naively assumed that MC would eventually want to become the "All-in-one" controller homebrew at some arbitrary point in time. Either way I'll leave the issue open if for nothing else than to stop others opening similar :)

No, you are correct in your assumptions. In addition to regular Bluetooth I hope to eventually be able to support both Bluetooth LE and USB controllers and to have various options for reconfiguring them.