Add a couple new controller remapping options (#1028)

* Add option to choose which button/combo is used to toggle the menu

* Add option to remap the ABXY buttons to the right analog stick
This commit is contained in:
InfiniteBlueGX 2022-10-09 20:46:32 -05:00 committed by GitHub
parent 59b1b4c795
commit d03164449b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 126 additions and 15 deletions

View File

@ -590,6 +590,50 @@ static void decodepad (int chan, int emuChan)
wiidrcp |= WIIDRC_BUTTON_RIGHT; wiidrcp |= WIIDRC_BUTTON_RIGHT;
#endif #endif
if (GCSettings.MapABXYRightStick == 1)
{
s8 pad_substickX = userInput[chan].pad.substickX;
s8 pad_substickY = userInput[chan].pad.substickY;
#ifdef HW_RVL
s8 wm_substickX = userInput[chan].WPAD_StickX(1);
s8 wm_substickY = userInput[chan].WPAD_StickY(1);
s16 wiidrc_substickX = userInput[chan].wiidrcdata.substickX;
s16 wiidrc_substickY = userInput[chan].wiidrcdata.substickY;
#endif
/* Gamecube Controller */
if (pad_substickY > ANALOG_SENSITIVITY)
jp |= PAD_BUTTON_X;
else if (pad_substickY < -ANALOG_SENSITIVITY)
jp |= PAD_BUTTON_B;
if (pad_substickX < -ANALOG_SENSITIVITY)
jp |= PAD_BUTTON_Y;
else if (pad_substickX > ANALOG_SENSITIVITY)
jp |= PAD_BUTTON_A;
#ifdef HW_RVL
/* Wii Controller */
if (wm_substickY > ANALOG_SENSITIVITY)
wp |= WPAD_CLASSIC_BUTTON_X;
else if (wm_substickY < -ANALOG_SENSITIVITY)
wp |= WPAD_CLASSIC_BUTTON_B;
if (wm_substickX < -ANALOG_SENSITIVITY)
wp |= WPAD_CLASSIC_BUTTON_Y;
else if (wm_substickX > ANALOG_SENSITIVITY)
wp |= WPAD_CLASSIC_BUTTON_A;
/* Wii U Gamepad */
if (wiidrc_substickY > ANALOG_SENSITIVITY)
wiidrcp |= WIIDRC_BUTTON_X;
else if (wiidrc_substickY < -ANALOG_SENSITIVITY)
wiidrcp |= WIIDRC_BUTTON_B;
if (wiidrc_substickX < -ANALOG_SENSITIVITY)
wiidrcp |= WIIDRC_BUTTON_Y;
else if (wiidrc_substickX > ANALOG_SENSITIVITY)
wiidrcp |= WIIDRC_BUTTON_A;
#endif
}
/*** Fix offset to pad ***/ /*** Fix offset to pad ***/
offset = ((emuChan + 1) << 4); offset = ((emuChan + 1) << 4);
@ -713,6 +757,38 @@ static void decodepad (int chan, int emuChan)
bool MenuRequested() bool MenuRequested()
{ {
for(int i=0; i<4; i++) for(int i=0; i<4; i++)
{
if (GCSettings.GamepadMenuToggle == 1) // Home (WiiPad) or Right Stick (GC/3rd party gamepad) only
{
if (
(userInput[i].pad.substickX < -70)
#ifdef HW_RVL
|| (userInput[i].wpad->btns_h & WPAD_BUTTON_HOME) ||
(userInput[i].wpad->btns_h & WPAD_CLASSIC_BUTTON_HOME) ||
(userInput[i].wiidrcdata.btns_h & WIIDRC_BUTTON_HOME)
#endif
)
{
return true;
}
}
else if (GCSettings.GamepadMenuToggle == 2) // L+R+Start combo only (frees up the right stick on GC/3rd party gamepad)
{
if (
(userInput[i].pad.btns_h & PAD_TRIGGER_L &&
userInput[i].pad.btns_h & PAD_TRIGGER_R &&
userInput[i].pad.btns_h & PAD_BUTTON_START)
#ifdef HW_RVL
|| (userInput[i].wpad->btns_h & WPAD_CLASSIC_BUTTON_FULL_L &&
userInput[i].wpad->btns_h & WPAD_CLASSIC_BUTTON_FULL_R &&
userInput[i].wpad->btns_h & WPAD_CLASSIC_BUTTON_PLUS)
#endif
)
{
return true;
}
}
else // All toggle options enabled
{ {
if ( if (
(userInput[i].pad.substickX < -70) || (userInput[i].pad.substickX < -70) ||
@ -732,6 +808,9 @@ bool MenuRequested()
return true; return true;
} }
} }
}
return false; return false;
} }

View File

@ -3403,6 +3403,8 @@ static int MenuSettingsOtherMappings()
sprintf(options.name[i++], "Enable Turbo Mode"); sprintf(options.name[i++], "Enable Turbo Mode");
sprintf(options.name[i++], "Turbo Mode Button"); sprintf(options.name[i++], "Turbo Mode Button");
sprintf(options.name[i++], "Menu Toggle");
sprintf(options.name[i++], "Map ABXY to Right Stick");
options.length = i; options.length = i;
@ -3468,6 +3470,16 @@ static int MenuSettingsOtherMappings()
if (GCSettings.TurboModeButton > 14) if (GCSettings.TurboModeButton > 14)
GCSettings.TurboModeButton = 0; GCSettings.TurboModeButton = 0;
break; break;
case 2:
GCSettings.GamepadMenuToggle++;
if (GCSettings.GamepadMenuToggle > 2)
GCSettings.GamepadMenuToggle = 0;
break;
case 3:
GCSettings.MapABXYRightStick ^= 1;
break;
} }
if(ret >= 0 || firstRun) if(ret >= 0 || firstRun)
@ -3509,6 +3521,18 @@ static int MenuSettingsOtherMappings()
sprintf (options.value[1], "Minus"); break; sprintf (options.value[1], "Minus"); break;
} }
switch(GCSettings.GamepadMenuToggle)
{
case 0:
sprintf (options.value[2], "Default (All Enabled)"); break;
case 1:
sprintf (options.value[2], "Home / Right Stick"); break;
case 2:
sprintf (options.value[2], "L+R+Start"); break;
}
sprintf (options.value[3], "%s", GCSettings.MapABXYRightStick == 1 ? "On" : "Off");
optionBrowser.TriggerUpdate(); optionBrowser.TriggerUpdate();
} }

