diff --git a/source/fceugx.h b/source/fceugx.h index 425e483..0bd06cc 100644 --- a/source/fceugx.h +++ b/source/fceugx.h @@ -79,6 +79,24 @@ enum LANG_LENGTH }; +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, +}; + struct SGCSettings { int AutoLoad; @@ -123,6 +141,8 @@ struct SGCSettings int PreviewImage; int HideRAMSaving; int TurboModeEnabled; // 0 - disabled, 1 - enabled + int TurboModeButton; + int GamepadMenuToggle; }; void ExitApp(); diff --git a/source/gui/gui.h b/source/gui/gui.h index d14483d..152faf4 100644 --- a/source/gui/gui.h +++ b/source/gui/gui.h @@ -435,7 +435,7 @@ class GuiElement //!Called constantly to redraw the element's tooltip virtual void DrawTooltip(); protected: - GuiTrigger * trigger[3]; //!< GuiTriggers (input actions) that this element responds to + GuiTrigger * trigger[5]; //!< GuiTriggers (input actions) that this element responds to UpdateCallback updateCB; //!< Callback function to call when this element is updated GuiElement * parentElement; //!< Parent element int focus; //!< Element focus (-1 = focus disabled, 0 = not focused, 1 = focused) diff --git a/source/gui/gui_button.cpp b/source/gui/gui_button.cpp index 7a0b9f2..9f8df08 100644 --- a/source/gui/gui_button.cpp +++ b/source/gui/gui_button.cpp @@ -255,7 +255,7 @@ void GuiButton::Update(GuiTrigger * t) if(this->IsClickable()) { s32 wm_btns, wm_btns_trig, cc_btns, cc_btns_trig, wiidrc_btns, wiidrc_btns_trig; - for(int i=0; i<3; i++) + for(int i=0; i<5; i++) { if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan)) { @@ -310,7 +310,7 @@ void GuiButton::Update(GuiTrigger * t) bool held = false; s32 wm_btns, wm_btns_h, wm_btns_trig, cc_btns, cc_btns_h, cc_btns_trig, wiidrc_btns, wiidrc_btns_h, wiidrc_btns_trig; - for(int i=0; i<3; i++) + for(int i=0; i<5; i++) { if(trigger[i] && (trigger[i]->chan == -1 || trigger[i]->chan == t->chan)) { diff --git a/source/gui/gui_element.cpp b/source/gui/gui_element.cpp index 9efb1c1..82a4a5d 100644 --- a/source/gui/gui_element.cpp +++ b/source/gui/gui_element.cpp @@ -31,6 +31,8 @@ GuiElement::GuiElement() trigger[0] = NULL; trigger[1] = NULL; trigger[2] = NULL; + trigger[3] = NULL; + trigger[4] = NULL; parentElement = NULL; rumble = true; selectable = false; @@ -362,6 +364,10 @@ void GuiElement::SetTrigger(GuiTrigger * t) trigger[1] = t; else if(!trigger[2]) trigger[2] = t; + else if(!trigger[3]) + trigger[3] = t; + else if(!trigger[4]) + trigger[4] = t; else // all were assigned, so we'll just overwrite the first one trigger[0] = t; } diff --git a/source/menu.cpp b/source/menu.cpp index ca60606..653d33d 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -79,6 +79,7 @@ static GuiText * settingText2 = NULL; static int lastMenu = MENU_NONE; static int mapMenuCtrl = 0; static int mapMenuCtrlNES = 0; +static bool showCredits = false; static lwp_t guithread = LWP_THREAD_NULL; static lwp_t progressthread = LWP_THREAD_NULL; @@ -802,7 +803,7 @@ SettingWindow(const char * title, GuiWindow * w) ***************************************************************************/ static void WindowCredits(void * ptr) { - if(btnLogo->GetState() != STATE_CLICKED) + if(btnLogo->GetState() != STATE_CLICKED && !showCredits) return; btnLogo->ResetState(); @@ -820,7 +821,7 @@ static void WindowCredits(void * ptr) creditsBoxImg.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); creditsWindowBox.Append(&creditsBoxImg); - int numEntries = 26; + int numEntries = 27; GuiText * txt[numEntries]; txt[i] = new GuiText("Credits", 30, (GXColor){0, 0, 0, 255}); @@ -849,8 +850,10 @@ static void WindowCredits(void * ptr) txt[i]->SetPosition(335,y); i++; y+=24; txt[i] = new GuiText("Additional improvements"); txt[i]->SetPosition(40,y); i++; - txt[i] = new GuiText("Zopenko, Askot, others"); - txt[i]->SetPosition(335,y); i++; y+=48; + txt[i] = new GuiText("Zopenko, Askot,"); + txt[i]->SetPosition(335,y); i++; y+=24; + txt[i] = new GuiText("InfiniteBlue, others"); + txt[i]->SetPosition(335,y); i++; y+=24; txt[i] = new GuiText("FCE Ultra GX GameCube"); txt[i]->SetPosition(40,y); i++; @@ -936,6 +939,7 @@ static void WindowCredits(void * ptr) (userInput[3].wpad->btns_d || userInput[3].pad.btns_d || userInput[3].wiidrcdata.btns_d)) { exit = true; + showCredits = false; } usleep(THREAD_SLEEP); } @@ -1385,7 +1389,11 @@ static int MenuGame() GuiImageData batteryBar(battery_bar_png); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0, WIIDRC_BUTTON_HOME); + GuiTrigger trigB; + GuiTrigger trig1; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, PAD_BUTTON_START, WIIDRC_BUTTON_HOME); + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); GuiText saveBtnTxt("Save", 22, (GXColor){0, 0, 0, 255}); GuiImage saveBtnImg(&btnLargeOutline); @@ -1505,6 +1513,8 @@ static int MenuGame() closeBtn.SetTrigger(trigA); closeBtn.SetTrigger(trig2); closeBtn.SetTrigger(&trigHome); + closeBtn.SetTrigger(&trigB); + closeBtn.SetTrigger(&trig1); closeBtn.SetEffectGrow(); #ifdef HW_RVL @@ -1826,8 +1836,12 @@ static int MenuGameSaves(int action) GuiImageData btnCloseOutlineOver(button_small_over_png); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0, WIIDRC_BUTTON_HOME); - + GuiTrigger trigB; + GuiTrigger trig1; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, PAD_BUTTON_START, WIIDRC_BUTTON_HOME); + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -1841,6 +1855,8 @@ static int MenuGameSaves(int action) backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiText closeBtnTxt("Close", 20, (GXColor){0, 0, 0, 255}); @@ -2102,8 +2118,12 @@ static int MenuGameSettings() GuiImageData btnCloseOutlineOver(button_small_over_png); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0, WIIDRC_BUTTON_HOME); - + GuiTrigger trigB; + GuiTrigger trig1; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, PAD_BUTTON_START, WIIDRC_BUTTON_HOME); + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText mappingBtnTxt("Button Mappings", 22, (GXColor){0, 0, 0, 255}); mappingBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); GuiImage mappingBtnImg(&btnLargeOutline); @@ -2220,6 +2240,8 @@ static int MenuGameSettings() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); HaltGui(); @@ -2336,8 +2358,12 @@ static int MenuGameCheats() GuiImageData btnCloseOutlineOver(button_small_over_png); GuiTrigger trigHome; - trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0, WIIDRC_BUTTON_HOME); - + GuiTrigger trigB; + GuiTrigger trig1; + trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, PAD_BUTTON_START, WIIDRC_BUTTON_HOME); + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -2351,6 +2377,8 @@ static int MenuGameCheats() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiOptionBrowser optionBrowser(552, 248, &options); @@ -2411,6 +2439,11 @@ static int MenuSettingsMappings() GuiImageData iconNESController(icon_settings_nescontroller_png); GuiImageData iconZapper(icon_settings_zapper_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText nesBtnTxt("NES Controller", 22, (GXColor){0, 0, 0, 255}); nesBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); GuiImage nesBtnImg(&btnLargeOutline); @@ -2447,6 +2480,21 @@ static int MenuSettingsMappings() zapperBtn.SetTrigger(trig2); zapperBtn.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(0, 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}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -2460,6 +2508,8 @@ static int MenuSettingsMappings() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); HaltGui(); @@ -2467,6 +2517,7 @@ static int MenuSettingsMappings() w.Append(&titleTxt); w.Append(&nesBtn); w.Append(&zapperBtn); + w.Append(&otherBtn); w.Append(&backBtn); @@ -2488,6 +2539,10 @@ static int MenuSettingsMappings() menu = MENU_GAMESETTINGS_MAPPINGS_CTRL; mapMenuCtrlNES = CTRL_ZAPPER; } + else if(otherBtn.GetState() == STATE_CLICKED) + { + menu = MENU_GAMESETTINGS_MAPPINGS_OTHER; + } else if(backBtn.GetState() == STATE_CLICKED) { menu = MENU_GAMESETTINGS; @@ -2527,6 +2582,11 @@ static int MenuSettingsMappingsController() GuiImageData iconWiiupro(icon_settings_wiiupro_png); GuiImageData iconDrc(icon_settings_drc_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText gamecubeBtnTxt("GameCube Controller", 22, (GXColor){0, 0, 0, 255}); gamecubeBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-30); GuiImage gamecubeBtnImg(&btnLargeOutline); @@ -2652,6 +2712,8 @@ static int MenuSettingsMappingsController() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); HaltGui(); @@ -3301,6 +3363,162 @@ static void ScreenPositionWindow() 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"); + sprintf(options.name[i++], "Menu Toggle"); + + 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); + + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + + 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.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); + 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; + + case 2: + GCSettings.GamepadMenuToggle++; + if (GCSettings.GamepadMenuToggle > 2) + GCSettings.GamepadMenuToggle = 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; + } + + 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; + } + + 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() { int menu = MENU_NONE; @@ -3319,7 +3537,6 @@ static int MenuSettingsVideo() sprintf(options.name[i++], "Zapper Crosshair"); sprintf(options.name[i++], "Sprite Limit"); sprintf(options.name[i++], "Video Mode"); - sprintf(options.name[i++], "Enable Turbo Mode"); options.length = i; for(i=0; i < options.length; i++) @@ -3334,6 +3551,11 @@ static int MenuSettingsVideo() GuiImageData btnOutline(button_png); GuiImageData btnOutlineOver(button_over_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -3347,6 +3569,8 @@ static int MenuSettingsVideo() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiOptionBrowser optionBrowser(552, 248, &options); @@ -3418,9 +3642,6 @@ static int MenuSettingsVideo() if(GCSettings.videomode > 4) GCSettings.videomode = 0; break; - case 10: - GCSettings.TurboModeEnabled ^= 1; - break; } if(ret >= 0 || firstRun) @@ -3480,7 +3701,6 @@ static int MenuSettingsVideo() case 4: sprintf (options.value[9], "PAL (60Hz)"); break; } - sprintf (options.value[10], "%s", GCSettings.TurboModeEnabled == 1 ? "On" : "Off"); optionBrowser.TriggerUpdate(); } @@ -3524,6 +3744,11 @@ static int MenuSettings() GuiImageData iconNetwork(icon_settings_network_png); GuiImageData iconCheats(icon_game_cheats_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText savingBtnTxt1("Saving", 22, (GXColor){0, 0, 0, 255}); GuiText savingBtnTxt2("&", 18, (GXColor){0, 0, 0, 255}); GuiText savingBtnTxt3("Loading", 22, (GXColor){0, 0, 0, 255}); @@ -3572,7 +3797,7 @@ static int MenuSettings() GuiImage networkBtnIcon(&iconNetwork); GuiButton networkBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight()); networkBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - networkBtn.SetPosition(-125, 250); + networkBtn.SetPosition(-200, 250); networkBtn.SetLabel(&networkBtnTxt); networkBtn.SetImage(&networkBtnImg); networkBtn.SetImageOver(&networkBtnImgOver); @@ -3592,7 +3817,7 @@ static int MenuSettings() GuiImage cheatsBtnIcon(&iconCheats); GuiButton cheatsBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight()); cheatsBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); - cheatsBtn.SetPosition(125, 250); + cheatsBtn.SetPosition(0, 250); cheatsBtn.SetLabel(&cheatsBtnTxt, 0); cheatsBtn.SetLabel(&cheatsBtnTxt2, 1); cheatsBtn.SetImage(&cheatsBtnImg); @@ -3604,6 +3829,23 @@ static int MenuSettings() cheatsBtn.SetTrigger(trig2); cheatsBtn.SetEffectGrow(); + GuiText creditsBtnTxt("Credits", 22, (GXColor){0, 0, 0, 255}); + creditsBtnTxt.SetWrap(true, btnLargeOutline.GetWidth()-20); + GuiImage creditsBtnImg(&btnLargeOutline); + GuiImage creditsBtnImgOver(&btnLargeOutlineOver); + GuiButton creditsBtn(btnLargeOutline.GetWidth(), btnLargeOutline.GetHeight()); + creditsBtn.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + creditsBtn.SetPosition(200, 250); + creditsBtn.SetLabel(&creditsBtnTxt); + creditsBtn.SetImage(&creditsBtnImg); + creditsBtn.SetImageOver(&creditsBtnImgOver); + creditsBtn.SetSoundOver(&btnSoundOver); + creditsBtn.SetSoundClick(&btnSoundClick); + creditsBtn.SetTrigger(trigA); + creditsBtn.SetTrigger(trig2); + creditsBtn.SetEffectGrow(); + creditsBtn.SetUpdateCallback(WindowCredits); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -3617,6 +3859,8 @@ static int MenuSettings() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiText resetBtnTxt("Reset Settings", 22, (GXColor){0, 0, 0, 255}); @@ -3641,6 +3885,7 @@ static int MenuSettings() w.Append(&menuBtn); w.Append(&networkBtn); w.Append(&cheatsBtn); + w.Append(&creditsBtn); w.Append(&backBtn); w.Append(&resetBtn); @@ -3664,6 +3909,11 @@ static int MenuSettings() { menu = MENU_SETTINGS_NETWORK; } + else if(creditsBtn.GetState() == STATE_CLICKED) + { + showCredits = true; + creditsBtn.SetState(STATE_SELECTED); + } else if(cheatsBtn.GetState() == STATE_CLICKED) { cheatsBtn.ResetState(); @@ -3740,6 +3990,11 @@ static int MenuSettingsFile() GuiImageData btnOutline(button_long_png); GuiImageData btnOutlineOver(button_long_over_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -3753,6 +4008,8 @@ static int MenuSettingsFile() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiOptionBrowser optionBrowser(552, 248, &options); @@ -3958,6 +4215,11 @@ static int MenuSettingsMenu() GuiImageData btnOutline(button_long_png); GuiImageData btnOutlineOver(button_long_over_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -3971,6 +4233,8 @@ static int MenuSettingsMenu() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiOptionBrowser optionBrowser(552, 248, &options); @@ -4162,6 +4426,11 @@ static int MenuSettingsNetwork() GuiImageData btnOutline(button_long_png); GuiImageData btnOutlineOver(button_long_over_png); + GuiTrigger trigB; + GuiTrigger trig1; + trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B, WIIDRC_BUTTON_B); + trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1, 0, 0); + GuiText backBtnTxt("Go Back", 22, (GXColor){0, 0, 0, 255}); GuiImage backBtnImg(&btnOutline); GuiImage backBtnImgOver(&btnOutlineOver); @@ -4175,6 +4444,8 @@ static int MenuSettingsNetwork() backBtn.SetSoundClick(&btnSoundClick); backBtn.SetTrigger(trigA); backBtn.SetTrigger(trig2); + backBtn.SetTrigger(&trigB); + backBtn.SetTrigger(&trig1); backBtn.SetEffectGrow(); GuiOptionBrowser optionBrowser(552, 248, &options); @@ -4398,11 +4669,19 @@ MainMenu (int menu) case MENU_SETTINGS_NETWORK: currentMenu = MenuSettingsNetwork(); break; + case MENU_GAMESETTINGS_MAPPINGS_OTHER: + currentMenu = MenuSettingsOtherMappings(); + break; default: // unrecognized menu currentMenu = MenuGameSelection(); break; } lastMenu = currentMenu; + if (btnLogo->GetState() == STATE_CLICKED) + { + showCredits = true; + btnLogo->ResetState(); + } usleep(THREAD_SLEEP); } diff --git a/source/menu.h b/source/menu.h index fce481b..1a1215e 100644 --- a/source/menu.h +++ b/source/menu.h @@ -44,7 +44,8 @@ enum MENU_GAMESETTINGS_MAPPINGS_CTRL, MENU_GAMESETTINGS_MAPPINGS_MAP, MENU_GAMESETTINGS_VIDEO, - MENU_GAMESETTINGS_CHEATS + MENU_GAMESETTINGS_CHEATS, + MENU_GAMESETTINGS_MAPPINGS_OTHER }; #endif diff --git a/source/pad.cpp b/source/pad.cpp index 2545298..5a05044 100644 --- a/source/pad.cpp +++ b/source/pad.cpp @@ -596,31 +596,139 @@ bool MenuRequested() { for(int i=0; i<4; i++) { - if ( - (userInput[i].pad.substickX < -70) || - (userInput[i].pad.btns_h & PAD_TRIGGER_L && - userInput[i].pad.btns_h & PAD_TRIGGER_R && - userInput[i].pad.btns_h & PAD_BUTTON_START) || - (userInput[i].pad.btns_h & PAD_BUTTON_START && - userInput[i].pad.btns_h & PAD_BUTTON_A && - userInput[i].pad.btns_h & PAD_BUTTON_B && - userInput[i].pad.btns_h & PAD_TRIGGER_Z) - #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) || - (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 - ) + if (GCSettings.GamepadMenuToggle == 1) // Home (WiiPad) or Right Stick (GC/3rd party gamepad) only { - return true; + 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 + { + 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 ( + (userInput[i].pad.substickX < -70) || + (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_BUTTON_HOME) || + (userInput[i].wpad->btns_h & WPAD_CLASSIC_BUTTON_HOME) || + (userInput[i].wiidrcdata.btns_h & WIIDRC_BUTTON_HOME) || + (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; + } } } 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; + } +} + void GetJoy() { JSReturn = 0; // reset buttons pressed @@ -631,12 +739,9 @@ void GetJoy() // Turbo mode // RIGHT on c-stick and on classic ctrlr right joystick - if (GCSettings.TurboModeEnabled == 1) + if (GCSettings.TurboModeEnabled) { - if(userInput[0].pad.substickX > 70 || userInput[0].WPAD_StickX(1) > 70 || userInput[0].wiidrcdata.substickX > 45) - turbomode = 1; - else - turbomode = 0; + turbomode = IsTurboModeInputPressed(); } // request to go back to menu if(MenuRequested()) @@ -646,4 +751,4 @@ void GetJoy() pad[playerMapping[i]] = DecodeJoy(i); JSReturn = pad[0] | pad[1] << 8 | pad[2] << 16 | pad[3] << 24; -} +} \ No newline at end of file diff --git a/source/preferences.cpp b/source/preferences.cpp index 9de18bd..f52200c 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -157,6 +157,8 @@ preparePrefsData () createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift)); createXMLSetting("yshift", "Vertical Video Shift", toStr(GCSettings.yshift)); createXMLSetting("TurboModeEnabled", "Turbo Mode Enabled", toStr(GCSettings.TurboModeEnabled)); + createXMLSetting("TurboModeButton", "Turbo Mode Button", toStr(GCSettings.TurboModeButton)); + createXMLSetting("GamepadMenuToggle", "Gamepad Menu Toggle", toStr(GCSettings.GamepadMenuToggle)); createXMLSection("Menu", "Menu Settings"); @@ -332,7 +334,12 @@ decodePrefsData () loadXMLSetting(&GCSettings.hideoverscan, "hideoverscan"); loadXMLSetting(&GCSettings.xshift, "xshift"); loadXMLSetting(&GCSettings.yshift, "yshift"); + + // Other Mappings + loadXMLSetting(&GCSettings.TurboModeEnabled, "TurboModeEnabled"); + loadXMLSetting(&GCSettings.TurboModeButton, "TurboModeButton"); + loadXMLSetting(&GCSettings.GamepadMenuToggle, "GamepadMenuToggle"); // Menu Settings @@ -463,6 +470,8 @@ DefaultSettings () GCSettings.AutoLoad = 1; // Auto Load RAM GCSettings.AutoSave = 1; // Auto Save RAM GCSettings.TurboModeEnabled = 1; // Enabled by default + GCSettings.TurboModeButton = 0; // Default is Right Analog Stick (0) + GCSettings.GamepadMenuToggle = 0; // 0 = All options (default), 1 = Home / C-Stick left, 2 = R+L+Start } /****************************************************************************