diff --git a/source/opendingux/gui.c b/source/opendingux/gui.c index 2c90705..9f7d22d 100644 --- a/source/opendingux/gui.c +++ b/source/opendingux/gui.c @@ -1432,7 +1432,12 @@ static struct MenuEntry HotkeyMenu_FastForward = { ENTRY_OPTIONAL_HOTKEY }; -#if !defined GCW_ZERO +#if (defined(GCW_ZERO) || defined(RS90)) +static struct MenuEntry HotkeyMenu_MenuToggleCombo = { + ENTRY_OPTION("menu_toggle_combo", "Menu", &MenuToggleCombo), + .ChoiceCount = 4, .Choices = { { "Power/Start+Select", "power_or_start_select" }, { "Power/L3+R3", "power_or_l3_r3" }, { "Power", "power" }, { "Start+Select", "start_select" } } +}; +#else static struct MenuEntry HotkeyMenu_Menu = { ENTRY_OPTION("hotkey_menu", "Menu", &Hotkeys[1]), ENTRY_MANDATORY_HOTKEY @@ -1476,10 +1481,10 @@ static struct Menu HotkeyMenu = { .Parent = &MainMenu, .Title = "Hotkeys", .AlternateVersion = &PerGameHotkeyMenu, .Entries = { -#if !defined GCW_ZERO - &HotkeyMenu_Menu, +#if (defined(GCW_ZERO) || defined(RS90)) + &HotkeyMenu_MenuToggleCombo, #else - &Strut, + &HotkeyMenu_Menu, #endif &HotkeyMenu_FastForward, &HotkeyMenu_FastForwardToggle, &HotkeyMenu_QuickLoadState, &HotkeyMenu_QuickSaveState, NULL } diff --git a/source/opendingux/od-input.c b/source/opendingux/od-input.c index 57b37d2..f68940c 100644 --- a/source/opendingux/od-input.c +++ b/source/opendingux/od-input.c @@ -149,6 +149,10 @@ enum OpenDingux_Buttons Hotkeys[5] = { 0, // Quick save state #1 }; +#if (defined(GCW_ZERO) || defined(RS90)) +uint32_t MenuToggleCombo = 0; +#endif + // The menu keys, in decreasing order of priority when two or more are // pressed. For example, when the user keeps a direction pressed but also // presses A, start ignoring the direction. @@ -362,6 +366,7 @@ enum ReGBA_Buttons ReGBA_GetPressedButtons() { uint_fast8_t i; enum ReGBA_Buttons Result = 0; + bool toggle_menu = false; UpdateOpenDinguxButtons(); @@ -389,18 +394,42 @@ enum ReGBA_Buttons ReGBA_GetPressedButtons() if ((Result & REGBA_BUTTON_UP) && (Result & REGBA_BUTTON_DOWN)) Result &= ~REGBA_BUTTON_UP; - if ( -#if defined(GCW_ZERO) || defined(RS90) - // Unified emulator menu buttons: Start+Select - ((LastButtons & (OPENDINGUX_BUTTON_START | OPENDINGUX_BUTTON_SELECT)) == (OPENDINGUX_BUTTON_START | OPENDINGUX_BUTTON_SELECT)) +#if (defined(GCW_ZERO) || defined(RS90)) + switch (MenuToggleCombo) + { + case MENU_TOGGLE_POWER_OR_L3_R3: + if ((LastButtons & OPENDINGUX_BUTTON_MENU) || + ((LastButtons & (OPENDINGUX_BUTTON_L3 | OPENDINGUX_BUTTON_R3)) == + (OPENDINGUX_BUTTON_L3 | OPENDINGUX_BUTTON_R3))) + toggle_menu = true; + case MENU_TOGGLE_POWER: + if (LastButtons & OPENDINGUX_BUTTON_MENU) + toggle_menu = true; + break; + case MENU_TOGGLE_START_SELECT: + if ((LastButtons & (OPENDINGUX_BUTTON_START | OPENDINGUX_BUTTON_SELECT)) == + (OPENDINGUX_BUTTON_START | OPENDINGUX_BUTTON_SELECT)) + toggle_menu = true; + break; + case MENU_TOGGLE_POWER_OR_START_SELECT: + default: + if ((LastButtons & OPENDINGUX_BUTTON_MENU) || + ((LastButtons & (OPENDINGUX_BUTTON_START | OPENDINGUX_BUTTON_SELECT)) == + (OPENDINGUX_BUTTON_START | OPENDINGUX_BUTTON_SELECT))) + toggle_menu = true; + break; + } #else // The ReGBA Menu key should be pressed if ONLY the hotkey bound to it // is pressed on the native device. // This is not in ProcessSpecialKeys because REGBA_BUTTON_MENU needs to // be returned by ReGBA_GetPressedButtons. - LastButtons == Hotkeys[1] + if ((LastButtons == Hotkeys[1]) || + (LastButtons & OPENDINGUX_BUTTON_MENU)) + toggle_menu = true; #endif - || (LastButtons & OPENDINGUX_BUTTON_MENU)) + + if (toggle_menu) Result |= REGBA_BUTTON_MENU; return Result; diff --git a/source/opendingux/od-input.h b/source/opendingux/od-input.h index b66ac06..a8fe1a1 100644 --- a/source/opendingux/od-input.h +++ b/source/opendingux/od-input.h @@ -80,6 +80,18 @@ enum Joystick_Stick_Axis { JS_AXIS_RIGHT_VERTICAL = 3, }; +#if (defined(GCW_ZERO) || defined(RS90)) +/* Note: We do not offer an L3+R3 combo *without* + * power, since this would lock users out of the + * menu on devices without L3/R3 buttons */ +enum Menu_Toggle_Combo { + MENU_TOGGLE_POWER_OR_START_SELECT = 0, + MENU_TOGGLE_POWER_OR_L3_R3 = 1, + MENU_TOGGLE_POWER = 2, + MENU_TOGGLE_START_SELECT = 3, +}; +#endif + // 0 if not fast-forwarding. // Otherwise, the amount of frames to skip per rendered frame. // 1 amounts to targetting 200% real-time; @@ -174,6 +186,15 @@ extern enum OpenDingux_Buttons KeypadRemapping[12]; extern enum OpenDingux_Buttons PerGameHotkeys[5]; extern enum OpenDingux_Buttons Hotkeys[5]; +#if (defined(GCW_ZERO) || defined(RS90)) +// A value indicating which button combos will open the menu. +// 0 means POWER or START+SELECT +// 1 means POWER or L3+R3 +// 2 means POWER +// 3 means START+SELECT +extern uint32_t MenuToggleCombo; +#endif + /* * Returns true if the given hotkey is completely impossible to input on the * port being compiled. diff --git a/source/opendingux/settings.c b/source/opendingux/settings.c index b811833..f8fdbe5 100644 --- a/source/opendingux/settings.c +++ b/source/opendingux/settings.c @@ -203,6 +203,10 @@ static void FixUpSettings() if (IsImpossibleHotkey(PerGameHotkeys[4])) PerGameHotkeys[4] = 0; +#if (defined(GCW_ZERO) || defined(RS90)) + MenuToggleCombo = (MenuToggleCombo > MENU_TOGGLE_START_SELECT) ? MENU_TOGGLE_START_SELECT : MenuToggleCombo; +#endif + /* Colour correction and interframe blending options * are converted to an enum via bit manipulation. It * is therefore essential that the associated settings