[CONSOLE] Make separate timers for holding scroll and menu/exit button delay.

Fixes issues with exit/menu button combo not working on GC controllers occasionally
This commit is contained in:
Toad King 2012-11-28 19:54:49 -05:00
parent ee82a8daf5
commit c6111a3259
9 changed files with 25 additions and 30 deletions

View File

@ -1169,7 +1169,7 @@ void menu_loop(void)
g_extern.console.rmenu.state.rmenu.enable = !((state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB)
&& (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) && (g_extern.console.emulator_initialized)
&& IS_TIMER_EXPIRED(device_ptr));
&& IS_TIMER_EXPIRED(device_ptr, 0));
g_extern.console.rmenu.mode = g_extern.console.rmenu.state.rmenu.enable ? MODE_MENU : MODE_EMULATION;
@ -1181,7 +1181,7 @@ void menu_loop(void)
{
uint64_t action = (1 << RMENU_DEVICE_NAV_A);
browser_update(browser, action, rarch_console_get_rom_ext());
SET_TIMER_EXPIRATION(d3d, 15);
SET_TIMER_EXPIRATION(d3d, 0, 15);
}
*/
case INPUT_LOOP_MENU:
@ -1201,7 +1201,7 @@ void menu_loop(void)
if(g_extern.console.rmenu.mode == MODE_EMULATION && !g_extern.console.screen.state.frame_advance.enable)
{
SET_TIMER_EXPIRATION(device_ptr, 30);
SET_TIMER_EXPIRATION(device_ptr, 0, 30);
}
const char *message = msg_queue_pull(g_extern.msg_queue);

View File

@ -17,9 +17,9 @@
#ifndef RARCH_CONSOLE_VIDEO_H__
#define RARCH_CONSOLE_VIDEO_H__
#define IS_TIMER_NOT_EXPIRED(handle) ((handle)->frame_count < g_extern.console.timers.general_timer.expire_frame)
#define IS_TIMER_EXPIRED(handle) (!(IS_TIMER_NOT_EXPIRED((handle))))
#define SET_TIMER_EXPIRATION(handle, value) (g_extern.console.timers.general_timer.expire_frame = (handle)->frame_count + (value))
#define IS_TIMER_NOT_EXPIRED(handle, index) ((handle)->frame_count < g_extern.console.general_timers[(index)].expire_frame)
#define IS_TIMER_EXPIRED(handle, index) (!(IS_TIMER_NOT_EXPIRED((handle), (index))))
#define SET_TIMER_EXPIRATION(handle, index, value) (g_extern.console.general_timers[(index)].expire_frame = (handle)->frame_count + (value))
#define MIN_SCALING_FACTOR (1.0f)

View File