View File

@ -159,6 +159,8 @@ preparePrefsData ()
createXMLSetting("Interpolation", "Interpolation", toStr(GCSettings.Interpolation)); createXMLSetting("Interpolation", "Interpolation", toStr(GCSettings.Interpolation));
createXMLSetting("TurboModeEnabled", "Turbo Mode Enabled", toStr(GCSettings.TurboModeEnabled)); createXMLSetting("TurboModeEnabled", "Turbo Mode Enabled", toStr(GCSettings.TurboModeEnabled));
createXMLSetting("TurboModeButton", "Turbo Mode Button", toStr(GCSettings.TurboModeButton)); createXMLSetting("TurboModeButton", "Turbo Mode Button", toStr(GCSettings.TurboModeButton));
createXMLSetting("GamepadMenuToggle", "Gamepad Menu Toggle", toStr(GCSettings.GamepadMenuToggle));
createXMLSetting("MapABXYRightStick", "Map ABXY Right Stick", toStr(GCSettings.MapABXYRightStick));
createXMLSection("Menu", "Menu Settings"); createXMLSection("Menu", "Menu Settings");
@ -347,6 +349,8 @@ decodePrefsData ()
loadXMLSetting(&GCSettings.yshift, "yshift"); loadXMLSetting(&GCSettings.yshift, "yshift");
loadXMLSetting(&GCSettings.TurboModeEnabled, "TurboModeEnabled"); loadXMLSetting(&GCSettings.TurboModeEnabled, "TurboModeEnabled");
loadXMLSetting(&GCSettings.TurboModeButton, "TurboModeButton"); loadXMLSetting(&GCSettings.TurboModeButton, "TurboModeButton");
loadXMLSetting(&GCSettings.GamepadMenuToggle, "GamepadMenuToggle");
loadXMLSetting(&GCSettings.MapABXYRightStick, "MapABXYRightStick");
// Audio Settings // Audio Settings
@ -545,6 +549,8 @@ DefaultSettings ()
GCSettings.TurboModeEnabled = 1; // Enabled by default GCSettings.TurboModeEnabled = 1; // Enabled by default
GCSettings.TurboModeButton = 0; // Default is Right Analog Stick (0) GCSettings.TurboModeButton = 0; // Default is Right Analog Stick (0)
GCSettings.GamepadMenuToggle = 0; // 0 = All options (default), 1 = C-Stick left, 2 = R+L+Start
GCSettings.MapABXYRightStick = 0;
} }
/**************************************************************************** /****************************************************************************

View File

@ -146,6 +146,8 @@ struct SGCSettings{
int TurboModeEnabled; // 0 - disabled, 1 - enabled int TurboModeEnabled; // 0 - disabled, 1 - enabled
int TurboModeButton; int TurboModeButton;
int GamepadMenuToggle;
int MapABXYRightStick;
}; };
void ExitApp(); void ExitApp();