GaryOderNichts / Bloopair

Allows connecting controllers from other consoles like native Wii U Pro Controllers on the Wii U
GNU General Public License v2.0
354 stars 12 forks source link

Switch SNES Controller Support #16

Closed NoahOberstein closed 3 years ago

NoahOberstein commented 3 years ago

I believe the Switch SNES Controller (bluetooth) can work with Bloopair. As a proof of concept I edited this block of code in controllers.c to allow the controller to pair:

if ((_strncmp((const char*) name, "Pro Controller", 0x40) == 0) || // switch pro controller
            (_strncmp((const char*) name, "SNES Controller", 0x40) == 0) || // switch snes controller
            (_strncmp((const char*) name, "Joy-Con (R)", 0x40) == 0) || // joycon r
            (_strncmp((const char*) name, "Joy-Con (L)", 0x40) == 0)) { // joycon l
            controllerInit_switch(&controllers[handle], 
                _strncmp((const char*) name, "Pro Controller", 0x40) == 0 || _strncmp((const char*) name, "SNES Controller", 0x40) == 0, // add in snes stuff
                _strncmp((const char*) name, "Joy-Con (R)", 0x40) == 0);
            return 0;
        }

and disabled this check in switch_controller.c:

//if (!isProController) {
        // The pro controller already sends continous reports but the joy-con don't
        initContinuousReports(controller);
    //}

My guess is that the controller is laid out like a Switch Pro Controller missing a few buttons. Forcing the initContinuousReports function to run regardless of switch controller type fixed issues with buttons being stuck on the SNES controller. I've tested it on my own Wii U, playing a virtual console game, and everything seems to work.

Obviously this is a bit of a hacky implementation, but it shows it can be done.

Thanks for making this awesome project!

GaryOderNichts commented 3 years ago

Ah good to know. The next release will use vendor and product IDs instead of names, so support for the SNES controller should be easily addable. I've also reworked the reporting process quite a bit.

I will look into supporting it in the next release.

GaryOderNichts commented 3 years ago

Should be working with Bloopair version 0.2.0.