From 039fc644d57db57723bb62fc7f9f647df1f0fa15 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Mar 2013 02:07:50 +0100 Subject: [PATCH] Revert "Menu toggle without delay timers (more testing might be needed -" This reverts commit 54a6175a555925d8a3530756b1fa6c9a7b14adc2. --- frontend/menu/rgui.c | 21 +++++++++++++-------- frontend/menu/rmenu.c | 26 ++++++++++++++++---------- frontend/menu/rmenu_xui.cpp | 25 +++++++++++++++---------- gx/gx_input.c | 15 +++++++++------ ps3/ps3_input.c | 13 ++++++++----- retroarch.c | 1 + xdk/xdk_xinput_input.c | 13 ++++++++----- 7 files changed, 70 insertions(+), 44 deletions(-) diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index 23eb2a0102..9afe164a9d 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -1631,16 +1631,16 @@ static int menu_input_process(void *data, void *state) return -1; } - static bool old_rmenu_toggle = true; - bool rmenu_toggle = ((trigger_state & (1ULL << GX_DEVICE_NAV_MENU)) && g_extern.main_is_init); - if (rmenu_toggle && !old_rmenu_toggle) + if (!(g_extern.frame_count < g_extern.delay_timer[0])) { - g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME); - old_rmenu_toggle = true; - return -1; + bool return_to_game_enable = ((trigger_state & (1ULL << GX_DEVICE_NAV_MENU)) && g_extern.main_is_init); + + if (return_to_game_enable) + { + g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME); + return -1; + } } - else - old_rmenu_toggle = rmenu_toggle; return 0; } @@ -1788,6 +1788,11 @@ bool menu_iterate(void) return true; deinit: + // set a timer delay so that we don't instantly switch back to the menu when + // press and holding QUIT in the emulation loop (lasts for 30 frame ticks) + if (!(g_extern.lifecycle_state & (1ULL << RARCH_FRAMEADVANCE))) + g_extern.delay_timer[0] = g_extern.frame_count + 30; + g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_DRAW); g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_INGAME); diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index 20d439bc1e..e2430e22bd 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -2709,18 +2709,19 @@ int menu_input_process(void *data, void *state) return -1; } - static bool old_rmenu_toggle = true; - bool rmenu_toggle = (((rstate->old_state & (1ULL << RMENU_DEVICE_NAV_L3)) - && (rstate->old_state & (1ULL << RMENU_DEVICE_NAV_R3)) - && g_extern.main_is_init)); - if (rmenu_toggle && !old_rmenu_toggle) + if (!(g_extern.frame_count < g_extern.delay_timer[0])) { - g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME); - old_rmenu_toggle = true; - return -1; + bool return_to_game_enable = (((rstate->old_state & (1ULL << RMENU_DEVICE_NAV_L3)) && (rstate->old_state & (1ULL << RMENU_DEVICE_NAV_R3)) && g_extern.main_is_init)); + + if (return_to_game_enable) + { + if (!(g_extern.lifecycle_mode_state & (1ULL << MODE_MENU_INGAME))) + { + g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME); + return -1; + } + } } - else - old_rmenu_toggle = rmenu_toggle; bool quit, resize; unsigned width, height, frame_count; @@ -2888,6 +2889,11 @@ bool menu_iterate(void) return true; deinit: + // set a timer delay so that we don't instantly switch back to the menu when + // press and holding L3 + R3 in the emulation loop (lasts for 30 frame ticks) + if (!(g_extern.lifecycle_state & (1ULL << RARCH_FRAMEADVANCE))) + g_extern.delay_timer[0] = g_extern.frame_count + 30; + g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_DRAW); #ifndef __CELLOS_LV2__ diff --git a/frontend/menu/rmenu_xui.cpp b/frontend/menu/rmenu_xui.cpp index d0f4806e4f..249d1d7c2a 100644 --- a/frontend/menu/rmenu_xui.cpp +++ b/frontend/menu/rmenu_xui.cpp @@ -1499,19 +1499,19 @@ bool menu_iterate(void) process_input_ret = -1; } - static bool old_rmenu_toggle = true; - bool rmenu_toggle = ((state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) - && (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) - && (g_extern.main_is_init)); - if (rmenu_toggle && !old_rmenu_toggle) + if (!(g_extern.frame_count < g_extern.delay_timer[0])) { - g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME); - old_rmenu_toggle = true; - process_input_ret = -1; + bool rmenu_enable = ((state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) + && (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) && (g_extern.main_is_init)); + + if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU)) + if (rmenu_enable) + { + g_extern.lifecycle_mode_state |= (1ULL << MODE_GAME); + process_input_ret = -1; + } } - else - old_rmenu_toggle = rmenu_toggle; rarch_render_cached_frame(); @@ -1543,6 +1543,11 @@ bool menu_iterate(void) return true; deinit: + // set a timer delay so that we don't instantly switch back to the menu when + // press and holding L3 + R3 in the emulation loop (lasts for 30 frame ticks) + if(!(g_extern.lifecycle_state & (1ULL << RARCH_FRAMEADVANCE))) + g_extern.delay_timer[0] = g_extern.frame_count + 30; + g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_INGAME); g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_DRAW); diff --git a/gx/gx_input.c b/gx/gx_input.c index fc57ddb9f1..4cbadde846 100644 --- a/gx/gx_input.c +++ b/gx/gx_input.c @@ -518,15 +518,18 @@ static void gx_input_poll(void *data) g_quit = false; } - if (*state_p1 & GX_QUIT_KEY) - *lifecycle_state |= (1ULL << RARCH_QUIT_KEY); + if (!(g_extern.frame_count < g_extern.delay_timer[0])) + { + if (*state_p1 & GX_QUIT_KEY) + *lifecycle_state |= (1ULL << RARCH_QUIT_KEY); - if (*state_p1 & (GX_WIIMOTE_HOME + if (*state_p1 & (GX_WIIMOTE_HOME #ifdef HW_RVL - | GX_CLASSIC_HOME + | GX_CLASSIC_HOME #endif - )) - *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE); + )) + *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE); + } } static bool gx_input_key_pressed(void *data, int key) diff --git a/ps3/ps3_input.c b/ps3/ps3_input.c index 0e40dfe985..43f8638f75 100644 --- a/ps3/ps3_input.c +++ b/ps3/ps3_input.c @@ -207,12 +207,15 @@ static void ps3_input_poll(void *data) if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP)) && !(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2))) *lifecycle_state |= (1ULL << RARCH_REWIND); - if ((*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3))) - *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE); - if (!(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3))) + if (!(g_extern.frame_count < g_extern.delay_timer[0])) { - *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE); - *lifecycle_state |= (1ULL << RARCH_MENU_QUICKMENU_TOGGLE); + if ((*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3))) + *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE); + if (!(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3))) + { + *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE); + *lifecycle_state |= (1ULL << RARCH_MENU_QUICKMENU_TOGGLE); + } } cellPadGetInfo2(&pad_info); diff --git a/retroarch.c b/retroarch.c index 5884395575..efb4779c60 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2858,6 +2858,7 @@ static inline bool check_enter_rgui(void) g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_INGAME); g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU); + g_extern.delay_timer[0] = g_extern.frame_count + 30; // FIXME: Purge. Should do something similar in RGUI as well. old_rmenu_toggle = true; return true; } diff --git a/xdk/xdk_xinput_input.c b/xdk/xdk_xinput_input.c index fd3ee5ed1a..9792e75a19 100644 --- a/xdk/xdk_xinput_input.c +++ b/xdk/xdk_xinput_input.c @@ -228,12 +228,15 @@ static void xdk_input_poll(void *data) if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP)) && !(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2))) *lifecycle_state |= (1ULL << RARCH_REWIND); - if((*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3))) - *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE); - if(!(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3))) + if (!(g_extern.frame_count < g_extern.delay_timer[0])) { - *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE); - *lifecycle_state |= (1ULL << RARCH_MENU_QUICKMENU_TOGGLE); + if((*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3))) + *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE); + if(!(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3))) + { + *lifecycle_state |= (1ULL << RARCH_MENU_TOGGLE); + *lifecycle_state |= (1ULL << RARCH_MENU_QUICKMENU_TOGGLE); + } } }