(RGUI) hold direction repeat

This commit is contained in:
Toad King 2012-08-21 01:14:46 -04:00
parent dc0b44d2f3
commit 0adeeaabf7
2 changed files with 34 additions and 8 deletions

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_console.timer_expiration_frame_count)
#define IS_TIMER_EXPIRED(handle) (!(IS_TIMER_NOT_EXPIRED(handle)))
#define SET_TIMER_EXPIRATION(handle, value) (g_console.timer_expiration_frame_count = handle->frame_count + value)
#define IS_TIMER_NOT_EXPIRED(handle) ((handle)->frame_count < g_console.timer_expiration_frame_count)
#define IS_TIMER_EXPIRED(handle) (!(IS_TIMER_NOT_EXPIRED((handle))))
#define SET_TIMER_EXPIRATION(handle, value) (g_console.timer_expiration_frame_count = (handle)->frame_count + (value))
#define MIN_SCALING_FACTOR (1.0f)

View File

@ -182,6 +182,8 @@ static void menu_loop(void)
uint16_t old_input_state = 0;
bool first = true;
bool first_held = false;
bool initial_held = true;
g_console.menu_enable = true;
gx->menu_render = true;
@ -199,16 +201,36 @@ static void menu_loop(void)
}
uint16_t trigger_state = input_state & ~old_input_state;
bool do_held = (input_state & ((1 << GX_DEVICE_NAV_UP) | (1 << GX_DEVICE_NAV_DOWN) | (1 << GX_DEVICE_NAV_LEFT) | (1 << GX_DEVICE_NAV_RIGHT))) && !(input_state & ((1 << GX_DEVICE_NAV_MENU) | (1 << GX_DEVICE_NAV_QUIT)));
if(do_held)
{
if(!first_held)
{
first_held = true;
SET_TIMER_EXPIRATION(gx, (initial_held) ? 15 : 7);
}
if(IS_TIMER_EXPIRED(gx))
{
first_held = false;
trigger_state = input_state; //second input frame set as current frame
}
initial_held = false;
}
else
{
first_held = false;
initial_held = true;
}
rgui_action_t action = RGUI_ACTION_NOOP;
// don't run anything first frame, only capture held inputs for old_input_state
if (!first)
{
if (trigger_state & (1 << GX_DEVICE_NAV_B))
action = RGUI_ACTION_CANCEL;
else if (trigger_state & (1 << GX_DEVICE_NAV_A))
action = RGUI_ACTION_OK;
else if (trigger_state & (1 << GX_DEVICE_NAV_UP))
if (trigger_state & (1 << GX_DEVICE_NAV_UP))
action = RGUI_ACTION_UP;
else if (trigger_state & (1 << GX_DEVICE_NAV_DOWN))
action = RGUI_ACTION_DOWN;
@ -216,6 +238,10 @@ static void menu_loop(void)
action = RGUI_ACTION_LEFT;
else if (trigger_state & (1 << GX_DEVICE_NAV_RIGHT))
action = RGUI_ACTION_RIGHT;
else if (trigger_state & (1 << GX_DEVICE_NAV_B))
action = RGUI_ACTION_CANCEL;
else if (trigger_state & (1 << GX_DEVICE_NAV_A))
action = RGUI_ACTION_OK;
else if (trigger_state & (1 << GX_DEVICE_NAV_START))
action = RGUI_ACTION_START;
else if (trigger_state & (1 << GX_DEVICE_NAV_SELECT))