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

[Feature Request]: Assign D-Pad to R-stick when Nunchuck is Connected #653

Open NeilAgar opened 1 year ago

NeilAgar commented 1 year ago

Feature Description

When a nunchuck is connected, I'd like the option to change the WiiMote's D-pad into the virtual controller's R-stick.

Rationale

Hopefully, this would be as close as possible to how the normal WiiMote turns its D-pad into the L-stick when a nunchuck is not connected.

Additional Details

If this is already possible within the system settings or config files, please let me know how to do so.

NeilAgar commented 1 year ago

I'm not able to make the C code myself as troubleshooting the environment settings would take me hours, but I believe all that needs to be modified is wii_controller.cpp. The else statement on line 180 could be changed to the following to turn the d-pad into the r-stick without choice:

else {
            m_buttons.A = buttons->A;
            m_buttons.B = buttons->B;

            if ((m_extension == WiiExtensionController_ClassicPro) || (m_extension == WiiExtensionController_MotionPlusClassicControllerPassthrough)) {
                // Allow buttons one and two to be used for L3/R3 when Classic or Classic Pro controller connected
                m_buttons.lstick_press = buttons->one;
                m_buttons.rstick_press = buttons->two;

                m_buttons.dpad_down  = buttons->dpad_down;
                m_buttons.dpad_up    = buttons->dpad_up;
                m_buttons.dpad_right = buttons->dpad_right;
                m_buttons.dpad_left  = buttons->dpad_left;
            } else {
                // Not the best mapping but at least most buttons are mapped to something when nunchuck is connected.
                m_buttons.R  = buttons->one;
                m_buttons.ZR = buttons->two;

                m_right_stick.SetData(
                    dpad_stick_positions[1 + buttons->dpad_right - buttons->dpad_left],
                    dpad_stick_positions[1 + buttons->dpad_down - buttons->dpad_up]
                );
            }

            m_buttons.minus = buttons->minus;
            m_buttons.plus  = buttons->plus;

            m_buttons.home = buttons->home;
        }

This code just changes the dpad buttons to be set depending on the extension that is connected. This else statement is already contained within a section of code that knows that there is an extension connected to the WiiMote. If the extension is not the nunchuck, it sets the d-pad as normal. If it IS the nunchuck, then it sets the r-stick to the d-pad buttons.

I've also attached a file of the changed cpp if that would be preferable. Would it be possible to send a compiled version of the project with this changed file?

Thank you

Banz99 commented 1 year ago

Hey, I've compiled it for you (based on the changed cpp): MissionControl-0.9.2-rsticknunchuck-fe31665.zip

Anyway, I was discussing with ndeadly about a more customizable way to handle different mappings based on controller extensions plugged. That might end up mattering just for the wiimote, but we're trying to figure out what the best course of action for this is.

NeilAgar commented 1 year ago

Thank you so much!

Yeah, I found that a lot of games required control schemes that the default switch mapper wasn't flexible enough to handle. A built-in homebrew applet or config editable mapper would be much appreciated for situations like this - I'll let you know if this build works.