Add Turbo Mode Button remapping feature and "Other Mappings" submenu (#1006)

* Create Turbo Mode submenu under Button Mappings

"Enable Turbo Mode" was moved into this new menu.

* Add Turbo Mode Button remap to the Turbo Mode settings menu

* Rename the Turbo Mode Settings enum

* Remove an extra TriggerUpdate added by mistake

* Fix an edge case where Turbo could be activated on dpad up/left when nunchuck Z/C is mapped

* Rename the Turbo Mode submenu to "Other Mappings"

* Add an enumeration for the remappable buttons for Turbo Mode
This commit is contained in:
InfiniteBlueGX 2022-05-20 16:54:29 -05:00 committed by GitHub
parent 2e0df05e5d
commit 2dcea7e3bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 261 additions and 15 deletions

View File

@ -735,6 +735,85 @@ bool MenuRequested()
return false; return false;
} }
bool IsTurboModeInputPressed()
{
switch(GCSettings.TurboModeButton)
{
case TURBO_BUTTON_RSTICK:
return (
userInput[0].pad.substickX > 70 ||
userInput[0].WPAD_StickX(1) > 70 ||
userInput[0].wiidrcdata.substickX > 45);
case TURBO_BUTTON_A:
return (
userInput[0].wpad->btns_h & WPAD_CLASSIC_BUTTON_A ||
userInput[0].wpad->btns_h & WPAD_BUTTON_A ||
userInput[0].pad.btns_h & PAD_BUTTON_A ||
userInput[0].wiidrcdata.btns_h & WIIDRC_BUTTON_A);
case TURBO_BUTTON_B:
return (
userInput[0].wpad->btns_h & WPAD_CLASSIC_BUTTON_B ||
userInput[0].wpad->btns_h & WPAD_BUTTON_B ||
userInput[0].pad.btns_h & PAD_BUTTON_B ||
userInput[0].wiidrcdata.btns_h & WIIDRC_BUTTON_B);
case TURBO_BUTTON_X:
return (
userInput[0].wpad->btns_h & WPAD_CLASSIC_BUTTON_X ||
userInput[0].pad.btns_h & PAD_BUTTON_X ||
userInput[0].wiidrcdata.btns_h & WIIDRC_BUTTON_X);
case TURBO_BUTTON_Y:
return (
userInput[0].wpad->btns_h & WPAD_CLASSIC_BUTTON_Y ||
userInput[0].pad.btns_h & PAD_BUTTON_Y ||
userInput[0].wiidrcdata.btns_h & WIIDRC_BUTTON_Y);
case TURBO_BUTTON_L:
return (
userInput[0].wpad->btns_h & WPAD_CLASSIC_BUTTON_FULL_L ||
userInput[0].pad.btns_h & PAD_TRIGGER_L ||
userInput[0].wiidrcdata.btns_h & WIIDRC_BUTTON_L);
case TURBO_BUTTON_R:
return (
userInput[0].wpad->btns_h & WPAD_CLASSIC_BUTTON_FULL_R ||
userInput[0].pad.btns_h & PAD_TRIGGER_R ||
userInput[0].wiidrcdata.btns_h & WIIDRC_BUTTON_R);
case TURBO_BUTTON_ZL:
return (
userInput[0].wpad->btns_h & WPAD_CLASSIC_BUTTON_ZL ||
userInput[0].wiidrcdata.btns_h & WIIDRC_BUTTON_ZL);
case TURBO_BUTTON_ZR:
return (
userInput[0].wpad->btns_h & WPAD_CLASSIC_BUTTON_ZR ||
userInput[0].wiidrcdata.btns_h & WIIDRC_BUTTON_ZR);
case TURBO_BUTTON_Z:
return (
userInput[0].pad.btns_h & PAD_TRIGGER_Z ||
(userInput[0].wpad->exp.type == WPAD_EXP_NUNCHUK &&
userInput[0].wpad->btns_h & WPAD_NUNCHUK_BUTTON_Z));
case TURBO_BUTTON_C:
return (
userInput[0].wpad->exp.type == WPAD_EXP_NUNCHUK &&
userInput[0].wpad->btns_h & WPAD_NUNCHUK_BUTTON_C);
case TURBO_BUTTON_1:
return (
userInput[0].wpad->btns_h & WPAD_BUTTON_1);
case TURBO_BUTTON_2:
return (
userInput[0].wpad->btns_h & WPAD_BUTTON_2);
case TURBO_BUTTON_PLUS:
return (
userInput[0].wpad->btns_h & WPAD_CLASSIC_BUTTON_PLUS ||
userInput[0].wpad->btns_h & WPAD_BUTTON_PLUS ||
userInput[0].wiidrcdata.btns_h & WIIDRC_BUTTON_PLUS);
case TURBO_BUTTON_MINUS:
return (
userInput[0].wpad->btns_h & WPAD_CLASSIC_BUTTON_MINUS ||
userInput[0].wpad->btns_h & WPAD_BUTTON_MINUS ||
userInput[0].wiidrcdata.btns_h & WIIDRC_BUTTON_MINUS);
default:
return false;
}
}
/**************************************************************************** /****************************************************************************
* ReportButtons * ReportButtons
* *
@ -749,11 +828,7 @@ void ReportButtons ()
if (GCSettings.TurboModeEnabled == 1) if (GCSettings.TurboModeEnabled == 1)
{ {
Settings.TurboMode = ( Settings.TurboMode = IsTurboModeInputPressed();
userInput[0].pad.substickX > 70 ||
userInput[0].WPAD_StickX(1) > 70 ||
userInput[0].wiidrcdata.substickX > 45
); // RIGHT on c-stick and on classic controller right joystick
} }
if(Settings.TurboMode) { if(Settings.TurboMode) {

View File

@ -2459,7 +2459,7 @@ static int MenuSettingsMappings()
GuiImage mouseBtnIcon(&iconMouse); GuiImage mouseBtnIcon(&iconMouse);
GuiButton mouseBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight()); GuiButton mouseBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
mouseBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); mouseBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
mouseBtn.SetPosition(-125, 250); mouseBtn.SetPosition(-200, 250);
mouseBtn.SetLabel(&mouseBtnTxt); mouseBtn.SetLabel(&mouseBtnTxt);
mouseBtn.SetImage(&mouseBtnImg); mouseBtn.SetImage(&mouseBtnImg);
mouseBtn.SetImageOver(&mouseBtnImgOver); mouseBtn.SetImageOver(&mouseBtnImgOver);
@ -2476,7 +2476,7 @@ static int MenuSettingsMappings()
GuiImage justifierBtnIcon(&iconJustifier); GuiImage justifierBtnIcon(&iconJustifier);
GuiButton justifierBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight()); GuiButton justifierBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
justifierBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); justifierBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
justifierBtn.SetPosition(125, 250); justifierBtn.SetPosition(0, 250);
justifierBtn.SetLabel(&justifierBtnTxt); justifierBtn.SetLabel(&justifierBtnTxt);
justifierBtn.SetImage(&justifierBtnImg); justifierBtn.SetImage(&justifierBtnImg);
justifierBtn.SetImageOver(&justifierBtnImgOver); justifierBtn.SetImageOver(&justifierBtnImgOver);
@ -2487,6 +2487,21 @@ static int MenuSettingsMappings()
justifierBtn.SetTrigger(trig2); justifierBtn.SetTrigger(trig2);
justifierBtn.SetEffectGrow(); justifierBtn.SetEffectGrow();
GuiText otherBtnTxt("Other Mappings", 22, (GXColor){0, 0, 0, 255});
GuiImage otherBtnImg(&btnLargeOutline);
GuiImage otherBtnImgOver(&btnLargeOutlineOver);
GuiButton otherBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight());
otherBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
otherBtn.SetPosition(200, 250);
otherBtn.SetLabel(&otherBtnTxt);
otherBtn.SetImage(&otherBtnImg);
otherBtn.SetImageOver(&otherBtnImgOver);
otherBtn.SetSoundOver(&btnSoundOver);
otherBtn.SetSoundClick(&btnSoundClick);
otherBtn.SetTrigger(trigA);
otherBtn.SetTrigger(trig2);
otherBtn.SetEffectGrow();
GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255});
GuiImage backBtnImg(&btnOutline); GuiImage backBtnImg(&btnOutline);
GuiImage backBtnImgOver(&btnOutlineOver); GuiImage backBtnImgOver(&btnOutlineOver);
@ -2509,6 +2524,7 @@ static int MenuSettingsMappings()
w.Append(&superscopeBtn); w.Append(&superscopeBtn);
w.Append(&mouseBtn); w.Append(&mouseBtn);
w.Append(&justifierBtn); w.Append(&justifierBtn);
w.Append(&otherBtn);
w.Append(&backBtn); w.Append(&backBtn);
@ -2540,6 +2556,10 @@ static int MenuSettingsMappings()
menu = MENU_GAMESETTINGS_MAPPINGS_CTRL; menu = MENU_GAMESETTINGS_MAPPINGS_CTRL;
mapMenuCtrlSNES = CTRL_JUST; mapMenuCtrlSNES = CTRL_JUST;
} }
else if(otherBtn.GetState() == STATE_CLICKED)
{
menu = MENU_GAMESETTINGS_MAPPINGS_OTHER;
}
else if(backBtn.GetState() == STATE_CLICKED) else if(backBtn.GetState() == STATE_CLICKED)
{ {
menu = MENU_GAMESETTINGS; menu = MENU_GAMESETTINGS;
@ -3371,6 +3391,138 @@ static void ScreenPositionWindow()
delete(settingText); delete(settingText);
} }
static int MenuSettingsOtherMappings()
{
int menu = MENU_NONE;
int ret;
int i = 0;
bool firstRun = true;
OptionList options;
sprintf(options.name[i++], "Enable Turbo Mode");
sprintf(options.name[i++], "Turbo Mode Button");
options.length = i;
for(i=0; i < options.length; i++)
options.value[i][0] = 0;
GuiText titleTxt("Game Settings - Button Mappings", 26, (GXColor){255, 255, 255, 255});
titleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
titleTxt.SetPosition(50,30);
GuiText subtitleTxt("Other Mappings", 20, (GXColor){255, 255, 255, 255});
subtitleTxt.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
subtitleTxt.SetPosition(50,60);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM);
GuiSound btnSoundClick(button_click_pcm, button_click_pcm_size, SOUND_PCM);
GuiImageData btnOutline(button_png);
GuiImageData btnOutlineOver(button_over_png);
GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255});
GuiImage backBtnImg(&btnOutline);
GuiImage backBtnImgOver(&btnOutlineOver);
GuiButton backBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
backBtn.SetAlignment(ALIGN_LEFT, ALIGN_BOTTOM);
backBtn.SetPosition(50, -35);
backBtn.SetLabel(&backBtnTxt);
backBtn.SetImage(&backBtnImg);
backBtn.SetImageOver(&backBtnImgOver);
backBtn.SetSoundOver(&btnSoundOver);
backBtn.SetSoundClick(&btnSoundClick);
backBtn.SetTrigger(trigA);
backBtn.SetTrigger(trig2);
backBtn.SetEffectGrow();
GuiOptionBrowser optionBrowser(552, 248, &options);
optionBrowser.SetPosition(0, 108);
optionBrowser.SetCol2Position(200);
optionBrowser.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
HaltGui();
GuiWindow w(screenwidth, screenheight);
w.Append(&backBtn);
mainWindow->Append(&optionBrowser);
mainWindow->Append(&w);
mainWindow->Append(&titleTxt);
w.Append(&subtitleTxt);
ResumeGui();
while(menu == MENU_NONE)
{
usleep(THREAD_SLEEP);
ret = optionBrowser.GetClickedOption();
switch (ret)
{
case 0:
GCSettings.TurboModeEnabled ^= 1;
break;
case 1:
GCSettings.TurboModeButton++;
if (GCSettings.TurboModeButton > 14)
GCSettings.TurboModeButton = 0;
break;
}
if(ret >= 0 || firstRun)
{
firstRun = false;
sprintf (options.value[0], "%s", GCSettings.TurboModeEnabled == 1 ? "On" : "Off");
switch(GCSettings.TurboModeButton)
{
case 0:
sprintf (options.value[1], "Right Stick (default)"); break;
case 1:
sprintf (options.value[1], "A"); break;
case 2:
sprintf (options.value[1], "B"); break;
case 3:
sprintf (options.value[1], "X"); break;
case 4:
sprintf (options.value[1], "Y"); break;
case 5:
sprintf (options.value[1], "L"); break;
case 6:
sprintf (options.value[1], "R"); break;
case 7:
sprintf (options.value[1], "ZL"); break;
case 8:
sprintf (options.value[1], "ZR"); break;
case 9:
sprintf (options.value[1], "Z"); break;
case 10:
sprintf (options.value[1], "C"); break;
case 11:
sprintf (options.value[1], "1"); break;
case 12:
sprintf (options.value[1], "2"); break;
case 13:
sprintf (options.value[1], "Plus"); break;
case 14:
sprintf (options.value[1], "Minus"); break;
}
optionBrowser.TriggerUpdate();
}
if(backBtn.GetState() == STATE_CLICKED)
{
menu = MENU_GAMESETTINGS_MAPPINGS;
}
}
HaltGui();
mainWindow->Remove(&optionBrowser);
mainWindow->Remove(&w);
mainWindow->Remove(&titleTxt);
mainWindow->Remove(&subtitleTxt);
return menu;
}
static int MenuSettingsVideo() static int MenuSettingsVideo()
{ {
int menu = MENU_NONE; int menu = MENU_NONE;
@ -3389,7 +3541,6 @@ static int MenuSettingsVideo()
sprintf(options.name[i++], "Show Framerate"); sprintf(options.name[i++], "Show Framerate");
sprintf(options.name[i++], "Show Local Time"); sprintf(options.name[i++], "Show Local Time");
sprintf(options.name[i++], "SuperFX Overclock"); sprintf(options.name[i++], "SuperFX Overclock");
sprintf(options.name[i++], "Enable Turbo Mode");
options.length = i; options.length = i;
#ifdef HW_DOL #ifdef HW_DOL
@ -3498,11 +3649,6 @@ static int MenuSettingsVideo()
S9xResetSuperFX(); S9xResetSuperFX();
S9xReset(); S9xReset();
break; break;
case 10:
GCSettings.TurboModeEnabled++;
if (GCSettings.TurboModeEnabled > 1)
GCSettings.TurboModeEnabled = 0;
break;
} }
if(ret >= 0 || firstRun) if(ret >= 0 || firstRun)
@ -3557,7 +3703,6 @@ static int MenuSettingsVideo()
case 3: case 3:
sprintf (options.value[9], "60 MHz"); break; sprintf (options.value[9], "60 MHz"); break;
} }
sprintf (options.value[10], "%s", GCSettings.TurboModeEnabled == 1 ? "On" : "Off");
optionBrowser.TriggerUpdate(); optionBrowser.TriggerUpdate();
} }
@ -4521,6 +4666,9 @@ MainMenu (int menu)
case MENU_SETTINGS_NETWORK: case MENU_SETTINGS_NETWORK:
currentMenu = MenuSettingsNetwork(); currentMenu = MenuSettingsNetwork();
break; break;
case MENU_GAMESETTINGS_MAPPINGS_OTHER:
currentMenu = MenuSettingsOtherMappings();
break;
default: // unrecognized menu default: // unrecognized menu
currentMenu = MenuGameSelection(); currentMenu = MenuGameSelection();
break; break;

View File

@ -45,7 +45,8 @@ enum
MENU_GAMESETTINGS_MAPPINGS_MAP, MENU_GAMESETTINGS_MAPPINGS_MAP,
MENU_GAMESETTINGS_VIDEO, MENU_GAMESETTINGS_VIDEO,
MENU_GAMESETTINGS_AUDIO, MENU_GAMESETTINGS_AUDIO,
MENU_GAMESETTINGS_CHEATS MENU_GAMESETTINGS_CHEATS,
MENU_GAMESETTINGS_MAPPINGS_OTHER,
}; };
#endif #endif

View File

@ -155,6 +155,7 @@ preparePrefsData ()
createXMLSetting("sfxOverclock", "SuperFX Overclock", toStr(GCSettings.sfxOverclock)); createXMLSetting("sfxOverclock", "SuperFX Overclock", toStr(GCSettings.sfxOverclock));
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));
createXMLSection("Menu", "Menu Settings"); createXMLSection("Menu", "Menu Settings");
@ -339,6 +340,7 @@ decodePrefsData ()
loadXMLSetting(&GCSettings.xshift, "xshift"); loadXMLSetting(&GCSettings.xshift, "xshift");
loadXMLSetting(&GCSettings.yshift, "yshift"); loadXMLSetting(&GCSettings.yshift, "yshift");
loadXMLSetting(&GCSettings.TurboModeEnabled, "TurboModeEnabled"); loadXMLSetting(&GCSettings.TurboModeEnabled, "TurboModeEnabled");
loadXMLSetting(&GCSettings.TurboModeButton, "TurboModeButton");
// Audio Settings // Audio Settings
@ -533,6 +535,7 @@ DefaultSettings ()
Settings.TwoClockCycles = 12; Settings.TwoClockCycles = 12;
GCSettings.TurboModeEnabled = 1; // Enabled by default GCSettings.TurboModeEnabled = 1; // Enabled by default
GCSettings.TurboModeButton = 0; // Default is Right Analog Stick (0)
} }
/**************************************************************************** /****************************************************************************

View File

@ -63,6 +63,24 @@ enum
const char ctrlName[6][24] = const char ctrlName[6][24] =
{ "SNES Controller", "SNES Mouse", "Super Scope", "Justifier", "SNES Controllers (2)", "SNES Controllers (4)" }; { "SNES Controller", "SNES Mouse", "Super Scope", "Justifier", "SNES Controllers (2)", "SNES Controllers (4)" };
enum {
TURBO_BUTTON_RSTICK = 0,
TURBO_BUTTON_A,
TURBO_BUTTON_B,
TURBO_BUTTON_X,
TURBO_BUTTON_Y,
TURBO_BUTTON_L,
TURBO_BUTTON_R,
TURBO_BUTTON_ZL,
TURBO_BUTTON_ZR,
TURBO_BUTTON_Z,
TURBO_BUTTON_C,
TURBO_BUTTON_1,
TURBO_BUTTON_2,
TURBO_BUTTON_PLUS,
TURBO_BUTTON_MINUS,
};
enum { enum {
LANG_JAPANESE = 0, LANG_JAPANESE = 0,
LANG_ENGLISH, LANG_ENGLISH,
@ -124,6 +142,7 @@ struct SGCSettings{
int Interpolation; int Interpolation;
int TurboModeEnabled; // 0 - disabled, 1 - enabled int TurboModeEnabled; // 0 - disabled, 1 - enabled
int TurboModeButton;
}; };
void ExitApp(); void ExitApp();