diff --git a/360/frontend-xdk/menu.cpp b/360/frontend-xdk/menu.cpp index 61e7b35de1..3dfeab2e9f 100644 --- a/360/frontend-xdk/menu.cpp +++ b/360/frontend-xdk/menu.cpp @@ -1179,7 +1179,7 @@ bool rmenu_iterate(void) XInputGetState(0, &state); - if (IS_TIMER_EXPIRED(0)) + if (!(g_extern.frame_count < g_extern.delay_timer)) { bool rmenu_enable = !((state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) && (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) && (g_extern.main_is_init)); @@ -1226,12 +1226,10 @@ bool rmenu_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))) - { - // 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) - SET_TIMER_EXPIRATION(0, 30); - } + g_extern.delay_timer = g_extern.frame_count + 30; g_extern.console.rmenu.state.ingame_menu.enable = false; g_extern.draw_menu = false; diff --git a/console/rarch_console_video.h b/console/rarch_console_video.h index 24fd9da078..c538b1629d 100644 --- a/console/rarch_console_video.h +++ b/console/rarch_console_video.h @@ -17,10 +17,6 @@ #ifndef RARCH_CONSOLE_VIDEO_H__ #define RARCH_CONSOLE_VIDEO_H__ -#define IS_TIMER_NOT_EXPIRED(index) (g_extern.frame_count < g_extern.console.general_timers[(index)].expire_frame) -#define IS_TIMER_EXPIRED(index) (!(IS_TIMER_NOT_EXPIRED(index))) -#define SET_TIMER_EXPIRATION(index, value) (g_extern.console.general_timers[(index)].expire_frame = g_extern.frame_count + (value)) - #define MIN_SCALING_FACTOR (1.0f) #if defined(__CELLOS_LV2__) diff --git a/console/rmenu/rmenu.c b/console/rmenu/rmenu.c index 7b10d1a973..5e62c437f6 100644 --- a/console/rmenu/rmenu.c +++ b/console/rmenu/rmenu.c @@ -2322,10 +2322,10 @@ void rmenu_input_poll(void *data, void *state) if(!first_held) { first_held = true; - SET_TIMER_EXPIRATION(1, 7); + g_extern.delay_timer = g_extern.frame_count + 7; } - if(IS_TIMER_EXPIRED(1)) + if(!(g_extern.frame_count < g_extern.delay_timer)) { first_held = false; rstate->input = input_state; //second input frame set as current frame @@ -2344,7 +2344,7 @@ void rmenu_input_process(void *data, void *state) (void)data; rmenu_state_t *rstate = (rmenu_state_t*)state; - if (IS_TIMER_EXPIRED(0)) + if (!(g_extern.frame_count < g_extern.delay_timer)) { bool rmenu_enable = (((rstate->old_state & (1ULL << RMENU_DEVICE_NAV_L3)) && (rstate->old_state & (1ULL << RMENU_DEVICE_NAV_R3)) && g_extern.main_is_init)); @@ -2503,12 +2503,10 @@ bool rmenu_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))) - { - // 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) - SET_TIMER_EXPIRATION(0, 30); - } + g_extern.delay_timer = g_extern.frame_count + 30; if(g_extern.console.rmenu.state.ingame_menu.enable) menu_stack_pop(); diff --git a/frontend/frontend_gx.c b/frontend/frontend_gx.c index 60c4c9cfb1..a706dd8117 100644 --- a/frontend/frontend_gx.c +++ b/frontend/frontend_gx.c @@ -298,10 +298,10 @@ static bool rmenu_iterate(void) if(!first_held) { first_held = true; - SET_TIMER_EXPIRATION(1, (initial_held) ? 15 : 7); + g_extern.delay_timer = g_extern.frame_count + (initial_held ? 15 : 7); } - if(IS_TIMER_EXPIRED(1)) + if (!(g_extern.frame_count < g_extern.delay_timer)) { first_held = false; trigger_state = input_state; //second input frame set as current frame @@ -341,7 +341,7 @@ static bool rmenu_iterate(void) old_input_state = input_state; - if(IS_TIMER_EXPIRED(0)) + if (!(g_extern.frame_count < g_extern.delay_timer)) { bool rmenu_enable = ((trigger_state & (1ULL << GX_DEVICE_NAV_MENU)) && g_extern.main_is_init); bool quit_key_pressed = (trigger_state & (1ULL << GX_DEVICE_NAV_QUIT)); @@ -364,12 +364,11 @@ static bool rmenu_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))) - { - // 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) - SET_TIMER_EXPIRATION(0, 30); - } + g_extern.delay_timer = g_extern.frame_count + 30; + g_extern.draw_menu = false; g_extern.console.rmenu.state.ingame_menu.enable = false; diff --git a/general.h b/general.h index 6dc52de965..1bbd27d959 100644 --- a/general.h +++ b/general.h @@ -238,11 +238,6 @@ typedef struct rarch_boolean_state unsigned value; } rarch_boolean_state_t; -typedef struct rarch_frame_count -{ - unsigned expire_frame; -} rarch_frame_count_t; - typedef struct rarch_resolution { unsigned idx; @@ -459,6 +454,7 @@ struct global } frame_cache; unsigned frame_count; + unsigned delay_timer; char title_buf[64]; struct @@ -475,7 +471,6 @@ struct global struct { bool block_config_read; - rarch_frame_count_t general_timers[2]; struct { diff --git a/gx/gx_input.c b/gx/gx_input.c index 6ee665c50e..26345860b8 100644 --- a/gx/gx_input.c +++ b/gx/gx_input.c @@ -449,7 +449,7 @@ static void gx_input_poll(void *data) g_quit = false; } - if (IS_TIMER_EXPIRED(0)) + if (!(g_extern.frame_count < g_extern.delay_timer)) { if (*pad_p1 & GX_QUIT_KEY) *lifecycle_state |= (1ULL << RARCH_QUIT_KEY); diff --git a/ps3/ps3_input.c b/ps3/ps3_input.c index 424f0c3883..4a6610d72b 100644 --- a/ps3/ps3_input.c +++ b/ps3/ps3_input.c @@ -206,7 +206,8 @@ static void ps3_input_poll(void *data) *lifecycle_state |= (1ULL << RARCH_STATE_SLOT_MINUS); if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP)) && !(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2))) *lifecycle_state |= (1ULL << RARCH_REWIND); - if(IS_TIMER_EXPIRED(0)) + + if (!(g_extern.frame_count < g_extern.delay_timer)) { if((*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3))) { diff --git a/retroarch.c b/retroarch.c index a8a6b72825..42b983dbed 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2789,7 +2789,7 @@ bool rarch_main_iterate(void) if (rmenu_enable || (g_extern.console.rmenu.state.ingame_menu.enable && !rmenu_enable)) { g_extern.console.rmenu.mode = MODE_MENU; - SET_TIMER_EXPIRATION(0, 30); + g_extern.delay_timer = g_extern.frame_count + 30; } #endif return false; diff --git a/xdk/xdk_xinput_input.c b/xdk/xdk_xinput_input.c index 746b926a36..41a5c86bf5 100644 --- a/xdk/xdk_xinput_input.c +++ b/xdk/xdk_xinput_input.c @@ -222,7 +222,8 @@ static void xdk_input_poll(void *data) *lifecycle_state |= (1ULL << RARCH_STATE_SLOT_MINUS); if ((*state_p1 & (1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP)) && !(*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R2))) *lifecycle_state |= (1ULL << RARCH_REWIND); - if(IS_TIMER_EXPIRED(0)) + + if (!(g_extern.frame_count < g_extern.delay_timer)) { if((*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_L3)) && (*state_p1 & (1ULL << RETRO_DEVICE_ID_JOYPAD_R3))) {