mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-25 00:49:47 +00:00
(Wii) Menu flow control improvements
This commit is contained in:
parent
c4d81c6371
commit
40430f735b
@ -52,7 +52,6 @@ void rarch_settings_change(unsigned setting)
|
||||
break;
|
||||
case S_FRAME_ADVANCE:
|
||||
g_extern.lifecycle_state |= (1ULL << RARCH_FRAMEADVANCE);
|
||||
g_extern.console.rmenu.state.rmenu.enable = false;
|
||||
g_extern.console.rmenu.mode = MODE_EMULATION;
|
||||
break;
|
||||
case S_HW_TEXTURE_FILTER:
|
||||
@ -88,25 +87,20 @@ void rarch_settings_change(unsigned setting)
|
||||
}
|
||||
break;
|
||||
case S_QUIT:
|
||||
g_extern.console.rmenu.state.rmenu.enable = false;
|
||||
g_extern.console.rmenu.state.ingame_menu.enable = false;
|
||||
g_extern.console.rmenu.mode = MODE_EXIT;
|
||||
break;
|
||||
case S_QUIT_RARCH:
|
||||
g_extern.console.rmenu.state.rmenu.enable = false;
|
||||
g_extern.console.rmenu.mode = MODE_EXIT;
|
||||
break;
|
||||
case S_RETURN_TO_GAME:
|
||||
g_extern.console.rmenu.state.rmenu.enable = false;
|
||||
g_extern.console.rmenu.mode = MODE_EMULATION;
|
||||
break;
|
||||
case S_RETURN_TO_LAUNCHER:
|
||||
g_extern.console.external_launch.enable = true;
|
||||
g_extern.console.rmenu.state.rmenu.enable = false;
|
||||
g_extern.console.rmenu.mode = MODE_EXIT;
|
||||
break;
|
||||
case S_RETURN_TO_MENU:
|
||||
g_extern.console.rmenu.state.rmenu.enable = false;
|
||||
g_extern.console.rmenu.mode = MODE_MENU;
|
||||
break;
|
||||
case S_ROTATION_DECREMENT:
|
||||
@ -118,7 +112,6 @@ void rarch_settings_change(unsigned setting)
|
||||
g_extern.console.screen.orientation++;
|
||||
break;
|
||||
case S_START_RARCH:
|
||||
g_extern.console.rmenu.state.rmenu.enable = false;
|
||||
g_extern.console.rmenu.mode = MODE_INIT;
|
||||
break;
|
||||
case S_REWIND:
|
||||
|
@ -273,120 +273,111 @@ static bool folder_cb(const char *directory, rgui_file_enum_cb_t file_cb,
|
||||
|
||||
static bool rmenu_iterate(void)
|
||||
{
|
||||
uint16_t old_input_state = 0;
|
||||
bool first = true;
|
||||
bool first_held = false;
|
||||
static uint16_t old_input_state = 0;
|
||||
bool initial_held = true;
|
||||
static bool first_held = false;
|
||||
|
||||
g_extern.console.rmenu.state.rmenu.enable = true;
|
||||
g_extern.draw_menu = true;
|
||||
video_gx.apply_state_changes();
|
||||
|
||||
do
|
||||
g_extern.frame_count++;
|
||||
|
||||
uint16_t input_state = 0;
|
||||
|
||||
input_gx.poll(NULL);
|
||||
|
||||
for (unsigned i = 0; i < GX_DEVICE_NAV_LAST; i++)
|
||||
{
|
||||
g_extern.frame_count++;
|
||||
input_state |= input_gx.input_state(NULL, gx_nav_binds, 0,
|
||||
RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;
|
||||
}
|
||||
|
||||
uint16_t input_state = 0;
|
||||
uint16_t trigger_state = input_state & ~old_input_state;
|
||||
bool do_held = (input_state & ((1ULL << GX_DEVICE_NAV_UP) | (1ULL << GX_DEVICE_NAV_DOWN) | (1ULL << GX_DEVICE_NAV_LEFT) | (1ULL << GX_DEVICE_NAV_RIGHT))) && !(input_state & ((1ULL << GX_DEVICE_NAV_MENU) | (1ULL << GX_DEVICE_NAV_QUIT)));
|
||||
|
||||
input_gx.poll(NULL);
|
||||
|
||||
for (unsigned i = 0; i < GX_DEVICE_NAV_LAST; i++)
|
||||
if(do_held)
|
||||
{
|
||||
if(!first_held)
|
||||
{
|
||||
input_state |= input_gx.input_state(NULL, gx_nav_binds, 0,
|
||||
RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;
|
||||
first_held = true;
|
||||
SET_TIMER_EXPIRATION(1, (initial_held) ? 15 : 7);
|
||||
}
|
||||
|
||||
uint16_t trigger_state = input_state & ~old_input_state;
|
||||
bool do_held = (input_state & ((1ULL << GX_DEVICE_NAV_UP) | (1ULL << GX_DEVICE_NAV_DOWN) | (1ULL << GX_DEVICE_NAV_LEFT) | (1ULL << GX_DEVICE_NAV_RIGHT))) && !(input_state & ((1ULL << GX_DEVICE_NAV_MENU) | (1ULL << GX_DEVICE_NAV_QUIT)));
|
||||
|
||||
if(do_held)
|
||||
{
|
||||
if(!first_held)
|
||||
{
|
||||
first_held = true;
|
||||
SET_TIMER_EXPIRATION(1, (initial_held) ? 15 : 7);
|
||||
}
|
||||
|
||||
if(IS_TIMER_EXPIRED(1))
|
||||
{
|
||||
first_held = false;
|
||||
trigger_state = input_state; //second input frame set as current frame
|
||||
}
|
||||
|
||||
initial_held = false;
|
||||
}
|
||||
else
|
||||
if(IS_TIMER_EXPIRED(1))
|
||||
{
|
||||
first_held = false;
|
||||
initial_held = true;
|
||||
trigger_state = input_state; //second input frame set as current frame
|
||||
}
|
||||
|
||||
rgui_action_t action = RGUI_ACTION_NOOP;
|
||||
initial_held = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
first_held = false;
|
||||
initial_held = true;
|
||||
}
|
||||
|
||||
// don't run anything first frame, only capture held inputs for old_input_state
|
||||
if (!first)
|
||||
rgui_action_t action = RGUI_ACTION_NOOP;
|
||||
|
||||
// don't run anything first frame, only capture held inputs for old_input_state
|
||||
if (trigger_state & (1ULL << GX_DEVICE_NAV_UP))
|
||||
action = RGUI_ACTION_UP;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_DOWN))
|
||||
action = RGUI_ACTION_DOWN;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_LEFT))
|
||||
action = RGUI_ACTION_LEFT;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_RIGHT))
|
||||
action = RGUI_ACTION_RIGHT;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_B))
|
||||
action = RGUI_ACTION_CANCEL;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_A))
|
||||
action = RGUI_ACTION_OK;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_START))
|
||||
action = RGUI_ACTION_START;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_SELECT))
|
||||
action = RGUI_ACTION_SETTINGS;
|
||||
|
||||
rgui_iterate(rgui, action);
|
||||
|
||||
rarch_render_cached_frame();
|
||||
|
||||
old_input_state = input_state;
|
||||
|
||||
if(IS_TIMER_EXPIRED(0))
|
||||
{
|
||||
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));
|
||||
|
||||
switch(g_extern.console.rmenu.mode)
|
||||
{
|
||||
if (trigger_state & (1ULL << GX_DEVICE_NAV_UP))
|
||||
action = RGUI_ACTION_UP;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_DOWN))
|
||||
action = RGUI_ACTION_DOWN;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_LEFT))
|
||||
action = RGUI_ACTION_LEFT;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_RIGHT))
|
||||
action = RGUI_ACTION_RIGHT;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_B))
|
||||
action = RGUI_ACTION_CANCEL;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_A))
|
||||
action = RGUI_ACTION_OK;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_START))
|
||||
action = RGUI_ACTION_START;
|
||||
else if (trigger_state & (1ULL << GX_DEVICE_NAV_SELECT))
|
||||
action = RGUI_ACTION_SETTINGS;
|
||||
case MODE_EXIT:
|
||||
case MODE_INIT:
|
||||
case MODE_EMULATION:
|
||||
break;
|
||||
default:
|
||||
if (quit_key_pressed)
|
||||
g_extern.console.rmenu.mode = MODE_EXIT;
|
||||
g_extern.console.rmenu.mode = rmenu_enable ? MODE_EMULATION : MODE_MENU;
|
||||
break;
|
||||
}
|
||||
else
|
||||
first = false;
|
||||
}
|
||||
|
||||
rgui_iterate(rgui, action);
|
||||
if (g_extern.console.rmenu.mode != MODE_MENU)
|
||||
goto deinit;
|
||||
|
||||
rarch_render_cached_frame();
|
||||
|
||||
old_input_state = input_state;
|
||||
|
||||
if(IS_TIMER_EXPIRED(0))
|
||||
{
|
||||
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));
|
||||
|
||||
switch(g_extern.console.rmenu.mode)
|
||||
{
|
||||
case MODE_EXIT:
|
||||
case MODE_INIT:
|
||||
break;
|
||||
case MODE_EMULATION:
|
||||
// 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);
|
||||
break;
|
||||
default:
|
||||
if (quit_key_pressed)
|
||||
{
|
||||
g_extern.console.rmenu.mode = MODE_EXIT;
|
||||
g_extern.console.rmenu.state.rmenu.enable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_extern.console.rmenu.state.rmenu.enable = rmenu_enable ? false : true;
|
||||
g_extern.console.rmenu.mode = rmenu_enable ? MODE_EMULATION : MODE_MENU;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}while(g_extern.console.rmenu.state.rmenu.enable);
|
||||
return true;
|
||||
|
||||
deinit:
|
||||
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.draw_menu = false;
|
||||
g_extern.console.rmenu.state.ingame_menu.enable = false;
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void menu_init(void)
|
||||
|
@ -489,7 +489,6 @@ struct global
|
||||
rarch_boolean_state_t msg_fps;
|
||||
rarch_boolean_state_t msg_info;
|
||||
rarch_boolean_state_t ingame_menu;
|
||||
rarch_boolean_state_t rmenu;
|
||||
rarch_boolean_state_t rmenu_widescreen;
|
||||
rarch_boolean_state_t rmenu_hd;
|
||||
} state;
|
||||
|
@ -471,9 +471,9 @@ 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));
|
||||
bool rmenu_enable = ((quit_rarch || goto_menu_pressed));
|
||||
|
||||
if(g_extern.console.rmenu.state.rmenu.enable)
|
||||
if(rmenu_enable)
|
||||
{
|
||||
g_extern.console.rmenu.mode = MODE_MENU;
|
||||
g_extern.console.rmenu.state.ingame_menu.enable = true;
|
||||
@ -483,7 +483,7 @@ static bool gx_input_key_pressed(void *data, int key)
|
||||
if(quit_rarch)
|
||||
g_extern.console.rmenu.mode = MODE_EXIT;
|
||||
|
||||
retval = g_extern.console.rmenu.state.rmenu.enable;
|
||||
retval = rmenu_enable;
|
||||
return retval;
|
||||
}
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user