Standardize rmenu_generic code more

This commit is contained in:
twinaphex 2013-03-07 15:59:47 +01:00
parent 6899434609
commit 361363d423

View File

@ -27,10 +27,8 @@
uint16_t menu_framebuf[400 * 240];
rgui_handle_t *rgui;
#ifdef GEKKO
static const struct retro_keybind _rmenu_nav_binds[] = {
#ifdef HW_RVL
#if defined(HW_RVL)
{ 0, 0, NULL, 0, GX_GC_UP | GX_GC_LSTICK_UP | GX_GC_RSTICK_UP | GX_CLASSIC_UP | GX_CLASSIC_LSTICK_UP | GX_CLASSIC_RSTICK_UP | GX_WIIMOTE_UP | GX_NUNCHUK_UP, 0 },
{ 0, 0, NULL, 0, GX_GC_DOWN | GX_GC_LSTICK_DOWN | GX_GC_RSTICK_DOWN | GX_CLASSIC_DOWN | GX_CLASSIC_LSTICK_DOWN | GX_CLASSIC_RSTICK_DOWN | GX_WIIMOTE_DOWN | GX_NUNCHUK_DOWN, 0 },
{ 0, 0, NULL, 0, GX_GC_LEFT | GX_GC_LSTICK_LEFT | GX_GC_RSTICK_LEFT | GX_CLASSIC_LEFT | GX_CLASSIC_LSTICK_LEFT | GX_CLASSIC_RSTICK_LEFT | GX_WIIMOTE_LEFT | GX_NUNCHUK_LEFT, 0 },
@ -40,7 +38,7 @@ static const struct retro_keybind _rmenu_nav_binds[] = {
{ 0, 0, NULL, 0, GX_GC_START | GX_CLASSIC_PLUS | GX_WIIMOTE_PLUS, 0 },
{ 0, 0, NULL, 0, GX_GC_Z_TRIGGER | GX_CLASSIC_MINUS | GX_WIIMOTE_MINUS, 0 },
{ 0, 0, NULL, 0, GX_WIIMOTE_HOME | GX_CLASSIC_HOME, 0 },
#else
#elif defined(HW_DOL)
{ 0, 0, NULL, 0, GX_GC_UP | GX_GC_LSTICK_UP | GX_GC_RSTICK_UP, 0 },
{ 0, 0, NULL, 0, GX_GC_DOWN | GX_GC_LSTICK_DOWN | GX_GC_RSTICK_DOWN, 0 },
{ 0, 0, NULL, 0, GX_GC_LEFT | GX_GC_LSTICK_LEFT | GX_GC_RSTICK_LEFT, 0 },
@ -50,8 +48,19 @@ static const struct retro_keybind _rmenu_nav_binds[] = {
{ 0, 0, NULL, 0, GX_GC_START, 0 },
{ 0, 0, NULL, 0, GX_GC_Z_TRIGGER, 0 },
{ 0, 0, NULL, 0, GX_WIIMOTE_HOME, 0 },
#endif
{ 0, 0, NULL, 0, GX_QUIT_KEY, 0 },
#else
{ 0, 0, NULL, 0, (1ULL << RETRO_DEVICE_ID_JOYPAD_UP), 0 },
{ 0, 0, NULL, 0, (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN), 0 },
{ 0, 0, NULL, 0, (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT), 0 },
{ 0, 0, NULL, 0, (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT), 0 },
{ 0, 0, NULL, 0, (1ULL << RETRO_DEVICE_ID_JOYPAD_B), 0 },
{ 0, 0, NULL, 0, (1ULL << RETRO_DEVICE_ID_JOYPAD_A), 0 },
{ 0, 0, NULL, 0, (1ULL << RETRO_DEVICE_ID_JOYPAD_START), 0 },
{ 0, 0, NULL, 0, (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT), 0 },
{ 0, 0, NULL, 0, (1ULL << RARCH_RMENU_TOGGLE), 0 },
{ 0, 0, NULL, 0, (1ULL << RARCH_QUIT_KEY), 0 },
#endif
};
static const struct retro_keybind *rmenu_nav_binds[] = {
@ -73,6 +82,9 @@ enum
RMENU_DEVICE_NAV_LAST
};
#ifdef GEKKO
static bool folder_cb(const char *directory, rgui_file_enum_cb_t file_cb,
void *userdata, void *ctx)
{
@ -245,11 +257,7 @@ int rmenu_input_process(void *data, void *state)
if (!(g_extern.frame_count < g_extern.delay_timer[0]))
{
#ifdef GEKKO
bool return_to_game_enable = ((trigger_state & (1ULL << GX_DEVICE_NAV_MENU)) && g_extern.main_is_init);
#else
bool return_to_game_enable = ((g_extern.lifecycle_mode_state & (1ULL << RARCH_RMENU_TOGGLE)) && g_extern.main_is_init);
#endif
if (return_to_game_enable)
{
@ -362,10 +370,6 @@ deinit:
#else
bool rmenu_iterate(void)
{
static const struct retro_keybind *binds[] = {
g_settings.input.binds[0]
};
static uint16_t old_input_state = 0;
static bool initial_held = true;
static bool first_held = false;
@ -413,16 +417,19 @@ bool rmenu_iterate(void)
uint16_t input_state = 0;
for (unsigned i = 0; i < RMENU_DEVICE_NAV_LAST; i++)
input_state |= driver.input->input_state(NULL, rmenu_nav_binds, 0,
RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;
#ifdef HAVE_OVERLAY
for (unsigned i = 0; i < 16; i++)
{
input_state |= driver.input->input_state(NULL, binds, 0, RETRO_DEVICE_JOYPAD, 0, i) ? (1ULL << i) : 0;
#ifdef HAVE_OVERLAY
input_state |= driver.overlay_state & (1ULL << i) ? (1ULL << i) : 0;
#endif
}
#endif
trigger_state = input_state & ~old_input_state;
bool do_held = input_state & ((1ULL << RETRO_DEVICE_ID_JOYPAD_UP) | (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) | (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) | (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT));
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)
{
@ -451,22 +458,29 @@ bool rmenu_iterate(void)
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 << RETRO_DEVICE_ID_JOYPAD_UP))
if (trigger_state & (1ULL << GX_DEVICE_NAV_UP))
action = RGUI_ACTION_UP;
else if (trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN))
else if (trigger_state & (1ULL << GX_DEVICE_NAV_DOWN))
action = RGUI_ACTION_DOWN;
else if (trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT))
else if (trigger_state & (1ULL << GX_DEVICE_NAV_LEFT))
action = RGUI_ACTION_LEFT;
else if (trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT))
else if (trigger_state & (1ULL << GX_DEVICE_NAV_RIGHT))
action = RGUI_ACTION_RIGHT;
else if (trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_B))
else if (trigger_state & (1ULL << GX_DEVICE_NAV_B))
action = RGUI_ACTION_CANCEL;
else if (trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_A))
else if (trigger_state & (1ULL << GX_DEVICE_NAV_A))
action = RGUI_ACTION_OK;
else if (trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_START))
else if (trigger_state & (1ULL << GX_DEVICE_NAV_START))
action = RGUI_ACTION_START;
//else if (trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT))
// action = RGUI_ACTION_SETTINGS;
else if (trigger_state & (1ULL << GX_DEVICE_NAV_SELECT))
action = RGUI_ACTION_SETTINGS;
#if 0
else if (trigger_state & (1ULL << GX_DEVICE_NAV_QUIT))
{
g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT);
goto deinit;
}
#endif
int input_entry_ret = 0;
int input_process_ret = 0;