(Wii) Add changes to Rmenu code

This commit is contained in:
twinaphex 2013-01-11 04:36:40 +01:00
parent c869e3f32c
commit 28566bd3e1
3 changed files with 86 additions and 44 deletions

View File

@ -363,7 +363,7 @@ static void render_messagebox(rgui_handle_t *rgui, const char *message)
static void render_text(rgui_handle_t *rgui)
{
if (rgui->need_refresh &&
(g_extern.console.rmenu.mode & (1ULL << MODE_MENU))
(g_extern.lifecycle_menu_state & (1ULL << MODE_MENU))
&& !rgui->msg_force)
return;
@ -567,7 +567,7 @@ static void render_text(rgui_handle_t *rgui)
#define MAX_GAMMA_SETTING 1
#endif
static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t action, rgui_file_type_t menu_type)
static int rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t action, rgui_file_type_t menu_type)
{
unsigned port = menu_type - RGUI_SETTINGS_CONTROLLER_1;
@ -581,7 +581,8 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
rarch_save_state();
else
rarch_load_state();
g_extern.lifecycle_menu_state = (1 << MODE_EMULATION);
g_extern.lifecycle_menu_state |= (1 << MODE_EMULATION);
return -1;
}
else if (action == RGUI_ACTION_START)
rarch_settings_default(S_DEF_SAVE_STATE);
@ -610,8 +611,9 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
case RGUI_SETTINGS_RESTART_GAME:
if (action == RGUI_ACTION_OK)
{
g_extern.lifecycle_menu_state = (1 << MODE_EMULATION);
rarch_game_reset();
g_extern.lifecycle_menu_state |= (1 << MODE_EMULATION);
return -1;
}
break;
case RGUI_SETTINGS_VIDEO_FILTER:
@ -761,14 +763,17 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
snprintf(g_extern.console.external_launch.launch_app, sizeof(g_extern.console.external_launch.launch_app), "%s/boot.dol", default_paths.core_dir);
#endif
g_extern.console.external_launch.enable = true;
g_extern.lifecycle_menu_state = (1 << MODE_EXIT);
g_extern.lifecycle_menu_state &= ~(1 << MODE_EMULATION);
g_extern.lifecycle_menu_state |= (1 << MODE_EXIT);
return -1;
}
break;
case RGUI_SETTINGS_QUIT_EMULATOR:
if (action == RGUI_ACTION_OK)
{
g_extern.lifecycle_menu_state &= ~((1 << MODE_MENU) | (1 << MODE_MENU_INGAME) | (1 << MODE_EMULATION));
g_extern.lifecycle_menu_state &= ~(1 << MODE_EMULATION);
g_extern.lifecycle_menu_state |= (1 << MODE_EXIT);
return -1;
}
break;
// controllers
@ -829,6 +834,8 @@ static void rgui_settings_toggle_setting(rgui_file_type_t setting, rgui_action_t
default:
break;
}
return 0;
}
#define RGUI_MENU_ITEM(x, y) rgui_list_push(rgui->folder_buf, x, y, 0)
@ -896,7 +903,7 @@ static void rgui_settings_controller_populate_entries(rgui_handle_t *rgui)
}
void rgui_viewport_iterate(rgui_handle_t *rgui, rgui_action_t action)
int rgui_viewport_iterate(rgui_handle_t *rgui, rgui_action_t action)
{
#ifdef GEKKO
gx_video_t *gx = (gx_video_t*)driver.video_data;
@ -1012,9 +1019,11 @@ void rgui_viewport_iterate(rgui_handle_t *rgui, rgui_action_t action)
render_messagebox(rgui, "Set Upper-Left Corner");
else if (menu_type == RGUI_SETTINGS_CUSTOM_VIEWPORT_2)
render_messagebox(rgui, "Set Bottom-Right Corner");
return 0;
}
void rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
int rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
{
rgui->frame_buf_pitch = RGUI_WIDTH * 2;
rgui_file_type_t type = 0;
@ -1070,7 +1079,12 @@ void rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
video_set_aspect_ratio_func(g_settings.video.aspect_ratio_idx);
}
else
rgui_settings_toggle_setting(type, action, menu_type);
{
int ret = rgui_settings_toggle_setting(type, action, menu_type);
if (ret != 0)
return ret;
}
break;
case RGUI_ACTION_REFRESH:
@ -1099,10 +1113,10 @@ void rgui_settings_iterate(rgui_handle_t *rgui, rgui_action_t action)
render_text(rgui);
return;
return 0;
}
void rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
int rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
{
const char *dir = 0;
rgui_file_type_t menu_type = 0;
@ -1158,7 +1172,7 @@ void rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
case RGUI_ACTION_OK:
{
if (rgui_list_size(rgui->folder_buf) == 0)
return;
return 0;
const char *path = 0;
rgui_file_type_t type = 0;
@ -1203,6 +1217,7 @@ void rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
rarch_console_load_game_wrap(rgui->path_buf, g_extern.file_state.zip_extract_mode);
rgui->need_refresh = true; // in case of zip extract
rgui->msg_force = true;
return -1;
}
}
break;
@ -1238,7 +1253,7 @@ void rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
// refresh values in case the stack changed
rgui_list_back(rgui->path_stack, &dir, &menu_type, &directory_ptr);
if (rgui->need_refresh && (menu_type == RGUI_FILE_DIRECTORY || menu_type == RGUI_FILE_DEVICE || menu_type == RGUI_SETTINGS_CORE) && (g_extern.console.rmenu.mode & (1ULL << MODE_MENU)))
if (rgui->need_refresh && (menu_type == RGUI_FILE_DIRECTORY || menu_type == RGUI_FILE_DEVICE || menu_type == RGUI_SETTINGS_CORE))
{
rgui->need_refresh = false;
rgui_list_clear(rgui->folder_buf);
@ -1251,4 +1266,6 @@ void rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
}
render_text(rgui);
return 0;
}