@ -2260,10 +2260,10 @@ void menu_loop(void)
if(!first_held)
{
first_held = true;
SET_TIMER_EXPIRATION(device_ptr, 7);
SET_TIMER_EXPIRATION(device_ptr, 1, 7);
}
if(IS_TIMER_EXPIRED(device_ptr))
if(IS_TIMER_EXPIRED(device_ptr, 1))
{
first_held = false;
trig_state = input_state; //second input frame set as current frame
@ -2344,7 +2344,7 @@ void menu_loop(void)
old_state = input_state_first_frame;
if(IS_TIMER_EXPIRED(device_ptr))
if(IS_TIMER_EXPIRED(device_ptr, 0))
{
// if we want to force goto the emulation loop, skip this
if(g_extern.console.rmenu.mode != MODE_EMULATION)
@ -2372,7 +2372,7 @@ void menu_loop(void)
// press and holding L3 + R3 in the emulation loop (lasts for 30 frame ticks)
if(g_extern.console.rmenu.mode == MODE_EMULATION && !g_extern.console.screen.state.frame_advance.enable)
{
SET_TIMER_EXPIRATION(device_ptr, 30);
SET_TIMER_EXPIRATION(device_ptr, 0, 30);
}
const char * message = msg_queue_pull(g_extern.msg_queue);

View File

@ -474,6 +474,7 @@ struct global
bool block_config_read;
bool initialize_rarch_enable;
unsigned emulator_initialized;
rarch_frame_count_t general_timers[2];
struct
{
@ -498,12 +499,6 @@ struct global
} state;
} rmenu;
struct
{
rarch_frame_count_t control_timer;
rarch_frame_count_t general_timer;
} timers;
struct
{
bool enable;

View File

@ -1749,7 +1749,7 @@ static void gl_restart(void)
#ifdef RARCH_CONSOLE
gl->block_swap = should_block_swap;
SET_TIMER_EXPIRATION(gl, 30);
SET_TIMER_EXPIRATION(gl, 0, 30);
#endif
}

View File

@ -304,10 +304,10 @@ static void menu_loop(void)
if(!first_held)
{
first_held = true;
SET_TIMER_EXPIRATION(gx, (initial_held) ? 15 : 7);
SET_TIMER_EXPIRATION(gx, 1, (initial_held) ? 15 : 7);
}
if(IS_TIMER_EXPIRED(gx))
if(IS_TIMER_EXPIRED(gx, 1))
{
first_held = false;
trigger_state = input_state; //second input frame set as current frame
@ -357,7 +357,7 @@ static void menu_loop(void)
bool goto_menu_key_pressed = (trigger_state & (1 << GX_DEVICE_NAV_MENU));
bool quit_key_pressed = (trigger_state & (1 << GX_DEVICE_NAV_QUIT));
if(IS_TIMER_EXPIRED(gx))
if(IS_TIMER_EXPIRED(gx, 0))
{
// if we want to force goto the emulation loop, skip this
if(g_extern.console.rmenu.mode != MODE_EMULATION)
@ -380,7 +380,7 @@ static void menu_loop(void)
// press and holding QUIT in the emulation loop (lasts for 30 frame ticks)
if(g_extern.console.rmenu.mode == MODE_EMULATION)
{
SET_TIMER_EXPIRATION(gx, 30);
SET_TIMER_EXPIRATION(gx, 0, 30);
}
}while(g_extern.console.rmenu.state.rmenu.enable);

View File

@ -465,7 +465,7 @@ static bool gx_input_key_pressed(void *data, int key)
switch (key)
{
case RARCH_QUIT_KEY:
if(IS_TIMER_EXPIRED(gx))
if(IS_TIMER_EXPIRED(gx, 0))
{
uint64_t goto_menu_pressed = pad_state[0] & (GX_WIIMOTE_HOME
#ifdef HW_RVL
@ -474,13 +474,13 @@ static bool gx_input_key_pressed(void *data, int key)
);
uint64_t quit_rarch = pad_state[0] & GX_QUIT_KEY;
bool retval = false;
g_extern.console.rmenu.state.rmenu.enable = ((quit_rarch || goto_menu_pressed) && IS_TIMER_EXPIRED(gx));
g_extern.console.rmenu.state.rmenu.enable = ((quit_rarch || goto_menu_pressed) && IS_TIMER_EXPIRED(gx, 0));
if(g_extern.console.rmenu.state.rmenu.enable)
{
g_extern.console.rmenu.mode = MODE_MENU;
g_extern.console.rmenu.state.ingame_menu.enable = true;
SET_TIMER_EXPIRATION(gx, 30);
SET_TIMER_EXPIRATION(gx, 0, 30);
}
if(quit_rarch)

View File

@ -454,18 +454,18 @@ static bool ps3_input_key_pressed(void *data, int key)
return (state[0] & PS3_GAMEPAD_RSTICK_UP_MASK) && !(state[0] & PS3_GAMEPAD_R2);
case RARCH_QUIT_KEY:
#ifdef HAVE_OPENGL
if(IS_TIMER_EXPIRED(gl))
if(IS_TIMER_EXPIRED(gl, 0))
{
uint32_t r3_pressed = state[0] & PS3_GAMEPAD_R3;
uint32_t l3_pressed = state[0] & PS3_GAMEPAD_L3;
bool retval = false;
g_extern.console.rmenu.state.rmenu.enable = (r3_pressed && l3_pressed && IS_TIMER_EXPIRED(gl));
g_extern.console.rmenu.state.rmenu.enable = (r3_pressed && l3_pressed && IS_TIMER_EXPIRED(gl, 0));
g_extern.console.rmenu.state.ingame_menu.enable = r3_pressed && !l3_pressed;
if(g_extern.console.rmenu.state.rmenu.enable || (g_extern.console.rmenu.state.ingame_menu.enable && !g_extern.console.rmenu.state.rmenu.enable))
{
g_extern.console.rmenu.mode = MODE_MENU;
SET_TIMER_EXPIRATION(gl, 30);
SET_TIMER_EXPIRATION(gl, 0, 30);
retval = g_extern.console.rmenu.state.rmenu.enable;
}

View File

@ -338,18 +338,18 @@ static bool xinput_input_key_pressed(void *data, int key)
case RARCH_REWIND:
return ((state[0] & XINPUT1_GAMEPAD_RSTICK_UP_MASK) && !(state[0] & XINPUT1_GAMEPAD_RIGHT_TRIGGER));
case RARCH_QUIT_KEY:
if(IS_TIMER_EXPIRED(d3d))
if(IS_TIMER_EXPIRED(d3d, 0))
{
uint32_t left_thumb_pressed = (state[0] & (1 << RETRO_DEVICE_ID_JOYPAD_L3));
uint32_t right_thumb_pressed = (state[0] & (1 << RETRO_DEVICE_ID_JOYPAD_R3));
g_extern.console.rmenu.state.rmenu.enable = right_thumb_pressed && left_thumb_pressed && IS_TIMER_EXPIRED(d3d);
g_extern.console.rmenu.state.rmenu.enable = right_thumb_pressed && left_thumb_pressed && IS_TIMER_EXPIRED(d3d, 0);
g_extern.console.rmenu.state.ingame_menu.enable = right_thumb_pressed && !left_thumb_pressed;
if(g_extern.console.rmenu.state.rmenu.enable || (g_extern.console.rmenu.state.ingame_menu.enable && !g_extern.console.rmenu.state.rmenu.enable))
{
g_extern.console.rmenu.mode = MODE_MENU;
SET_TIMER_EXPIRATION(d3d, 30);
SET_TIMER_EXPIRATION(d3d, 0, 30);
retval = g_extern.console.rmenu.state.rmenu.enable;
}
retval = g_extern.console.rmenu.state.ingame_menu.enable ? g_extern.console.rmenu.state.ingame_menu.enable : g_extern.console.rmenu.state.rmenu.enable;