From 5506674c698c289f526612e57c6575d8a32cbbbb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 14 Oct 2014 22:02:27 +0200 Subject: [PATCH 01/42] settings_list.c - Add action OK callback --- frontend/menu/menu_action.c | 44 ++------------------------- settings_data.c | 60 +++++++++++++++++++++++++++++++++++++ settings_list.h | 4 ++- 3 files changed, 65 insertions(+), 43 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index 1ccd27b32e..033844e121 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -39,48 +39,8 @@ int menu_action_setting_apply(rarch_setting_t *setting) int menu_action_setting_boolean( rarch_setting_t *setting, unsigned action) { - if ( - !strcmp(setting->name, "savestate") || - !strcmp(setting->name, "loadstate")) - { - switch (action) - { - case MENU_ACTION_START: - g_settings.state_slot = 0; - break; - case MENU_ACTION_LEFT: - // Slot -1 is (auto) slot. - if (g_settings.state_slot >= 0) - g_settings.state_slot--; - break; - case MENU_ACTION_RIGHT: - g_settings.state_slot++; - break; - case MENU_ACTION_OK: - *setting->value.boolean = !(*setting->value.boolean); - - if (setting->cmd_trigger.idx != RARCH_CMD_NONE) - setting->cmd_trigger.triggered = true; - break; - } - } - else - { - switch (action) - { - case MENU_ACTION_OK: - if (setting->cmd_trigger.idx != RARCH_CMD_NONE) - setting->cmd_trigger.triggered = true; - /* fall-through */ - case MENU_ACTION_LEFT: - case MENU_ACTION_RIGHT: - *setting->value.boolean = !(*setting->value.boolean); - break; - case MENU_ACTION_START: - *setting->value.boolean = setting->default_value.boolean; - break; - } - } + if (setting->action_ok) + setting->action_ok(setting, action); return menu_action_setting_apply(setting); } diff --git a/settings_data.c b/settings_data.c index 44789f59f3..23febf105e 100644 --- a/settings_data.c +++ b/settings_data.c @@ -673,6 +673,62 @@ void setting_data_get_string_representation(rarch_setting_t* setting, } } +static int setting_data_bool_action_ok_savestates(void *data, unsigned action) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting) + return -1; + + switch (action) + { + case MENU_ACTION_START: + g_settings.state_slot = 0; + break; + case MENU_ACTION_LEFT: + // Slot -1 is (auto) slot. + if (g_settings.state_slot >= 0) + g_settings.state_slot--; + break; + case MENU_ACTION_RIGHT: + g_settings.state_slot++; + break; + case MENU_ACTION_OK: + *setting->value.boolean = !(*setting->value.boolean); + + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; + break; + } + + return 0; +} + +static int setting_data_bool_action_ok_default(void *data, unsigned action) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting) + return -1; + + switch (action) + { + case MENU_ACTION_OK: + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; + /* fall-through */ + case MENU_ACTION_LEFT: + case MENU_ACTION_RIGHT: + *setting->value.boolean = !(*setting->value.boolean); + break; + case MENU_ACTION_START: + *setting->value.boolean = setting->default_value.boolean; + break; + } + + return 0; +} + rarch_setting_t setting_data_group_setting(enum setting_type type, const char* name) { rarch_setting_t result = { type, name }; @@ -723,6 +779,8 @@ rarch_setting_t setting_data_bool_setting(const char* name, result.default_value.boolean = default_value; result.boolean.off_label = off; result.boolean.on_label = on; + + result.action_ok = setting_data_bool_action_ok_default; return result; } @@ -2325,6 +2383,7 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name, general_write_handler, general_read_handler); + (*list)[list_info->index - 1].action_ok = &setting_data_bool_action_ok_savestates; settings_list_current_add_cmd (list, list_info, RARCH_CMD_SAVE_STATE); settings_list_current_add_flags(list, list_info, SD_FLAG_EXIT); @@ -2339,6 +2398,7 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name, general_write_handler, general_read_handler); + (*list)[list_info->index - 1].action_ok = &setting_data_bool_action_ok_savestates; settings_list_current_add_cmd (list, list_info, RARCH_CMD_LOAD_STATE); settings_list_current_add_flags(list, list_info, SD_FLAG_EXIT); diff --git a/settings_list.h b/settings_list.h index bcba7aa5eb..1154145657 100644 --- a/settings_list.h +++ b/settings_list.h @@ -81,6 +81,7 @@ enum setting_list_flags #define SL_FLAG_ALL_SETTINGS (SL_FLAG_ALL - SL_FLAG_MAIN_MENU) typedef void (*change_handler_t)(void *data); +typedef int (*action_ok_handler_t)(void *data, unsigned action); typedef struct rarch_setting_info { @@ -115,7 +116,8 @@ typedef struct rarch_setting change_handler_t change_handler; change_handler_t deferred_handler; change_handler_t read_handler; - + action_ok_handler_t action_ok; + union { bool boolean; From b16ce98e342051ee3ce9a7e1d43752052d1b1971 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 14 Oct 2014 22:10:18 +0200 Subject: [PATCH 02/42] menu_action.c - cleanups --- frontend/menu/menu_action.c | 20 ++++++++++---------- frontend/menu/menu_action.h | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index 033844e121..a812a59b37 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -46,9 +46,9 @@ int menu_action_setting_boolean( } int menu_action_setting_unsigned_integer( - rarch_setting_t *setting, unsigned id, unsigned action) + rarch_setting_t *setting, unsigned type, unsigned action) { - if (id == MENU_FILE_LINEFEED) + if (type == MENU_FILE_LINEFEED) { if (action == MENU_ACTION_OK) menu_key_start_line(driver.menu, setting->short_description, @@ -226,17 +226,17 @@ int menu_action_setting_set_current_string_path( int menu_action_handle_setting(rarch_setting_t *setting, - unsigned id, const char *label, unsigned action) + unsigned type, const char *label, unsigned action) { if (setting->type == ST_BOOL) return menu_action_setting_boolean(setting, action); if (setting->type == ST_UINT) - return menu_action_setting_unsigned_integer(setting, id, action); + return menu_action_setting_unsigned_integer(setting, type, action); if (setting->type == ST_FLOAT) return menu_action_setting_fraction(setting, action); if (setting->type == ST_PATH) return menu_entries_set_current_path_selection(setting, - setting->default_value.string, setting->name, id, action); + setting->default_value.string, setting->name, type, action); if (setting->type == ST_DIR) { @@ -252,7 +252,7 @@ int menu_action_handle_setting(rarch_setting_t *setting, { if ( (setting->flags & SD_FLAG_ALLOW_INPUT) || - id == MENU_FILE_LINEFEED_SWITCH) + type == MENU_FILE_LINEFEED_SWITCH) { switch (action) { @@ -360,7 +360,7 @@ unsigned menu_gx_resolutions[GX_RESOLUTIONS_LAST][2] = { unsigned menu_current_gx_resolution = GX_RESOLUTIONS_640_480; #endif -int menu_action_setting_set(unsigned id, const char *label, +int menu_action_setting_set(unsigned type, const char *label, unsigned action) { unsigned port = driver.menu->current_pad; @@ -372,7 +372,7 @@ int menu_action_setting_set(unsigned id, const char *label, driver.menu->list_settings, list->list[driver.menu->selection_ptr].label); if (setting) - return menu_action_handle_setting(setting, id, label, action); + return menu_action_handle_setting(setting, type, label, action); /* Check if setting belongs to main menu. */ @@ -380,7 +380,7 @@ int menu_action_setting_set(unsigned id, const char *label, driver.menu->list_mainmenu, list->list[driver.menu->selection_ptr].label); if (setting) - return menu_action_handle_setting(setting, id, label, action); + return menu_action_handle_setting(setting, type, label, action); /* Fallback. */ @@ -517,7 +517,7 @@ int menu_action_setting_set(unsigned id, const char *label, } else { - switch (id) + switch (type) { #if defined(GEKKO) case MENU_SETTINGS_VIDEO_RESOLUTION: diff --git a/frontend/menu/menu_action.h b/frontend/menu/menu_action.h index 20d40724fe..4ae360fcfa 100644 --- a/frontend/menu/menu_action.h +++ b/frontend/menu/menu_action.h @@ -32,7 +32,7 @@ int menu_action_setting_fraction( rarch_setting_t *setting, unsigned action); int menu_action_setting_unsigned_integer( - rarch_setting_t *setting, unsigned id, unsigned action); + rarch_setting_t *setting, unsigned type, unsigned action); void menu_action_setting_driver( rarch_setting_t *setting, unsigned action); @@ -46,11 +46,11 @@ int menu_action_setting_set_current_string( int menu_action_setting_set_current_string_path( rarch_setting_t *setting, const char *dir, const char *path); -int menu_action_setting_set(unsigned id, const char *label, +int menu_action_setting_set(unsigned type, const char *label, unsigned action); int menu_action_handle_setting(rarch_setting_t *setting, - unsigned id, const char *label, unsigned action); + unsigned type, const char *label, unsigned action); #ifdef __cplusplus } From ffb904796177ab1e67dbb17115c98eab86ecb5c6 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 14 Oct 2014 22:11:44 +0200 Subject: [PATCH 03/42] menu_action.c - Fix 'declaration shadows global variable' --- frontend/menu/menu_action.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index a812a59b37..01b714b105 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -110,13 +110,13 @@ int menu_action_setting_fraction( break; case MENU_ACTION_OK: { - double refresh_rate, deviation = 0.0; + double video_refresh_rate, deviation = 0.0; unsigned sample_points = 0; - if (driver_monitor_fps_statistics(&refresh_rate, + if (driver_monitor_fps_statistics(&video_refresh_rate, &deviation, &sample_points)) { - driver_set_monitor_refresh_rate(refresh_rate); + driver_set_monitor_refresh_rate(video_refresh_rate); /* Incase refresh rate update forced non-block video. */ rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE); } From f7a735bf111c10b71e0298ecef1f82a0d8bb288d Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 14 Oct 2014 22:14:14 +0200 Subject: [PATCH 04/42] dynamic.c - Silence 'declaration shadows global variable' --- dynamic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dynamic.c b/dynamic.c index d327650980..a4b81c52bf 100644 --- a/dynamic.c +++ b/dynamic.c @@ -692,11 +692,11 @@ bool rarch_environment_cb(unsigned cmd, void *data) { for (id = 0; id < RARCH_FIRST_CUSTOM_BIND; id++) { - const char *desc = g_extern.system.input_desc_btn[p][id]; - if (desc) + const char *description = g_extern.system.input_desc_btn[p][id]; + if (description) { RARCH_LOG("\tRetroPad, Player %u, Button \"%s\" => \"%s\"\n", - p + 1, libretro_btn_desc[id], desc); + p + 1, libretro_btn_desc[id], description); } } } From 03fb9797300351d18af20d3f80c9945d9f87ea9f Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 14 Oct 2014 22:16:01 +0200 Subject: [PATCH 05/42] (video_thread_wrapper.c) Fix 'declaration shadows local variable' --- gfx/video_thread_wrapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 73133f5b6c..a6c8a2b370 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -288,7 +288,7 @@ static void thread_loop(void *data) slock_lock(thr->frame.lock); thread_update_driver_state(thr); - bool ret = false; + ret = false; bool alive = false; bool focus = false; bool has_windowed = true; From e67bcb28d0238022e00c49977b58d3c5423bb69e Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 14 Oct 2014 22:21:58 +0200 Subject: [PATCH 06/42] (rxml.c) Silence warnings --- compat/rxml/rxml.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/compat/rxml/rxml.c b/compat/rxml/rxml.c index 75d560284c..3d521a3b0e 100644 --- a/compat/rxml/rxml.c +++ b/compat/rxml/rxml.c @@ -284,15 +284,20 @@ static struct rxml_node *rxml_parse_node(const char **ptr_) /* Parse all child nodes. */ struct rxml_node *list = NULL; struct rxml_node *tail = NULL; + const char *first_start = NULL, *first_closing = NULL; - const char *ptr = child_start; - - const char *first_start = strchr(ptr, '<'); - const char *first_closing = strstr(ptr, " Date: Tue, 14 Oct 2014 22:37:01 +0200 Subject: [PATCH 07/42] (XMB/Lakka) Silence some warnings --- frontend/menu/disp/lakka.c | 14 +++++++------- frontend/menu/disp/xmb.c | 13 +++++-------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/frontend/menu/disp/lakka.c b/frontend/menu/disp/lakka.c index bdd62e5676..4920574493 100644 --- a/frontend/menu/disp/lakka.c +++ b/frontend/menu/disp/lakka.c @@ -89,7 +89,7 @@ static char *str_replace (const char *string, static void lakka_draw_text(lakka_handle_t *lakka, const char *str, float x, - float y, float scale, float alpha) + float y, float scale_factor, float alpha) { if (alpha > lakka->global_alpha) alpha = lakka->global_alpha; @@ -116,7 +116,7 @@ static void lakka_draw_text(lakka_handle_t *lakka, params.x = x / gl->win_width; params.y = 1.0f - y / gl->win_height; - params.scale = scale; + params.scale = scale_factor; params.color = FONT_COLOR_RGBA(255, 255, 255, a8); params.full_screen = true; @@ -196,9 +196,12 @@ static void lakka_draw_background(bool force_transparency) static void lakka_draw_icon(lakka_handle_t *lakka, GLuint texture, float x, float y, - float alpha, float rotation, float scale) + float alpha, float rotation, + float scale_factor) { struct gl_coords coords; + math_matrix mymat, mrot; + if (!lakka) return; @@ -236,14 +239,11 @@ static void lakka_draw_icon(lakka_handle_t *lakka, coords.color = color; glBindTexture(GL_TEXTURE_2D, texture); - math_matrix mymat; - - math_matrix mrot; matrix_rotate_z(&mrot, rotation); matrix_multiply(&mymat, &mrot, &gl->mvp_no_rot); math_matrix mscal; - matrix_scale(&mscal, scale, scale, 1); + matrix_scale(&mscal, scale_factor, scale_factor, 1); matrix_multiply(&mymat, &mscal, &mymat); gl->shader->set_coords(&coords); diff --git a/frontend/menu/disp/xmb.c b/frontend/menu/disp/xmb.c index b6e047c6e6..ae3caaff21 100644 --- a/frontend/menu/disp/xmb.c +++ b/frontend/menu/disp/xmb.c @@ -118,9 +118,10 @@ static const GLfloat rmb_tex_coord[] = { }; static void xmb_draw_icon(GLuint texture, float x, float y, - float alpha, float rotation, float scale) + float alpha, float rotation, float scale_factor) { struct gl_coords coords; + math_matrix mymat, mrot, mscal; xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; if (!xmb) @@ -160,14 +161,10 @@ static void xmb_draw_icon(GLuint texture, float x, float y, coords.color = color; glBindTexture(GL_TEXTURE_2D, texture); - math_matrix mymat; - - math_matrix mrot; matrix_rotate_z(&mrot, rotation); matrix_multiply(&mymat, &mrot, &gl->mvp_no_rot); - math_matrix mscal; - matrix_scale(&mscal, scale, scale, 1); + matrix_scale(&mscal, scale_factor, scale_factor, 1); matrix_multiply(&mymat, &mscal, &mymat); gl->shader->set_coords(&coords); @@ -180,7 +177,7 @@ static void xmb_draw_icon(GLuint texture, float x, float y, } static void xmb_draw_text(const char *str, float x, - float y, float scale, float alpha) + float y, float scale_factor, float alpha) { uint8_t a8 = 0; struct font_params params = {0}; @@ -209,7 +206,7 @@ static void xmb_draw_text(const char *str, float x, params.x = x / gl->win_width; params.y = 1.0f - y / gl->win_height; - params.scale = scale; + params.scale = scale_factor; params.color = FONT_COLOR_RGBA(255, 255, 255, a8); params.full_screen = true; From 860c9c575079f84475300e4bcc2987b063c245b2 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 14 Oct 2014 22:38:05 +0200 Subject: [PATCH 08/42] (settings_data.c) Silence some warnings --- settings_data.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/settings_data.c b/settings_data.c index 23febf105e..7b3029125d 100644 --- a/settings_data.c +++ b/settings_data.c @@ -576,13 +576,13 @@ static void menu_common_setting_set_label_st_float(rarch_setting_t *setting, if (!strcmp(setting->name, "video_refresh_rate_auto")) { - double refresh_rate = 0.0; + double video_refresh_rate = 0.0; double deviation = 0.0; unsigned sample_points = 0; - if (driver_monitor_fps_statistics(&refresh_rate, &deviation, &sample_points)) + if (driver_monitor_fps_statistics(&video_refresh_rate, &deviation, &sample_points)) snprintf(type_str, type_str_size, "%.3f Hz (%.1f%% dev, %u samples)", - refresh_rate, 100.0 * deviation, sample_points); + video_refresh_rate, 100.0 * deviation, sample_points); else strlcpy(type_str, "N/A", type_str_size); From 705c542911ae6f4ac705d5fc66e35c2a95bd698d Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 14 Oct 2014 22:41:35 +0200 Subject: [PATCH 09/42] (input/overlay.c) input_overlay_resolve_targets - do explicit cast --- input/overlay.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/input/overlay.c b/input/overlay.c index 9e555a5113..abfdf0a4c4 100644 --- a/input/overlay.c +++ b/input/overlay.c @@ -375,6 +375,7 @@ static bool input_overlay_load_overlay(input_overlay_t *ol, snprintf(overlay_path_key, sizeof(overlay_path_key), "overlay%u_overlay", index); + if (config_get_path(conf, overlay_path_key, overlay_path, sizeof(overlay_path))) { @@ -527,7 +528,7 @@ static bool input_overlay_resolve_targets(struct overlay *ol, size_t index, size_t size) { size_t i; - struct overlay *current = &ol[index]; + struct overlay *current = (struct overlay*)&ol[index]; for (i = 0; i < current->size; i++) { From d82929f031fc65a77e66cd583858c3214c7bdc0a Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 14 Oct 2014 22:52:13 +0200 Subject: [PATCH 10/42] Silence warnings in overlay.c --- input/overlay.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/input/overlay.c b/input/overlay.c index abfdf0a4c4..63d3f52cfa 100644 --- a/input/overlay.c +++ b/input/overlay.c @@ -535,15 +535,15 @@ static bool input_overlay_resolve_targets(struct overlay *ol, const char *next = current->descs[i].next_index_name; if (*next) { - ssize_t index = input_overlay_find_index(ol, next, size); - if (index < 0) + ssize_t idx = input_overlay_find_index(ol, next, size); + if (idx < 0) { RARCH_ERR("[Overlay]: Couldn't find overlay called: \"%s\".\n", next); return false; } - current->descs[i].next_index = index; + current->descs[i].next_index = idx; } else current->descs[i].next_index = (index + 1) % size; From d724d59d60abb81e42a380500b15920f9d6a360d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Tue, 14 Oct 2014 23:05:53 +0200 Subject: [PATCH 11/42] (XMB) Folder, file and archive icons --- frontend/menu/disp/xmb.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/frontend/menu/disp/xmb.c b/frontend/menu/disp/xmb.c index ae3caaff21..2d8240aa65 100644 --- a/frontend/menu/disp/xmb.c +++ b/frontend/menu/disp/xmb.c @@ -59,6 +59,9 @@ enum XMB_TEXTURE_LOADSTATE, XMB_TEXTURE_SCREENSHOT, XMB_TEXTURE_RELOAD, + XMB_TEXTURE_FILE, + XMB_TEXTURE_FOLDER, + XMB_TEXTURE_ZIP, XMB_TEXTURE_LAST }; @@ -469,7 +472,24 @@ static void xmb_frame(void) entry_label, path, path_buf, sizeof(path_buf)); - xmb_draw_icon(xmb->textures[XMB_TEXTURE_SETTING].id, + GLuint icon = 0; + switch(type) + { + case MENU_FILE_DIRECTORY: + icon = xmb->textures[XMB_TEXTURE_FOLDER].id; + break; + case MENU_FILE_PLAIN: + icon = xmb->textures[XMB_TEXTURE_FILE].id; + break; + case MENU_FILE_CARCHIVE: + icon = xmb->textures[XMB_TEXTURE_ZIP].id; + break; + default: + icon = xmb->textures[XMB_TEXTURE_SETTING].id; + break; + } + + xmb_draw_icon(icon, xmb->x + xmb->margin_left + xmb->hspacing - xmb->icon_size/2.0, xmb->margin_top + node->y + xmb->icon_size/2.0, node->alpha, @@ -763,6 +783,12 @@ static void xmb_context_reset(void *data) "screenshot.png", sizeof(xmb->textures[XMB_TEXTURE_SCREENSHOT].path)); fill_pathname_join(xmb->textures[XMB_TEXTURE_RELOAD].path, iconpath, "reload.png", sizeof(xmb->textures[XMB_TEXTURE_RELOAD].path)); + fill_pathname_join(xmb->textures[XMB_TEXTURE_FILE].path, iconpath, + "file.png", sizeof(xmb->textures[XMB_TEXTURE_RELOAD].path)); + fill_pathname_join(xmb->textures[XMB_TEXTURE_FOLDER].path, iconpath, + "folder.png", sizeof(xmb->textures[XMB_TEXTURE_RELOAD].path)); + fill_pathname_join(xmb->textures[XMB_TEXTURE_ZIP].path, iconpath, + "zip.png", sizeof(xmb->textures[XMB_TEXTURE_RELOAD].path)); for (k = 0; k < XMB_TEXTURE_LAST; k++) xmb->textures[k].id = xmb_png_texture_load(xmb->textures[k].path); From 682259eec5f49da86b8dfb36a60fbc331ef440b1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 00:30:23 +0200 Subject: [PATCH 12/42] (linuxraw_input.c) Check for null pointer dereferences --- input/linuxraw_input.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/input/linuxraw_input.c b/input/linuxraw_input.c index 487339ff44..2928d614f4 100644 --- a/input/linuxraw_input.c +++ b/input/linuxraw_input.c @@ -61,7 +61,7 @@ static void *linuxraw_input_init(void) if (driver.stdin_claimed) { - RARCH_WARN("stdin is already used for ROM loading. Cannot use stdin for input.\n"); + RARCH_WARN("stdin is already used for content loading. Cannot use stdin for input.\n"); return NULL; } @@ -98,7 +98,9 @@ static void *linuxraw_input_init(void) sa.sa_handler = linuxraw_exitGracefully; sa.sa_flags = SA_RESTART | SA_RESETHAND; sigemptyset(&sa.sa_mask); - // trap some standard termination codes so we can restore the keyboard before we lose control + + /* Trap some standard termination codes so we + * can restore the keyboard before we lose control. */ sigaction(SIGABRT, &sa, NULL); sigaction(SIGBUS, &sa, NULL); sigaction(SIGFPE, &sa, NULL); @@ -111,7 +113,9 @@ static void *linuxraw_input_init(void) linuxraw->joypad = input_joypad_init_driver(g_settings.input.joypad_driver); input_init_keyboard_lut(rarch_key_map_linux); - driver.stdin_claimed = true; // We need to disable use of stdin command interface if stdin is supposed to be used for input. + /* We need to disable use of stdin command interface if + * stdin is supposed to be used for input. */ + driver.stdin_claimed = true; return linuxraw; } @@ -121,12 +125,14 @@ static bool linuxraw_key_pressed(linuxraw_input_t *linuxraw, int key) return linuxraw->state[sym]; } -static bool linuxraw_is_pressed(linuxraw_input_t *linuxraw, const struct retro_keybind *binds, unsigned id) +static bool linuxraw_is_pressed(linuxraw_input_t *linuxraw, + const struct retro_keybind *binds, unsigned id) { if (id < RARCH_BIND_LIST_END) { const struct retro_keybind *bind = &binds[id]; - return bind->valid && linuxraw_key_pressed(linuxraw, binds[id].key); + if (bind) + return bind->valid && linuxraw_key_pressed(linuxraw, binds[id].key); } return false; } @@ -152,7 +158,9 @@ static bool linuxraw_bind_button_pressed(void *data, int key) input_joypad_pressed(linuxraw->joypad, 0, g_settings.input.binds[0], key); } -static int16_t linuxraw_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id) +static int16_t linuxraw_input_state(void *data, + const struct retro_keybind **binds, unsigned port, + unsigned device, unsigned index, unsigned id) { linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; int16_t ret; @@ -188,16 +196,21 @@ static void linuxraw_input_free(void *data) free(data); } -static bool linuxraw_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength) +static bool linuxraw_set_rumble(void *data, unsigned port, + enum retro_rumble_effect effect, uint16_t strength) { linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; - return input_joypad_set_rumble(linuxraw->joypad, port, effect, strength); + if (linuxraw) + return input_joypad_set_rumble(linuxraw->joypad, port, effect, strength); + return false; } static const rarch_joypad_driver_t *linuxraw_get_joypad_driver(void *data) { linuxraw_input_t *linuxraw = (linuxraw_input_t*)data; - return linuxraw->joypad; + if (linuxraw) + return linuxraw->joypad; + return NULL; } static void linuxraw_input_poll(void *data) From 88aa5e62e36fb2a95c5ba09b4ea36be42e0c234b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 00:47:38 +0200 Subject: [PATCH 13/42] Implement action OK for ST_UINT settings --- frontend/menu/menu_action.c | 48 +------ settings_data.c | 252 ++++++++++++++++++++++++------------ 2 files changed, 174 insertions(+), 126 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index 01b714b105..2581ee0ec0 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -48,52 +48,8 @@ int menu_action_setting_boolean( int menu_action_setting_unsigned_integer( rarch_setting_t *setting, unsigned type, unsigned action) { - if (type == MENU_FILE_LINEFEED) - { - if (action == MENU_ACTION_OK) - menu_key_start_line(driver.menu, setting->short_description, - setting->name, st_uint_callback); - else if (action == MENU_ACTION_START) - *setting->value.unsigned_integer = - setting->default_value.unsigned_integer; - } - else - { - switch (action) - { - case MENU_ACTION_LEFT: - if (*setting->value.unsigned_integer != setting->min) - *setting->value.unsigned_integer = - *setting->value.unsigned_integer - setting->step; - - if (setting->enforce_minrange) - { - if (*setting->value.unsigned_integer < setting->min) - *setting->value.unsigned_integer = setting->min; - } - break; - - case MENU_ACTION_OK: - if (setting->cmd_trigger.idx != RARCH_CMD_NONE) - setting->cmd_trigger.triggered = true; - /* fall-through */ - case MENU_ACTION_RIGHT: - *setting->value.unsigned_integer = - *setting->value.unsigned_integer + setting->step; - - if (setting->enforce_maxrange) - { - if (*setting->value.unsigned_integer > setting->max) - *setting->value.unsigned_integer = setting->max; - } - break; - - case MENU_ACTION_START: - *setting->value.unsigned_integer = - setting->default_value.unsigned_integer; - break; - } - } + if (setting->action_ok) + setting->action_ok(setting, action); return menu_action_setting_apply(setting); } diff --git a/settings_data.c b/settings_data.c index 7b3029125d..0b23ed850a 100644 --- a/settings_data.c +++ b/settings_data.c @@ -35,6 +35,7 @@ #ifdef HAVE_MENU #include "frontend/menu/menu_entries.h" +#include "frontend/menu/menu_input_line_cb.h" #include "frontend/menu/menu_shader.h" #endif @@ -729,6 +730,73 @@ static int setting_data_bool_action_ok_default(void *data, unsigned action) return 0; } +static int setting_data_uint_action_ok_default(void *data, unsigned action) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting) + return -1; + + switch (action) + { + case MENU_ACTION_LEFT: + if (*setting->value.unsigned_integer != setting->min) + *setting->value.unsigned_integer = + *setting->value.unsigned_integer - setting->step; + + if (setting->enforce_minrange) + { + if (*setting->value.unsigned_integer < setting->min) + *setting->value.unsigned_integer = setting->min; + } + break; + + case MENU_ACTION_OK: + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; + /* fall-through */ + case MENU_ACTION_RIGHT: + *setting->value.unsigned_integer = + *setting->value.unsigned_integer + setting->step; + + if (setting->enforce_maxrange) + { + if (*setting->value.unsigned_integer > setting->max) + *setting->value.unsigned_integer = setting->max; + } + break; + + case MENU_ACTION_START: + *setting->value.unsigned_integer = + setting->default_value.unsigned_integer; + break; + } + + return 0; +} + +static int setting_data_uint_action_ok_linefeed(void *data, unsigned action) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting) + return -1; + + switch (action) + { + case MENU_ACTION_OK: + menu_key_start_line(driver.menu, setting->short_description, + setting->name, st_uint_callback); + break; + case MENU_ACTION_START: + *setting->value.unsigned_integer = + setting->default_value.unsigned_integer; + break; + } + + return 0; +} + rarch_setting_t setting_data_group_setting(enum setting_type type, const char* name) { rarch_setting_t result = { type, name }; @@ -814,6 +882,8 @@ rarch_setting_t setting_data_uint_setting(const char* name, result.original_value.unsigned_integer = *target; result.default_value.unsigned_integer = default_value; + result.action_ok = setting_data_uint_action_ok_default; + return result; } @@ -2227,6 +2297,27 @@ static void general_write_handler(void *data) #define MAX_GAMMA_SETTING 1 #endif +static void setting_data_add_special_callbacks( + rarch_setting_t **list, + rarch_setting_info_t *list_info, + unsigned values) +{ + if (values & SD_FLAG_ALLOW_INPUT) + (*list)[list_info->index - 1].action_ok = setting_data_uint_action_ok_linefeed; +} + +static void settings_data_list_current_add_flags( + rarch_setting_t **list, + rarch_setting_info_t *list_info, + unsigned values) +{ + settings_list_current_add_flags( + list, + list_info, + values); + setting_data_add_special_callbacks(list, list_info, values); +} + static bool setting_data_append_list_main_menu_options( rarch_setting_t **list, rarch_setting_info_t *list_info) @@ -2249,7 +2340,7 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_PUSH_ACTION); @@ -2267,7 +2358,7 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); } if ( driver.menu @@ -2285,7 +2376,7 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); } CONFIG_BOOL( lists[3], @@ -2298,7 +2389,7 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); CONFIG_BOOL( lists[4], @@ -2311,7 +2402,7 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); CONFIG_BOOL( lists[5], @@ -2324,7 +2415,7 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); if (g_extern.main_is_init && !g_extern.libretro_dummy @@ -2341,7 +2432,7 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); } CONFIG_BOOL( lists[7], @@ -2354,7 +2445,7 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); if (g_extern.perfcnt_enable) { CONFIG_BOOL( @@ -2368,7 +2459,7 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); } if (g_extern.main_is_init && !g_extern.libretro_dummy) { @@ -2385,7 +2476,7 @@ static bool setting_data_append_list_main_menu_options( general_read_handler); (*list)[list_info->index - 1].action_ok = &setting_data_bool_action_ok_savestates; settings_list_current_add_cmd (list, list_info, RARCH_CMD_SAVE_STATE); - settings_list_current_add_flags(list, list_info, SD_FLAG_EXIT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_EXIT); CONFIG_BOOL( lists[10], @@ -2400,7 +2491,7 @@ static bool setting_data_append_list_main_menu_options( general_read_handler); (*list)[list_info->index - 1].action_ok = &setting_data_bool_action_ok_savestates; settings_list_current_add_cmd (list, list_info, RARCH_CMD_LOAD_STATE); - settings_list_current_add_flags(list, list_info, SD_FLAG_EXIT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_EXIT); CONFIG_BOOL( lists[11], @@ -2414,7 +2505,7 @@ static bool setting_data_append_list_main_menu_options( general_write_handler, general_read_handler); settings_list_current_add_cmd (list, list_info, RARCH_CMD_TAKE_SCREENSHOT); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); CONFIG_BOOL( lists[12], @@ -2428,7 +2519,7 @@ static bool setting_data_append_list_main_menu_options( general_write_handler, general_read_handler); settings_list_current_add_cmd (list, list_info, RARCH_CMD_RESUME); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION | SD_FLAG_EXIT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION | SD_FLAG_EXIT); CONFIG_BOOL( lists[13], @@ -2442,7 +2533,7 @@ static bool setting_data_append_list_main_menu_options( general_write_handler, general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_RESET); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION | SD_FLAG_EXIT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION | SD_FLAG_EXIT); } #ifndef HAVE_DYNAMIC CONFIG_BOOL( @@ -2457,7 +2548,7 @@ static bool setting_data_append_list_main_menu_options( general_write_handler, general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_RESTART_RETROARCH); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); #endif CONFIG_BOOL( @@ -2484,7 +2575,7 @@ static bool setting_data_append_list_main_menu_options( general_write_handler, general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_MENU_SAVE_CONFIG); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); CONFIG_BOOL( lists[17], @@ -2497,7 +2588,7 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); /* Apple rejects iOS apps that lets you forcibly quit an application. */ #if !defined(IOS) @@ -2513,7 +2604,7 @@ static bool setting_data_append_list_main_menu_options( general_write_handler, general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_QUIT_RETROARCH); - settings_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_PUSH_ACTION); #endif END_SUB_GROUP(list, list_info); @@ -2530,7 +2621,7 @@ static bool setting_data_append_list_driver_options( rarch_setting_group_info_t subgroup_info; START_GROUP(group_info, "Driver Options"); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); @@ -2543,7 +2634,7 @@ static bool setting_data_append_list_driver_options( subgroup_info.name, NULL, NULL); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); CONFIG_STRING( g_settings.video.driver, @@ -2554,7 +2645,7 @@ static bool setting_data_append_list_driver_options( subgroup_info.name, NULL, NULL); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); #ifdef HAVE_OPENGL CONFIG_STRING( @@ -2566,7 +2657,7 @@ static bool setting_data_append_list_driver_options( subgroup_info.name, NULL, NULL); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); #endif CONFIG_STRING( g_settings.audio.driver, @@ -2577,7 +2668,7 @@ static bool setting_data_append_list_driver_options( subgroup_info.name, NULL, NULL); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); CONFIG_STRING( g_settings.audio.resampler, @@ -2598,7 +2689,7 @@ static bool setting_data_append_list_driver_options( subgroup_info.name, NULL, NULL); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); CONFIG_STRING( g_settings.location.driver, @@ -2609,7 +2700,7 @@ static bool setting_data_append_list_driver_options( subgroup_info.name, NULL, NULL); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); #ifdef HAVE_MENU CONFIG_STRING( @@ -2621,7 +2712,7 @@ static bool setting_data_append_list_driver_options( subgroup_info.name, NULL, NULL); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); #endif CONFIG_STRING( @@ -2633,7 +2724,7 @@ static bool setting_data_append_list_driver_options( subgroup_info.name, NULL, NULL); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); CONFIG_STRING( g_settings.input.keyboard_layout, @@ -2644,7 +2735,7 @@ static bool setting_data_append_list_driver_options( subgroup_info.name, NULL, NULL); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DRIVER); END_SUB_GROUP(list, list_info); END_GROUP(list, list_info); @@ -2660,7 +2751,7 @@ static bool setting_data_append_list_general_options( rarch_setting_group_info_t subgroup_info; START_GROUP(group_info, "General Options"); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -2754,7 +2845,7 @@ static bool setting_data_append_list_general_options( general_write_handler, general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_REWIND_TOGGLE); - settings_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); #if 0 CONFIG_SIZE( g_settings.rewind_buffer_size, @@ -2801,7 +2892,7 @@ static bool setting_data_append_list_general_options( general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_AUTOSAVE_INIT); settings_list_current_add_range(list, list_info, 0, 0, 10, true, false); - settings_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); #endif CONFIG_BOOL( @@ -2816,7 +2907,7 @@ static bool setting_data_append_list_general_options( general_write_handler, general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_REINIT); - settings_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); CONFIG_BOOL( g_settings.pause_nonactive, @@ -2967,7 +3058,7 @@ static bool setting_data_append_list_video_options( rarch_setting_group_info_t subgroup_info; START_GROUP(group_info, "Video Options"); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -3010,7 +3101,7 @@ static bool setting_data_append_list_video_options( general_write_handler, general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_REINIT); - settings_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); #endif CONFIG_BOOL( g_settings.video.windowed_fullscreen, @@ -3079,7 +3170,7 @@ static bool setting_data_append_list_video_options( general_write_handler, general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_REINIT); - settings_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); END_SUB_GROUP(list, list_info); @@ -3140,7 +3231,7 @@ static bool setting_data_append_list_video_options( 1, true, true); - settings_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); END_SUB_GROUP(list, list_info); @@ -3296,7 +3387,7 @@ static bool setting_data_append_list_video_options( 1, true, true); - settings_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); #endif END_SUB_GROUP(list, list_info); @@ -3320,7 +3411,7 @@ static bool setting_data_append_list_video_options( general_write_handler, general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_REINIT); - settings_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); #endif CONFIG_BOOL( @@ -3346,7 +3437,7 @@ static bool setting_data_append_list_video_options( general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_VIDEO_SET_BLOCKING_STATE); settings_list_current_add_range(list, list_info, 1, 4, 1, true, true); - settings_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); CONFIG_BOOL( g_settings.video.hard_sync, @@ -3475,7 +3566,7 @@ static bool setting_data_append_list_video_options( general_read_handler); settings_list_current_add_values(list, list_info, "filt"); settings_list_current_add_cmd(list, list_info, RARCH_CMD_REINIT); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); #endif #if defined(_XBOX1) || defined(HW_RVL) @@ -3545,7 +3636,7 @@ static bool setting_data_append_list_shader_options( subgroup_info.name, NULL, NULL); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); END_SUB_GROUP(list, list_info); END_GROUP(list, list_info); @@ -3561,7 +3652,7 @@ static bool setting_data_append_list_font_options( rarch_setting_group_info_t subgroup_info; START_GROUP(group_info, "Font Options"); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); START_SUB_GROUP(list, list_info, "Messages", group_info.name, subgroup_info); CONFIG_PATH( @@ -3573,7 +3664,7 @@ static bool setting_data_append_list_font_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); CONFIG_FLOAT( g_settings.video.font_size, @@ -3637,7 +3728,7 @@ static bool setting_data_append_list_audio_options( rarch_setting_group_info_t subgroup_info; START_GROUP(group_info, "Audio Options"); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -3722,7 +3813,7 @@ static bool setting_data_append_list_audio_options( general_write_handler, general_read_handler); settings_list_current_add_range(list, list_info, 1, 256, 1.0, true, true); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_DEFERRED); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_DEFERRED); CONFIG_FLOAT( g_settings.audio.rate_control_delta, @@ -3771,7 +3862,7 @@ static bool setting_data_append_list_audio_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); CONFIG_UINT( g_settings.audio.out_rate, @@ -3794,7 +3885,7 @@ static bool setting_data_append_list_audio_options( general_read_handler); settings_list_current_add_values(list, list_info, "dsp"); settings_list_current_add_cmd(list, list_info, RARCH_CMD_DSP_FILTER_INIT); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); END_SUB_GROUP(list, list_info); END_GROUP(list, list_info); @@ -3811,7 +3902,7 @@ static bool setting_data_append_list_input_options( unsigned i, player; START_GROUP(group_info, "Input Options"); - //settings_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); + //settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -4019,7 +4110,7 @@ static bool setting_data_append_list_overlay_options( rarch_setting_group_info_t subgroup_info; START_GROUP(group_info, "Overlay Options"); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_PATH( @@ -4033,7 +4124,7 @@ static bool setting_data_append_list_overlay_options( general_read_handler); settings_list_current_add_values(list, list_info, "cfg"); settings_list_current_add_cmd(list, list_info, RARCH_CMD_OVERLAY_INIT); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); CONFIG_FLOAT( g_settings.input.overlay_opacity, @@ -4047,7 +4138,7 @@ static bool setting_data_append_list_overlay_options( general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_OVERLAY_SET_ALPHA_MOD); settings_list_current_add_range(list, list_info, 0, 1, 0.01, true, true); - settings_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); CONFIG_FLOAT( g_settings.input.overlay_scale, @@ -4061,7 +4152,7 @@ static bool setting_data_append_list_overlay_options( general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_OVERLAY_SET_SCALE_FACTOR); settings_list_current_add_range(list, list_info, 0, 2, 0.01, true, true); - settings_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); END_SUB_GROUP(list, list_info); END_GROUP(list, list_info); @@ -4079,7 +4170,7 @@ static bool setting_data_append_list_menu_options( rarch_setting_group_info_t subgroup_info; START_GROUP(group_info, "Menu Options"); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -4106,7 +4197,7 @@ static bool setting_data_append_list_menu_options( general_write_handler, general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_MENU_PAUSE_LIBRETRO); - settings_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); END_SUB_GROUP(list, list_info); END_GROUP(list, list_info); #endif @@ -4123,7 +4214,7 @@ static bool setting_data_append_list_netplay_options( rarch_setting_group_info_t subgroup_info; START_GROUP(group_info, "Netplay Options"); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -4147,7 +4238,7 @@ static bool setting_data_append_list_netplay_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); CONFIG_BOOL( g_extern.netplay_is_client, @@ -4194,7 +4285,7 @@ static bool setting_data_append_list_netplay_options( general_write_handler, general_read_handler); settings_list_current_add_range(list, list_info, 1, 99999, 1, true, true); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); END_SUB_GROUP(list, list_info); END_GROUP(list, list_info); @@ -4211,7 +4302,7 @@ static bool setting_data_append_list_user_options( rarch_setting_group_info_t subgroup_info; START_GROUP(group_info, "User Options"); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_STRING( @@ -4223,7 +4314,7 @@ static bool setting_data_append_list_user_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); CONFIG_UINT( g_settings.user_language, @@ -4242,7 +4333,7 @@ static bool setting_data_append_list_user_options( 1, true, true); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); END_SUB_GROUP(list, list_info); END_GROUP(list, list_info); @@ -4258,7 +4349,7 @@ static bool setting_data_append_list_path_options( rarch_setting_group_info_t subgroup_info; START_GROUP(group_info, "Path Options"); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_UINT( @@ -4285,7 +4376,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4300,7 +4391,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4315,7 +4406,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4330,7 +4421,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4348,7 +4439,7 @@ static bool setting_data_append_list_path_options( general_write_handler, general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_CORE_INFO_INIT); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4364,7 +4455,7 @@ static bool setting_data_append_list_path_options( general_write_handler, general_read_handler); settings_list_current_add_cmd(list, list_info, RARCH_CMD_CORE_INFO_INIT); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4378,7 +4469,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); CONFIG_PATH( g_settings.cheat_database, @@ -4389,7 +4480,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); CONFIG_PATH( g_settings.cheat_settings_path, @@ -4399,7 +4490,7 @@ static bool setting_data_append_list_path_options( group_info.name, subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); CONFIG_PATH( g_settings.content_history_path, @@ -4410,7 +4501,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); CONFIG_DIR( g_settings.video.filter_dir, @@ -4422,7 +4513,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4437,7 +4528,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4453,7 +4544,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4470,7 +4561,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4486,7 +4577,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4501,7 +4592,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4516,7 +4607,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4531,7 +4622,7 @@ static bool setting_data_append_list_path_options( subgroup_info.name, general_write_handler, general_read_handler); - settings_list_current_add_flags( + settings_data_list_current_add_flags( list, list_info, SD_FLAG_ALLOW_EMPTY | SD_FLAG_PATH_DIR); @@ -4593,7 +4684,7 @@ static bool setting_data_append_list_privacy_options( rarch_setting_group_info_t subgroup_info; START_GROUP(group_info, "Privacy Options"); - settings_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_IS_CATEGORY); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -4625,6 +4716,7 @@ static bool setting_data_append_list_privacy_options( return true; } + rarch_setting_t *setting_data_new(unsigned mask) { rarch_setting_t terminator = { ST_NONE }; From 9ade7b5245e40dda3746abbd3884d441731b6414 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 00:56:20 +0200 Subject: [PATCH 14/42] Add action OK fraction callbacks --- frontend/menu/menu_action.c | 63 +--------------------------- settings_data.c | 83 +++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 61 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index 2581ee0ec0..45b0bc9baf 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -57,67 +57,8 @@ int menu_action_setting_unsigned_integer( int menu_action_setting_fraction( rarch_setting_t *setting, unsigned action) { - if (!strcmp(setting->name, "video_refresh_rate_auto")) - { - switch (action) - { - case MENU_ACTION_START: - g_extern.measure_data.frame_time_samples_count = 0; - break; - case MENU_ACTION_OK: - { - double video_refresh_rate, deviation = 0.0; - unsigned sample_points = 0; - - if (driver_monitor_fps_statistics(&video_refresh_rate, - &deviation, &sample_points)) - { - driver_set_monitor_refresh_rate(video_refresh_rate); - /* Incase refresh rate update forced non-block video. */ - rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE); - } - - if (setting->cmd_trigger.idx != RARCH_CMD_NONE) - setting->cmd_trigger.triggered = true; - } - break; - } - } - else - { - switch (action) - { - case MENU_ACTION_LEFT: - *setting->value.fraction = - *setting->value.fraction - setting->step; - - if (setting->enforce_minrange) - { - if (*setting->value.fraction < setting->min) - *setting->value.fraction = setting->min; - } - break; - - case MENU_ACTION_OK: - if (setting->cmd_trigger.idx != RARCH_CMD_NONE) - setting->cmd_trigger.triggered = true; - /* fall-through */ - case MENU_ACTION_RIGHT: - *setting->value.fraction = - *setting->value.fraction + setting->step; - - if (setting->enforce_maxrange) - { - if (*setting->value.fraction > setting->max) - *setting->value.fraction = setting->max; - } - break; - - case MENU_ACTION_START: - *setting->value.fraction = setting->default_value.fraction; - break; - } - } + if (setting->action_ok) + setting->action_ok(setting, action); return menu_action_setting_apply(setting); } diff --git a/settings_data.c b/settings_data.c index 0b23ed850a..178e3f38c8 100644 --- a/settings_data.c +++ b/settings_data.c @@ -775,6 +775,85 @@ static int setting_data_uint_action_ok_default(void *data, unsigned action) return 0; } +static int setting_data_fraction_action_ok_video_refresh_rate_auto( + void *data, unsigned action) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting) + return -1; + + switch (action) + { + case MENU_ACTION_START: + g_extern.measure_data.frame_time_samples_count = 0; + break; + case MENU_ACTION_OK: + { + double video_refresh_rate, deviation = 0.0; + unsigned sample_points = 0; + + if (driver_monitor_fps_statistics(&video_refresh_rate, + &deviation, &sample_points)) + { + driver_set_monitor_refresh_rate(video_refresh_rate); + /* Incase refresh rate update forced non-block video. */ + rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE); + } + + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; + } + break; + } + + return 0; +} + +static int setting_data_fraction_action_ok_default( + void *data, unsigned action) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting) + return -1; + + switch (action) + { + case MENU_ACTION_LEFT: + *setting->value.fraction = + *setting->value.fraction - setting->step; + + if (setting->enforce_minrange) + { + if (*setting->value.fraction < setting->min) + *setting->value.fraction = setting->min; + } + break; + + case MENU_ACTION_OK: + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; + /* fall-through */ + case MENU_ACTION_RIGHT: + *setting->value.fraction = + *setting->value.fraction + setting->step; + + if (setting->enforce_maxrange) + { + if (*setting->value.fraction > setting->max) + *setting->value.fraction = setting->max; + } + break; + + case MENU_ACTION_START: + *setting->value.fraction = setting->default_value.fraction; + break; + } + + return 0; +} + static int setting_data_uint_action_ok_linefeed(void *data, unsigned action) { rarch_setting_t *setting = (rarch_setting_t*)data; @@ -829,6 +908,8 @@ rarch_setting_t setting_data_float_setting(const char* name, result.value.fraction = target; result.original_value.fraction = *target; result.default_value.fraction = default_value; + + result.action_ok = setting_data_fraction_action_ok_default; return result; } @@ -3157,6 +3238,8 @@ static bool setting_data_append_list_video_options( subgroup_info.name, general_write_handler, general_read_handler); + (*list)[list_info->index - 1].action_ok = + &setting_data_fraction_action_ok_video_refresh_rate_auto; CONFIG_BOOL( g_settings.video.force_srgb_disable, From 0ab30f4409a0bc73d48907c1723e3cb16bd8c1c8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 01:04:37 +0200 Subject: [PATCH 15/42] Turn menu_action_handle_setting into a static function --- frontend/menu/menu_action.c | 2 +- frontend/menu/menu_action.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index 45b0bc9baf..ce1d489c4e 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -122,7 +122,7 @@ int menu_action_setting_set_current_string_path( } -int menu_action_handle_setting(rarch_setting_t *setting, +static int menu_action_handle_setting(rarch_setting_t *setting, unsigned type, const char *label, unsigned action) { if (setting->type == ST_BOOL) diff --git a/frontend/menu/menu_action.h b/frontend/menu/menu_action.h index 4ae360fcfa..1e6c9ef589 100644 --- a/frontend/menu/menu_action.h +++ b/frontend/menu/menu_action.h @@ -49,9 +49,6 @@ int menu_action_setting_set_current_string_path( int menu_action_setting_set(unsigned type, const char *label, unsigned action); -int menu_action_handle_setting(rarch_setting_t *setting, - unsigned type, const char *label, unsigned action); - #ifdef __cplusplus } #endif From aa4cc4f4a2c589ad6fc4ab1b3d2ffb8a945bfd3b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 01:14:35 +0200 Subject: [PATCH 16/42] Move menu_entries_set_current_path_selection to menu_entries.c and make it static --- frontend/menu/menu_action.c | 22 ++++++++++++++++++++++ frontend/menu/menu_entries.c | 24 ------------------------ frontend/menu/menu_entries.h | 5 ----- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index ce1d489c4e..326c77fe41 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -121,6 +121,28 @@ int menu_action_setting_set_current_string_path( return menu_action_setting_apply(setting); } +static int menu_entries_set_current_path_selection( + rarch_setting_t *setting, const char *start_path, + const char *label, unsigned type, + unsigned action) +{ + switch (action) + { + case MENU_ACTION_OK: + menu_entries_push(driver.menu->menu_stack, + start_path, label, type, + driver.menu->selection_ptr); + + if (setting->cmd_trigger.idx != RARCH_CMD_NONE) + setting->cmd_trigger.triggered = true; + break; + case MENU_ACTION_START: + *setting->value.string = '\0'; + break; + } + + return menu_action_setting_apply(setting); +} static int menu_action_handle_setting(rarch_setting_t *setting, unsigned type, const char *label, unsigned action) diff --git a/frontend/menu/menu_entries.c b/frontend/menu/menu_entries.c index 3063407806..a252101dd0 100644 --- a/frontend/menu/menu_entries.c +++ b/frontend/menu/menu_entries.c @@ -925,30 +925,6 @@ void menu_flush_stack_label(file_list_t *list, } } - -int menu_entries_set_current_path_selection( - rarch_setting_t *setting, const char *start_path, - const char *label, unsigned type, - unsigned action) -{ - switch (action) - { - case MENU_ACTION_OK: - menu_entries_push(driver.menu->menu_stack, - start_path, label, type, - driver.menu->selection_ptr); - - if (setting->cmd_trigger.idx != RARCH_CMD_NONE) - setting->cmd_trigger.triggered = true; - break; - case MENU_ACTION_START: - *setting->value.string = '\0'; - break; - } - - return menu_action_setting_apply(setting); -} - bool menu_entries_init(menu_handle_t *menu) { if (!menu) diff --git a/frontend/menu/menu_entries.h b/frontend/menu/menu_entries.h index 2c63c16fdc..cfb2f6f366 100644 --- a/frontend/menu/menu_entries.h +++ b/frontend/menu/menu_entries.h @@ -39,11 +39,6 @@ void menu_entries_pop_stack(file_list_t *list, const char *needle); void menu_flush_stack_type(file_list_t *list, unsigned final_type); void menu_flush_stack_label(file_list_t *list, const char *needle); -int menu_entries_set_current_path_selection( - rarch_setting_t *setting, const char *start_path, - const char *label, unsigned type, - unsigned action); - bool menu_entries_init(menu_handle_t *menu); #ifdef __cplusplus From c9917ce6fe19d8388538f335c4443f918f8ea67f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Tue, 14 Oct 2014 20:18:50 -0300 Subject: [PATCH 17/42] (udev) Detect joypad vendor and product id --- input/udev_joypad.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/input/udev_joypad.c b/input/udev_joypad.c index 6c3c63f3ec..bfc50e6110 100644 --- a/input/udev_joypad.c +++ b/input/udev_joypad.c @@ -62,6 +62,8 @@ struct udev_joypad char *ident; char *path; + int32_t vid; + int32_t pid; }; static struct udev *g_udev; @@ -147,7 +149,7 @@ static bool hotplug_available(void) return (poll(&fds, 1, 0) == 1) && (fds.revents & POLLIN); } -static void check_device(const char *path, bool hotplugged); +static void check_device(struct udev_device *dev, const char *path, bool hotplugged); static void remove_device(const char *path); static void handle_hotplug(void) @@ -166,7 +168,7 @@ static void handle_hotplug(void) if (!strcmp(action, "add")) { RARCH_LOG("[udev]: Hotplug add: %s.\n", devnode); - check_device(devnode, true); + check_device(dev, devnode, true); } else if (!strcmp(action, "remove")) { @@ -308,7 +310,7 @@ static void free_pad(unsigned pad, bool hotplug) NULL); } -static bool add_pad(unsigned p, int fd, const char *path) +static bool add_pad(struct udev_device *dev, unsigned p, int fd, const char *path) { int i; struct udev_joypad *pad = &g_pads[p]; @@ -318,7 +320,22 @@ static bool add_pad(unsigned p, int fd, const char *path) return false; } - RARCH_LOG("[udev]: Plugged pad: %s on port #%u.\n", pad->ident, p); + const char *buf; + + /* don't worry about unref'ing the parent */ + struct udev_device *parent = + udev_device_get_parent_with_subsystem_devtype(dev, "usb", "usb_device"); + + pad->vid = pad->pid = 0; + + if ((buf = udev_device_get_sysattr_value(parent, "idVendor")) != NULL) + pad->vid = strtol(buf, NULL, 16); + + if ((buf = udev_device_get_sysattr_value(parent, "idProduct")) != NULL) + pad->pid = strtol(buf, NULL, 16); + + RARCH_LOG("[udev]: Plugged pad: %s (%04x:%04x) on port #%u.\n", + pad->ident, pad->vid, pad->pid, p); struct stat st; if (fstat(fd, &st) < 0) @@ -367,10 +384,8 @@ static bool add_pad(unsigned p, int fd, const char *path) pad->fd = fd; pad->path = strdup(path); - /* TODO - implement VID/PID? */ if (*pad->ident) - input_config_autoconfigure_joypad(p, pad->ident, - 0, 0, "udev"); + input_config_autoconfigure_joypad(p, pad->ident, pad->vid, pad->pid, "udev"); // Check for rumble features. unsigned long ffbit[NBITS(FF_MAX)] = {0}; @@ -387,7 +402,7 @@ static bool add_pad(unsigned p, int fd, const char *path) return true; } -static void check_device(const char *path, bool hotplugged) +static void check_device(struct udev_device *dev, const char *path, bool hotplugged) { unsigned i; struct stat st; @@ -411,7 +426,7 @@ static void check_device(const char *path, bool hotplugged) if (fd < 0) return; - if (add_pad(pad, fd, path)) + if (add_pad(dev, pad, fd, path)) { #ifndef IS_JOYCONFIG if (hotplugged) @@ -501,7 +516,7 @@ static bool udev_joypad_init(void) struct udev_device *dev = udev_device_new_from_syspath(g_udev, name); const char *devnode = udev_device_get_devnode(dev); if (devnode) - check_device(devnode, false); + check_device(dev, devnode, false); udev_device_unref(dev); } From 5eed703d649361ab747b8e3fee1d58f73b4a6f72 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 01:23:13 +0200 Subject: [PATCH 18/42] Cleanups --- frontend/menu/backend/menu_lakka_backend.c | 2 +- frontend/menu/menu_action.c | 13 ++++++++----- frontend/menu/menu_action.h | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend/menu/backend/menu_lakka_backend.c b/frontend/menu/backend/menu_lakka_backend.c index 006324a7dd..d3a943ccb8 100644 --- a/frontend/menu/backend/menu_lakka_backend.c +++ b/frontend/menu/backend/menu_lakka_backend.c @@ -371,7 +371,7 @@ static int menu_lakka_iterate(unsigned action) if (setting->type == ST_BOOL) menu_action_setting_boolean(setting, action); else if (setting->type == ST_UINT) - menu_action_setting_unsigned_integer(setting, 0, action); + menu_action_setting_unsigned_integer(setting, action); else if (setting->type == ST_FLOAT) menu_action_setting_fraction(setting, action); else if (setting->type == ST_STRING) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index 326c77fe41..ce6f5d76ab 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -46,7 +46,7 @@ int menu_action_setting_boolean( } int menu_action_setting_unsigned_integer( - rarch_setting_t *setting, unsigned type, unsigned action) + rarch_setting_t *setting, unsigned action) { if (setting->action_ok) setting->action_ok(setting, action); @@ -145,12 +145,15 @@ static int menu_entries_set_current_path_selection( } static int menu_action_handle_setting(rarch_setting_t *setting, - unsigned type, const char *label, unsigned action) + unsigned type, unsigned action) { + if (!setting) + return -1; + if (setting->type == ST_BOOL) return menu_action_setting_boolean(setting, action); if (setting->type == ST_UINT) - return menu_action_setting_unsigned_integer(setting, type, action); + return menu_action_setting_unsigned_integer(setting, action); if (setting->type == ST_FLOAT) return menu_action_setting_fraction(setting, action); if (setting->type == ST_PATH) @@ -291,7 +294,7 @@ int menu_action_setting_set(unsigned type, const char *label, driver.menu->list_settings, list->list[driver.menu->selection_ptr].label); if (setting) - return menu_action_handle_setting(setting, type, label, action); + return menu_action_handle_setting(setting, type, action); /* Check if setting belongs to main menu. */ @@ -299,7 +302,7 @@ int menu_action_setting_set(unsigned type, const char *label, driver.menu->list_mainmenu, list->list[driver.menu->selection_ptr].label); if (setting) - return menu_action_handle_setting(setting, type, label, action); + return menu_action_handle_setting(setting, type, action); /* Fallback. */ diff --git a/frontend/menu/menu_action.h b/frontend/menu/menu_action.h index 1e6c9ef589..05303a24ee 100644 --- a/frontend/menu/menu_action.h +++ b/frontend/menu/menu_action.h @@ -32,7 +32,7 @@ int menu_action_setting_fraction( rarch_setting_t *setting, unsigned action); int menu_action_setting_unsigned_integer( - rarch_setting_t *setting, unsigned type, unsigned action); + rarch_setting_t *setting, unsigned action); void menu_action_setting_driver( rarch_setting_t *setting, unsigned action); From ea8808a63e6144045287de5a2d2045e89d1159e6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 01:58:55 +0200 Subject: [PATCH 19/42] Cleanup --- frontend/menu/menu_shader.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/menu/menu_shader.c b/frontend/menu/menu_shader.c index 15c1d4593f..a99df181ac 100644 --- a/frontend/menu/menu_shader.c +++ b/frontend/menu/menu_shader.c @@ -359,10 +359,9 @@ int menu_shader_manager_setting_toggle( RARCH_LOG("shader label: %s\n", label); #endif - rarch_setting_t *current_setting = NULL; - if (!strcmp(label, "video_shader_default_filter")) { + rarch_setting_t *current_setting = NULL; if ((current_setting = setting_data_find_setting( driver.menu->list_settings, "video_smooth"))) menu_action_setting_boolean(current_setting, action); From df922034aac78e0ee6114b07c4e0d33a48b7baf2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 02:07:30 +0200 Subject: [PATCH 20/42] Move shader parameter setting toggle code to menu_entries_cbs.c --- frontend/menu/menu_entries_cbs.c | 50 +++++++++++++++++++++++++++++++- frontend/menu/menu_shader.c | 40 ------------------------- 2 files changed, 49 insertions(+), 41 deletions(-) diff --git a/frontend/menu/menu_entries_cbs.c b/frontend/menu/menu_entries_cbs.c index f9ceff19d6..2c220431e0 100644 --- a/frontend/menu/menu_entries_cbs.c +++ b/frontend/menu/menu_entries_cbs.c @@ -616,6 +616,51 @@ static int performance_counters_core_toggle(unsigned type, const char *label, return 0; } +static int shader_action_parameter_toggle(unsigned type, const char *label, + unsigned action) +{ +#ifdef HAVE_SHADER_MANAGER + bool apply_changes = false; + struct gfx_shader *shader = NULL; + struct gfx_shader_parameter *param = NULL; + + if (!(shader = (struct gfx_shader*)driver.menu->parameter_shader)) + return 0; + + if (!(param = &shader->parameters[type - MENU_SETTINGS_SHADER_PARAMETER_0])) + return 0; + + switch (action) + { + case MENU_ACTION_START: + param->current = param->initial; + apply_changes = true; + break; + + case MENU_ACTION_LEFT: + param->current -= param->step; + apply_changes = true; + break; + + case MENU_ACTION_RIGHT: + param->current += param->step; + apply_changes = true; + break; + + default: + break; + } + + param->current = min(max(param->minimum, param->current), param->maximum); + + if (apply_changes + && !strcmp(label, "video_shader_parameters")) + rarch_main_command(RARCH_CMD_SHADERS_APPLY_CHANGES); + +#endif + return 0; +} + static int performance_counters_frontend_toggle(unsigned type, const char *label, unsigned action) { @@ -900,7 +945,10 @@ static void menu_entries_cbs_init_bind_toggle(menu_file_list_cbs_t *cbs, cbs->action_toggle = menu_action_setting_set; - if ((menu_common_type_is(label, type) == MENU_SETTINGS_SHADER_OPTIONS) || + if (type >= MENU_SETTINGS_SHADER_PARAMETER_0 + && type <= MENU_SETTINGS_SHADER_PARAMETER_LAST) + cbs->action_toggle = shader_action_parameter_toggle; + else if ((menu_common_type_is(label, type) == MENU_SETTINGS_SHADER_OPTIONS) || !strcmp(label, "video_shader_parameters") || !strcmp(label, "video_shader_preset_parameters") ) diff --git a/frontend/menu/menu_shader.c b/frontend/menu/menu_shader.c index a99df181ac..05146658eb 100644 --- a/frontend/menu/menu_shader.c +++ b/frontend/menu/menu_shader.c @@ -366,46 +366,6 @@ int menu_shader_manager_setting_toggle( driver.menu->list_settings, "video_smooth"))) menu_action_setting_boolean(current_setting, action); } - else if (type >= MENU_SETTINGS_SHADER_PARAMETER_0 - && type <= MENU_SETTINGS_SHADER_PARAMETER_LAST) - { - bool apply_changes = false; - struct gfx_shader *shader = NULL; - struct gfx_shader_parameter *param = NULL; - - if (!(shader = (struct gfx_shader*)driver.menu->parameter_shader)) - return 0; - - if (!(param = &shader->parameters[type - MENU_SETTINGS_SHADER_PARAMETER_0])) - return 0; - - switch (action) - { - case MENU_ACTION_START: - param->current = param->initial; - apply_changes = true; - break; - - case MENU_ACTION_LEFT: - param->current -= param->step; - apply_changes = true; - break; - - case MENU_ACTION_RIGHT: - param->current += param->step; - apply_changes = true; - break; - - default: - break; - } - - param->current = min(max(param->minimum, param->current), param->maximum); - - if (apply_changes - && !strcmp(label, "video_shader_parameters")) - rarch_main_command(RARCH_CMD_SHADERS_APPLY_CHANGES); - } else if ((!strcmp(label, "video_shader_parameters") || !strcmp(label, "video_shader_preset_parameters")) && action == MENU_ACTION_OK) From 2c15e652f9e4b8b2398d113383cdeb69bda87833 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 02:34:43 +0200 Subject: [PATCH 21/42] Move more shader setting code to menu_entries_cbs.c --- frontend/menu/menu_entries_cbs.c | 209 ++++++++++++++++++++++++++++++- frontend/menu/menu_shader.c | 190 ---------------------------- frontend/menu/menu_shader.h | 3 - 3 files changed, 204 insertions(+), 198 deletions(-) diff --git a/frontend/menu/menu_entries_cbs.c b/frontend/menu/menu_entries_cbs.c index 2c220431e0..a1b0bc771d 100644 --- a/frontend/menu/menu_entries_cbs.c +++ b/frontend/menu/menu_entries_cbs.c @@ -661,6 +661,193 @@ static int shader_action_parameter_toggle(unsigned type, const char *label, return 0; } +#ifdef HAVE_SHADER_MANAGER +extern size_t hack_shader_pass; +#endif + +static int action_toggle_shader_pass(unsigned type, const char *label, + unsigned action) +{ +#ifdef HAVE_SHADER_MANAGER + hack_shader_pass = type - MENU_SETTINGS_SHADER_PASS_0; + struct gfx_shader *shader = (struct gfx_shader*)driver.menu->shader; + struct gfx_shader_pass *shader_pass = NULL; + + if (shader) + shader_pass = (struct gfx_shader_pass*)&shader->pass[hack_shader_pass]; + + switch (action) + { + case MENU_ACTION_OK: + menu_entries_push(driver.menu->menu_stack, + g_settings.video.shader_dir, + "video_shader_pass", + type, + driver.menu->selection_ptr); + break; + case MENU_ACTION_START: + if (shader_pass) + *shader_pass->source.path = '\0'; + break; + } +#endif + return 0; +} + +static int action_toggle_shader_preset(unsigned type, const char *label, + unsigned action) +{ +#ifdef HAVE_SHADER_MANAGER + switch (action) + { + case MENU_ACTION_OK: + menu_entries_push(driver.menu->menu_stack, + g_settings.video.shader_dir, + "video_shader_preset", + type, + driver.menu->selection_ptr); + break; + } +#endif + return 0; +} + +static int action_toggle_shader_scale_pass(unsigned type, const char *label, + unsigned action) +{ +#ifdef HAVE_SHADER_MANAGER + unsigned pass = type - MENU_SETTINGS_SHADER_PASS_SCALE_0; + struct gfx_shader *shader = (struct gfx_shader*)driver.menu->shader; + struct gfx_shader_pass *shader_pass = (struct gfx_shader_pass*) + &shader->pass[pass]; + + switch (action) + { + case MENU_ACTION_START: + if (shader) + { + shader_pass->fbo.scale_x = shader_pass->fbo.scale_y = 0; + shader_pass->fbo.valid = false; + } + break; + + case MENU_ACTION_LEFT: + case MENU_ACTION_RIGHT: + case MENU_ACTION_OK: + { + unsigned current_scale = shader_pass->fbo.scale_x; + unsigned delta = action == MENU_ACTION_LEFT ? 5 : 1; + current_scale = (current_scale + delta) % 6; + + if (shader_pass) + { + shader_pass->fbo.valid = current_scale; + shader_pass->fbo.scale_x = shader_pass->fbo.scale_y = current_scale; + } + } + break; + } +#endif + return 0; +} + +static int action_toggle_shader_filter_pass(unsigned type, const char *label, + unsigned action) +{ +#ifdef HAVE_SHADER_MANAGER + unsigned pass = type - MENU_SETTINGS_SHADER_PASS_FILTER_0; + struct gfx_shader *shader = (struct gfx_shader*)driver.menu->shader; + struct gfx_shader_pass *shader_pass = (struct gfx_shader_pass*) + &shader->pass[pass]; + + switch (action) + { + case MENU_ACTION_START: + if (shader) + shader->pass[pass].filter = RARCH_FILTER_UNSPEC; + break; + + case MENU_ACTION_LEFT: + case MENU_ACTION_RIGHT: + case MENU_ACTION_OK: + { + unsigned delta = (action == MENU_ACTION_LEFT) ? 2 : 1; + if (shader_pass) + shader_pass->filter = ((shader_pass->filter + delta) % 3); + } + break; + } +#endif + return 0; +} + +static int action_toggle_shader_filter_default(unsigned type, const char *label, + unsigned action) +{ +#ifdef HAVE_SHADER_MANAGER + rarch_setting_t *current_setting = NULL; + if ((current_setting = setting_data_find_setting( + driver.menu->list_settings, "video_smooth"))) + menu_action_setting_boolean(current_setting, action); +#endif + return 0; +} + +static int action_toggle_shader_num_passes(unsigned type, const char *label, + unsigned action) +{ +#ifdef HAVE_SHADER_MANAGER + struct gfx_shader *shader = (struct gfx_shader*)driver.menu->shader; + + if (!shader) + return -1; + + switch (action) + { + case MENU_ACTION_START: + if (shader && shader->passes) + shader->passes = 0; + driver.menu->need_refresh = true; + break; + + case MENU_ACTION_LEFT: + if (shader && shader->passes) + shader->passes--; + driver.menu->need_refresh = true; + break; + + case MENU_ACTION_RIGHT: + case MENU_ACTION_OK: + if (shader && (shader->passes < GFX_MAX_SHADERS)) + shader->passes++; + driver.menu->need_refresh = true; + break; + } + + if (driver.menu->need_refresh) + gfx_shader_resolve_parameters(NULL, driver.menu->shader); + +#endif + return 0; +} + +static int action_toggle_shader_parameters(unsigned type, const char *label, + unsigned action) +{ +#ifdef HAVE_SHADER_MANAGER + switch (action) + { + case MENU_ACTION_OK: + menu_entries_push(driver.menu->menu_stack, "", + "video_shader_parameters", + MENU_FILE_SWITCH, driver.menu->selection_ptr); + break; + } +#endif + + return 0; +} + static int performance_counters_frontend_toggle(unsigned type, const char *label, unsigned action) { @@ -948,11 +1135,23 @@ static void menu_entries_cbs_init_bind_toggle(menu_file_list_cbs_t *cbs, if (type >= MENU_SETTINGS_SHADER_PARAMETER_0 && type <= MENU_SETTINGS_SHADER_PARAMETER_LAST) cbs->action_toggle = shader_action_parameter_toggle; - else if ((menu_common_type_is(label, type) == MENU_SETTINGS_SHADER_OPTIONS) || - !strcmp(label, "video_shader_parameters") || - !strcmp(label, "video_shader_preset_parameters") - ) - cbs->action_toggle = menu_shader_manager_setting_toggle; + else if (!strcmp(label, "video_shader_pass")) + cbs->action_toggle = action_toggle_shader_pass; + else if (!strcmp(label, "video_shader_preset")) + cbs->action_toggle = action_toggle_shader_preset; + else if (!strcmp(label, "video_shader_scale_pass")) + cbs->action_toggle = action_toggle_shader_scale_pass; + else if (!strcmp(label, "video_shader_filter_pass")) + cbs->action_toggle = action_toggle_shader_filter_pass; + else if (!strcmp(label, "video_shader_default_filter")) + cbs->action_toggle = action_toggle_shader_filter_default; + else if (!strcmp(label, "video_shader_num_passes")) + cbs->action_toggle = action_toggle_shader_num_passes; + else if ((!strcmp(label, "video_shader_parameters") || + !strcmp(label, "video_shader_preset_parameters"))) + cbs->action_toggle = action_toggle_shader_parameters; + else if (!strcmp(label, "shader_apply_changes")) + cbs->action_toggle = menu_action_setting_set; else if ((type >= MENU_SETTINGS_CORE_OPTION_START)) cbs->action_toggle = core_setting_toggle; else if (type >= MENU_SETTINGS_PERF_COUNTERS_BEGIN && diff --git a/frontend/menu/menu_shader.c b/frontend/menu/menu_shader.c index 05146658eb..0c239088bb 100644 --- a/frontend/menu/menu_shader.c +++ b/frontend/menu/menu_shader.c @@ -22,8 +22,6 @@ #ifdef HAVE_SHADER_MANAGER -extern size_t hack_shader_pass; - void menu_shader_manager_init(void *data) { char cgp_path[PATH_MAX]; @@ -312,188 +310,6 @@ unsigned menu_shader_manager_get_type(const struct gfx_shader *shader) return type; } -static int handle_shader_pass_setting(struct gfx_shader *shader, - unsigned action) -{ - switch (action) - { - case MENU_ACTION_START: - if (shader && shader->passes) - shader->passes = 0; - driver.menu->need_refresh = true; - break; - - case MENU_ACTION_LEFT: - if (shader && shader->passes) - shader->passes--; - driver.menu->need_refresh = true; - break; - - case MENU_ACTION_RIGHT: - case MENU_ACTION_OK: - if (shader && (shader->passes < GFX_MAX_SHADERS)) - shader->passes++; - driver.menu->need_refresh = true; - break; - - default: - break; - } - - if (driver.menu->need_refresh) - gfx_shader_resolve_parameters(NULL, driver.menu->shader); - - return 0; -} - -int menu_shader_manager_setting_toggle( - unsigned type, const char *label, unsigned action) -{ - if (!driver.menu) - { - RARCH_ERR("Menu handle is not initialized.\n"); - return 0; - } - -#if 0 - RARCH_LOG("shader label: %s\n", label); -#endif - - if (!strcmp(label, "video_shader_default_filter")) - { - rarch_setting_t *current_setting = NULL; - if ((current_setting = setting_data_find_setting( - driver.menu->list_settings, "video_smooth"))) - menu_action_setting_boolean(current_setting, action); - } - else if ((!strcmp(label, "video_shader_parameters") || - !strcmp(label, "video_shader_preset_parameters")) - && action == MENU_ACTION_OK) - menu_entries_push(driver.menu->menu_stack, "", - "video_shader_parameters", MENU_FILE_SWITCH, driver.menu->selection_ptr); - else if (!strcmp(label, "shader_apply_changes") || - !strcmp(label, "video_shader_num_passes")) - { - if (!strcmp(label, "video_shader_num_passes")) - return handle_shader_pass_setting(driver.menu->shader, action); - menu_action_setting_set(type, label, action); - } - else if (!strcmp(label, "video_shader_preset")) - { - switch (action) - { - case MENU_ACTION_OK: - menu_entries_push(driver.menu->menu_stack, - g_settings.video.shader_dir, - "video_shader_preset", - type, - driver.menu->selection_ptr); - break; - - case MENU_ACTION_START: - break; - - default: - break; - } - } - else if (!strcmp(label, "video_shader_pass")) - { - hack_shader_pass = type - MENU_SETTINGS_SHADER_PASS_0; - struct gfx_shader *shader = (struct gfx_shader*)driver.menu->shader; - struct gfx_shader_pass *shader_pass = NULL; - - if (shader) - shader_pass = (struct gfx_shader_pass*)&shader->pass[hack_shader_pass]; - - switch (action) - { - case MENU_ACTION_OK: - menu_entries_push(driver.menu->menu_stack, - g_settings.video.shader_dir, - "video_shader_pass", - type, - driver.menu->selection_ptr); - break; - case MENU_ACTION_START: - if (shader_pass) - *shader_pass->source.path = '\0'; - break; - - default: - break; - } - } - else if (!strcmp(label, "video_shader_filter_pass")) - { - unsigned pass = type - MENU_SETTINGS_SHADER_PASS_FILTER_0; - struct gfx_shader *shader = (struct gfx_shader*)driver.menu->shader; - struct gfx_shader_pass *shader_pass = (struct gfx_shader_pass*) - &shader->pass[pass]; - - switch (action) - { - case MENU_ACTION_START: - if (shader) - shader->pass[pass].filter = RARCH_FILTER_UNSPEC; - break; - - case MENU_ACTION_LEFT: - case MENU_ACTION_RIGHT: - case MENU_ACTION_OK: - { - unsigned delta = (action == MENU_ACTION_LEFT) ? 2 : 1; - if (shader_pass) - shader_pass->filter = ((shader_pass->filter + delta) % 3); - break; - } - - default: - break; - } - } - else if (!strcmp(label, "video_shader_scale_pass")) - { - unsigned pass = type - MENU_SETTINGS_SHADER_PASS_SCALE_0; - struct gfx_shader *shader = (struct gfx_shader*)driver.menu->shader; - struct gfx_shader_pass *shader_pass = (struct gfx_shader_pass*) - &shader->pass[pass]; - - switch (action) - { - case MENU_ACTION_START: - if (shader) - { - shader_pass->fbo.scale_x = shader_pass->fbo.scale_y = 0; - shader_pass->fbo.valid = false; - } - break; - - case MENU_ACTION_LEFT: - case MENU_ACTION_RIGHT: - case MENU_ACTION_OK: - { - unsigned current_scale = shader_pass->fbo.scale_x; - unsigned delta = action == MENU_ACTION_LEFT ? 5 : 1; - current_scale = (current_scale + delta) % 6; - - if (shader_pass) - { - shader_pass->fbo.valid = current_scale; - shader_pass->fbo.scale_x = shader_pass->fbo.scale_y = current_scale; - } - break; - } - - default: - break; - } - } - - return 0; -} - - void menu_shader_manager_apply_changes(void) { unsigned shader_type = menu_shader_manager_get_type(driver.menu->shader); @@ -527,12 +343,6 @@ void menu_shader_manager_init(void *data) {} void menu_shader_manager_set_preset(struct gfx_shader *shader, unsigned type, const char *cgp_path) { } -int menu_shader_manager_setting_toggle( - unsigned id, const char *label, unsigned action) -{ - return 0; -} - void menu_shader_manager_save_preset( const char *basename, bool apply) { } diff --git a/frontend/menu/menu_shader.h b/frontend/menu/menu_shader.h index 502b036c29..bdd7fb5c71 100644 --- a/frontend/menu/menu_shader.h +++ b/frontend/menu/menu_shader.h @@ -32,9 +32,6 @@ void menu_shader_manager_init(void *data); void menu_shader_manager_set_preset(struct gfx_shader *shader, unsigned type, const char *cgp_path); -int menu_shader_manager_setting_toggle( - unsigned id, const char *label, unsigned action); - void menu_shader_manager_save_preset( const char *basename, bool apply); From d7a216e889219d9602c3bbb696c365dec1395382 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 03:02:43 +0200 Subject: [PATCH 22/42] Get rid of fallback action in menu_action_setting_set --- frontend/menu/menu_action.c | 211 ------------------------- frontend/menu/menu_entries_cbs.c | 256 +++++++++++++++++++++++++++++++ 2 files changed, 256 insertions(+), 211 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index ce6f5d76ab..5110e68258 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -285,7 +285,6 @@ unsigned menu_current_gx_resolution = GX_RESOLUTIONS_640_480; int menu_action_setting_set(unsigned type, const char *label, unsigned action) { - unsigned port = driver.menu->current_pad; const file_list_t *list = (const file_list_t*)driver.menu->selection_buf; /* Check if setting belongs to settings menu. */ @@ -304,215 +303,5 @@ int menu_action_setting_set(unsigned type, const char *label, if (setting) return menu_action_handle_setting(setting, type, action); - /* Fallback. */ - - if (!strcmp(label, "input_bind_device_id")) - { - int *p = (int*)&g_settings.input.joypad_map[port]; - - switch (action) - { - case MENU_ACTION_START: - *p = port; - break; - case MENU_ACTION_LEFT: - (*p)--; - break; - case MENU_ACTION_RIGHT: - (*p)++; - break; - } - - if (*p < -1) - *p = -1; - else if (*p >= MAX_PLAYERS) - *p = MAX_PLAYERS - 1; - } - else if (!strcmp(label, "input_bind_device_type")) - { - unsigned current_device, current_index, i, devices[128]; - const struct retro_controller_info *desc; - unsigned types = 0; - - devices[types++] = RETRO_DEVICE_NONE; - devices[types++] = RETRO_DEVICE_JOYPAD; - - /* Only push RETRO_DEVICE_ANALOG as default if we use an - * older core which doesn't use SET_CONTROLLER_INFO. */ - if (!g_extern.system.num_ports) - devices[types++] = RETRO_DEVICE_ANALOG; - - desc = port < g_extern.system.num_ports ? - &g_extern.system.ports[port] : NULL; - if (desc) - { - for (i = 0; i < desc->num_types; i++) - { - unsigned id = desc->types[i].id; - if (types < ARRAY_SIZE(devices) && - id != RETRO_DEVICE_NONE && - id != RETRO_DEVICE_JOYPAD) - devices[types++] = id; - } - } - - current_device = g_settings.input.libretro_device[port]; - current_index = 0; - for (i = 0; i < types; i++) - { - if (current_device == devices[i]) - { - current_index = i; - break; - } - } - - switch (action) - { - case MENU_ACTION_START: - current_device = RETRO_DEVICE_JOYPAD; - - g_settings.input.libretro_device[port] = current_device; - pretro_set_controller_port_device(port, current_device); - break; - - case MENU_ACTION_LEFT: - current_device = devices - [(current_index + types - 1) % types]; - - g_settings.input.libretro_device[port] = current_device; - pretro_set_controller_port_device(port, current_device); - break; - - case MENU_ACTION_RIGHT: - case MENU_ACTION_OK: - current_device = devices - [(current_index + 1) % types]; - - g_settings.input.libretro_device[port] = current_device; - pretro_set_controller_port_device(port, current_device); - break; - } - } - else if (!strcmp(label, "input_bind_player_no")) - { - switch (action) - { - case MENU_ACTION_START: - driver.menu->current_pad = 0; - break; - case MENU_ACTION_LEFT: - if (driver.menu->current_pad != 0) - driver.menu->current_pad--; - break; - case MENU_ACTION_RIGHT: - if (driver.menu->current_pad < MAX_PLAYERS - 1) - driver.menu->current_pad++; - break; - } - - if (port != driver.menu->current_pad) - driver.menu->need_refresh = true; - port = driver.menu->current_pad; - } - else if (!strcmp(label, "input_bind_analog_dpad_mode")) - { - switch (action) - { - case MENU_ACTION_START: - g_settings.input.analog_dpad_mode[port] = 0; - break; - - case MENU_ACTION_OK: - case MENU_ACTION_RIGHT: - g_settings.input.analog_dpad_mode[port] = - (g_settings.input.analog_dpad_mode[port] + 1) - % ANALOG_DPAD_LAST; - break; - - case MENU_ACTION_LEFT: - g_settings.input.analog_dpad_mode[port] = - (g_settings.input.analog_dpad_mode - [port] + ANALOG_DPAD_LAST - 1) % ANALOG_DPAD_LAST; - break; - } - } - else - { - switch (type) - { -#if defined(GEKKO) - case MENU_SETTINGS_VIDEO_RESOLUTION: - switch (action) - { - case MENU_ACTION_LEFT: - if (menu_current_gx_resolution > 0) - menu_current_gx_resolution--; - break; - case MENU_ACTION_RIGHT: - if (menu_current_gx_resolution < GX_RESOLUTIONS_LAST - 1) - { -#ifdef HW_RVL - if ((menu_current_gx_resolution + 1) > GX_RESOLUTIONS_640_480) - if (CONF_GetVideo() != CONF_VIDEO_PAL) - return 0; -#endif - - menu_current_gx_resolution++; - } - break; - case MENU_ACTION_OK: - if (driver.video_data) - gx_set_video_mode(driver.video_data, menu_gx_resolutions - [menu_current_gx_resolution][0], - menu_gx_resolutions[menu_current_gx_resolution][1]); - break; - } - break; -#elif defined(__CELLOS_LV2__) - case MENU_SETTINGS_VIDEO_RESOLUTION: - switch (action) - { - case MENU_ACTION_LEFT: - if (g_extern.console.screen.resolutions.current.idx) - { - g_extern.console.screen.resolutions.current.idx--; - g_extern.console.screen.resolutions.current.id = - g_extern.console.screen.resolutions.list - [g_extern.console.screen.resolutions.current.idx]; - } - break; - case MENU_ACTION_RIGHT: - if (g_extern.console.screen.resolutions.current.idx + 1 < - g_extern.console.screen.resolutions.count) - { - g_extern.console.screen.resolutions.current.idx++; - g_extern.console.screen.resolutions.current.id = - g_extern.console.screen.resolutions.list - [g_extern.console.screen.resolutions.current.idx]; - } - break; - case MENU_ACTION_OK: - if (g_extern.console.screen.resolutions.list[ - g_extern.console.screen.resolutions.current.idx] == - CELL_VIDEO_OUT_RESOLUTION_576) - { - if (g_extern.console.screen.pal_enable) - g_extern.console.screen.pal60_enable = true; - } - else - { - g_extern.console.screen.pal_enable = false; - g_extern.console.screen.pal60_enable = false; - } - - rarch_main_command(RARCH_CMD_REINIT); - break; - } -#endif - break; - } - } - return 0; } diff --git a/frontend/menu/menu_entries_cbs.c b/frontend/menu/menu_entries_cbs.c index a1b0bc771d..edc963b69b 100644 --- a/frontend/menu/menu_entries_cbs.c +++ b/frontend/menu/menu_entries_cbs.c @@ -848,6 +848,252 @@ static int action_toggle_shader_parameters(unsigned type, const char *label, return 0; } +static int action_toggle_input_bind_analog_dpad_mode(unsigned type, const char *label, + unsigned action) +{ + unsigned port = 0; + + if (!driver.menu) + return -1; + + port = driver.menu->current_pad; + + switch (action) + { + case MENU_ACTION_START: + g_settings.input.analog_dpad_mode[port] = 0; + break; + + case MENU_ACTION_OK: + case MENU_ACTION_RIGHT: + g_settings.input.analog_dpad_mode[port] = + (g_settings.input.analog_dpad_mode[port] + 1) + % ANALOG_DPAD_LAST; + break; + + case MENU_ACTION_LEFT: + g_settings.input.analog_dpad_mode[port] = + (g_settings.input.analog_dpad_mode + [port] + ANALOG_DPAD_LAST - 1) % ANALOG_DPAD_LAST; + break; + } + + return 0; +} + +static int action_toggle_input_bind_device_id(unsigned type, const char *label, + unsigned action) +{ + int *p = NULL; + unsigned port = 0; + + if (!driver.menu) + return -1; + + port = driver.menu->current_pad; + p = (int*)&g_settings.input.joypad_map[port]; + + switch (action) + { + case MENU_ACTION_START: + *p = port; + break; + case MENU_ACTION_LEFT: + (*p)--; + break; + case MENU_ACTION_RIGHT: + (*p)++; + break; + } + + if (*p < -1) + *p = -1; + else if (*p >= MAX_PLAYERS) + *p = MAX_PLAYERS - 1; + + return 0; +} + +static int action_toggle_input_bind_device_type(unsigned type, const char *label, + unsigned action) +{ + unsigned current_device, current_index, i, devices[128]; + const struct retro_controller_info *desc; + unsigned types = 0, port = 0; + + if (!driver.menu) + return -1; + + port = driver.menu->current_pad; + + devices[types++] = RETRO_DEVICE_NONE; + devices[types++] = RETRO_DEVICE_JOYPAD; + + /* Only push RETRO_DEVICE_ANALOG as default if we use an + * older core which doesn't use SET_CONTROLLER_INFO. */ + if (!g_extern.system.num_ports) + devices[types++] = RETRO_DEVICE_ANALOG; + + desc = port < g_extern.system.num_ports ? + &g_extern.system.ports[port] : NULL; + if (desc) + { + for (i = 0; i < desc->num_types; i++) + { + unsigned id = desc->types[i].id; + if (types < ARRAY_SIZE(devices) && + id != RETRO_DEVICE_NONE && + id != RETRO_DEVICE_JOYPAD) + devices[types++] = id; + } + } + + current_device = g_settings.input.libretro_device[port]; + current_index = 0; + for (i = 0; i < types; i++) + { + if (current_device == devices[i]) + { + current_index = i; + break; + } + } + + switch (action) + { + case MENU_ACTION_START: + current_device = RETRO_DEVICE_JOYPAD; + + g_settings.input.libretro_device[port] = current_device; + pretro_set_controller_port_device(port, current_device); + break; + + case MENU_ACTION_LEFT: + current_device = devices + [(current_index + types - 1) % types]; + + g_settings.input.libretro_device[port] = current_device; + pretro_set_controller_port_device(port, current_device); + break; + + case MENU_ACTION_RIGHT: + case MENU_ACTION_OK: + current_device = devices + [(current_index + 1) % types]; + + g_settings.input.libretro_device[port] = current_device; + pretro_set_controller_port_device(port, current_device); + break; + } + + return 0; +} + +static int action_toggle_video_resolution(unsigned type, const char *label, + unsigned action) +{ +#ifdef GEKKO + switch (action) + { + case MENU_ACTION_LEFT: + if (menu_current_gx_resolution > 0) + menu_current_gx_resolution--; + break; + case MENU_ACTION_RIGHT: + if (menu_current_gx_resolution < GX_RESOLUTIONS_LAST - 1) + { +#ifdef HW_RVL + if ((menu_current_gx_resolution + 1) > GX_RESOLUTIONS_640_480) + if (CONF_GetVideo() != CONF_VIDEO_PAL) + return 0; +#endif + + menu_current_gx_resolution++; + } + break; + case MENU_ACTION_OK: + if (driver.video_data) + gx_set_video_mode(driver.video_data, menu_gx_resolutions + [menu_current_gx_resolution][0], + menu_gx_resolutions[menu_current_gx_resolution][1]); + break; + } +#elif defined(__CELLOS_LV2__) + switch (action) + { + case MENU_ACTION_LEFT: + if (g_extern.console.screen.resolutions.current.idx) + { + g_extern.console.screen.resolutions.current.idx--; + g_extern.console.screen.resolutions.current.id = + g_extern.console.screen.resolutions.list + [g_extern.console.screen.resolutions.current.idx]; + } + break; + case MENU_ACTION_RIGHT: + if (g_extern.console.screen.resolutions.current.idx + 1 < + g_extern.console.screen.resolutions.count) + { + g_extern.console.screen.resolutions.current.idx++; + g_extern.console.screen.resolutions.current.id = + g_extern.console.screen.resolutions.list + [g_extern.console.screen.resolutions.current.idx]; + } + break; + case MENU_ACTION_OK: + if (g_extern.console.screen.resolutions.list[ + g_extern.console.screen.resolutions.current.idx] == + CELL_VIDEO_OUT_RESOLUTION_576) + { + if (g_extern.console.screen.pal_enable) + g_extern.console.screen.pal60_enable = true; + } + else + { + g_extern.console.screen.pal_enable = false; + g_extern.console.screen.pal60_enable = false; + } + + rarch_main_command(RARCH_CMD_REINIT); + break; + } +#endif + + return 0; +} + +static int action_toggle_input_bind_player_no(unsigned type, const char *label, + unsigned action) +{ + unsigned port = 0; + + if (!driver.menu) + return -1; + + port = driver.menu->current_pad; + + switch (action) + { + case MENU_ACTION_START: + driver.menu->current_pad = 0; + break; + case MENU_ACTION_LEFT: + if (driver.menu->current_pad != 0) + driver.menu->current_pad--; + break; + case MENU_ACTION_RIGHT: + if (driver.menu->current_pad < MAX_PLAYERS - 1) + driver.menu->current_pad++; + break; + } + + if (port != driver.menu->current_pad) + driver.menu->need_refresh = true; + port = driver.menu->current_pad; + + return 0; +} + static int performance_counters_frontend_toggle(unsigned type, const char *label, unsigned action) { @@ -1152,6 +1398,16 @@ static void menu_entries_cbs_init_bind_toggle(menu_file_list_cbs_t *cbs, cbs->action_toggle = action_toggle_shader_parameters; else if (!strcmp(label, "shader_apply_changes")) cbs->action_toggle = menu_action_setting_set; + else if (!strcmp(label, "input_bind_analog_dpad_mode")) + cbs->action_toggle = action_toggle_input_bind_analog_dpad_mode; + else if (!strcmp(label, "input_bind_player_no")) + cbs->action_toggle = action_toggle_input_bind_player_no; + else if (!strcmp(label, "input_bind_device_id")) + cbs->action_toggle = action_toggle_input_bind_device_id; + else if (!strcmp(label, "input_bind_device_type")) + cbs->action_toggle = action_toggle_input_bind_device_type; + else if (type == MENU_SETTINGS_VIDEO_RESOLUTION) + cbs->action_toggle = action_toggle_video_resolution; else if ((type >= MENU_SETTINGS_CORE_OPTION_START)) cbs->action_toggle = core_setting_toggle; else if (type >= MENU_SETTINGS_PERF_COUNTERS_BEGIN && From 23b69085d3bc1d43683ba3a663bb0b1abb8b3e23 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 03:05:21 +0200 Subject: [PATCH 23/42] Move code over to menu_entries_cbs.c --- frontend/menu/menu_action.c | 88 -------------------------------- frontend/menu/menu_entries_cbs.c | 88 ++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 88 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index 5110e68258..b77cc0a2cf 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -194,94 +194,6 @@ static int menu_action_handle_setting(rarch_setting_t *setting, return 0; } -#ifdef GEKKO -enum -{ - GX_RESOLUTIONS_512_192 = 0, - GX_RESOLUTIONS_598_200, - GX_RESOLUTIONS_640_200, - GX_RESOLUTIONS_384_224, - GX_RESOLUTIONS_448_224, - GX_RESOLUTIONS_480_224, - GX_RESOLUTIONS_512_224, - GX_RESOLUTIONS_576_224, - GX_RESOLUTIONS_608_224, - GX_RESOLUTIONS_640_224, - GX_RESOLUTIONS_340_232, - GX_RESOLUTIONS_512_232, - GX_RESOLUTIONS_512_236, - GX_RESOLUTIONS_336_240, - GX_RESOLUTIONS_352_240, - GX_RESOLUTIONS_384_240, - GX_RESOLUTIONS_512_240, - GX_RESOLUTIONS_530_240, - GX_RESOLUTIONS_640_240, - GX_RESOLUTIONS_512_384, - GX_RESOLUTIONS_598_400, - GX_RESOLUTIONS_640_400, - GX_RESOLUTIONS_384_448, - GX_RESOLUTIONS_448_448, - GX_RESOLUTIONS_480_448, - GX_RESOLUTIONS_512_448, - GX_RESOLUTIONS_576_448, - GX_RESOLUTIONS_608_448, - GX_RESOLUTIONS_640_448, - GX_RESOLUTIONS_340_464, - GX_RESOLUTIONS_512_464, - GX_RESOLUTIONS_512_472, - GX_RESOLUTIONS_352_480, - GX_RESOLUTIONS_384_480, - GX_RESOLUTIONS_512_480, - GX_RESOLUTIONS_530_480, - GX_RESOLUTIONS_608_480, - GX_RESOLUTIONS_640_480, - GX_RESOLUTIONS_LAST, -}; - -unsigned menu_gx_resolutions[GX_RESOLUTIONS_LAST][2] = { - { 512, 192 }, - { 598, 200 }, - { 640, 200 }, - { 384, 224 }, - { 448, 224 }, - { 480, 224 }, - { 512, 224 }, - { 576, 224 }, - { 608, 224 }, - { 640, 224 }, - { 340, 232 }, - { 512, 232 }, - { 512, 236 }, - { 336, 240 }, - { 352, 240 }, - { 384, 240 }, - { 512, 240 }, - { 530, 240 }, - { 640, 240 }, - { 512, 384 }, - { 598, 400 }, - { 640, 400 }, - { 384, 448 }, - { 448, 448 }, - { 480, 448 }, - { 512, 448 }, - { 576, 448 }, - { 608, 448 }, - { 640, 448 }, - { 340, 464 }, - { 512, 464 }, - { 512, 472 }, - { 352, 480 }, - { 384, 480 }, - { 512, 480 }, - { 530, 480 }, - { 608, 480 }, - { 640, 480 }, -}; - -unsigned menu_current_gx_resolution = GX_RESOLUTIONS_640_480; -#endif - int menu_action_setting_set(unsigned type, const char *label, unsigned action) { diff --git a/frontend/menu/menu_entries_cbs.c b/frontend/menu/menu_entries_cbs.c index edc963b69b..6b702ce1f3 100644 --- a/frontend/menu/menu_entries_cbs.c +++ b/frontend/menu/menu_entries_cbs.c @@ -24,6 +24,94 @@ #include "../../config.def.h" #include "../../performance.h" +#ifdef GEKKO +enum +{ + GX_RESOLUTIONS_512_192 = 0, + GX_RESOLUTIONS_598_200, + GX_RESOLUTIONS_640_200, + GX_RESOLUTIONS_384_224, + GX_RESOLUTIONS_448_224, + GX_RESOLUTIONS_480_224, + GX_RESOLUTIONS_512_224, + GX_RESOLUTIONS_576_224, + GX_RESOLUTIONS_608_224, + GX_RESOLUTIONS_640_224, + GX_RESOLUTIONS_340_232, + GX_RESOLUTIONS_512_232, + GX_RESOLUTIONS_512_236, + GX_RESOLUTIONS_336_240, + GX_RESOLUTIONS_352_240, + GX_RESOLUTIONS_384_240, + GX_RESOLUTIONS_512_240, + GX_RESOLUTIONS_530_240, + GX_RESOLUTIONS_640_240, + GX_RESOLUTIONS_512_384, + GX_RESOLUTIONS_598_400, + GX_RESOLUTIONS_640_400, + GX_RESOLUTIONS_384_448, + GX_RESOLUTIONS_448_448, + GX_RESOLUTIONS_480_448, + GX_RESOLUTIONS_512_448, + GX_RESOLUTIONS_576_448, + GX_RESOLUTIONS_608_448, + GX_RESOLUTIONS_640_448, + GX_RESOLUTIONS_340_464, + GX_RESOLUTIONS_512_464, + GX_RESOLUTIONS_512_472, + GX_RESOLUTIONS_352_480, + GX_RESOLUTIONS_384_480, + GX_RESOLUTIONS_512_480, + GX_RESOLUTIONS_530_480, + GX_RESOLUTIONS_608_480, + GX_RESOLUTIONS_640_480, + GX_RESOLUTIONS_LAST, +}; + +unsigned menu_gx_resolutions[GX_RESOLUTIONS_LAST][2] = { + { 512, 192 }, + { 598, 200 }, + { 640, 200 }, + { 384, 224 }, + { 448, 224 }, + { 480, 224 }, + { 512, 224 }, + { 576, 224 }, + { 608, 224 }, + { 640, 224 }, + { 340, 232 }, + { 512, 232 }, + { 512, 236 }, + { 336, 240 }, + { 352, 240 }, + { 384, 240 }, + { 512, 240 }, + { 530, 240 }, + { 640, 240 }, + { 512, 384 }, + { 598, 400 }, + { 640, 400 }, + { 384, 448 }, + { 448, 448 }, + { 480, 448 }, + { 512, 448 }, + { 576, 448 }, + { 608, 448 }, + { 640, 448 }, + { 340, 464 }, + { 512, 464 }, + { 512, 472 }, + { 352, 480 }, + { 384, 480 }, + { 512, 480 }, + { 530, 480 }, + { 608, 480 }, + { 640, 480 }, +}; + +unsigned menu_current_gx_resolution = GX_RESOLUTIONS_640_480; +#endif + static void common_load_content(void) { rarch_main_command(RARCH_CMD_LOAD_CONTENT); From 2210932e90ba3573a4c1e14ba5679a464c9a58d3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 03:06:44 +0200 Subject: [PATCH 24/42] Turn menu_action_setting_apply into static function --- frontend/menu/menu_action.c | 2 +- frontend/menu/menu_action.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index b77cc0a2cf..a4de696afc 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -21,7 +21,7 @@ #include "menu_shader.h" -int menu_action_setting_apply(rarch_setting_t *setting) +static int menu_action_setting_apply(rarch_setting_t *setting) { if (setting->change_handler) setting->change_handler(setting); diff --git a/frontend/menu/menu_action.h b/frontend/menu/menu_action.h index 05303a24ee..3f6e968311 100644 --- a/frontend/menu/menu_action.h +++ b/frontend/menu/menu_action.h @@ -23,8 +23,6 @@ extern "C" { #endif -int menu_action_setting_apply(rarch_setting_t *setting); - int menu_action_setting_boolean( rarch_setting_t *setting, unsigned action); From ff72ddebdd2c6aa6e2718acd247faae03357dfd9 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 15 Oct 2014 03:12:19 +0200 Subject: [PATCH 25/42] menu_entries.c - cleanups --- frontend/menu/menu_entries.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/menu/menu_entries.c b/frontend/menu/menu_entries.c index a252101dd0..cd90b89545 100644 --- a/frontend/menu/menu_entries.c +++ b/frontend/menu/menu_entries.c @@ -196,7 +196,6 @@ static int push_list(menu_handle_t *menu, for (i = 0; i < list_size; i++) { char fill_buf[PATH_MAX]; - const char *path = NULL; const char *core_name = NULL; content_playlist_get_index(g_defaults.history, i, @@ -740,7 +739,6 @@ static int menu_parse_list(file_list_t *list, file_list_t *menu_list, { char core_path[PATH_MAX], display_name[PATH_MAX]; const char *path = NULL; - unsigned type = 0; file_list_get_at_offset(list, i, &path, NULL, &type); if (type != MENU_FILE_CORE) From de82a96d5cc174159f44ea92b76e02e98b7e9664 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 15 Oct 2014 03:13:27 +0200 Subject: [PATCH 26/42] file.c - fix warnings --- file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/file.c b/file.c index 63fd323c95..20142ee502 100644 --- a/file.c +++ b/file.c @@ -402,12 +402,12 @@ static bool load_content(const struct retro_subsystem_info *special, } char new_path[PATH_MAX]; - union string_list_elem_attr attr; - attr.i = 0; + union string_list_elem_attr attributes; + attributes.i = 0; fill_pathname_join(new_path,g_settings.extraction_directory, path_basename(path),sizeof(new_path)); read_compressed_file(path,NULL,new_path); - string_list_append(additional_path_allocs,new_path,attr); + string_list_append(additional_path_allocs,new_path, attributes); info[i].path = additional_path_allocs->elems [additional_path_allocs->size -1 ].data; @@ -418,7 +418,7 @@ static bool load_content(const struct retro_subsystem_info *special, */ rarch_assert(g_extern.temporary_content != NULL); string_list_append(g_extern.temporary_content, - new_path, attr); + new_path, attributes); } } } From 6ffd0d2ea760227fb778b6ecb2712ad5a93b0f9e Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 15 Oct 2014 03:14:57 +0200 Subject: [PATCH 27/42] platform_apple.c - Fix warnings --- frontend/platform/platform_apple.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/platform/platform_apple.c b/frontend/platform/platform_apple.c index f8a1b87960..aee24de426 100644 --- a/frontend/platform/platform_apple.c +++ b/frontend/platform/platform_apple.c @@ -24,6 +24,10 @@ #include #include +void apple_start_iteration(void); + +void apple_stop_iteration(void); + static CFRunLoopObserverRef iterate_observer; static void do_iteration(void) From 5279a161de14586b5827a5a1ffacf3615cd49c2d Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 15 Oct 2014 03:15:43 +0200 Subject: [PATCH 28/42] (apple/common/main.m) Fix warning --- apple/common/main.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apple/common/main.m b/apple/common/main.m index 95dc201fbf..87d5279bc8 100644 --- a/apple/common/main.m +++ b/apple/common/main.m @@ -23,6 +23,8 @@ id apple_platform; +void apple_rarch_exited(void); + void apple_rarch_exited(void) { [apple_platform unloadingCore]; From 9eabdc0dcc1914186e87c184e84cff6ad43b3ac5 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 15 Oct 2014 03:21:21 +0200 Subject: [PATCH 29/42] (7zip/rzlib) Fix no previous prototypes for function warnings --- deps/7zip/7zCrcOpt.c | 3 +++ deps/7zip/7zIn.c | 3 +++ deps/7zip/CpuArch.c | 4 +++- deps/7zip/LzmaDec.c | 2 ++ deps/rzlib/deflate.c | 4 ++++ deps/rzlib/gzread.c | 2 ++ deps/rzlib/gzwrite.c | 2 ++ deps/rzlib/inflate.c | 4 ++++ 8 files changed, 23 insertions(+), 1 deletion(-) diff --git a/deps/7zip/7zCrcOpt.c b/deps/7zip/7zCrcOpt.c index 6205d71610..96abb2f6a4 100755 --- a/deps/7zip/7zCrcOpt.c +++ b/deps/7zip/7zCrcOpt.c @@ -7,6 +7,9 @@ #define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) +UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table); +UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table); + UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table) { const Byte *p = (const Byte *)data; diff --git a/deps/7zip/7zIn.c b/deps/7zip/7zIn.c index f1a44928e2..2a1a1bca35 100755 --- a/deps/7zip/7zIn.c +++ b/deps/7zip/7zIn.c @@ -14,6 +14,9 @@ Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; #define NUM_FOLDER_CODERS_MAX 32 #define NUM_CODER_STREAMS_MAX 32 +void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc); +int SzFolder_FindBindPairForOutStream(CSzFolder *p, UInt32 outStreamIndex); + void SzCoderInfo_Init(CSzCoderInfo *p) { Buf_Init(&p->Props); diff --git a/deps/7zip/CpuArch.c b/deps/7zip/CpuArch.c index 2c25218855..4490e8f401 100755 --- a/deps/7zip/CpuArch.c +++ b/deps/7zip/CpuArch.c @@ -1,6 +1,8 @@ #include "CpuArch.h" -Bool CPU_Is_InOrder() +Bool CPU_Is_InOrder(void); + +Bool CPU_Is_InOrder(void) { return False; } diff --git a/deps/7zip/LzmaDec.c b/deps/7zip/LzmaDec.c index 9ac469d348..85f50275d1 100755 --- a/deps/7zip/LzmaDec.c +++ b/deps/7zip/LzmaDec.c @@ -682,6 +682,8 @@ static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data) p->needFlush = 0; } +void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState); + void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) { p->needFlush = 1; diff --git a/deps/rzlib/deflate.c b/deps/rzlib/deflate.c index 1238e61149..e3638e7310 100644 --- a/deps/rzlib/deflate.c +++ b/deps/rzlib/deflate.c @@ -193,6 +193,10 @@ local const config configuration_table[10] = { s->head[s->hash_size-1] = NIL; \ zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); +int ZEXPORT deflateResetKeep (z_streamp strm); + +int ZEXPORT deflatePending (z_streamp strm, unsigned *pending, int *bits); + /* ========================================================================= */ int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, int stream_size) { diff --git a/deps/rzlib/gzread.c b/deps/rzlib/gzread.c index 278fc0b48f..e7b6ea092a 100644 --- a/deps/rzlib/gzread.c +++ b/deps/rzlib/gzread.c @@ -13,6 +13,8 @@ local int gz_decomp OF((gz_statep)); local int gz_fetch OF((gz_statep)); local int gz_skip OF((gz_statep, z_off64_t)); +int ZEXPORT gzgetc_(gzFile file); + /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from state->fd, and update state->eof, state->err, and state->msg as appropriate. This function needs to loop on read(), since read() is not guaranteed to diff --git a/deps/rzlib/gzwrite.c b/deps/rzlib/gzwrite.c index 25e058c001..61b217e23a 100644 --- a/deps/rzlib/gzwrite.c +++ b/deps/rzlib/gzwrite.c @@ -10,6 +10,8 @@ local int gz_init OF((gz_statep)); local int gz_comp OF((gz_statep, int)); local int gz_zero OF((gz_statep, z_off64_t)); +int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va); + /* Initialize state for writing a gzip file. Mark initialization by setting state->size to non-zero. Return -1 on failure or 0 on success. */ local int gz_init(gz_statep state) diff --git a/deps/rzlib/inflate.c b/deps/rzlib/inflate.c index 4213615636..b78f23a53d 100644 --- a/deps/rzlib/inflate.c +++ b/deps/rzlib/inflate.c @@ -105,6 +105,10 @@ local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, unsigned len)); +int ZEXPORT inflateResetKeep(z_streamp strm); + +int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, uInt *dictLength); + int ZEXPORT inflateResetKeep(z_streamp strm) { struct inflate_state FAR *state; From c9bd4ad5896d1e8c0dcf4c57acdfbf328c1c7485 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 15 Oct 2014 03:25:36 +0200 Subject: [PATCH 30/42] Comment out unused code --- input/connect/connect_ps4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/connect/connect_ps4.c b/input/connect/connect_ps4.c index 1c3ff2b382..f89c8d8bcb 100644 --- a/input/connect/connect_ps4.c +++ b/input/connect/connect_ps4.c @@ -85,6 +85,7 @@ static void hidpad_ps4_disconnect(void *data) free(device); } +#if 0 static uint32_t hidpad_ps4_get_buttons(void *data) { uint32_t result = 0; @@ -125,7 +126,6 @@ static uint32_t hidpad_ps4_get_buttons(void *data) return result; } -#if 0 static int16_t hidpad_ps4_get_axis(void *data, unsigned axis) { struct hidpad_ps4_data *device = (struct hidpad_ps4_data*)data; From c0113bef6adfcf15f403ea05cb005479d410522c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 03:34:20 +0200 Subject: [PATCH 31/42] Cleanups to menu_action_handle_settings --- frontend/menu/menu_action.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index a4de696afc..dfbf0c6bdf 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -172,9 +172,7 @@ static int menu_action_handle_setting(rarch_setting_t *setting, if (setting->type == ST_STRING) { - if ( - (setting->flags & SD_FLAG_ALLOW_INPUT) || - type == MENU_FILE_LINEFEED_SWITCH) + if (setting->flags & SD_FLAG_ALLOW_INPUT) { switch (action) { From bb3caf700507eea352406b5b8276537b11144895 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 05:51:00 +0200 Subject: [PATCH 32/42] Get rid of static inline function --- frontend/menu/menu_action.c | 87 +++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 17 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index dfbf0c6bdf..d2fdf6f88e 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -20,9 +20,12 @@ #include "menu_entries.h" #include "menu_shader.h" - -static int menu_action_setting_apply(rarch_setting_t *setting) +int menu_action_setting_boolean( + rarch_setting_t *setting, unsigned action) { + if (setting->action_ok) + setting->action_ok(setting, action); + if (setting->change_handler) setting->change_handler(setting); @@ -36,22 +39,23 @@ static int menu_action_setting_apply(rarch_setting_t *setting) return 0; } -int menu_action_setting_boolean( - rarch_setting_t *setting, unsigned action) -{ - if (setting->action_ok) - setting->action_ok(setting, action); - - return menu_action_setting_apply(setting); -} - int menu_action_setting_unsigned_integer( rarch_setting_t *setting, unsigned action) { if (setting->action_ok) setting->action_ok(setting, action); - return menu_action_setting_apply(setting); + if (setting->change_handler) + setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; + return -1; + } + + return 0; } int menu_action_setting_fraction( @@ -60,7 +64,17 @@ int menu_action_setting_fraction( if (setting->action_ok) setting->action_ok(setting, action); - return menu_action_setting_apply(setting); + if (setting->change_handler) + setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; + return -1; + } + + return 0; } void menu_action_setting_driver( @@ -101,7 +115,17 @@ int menu_action_setting_set_current_string( { strlcpy(setting->value.string, str, setting->size); - return menu_action_setting_apply(setting); + if (setting->change_handler) + setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; + return -1; + } + + return 0; } int menu_action_set_current_string_based_on_label( @@ -118,7 +142,17 @@ int menu_action_setting_set_current_string_path( { fill_pathname_join(setting->value.string, dir, path, setting->size); - return menu_action_setting_apply(setting); + if (setting->change_handler) + setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; + return -1; + } + + return 0; } static int menu_entries_set_current_path_selection( @@ -141,7 +175,17 @@ static int menu_entries_set_current_path_selection( break; } - return menu_action_setting_apply(setting); + if (setting->change_handler) + setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; + return -1; + } + + return 0; } static int menu_action_handle_setting(rarch_setting_t *setting, @@ -165,7 +209,16 @@ static int menu_action_handle_setting(rarch_setting_t *setting, if (action == MENU_ACTION_START) { *setting->value.string = '\0'; - return menu_action_setting_apply(setting); + + if (setting->change_handler) + setting->change_handler(setting); + + if (setting->flags & SD_FLAG_EXIT + && setting->cmd_trigger.triggered) + { + setting->cmd_trigger.triggered = false; + return -1; + } } return 0; } From 5636414e315c07c322ea95466ecccab315587f22 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 05:57:15 +0200 Subject: [PATCH 33/42] Refactor Lakka action code --- frontend/menu/backend/menu_lakka_backend.c | 22 +--------------------- frontend/menu/menu_action.c | 2 +- frontend/menu/menu_action.h | 3 +++ 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/frontend/menu/backend/menu_lakka_backend.c b/frontend/menu/backend/menu_lakka_backend.c index d3a943ccb8..d1ff11206f 100644 --- a/frontend/menu/backend/menu_lakka_backend.c +++ b/frontend/menu/backend/menu_lakka_backend.c @@ -359,27 +359,7 @@ static int menu_lakka_iterate(unsigned action) rarch_setting_t *setting = (rarch_setting_t*) active_subitem->setting; - switch (action) - { - case MENU_ACTION_OK: - if (setting->cmd_trigger.idx != RARCH_CMD_NONE) - setting->cmd_trigger.triggered = true; - /* fall-through */ - case MENU_ACTION_LEFT: - case MENU_ACTION_RIGHT: - case MENU_ACTION_START: - if (setting->type == ST_BOOL) - menu_action_setting_boolean(setting, action); - else if (setting->type == ST_UINT) - menu_action_setting_unsigned_integer(setting, action); - else if (setting->type == ST_FLOAT) - menu_action_setting_fraction(setting, action); - else if (setting->type == ST_STRING) - menu_action_setting_driver(setting, action); - break; - default: - break; - } + menu_action_handle_setting(setting, 0, action); } switch (action) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index d2fdf6f88e..6801ac32b4 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -188,7 +188,7 @@ static int menu_entries_set_current_path_selection( return 0; } -static int menu_action_handle_setting(rarch_setting_t *setting, +int menu_action_handle_setting(rarch_setting_t *setting, unsigned type, unsigned action) { if (!setting) diff --git a/frontend/menu/menu_action.h b/frontend/menu/menu_action.h index 3f6e968311..d3e4d27544 100644 --- a/frontend/menu/menu_action.h +++ b/frontend/menu/menu_action.h @@ -47,6 +47,9 @@ int menu_action_setting_set_current_string_path( int menu_action_setting_set(unsigned type, const char *label, unsigned action); +int menu_action_handle_setting(rarch_setting_t *setting, + unsigned type, unsigned action); + #ifdef __cplusplus } #endif From 368e3455f97fc2b4a17567dfd5afddefe763ce3a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 06:01:36 +0200 Subject: [PATCH 34/42] Make menu_action_setting_driver a static function --- frontend/menu/menu_action.c | 2 +- frontend/menu/menu_action.h | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index 6801ac32b4..cbc77f5d2b 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -77,7 +77,7 @@ int menu_action_setting_fraction( return 0; } -void menu_action_setting_driver( +static void menu_action_setting_driver( rarch_setting_t *setting, unsigned action) { if (!strcmp(setting->name, "audio_resampler_driver")) diff --git a/frontend/menu/menu_action.h b/frontend/menu/menu_action.h index d3e4d27544..c2d0c2a4ca 100644 --- a/frontend/menu/menu_action.h +++ b/frontend/menu/menu_action.h @@ -32,9 +32,6 @@ int menu_action_setting_fraction( int menu_action_setting_unsigned_integer( rarch_setting_t *setting, unsigned action); -void menu_action_setting_driver( - rarch_setting_t *setting, unsigned action); - int menu_action_set_current_string_based_on_label( const char *label, const char *str); From ec002b5f5c02963021faf650d197fbd82be1c715 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 06:23:04 +0200 Subject: [PATCH 35/42] driver.h - Indenting nits --- driver.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/driver.h b/driver.h index 19b0b7be0a..46d20a1f09 100644 --- a/driver.h +++ b/driver.h @@ -443,13 +443,13 @@ enum rarch_display_type /* Flags for init_drivers/uninit_drivers */ enum { - DRIVER_AUDIO = 1 << 0, - DRIVER_VIDEO = 1 << 1, - DRIVER_INPUT = 1 << 2, - DRIVER_OSK = 1 << 3, - DRIVER_CAMERA = 1 << 4, - DRIVER_LOCATION = 1 << 5, - DRIVER_MENU = 1 << 6, + DRIVER_AUDIO = 1 << 0, + DRIVER_VIDEO = 1 << 1, + DRIVER_INPUT = 1 << 2, + DRIVER_OSK = 1 << 3, + DRIVER_CAMERA = 1 << 4, + DRIVER_LOCATION = 1 << 5, + DRIVER_MENU = 1 << 6, DRIVERS_VIDEO_INPUT = 1 << 7 /* note multiple drivers */ }; From 459e4fa0d2e42d802d63a083cde811a229100867 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 06:46:00 +0200 Subject: [PATCH 36/42] Move more settings callbacks over to settings_data.c --- frontend/menu/menu_action.c | 50 +------------------------ settings_data.c | 73 +++++++++++++++++++++++++++++++++++++ settings_list.h | 2 + 3 files changed, 77 insertions(+), 48 deletions(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index cbc77f5d2b..e362029b65 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -77,39 +77,6 @@ int menu_action_setting_fraction( return 0; } -static void menu_action_setting_driver( - rarch_setting_t *setting, unsigned action) -{ - if (!strcmp(setting->name, "audio_resampler_driver")) - { - switch (action) - { - case MENU_ACTION_LEFT: - find_prev_resampler_driver(); - break; - case MENU_ACTION_RIGHT: - find_next_resampler_driver(); - break; - } - } - else if (setting->flags & SD_FLAG_IS_DRIVER) - { - const char *label = setting->name; - char *drv = (char*)setting->value.string; - size_t sizeof_driver = setting->size; - - switch (action) - { - case MENU_ACTION_LEFT: - find_prev_driver(label, drv, sizeof_driver); - break; - case MENU_ACTION_RIGHT: - find_next_driver(label, drv, sizeof_driver); - break; - } - } -} - int menu_action_setting_set_current_string( rarch_setting_t *setting, const char *str) { @@ -225,21 +192,8 @@ int menu_action_handle_setting(rarch_setting_t *setting, if (setting->type == ST_STRING) { - if (setting->flags & SD_FLAG_ALLOW_INPUT) - { - switch (action) - { - case MENU_ACTION_OK: - menu_key_start_line(driver.menu, setting->short_description, - setting->name, st_string_callback); - break; - case MENU_ACTION_START: - *setting->value.string = '\0'; - break; - } - } - else - menu_action_setting_driver(setting, action); + if (setting->action_toggle) + setting->action_toggle(setting, action); } return 0; diff --git a/settings_data.c b/settings_data.c index 178e3f38c8..de1a37ed83 100644 --- a/settings_data.c +++ b/settings_data.c @@ -2378,13 +2378,85 @@ static void general_write_handler(void *data) #define MAX_GAMMA_SETTING 1 #endif +static int setting_data_string_action_toggle_driver(void *data, + unsigned action) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting) + return -1; + + + switch (action) + { + case MENU_ACTION_LEFT: + find_prev_driver(setting->name, setting->value.string, setting->size); + break; + case MENU_ACTION_RIGHT: + find_next_driver(setting->name, setting->value.string, setting->size); + break; + } + + return 0; +} + +static int setting_data_string_action_toggle_allow_input(void *data, + unsigned action) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting || !driver.menu) + return -1; + + switch (action) + { + case MENU_ACTION_OK: + menu_key_start_line(driver.menu, setting->short_description, + setting->name, st_string_callback); + break; + case MENU_ACTION_START: + *setting->value.string = '\0'; + break; + } + + return 0; +} + +static int setting_data_string_action_toggle_audio_resampler(void *data, + unsigned action) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + + if (!setting) + return -1; + + switch (action) + { + case MENU_ACTION_LEFT: + find_prev_resampler_driver(); + break; + case MENU_ACTION_RIGHT: + find_next_resampler_driver(); + break; + } + + return 0; +} + static void setting_data_add_special_callbacks( rarch_setting_t **list, rarch_setting_info_t *list_info, unsigned values) { + /* Action OK. */ if (values & SD_FLAG_ALLOW_INPUT) (*list)[list_info->index - 1].action_ok = setting_data_uint_action_ok_linefeed; + + /* Action Toggle. */ + if (values & SD_FLAG_ALLOW_INPUT) + (*list)[list_info->index - 1].action_toggle = setting_data_string_action_toggle_allow_input; + else if (values & SD_FLAG_IS_DRIVER) + (*list)[list_info->index - 1].action_toggle = setting_data_string_action_toggle_driver; } static void settings_data_list_current_add_flags( @@ -2760,6 +2832,7 @@ static bool setting_data_append_list_driver_options( subgroup_info.name, NULL, NULL); + (*list)[list_info->index - 1].action_toggle = &setting_data_string_action_toggle_audio_resampler; CONFIG_STRING( g_settings.camera.driver, diff --git a/settings_list.h b/settings_list.h index 1154145657..d10185257a 100644 --- a/settings_list.h +++ b/settings_list.h @@ -81,6 +81,7 @@ enum setting_list_flags #define SL_FLAG_ALL_SETTINGS (SL_FLAG_ALL - SL_FLAG_MAIN_MENU) typedef void (*change_handler_t)(void *data); +typedef int (*action_toggle_handler_t)(void *data, unsigned action); typedef int (*action_ok_handler_t)(void *data, unsigned action); typedef struct rarch_setting_info @@ -116,6 +117,7 @@ typedef struct rarch_setting change_handler_t change_handler; change_handler_t deferred_handler; change_handler_t read_handler; + action_toggle_handler_t action_toggle; action_ok_handler_t action_ok; union From 28b5826cde81190a422ddede6c54a5cad1be62ee Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 06:47:43 +0200 Subject: [PATCH 37/42] Return setting->action_toggle --- frontend/menu/menu_action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/menu/menu_action.c b/frontend/menu/menu_action.c index e362029b65..8b94a9995f 100644 --- a/frontend/menu/menu_action.c +++ b/frontend/menu/menu_action.c @@ -193,7 +193,7 @@ int menu_action_handle_setting(rarch_setting_t *setting, if (setting->type == ST_STRING) { if (setting->action_toggle) - setting->action_toggle(setting, action); + return setting->action_toggle(setting, action); } return 0; From 26679ab2414ee99b0b3aa41618eeb938cc49965e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 06:58:54 +0200 Subject: [PATCH 38/42] Put fifo_buffer struct definition in fifo_buffer.h - don't include stdio.h --- fifo_buffer.c | 9 --------- fifo_buffer.h | 10 +++++++++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/fifo_buffer.c b/fifo_buffer.c index 657697a53b..a4ae0a29f1 100644 --- a/fifo_buffer.c +++ b/fifo_buffer.c @@ -14,15 +14,6 @@ */ #include "fifo_buffer.h" -#include - -struct fifo_buffer -{ - uint8_t *buffer; - size_t bufsize; - size_t first; - size_t end; -}; fifo_buffer_t *fifo_new(size_t size) { diff --git a/fifo_buffer.h b/fifo_buffer.h index ff61be66ad..54ef8ba4fa 100644 --- a/fifo_buffer.h +++ b/fifo_buffer.h @@ -17,13 +17,21 @@ #define __FIFO_BUFFER_H #include -#include +#include #include #ifdef __cplusplus extern "C" { #endif +struct fifo_buffer +{ + uint8_t *buffer; + size_t bufsize; + size_t first; + size_t end; +}; + typedef struct fifo_buffer fifo_buffer_t; fifo_buffer_t *fifo_new(size_t size); From d56105b6e5414b4906c30a8d70916912fdd10d82 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 07:00:51 +0200 Subject: [PATCH 39/42] Some more stdio.h header includes removed --- driver.c | 2 +- retroarch.c | 2 +- string_list.c | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/driver.c b/driver.c index 26f930c4fe..cbcb198661 100644 --- a/driver.c +++ b/driver.c @@ -19,7 +19,7 @@ #include "general.h" #include "file.h" #include "libretro.h" -#include +#include #include #include #include "compat/posix_string.h" diff --git a/retroarch.c b/retroarch.c index 7bffe65268..74a7f30822 100644 --- a/retroarch.c +++ b/retroarch.c @@ -18,8 +18,8 @@ #include "boolean.h" #include "libretro.h" #include "retro.h" -#include #include +#include #include #include #include diff --git a/string_list.c b/string_list.c index c767549132..6890737115 100644 --- a/string_list.c +++ b/string_list.c @@ -14,7 +14,6 @@ * If not, see . */ -#include #include #include #include From 78c136b218e666deed4e12af8e1c00baa9307133 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 07:40:19 +0200 Subject: [PATCH 40/42] Start setting the stage for deferred push callback --- file_list.c | 5 +++++ file_list.h | 2 ++ frontend/menu/menu_entries.c | 10 ++++++++-- frontend/menu/menu_entries.h | 4 ++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/file_list.c b/file_list.c index fbb24e8fb2..367ff07727 100644 --- a/file_list.c +++ b/file_list.c @@ -205,6 +205,11 @@ void *file_list_get_actiondata_at_offset(const file_list_t *list, size_t index) return list->list[index].actiondata; } +void *file_list_get_last_actiondata(const file_list_t *list) +{ + return list->list[list->size - 1].actiondata; +} + void file_list_get_at_offset(const file_list_t *list, size_t index, const char **path, const char **label, unsigned *file_type) { diff --git a/file_list.h b/file_list.h index 6843db9bbb..875a429eb4 100644 --- a/file_list.h +++ b/file_list.h @@ -60,6 +60,8 @@ void file_list_get_last(const file_list_t *list, const char **path, const char **label, unsigned *type); +void *file_list_get_last_actiondata(const file_list_t *list); + size_t file_list_get_size(const file_list_t *list); size_t file_list_get_directory_ptr(const file_list_t *list); diff --git a/frontend/menu/menu_entries.c b/frontend/menu/menu_entries.c index cd90b89545..5663051191 100644 --- a/frontend/menu/menu_entries.c +++ b/frontend/menu/menu_entries.c @@ -543,7 +543,7 @@ static int push_list(menu_handle_t *menu, return 0; } -static int menu_parse_list(file_list_t *list, file_list_t *menu_list, +int menu_entries_parse_list(file_list_t *list, file_list_t *menu_list, const char *dir, const char *label, unsigned type, unsigned default_type_plain, const char *exts) { @@ -792,6 +792,7 @@ int menu_entries_deferred_push(file_list_t *list, file_list_t *menu_list) const char *path = NULL; const char *label = NULL; const char *exts = NULL; + menu_file_list_cbs_t *cbs = NULL; char ext_buf[PATH_MAX]; file_list_get_last(menu_list, &path, &label, &type); @@ -803,6 +804,11 @@ int menu_entries_deferred_push(file_list_t *list, file_list_t *menu_list) if (((menu_parse_check(label, type)) == -1)) return push_list(driver.menu, list, path, label, type); + cbs = (menu_file_list_cbs_t*) + file_list_get_last_actiondata(menu_list); + + (void)cbs; + //RARCH_LOG("LABEL: %s\n", label); if (!strcmp(label, "core_list")) exts = EXT_EXECUTABLES; @@ -860,7 +866,7 @@ int menu_entries_deferred_push(file_list_t *list, file_list_t *menu_list) else exts = g_extern.system.valid_extensions; - menu_parse_list(list, menu_list, path, label, + menu_entries_parse_list(list, menu_list, path, label, type, default_type_plain, exts); return 0; diff --git a/frontend/menu/menu_entries.h b/frontend/menu/menu_entries.h index cfb2f6f366..0b060b7bdb 100644 --- a/frontend/menu/menu_entries.h +++ b/frontend/menu/menu_entries.h @@ -30,6 +30,10 @@ void menu_entries_push(file_list_t *list, const char *path, const char *label, unsigned type, size_t directory_ptr); +int menu_entries_parse_list(file_list_t *list, file_list_t *menu_list, + const char *dir, const char *label, unsigned type, + unsigned default_type_plain, const char *exts); + void menu_entries_pop_list(file_list_t *list); int menu_entries_deferred_push(file_list_t *list, file_list_t *menu_list); From 53804dfa168d0a2a894b1f6dfa3ac5a08649219f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 08:04:10 +0200 Subject: [PATCH 41/42] (Menu) Implement deferred push callback --- frontend/menu/backend/menu_backend.h | 2 + frontend/menu/menu_entries.c | 73 +-------- frontend/menu/menu_entries_cbs.c | 220 +++++++++++++++++++++++++++ 3 files changed, 225 insertions(+), 70 deletions(-) diff --git a/frontend/menu/backend/menu_backend.h b/frontend/menu/backend/menu_backend.h index 1bf1f7fd7a..e93dae9535 100644 --- a/frontend/menu/backend/menu_backend.h +++ b/frontend/menu/backend/menu_backend.h @@ -7,6 +7,8 @@ extern "C" { typedef struct menu_file_list_cbs { + int (*action_deferred_push)(void *data, void *userdata, const char + *path, const char *label, unsigned type); int (*action_ok)(const char *path, const char *label, unsigned type, size_t index); int (*action_start)(unsigned type, const char *label, unsigned action); diff --git a/frontend/menu/menu_entries.c b/frontend/menu/menu_entries.c index 5663051191..42fd66c292 100644 --- a/frontend/menu/menu_entries.c +++ b/frontend/menu/menu_entries.c @@ -17,7 +17,6 @@ #include "menu_entries.h" #include "menu_action.h" #include "../../settings_data.h" -#include "../../file_ext.h" #include "../../performance.h" static void entries_refresh(file_list_t *list) @@ -784,90 +783,24 @@ static int menu_parse_check(const char *label, unsigned menu_type) return 0; } - int menu_entries_deferred_push(file_list_t *list, file_list_t *menu_list) { - unsigned type = 0, default_type_plain = MENU_FILE_PLAIN; + unsigned type = 0; const char *path = NULL; const char *label = NULL; - const char *exts = NULL; menu_file_list_cbs_t *cbs = NULL; - char ext_buf[PATH_MAX]; file_list_get_last(menu_list, &path, &label, &type); -#if 0 - RARCH_LOG("label: %s\n", label); -#endif - if (((menu_parse_check(label, type)) == -1)) return push_list(driver.menu, list, path, label, type); cbs = (menu_file_list_cbs_t*) file_list_get_last_actiondata(menu_list); - (void)cbs; - - //RARCH_LOG("LABEL: %s\n", label); - if (!strcmp(label, "core_list")) - exts = EXT_EXECUTABLES; - else if (!strcmp(label, "configurations")) - { - exts = "cfg"; - default_type_plain = MENU_FILE_CONFIG; - } - else if (!strcmp(label, "video_shader_preset")) - { - exts = "cgp|glslp"; - default_type_plain = MENU_FILE_SHADER_PRESET; - } - else if (!strcmp(label, "video_shader_pass")) - { - exts = "cg|glsl"; - default_type_plain = MENU_FILE_SHADER; - } - else if (!strcmp(label, "video_filter")) - { - exts = "filt"; - default_type_plain = MENU_FILE_VIDEOFILTER; - } - else if (!strcmp(label, "audio_dsp_plugin")) - { - exts = "dsp"; - default_type_plain = MENU_FILE_AUDIOFILTER; - } - else if (!strcmp(label, "input_overlay")) - { - exts = "cfg"; - default_type_plain = MENU_FILE_OVERLAY; - } - else if (!strcmp(label, "video_font_path")) - { - exts = "ttf"; - default_type_plain = MENU_FILE_FONT; - } - else if (!strcmp(label, "game_history_path")) - exts = "cfg"; - else if (menu_common_type_is(label, type) == MENU_FILE_DIRECTORY) - exts = ""; /* we ignore files anyway */ - else if (!strcmp(label, "detect_core_list")) - exts = g_extern.core_info ? core_info_list_get_all_extensions( - g_extern.core_info) : ""; - else if (g_extern.menu.info.valid_extensions) - { - exts = ext_buf; - if (*g_extern.menu.info.valid_extensions) - snprintf(ext_buf, sizeof(ext_buf), "%s", - g_extern.menu.info.valid_extensions); - else - *ext_buf = '\0'; - } - else - exts = g_extern.system.valid_extensions; - - menu_entries_parse_list(list, menu_list, path, label, - type, default_type_plain, exts); + if (cbs->action_deferred_push) + return cbs->action_deferred_push(list, menu_list, path, label, type); return 0; } diff --git a/frontend/menu/menu_entries_cbs.c b/frontend/menu/menu_entries_cbs.c index 6b702ce1f3..e4f53aa006 100644 --- a/frontend/menu/menu_entries_cbs.c +++ b/frontend/menu/menu_entries_cbs.c @@ -21,6 +21,7 @@ #include "menu_shader.h" #include "backend/menu_backend.h" +#include "../../file_ext.h" #include "../../config.def.h" #include "../../performance.h" @@ -1309,6 +1310,191 @@ static int action_start_bind(unsigned type, const char *label, return 0; } +static int deferred_push_core_list(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + menu_entries_parse_list(list, menu_list, path, label, + type, MENU_FILE_PLAIN, EXT_EXECUTABLES); + + return 0; +} + +static int deferred_push_configurations(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + menu_entries_parse_list(list, menu_list, path, label, + type, MENU_FILE_CONFIG, "cfg"); + + return 0; +} + +static int deferred_push_video_shader_preset(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + menu_entries_parse_list(list, menu_list, path, label, + type, MENU_FILE_SHADER_PRESET, "cgp|glslp"); + + return 0; +} + +static int deferred_push_video_shader_pass(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + menu_entries_parse_list(list, menu_list, path, label, + type, MENU_FILE_SHADER, "cg|glsl"); + + return 0; +} + +static int deferred_push_video_filter(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + menu_entries_parse_list(list, menu_list, path, label, + type, MENU_FILE_VIDEOFILTER, "filt"); + + return 0; +} + +static int deferred_push_audio_dsp_plugin(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + menu_entries_parse_list(list, menu_list, path, label, + type, MENU_FILE_AUDIOFILTER, "dsp"); + + return 0; +} + +static int deferred_push_input_overlay(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + menu_entries_parse_list(list, menu_list, path, label, + type, MENU_FILE_OVERLAY, "cfg"); + + return 0; +} + +static int deferred_push_video_font_path(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + menu_entries_parse_list(list, menu_list, path, label, + type, MENU_FILE_FONT, "ttf"); + + return 0; +} + +static int deferred_push_content_history_path(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + menu_entries_parse_list(list, menu_list, path, label, + type, MENU_FILE_PLAIN, "cfg"); + + return 0; +} + +static int deferred_push_detect_core_list(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + const char *exts = NULL; + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + exts = g_extern.core_info ? core_info_list_get_all_extensions( + g_extern.core_info) : ""; + + menu_entries_parse_list(list, menu_list, path, label, + type, MENU_FILE_PLAIN, exts); + + return 0; +} + +static int deferred_push_default(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + char ext_buf[PATH_MAX]; + const char *exts = NULL; + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + if (menu_common_type_is(label, type) == MENU_FILE_DIRECTORY) + exts = ""; /* we ignore files anyway */ + else if (g_extern.menu.info.valid_extensions) + { + exts = ext_buf; + if (*g_extern.menu.info.valid_extensions) + snprintf(ext_buf, sizeof(ext_buf), "%s", + g_extern.menu.info.valid_extensions); + else + *ext_buf = '\0'; + } + else + exts = g_extern.system.valid_extensions; + + menu_entries_parse_list(list, menu_list, path, label, + type, MENU_FILE_PLAIN, exts); + + return 0; +} + /* Bind the OK callback function */ static int menu_entries_cbs_init_bind_ok_first(menu_file_list_cbs_t *cbs, @@ -1516,6 +1702,39 @@ static void menu_entries_cbs_init_bind_toggle(menu_file_list_cbs_t *cbs, } } +static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs, + const char *path, const char *label, unsigned type, size_t index) +{ + const char *menu_label = NULL; + if (!cbs || !driver.menu) + return; + + file_list_get_last(driver.menu->menu_stack, NULL, &menu_label, NULL); + + cbs->action_deferred_push = deferred_push_default; + + if (!strcmp(label, "core_list")) + cbs->action_deferred_push = deferred_push_core_list; + else if (!strcmp(label, "configurations")) + cbs->action_deferred_push = deferred_push_configurations; + else if (!strcmp(label, "video_shader_preset")) + cbs->action_deferred_push = deferred_push_video_shader_preset; + else if (!strcmp(label, "video_shader_pass")) + cbs->action_deferred_push = deferred_push_video_shader_pass; + else if (!strcmp(label, "video_filter")) + cbs->action_deferred_push = deferred_push_video_filter; + else if (!strcmp(label, "audio_dsp_plugin")) + cbs->action_deferred_push = deferred_push_audio_dsp_plugin; + else if (!strcmp(label, "input_overlay")) + cbs->action_deferred_push = deferred_push_input_overlay; + else if (!strcmp(label, "video_font_path")) + cbs->action_deferred_push = deferred_push_video_font_path; + else if (!strcmp(label, "game_history_path")) + cbs->action_deferred_push = deferred_push_content_history_path; + else if (!strcmp(label, "detect_core_list")) + cbs->action_deferred_push = deferred_push_detect_core_list; +} + void menu_entries_cbs_init(void *data, const char *path, const char *label, unsigned type, size_t index) @@ -1533,5 +1752,6 @@ void menu_entries_cbs_init(void *data, menu_entries_cbs_init_bind_ok(cbs, path, label, type, index); menu_entries_cbs_init_bind_start(cbs, path, label, type, index); menu_entries_cbs_init_bind_toggle(cbs, path, label, type, index); + menu_entries_cbs_init_bind_deferred_push(cbs, path, label, type, index); } } From fbeb79504aa7ece90cb2c1748e61c1124a7bfd8e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Oct 2014 08:22:28 +0200 Subject: [PATCH 42/42] Move history_list to deferred push callback too --- frontend/menu/menu_entries.c | 61 +++++++++----------------------- frontend/menu/menu_entries.h | 4 +++ frontend/menu/menu_entries_cbs.c | 47 ++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 45 deletions(-) diff --git a/frontend/menu/menu_entries.c b/frontend/menu/menu_entries.c index 42fd66c292..080e96cd95 100644 --- a/frontend/menu/menu_entries.c +++ b/frontend/menu/menu_entries.c @@ -19,7 +19,7 @@ #include "../../settings_data.h" #include "../../performance.h" -static void entries_refresh(file_list_t *list) +void entries_refresh(file_list_t *list) { /* Before a refresh, we could have deleted a file on disk, causing * selection_ptr to suddendly be out of range. @@ -74,28 +74,28 @@ static inline int menu_list_get_first_char(file_list_t *buf, return ret; } -static void menu_build_scroll_indices(file_list_t *buf) +void menu_build_scroll_indices(file_list_t *list) { size_t i; int current; bool current_is_dir; - if (!driver.menu || !buf) + if (!driver.menu || !list) return; driver.menu->scroll_indices_size = 0; - if (!buf->size) + if (!list->size) return; driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = 0; - current = menu_list_get_first_char(buf, 0); - current_is_dir = menu_list_elem_is_dir(buf, 0); + current = menu_list_get_first_char(list, 0); + current_is_dir = menu_list_elem_is_dir(list, 0); - for (i = 1; i < buf->size; i++) + for (i = 1; i < list->size; i++) { - int first = menu_list_get_first_char(buf, i); - bool is_dir = menu_list_elem_is_dir(buf, i); + int first = menu_list_get_first_char(list, i); + bool is_dir = menu_list_elem_is_dir(list, i); if ((current_is_dir && !is_dir) || (first > current)) driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = i; @@ -105,7 +105,7 @@ static void menu_build_scroll_indices(file_list_t *buf) } driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = - buf->size - 1; + list->size - 1; } static void add_setting_entry(menu_handle_t *menu, @@ -179,7 +179,6 @@ static int push_list(menu_handle_t *menu, unsigned i; size_t list_size = 0; bool do_action = false; - bool is_history_list = !strcmp(label, "history_list"); #if 0 RARCH_LOG("Label is: %s\n", label); @@ -187,35 +186,7 @@ static int push_list(menu_handle_t *menu, RARCH_LOG("Menu type is: %d\n", menu_type); #endif - if (!strcmp(label, "history_list")) - { - file_list_clear(list); - list_size = content_playlist_size(g_defaults.history); - - for (i = 0; i < list_size; i++) - { - char fill_buf[PATH_MAX]; - const char *core_name = NULL; - - content_playlist_get_index(g_defaults.history, i, - &path, NULL, &core_name); - strlcpy(fill_buf, core_name, sizeof(fill_buf)); - - if (path) - { - char path_short[PATH_MAX]; - fill_short_pathname_representation(path_short,path,sizeof(path_short)); - snprintf(fill_buf,sizeof(fill_buf),"%s (%s)", - path_short,core_name); - } - - file_list_push(list, fill_buf, "", - MENU_FILE_PLAYLIST_ENTRY, 0); - - do_action = true; - } - } - else if (!strcmp(label, "Main Menu")) + if (!strcmp(label, "Main Menu")) { settings_list_free(menu->list_mainmenu); menu->list_mainmenu = (rarch_setting_t *)setting_data_new(SL_FLAG_MAIN_MENU); @@ -530,9 +501,6 @@ static int push_list(menu_handle_t *menu, if (do_action) { driver.menu->scroll_indices_size = 0; - if (is_history_list) - menu_build_scroll_indices(list); - entries_refresh(list); } @@ -777,7 +745,7 @@ static int menu_parse_check(const char *label, unsigned menu_type) !strcmp(label, "disk_image_append")))); if (check) return -1; - check = !strcmp(label, "history_list") || !strcmp(label, "deferred_core_list"); + check = !strcmp(label, "deferred_core_list"); if (check) return -1; return 0; @@ -794,7 +762,10 @@ int menu_entries_deferred_push(file_list_t *list, file_list_t *menu_list) file_list_get_last(menu_list, &path, &label, &type); if (((menu_parse_check(label, type)) == -1)) - return push_list(driver.menu, list, path, label, type); + { + if (strcmp(label, "history_list") != 0) + return push_list(driver.menu, list, path, label, type); + } cbs = (menu_file_list_cbs_t*) file_list_get_last_actiondata(menu_list); diff --git a/frontend/menu/menu_entries.h b/frontend/menu/menu_entries.h index 0b060b7bdb..6d786c32a1 100644 --- a/frontend/menu/menu_entries.h +++ b/frontend/menu/menu_entries.h @@ -45,6 +45,10 @@ void menu_flush_stack_label(file_list_t *list, const char *needle); bool menu_entries_init(menu_handle_t *menu); +void entries_refresh(file_list_t *list); + +void menu_build_scroll_indices(file_list_t *list); + #ifdef __cplusplus } #endif diff --git a/frontend/menu/menu_entries_cbs.c b/frontend/menu/menu_entries_cbs.c index e4f53aa006..1ffc27da31 100644 --- a/frontend/menu/menu_entries_cbs.c +++ b/frontend/menu/menu_entries_cbs.c @@ -1325,6 +1325,51 @@ static int deferred_push_core_list(void *data, void *userdata, return 0; } +static int deferred_push_history_list(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + unsigned i; + size_t list_size = 0; + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list || !driver.menu) + return -1; + + file_list_clear(list); + list_size = content_playlist_size(g_defaults.history); + + for (i = 0; i < list_size; i++) + { + char fill_buf[PATH_MAX]; + const char *core_name = NULL; + + content_playlist_get_index(g_defaults.history, i, + &path, NULL, &core_name); + strlcpy(fill_buf, core_name, sizeof(fill_buf)); + + if (path) + { + char path_short[PATH_MAX]; + fill_short_pathname_representation(path_short,path,sizeof(path_short)); + snprintf(fill_buf,sizeof(fill_buf),"%s (%s)", + path_short,core_name); + } + + file_list_push(list, fill_buf, "", + MENU_FILE_PLAYLIST_ENTRY, 0); + } + + driver.menu->scroll_indices_size = 0; + menu_build_scroll_indices(list); + entries_refresh(list); + + if (driver.menu_ctx && driver.menu_ctx->populate_entries) + driver.menu_ctx->populate_entries(driver.menu, path, label, type); + + return 0; +} + static int deferred_push_configurations(void *data, void *userdata, const char *path, const char *label, unsigned type) { @@ -1715,6 +1760,8 @@ static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs, if (!strcmp(label, "core_list")) cbs->action_deferred_push = deferred_push_core_list; + if (!strcmp(label, "history_list")) + cbs->action_deferred_push = deferred_push_history_list; else if (!strcmp(label, "configurations")) cbs->action_deferred_push = deferred_push_configurations; else if (!strcmp(label, "video_shader_preset"))