View File

@ -114,7 +114,7 @@ rgui_handle_t *rgui_init(const char *base_path,
const uint8_t *font_bmp_buf, const uint8_t *font_bin_buf,
rgui_folder_enum_cb_t folder_cb, void *userdata);
void rgui_iterate(rgui_handle_t *rgui, rgui_action_t action);
int rgui_iterate(rgui_handle_t *rgui, rgui_action_t action);
void rgui_free(rgui_handle_t *rgui);

View File

@ -21,7 +21,7 @@
uint16_t menu_framebuf[400 * 240];
static const struct retro_keybind _gx_nav_binds[] = {
static const struct retro_keybind _rmenu_nav_binds[] = {
#ifdef HW_RVL
{ 0, 0, 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, 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 },
@ -46,8 +46,8 @@ static const struct retro_keybind _gx_nav_binds[] = {
{ 0, 0, 0, GX_QUIT_KEY, 0 },
};
static const struct retro_keybind *gx_nav_binds[] = {
_gx_nav_binds
static const struct retro_keybind *rmenu_nav_binds[] = {
_rmenu_nav_binds
};
enum
@ -62,7 +62,7 @@ enum
GX_DEVICE_NAV_SELECT,
GX_DEVICE_NAV_MENU,
GX_DEVICE_NAV_QUIT,
GX_DEVICE_NAV_LAST
RMENU_DEVICE_NAV_LAST
};
static bool folder_cb(const char *directory, rgui_file_enum_cb_t file_cb,
@ -165,6 +165,45 @@ void menu_free(void)
rgui_free(rgui);
}
static uint16_t trigger_state = 0;
int rmenu_input_process(void *data, void *state)
{
if (g_extern.lifecycle_menu_state & (1 << MODE_LOAD_GAME))
{
if(g_extern.console.rmenu.state.msg_info.enable)
rarch_settings_msg(S_MSG_LOADING_ROM, 100);
if (g_extern.fullpath)
g_extern.lifecycle_menu_state = (1 << MODE_INIT);
g_extern.lifecycle_menu_state |= (1 << MODE_INIT);
g_extern.lifecycle_menu_state &= ~(1 << MODE_LOAD_GAME);
return -1;
}
if (!(g_extern.frame_count < g_extern.delay_timer[0]))
{
bool return_to_game_enable = ((trigger_state & (1ULL << GX_DEVICE_NAV_MENU)) && g_extern.main_is_init);
bool quit_key_pressed = (trigger_state & (1ULL << GX_DEVICE_NAV_QUIT));
if (return_to_game_enable)
{
g_extern.lifecycle_menu_state |= (1 << MODE_EMULATION);
return -1;
}
if (quit_key_pressed)
{
g_extern.lifecycle_menu_state &= ~((1 << MODE_EMULATION));
g_extern.lifecycle_menu_state |= (1 << MODE_EXIT);
return -1;
}
}
return 0;
}
bool rmenu_iterate(void)
{
static uint16_t old_input_state = 0;
@ -176,15 +215,17 @@ bool rmenu_iterate(void)
g_extern.frame_count++;
rarch_render_cached_frame();
uint16_t input_state = 0;
driver.input->poll(NULL);
for (unsigned i = 0; i < GX_DEVICE_NAV_LAST; i++)
input_state |= driver.input->input_state(NULL, gx_nav_binds, 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;
uint16_t trigger_state = input_state & ~old_input_state;
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)
@ -209,6 +250,8 @@ bool rmenu_iterate(void)
initial_held = true;
}
old_input_state = input_state;
rgui_action_t action = RGUI_ACTION_NOOP;
// don't run anything first frame, only capture held inputs for old_input_state
@ -229,32 +272,14 @@ bool rmenu_iterate(void)
else if (trigger_state & (1ULL << GX_DEVICE_NAV_SELECT))
action = RGUI_ACTION_SETTINGS;
rgui_iterate(rgui, action);
int input_entry_ret = 0;
int input_process_ret = 0;
rarch_render_cached_frame();
input_entry_ret = rgui_iterate(rgui, action);
old_input_state = input_state;
input_process_ret = rmenu_input_process(NULL, NULL);
if (g_extern.lifecycle_menu_state & (1 << MODE_LOAD_GAME))
{
if(g_extern.console.rmenu.state.msg_info.enable)
rarch_settings_msg(S_MSG_LOADING_ROM, 100);
if (g_extern.fullpath)
g_extern.lifecycle_menu_state = (1 << MODE_INIT);
}
if (!(g_extern.frame_count < g_extern.delay_timer[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));
if (g_extern.lifecycle_menu_state & (1 << MODE_MENU))
g_extern.lifecycle_menu_state = quit_key_pressed ? (1 << MODE_EXIT) : rmenu_enable ? (1 << MODE_EMULATION) : (1 << MODE_MENU);
}
if(!(g_extern.lifecycle_menu_state & (1 << MODE_MENU))
&& !(g_extern.lifecycle_menu_state & (1 << MODE_LOAD_GAME)))
if (input_entry_ret != 0 || input_process_ret != 0)
goto deinit;
return true;