From 0e87a3b86a865f897086a3bc6e31f61a6c8f5f64 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Feb 2015 22:39:42 +0100 Subject: [PATCH 001/147] database_info_list_new - cleanups --- database_info.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/database_info.c b/database_info.c index 1ad464873b..5bff7341b8 100644 --- a/database_info.c +++ b/database_info.c @@ -123,7 +123,8 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q libretrodb_t db; libretrodb_cursor_t cur; struct rmsgpack_dom_value item; - size_t i = 0, j; + size_t j; + unsigned k = 0; database_info_t *database_info = NULL; database_info_list_t *database_info_list = NULL; @@ -142,12 +143,15 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q if (item.type != RDT_MAP) continue; - database_info = (database_info_t*)realloc(database_info, (i+1) * sizeof(database_info_t)); + database_info = (database_info_t*)realloc(database_info, (k+1) * sizeof(database_info_t)); if (!database_info) goto error; - db_info = &database_info[i]; + db_info = &database_info[k]; + + if (!db_info) + continue; db_info->name = NULL; db_info->description = NULL; @@ -284,11 +288,11 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q db_info->md5 = strdup(md5); } } - i++; + k++; } database_info_list->list = database_info; - database_info_list->count = i; + database_info_list->count = k; return database_info_list; From 8869ffdd57835b6be9f514ee28b4fc74756dd32c Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 10 Feb 2015 23:11:20 +0100 Subject: [PATCH 002/147] (XMB) Remove unused variables --- menu/drivers/xmb.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 30fe093ce1..a5ff89d15f 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -537,7 +537,6 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) for (i = 0; i < file_list_get_size(list); i++) { - float iy = 0; xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); if (!xmb) @@ -1506,7 +1505,6 @@ static void xmb_navigation_ascend_alphabet(void *data, size_t *unused) static void xmb_list_insert(void *data, const char *path, const char *unused, size_t list_size) { - float iy; int current = 0, i = list_size; xmb_node_t *node = NULL; xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; From affce9a7cf1e48b0c635a52f1d6c7b52afdb4e37 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Feb 2015 23:14:01 +0100 Subject: [PATCH 003/147] Make xmb_font_init_first a bit more safe for threaded video mode --- menu/drivers/xmb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index a5ff89d15f..20650098e7 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1288,6 +1288,10 @@ static bool xmb_font_init_first(const gl_font_renderer_t **font_driver, && !g_extern.system.hw_render_callback.context_type) { thread_video_t *thr = (thread_video_t*)driver.video_data; + + if (!thr) + return false; + thr->cmd_data.font_init.method = gl_font_init_first; thr->cmd_data.font_init.font_driver = font_driver; thr->cmd_data.font_init.font_handle = font_handle; From ca36923c998673f65dddcbe7870ae8f1e66596b3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Feb 2015 23:17:19 +0100 Subject: [PATCH 004/147] (XMB) Some cleanups --- menu/drivers/xmb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 20650098e7..b2fe940e40 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -605,6 +605,9 @@ static GLuint xmb_png_texture_load_(const char * file_name) static int xmb_png_texture_load_wrap(void *data) { const char *filename = (const char*)data; + + if (!filename) + return 0; return xmb_png_texture_load_(filename); } @@ -614,6 +617,10 @@ static GLuint xmb_png_texture_load(const char* file_name) && !g_extern.system.hw_render_callback.context_type) { thread_video_t *thr = (thread_video_t*)driver.video_data; + + if (!thr) + return 0; + thr->cmd_data.custom_command.method = xmb_png_texture_load_wrap; thr->cmd_data.custom_command.data = (void*)file_name; thr->send_cmd_func(thr, CMD_CUSTOM_COMMAND); @@ -1276,7 +1283,7 @@ static void xmb_free(void *data) { menu_handle_t *menu = (menu_handle_t*)data; - if (menu->userdata) + if (menu && menu->userdata) free(menu->userdata); } From 8b5699d2d5369fea423435cbff9dff2168729acb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Feb 2015 23:26:21 +0100 Subject: [PATCH 005/147] Cleanups --- menu/menu_entries.c | 6 ++++++ menu/menu_entries_cbs.c | 2 ++ menu/menu_input.c | 29 ++++++++++++++++++++++++----- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 6d99f910bc..b6af0ca9ee 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -63,6 +63,9 @@ int menu_entries_push_query(libretrodb_t *db, { struct rmsgpack_dom_value *key = &item.map.items[i].key; struct rmsgpack_dom_value *val = &item.map.items[i].value; + + if (!key || !val) + continue; if (!strcmp(key->string.buff, "name")) { @@ -143,6 +146,9 @@ static void menu_entries_content_list_push( for (j = 0; j < str_list->size; j++) { const char *name = str_list->elems[j].data; + + if (!name) + continue; if (str_list->elems[j].attr.i == RARCH_DIRECTORY) menu_entries_content_list_push(list, info, name); diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index f6725c08e5..20f9b8b08c 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -294,8 +294,10 @@ static int action_ok_shader_pass_load(const char *path, const char *label, unsigned type, size_t idx) { const char *menu_path = NULL; + if (!driver.menu) return -1; + (void)menu_path; #ifdef HAVE_SHADER_MANAGER diff --git a/menu/menu_input.c b/menu/menu_input.c index 4cc18e9dc3..622186d6ae 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -69,6 +69,9 @@ static void menu_input_search_callback(void *userdata, const char *str) size_t idx; menu_handle_t *menu = (menu_handle_t*)userdata; + if (!menu) + return; + if (str && *str && file_list_search(menu->menu_list->selection_buf, str, &idx)) menu_navigation_set(menu, idx, true); @@ -78,15 +81,19 @@ static void menu_input_search_callback(void *userdata, const char *str) void menu_input_st_uint_callback(void *userdata, const char *str) { menu_handle_t *menu = (menu_handle_t*)userdata; - rarch_setting_t *current_setting = NULL; + + if (!menu) + return; if (str && *str) { + rarch_setting_t *current_setting = NULL; if ((current_setting = (rarch_setting_t*) setting_data_find_setting( menu->list_settings, menu->keyboard.label_setting))) *current_setting->value.unsigned_integer = strtoul(str, NULL, 0); } + menu_input_key_end_line(menu); } @@ -94,10 +101,14 @@ void menu_input_st_uint_callback(void *userdata, const char *str) void menu_input_st_string_callback(void *userdata, const char *str) { menu_handle_t *menu = (menu_handle_t*)userdata; - rarch_setting_t *current_setting = NULL; + + if (!menu) + return; if (str && *str) { + rarch_setting_t *current_setting = NULL; + if ((current_setting = (rarch_setting_t*) setting_data_find_setting( menu->list_settings, menu->keyboard.label_setting))) @@ -118,8 +129,11 @@ void menu_input_st_string_callback(void *userdata, const char *str) void menu_input_st_cheat_callback(void *userdata, const char *str) { - menu_handle_t *menu = (menu_handle_t*)userdata; cheat_manager_t *cheat = g_extern.cheat; + menu_handle_t *menu = (menu_handle_t*)userdata; + + if (!menu) + return; if (cheat && str && *str) { @@ -333,14 +347,19 @@ bool menu_input_custom_bind_keyboard_cb(void *data, unsigned code) menu->binds.timeout_end = rarch_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; - return menu->binds.begin <= menu->binds.last; + return (menu->binds.begin <= menu->binds.last); } int menu_input_bind_iterate(void *data) { char msg[PATH_MAX_LENGTH]; + struct menu_bind_state binds; menu_handle_t *menu = (menu_handle_t*)data; - struct menu_bind_state binds = menu->binds; + + if (!menu) + return 1; + + binds = menu->binds; if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) From e6ab59bce222231bade8459dac1ef3836a5c0b02 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Feb 2015 23:35:22 +0100 Subject: [PATCH 006/147] Refactor update_tweens --- menu/drivers/xmb.c | 2 +- menu/menu_animation.c | 5 ++--- menu/menu_animation.h | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index b2fe940e40..283ad72204 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1062,7 +1062,7 @@ static void xmb_frame(void) if (!xmb || !gl) return; - update_tweens(0.002); + update_tweens(driver.menu->tweens, 0.002); glViewport(0, 0, gl->win_width, gl->win_height); diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 7c95fbdded..3c8c56630c 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -93,14 +93,13 @@ static int iterate_tween(tween_t *tween, float dt, return 0; } -void update_tweens(float dt) +void update_tweens(tween_t *tweens, float dt) { unsigned i; unsigned active_tweens = 0; - tween_t *tween = &driver.menu->tweens[0]; for(i = 0; i < driver.menu->numtweens; i++) - iterate_tween(tween++, dt, &active_tweens); + iterate_tween(&tweens[i], dt, &active_tweens); if (!active_tweens) driver.menu->numtweens = 0; diff --git a/menu/menu_animation.h b/menu/menu_animation.h index fdc2e5cc11..743050db2c 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -43,7 +43,7 @@ typedef struct bool add_tween(float duration, float target_value, float* subject, easingFunc easing, tween_cb cb); -void update_tweens(float dt); +void update_tweens(tween_t *tweens, float dt); /* from https://github.com/kikito/tween.lua/blob/master/tween.lua */ From 9a6e99e12c8d273f3d58dfd4322f5b50fc4c05a4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Feb 2015 23:40:58 +0100 Subject: [PATCH 007/147] Cleanup add_tween --- menu/menu_animation.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 3c8c56630c..6c4334f96d 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -18,7 +18,7 @@ #include "../driver.h" #include -static void tween_free(tween_t *tween) +void tweens_free(tween_t *tween) { if (tween) free(tween); @@ -37,10 +37,7 @@ bool add_tween(float duration, float target_value, float* subject, (driver.menu->numtweens + 1) * sizeof(tween_t)); if (!temp_tweens) - { - tween_free(driver.menu->tweens); return false; - } driver.menu->tweens = temp_tweens; tween = (tween_t*)&driver.menu->tweens[driver.menu->numtweens]; From 453e5b768154fa2e8ffc12ac97c7bd00d341ea3c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Feb 2015 23:45:14 +0100 Subject: [PATCH 008/147] Rename tween functions --- menu/drivers/xmb.c | 52 +++++++++++++++++++++---------------------- menu/menu_animation.c | 9 ++++---- menu/menu_animation.h | 4 ++-- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 283ad72204..c13f4843cc 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -493,10 +493,10 @@ static void xmb_selection_pointer_changed(void) iz = xmb->i_active_zoom; } - add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - add_tween(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); - add_tween(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL); - add_tween(XMB_DELAY, iy, &node->y, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL); + tweens_push(XMB_DELAY, iy, &node->y, &inOutQuad, NULL); } } @@ -521,9 +521,9 @@ static void xmb_list_open_old(file_list_t *list, int dir, size_t current) if (dir == -1) ia = 0; - add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - add_tween(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL); - add_tween(XMB_DELAY, xmb->icon_size*dir*-2, &node->x, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, xmb->icon_size*dir*-2, &node->x, &inOutQuad, NULL); } } @@ -567,9 +567,9 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) if (i == current) ia = xmb->i_active_alpha; - add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - add_tween(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); - add_tween(XMB_DELAY, 0, &node->x, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, 0, &node->x, &inOutQuad, NULL); } xmb->old_depth = xmb->depth; @@ -699,9 +699,9 @@ static void xmb_list_switch_old(file_list_t *list, int dir, size_t current) if (!xmb) continue; - add_tween(XMB_DELAY, 0, &node->alpha, &inOutQuad, NULL); - add_tween(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL); - add_tween(XMB_DELAY, -xmb->hspacing*dir, &node->x, &inOutQuad, NULL); + tweens_push(XMB_DELAY, 0, &node->alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, -xmb->hspacing*dir, &node->x, &inOutQuad, NULL); } } @@ -729,9 +729,9 @@ static void xmb_list_switch_new(file_list_t *list, int dir, size_t current) if (i == current) ia = 1.0; - add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - add_tween(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); - add_tween(XMB_DELAY, 0, &node->x, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, 0, &node->x, &inOutQuad, NULL); } } @@ -795,11 +795,11 @@ static void xmb_list_open(void) iz = xmb->c_active_zoom; } - add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - add_tween(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL); } - add_tween(XMB_DELAY, xmb->hspacing * -(float)driver.menu->cat_selection_ptr, + tweens_push(XMB_DELAY, xmb->hspacing * -(float)driver.menu->cat_selection_ptr, &xmb->categories_x, &inOutQuad, NULL); dir = -1; @@ -840,7 +840,7 @@ static void xmb_list_switch(void) else if (xmb->depth <= 1) ia = xmb->c_passive_alpha; - add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); } xmb_list_open_old(xmb->selection_buf_old, dir, xmb->selection_ptr_old); @@ -849,12 +849,12 @@ static void xmb_list_switch(void) switch (xmb->depth) { case 1: - add_tween(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL); - add_tween(XMB_DELAY, 0, &xmb->arrow_alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL); + tweens_push(XMB_DELAY, 0, &xmb->arrow_alpha, &inOutQuad, NULL); break; case 2: - add_tween(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL); - add_tween(XMB_DELAY, 1, &xmb->arrow_alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL); + tweens_push(XMB_DELAY, 1, &xmb->arrow_alpha, &inOutQuad, NULL); break; } @@ -1062,7 +1062,7 @@ static void xmb_frame(void) if (!xmb || !gl) return; - update_tweens(driver.menu->tweens, 0.002); + tweens_update(driver.menu->tweens, 0.002); glViewport(0, 0, gl->win_width, gl->win_height); @@ -1670,7 +1670,7 @@ static void xmb_toggle(bool menu_on) return; } - add_tween(XMB_DELAY, 1.0f, &xmb->alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, 1.0f, &xmb->alpha, &inOutQuad, NULL); xmb->prevent_populate = !menu->need_refresh; diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 6c4334f96d..f465eb8412 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -22,10 +22,9 @@ void tweens_free(tween_t *tween) { if (tween) free(tween); - tween = NULL; } -bool add_tween(float duration, float target_value, float* subject, +bool tweens_push(float duration, float target_value, float* subject, easingFunc easing, tween_cb cb) { tween_t *tween = NULL, *temp_tweens = NULL; @@ -59,7 +58,7 @@ bool add_tween(float duration, float target_value, float* subject, return true; } -static int iterate_tween(tween_t *tween, float dt, +static int tweens_iterate(tween_t *tween, float dt, unsigned *active_tweens) { if (!tween) @@ -90,13 +89,13 @@ static int iterate_tween(tween_t *tween, float dt, return 0; } -void update_tweens(tween_t *tweens, float dt) +void tweens_update(tween_t *tweens, float dt) { unsigned i; unsigned active_tweens = 0; for(i = 0; i < driver.menu->numtweens; i++) - iterate_tween(&tweens[i], dt, &active_tweens); + tweens_iterate(&tweens[i], dt, &active_tweens); if (!active_tweens) driver.menu->numtweens = 0; diff --git a/menu/menu_animation.h b/menu/menu_animation.h index 743050db2c..f346aa1e8a 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -40,10 +40,10 @@ typedef struct tween_cb cb; } tween_t; -bool add_tween(float duration, float target_value, float* subject, +bool tweens_push(float duration, float target_value, float* subject, easingFunc easing, tween_cb cb); -void update_tweens(tween_t *tweens, float dt); +void tweens_update(tween_t *tweens, float dt); /* from https://github.com/kikito/tween.lua/blob/master/tween.lua */ From 9a839fce2f2ed0387e4fc04a1fb031ce228338a6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Feb 2015 23:49:26 +0100 Subject: [PATCH 009/147] Pass numtweens as pointer --- menu/drivers/xmb.c | 52 +++++++++++++++++++++---------------------- menu/menu_animation.c | 15 +++++++------ menu/menu_animation.h | 4 ++-- 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c13f4843cc..e847c1a11f 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -493,10 +493,10 @@ static void xmb_selection_pointer_changed(void) iz = xmb->i_active_zoom; } - tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); - tweens_push(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL); - tweens_push(XMB_DELAY, iy, &node->y, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, iy, &node->y, &inOutQuad, NULL, &driver.menu->numtweens); } } @@ -521,9 +521,9 @@ static void xmb_list_open_old(file_list_t *list, int dir, size_t current) if (dir == -1) ia = 0; - tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - tweens_push(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL); - tweens_push(XMB_DELAY, xmb->icon_size*dir*-2, &node->x, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, xmb->icon_size*dir*-2, &node->x, &inOutQuad, NULL, &driver.menu->numtweens); } } @@ -567,9 +567,9 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) if (i == current) ia = xmb->i_active_alpha; - tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); - tweens_push(XMB_DELAY, 0, &node->x, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, 0, &node->x, &inOutQuad, NULL, &driver.menu->numtweens); } xmb->old_depth = xmb->depth; @@ -699,9 +699,9 @@ static void xmb_list_switch_old(file_list_t *list, int dir, size_t current) if (!xmb) continue; - tweens_push(XMB_DELAY, 0, &node->alpha, &inOutQuad, NULL); - tweens_push(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL); - tweens_push(XMB_DELAY, -xmb->hspacing*dir, &node->x, &inOutQuad, NULL); + tweens_push(XMB_DELAY, 0, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, -xmb->hspacing*dir, &node->x, &inOutQuad, NULL, &driver.menu->numtweens); } } @@ -729,9 +729,9 @@ static void xmb_list_switch_new(file_list_t *list, int dir, size_t current) if (i == current) ia = 1.0; - tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); - tweens_push(XMB_DELAY, 0, &node->x, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, 0, &node->x, &inOutQuad, NULL, &driver.menu->numtweens); } } @@ -795,12 +795,12 @@ static void xmb_list_open(void) iz = xmb->c_active_zoom; } - tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - tweens_push(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL, &driver.menu->numtweens); } tweens_push(XMB_DELAY, xmb->hspacing * -(float)driver.menu->cat_selection_ptr, - &xmb->categories_x, &inOutQuad, NULL); + &xmb->categories_x, &inOutQuad, NULL, &driver.menu->numtweens); dir = -1; if (driver.menu->cat_selection_ptr > xmb->cat_selection_ptr_old) @@ -840,7 +840,7 @@ static void xmb_list_switch(void) else if (xmb->depth <= 1) ia = xmb->c_passive_alpha; - tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); } xmb_list_open_old(xmb->selection_buf_old, dir, xmb->selection_ptr_old); @@ -849,12 +849,12 @@ static void xmb_list_switch(void) switch (xmb->depth) { case 1: - tweens_push(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL); - tweens_push(XMB_DELAY, 0, &xmb->arrow_alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, 0, &xmb->arrow_alpha, &inOutQuad, NULL, &driver.menu->numtweens); break; case 2: - tweens_push(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL); - tweens_push(XMB_DELAY, 1, &xmb->arrow_alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL, &driver.menu->numtweens); + tweens_push(XMB_DELAY, 1, &xmb->arrow_alpha, &inOutQuad, NULL, &driver.menu->numtweens); break; } @@ -1062,7 +1062,7 @@ static void xmb_frame(void) if (!xmb || !gl) return; - tweens_update(driver.menu->tweens, 0.002); + tweens_update(driver.menu->tweens, 0.002, &driver.menu->numtweens); glViewport(0, 0, gl->win_width, gl->win_height); @@ -1670,7 +1670,7 @@ static void xmb_toggle(bool menu_on) return; } - tweens_push(XMB_DELAY, 1.0f, &xmb->alpha, &inOutQuad, NULL); + tweens_push(XMB_DELAY, 1.0f, &xmb->alpha, &inOutQuad, NULL, &driver.menu->numtweens); xmb->prevent_populate = !menu->need_refresh; diff --git a/menu/menu_animation.c b/menu/menu_animation.c index f465eb8412..d1fbcfb7b6 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -25,7 +25,7 @@ void tweens_free(tween_t *tween) } bool tweens_push(float duration, float target_value, float* subject, - easingFunc easing, tween_cb cb) + easingFunc easing, tween_cb cb, unsigned *numtweens) { tween_t *tween = NULL, *temp_tweens = NULL; @@ -33,13 +33,13 @@ bool tweens_push(float duration, float target_value, float* subject, return false; temp_tweens = (tween_t*)realloc(driver.menu->tweens, - (driver.menu->numtweens + 1) * sizeof(tween_t)); + (*numtweens + 1) * sizeof(tween_t)); if (!temp_tweens) return false; driver.menu->tweens = temp_tweens; - tween = (tween_t*)&driver.menu->tweens[driver.menu->numtweens]; + tween = (tween_t*)&driver.menu->tweens[*numtweens]; if (!tween) return false; @@ -53,7 +53,7 @@ bool tweens_push(float duration, float target_value, float* subject, tween->easing = easing; tween->cb = cb; - driver.menu->numtweens++; + *numtweens = *numtweens + 1; return true; } @@ -89,16 +89,17 @@ static int tweens_iterate(tween_t *tween, float dt, return 0; } -void tweens_update(tween_t *tweens, float dt) +void tweens_update(tween_t *tweens, float dt, + unsigned *numtweens) { unsigned i; unsigned active_tweens = 0; - for(i = 0; i < driver.menu->numtweens; i++) + for(i = 0; i < *numtweens; i++) tweens_iterate(&tweens[i], dt, &active_tweens); if (!active_tweens) - driver.menu->numtweens = 0; + *numtweens = 0; } /* Linear */ diff --git a/menu/menu_animation.h b/menu/menu_animation.h index f346aa1e8a..7f268035a5 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -41,9 +41,9 @@ typedef struct } tween_t; bool tweens_push(float duration, float target_value, float* subject, - easingFunc easing, tween_cb cb); + easingFunc easing, tween_cb cb, unsigned *numtweens); -void tweens_update(tween_t *tweens, float dt); +void tweens_update(tween_t *tweens, float dt, unsigned *numtweens); /* from https://github.com/kikito/tween.lua/blob/master/tween.lua */ From 13a87d48fe87ddd643d1fd264fbc7ec8e567d2d5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 Feb 2015 23:59:16 +0100 Subject: [PATCH 010/147] Refactor tweens_push --- menu/menu_animation.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/menu/menu_animation.c b/menu/menu_animation.c index d1fbcfb7b6..2cb31058e9 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -27,33 +27,38 @@ void tweens_free(tween_t *tween) bool tweens_push(float duration, float target_value, float* subject, easingFunc easing, tween_cb cb, unsigned *numtweens) { - tween_t *tween = NULL, *temp_tweens = NULL; + size_t cap; + tween_t *temp_tweens = NULL; if (!driver.menu) return false; + + cap = *numtweens; temp_tweens = (tween_t*)realloc(driver.menu->tweens, - (*numtweens + 1) * sizeof(tween_t)); + (cap + 1) * sizeof(tween_t)); if (!temp_tweens) + { + tweens_free(driver.menu->tweens); return false; + } driver.menu->tweens = temp_tweens; - tween = (tween_t*)&driver.menu->tweens[*numtweens]; - if (!tween) + if (!driver.menu->tweens) return false; - tween->alive = 1; - tween->duration = duration; - tween->running_since = 0; - tween->initial_value = *subject; - tween->target_value = target_value; - tween->subject = subject; - tween->easing = easing; - tween->cb = cb; + driver.menu->tweens[cap].alive = 1; + driver.menu->tweens[cap].duration = duration; + driver.menu->tweens[cap].running_since = 0; + driver.menu->tweens[cap].initial_value = *subject; + driver.menu->tweens[cap].target_value = target_value; + driver.menu->tweens[cap].subject = subject; + driver.menu->tweens[cap].easing = easing; + driver.menu->tweens[cap].cb = cb; - *numtweens = *numtweens + 1; + *numtweens = cap + 1; return true; } From 46003314a84e123558b4b9e5cec048663db2380e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 00:40:18 +0100 Subject: [PATCH 011/147] Refactor menu_animation.c --- menu/drivers/xmb.c | 61 +++++++++++++++++++++---------------- menu/menu.c | 12 ++++++++ menu/menu_animation.c | 71 ++++++++++++++++++++----------------------- menu/menu_animation.h | 20 +++++++++--- menu/menu_driver.h | 3 +- 5 files changed, 95 insertions(+), 72 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index e847c1a11f..ed4e919521 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -493,10 +493,10 @@ static void xmb_selection_pointer_changed(void) iz = xmb->i_active_zoom; } - tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, iy, &node->y, &inOutQuad, NULL, &driver.menu->numtweens); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, iy, &node->y, &inOutQuad, NULL); } } @@ -521,9 +521,9 @@ static void xmb_list_open_old(file_list_t *list, int dir, size_t current) if (dir == -1) ia = 0; - tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, xmb->icon_size*dir*-2, &node->x, &inOutQuad, NULL, &driver.menu->numtweens); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, xmb->icon_size*dir*-2, &node->x, &inOutQuad, NULL); } } @@ -567,9 +567,9 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) if (i == current) ia = xmb->i_active_alpha; - tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, 0, &node->x, &inOutQuad, NULL, &driver.menu->numtweens); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->x, &inOutQuad, NULL); } xmb->old_depth = xmb->depth; @@ -699,9 +699,9 @@ static void xmb_list_switch_old(file_list_t *list, int dir, size_t current) if (!xmb) continue; - tweens_push(XMB_DELAY, 0, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, -xmb->hspacing*dir, &node->x, &inOutQuad, NULL, &driver.menu->numtweens); + menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->alpha, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, -xmb->hspacing*dir, &node->x, &inOutQuad, NULL); } } @@ -729,9 +729,9 @@ static void xmb_list_switch_new(file_list_t *list, int dir, size_t current) if (i == current) ia = 1.0; - tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, 0, &node->x, &inOutQuad, NULL, &driver.menu->numtweens); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->x, &inOutQuad, NULL); } } @@ -795,12 +795,13 @@ static void xmb_list_open(void) iz = xmb->c_active_zoom; } - tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL, &driver.menu->numtweens); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL); } - tweens_push(XMB_DELAY, xmb->hspacing * -(float)driver.menu->cat_selection_ptr, - &xmb->categories_x, &inOutQuad, NULL, &driver.menu->numtweens); + menu_animation_push(driver.menu->animation, XMB_DELAY, + xmb->hspacing * -(float)driver.menu->cat_selection_ptr, + &xmb->categories_x, &inOutQuad, NULL); dir = -1; if (driver.menu->cat_selection_ptr > xmb->cat_selection_ptr_old) @@ -840,7 +841,8 @@ static void xmb_list_switch(void) else if (xmb->depth <= 1) ia = xmb->c_passive_alpha; - tweens_push(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL, &driver.menu->numtweens); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, + &node->alpha, &inOutQuad, NULL); } xmb_list_open_old(xmb->selection_buf_old, dir, xmb->selection_ptr_old); @@ -849,12 +851,16 @@ static void xmb_list_switch(void) switch (xmb->depth) { case 1: - tweens_push(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, 0, &xmb->arrow_alpha, &inOutQuad, NULL, &driver.menu->numtweens); + menu_animation_push(driver.menu->animation, XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), + &xmb->x, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &xmb->arrow_alpha, + &inOutQuad, NULL); break; case 2: - tweens_push(XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL, &driver.menu->numtweens); - tweens_push(XMB_DELAY, 1, &xmb->arrow_alpha, &inOutQuad, NULL, &driver.menu->numtweens); + menu_animation_push(driver.menu->animation, XMB_DELAY, + xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, 1, &xmb->arrow_alpha, + &inOutQuad, NULL); break; } @@ -1062,7 +1068,7 @@ static void xmb_frame(void) if (!xmb || !gl) return; - tweens_update(driver.menu->tweens, 0.002, &driver.menu->numtweens); + menu_animation_update(driver.menu->animation, 0.002); glViewport(0, 0, gl->win_width, gl->win_height); @@ -1670,7 +1676,8 @@ static void xmb_toggle(bool menu_on) return; } - tweens_push(XMB_DELAY, 1.0f, &xmb->alpha, &inOutQuad, NULL, &driver.menu->numtweens); + menu_animation_push(driver.menu->animation, XMB_DELAY, 1.0f, + &xmb->alpha, &inOutQuad, NULL); xmb->prevent_populate = !menu->need_refresh; diff --git a/menu/menu.c b/menu/menu.c index 9c420663aa..e92ed670e1 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -15,6 +15,7 @@ */ #include "menu.h" +#include "menu_animation.h" #include "menu_entries.h" #include "menu_shader.h" #include "../dynamic.h" @@ -196,6 +197,14 @@ void *menu_init(const void *data) menu_shader_manager_init(menu); + menu->animation = (animation_t*)calloc(1, sizeof(animation_t)); + + if (!menu->animation) + { + free(menu); + return NULL; + } + return menu; } @@ -245,6 +254,9 @@ void menu_free(void *data) libretro_free_system_info(&g_extern.menu.info); #endif + menu_animation_free(menu->animation); + menu->animation = NULL; + menu_list_free(menu->menu_list); menu->menu_list = NULL; diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 2cb31058e9..a9cf55ade3 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -18,52 +18,48 @@ #include "../driver.h" #include -void tweens_free(tween_t *tween) +void menu_animation_free(animation_t *animation) { - if (tween) - free(tween); -} + size_t i; -bool tweens_push(float duration, float target_value, float* subject, - easingFunc easing, tween_cb cb, unsigned *numtweens) -{ - size_t cap; - tween_t *temp_tweens = NULL; + if (!animation) + return; - if (!driver.menu) - return false; - - cap = *numtweens; - - temp_tweens = (tween_t*)realloc(driver.menu->tweens, - (cap + 1) * sizeof(tween_t)); - - if (!temp_tweens) + for (i = 0; i < animation->size; i++) { - tweens_free(driver.menu->tweens); - return false; + free(animation->list[i].subject); } - driver.menu->tweens = temp_tweens; + free(animation->list); + free(animation); +} - if (!driver.menu->tweens) - return false; +bool menu_animation_push(animation_t *animation, + float duration, float target_value, float* subject, + easingFunc easing, tween_cb cb) +{ + if (animation->size >= animation->capacity) + { + animation->capacity++; + animation->list = (struct tween*)realloc(animation->list, + animation->capacity * sizeof(struct tween)); + } - driver.menu->tweens[cap].alive = 1; - driver.menu->tweens[cap].duration = duration; - driver.menu->tweens[cap].running_since = 0; - driver.menu->tweens[cap].initial_value = *subject; - driver.menu->tweens[cap].target_value = target_value; - driver.menu->tweens[cap].subject = subject; - driver.menu->tweens[cap].easing = easing; - driver.menu->tweens[cap].cb = cb; + animation->list[animation->size].alive = 1; + animation->list[animation->size].duration = duration; + animation->list[animation->size].running_since = 0; + animation->list[animation->size].initial_value = *subject; + animation->list[animation->size].target_value = target_value; + animation->list[animation->size].subject = subject; + animation->list[animation->size].easing = easing; + animation->list[animation->size].cb = cb; - *numtweens = cap + 1; + animation->size++; return true; } -static int tweens_iterate(tween_t *tween, float dt, +static int menu_animation_iterate(struct tween *tween, float dt, unsigned *active_tweens) { if (!tween) @@ -94,17 +90,16 @@ static int tweens_iterate(tween_t *tween, float dt, return 0; } -void tweens_update(tween_t *tweens, float dt, - unsigned *numtweens) +void menu_animation_update(animation_t *animation, float dt) { unsigned i; unsigned active_tweens = 0; - for(i = 0; i < *numtweens; i++) - tweens_iterate(&tweens[i], dt, &active_tweens); + for(i = 0; i < animation->size; i++) + menu_animation_iterate(&animation->list[i], dt, &active_tweens); if (!active_tweens) - *numtweens = 0; + animation->size = 0; } /* Linear */ diff --git a/menu/menu_animation.h b/menu/menu_animation.h index 7f268035a5..e2b15c8e08 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -28,7 +28,7 @@ extern "C" { typedef float (*easingFunc)(float, float, float, float); typedef void (*tween_cb) (void); -typedef struct +struct tween { int alive; float duration; @@ -38,12 +38,22 @@ typedef struct float* subject; easingFunc easing; tween_cb cb; -} tween_t; +}; -bool tweens_push(float duration, float target_value, float* subject, - easingFunc easing, tween_cb cb, unsigned *numtweens); +typedef struct animation +{ + struct tween *list; -void tweens_update(tween_t *tweens, float dt, unsigned *numtweens); + size_t capacity; + size_t size; +} animation_t; + +void menu_animation_free(animation_t *animation); + +bool menu_animation_push(animation_t *animation, float duration, float target_value, float* subject, + easingFunc easing, tween_cb cb); + +void menu_animation_update(animation_t *animation, float dt); /* from https://github.com/kikito/tween.lua/blob/master/tween.lua */ diff --git a/menu/menu_driver.h b/menu/menu_driver.h index de3c171c47..1afe089026 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -142,8 +142,7 @@ typedef struct } keyboard; rarch_setting_t *list_settings; - tween_t* tweens; - unsigned numtweens; + animation_t *animation; content_playlist_t *db_playlist; char db_playlist_file[PATH_MAX_LENGTH]; From a85908c8f920a1e859e72cec80cc61a098de7dbe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 01:15:16 +0100 Subject: [PATCH 012/147] (Menu) Refactor easing functions --- menu/drivers/xmb.c | 50 ++-- menu/menu_animation.c | 588 ++++++++++++++++++++++++------------------ menu/menu_animation.h | 119 ++++----- 3 files changed, 417 insertions(+), 340 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index ed4e919521..2dc04341fb 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -493,10 +493,10 @@ static void xmb_selection_pointer_changed(void) iz = xmb->i_active_zoom; } - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, iy, &node->y, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, iz, &node->zoom, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, iy, &node->y, EASING_IN_OUT_QUAD, NULL); } } @@ -521,9 +521,9 @@ static void xmb_list_open_old(file_list_t *list, int dir, size_t current) if (dir == -1) ia = 0; - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, xmb->icon_size*dir*-2, &node->x, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, xmb->icon_size*dir*-2, &node->x, EASING_IN_OUT_QUAD, NULL); } } @@ -567,9 +567,9 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) if (i == current) ia = xmb->i_active_alpha; - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->x, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->x, EASING_IN_OUT_QUAD, NULL); } xmb->old_depth = xmb->depth; @@ -699,9 +699,9 @@ static void xmb_list_switch_old(file_list_t *list, int dir, size_t current) if (!xmb) continue; - menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->alpha, &inOutQuad, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, -xmb->hspacing*dir, &node->x, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, -xmb->hspacing*dir, &node->x, EASING_IN_OUT_QUAD, NULL); } } @@ -729,9 +729,9 @@ static void xmb_list_switch_new(file_list_t *list, int dir, size_t current) if (i == current) ia = 1.0; - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->x, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->x, EASING_IN_OUT_QUAD, NULL); } } @@ -795,13 +795,13 @@ static void xmb_list_open(void) iz = xmb->c_active_zoom; } - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(driver.menu->animation, XMB_DELAY, iz, &node->zoom, EASING_IN_OUT_QUAD, NULL); } menu_animation_push(driver.menu->animation, XMB_DELAY, xmb->hspacing * -(float)driver.menu->cat_selection_ptr, - &xmb->categories_x, &inOutQuad, NULL); + &xmb->categories_x, EASING_IN_OUT_QUAD, NULL); dir = -1; if (driver.menu->cat_selection_ptr > xmb->cat_selection_ptr_old) @@ -842,7 +842,7 @@ static void xmb_list_switch(void) ia = xmb->c_passive_alpha; menu_animation_push(driver.menu->animation, XMB_DELAY, ia, - &node->alpha, &inOutQuad, NULL); + &node->alpha, EASING_IN_OUT_QUAD, NULL); } xmb_list_open_old(xmb->selection_buf_old, dir, xmb->selection_ptr_old); @@ -852,15 +852,15 @@ static void xmb_list_switch(void) { case 1: menu_animation_push(driver.menu->animation, XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), - &xmb->x, &inOutQuad, NULL); + &xmb->x, EASING_IN_OUT_QUAD, NULL); menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &xmb->arrow_alpha, - &inOutQuad, NULL); + EASING_IN_OUT_QUAD, NULL); break; case 2: menu_animation_push(driver.menu->animation, XMB_DELAY, - xmb->icon_size*-(xmb->depth*2-2), &xmb->x, &inOutQuad, NULL); + xmb->icon_size*-(xmb->depth*2-2), &xmb->x, EASING_IN_OUT_QUAD, NULL); menu_animation_push(driver.menu->animation, XMB_DELAY, 1, &xmb->arrow_alpha, - &inOutQuad, NULL); + EASING_IN_OUT_QUAD, NULL); break; } @@ -1677,7 +1677,7 @@ static void xmb_toggle(bool menu_on) } menu_animation_push(driver.menu->animation, XMB_DELAY, 1.0f, - &xmb->alpha, &inOutQuad, NULL); + &xmb->alpha, EASING_IN_OUT_QUAD, NULL); xmb->prevent_populate = !menu->need_refresh; diff --git a/menu/menu_animation.c b/menu/menu_animation.c index a9cf55ade3..3dfbce14b9 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -18,6 +18,234 @@ #include "../driver.h" #include +/* from https://github.com/kikito/tween.lua/blob/master/tween.lua */ + +static float easing_linear(float t, float b, float c, float d) +{ + return c * t / d + b; +} + +static float easing_in_out_quad(float t, float b, float c, float d) +{ + t = t / d * 2; + if (t < 1) + return c / 2 * pow(t, 2) + b; + return -c / 2 * ((t - 1) * (t - 3) - 1) + b; +} + +static float easing_in_quad(float t, float b, float c, float d) +{ + return c * pow(t / d, 2) + b; +} + +static float easing_out_quad(float t, float b, float c, float d) +{ + t = t / d; + return -c * t * (t - 2) + b; +} + +static float easing_out_in_quad(float t, float b, float c, float d) +{ + if (t < d / 2) + return easing_out_quad(t * 2, b, c / 2, d); + return easing_in_quad((t * 2) - d, b + c / 2, c / 2, d); +} + +static float easing_in_cubic(float t, float b, float c, float d) +{ + return c * pow(t / d, 3) + b; +} + +static float easing_out_cubic(float t, float b, float c, float d) +{ + return c * (pow(t / d - 1, 3) + 1) + b; +} + +float easing_in_out_cubic(float t, float b, float c, float d) +{ + t = t / d * 2; + if (t < 1) + return c / 2 * t * t * t + b; + t = t - 2; + return c / 2 * (t * t * t + 2) + b; +} + +static float easing_out_in_cubic(float t, float b, float c, float d) +{ + if (t < d / 2) + return easing_out_cubic(t * 2, b, c / 2, d); + return easing_in_cubic((t * 2) - d, b + c / 2, c / 2, d); +} + +static float easing_in_quart(float t, float b, float c, float d) +{ + return c * pow(t / d, 4) + b; +} + +static float easing_out_quart(float t, float b, float c, float d) +{ + return -c * (pow(t / d - 1, 4) - 1) + b; +} + +static float easing_in_out_quart(float t, float b, float c, float d) +{ + t = t / d * 2; + if (t < 1) + return c / 2 * pow(t, 4) + b; + return -c / 2 * (pow(t - 2, 4) - 2) + b; +} + +static float easing_out_in_quart(float t, float b, float c, float d) +{ + if (t < d / 2) + return easing_out_quart(t * 2, b, c / 2, d); + return easing_in_quart((t * 2) - d, b + c / 2, c / 2, d); +} + +static float easing_in_quint(float t, float b, float c, float d) +{ + return c * pow(t / d, 5) + b; +} + +static float easing_out_quint(float t, float b, float c, float d) +{ + return c * (pow(t / d - 1, 5) + 1) + b; +} + +static float easing_in_out_quint(float t, float b, float c, float d) +{ + t = t / d * 2; + if (t < 1) + return c / 2 * pow(t, 5) + b; + return c / 2 * (pow(t - 2, 5) + 2) + b; +} + +static float easing_out_in_quint(float t, float b, float c, float d) +{ + if (t < d / 2) + return easing_out_quint(t * 2, b, c / 2, d); + return easing_in_quint((t * 2) - d, b + c / 2, c / 2, d); +} + +static float easing_in_sine(float t, float b, float c, float d) +{ + return -c * cos(t / d * (M_PI / 2)) + c + b; +} + +static float easing_out_sine(float t, float b, float c, float d) +{ + return c * sin(t / d * (M_PI / 2)) + b; +} + +static float easing_in_out_sine(float t, float b, float c, float d) +{ + return -c / 2 * (cos(M_PI * t / d) - 1) + b; +} + +static float easing_out_in_sine(float t, float b, float c, float d) +{ + if (t < d / 2) + return easing_out_sine(t * 2, b, c / 2, d); + return easing_in_sine((t * 2) -d, b + c / 2, c / 2, d); +} + +static float easing_in_expo(float t, float b, float c, float d) +{ + if (t == 0) + return b; + return c * powf(2, 10 * (t / d - 1)) + b - c * 0.001; +} + +static float easing_out_expo(float t, float b, float c, float d) +{ + if (t == d) + return b + c; + return c * 1.001 * (-powf(2, -10 * t / d) + 1) + b; +} + +static float easing_in_out_expo(float t, float b, float c, float d) +{ + if (t == 0) + return b; + if (t == d) + return b + c; + t = t / d * 2; + if (t < 1) + return c / 2 * powf(2, 10 * (t - 1)) + b - c * 0.0005; + return c / 2 * 1.0005 * (-powf(2, -10 * (t - 1)) + 2) + b; +} + +static float easing_out_in_expo(float t, float b, float c, float d) +{ + if (t < d / 2) + return easing_out_expo(t * 2, b, c / 2, d); + return easing_in_expo((t * 2) - d, b + c / 2, c / 2, d); +} + +static float easing_in_circ(float t, float b, float c, float d) +{ + return(-c * (sqrt(1 - powf(t / d, 2)) - 1) + b); +} + +static float easing_out_circ(float t, float b, float c, float d) +{ + return(c * sqrt(1 - powf(t / d - 1, 2)) + b); +} + +static float easing_in_out_circ(float t, float b, float c, float d) +{ + t = t / d * 2; + if (t < 1) + return -c / 2 * (sqrt(1 - t * t) - 1) + b; + t = t - 2; + return c / 2 * (sqrt(1 - t * t) + 1) + b; +} + +static float easing_out_in_circ(float t, float b, float c, float d) +{ + if (t < d / 2) + return easing_out_circ(t * 2, b, c / 2, d); + return easing_in_circ((t * 2) - d, b + c / 2, c / 2, d); +} + +static float easing_out_bounce(float t, float b, float c, float d) +{ + t = t / d; + if (t < 1 / 2.75) + return c * (7.5625 * t * t) + b; + if (t < 2 / 2.75) + { + t = t - (1.5 / 2.75); + return c * (7.5625 * t * t + 0.75) + b; + } + else if (t < 2.5 / 2.75) + { + t = t - (2.25 / 2.75); + return c * (7.5625 * t * t + 0.9375) + b; + } + t = t - (2.625 / 2.75); + return c * (7.5625 * t * t + 0.984375) + b; +} + +static float easing_in_bounce(float t, float b, float c, float d) +{ + return c - easing_out_bounce(d - t, 0, c, d) + b; +} + +static float easing_in_out_bounce(float t, float b, float c, float d) +{ + if (t < d / 2) + return easing_in_bounce(t * 2, 0, c, d) * 0.5 + b; + return easing_out_bounce(t * 2 - d, 0, c, d) * 0.5 + c * .5 + b; +} + +static float easing_out_in_bounce(float t, float b, float c, float d) +{ + if (t < d / 2) + return easing_out_bounce(t * 2, b, c / 2, d); + return easing_in_bounce((t * 2) - d, b + c / 2, c / 2, d); +} + void menu_animation_free(animation_t *animation) { size_t i; @@ -36,7 +264,7 @@ void menu_animation_free(animation_t *animation) bool menu_animation_push(animation_t *animation, float duration, float target_value, float* subject, - easingFunc easing, tween_cb cb) + enum animation_easing_type easing_enum, tween_cb cb) { if (animation->size >= animation->capacity) { @@ -51,9 +279,122 @@ bool menu_animation_push(animation_t *animation, animation->list[animation->size].initial_value = *subject; animation->list[animation->size].target_value = target_value; animation->list[animation->size].subject = subject; - animation->list[animation->size].easing = easing; animation->list[animation->size].cb = cb; + switch (easing_enum) + { + case EASING_LINEAR: + animation->list[animation->size].easing = &easing_linear; + break; + /* Quad */ + case EASING_IN_QUAD: + animation->list[animation->size].easing = &easing_in_quad; + break; + case EASING_OUT_QUAD: + animation->list[animation->size].easing = &easing_out_quad; + break; + case EASING_IN_OUT_QUAD: + animation->list[animation->size].easing = &easing_in_out_quad; + break; + case EASING_OUT_IN_QUAD: + animation->list[animation->size].easing = &easing_out_in_quad; + break; + /* Cubic */ + case EASING_IN_CUBIC: + animation->list[animation->size].easing = &easing_in_cubic; + break; + case EASING_OUT_CUBIC: + animation->list[animation->size].easing = &easing_out_cubic; + break; + case EASING_IN_OUT_CUBIC: + animation->list[animation->size].easing = &easing_in_out_cubic; + break; + case EASING_OUT_IN_CUBIC: + animation->list[animation->size].easing = &easing_out_in_cubic; + break; + /* Quart */ + case EASING_IN_QUART: + animation->list[animation->size].easing = &easing_in_quart; + break; + case EASING_OUT_QUART: + animation->list[animation->size].easing = &easing_out_quart; + break; + case EASING_IN_OUT_QUART: + animation->list[animation->size].easing = &easing_in_out_quart; + break; + case EASING_OUT_IN_QUART: + animation->list[animation->size].easing = &easing_out_in_quart; + break; + /* Quint */ + case EASING_IN_QUINT: + animation->list[animation->size].easing = &easing_in_quint; + break; + case EASING_OUT_QUINT: + animation->list[animation->size].easing = &easing_out_quint; + break; + case EASING_IN_OUT_QUINT: + animation->list[animation->size].easing = &easing_in_out_quint; + break; + case EASING_OUT_IN_QUINT: + animation->list[animation->size].easing = &easing_out_in_quint; + break; + /* Sine */ + case EASING_IN_SINE: + animation->list[animation->size].easing = &easing_in_sine; + break; + case EASING_OUT_SINE: + animation->list[animation->size].easing = &easing_out_sine; + break; + case EASING_IN_OUT_SINE: + animation->list[animation->size].easing = &easing_in_out_sine; + break; + case EASING_OUT_IN_SINE: + animation->list[animation->size].easing = &easing_out_in_sine; + break; + /* Expo */ + case EASING_IN_EXPO: + animation->list[animation->size].easing = &easing_in_expo; + break; + case EASING_OUT_EXPO: + animation->list[animation->size].easing = &easing_out_expo; + break; + case EASING_IN_OUT_EXPO: + animation->list[animation->size].easing = &easing_in_out_expo; + break; + case EASING_OUT_IN_EXPO: + animation->list[animation->size].easing = &easing_out_in_expo; + break; + /* Circ */ + case EASING_IN_CIRC: + animation->list[animation->size].easing = &easing_in_circ; + break; + case EASING_OUT_CIRC: + animation->list[animation->size].easing = &easing_out_circ; + break; + case EASING_IN_OUT_CIRC: + animation->list[animation->size].easing = &easing_in_out_circ; + break; + case EASING_OUT_IN_CIRC: + animation->list[animation->size].easing = &easing_out_in_circ; + break; + /* Bounce */ + case EASING_IN_BOUNCE: + animation->list[animation->size].easing = &easing_in_bounce; + break; + case EASING_OUT_BOUNCE: + animation->list[animation->size].easing = &easing_out_bounce; + break; + case EASING_IN_OUT_BOUNCE: + animation->list[animation->size].easing = &easing_in_out_bounce; + break; + case EASING_OUT_IN_BOUNCE: + animation->list[animation->size].easing = &easing_out_in_bounce; + break; + default: + animation->list[animation->size].easing = NULL; + break; + } + animation->size++; return true; @@ -102,246 +443,3 @@ void menu_animation_update(animation_t *animation, float dt) animation->size = 0; } -/* Linear */ - -float linear(float t, float b, float c, float d) -{ - return c * t / d + b; -} - -/* Quad */ - -float inQuad(float t, float b, float c, float d) -{ - return c * pow(t / d, 2) + b; -} - -float outQuad(float t, float b, float c, float d) -{ - t = t / d; - return -c * t * (t - 2) + b; -} - -float inOutQuad(float t, float b, float c, float d) -{ - t = t / d * 2; - if (t < 1) - return c / 2 * pow(t, 2) + b; - return -c / 2 * ((t - 1) * (t - 3) - 1) + b; -} - -float outInQuad(float t, float b, float c, float d) -{ - if (t < d / 2) - return outQuad(t * 2, b, c / 2, d); - return inQuad((t * 2) - d, b + c / 2, c / 2, d); -} - -/* Cubic */ - -float inCubic(float t, float b, float c, float d) -{ - return c * pow(t / d, 3) + b; -} - -float outCubic(float t, float b, float c, float d) -{ - return c * (pow(t / d - 1, 3) + 1) + b; -} - -float inOutCubic(float t, float b, float c, float d) -{ - t = t / d * 2; - if (t < 1) - return c / 2 * t * t * t + b; - t = t - 2; - return c / 2 * (t * t * t + 2) + b; -} - -float outInCubic(float t, float b, float c, float d) -{ - if (t < d / 2) - return outCubic(t * 2, b, c / 2, d); - return inCubic((t * 2) - d, b + c / 2, c / 2, d); -} - -/* Quart */ - -float inQuart(float t, float b, float c, float d) -{ - return c * pow(t / d, 4) + b; -} - -float outQuart(float t, float b, float c, float d) -{ - return -c * (pow(t / d - 1, 4) - 1) + b; -} - -float inOutQuart(float t, float b, float c, float d) -{ - t = t / d * 2; - if (t < 1) - return c / 2 * pow(t, 4) + b; - return -c / 2 * (pow(t - 2, 4) - 2) + b; -} - -float outInQuart(float t, float b, float c, float d) -{ - if (t < d / 2) - return outQuart(t * 2, b, c / 2, d); - return inQuart((t * 2) - d, b + c / 2, c / 2, d); -} - -/* Quint */ - -float inQuint(float t, float b, float c, float d) -{ - return c * pow(t / d, 5) + b; -} - -float outQuint(float t, float b, float c, float d) -{ - return c * (pow(t / d - 1, 5) + 1) + b; -} - -float inOutQuint(float t, float b, float c, float d) -{ - t = t / d * 2; - if (t < 1) - return c / 2 * pow(t, 5) + b; - return c / 2 * (pow(t - 2, 5) + 2) + b; -} - -float outInQuint(float t, float b, float c, float d) -{ - if (t < d / 2) - return outQuint(t * 2, b, c / 2, d); - return inQuint((t * 2) - d, b + c / 2, c / 2, d); -} - -/* Sine */ - -float inSine(float t, float b, float c, float d) -{ - return -c * cos(t / d * (M_PI / 2)) + c + b; -} - -float outSine(float t, float b, float c, float d) -{ - return c * sin(t / d * (M_PI / 2)) + b; -} - -float inOutSine(float t, float b, float c, float d) -{ - return -c / 2 * (cos(M_PI * t / d) - 1) + b; -} - -float outInSine(float t, float b, float c, float d) -{ - if (t < d / 2) - return outSine(t * 2, b, c / 2, d); - return inSine((t * 2) -d, b + c / 2, c / 2, d); -} - -/* Expo */ - -float inExpo(float t, float b, float c, float d) -{ - if (t == 0) - return b; - return c * powf(2, 10 * (t / d - 1)) + b - c * 0.001; -} - -float outExpo(float t, float b, float c, float d) -{ - if (t == d) - return b + c; - return c * 1.001 * (-powf(2, -10 * t / d) + 1) + b; -} - -float inOutExpo(float t, float b, float c, float d) -{ - if (t == 0) - return b; - if (t == d) - return b + c; - t = t / d * 2; - if (t < 1) - return c / 2 * powf(2, 10 * (t - 1)) + b - c * 0.0005; - return c / 2 * 1.0005 * (-powf(2, -10 * (t - 1)) + 2) + b; -} - -float outInExpo(float t, float b, float c, float d) -{ - if (t < d / 2) - return outExpo(t * 2, b, c / 2, d); - return inExpo((t * 2) - d, b + c / 2, c / 2, d); -} - -/* Circ */ - -float inCirc(float t, float b, float c, float d) -{ - return(-c * (sqrt(1 - powf(t / d, 2)) - 1) + b); -} - -float outCirc(float t, float b, float c, float d) -{ - return(c * sqrt(1 - powf(t / d - 1, 2)) + b); -} - -float inOutCirc(float t, float b, float c, float d) -{ - t = t / d * 2; - if (t < 1) - return -c / 2 * (sqrt(1 - t * t) - 1) + b; - t = t - 2; - return c / 2 * (sqrt(1 - t * t) + 1) + b; -} - -float outInCirc(float t, float b, float c, float d) -{ - if (t < d / 2) - return outCirc(t * 2, b, c / 2, d); - return inCirc((t * 2) - d, b + c / 2, c / 2, d); -} - -/* Bounce */ - -float outBounce(float t, float b, float c, float d) -{ - t = t / d; - if (t < 1 / 2.75) - return c * (7.5625 * t * t) + b; - if (t < 2 / 2.75) - { - t = t - (1.5 / 2.75); - return c * (7.5625 * t * t + 0.75) + b; - } - else if (t < 2.5 / 2.75) - { - t = t - (2.25 / 2.75); - return c * (7.5625 * t * t + 0.9375) + b; - } - t = t - (2.625 / 2.75); - return c * (7.5625 * t * t + 0.984375) + b; -} - -float inBounce(float t, float b, float c, float d) -{ - return c - outBounce(d - t, 0, c, d) + b; -} - -float inOutBounce(float t, float b, float c, float d) -{ - if (t < d / 2) - return inBounce(t * 2, 0, c, d) * 0.5 + b; - return outBounce(t * 2 - d, 0, c, d) * 0.5 + c * .5 + b; -} - -float outInBounce(float t, float b, float c, float d) -{ - if (t < d / 2) - return outBounce(t * 2, b, c / 2, d); - return inBounce((t * 2) - d, b + c / 2, c / 2, d); -} diff --git a/menu/menu_animation.h b/menu/menu_animation.h index e2b15c8e08..69e7a6aef5 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -48,81 +48,60 @@ typedef struct animation size_t size; } animation_t; +enum animation_easing_type +{ + /* Linear */ + EASING_LINEAR = 0, + /* Quad */ + EASING_IN_QUAD, + EASING_OUT_QUAD, + EASING_IN_OUT_QUAD, + EASING_OUT_IN_QUAD, + /* Cubic */ + EASING_IN_CUBIC, + EASING_OUT_CUBIC, + EASING_IN_OUT_CUBIC, + EASING_OUT_IN_CUBIC, + /* Quart */ + EASING_IN_QUART, + EASING_OUT_QUART, + EASING_IN_OUT_QUART, + EASING_OUT_IN_QUART, + /* Quint */ + EASING_IN_QUINT, + EASING_OUT_QUINT, + EASING_IN_OUT_QUINT, + EASING_OUT_IN_QUINT, + /* Sine */ + EASING_IN_SINE, + EASING_OUT_SINE, + EASING_IN_OUT_SINE, + EASING_OUT_IN_SINE, + /* Expo */ + EASING_IN_EXPO, + EASING_OUT_EXPO, + EASING_IN_OUT_EXPO, + EASING_OUT_IN_EXPO, + /* Circ */ + EASING_IN_CIRC, + EASING_OUT_CIRC, + EASING_IN_OUT_CIRC, + EASING_OUT_IN_CIRC, + /* Bounce */ + EASING_IN_BOUNCE, + EASING_OUT_BOUNCE, + EASING_IN_OUT_BOUNCE, + EASING_OUT_IN_BOUNCE, +}; + void menu_animation_free(animation_t *animation); -bool menu_animation_push(animation_t *animation, float duration, float target_value, float* subject, - easingFunc easing, tween_cb cb); +bool menu_animation_push(animation_t *animation, float duration, + float target_value, float* subject, + enum animation_easing_type easing_enum, tween_cb cb); void menu_animation_update(animation_t *animation, float dt); -/* from https://github.com/kikito/tween.lua/blob/master/tween.lua */ - -float linear(float t, float b, float c, float d); - -float inQuad(float t, float b, float c, float d); - -float outQuad(float t, float b, float c, float d); - -float inOutQuad(float t, float b, float c, float d); - -float outInQuad(float t, float b, float c, float d); - -float inCubic(float t, float b, float c, float d); - -float outCubic(float t, float b, float c, float d); - -float inOutCubic(float t, float b, float c, float d); - -float outInCubic(float t, float b, float c, float d); - -float inQuart(float t, float b, float c, float d); - -float outQuart(float t, float b, float c, float d); - -float inOutQuart(float t, float b, float c, float d); - -float outInQuart(float t, float b, float c, float d); - -float inQuint(float t, float b, float c, float d); - -float outQuint(float t, float b, float c, float d); - -float inOutQuint(float t, float b, float c, float d); - -float outInQuint(float t, float b, float c, float d); - -float inSine(float t, float b, float c, float d); - -float outSine(float t, float b, float c, float d); - -float inOutSine(float t, float b, float c, float d); - -float outInSine(float t, float b, float c, float d); - -float inExpo(float t, float b, float c, float d); - -float outExpo(float t, float b, float c, float d); - -float inOutExpo(float t, float b, float c, float d); - -float outInExpo(float t, float b, float c, float d); - -float inCirc(float t, float b, float c, float d); - -float outCirc(float t, float b, float c, float d); - -float inOutCirc(float t, float b, float c, float d); - -float outInCirc(float t, float b, float c, float d); - -float inBounce(float t, float b, float c, float d); - -float outBounce(float t, float b, float c, float d); - -float inOutBounce(float t, float b, float c, float d); - -float outInBounce(float t, float b, float c, float d); - #ifdef __cplusplus } #endif From 37a8e0ef853e3836c58e4f1ae69945017cf95a06 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 01:22:15 +0100 Subject: [PATCH 013/147] Improve menu_animation_free --- menu/menu_animation.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 3dfbce14b9..4a262b7c19 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -255,7 +255,8 @@ void menu_animation_free(animation_t *animation) for (i = 0; i < animation->size; i++) { - free(animation->list[i].subject); + if (animation->list[i].subject) + free(animation->list[i].subject); } free(animation->list); From 436fe5150de0c8f060652323397f3b7aaa432913 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 01:26:33 +0100 Subject: [PATCH 014/147] (menu_animation.c) subject does not need to be freed --- menu/menu_animation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 4a262b7c19..9bf8e6534e 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -256,7 +256,7 @@ void menu_animation_free(animation_t *animation) for (i = 0; i < animation->size; i++) { if (animation->list[i].subject) - free(animation->list[i].subject); + animation->list[i].subject = NULL; } free(animation->list); From 6cbb3ba3c8fd405fd1bbf4f51aec8533192bf626 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 11 Feb 2015 01:36:42 +0100 Subject: [PATCH 015/147] action_ok_core_list - add early return if directory cannot be accessed --- menu/menu_entries_cbs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 20f9b8b08c..39f1e058b7 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -420,6 +420,12 @@ static int action_ok_remap_file(const char *path, static int action_ok_core_list(const char *path, const char *label, unsigned type, size_t idx) { + if (!path_file_exists(g_settings.libretro_directory)) + { + msg_queue_clear(g_extern.msg_queue); + msg_queue_push(g_extern.msg_queue, "Core Directory doesn't exist or cannot be accessed.\n", 1, 180); + return -1; + } return menu_list_push_stack_refresh( driver.menu->menu_list, g_settings.libretro_directory, From 6d5939063cfc6fac4c0f0d70d70d821e298cf2e3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 01:41:30 +0100 Subject: [PATCH 016/147] Add early return in case cheat directory or remap file doesn't exist --- menu/menu_entries_cbs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 39f1e058b7..dc557921cd 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -402,6 +402,12 @@ static int action_ok_configurations_list(const char *path, static int action_ok_cheat_file(const char *path, const char *label, unsigned type, size_t idx) { + if (!path_file_exists(g_settings.cheat_database)) + { + msg_queue_clear(g_extern.msg_queue); + msg_queue_push(g_extern.msg_queue, "Cheat Directory doesn't exist or cannot be accessed.\n", 1, 180); + return -1; + } return menu_list_push_stack_refresh( driver.menu->menu_list, g_settings.cheat_database, @@ -411,6 +417,12 @@ static int action_ok_cheat_file(const char *path, static int action_ok_remap_file(const char *path, const char *label, unsigned type, size_t idx) { + if (!path_file_exists(g_settings.input_remapping_directory)) + { + msg_queue_clear(g_extern.msg_queue); + msg_queue_push(g_extern.msg_queue, "Remapping Directory doesn't exist or cannot be accessed.\n", 1, 180); + return -1; + } return menu_list_push_stack_refresh( driver.menu->menu_list, g_settings.input_remapping_directory, From f71c00112aaabe970bb7421fa74ae1f9656b7835 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 01:43:16 +0100 Subject: [PATCH 017/147] Add early return in case database/cursor directory has not been set or is inaccessible --- menu/menu_entries_cbs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index dc557921cd..a63a212c69 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -1237,6 +1237,14 @@ static int action_ok_database_manager_list(const char *path, fill_pathname_join(rdb_path, g_settings.content_database, path, sizeof(rdb_path)); + if (!path_file_exists(rdb_path)) + { + msg_queue_clear(g_extern.msg_queue); + msg_queue_push(g_extern.msg_queue, + "Database Directory doesn't exist or cannot be accessed.\n", + 1, 180); + return -1; + } return menu_list_push_stack_refresh( driver.menu->menu_list, rdb_path, @@ -1252,6 +1260,14 @@ static int action_ok_cursor_manager_list(const char *path, fill_pathname_join(cursor_path, g_settings.cursor_directory, path, sizeof(cursor_path)); + if (!path_file_exists(cursor_path)) + { + msg_queue_clear(g_extern.msg_queue); + msg_queue_push(g_extern.msg_queue, + "Cursor Directory doesn't exist or cannot be accessed.\n", + 1, 180); + return -1; + } return menu_list_push_stack_refresh( driver.menu->menu_list, cursor_path, From 639fc61f603399ff4169551b1b5d01780378576b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 02:03:44 +0100 Subject: [PATCH 018/147] (gfx/rpng) Correct copy_line_bw --- gfx/rpng/rpng.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gfx/rpng/rpng.c b/gfx/rpng/rpng.c index c21af16700..2f9d01f5c9 100644 --- a/gfx/rpng/rpng.c +++ b/gfx/rpng/rpng.c @@ -303,11 +303,10 @@ static inline void copy_line_rgba(uint32_t *data, static inline void copy_line_bw(uint32_t *data, const uint8_t *decoded, unsigned width, unsigned depth) { - unsigned i, bit = 0; + unsigned i, bit; static const unsigned mul_table[] = { 0, 0xff, 0x55, 0, 0x11, 0, 0, 0, 0x01 }; - unsigned mul = mul_table[depth]; - unsigned mask = (1 << depth) - 1; - + unsigned mul, mask; + if (depth == 16) { for (i = 0; i < width; i++) @@ -318,6 +317,10 @@ static inline void copy_line_bw(uint32_t *data, return; } + mul = mul_table[depth]; + mask = (1 << depth) - 1; + bit = 0; + for (i = 0; i < width; i++, bit += depth) { unsigned byte = bit >> 3; From 8fca12257a0915c4daafae867a26f3bcbbe6b044 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 02:16:33 +0100 Subject: [PATCH 019/147] (Apple) Input cleanups --- input/drivers/apple_input.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/input/drivers/apple_input.c b/input/drivers/apple_input.c index 7e234118b6..e0c47d078d 100644 --- a/input/drivers/apple_input.c +++ b/input/drivers/apple_input.c @@ -247,14 +247,13 @@ static void apple_input_poll(void *data) return; for (i = 0; i < apple->touch_count; i++) - { - input_translate_coord_viewport(apple->touches[i].screen_x, - apple->touches[i].screen_y, - &apple->touches[i].fixed_x, - &apple->touches[i].fixed_y, - &apple->touches[i].full_x, - &apple->touches[i].full_y); - } + input_translate_coord_viewport( + apple->touches[i].screen_x, + apple->touches[i].screen_y, + &apple->touches[i].fixed_x, + &apple->touches[i].fixed_y, + &apple->touches[i].full_x, + &apple->touches[i].full_y); if (apple->joypad) apple->joypad->poll(); @@ -293,8 +292,14 @@ static int16_t apple_pointer_state(apple_input_data_t *apple, { const apple_touch_data_t *touch = (const apple_touch_data_t *) &apple->touches[idx]; - int16_t x = want_full ? touch->full_x : touch->fixed_x; - int16_t y = want_full ? touch->full_y : touch->fixed_y; + int16_t x = touch->fixed_x; + int16_t y = touch->fixed_y; + + if (want_full) + { + x = touch->full_x; + y = touch->full_y; + } switch (id) { @@ -310,6 +315,12 @@ static int16_t apple_pointer_state(apple_input_data_t *apple, return 0; } +static int16_t apple_keyboard_state(apple_input_data_t *apple, unsigned id) +{ + unsigned bit = input_keymaps_translate_rk_to_keysym((enum retro_key)id); + return (id < RETROK_LAST) && apple->key_state[bit]; +} + static int16_t apple_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned idx, unsigned id) @@ -328,10 +339,7 @@ static int16_t apple_input_state(void *data, return input_joypad_analog(apple->joypad, port, idx, id, binds[port]); case RETRO_DEVICE_KEYBOARD: - { - unsigned bit = input_keymaps_translate_rk_to_keysym((enum retro_key)id); - return (id < RETROK_LAST) && apple->key_state[bit]; - } + return apple_keyboard_state(apple, id); case RETRO_DEVICE_MOUSE: return apple_mouse_state(apple, id); case RETRO_DEVICE_POINTER: From 1bb8ff6f20b25b6169c2c644edb5622a54748bc4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 02:22:20 +0100 Subject: [PATCH 020/147] Move rxml to libretro SDK --- compat/rxml/rxml_test.c | 60 ----------------- .../rxml => libretro-sdk/formats}/Makefile | 2 +- {compat/rxml => libretro-sdk/formats}/rxml.c | 35 +++++----- libretro-sdk/formats/rxml_test.c | 67 +++++++++++++++++++ .../include/formats}/rxml.h | 34 ++++++---- 5 files changed, 107 insertions(+), 91 deletions(-) delete mode 100644 compat/rxml/rxml_test.c rename {compat/rxml => libretro-sdk/formats}/Makefile (76%) rename {compat/rxml => libretro-sdk/formats}/rxml.c (88%) create mode 100644 libretro-sdk/formats/rxml_test.c rename {compat/rxml => libretro-sdk/include/formats}/rxml.h (58%) diff --git a/compat/rxml/rxml_test.c b/compat/rxml/rxml_test.c deleted file mode 100644 index 375a443249..0000000000 --- a/compat/rxml/rxml_test.c +++ /dev/null @@ -1,60 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#include "rxml.h" -#include - -static void print_siblings(struct rxml_node *node, unsigned level) -{ - fprintf(stderr, "\n%*sName: %s\n", level * 4, "", node->name); - if (node->data) - fprintf(stderr, "%*sData: %s\n", level * 4, "", node->data); - - for (const struct rxml_attrib_node *attrib = - node->attrib; attrib; attrib = attrib->next) - fprintf(stderr, "%*s Attrib: %s = %s\n", level * 4, "", - attrib->attrib, attrib->value); - - if (node->children) - print_siblings(node->children, level + 1); - - if (node->next) - print_siblings(node->next, level); -} - -static void rxml_log_document(const char *path) -{ - rxml_document_t *doc = rxml_load_document(path); - if (!doc) - { - fprintf(stderr, "rxml: Failed to load document: %s\n", path); - return; - } - - print_siblings(rxml_root_node(doc), 0); - rxml_free_document(doc); -} - -int main(int argc, char *argv[]) -{ - if (argc != 2) - { - fprintf(stderr, "Usage: %s \n", argv[0]); - return 1; - } - - rxml_log_document(argv[1]); -} - diff --git a/compat/rxml/Makefile b/libretro-sdk/formats/Makefile similarity index 76% rename from compat/rxml/Makefile rename to libretro-sdk/formats/Makefile index f3d54f17e1..db66a6d8d5 100644 --- a/compat/rxml/Makefile +++ b/libretro-sdk/formats/Makefile @@ -3,7 +3,7 @@ TARGET := rxml SOURCES := $(wildcard *.c) OBJS := $(SOURCES:.c=.o) -CFLAGS += -DRXML_TEST -Wall -pedantic -std=gnu99 -O0 -g +CFLAGS += -DRXML_TEST -Wall -pedantic -std=gnu99 -O0 -g -I../include all: $(TARGET) diff --git a/compat/rxml/rxml.c b/libretro-sdk/formats/rxml.c similarity index 88% rename from compat/rxml/rxml.c rename to libretro-sdk/formats/rxml.c index bf44c1d303..410fbf6230 100644 --- a/compat/rxml/rxml.c +++ b/libretro-sdk/formats/rxml.c @@ -1,19 +1,26 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. +/* Copyright (C) 2010-2015 The RetroArch team * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rxml.c). + * --------------------------------------------------------------------------------------- * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "rxml.h" +#include #include #include #include @@ -23,10 +30,6 @@ #include #include -#ifndef RXML_TEST -#include "../../general.h" -#endif - struct rxml_document { struct rxml_node *root_node; diff --git a/libretro-sdk/formats/rxml_test.c b/libretro-sdk/formats/rxml_test.c new file mode 100644 index 0000000000..1156f64f8f --- /dev/null +++ b/libretro-sdk/formats/rxml_test.c @@ -0,0 +1,67 @@ +/* Copyright (C) 2010-2015 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rxml_test.c). + * --------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include + +static void print_siblings(struct rxml_node *node, unsigned level) +{ + fprintf(stderr, "\n%*sName: %s\n", level * 4, "", node->name); + if (node->data) + fprintf(stderr, "%*sData: %s\n", level * 4, "", node->data); + + for (const struct rxml_attrib_node *attrib = + node->attrib; attrib; attrib = attrib->next) + fprintf(stderr, "%*s Attrib: %s = %s\n", level * 4, "", + attrib->attrib, attrib->value); + + if (node->children) + print_siblings(node->children, level + 1); + + if (node->next) + print_siblings(node->next, level); +} + +static void rxml_log_document(const char *path) +{ + rxml_document_t *doc = rxml_load_document(path); + if (!doc) + { + fprintf(stderr, "rxml: Failed to load document: %s\n", path); + return; + } + + print_siblings(rxml_root_node(doc), 0); + rxml_free_document(doc); +} + +int main(int argc, char *argv[]) +{ + if (argc != 2) + { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } + + rxml_log_document(argv[1]); +} + diff --git a/compat/rxml/rxml.h b/libretro-sdk/include/formats/rxml.h similarity index 58% rename from compat/rxml/rxml.h rename to libretro-sdk/include/formats/rxml.h index 3a0b87eefc..ecebefee96 100644 --- a/compat/rxml/rxml.h +++ b/libretro-sdk/include/formats/rxml.h @@ -1,20 +1,26 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. +/* Copyright (C) 2010-2015 The RetroArch team * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rxml.h). + * --------------------------------------------------------------------------------------- * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef RXML_H__ -#define RXML_H__ +#ifndef __LIBRETRO_SDK_FORMAT_RXML_H__ +#define __LIBRETRO_SDK_FORMAT_RXML_H__ #ifdef __cplusplus extern "C" { From 378bd856100d534ab4ee328d95016379dc087cf9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 02:23:41 +0100 Subject: [PATCH 021/147] Move rxml in libretro-SDK --- griffin/griffin.c | 2 +- libretro-sdk/formats/{ => xml}/Makefile | 2 +- libretro-sdk/formats/{ => xml}/rxml.c | 0 libretro-sdk/formats/{ => xml}/rxml_test.c | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename libretro-sdk/formats/{ => xml}/Makefile (75%) rename libretro-sdk/formats/{ => xml}/rxml.c (100%) rename libretro-sdk/formats/{ => xml}/rxml_test.c (100%) diff --git a/griffin/griffin.c b/griffin/griffin.c index 7b912efb03..30b1f14f13 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -778,7 +778,7 @@ XML #if 0 #ifndef HAVE_LIBXML2 #define RXML_LIBXML2_COMPAT -#include "../compat/rxml/rxml.c" +#include "../libretro-sdk/formats/xml/rxml.c" #endif #endif diff --git a/libretro-sdk/formats/Makefile b/libretro-sdk/formats/xml/Makefile similarity index 75% rename from libretro-sdk/formats/Makefile rename to libretro-sdk/formats/xml/Makefile index db66a6d8d5..3c2a6e1fcb 100644 --- a/libretro-sdk/formats/Makefile +++ b/libretro-sdk/formats/xml/Makefile @@ -3,7 +3,7 @@ TARGET := rxml SOURCES := $(wildcard *.c) OBJS := $(SOURCES:.c=.o) -CFLAGS += -DRXML_TEST -Wall -pedantic -std=gnu99 -O0 -g -I../include +CFLAGS += -DRXML_TEST -Wall -pedantic -std=gnu99 -O0 -g -I../../include all: $(TARGET) diff --git a/libretro-sdk/formats/rxml.c b/libretro-sdk/formats/xml/rxml.c similarity index 100% rename from libretro-sdk/formats/rxml.c rename to libretro-sdk/formats/xml/rxml.c diff --git a/libretro-sdk/formats/rxml_test.c b/libretro-sdk/formats/xml/rxml_test.c similarity index 100% rename from libretro-sdk/formats/rxml_test.c rename to libretro-sdk/formats/xml/rxml_test.c From 3a062538ddbb872063dfa525ca764d790d963c59 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 02:30:56 +0100 Subject: [PATCH 022/147] Move rpng to libretro SDK --- Makefile.common | 4 +- gfx/image/image_rpng.c | 2 +- gfx/rpng/rpng.h | 46 ---------------- griffin/griffin.c | 2 +- .../formats/png}/Makefile | 0 {gfx/rpng => libretro-sdk/formats/png}/rpng.c | 34 +++++++----- .../formats/png}/rpng_test.c | 31 ++++++----- libretro-sdk/include/formats/rpng.h | 53 +++++++++++++++++++ screenshot.c | 2 +- 9 files changed, 98 insertions(+), 76 deletions(-) delete mode 100644 gfx/rpng/rpng.h rename {gfx/rpng => libretro-sdk/formats/png}/Makefile (100%) rename {gfx/rpng => libretro-sdk/formats/png}/rpng.c (95%) rename {gfx/rpng => libretro-sdk/formats/png}/rpng_test.c (60%) create mode 100644 libretro-sdk/include/formats/rpng.h diff --git a/Makefile.common b/Makefile.common index 28692d589c..358bb5dbaa 100644 --- a/Makefile.common +++ b/Makefile.common @@ -534,7 +534,7 @@ endif #LIBS += $(LIBXML2_LIBS) #DEFINES += $(LIBXML2_CFLAGS) #else - #OBJ += compat/rxml/rxml.o + #OBJ += libretro-sdk/formats/xml/rxml.o #endif # Compression/Archive @@ -564,7 +564,7 @@ endif ifeq ($(HAVE_ZLIB), 1) ZLIB_OBJS = decompress/zip_support.o - OBJ += gfx/rpng/rpng.o file_extract.o + OBJ += libretro-sdk/formats/png/rpng.o file_extract.o OBJ += $(ZLIB_OBJS) DEFINES += -DHAVE_ZLIB HAVE_COMPRESSION = 1 diff --git a/gfx/image/image_rpng.c b/gfx/image/image_rpng.c index 6ec68cdc81..cf2aed2647 100644 --- a/gfx/image/image_rpng.c +++ b/gfx/image/image_rpng.c @@ -25,7 +25,7 @@ #include #include #include "../../general.h" -#include "../rpng/rpng.h" +#include static bool rpng_image_load_tga_shift(const char *path, struct texture_image *out_img, diff --git a/gfx/rpng/rpng.h b/gfx/rpng/rpng.h deleted file mode 100644 index 95fa96d512..0000000000 --- a/gfx/rpng/rpng.h +++ /dev/null @@ -1,46 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#ifndef RPNG_H__ -#define RPNG_H__ - -#include - -#include - -#ifdef HAVE_CONFIG_H -#include "../../config.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -bool rpng_load_image_argb(const char *path, uint32_t **data, - unsigned *width, unsigned *height); - -#ifdef HAVE_ZLIB_DEFLATE -bool rpng_save_image_argb(const char *path, const uint32_t *data, - unsigned width, unsigned height, unsigned pitch); -bool rpng_save_image_bgr24(const char *path, const uint8_t *data, - unsigned width, unsigned height, unsigned pitch); -#endif - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/griffin/griffin.c b/griffin/griffin.c index 30b1f14f13..588d9d2837 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -180,7 +180,7 @@ VIDEO IMAGE #include "../gfx/image/image_rpng.c" #endif -#include "../gfx/rpng/rpng.c" +#include "../libretro-sdk/formats/png/rpng.c" /*============================================================ VIDEO DRIVER diff --git a/gfx/rpng/Makefile b/libretro-sdk/formats/png/Makefile similarity index 100% rename from gfx/rpng/Makefile rename to libretro-sdk/formats/png/Makefile diff --git a/gfx/rpng/rpng.c b/libretro-sdk/formats/png/rpng.c similarity index 95% rename from gfx/rpng/rpng.c rename to libretro-sdk/formats/png/rpng.c index 2f9d01f5c9..80344edbf5 100644 --- a/gfx/rpng/rpng.c +++ b/libretro-sdk/formats/png/rpng.c @@ -1,19 +1,26 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. +/* Copyright (C) 2010-2015 The RetroArch team * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rpng.c). + * --------------------------------------------------------------------------------------- * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "rpng.h" +#include #include @@ -26,8 +33,9 @@ #endif #ifdef RARCH_INTERNAL -#include "../../hash.h" +#include "../../../hash.h" #else + static inline uint32_t crc32_calculate(const uint8_t *data, size_t length) { return crc32(0, data, length); diff --git a/gfx/rpng/rpng_test.c b/libretro-sdk/formats/png/rpng_test.c similarity index 60% rename from gfx/rpng/rpng_test.c rename to libretro-sdk/formats/png/rpng_test.c index 0870de0f32..0d3ad73265 100644 --- a/gfx/rpng/rpng_test.c +++ b/libretro-sdk/formats/png/rpng_test.c @@ -1,19 +1,26 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. +/* Copyright (C) 2010-2015 The RetroArch team * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rpng_test.c). + * --------------------------------------------------------------------------------------- * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "rpng.h" +#include #include #include #include diff --git a/libretro-sdk/include/formats/rpng.h b/libretro-sdk/include/formats/rpng.h new file mode 100644 index 0000000000..077afc67e5 --- /dev/null +++ b/libretro-sdk/include/formats/rpng.h @@ -0,0 +1,53 @@ +/* Copyright (C) 2010-2015 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rpng.h). + * --------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __LIBRETRO_SDK_FORMAT_RPNG_H__ +#define __LIBRETRO_SDK_FORMAT_RPNG_H__ + +#include + +#include + +#ifdef HAVE_CONFIG_H +#include "../../config.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +bool rpng_load_image_argb(const char *path, uint32_t **data, + unsigned *width, unsigned *height); + +#ifdef HAVE_ZLIB_DEFLATE +bool rpng_save_image_argb(const char *path, const uint32_t *data, + unsigned width, unsigned height, unsigned pitch); +bool rpng_save_image_bgr24(const char *path, const uint8_t *data, + unsigned width, unsigned height, unsigned pitch); +#endif + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/screenshot.c b/screenshot.c index 127b20d1f0..13233aa011 100644 --- a/screenshot.c +++ b/screenshot.c @@ -35,7 +35,7 @@ #ifdef HAVE_ZLIB_DEFLATE -#include "gfx/rpng/rpng.h" +#include #define IMG_EXT "png" #else From 4e5cec22d99806a35d9334e0b9b6c89c684ca3c1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 02:32:20 +0100 Subject: [PATCH 023/147] (Libretro SDK) Update --- libretro-sdk/formats/png/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-sdk/formats/png/Makefile b/libretro-sdk/formats/png/Makefile index 46e2137164..ed00d89b45 100644 --- a/libretro-sdk/formats/png/Makefile +++ b/libretro-sdk/formats/png/Makefile @@ -3,7 +3,7 @@ TARGET := rpng SOURCES := $(wildcard *.c) OBJS := $(SOURCES:.c=.o) -CFLAGS += -Wall -pedantic -std=gnu99 -O0 -g -DHAVE_ZLIB -DHAVE_ZLIB_DEFLATE -DRPNG_TEST -I../../libretro-sdk/include +CFLAGS += -Wall -pedantic -std=gnu99 -O0 -g -DHAVE_ZLIB -DHAVE_ZLIB_DEFLATE -DRPNG_TEST -I../../include all: $(TARGET) From 5c050864557d768a63c5d6252e6bcd915375e058 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 02:40:18 +0100 Subject: [PATCH 024/147] Start updating audio/test --- audio/audio_utils.c | 4 +--- audio/test/Makefile | 41 +++++++++++++++++++++-------------------- audio/test/main.c | 2 +- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/audio/audio_utils.c b/audio/audio_utils.c index 2c50fe0197..a703b2981e 100644 --- a/audio/audio_utils.c +++ b/audio/audio_utils.c @@ -25,10 +25,8 @@ #ifdef RARCH_INTERNAL #include "../performance.h" -#include "../libretro.h" -#else -#include "../libretro/libretro.h" #endif +#include "libretro.h" /** * audio_convert_s16_to_float_C: diff --git a/audio/test/Makefile b/audio/test/Makefile index 4d772d0cc2..935e75abd7 100644 --- a/audio/test/Makefile +++ b/audio/test/Makefile @@ -13,15 +13,16 @@ TESTS := test-sinc-lowest \ CFLAGS += -O3 -ffast-math -g -Wall -pedantic -march=native -std=gnu99 CFLAGS += -DRESAMPLER_TEST -DRARCH_DUMMY_LOG +CFLAGS += -I../../libretro-sdk/include -I../../ LDFLAGS += -lm all: $(TESTS) -resampler-sinc.o: ../resamplers/resampler.c +resampler-sinc.o: ../audio_resampler_driver.c $(CC) -c -o $@ $< $(CFLAGS) -resampler-cc.o: ../resamplers/resampler.c +resampler-cc.o: ../audio_resampler_driver.c $(CC) -c -o $@ $< $(CFLAGS) -DRESAMPLER_IDENT='"CC"' main-cc.o: main.c @@ -33,58 +34,58 @@ snr-cc.o: snr.c cc-resampler.o: ../resamplers/cc_resampler.c $(CC) -c -o $@ $< $(CFLAGS) -sinc-lowest.o: ../resamplers/sinc.c +sinc-lowest.o: ../drivers_resampler/sinc.c $(CC) -c -o $@ $< $(CFLAGS) -DSINC_LOWEST_QUALITY -sinc-lower.o: ../resamplers/sinc.c +sinc-lower.o: ../drivers_resampler/sinc.c $(CC) -c -o $@ $< $(CFLAGS) -DSINC_LOWER_QUALITY -sinc.o: ../resamplers/sinc.c +sinc.o: ../drivers_resampler/sinc.c $(CC) -c -o $@ $< $(CFLAGS) -nearest.o: ../resamplers/nearest.c +nearest.o: ../drivers_resampler/nearest.c $(CC) -c -o $@ $< $(CFLAGS) -sinc-higher.o: ../resamplers/sinc.c +sinc-higher.o: ../drivers_resampler/sinc.c $(CC) -c -o $@ $< $(CFLAGS) -DSINC_HIGHER_QUALITY -sinc-highest.o: ../resamplers/sinc.c +sinc-highest.o: ../drivers_resampler/sinc.c $(CC) -c -o $@ $< $(CFLAGS) -DSINC_HIGHEST_QUALITY -test-sinc-lowest: sinc-lowest.o ../utils.o main.o resampler-sinc.o nearest.o +test-sinc-lowest: sinc-lowest.o ../audio_utils.o main.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-snr-sinc-lowest: sinc-lowest.o ../utils.o snr.o resampler-sinc.o nearest.o +test-snr-sinc-lowest: sinc-lowest.o ../audio_utils.o snr.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-sinc-lower: sinc-lower.o ../utils.o main.o resampler-sinc.o nearest.o +test-sinc-lower: sinc-lower.o ../audio_utils.o main.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-snr-sinc-lower: sinc-lower.o ../utils.o snr.o resampler-sinc.o nearest.o +test-snr-sinc-lower: sinc-lower.o ../audio_utils.o snr.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-sinc: sinc.o ../utils.o main.o resampler-sinc.o nearest.o +test-sinc: sinc.o ../audio_utils.o main.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-snr-sinc: sinc.o ../utils.o snr.o resampler-sinc.o nearest.o +test-snr-sinc: sinc.o ../audio_utils.o snr.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-sinc-higher: sinc-higher.o ../utils.o main.o resampler-sinc.o nearest.o +test-sinc-higher: sinc-higher.o ../audio_utils.o main.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-snr-sinc-higher: sinc-higher.o ../utils.o snr.o resampler-sinc.o nearest.o +test-snr-sinc-higher: sinc-higher.o ../audio_utils.o snr.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-sinc-highest: sinc-highest.o ../utils.o main.o resampler-sinc.o nearest.o +test-sinc-highest: sinc-highest.o ../audio_utils.o main.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-snr-sinc-highest: sinc-highest.o ../utils.o snr.o resampler-sinc.o nearest.o +test-snr-sinc-highest: sinc-highest.o ../audio_utils.o snr.o resampler-sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-cc: cc-resampler.o ../utils.o main-cc.o resampler-cc.o sinc.o nearest.o +test-cc: cc-resampler.o ../audio_utils.o main-cc.o resampler-cc.o sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) -test-snr-cc: cc-resampler.o ../utils.o snr-cc.o resampler-cc.o sinc.o nearest.o +test-snr-cc: cc-resampler.o ../audio_utils.o snr-cc.o resampler-cc.o sinc.o nearest.o $(CC) -o $@ $^ $(LDFLAGS) %.o: %.c diff --git a/audio/test/main.c b/audio/test/main.c index 15e5bfc4e3..abecdba194 100644 --- a/audio/test/main.c +++ b/audio/test/main.c @@ -16,7 +16,7 @@ // Resampler that reads raw S16NE/stereo from stdin and outputs to stdout in S16NE/stereo. // Used for testing and performance benchmarking. -#include "../resamplers/resampler.h" +#include "../audio_resampler_driver.h" #include "../audio_utils.h" #include #include From 4186d9728124966871f7f77d4b8465a49102b975 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 03:40:29 +0100 Subject: [PATCH 025/147] Start creating menu_texture.c - have GLUI use it --- Makefile.common | 1 + griffin/griffin.c | 1 + menu/drivers/glui.c | 56 ++------------------- menu/menu_texture.c | 116 ++++++++++++++++++++++++++++++++++++++++++++ menu/menu_texture.h | 37 ++++++++++++++ 5 files changed, 159 insertions(+), 52 deletions(-) create mode 100644 menu/menu_texture.c create mode 100644 menu/menu_texture.h diff --git a/Makefile.common b/Makefile.common index 358bb5dbaa..03b37bac07 100644 --- a/Makefile.common +++ b/Makefile.common @@ -307,6 +307,7 @@ ifeq ($(HAVE_MENU_COMMON), 1) menu/menu_action.o \ menu/menu_database.o \ menu/menu_shader.o \ + menu/menu_texture.o \ menu/menu_entries.o \ menu/menu_entries_cbs.o \ menu/menu_list.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 588d9d2837..5ce297ed66 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -686,6 +686,7 @@ MENU #include "../menu/menu_entries.c" #include "../menu/menu_entries_cbs.c" #include "../menu/menu_shader.c" +#include "../menu/menu_texture.c" #include "../menu/menu_navigation.c" #include "../menu/menu_animation.c" #include "../menu/menu_database.c" diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 52028735d9..f6bb85b2b7 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -22,11 +22,12 @@ #include #include "../menu.h" +#include "../menu_texture.h" +#include "../menu_input.h" + #include #include "../../gfx/gl_common.h" -#include "../../gfx/video_thread_wrapper.h" #include -#include "../menu_input.h" #include "shared.h" @@ -497,55 +498,6 @@ static void glui_free(void *data) free(menu->userdata); } -static GLuint glui_png_texture_load_(const char * file_name) -{ - GLuint texture = 0; - struct texture_image ti = {0}; - if (! path_file_exists(file_name)) - return 0; - - texture_image_load(&ti, file_name); - - /* Generate the OpenGL texture object */ - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); - glTexImage2D(GL_TEXTURE_2D, 0, driver.gfx_use_rgba ? - GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, - ti.width, ti.height, 0, - driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, - RARCH_GL_FORMAT32, ti.pixels); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - free(ti.pixels); - - return texture; -} -static int glui_png_texture_load_wrap(void *data) -{ - const char *filename = (const char*)data; - return glui_png_texture_load_(filename); -} - - -static GLuint glui_png_texture_load(const char* file_name) -{ - if (g_settings.video.threaded - && !g_extern.system.hw_render_callback.context_type) - { - thread_video_t *thr = (thread_video_t*)driver.video_data; - thr->cmd_data.custom_command.method = glui_png_texture_load_wrap; - thr->cmd_data.custom_command.data = (void*)file_name; - thr->send_cmd_func(thr, CMD_CUSTOM_COMMAND); - thr->wait_reply_func(thr, CMD_CUSTOM_COMMAND); - - return thr->cmd_data.custom_command.return_value; - - } - - return glui_png_texture_load_(file_name); -} - static void glui_context_reset(void *data) { @@ -573,7 +525,7 @@ static void glui_context_reset(void *data) fill_pathname_join(bgpath, bgpath, "bg.png", sizeof(bgpath)); if (path_file_exists(bgpath)) - glui->bg = glui_png_texture_load(bgpath); + glui->bg = (GLuint)menu_texture_load(bgpath, TEXTURE_BACKEND_OPENGL); } static void glui_navigation_clear(void *data, bool pending_push) diff --git a/menu/menu_texture.c b/menu/menu_texture.c new file mode 100644 index 0000000000..a812d37890 --- /dev/null +++ b/menu/menu_texture.c @@ -0,0 +1,116 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2015 - Daniel De Matteis + * Copyright (C) 2014-2015 - Jean-André Santoni + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include "menu_texture.h" +#include +#include "../general.h" +#include "../gfx/video_thread_wrapper.h" + +#ifdef HAVE_OPENGL +#include "../gfx/gl_common.h" + +static void menu_texture_png_load_gl(struct texture_image *ti, + unsigned *id) +{ + /* Generate the OpenGL texture object */ + glGenTextures(1, id); + glBindTexture(GL_TEXTURE_2D, (GLuint)*id); + glTexImage2D(GL_TEXTURE_2D, 0, driver.gfx_use_rgba ? + GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, + ti->width, ti->height, 0, + driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, + RARCH_GL_FORMAT32, ti->pixels); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); +} +#endif + +static unsigned menu_texture_png_load(const char *path, + enum texture_backend_type type) +{ + unsigned id = 0; + struct texture_image ti = {0}; + if (! path_file_exists(path)) + return 0; + + texture_image_load(&ti, path); + + switch (type) + { + case TEXTURE_BACKEND_OPENGL: +#ifdef HAVE_OPENGL + menu_texture_png_load_gl(&ti, &id); +#endif + break; + case TEXTURE_BACKEND_DEFAULT: + default: + break; + } + + free(ti.pixels); + + return id; +} + +static int menu_texture_png_load_wrap(void *data) +{ + const char *filename = (const char*)data; + if (!filename) + return 0; + return menu_texture_png_load(filename, TEXTURE_BACKEND_DEFAULT); +} + +static int menu_texture_png_load_wrap_gl(void *data) +{ + const char *filename = (const char*)data; + if (!filename) + return 0; + return menu_texture_png_load(filename, TEXTURE_BACKEND_OPENGL); +} + +unsigned menu_texture_load(const char *path, + enum texture_backend_type type) +{ + if (g_settings.video.threaded + && !g_extern.system.hw_render_callback.context_type) + { + thread_video_t *thr = (thread_video_t*)driver.video_data; + + if (!thr) + return 0; + + switch (type) + { + case TEXTURE_BACKEND_OPENGL: + thr->cmd_data.custom_command.method = menu_texture_png_load_wrap_gl; + break; + case TEXTURE_BACKEND_DEFAULT: + default: + thr->cmd_data.custom_command.method = menu_texture_png_load_wrap; + break; + } + + thr->cmd_data.custom_command.data = (void*)path; + + thr->send_cmd_func(thr, CMD_CUSTOM_COMMAND); + thr->wait_reply_func(thr, CMD_CUSTOM_COMMAND); + + return thr->cmd_data.custom_command.return_value; + } + + return menu_texture_png_load(path, type); +} diff --git a/menu/menu_texture.h b/menu/menu_texture.h new file mode 100644 index 0000000000..4f48d38c52 --- /dev/null +++ b/menu/menu_texture.h @@ -0,0 +1,37 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2015 - Daniel De Matteis + * Copyright (C) 2014-2015 - Jean-André Santoni + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#ifndef _MENU_TEXTURE_MANAGER_H +#define _MENU_TEXTURE_MANAGER_H + +enum texture_backend_type +{ + TEXTURE_BACKEND_DEFAULT = 0, + TEXTURE_BACKEND_OPENGL, +}; + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned menu_texture_load(const char *path, + enum texture_backend_type type); + +#ifdef __cplusplus +} +#endif + +#endif From 04022926bc7c507bdc1cea9a6768ffbd511eb02e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 03:52:35 +0100 Subject: [PATCH 026/147] Have XMB and GLUI reuse same menu_texture code --- menu/drivers/glui.c | 3 +- menu/drivers/xmb.c | 71 +++++++-------------------------------------- menu/menu_texture.c | 50 +++++++++++++++++++++++++------ menu/menu_texture.h | 9 +++++- 4 files changed, 61 insertions(+), 72 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index f6bb85b2b7..bab1f4d905 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -525,7 +525,8 @@ static void glui_context_reset(void *data) fill_pathname_join(bgpath, bgpath, "bg.png", sizeof(bgpath)); if (path_file_exists(bgpath)) - glui->bg = (GLuint)menu_texture_load(bgpath, TEXTURE_BACKEND_OPENGL); + glui->bg = (GLuint)menu_texture_load(bgpath, TEXTURE_BACKEND_OPENGL, + TEXTURE_FILTER_DEFAULT); } static void glui_navigation_clear(void *data, bool pending_push) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 2dc04341fb..bfd9f6228a 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -22,13 +22,15 @@ #include "../menu.h" #include "../menu_input.h" +#include "../menu_animation.h" +#include "../menu_texture.h" + #include #include "../../gfx/gl_common.h" #include "../../gfx/video_thread_wrapper.h" #include #include "shared.h" -#include "../menu_animation.h" #ifndef XMB_THEME #define XMB_THEME "monochrome" @@ -575,63 +577,6 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) xmb->old_depth = xmb->depth; } -static GLuint xmb_png_texture_load_(const char * file_name) -{ - struct texture_image ti = {0}; - GLuint texture = 0; - - if (! path_file_exists(file_name)) - return 0; - - texture_image_load(&ti, file_name); - - /* Generate the OpenGL texture object */ - glGenTextures(1, &texture); - glBindTexture(GL_TEXTURE_2D, texture); - glTexImage2D(GL_TEXTURE_2D, 0, driver.gfx_use_rgba ? - GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, - ti.width, ti.height, 0, - driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, - RARCH_GL_FORMAT32, ti.pixels); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glGenerateMipmap(GL_TEXTURE_2D); - - free(ti.pixels); - - return texture; -} - -static int xmb_png_texture_load_wrap(void *data) -{ - const char *filename = (const char*)data; - - if (!filename) - return 0; - return xmb_png_texture_load_(filename); -} - -static GLuint xmb_png_texture_load(const char* file_name) -{ - if (g_settings.video.threaded - && !g_extern.system.hw_render_callback.context_type) - { - thread_video_t *thr = (thread_video_t*)driver.video_data; - - if (!thr) - return 0; - - thr->cmd_data.custom_command.method = xmb_png_texture_load_wrap; - thr->cmd_data.custom_command.data = (void*)file_name; - thr->send_cmd_func(thr, CMD_CUSTOM_COMMAND); - thr->wait_reply_func(thr, CMD_CUSTOM_COMMAND); - - return thr->cmd_data.custom_command.return_value; - } - - return xmb_png_texture_load_(file_name); -} - static xmb_node_t* xmb_node_for_core(int i) { core_info_t *info = NULL; @@ -1408,7 +1353,8 @@ static void xmb_context_reset(void *data) "clock.png", sizeof(xmb->textures[XMB_TEXTURE_CLOCK].path)); for (k = 0; k < XMB_TEXTURE_LAST; k++) - xmb->textures[k].id = xmb_png_texture_load(xmb->textures[k].path); + xmb->textures[k].id = menu_texture_load(xmb->textures[k].path, + TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP); xmb->settings_node.icon = xmb->textures[XMB_TEXTURE_SETTINGS].id; xmb->settings_node.alpha = xmb->c_active_alpha; @@ -1453,8 +1399,11 @@ static void xmb_context_reset(void *data) node->alpha = 0; node->zoom = xmb->c_passive_zoom; - node->icon = xmb_png_texture_load(texturepath); - node->content_icon = xmb_png_texture_load(content_texturepath); + node->icon = menu_texture_load(texturepath, + TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP); + node->content_icon = menu_texture_load(content_texturepath, + TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP); + if (i == xmb->active_category) { diff --git a/menu/menu_texture.c b/menu/menu_texture.c index a812d37890..817d032029 100644 --- a/menu/menu_texture.c +++ b/menu/menu_texture.c @@ -23,6 +23,7 @@ #include "../gfx/gl_common.h" static void menu_texture_png_load_gl(struct texture_image *ti, + enum texture_filter_type filter_type, unsigned *id) { /* Generate the OpenGL texture object */ @@ -34,13 +35,29 @@ static void menu_texture_png_load_gl(struct texture_image *ti, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, RARCH_GL_FORMAT32, ti->pixels); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + switch (filter_type) + { + case TEXTURE_FILTER_MIPMAP: + glTexParameterf(GL_TEXTURE_2D, + GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); + glTexParameterf(GL_TEXTURE_2D, + GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glGenerateMipmap(GL_TEXTURE_2D); + break; + case TEXTURE_FILTER_DEFAULT: + default: + glTexParameterf(GL_TEXTURE_2D, + GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, + GL_TEXTURE_MAG_FILTER, GL_LINEAR); + break; + } } #endif static unsigned menu_texture_png_load(const char *path, - enum texture_backend_type type) + enum texture_backend_type type, + enum texture_filter_type filter_type) { unsigned id = 0; struct texture_image ti = {0}; @@ -53,7 +70,7 @@ static unsigned menu_texture_png_load(const char *path, { case TEXTURE_BACKEND_OPENGL: #ifdef HAVE_OPENGL - menu_texture_png_load_gl(&ti, &id); + menu_texture_png_load_gl(&ti, filter_type, &id); #endif break; case TEXTURE_BACKEND_DEFAULT: @@ -71,7 +88,17 @@ static int menu_texture_png_load_wrap(void *data) const char *filename = (const char*)data; if (!filename) return 0; - return menu_texture_png_load(filename, TEXTURE_BACKEND_DEFAULT); + return menu_texture_png_load(filename, TEXTURE_BACKEND_DEFAULT, + TEXTURE_FILTER_DEFAULT); +} + +static int menu_texture_png_load_wrap_gl_mipmap(void *data) +{ + const char *filename = (const char*)data; + if (!filename) + return 0; + return menu_texture_png_load(filename, TEXTURE_BACKEND_OPENGL, + TEXTURE_FILTER_MIPMAP); } static int menu_texture_png_load_wrap_gl(void *data) @@ -79,11 +106,13 @@ static int menu_texture_png_load_wrap_gl(void *data) const char *filename = (const char*)data; if (!filename) return 0; - return menu_texture_png_load(filename, TEXTURE_BACKEND_OPENGL); + return menu_texture_png_load(filename, TEXTURE_BACKEND_OPENGL, + TEXTURE_FILTER_DEFAULT); } unsigned menu_texture_load(const char *path, - enum texture_backend_type type) + enum texture_backend_type type, + enum texture_filter_type filter_type) { if (g_settings.video.threaded && !g_extern.system.hw_render_callback.context_type) @@ -96,7 +125,10 @@ unsigned menu_texture_load(const char *path, switch (type) { case TEXTURE_BACKEND_OPENGL: - thr->cmd_data.custom_command.method = menu_texture_png_load_wrap_gl; + if (filter_type == TEXTURE_FILTER_MIPMAP) + thr->cmd_data.custom_command.method = menu_texture_png_load_wrap_gl_mipmap; + else + thr->cmd_data.custom_command.method = menu_texture_png_load_wrap_gl; break; case TEXTURE_BACKEND_DEFAULT: default: @@ -112,5 +144,5 @@ unsigned menu_texture_load(const char *path, return thr->cmd_data.custom_command.return_value; } - return menu_texture_png_load(path, type); + return menu_texture_png_load(path, type, filter_type); } diff --git a/menu/menu_texture.h b/menu/menu_texture.h index 4f48d38c52..d5ef3ffd22 100644 --- a/menu/menu_texture.h +++ b/menu/menu_texture.h @@ -23,12 +23,19 @@ enum texture_backend_type TEXTURE_BACKEND_OPENGL, }; +enum texture_filter_type +{ + TEXTURE_FILTER_DEFAULT = 0, + TEXTURE_FILTER_MIPMAP, +}; + #ifdef __cplusplus extern "C" { #endif unsigned menu_texture_load(const char *path, - enum texture_backend_type type); + enum texture_backend_type type, + enum texture_filter_type filter_type); #ifdef __cplusplus } From 1b4519ec977ba979d1710ee3a64c05d1def6306c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 03:55:25 +0100 Subject: [PATCH 027/147] (Menu) rmenu_set_texture - make it static --- menu/drivers/rmenu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index 0f7d84883c..eadce12fb3 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -283,7 +283,7 @@ static void rmenu_render(void) } } -void rmenu_set_texture(void *data) +static void rmenu_set_texture(void *data) { menu_handle_t *menu = (menu_handle_t*)data; From da004daa8a1397e10fc254747e94484224761c8e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 05:08:07 +0100 Subject: [PATCH 028/147] Move frame_buf/frame_buf_pitch to menu_driver struct --- menu/drivers/rgui.c | 86 +++++++++++++++++++++------------------------ menu/menu_driver.h | 3 ++ 2 files changed, 44 insertions(+), 45 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 6412ae8a61..0307425d8f 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -34,8 +34,6 @@ typedef struct rgui_handle { unsigned term_height; - uint16_t *frame_buf; - size_t frame_buf_pitch; } rgui_handle_t; #define RGUI_TERM_START_X (driver.menu->width / 21) @@ -178,8 +176,8 @@ static void blit_line(int x, int y, const char *message, bool green) if (!col) continue; - rgui->frame_buf[(y + j) * - (rgui->frame_buf_pitch >> 1) + (x + i)] = green ? + driver.menu->frame_buf[(y + j) * + (driver.menu->frame_buf_pitch >> 1) + (x + i)] = green ? #if defined(GEKKO)|| defined(PSP) (3 << 0) | (10 << 4) | (3 << 8) | (7 << 12) : 0x7FFF; #else @@ -235,28 +233,26 @@ static bool rguidisp_init_font(void *data) return true; } -static void rgui_render_background(void *data) +static void rgui_render_background(menu_handle_t *menu) { - rgui_handle_t *rgui = (rgui_handle_t*)data; - - if (!rgui) + if (!menu) return; - fill_rect(rgui->frame_buf, rgui->frame_buf_pitch, - 0, 0, driver.menu->width, driver.menu->height, gray_filler); + fill_rect(menu->frame_buf, menu->frame_buf_pitch, + 0, 0, menu->width, menu->height, gray_filler); - fill_rect(rgui->frame_buf, rgui->frame_buf_pitch, - 5, 5, driver.menu->width - 10, 5, green_filler); + fill_rect(menu->frame_buf, menu->frame_buf_pitch, + 5, 5, menu->width - 10, 5, green_filler); - fill_rect(rgui->frame_buf, rgui->frame_buf_pitch, - 5, driver.menu->height - 10, driver.menu->width - 10, 5, + fill_rect(menu->frame_buf, menu->frame_buf_pitch, + 5, menu->height - 10, menu->width - 10, 5, green_filler); - fill_rect(rgui->frame_buf, rgui->frame_buf_pitch, - 5, 5, 5, driver.menu->height - 10, green_filler); + fill_rect(menu->frame_buf, menu->frame_buf_pitch, + 5, 5, 5, menu->height - 10, green_filler); - fill_rect(rgui->frame_buf, rgui->frame_buf_pitch, - driver.menu->width - 10, 5, 5, driver.menu->height - 10, + fill_rect(menu->frame_buf, menu->frame_buf_pitch, + menu->width - 10, 5, 5, menu->height - 10, green_filler); } @@ -308,19 +304,19 @@ static void rgui_render_messagebox(const char *message) x = (driver.menu->width - width) / 2; y = (driver.menu->height - height) / 2; - fill_rect(rgui->frame_buf, rgui->frame_buf_pitch, + fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch, x + 5, y + 5, width - 10, height - 10, gray_filler); - fill_rect(rgui->frame_buf, rgui->frame_buf_pitch, + fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch, x, y, width - 5, 5, green_filler); - fill_rect(rgui->frame_buf, rgui->frame_buf_pitch, + fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch, x + width - 5, y, 5, height - 5, green_filler); - fill_rect(rgui->frame_buf, rgui->frame_buf_pitch, + fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch, x + 5, y + height - 5, width - 5, 5, green_filler); - fill_rect(rgui->frame_buf, rgui->frame_buf_pitch, + fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch, x, y + 5, 5, height - 5, green_filler); for (i = 0; i < list->size; i++) @@ -335,18 +331,19 @@ end: string_list_free(list); } -static void rgui_blit_cursor(void* data) +static void rgui_blit_cursor(menu_handle_t *menu) { - rgui_handle_t *rgui = (rgui_handle_t*)data; - int16_t x = driver.menu->mouse.x; - int16_t y = driver.menu->mouse.y; + int16_t x, y; - if (!rgui) + if (!menu) return; + + x = menu->mouse.x; + y = menu->mouse.y; - color_rect(rgui->frame_buf, rgui->frame_buf_pitch, + color_rect(menu->frame_buf, menu->frame_buf_pitch, x, y-5, 1, 11, 0xFFFF); - color_rect(rgui->frame_buf, rgui->frame_buf_pitch, + color_rect(menu->frame_buf, menu->frame_buf_pitch, x-5, y, 11, 1, 0xFFFF); } @@ -390,7 +387,7 @@ static void rgui_render(void) driver.menu->begin + RGUI_TERM_HEIGHT : menu_list_get_size(driver.menu->menu_list); - rgui_render_background(rgui); + rgui_render_background(driver.menu); menu_list_get_last_stack(driver.menu->menu_list, &dir, &label, &menu_type); @@ -506,13 +503,12 @@ static void rgui_render(void) } if (driver.menu->mouse.enable) - rgui_blit_cursor(rgui); + rgui_blit_cursor(driver.menu); } static void *rgui_init(void) { bool ret = false; - rgui_handle_t *rgui = NULL; menu_handle_t *menu = (menu_handle_t*)calloc(1, sizeof(*menu)); if (!menu) @@ -523,17 +519,15 @@ static void *rgui_init(void) if (!menu->userdata) goto error; - rgui = (rgui_handle_t*)menu->userdata; + menu->frame_buf = (uint16_t*)malloc(400 * 240 * sizeof(uint16_t)); - rgui->frame_buf = (uint16_t*)malloc(400 * 240 * sizeof(uint16_t)); - - if (!rgui->frame_buf) + if (!menu->frame_buf) goto error; menu->width = 320; menu->height = 240; menu->begin = 0; - rgui->frame_buf_pitch = menu->width * sizeof(uint16_t); + menu->frame_buf_pitch = menu->width * sizeof(uint16_t); ret = rguidisp_init_font(menu); @@ -548,12 +542,14 @@ static void *rgui_init(void) return menu; error: - if (rgui && rgui->frame_buf) - free(rgui->frame_buf); - if (menu && menu->userdata) - free(menu->userdata); if (menu) + { + if (menu->frame_buf) + free(menu->frame_buf); + if (menu->userdata) + free(menu->userdata); free(menu); + } return NULL; } @@ -570,8 +566,8 @@ static void rgui_free(void *data) if (!rgui) return; - if (rgui->frame_buf) - free(rgui->frame_buf); + if (menu->frame_buf) + free(menu->frame_buf); if (menu->userdata) free(menu->userdata); @@ -596,7 +592,7 @@ static void rgui_set_texture(void *data) return; driver.video_poke->set_texture_frame(driver.video_data, - rgui->frame_buf, false, menu->width, menu->height, 1.0f); + menu->frame_buf, false, menu->width, menu->height, 1.0f); } static void rgui_navigation_clear(void *data, bool pending_push) diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 1afe089026..b473119165 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -106,6 +106,9 @@ typedef struct char default_glslp[PATH_MAX_LENGTH]; char default_cgp[PATH_MAX_LENGTH]; + uint16_t *frame_buf; + size_t frame_buf_pitch; + const uint8_t *font; bool alloc_font; From e8ad0d183b04d1a52821fb91571af900a0b3a14b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 05:09:31 +0100 Subject: [PATCH 029/147] Cleanup color_rect --- menu/drivers/rgui.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 0307425d8f..b36efaeeaf 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -152,16 +152,10 @@ static void color_rect(uint16_t *buf, unsigned pitch, static void blit_line(int x, int y, const char *message, bool green) { unsigned i, j; - rgui_handle_t *rgui = NULL; if (!driver.menu) return; - rgui = (rgui_handle_t*)driver.menu->userdata; - - if (!rgui) - return; - while (*message) { for (j = 0; j < FONT_HEIGHT; j++) From 4d1cc8c2a9d34df3cd87818e0900ecd4efa8f02b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 05:16:19 +0100 Subject: [PATCH 030/147] (RGUI) Cleanups --- menu/drivers/rgui.c | 75 ++++++++++----------------------------------- 1 file changed, 17 insertions(+), 58 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index b36efaeeaf..dd4560bbf5 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -31,11 +31,6 @@ #include "shared.h" -typedef struct rgui_handle -{ - unsigned term_height; -} rgui_handle_t; - #define RGUI_TERM_START_X (driver.menu->width / 21) #define RGUI_TERM_START_Y (driver.menu->height / 9) #define RGUI_TERM_WIDTH (((driver.menu->width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE))) @@ -81,7 +76,7 @@ static void rgui_copy_glyph(uint8_t *glyph, const uint8_t *buf) ((uint32_t)buf[3 * (-y * 256 + x) + 1] << 8) | ((uint32_t)buf[3 * (-y * 256 + x) + 2] << 16); - uint8_t rem = 1 << ((x + y * FONT_WIDTH) & 7); + uint8_t rem = 1 << ((x + y * FONT_WIDTH) & 7); unsigned offset = (x + y * FONT_WIDTH) >> 3; if (col != 0xff) @@ -255,25 +250,20 @@ static void rgui_render_messagebox(const char *message) size_t i; int x, y; unsigned width, glyphs_width, height; - rgui_handle_t *rgui = NULL; struct string_list *list = NULL; if (!driver.menu || !message || !*message) return; - rgui = (rgui_handle_t*)driver.menu->userdata; - - if (!rgui) - return; - list = string_split(message, "\n"); if (!list) return; if (list->elems == 0) goto end; - width = 0; + width = 0; glyphs_width = 0; + for (i = 0; i < list->size; i++) { unsigned line_width; @@ -295,8 +285,8 @@ static void rgui_render_messagebox(const char *message) } height = FONT_HEIGHT_STRIDE * list->size + 6 + 10; - x = (driver.menu->width - width) / 2; - y = (driver.menu->height - height) / 2; + x = (driver.menu->width - width) / 2; + y = (driver.menu->height - height) / 2; fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch, x + 5, y + 5, width - 10, height - 10, gray_filler); @@ -327,13 +317,8 @@ end: static void rgui_blit_cursor(menu_handle_t *menu) { - int16_t x, y; - - if (!menu) - return; - - x = menu->mouse.x; - y = menu->mouse.y; + int16_t x = menu->mouse.x; + int16_t y = menu->mouse.y; color_rect(menu->frame_buf, menu->frame_buf_pitch, x, y-5, 1, 11, 0xFFFF); @@ -349,7 +334,6 @@ static void rgui_render(void) unsigned x, y, menu_type = 0; const char *dir = NULL; const char *label = NULL; - rgui_handle_t *rgui = NULL; const char *core_name = NULL; const char *core_version = NULL; @@ -358,11 +342,6 @@ static void rgui_render(void) && !driver.menu->msg_force) return; - rgui = (rgui_handle_t*)driver.menu->userdata; - - if (!rgui) - return; - driver.menu->mouse.ptr = driver.menu->mouse.y / 11 - 2 + driver.menu->begin; if (driver.menu->mouse.wheeldown && driver.menu->begin @@ -508,11 +487,6 @@ static void *rgui_init(void) if (!menu) return NULL; - menu->userdata = (rgui_handle_t*)calloc(1, sizeof(rgui_handle_t)); - - if (!menu->userdata) - goto error; - menu->frame_buf = (uint16_t*)malloc(400 * 240 * sizeof(uint16_t)); if (!menu->frame_buf) @@ -549,17 +523,11 @@ error: static void rgui_free(void *data) { - rgui_handle_t *rgui = NULL; menu_handle_t *menu = (menu_handle_t*)data; if (!menu) return; - rgui = (rgui_handle_t*)menu->userdata; - - if (!rgui) - return; - if (menu->frame_buf) free(menu->frame_buf); @@ -574,9 +542,8 @@ static void rgui_free(void *data) static void rgui_set_texture(void *data) { menu_handle_t *menu = (menu_handle_t*)data; - rgui_handle_t *rgui = (rgui_handle_t*)menu->userdata; - if (!menu || !rgui) + if (!menu) return; if (!driver.video_data) return; @@ -596,30 +563,22 @@ static void rgui_navigation_clear(void *data, bool pending_push) static void rgui_navigation_set(void *data, bool scroll) { - rgui_handle_t *rgui = NULL; - menu_handle_t *menu = (menu_handle_t*)data; if (!menu) return; - - rgui = (rgui_handle_t*)menu->userdata; - - if (!rgui) - return; - if (!scroll) return; - if (driver.menu->selection_ptr < RGUI_TERM_HEIGHT/2) - driver.menu->begin = 0; - else if (driver.menu->selection_ptr >= RGUI_TERM_HEIGHT/2 - && driver.menu->selection_ptr < - menu_list_get_size(driver.menu->menu_list) - RGUI_TERM_HEIGHT/2) - driver.menu->begin = driver.menu->selection_ptr - RGUI_TERM_HEIGHT/2; - else if (driver.menu->selection_ptr >= - menu_list_get_size(driver.menu->menu_list) - RGUI_TERM_HEIGHT/2) - driver.menu->begin = menu_list_get_size(driver.menu->menu_list) + if (menu->selection_ptr < RGUI_TERM_HEIGHT/2) + menu->begin = 0; + else if (menu->selection_ptr >= RGUI_TERM_HEIGHT/2 + && menu->selection_ptr < + menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT/2) + menu->begin = menu->selection_ptr - RGUI_TERM_HEIGHT/2; + else if (menu->selection_ptr >= + menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT/2) + menu->begin = menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT; } From b658d47c70a70a5b1a3cc8dfc91385c008129be6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 05:23:02 +0100 Subject: [PATCH 031/147] (RGUI) Cleanups --- menu/drivers/rgui.c | 65 +++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 41 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index dd4560bbf5..1abf126289 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -114,41 +114,43 @@ static uint16_t green_filler(unsigned x, unsigned y) #endif } -static void fill_rect(uint16_t *buf, unsigned pitch, +static void fill_rect(menu_handle_t *menu, unsigned x, unsigned y, unsigned width, unsigned height, uint16_t (*col)(unsigned x, unsigned y)) { unsigned i, j; - if (!buf || !col) + if (!menu->frame_buf || !col) return; for (j = y; j < y + height; j++) for (i = x; i < x + width; i++) - buf[j * (pitch >> 1) + i] = col(i, j); + menu->frame_buf[j * (menu->frame_buf_pitch >> 1) + i] = col(i, j); } -static void color_rect(uint16_t *buf, unsigned pitch, + +static void color_rect(menu_handle_t *menu, unsigned x, unsigned y, unsigned width, unsigned height, uint16_t color) { unsigned i, j; - if (!buf) + if (!menu->frame_buf) return; for (j = y; j < y + height; j++) for (i = x; i < x + width; i++) if (i < driver.menu->width && j < driver.menu->height) - buf[j * (pitch >> 1) + i] = color; + menu->frame_buf[j * (menu->frame_buf_pitch >> 1) + i] = color; } static void blit_line(int x, int y, const char *message, bool green) { unsigned i, j; + menu_handle_t *menu = driver.menu; - if (!driver.menu) + if (!menu) return; while (*message) @@ -159,14 +161,14 @@ static void blit_line(int x, int y, const char *message, bool green) { uint8_t rem = 1 << ((i + j * FONT_WIDTH) & 7); int offset = (i + j * FONT_WIDTH) >> 3; - bool col = (driver.menu->font[FONT_OFFSET + bool col = (menu->font[FONT_OFFSET ((unsigned char)*message) + offset] & rem); if (!col) continue; - driver.menu->frame_buf[(y + j) * - (driver.menu->frame_buf_pitch >> 1) + (x + i)] = green ? + menu->frame_buf[(y + j) * + (menu->frame_buf_pitch >> 1) + (x + i)] = green ? #if defined(GEKKO)|| defined(PSP) (3 << 0) | (10 << 4) | (3 << 8) | (7 << 12) : 0x7FFF; #else @@ -227,21 +229,13 @@ static void rgui_render_background(menu_handle_t *menu) if (!menu) return; - fill_rect(menu->frame_buf, menu->frame_buf_pitch, - 0, 0, menu->width, menu->height, gray_filler); - - fill_rect(menu->frame_buf, menu->frame_buf_pitch, - 5, 5, menu->width - 10, 5, green_filler); - - fill_rect(menu->frame_buf, menu->frame_buf_pitch, - 5, menu->height - 10, menu->width - 10, 5, + fill_rect(menu, 0, 0, menu->width, menu->height, gray_filler); + fill_rect(menu, 5, 5, menu->width - 10, 5, green_filler); + fill_rect(menu, 5, menu->height - 10, menu->width - 10, 5, green_filler); - fill_rect(menu->frame_buf, menu->frame_buf_pitch, - 5, 5, 5, menu->height - 10, green_filler); - - fill_rect(menu->frame_buf, menu->frame_buf_pitch, - menu->width - 10, 5, 5, menu->height - 10, + fill_rect(menu, 5, 5, 5, menu->height - 10, green_filler); + fill_rect(menu, menu->width - 10, 5, 5, menu->height - 10, green_filler); } @@ -288,20 +282,11 @@ static void rgui_render_messagebox(const char *message) x = (driver.menu->width - width) / 2; y = (driver.menu->height - height) / 2; - fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch, - x + 5, y + 5, width - 10, height - 10, gray_filler); - - fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch, - x, y, width - 5, 5, green_filler); - - fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch, - x + width - 5, y, 5, height - 5, green_filler); - - fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch, - x + 5, y + height - 5, width - 5, 5, green_filler); - - fill_rect(driver.menu->frame_buf, driver.menu->frame_buf_pitch, - x, y + 5, 5, height - 5, green_filler); + fill_rect(driver.menu, x + 5, y + 5, width - 10, height - 10, gray_filler); + fill_rect(driver.menu, x, y, width - 5, 5, green_filler); + fill_rect(driver.menu, x + width - 5, y, 5, height - 5, green_filler); + fill_rect(driver.menu, x + 5, y + height - 5, width - 5, 5, green_filler); + fill_rect(driver.menu, x, y + 5, 5, height - 5, green_filler); for (i = 0; i < list->size; i++) { @@ -320,10 +305,8 @@ static void rgui_blit_cursor(menu_handle_t *menu) int16_t x = menu->mouse.x; int16_t y = menu->mouse.y; - color_rect(menu->frame_buf, menu->frame_buf_pitch, - x, y-5, 1, 11, 0xFFFF); - color_rect(menu->frame_buf, menu->frame_buf_pitch, - x-5, y, 11, 1, 0xFFFF); + color_rect(driver.menu, x, y - 5, 1, 11, 0xFFFF); + color_rect(driver.menu, x - 5, y, 11, 1, 0xFFFF); } static void rgui_render(void) From e8d21942b40ef3829035671cc2edbae689c6a433 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 05:33:53 +0100 Subject: [PATCH 032/147] (XMB) cleanups --- menu/drivers/xmb.c | 64 +++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index bfd9f6228a..80a4d48bc2 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -143,16 +143,9 @@ static const GLfloat rmb_tex_coord[] = { 1, 0, }; -static float xmb_item_y(int i, size_t current) +static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current) { - float iy; - xmb_handle_t *xmb; - - xmb = (xmb_handle_t*)driver.menu->userdata; - if (!xmb) - return 0; - - iy = xmb->vspacing; + float iy = xmb->vspacing; if (i < current) if (xmb->depth > 1) @@ -229,16 +222,13 @@ static char *xmb_str_replace (const char *string, return newstr; } -static void xmb_draw_icon(GLuint texture, float x, float y, +static void xmb_draw_icon(xmb_handle_t *xmb, + GLuint texture, float x, float y, float alpha, float rotation, float scale_factor) { struct gl_coords coords; math_matrix_4x4 mymat, mrot, mscal; gl_t *gl; - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; - - if (!xmb) - return; if (alpha > xmb->alpha) alpha = xmb->alpha; @@ -487,7 +477,7 @@ static void xmb_selection_pointer_changed(void) if (!node) continue; - iy = xmb_item_y(i, current); + iy = xmb_item_y(xmb, i, current); if (i == current) { @@ -550,9 +540,8 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) if (dir == 1 || dir == -1) node->label_alpha = 0; - node->x = xmb->icon_size*dir*2; - - node->y = xmb_item_y(i, current); + node->x = xmb->icon_size * dir * 2; + node->y = xmb_item_y(xmb, i, current); if (i == current) node->zoom = 1; @@ -834,7 +823,8 @@ static void xmb_populate_entries(void *data, const char *path, xmb_list_switch(); } -static void xmb_draw_items(file_list_t *list, file_list_t *stack, +static void xmb_draw_items(xmb_handle_t *xmb, + file_list_t *list, file_list_t *stack, size_t current, size_t cat_selection_ptr) { unsigned i; @@ -844,9 +834,8 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack, xmb_node_t *core_node = NULL; size_t end = file_list_get_size(list); gl_t *gl = (gl_t*)video_driver_resolve(NULL); - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; - if (!xmb || !list->size || !gl) + if (!list->size || !gl) return; file_list_get_last(stack, &dir, &label, &menu_type); @@ -946,7 +935,7 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack, break; } - xmb_draw_icon(icon, icon_x, icon_y, node->alpha, 0, node->zoom); + xmb_draw_icon(xmb, icon, icon_x, icon_y, node->alpha, 0, node->zoom); menu_ticker_line(name, 35, g_extern.frame_count / 20, path_buf, (i == current)); @@ -981,7 +970,7 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack, 0); if (!strcmp(type_str, "ON") && xmb->textures[XMB_TEXTURE_SWITCH_ON].id) - xmb_draw_icon(xmb->textures[XMB_TEXTURE_SWITCH_ON].id, + xmb_draw_icon(xmb, xmb->textures[XMB_TEXTURE_SWITCH_ON].id, node->x + xmb->margin_left + xmb->hspacing + xmb->icon_size/2.0 + xmb->setting_margin_left, xmb->margin_top + node->y + xmb->icon_size/2.0, @@ -990,7 +979,7 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack, 1); if (!strcmp(type_str, "OFF") && xmb->textures[XMB_TEXTURE_SWITCH_OFF].id) - xmb_draw_icon(xmb->textures[XMB_TEXTURE_SWITCH_OFF].id, + xmb_draw_icon(xmb, xmb->textures[XMB_TEXTURE_SWITCH_OFF].id, node->x + xmb->margin_left + xmb->hspacing + xmb->icon_size/2.0 + xmb->setting_margin_left, xmb->margin_top + node->y + xmb->icon_size/2.0, @@ -1037,7 +1026,7 @@ static void xmb_frame(void) timedate, gl->win_width - xmb->title_margin_left - xmb->icon_size/4, xmb->title_margin_top, 1, 1, 1); - xmb_draw_icon(xmb->textures[XMB_TEXTURE_CLOCK].id, + xmb_draw_icon(xmb, xmb->textures[XMB_TEXTURE_CLOCK].id, gl->win_width - xmb->icon_size, xmb->icon_size, 1, 0, 1); } @@ -1053,20 +1042,21 @@ static void xmb_frame(void) xmb_draw_text(title_msg, xmb->title_margin_left, gl->win_height - xmb->title_margin_bottom, 1, 1, 0); - xmb_draw_icon(xmb->textures[XMB_TEXTURE_ARROW].id, + xmb_draw_icon(xmb, xmb->textures[XMB_TEXTURE_ARROW].id, xmb->x + xmb->margin_left + xmb->hspacing - xmb->icon_size/2.0 + xmb->icon_size, xmb->margin_top + xmb->icon_size/2.0 + xmb->vspacing * xmb->active_item_factor, xmb->arrow_alpha, 0, 1); depth = file_list_get_size(driver.menu->menu_list->menu_stack); - xmb_draw_items( + xmb_draw_items(xmb, xmb->selection_buf_old, xmb->menu_stack_old, xmb->selection_ptr_old, depth > 1 ? driver.menu->cat_selection_ptr : xmb->cat_selection_ptr_old); - xmb_draw_items( + + xmb_draw_items(xmb, driver.menu->menu_list->selection_buf, driver.menu->menu_list->menu_stack, driver.menu->selection_ptr, @@ -1076,15 +1066,13 @@ static void xmb_frame(void) { xmb_node_t *node = i ? xmb_node_for_core(i-1) : &xmb->settings_node; - if (!node) - continue; - - xmb_draw_icon(node->icon, - xmb->x + xmb->categories_x + xmb->margin_left + xmb->hspacing*(i+1) - xmb->icon_size / 2.0, - xmb->margin_top + xmb->icon_size / 2.0, - node->alpha, - 0, - node->zoom); + if (node) + xmb_draw_icon(xmb, node->icon, + xmb->x + xmb->categories_x + xmb->margin_left + xmb->hspacing * (i + 1) - xmb->icon_size / 2.0, + xmb->margin_top + xmb->icon_size / 2.0, + node->alpha, + 0, + node->zoom); } #ifdef GEKKO @@ -1497,7 +1485,7 @@ static void xmb_list_insert(void *data, node->alpha = xmb->i_passive_alpha; node->zoom = xmb->i_passive_zoom; node->label_alpha = node->alpha; - node->y = xmb_item_y(i, current); + node->y = xmb_item_y(xmb, i, current); node->x = 0; if (i == current) From 5eccada700a5311aef7367ef9f8d9e7da8713486 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 05:39:56 +0100 Subject: [PATCH 033/147] (XMB) Cleanups pt. 2 --- menu/drivers/xmb.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 80a4d48bc2..3c1557a144 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -228,7 +228,10 @@ static void xmb_draw_icon(xmb_handle_t *xmb, { struct gl_coords coords; math_matrix_4x4 mymat, mrot, mscal; - gl_t *gl; + gl_t *gl = (gl_t*)video_driver_resolve(NULL); + + if (!gl) + return; if (alpha > xmb->alpha) alpha = xmb->alpha; @@ -236,10 +239,6 @@ static void xmb_draw_icon(xmb_handle_t *xmb, if (alpha == 0) return; - gl = (gl_t*)video_driver_resolve(NULL); - - if (!gl) - return; if ( x < -xmb->icon_size/2 || @@ -282,15 +281,14 @@ static void xmb_draw_icon(xmb_handle_t *xmb, glDisable(GL_BLEND); } -static void xmb_draw_text(const char *str, float x, +static void xmb_draw_text(xmb_handle_t *xmb, const char *str, float x, float y, float scale_factor, float alpha, bool align_right) { - gl_t *gl = NULL; uint8_t a8 = 0; struct font_params params = {0}; - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; + gl_t *gl = (gl_t*)video_driver_resolve(NULL); - if (!xmb) + if (!gl) return; if (alpha > xmb->alpha) @@ -301,11 +299,6 @@ static void xmb_draw_text(const char *str, float x, if (a8 == 0) return; - gl = (gl_t*)video_driver_resolve(NULL); - - if (!gl) - return; - if (x < -xmb->icon_size || x > gl->win_width + xmb->icon_size || y < -xmb->icon_size || y > gl->win_height + xmb->icon_size) return; @@ -448,7 +441,7 @@ static void xmb_render_messagebox(const char *message) const char *msg = list->elems[i].data; if (msg) - xmb_draw_text(msg, x, y + i * xmb->font_size, 1, 1, 0); + xmb_draw_text(xmb, msg, x, y + i * xmb->font_size, 1, 1, 0); } string_list_free(list); @@ -940,7 +933,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, menu_ticker_line(name, 35, g_extern.frame_count / 20, path_buf, (i == current)); - xmb_draw_text(name, + xmb_draw_text(xmb, name, node->x + xmb->margin_left + xmb->hspacing + xmb->label_margin_left, xmb->margin_top + node->y + xmb->label_margin_top, 1, node->label_alpha, 0); @@ -961,7 +954,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, && !xmb->textures[XMB_TEXTURE_SWITCH_ON].id) || (!strcmp(type_str, "OFF") && !xmb->textures[XMB_TEXTURE_SWITCH_OFF].id))) - xmb_draw_text(value, + xmb_draw_text(xmb, value, node->x + xmb->margin_left + xmb->hspacing + xmb->label_margin_left + xmb->setting_margin_left, xmb->margin_top + node->y + xmb->label_margin_top, @@ -1015,14 +1008,14 @@ static void xmb_frame(void) if (!core_name) core_name = "No Core"; - xmb_draw_text( + xmb_draw_text(xmb, xmb->title, xmb->title_margin_left, xmb->title_margin_top, 1, 1, 0); disp_timedate_set_label(timedate, sizeof(timedate), 0); if (g_settings.menu.timedate_enable) { - xmb_draw_text( + xmb_draw_text(xmb, timedate, gl->win_width - xmb->title_margin_left - xmb->icon_size/4, xmb->title_margin_top, 1, 1, 1); @@ -1039,7 +1032,7 @@ static void xmb_frame(void) snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION, core_name, core_version); - xmb_draw_text(title_msg, xmb->title_margin_left, + xmb_draw_text(xmb, title_msg, xmb->title_margin_left, gl->win_height - xmb->title_margin_bottom, 1, 1, 0); xmb_draw_icon(xmb, xmb->textures[XMB_TEXTURE_ARROW].id, From ed4d8d5acfa48bcf1d2c9306f640c957df5fcdb3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 05:43:42 +0100 Subject: [PATCH 034/147] (XMB) Cleanups pt. 3 --- menu/drivers/xmb.c | 62 ++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 43 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 3c1557a144..8ce61cdc1a 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -222,16 +222,12 @@ static char *xmb_str_replace (const char *string, return newstr; } -static void xmb_draw_icon(xmb_handle_t *xmb, +static void xmb_draw_icon(gl_t *gl, xmb_handle_t *xmb, GLuint texture, float x, float y, float alpha, float rotation, float scale_factor) { struct gl_coords coords; math_matrix_4x4 mymat, mrot, mscal; - gl_t *gl = (gl_t*)video_driver_resolve(NULL); - - if (!gl) - return; if (alpha > xmb->alpha) alpha = xmb->alpha; @@ -239,7 +235,6 @@ static void xmb_draw_icon(xmb_handle_t *xmb, if (alpha == 0) return; - if ( x < -xmb->icon_size/2 || x > gl->win_width || @@ -281,15 +276,11 @@ static void xmb_draw_icon(xmb_handle_t *xmb, glDisable(GL_BLEND); } -static void xmb_draw_text(xmb_handle_t *xmb, const char *str, float x, +static void xmb_draw_text(gl_t *gl, xmb_handle_t *xmb, const char *str, float x, float y, float scale_factor, float alpha, bool align_right) { uint8_t a8 = 0; struct font_params params = {0}; - gl_t *gl = (gl_t*)video_driver_resolve(NULL); - - if (!gl) - return; if (alpha > xmb->alpha) alpha = xmb->alpha; @@ -319,12 +310,11 @@ static void xmb_draw_text(xmb_handle_t *xmb, const char *str, float x, str, ¶ms, xmb->font); } -static void xmb_render_background(bool force_transparency) +static void xmb_render_background(gl_t *gl, xmb_handle_t *xmb, + bool force_transparency) { struct gl_coords coords; float alpha = 0.75f; - gl_t *gl = NULL; - xmb_handle_t *xmb = NULL; static const GLfloat vertex[] = { 0, 0, 1, 0, @@ -339,14 +329,6 @@ static void xmb_render_background(bool force_transparency) 1, 0, }; - if (!driver.menu) - return; - - xmb = (xmb_handle_t*)driver.menu->userdata; - - if (!xmb) - return; - GLfloat color[] = { 1.0f, 1.0f, 1.0f, xmb->alpha, 1.0f, 1.0f, 1.0f, xmb->alpha, @@ -364,14 +346,8 @@ static void xmb_render_background(bool force_transparency) 0.0f, 0.0f, 0.0f, alpha, }; - gl = (gl_t*)video_driver_resolve(NULL); - - if (!gl) - return; - glViewport(0, 0, gl->win_width, gl->win_height); - coords.vertices = 4; coords.vertex = vertex; coords.tex_coord = tex_coord; @@ -441,7 +417,7 @@ static void xmb_render_messagebox(const char *message) const char *msg = list->elems[i].data; if (msg) - xmb_draw_text(xmb, msg, x, y + i * xmb->font_size, 1, 1, 0); + xmb_draw_text(gl, xmb, msg, x, y + i * xmb->font_size, 1, 1, 0); } string_list_free(list); @@ -928,12 +904,12 @@ static void xmb_draw_items(xmb_handle_t *xmb, break; } - xmb_draw_icon(xmb, icon, icon_x, icon_y, node->alpha, 0, node->zoom); + xmb_draw_icon(gl, xmb, icon, icon_x, icon_y, node->alpha, 0, node->zoom); menu_ticker_line(name, 35, g_extern.frame_count / 20, path_buf, (i == current)); - xmb_draw_text(xmb, name, + xmb_draw_text(gl, xmb, name, node->x + xmb->margin_left + xmb->hspacing + xmb->label_margin_left, xmb->margin_top + node->y + xmb->label_margin_top, 1, node->label_alpha, 0); @@ -954,7 +930,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, && !xmb->textures[XMB_TEXTURE_SWITCH_ON].id) || (!strcmp(type_str, "OFF") && !xmb->textures[XMB_TEXTURE_SWITCH_OFF].id))) - xmb_draw_text(xmb, value, + xmb_draw_text(gl, xmb, value, node->x + xmb->margin_left + xmb->hspacing + xmb->label_margin_left + xmb->setting_margin_left, xmb->margin_top + node->y + xmb->label_margin_top, @@ -963,7 +939,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, 0); if (!strcmp(type_str, "ON") && xmb->textures[XMB_TEXTURE_SWITCH_ON].id) - xmb_draw_icon(xmb, xmb->textures[XMB_TEXTURE_SWITCH_ON].id, + xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_SWITCH_ON].id, node->x + xmb->margin_left + xmb->hspacing + xmb->icon_size/2.0 + xmb->setting_margin_left, xmb->margin_top + node->y + xmb->icon_size/2.0, @@ -972,7 +948,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, 1); if (!strcmp(type_str, "OFF") && xmb->textures[XMB_TEXTURE_SWITCH_OFF].id) - xmb_draw_icon(xmb, xmb->textures[XMB_TEXTURE_SWITCH_OFF].id, + xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_SWITCH_OFF].id, node->x + xmb->margin_left + xmb->hspacing + xmb->icon_size/2.0 + xmb->setting_margin_left, xmb->margin_top + node->y + xmb->icon_size/2.0, @@ -999,7 +975,7 @@ static void xmb_frame(void) glViewport(0, 0, gl->win_width, gl->win_height); - xmb_render_background(false); + xmb_render_background(gl, xmb, false); core_name = g_extern.menu.info.library_name; @@ -1008,18 +984,18 @@ static void xmb_frame(void) if (!core_name) core_name = "No Core"; - xmb_draw_text(xmb, + xmb_draw_text(gl, xmb, xmb->title, xmb->title_margin_left, xmb->title_margin_top, 1, 1, 0); disp_timedate_set_label(timedate, sizeof(timedate), 0); if (g_settings.menu.timedate_enable) { - xmb_draw_text(xmb, + xmb_draw_text(gl, xmb, timedate, gl->win_width - xmb->title_margin_left - xmb->icon_size/4, xmb->title_margin_top, 1, 1, 1); - xmb_draw_icon(xmb, xmb->textures[XMB_TEXTURE_CLOCK].id, + xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_CLOCK].id, gl->win_width - xmb->icon_size, xmb->icon_size, 1, 0, 1); } @@ -1032,10 +1008,10 @@ static void xmb_frame(void) snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION, core_name, core_version); - xmb_draw_text(xmb, title_msg, xmb->title_margin_left, + xmb_draw_text(gl, xmb, title_msg, xmb->title_margin_left, gl->win_height - xmb->title_margin_bottom, 1, 1, 0); - xmb_draw_icon(xmb, xmb->textures[XMB_TEXTURE_ARROW].id, + xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_ARROW].id, xmb->x + xmb->margin_left + xmb->hspacing - xmb->icon_size/2.0 + xmb->icon_size, xmb->margin_top + xmb->icon_size/2.0 + xmb->vspacing * xmb->active_item_factor, xmb->arrow_alpha, 0, 1); @@ -1060,7 +1036,7 @@ static void xmb_frame(void) xmb_node_t *node = i ? xmb_node_for_core(i-1) : &xmb->settings_node; if (node) - xmb_draw_icon(xmb, node->icon, + xmb_draw_icon(gl, xmb, node->icon, xmb->x + xmb->categories_x + xmb->margin_left + xmb->hspacing * (i + 1) - xmb->icon_size / 2.0, xmb->margin_top + xmb->icon_size / 2.0, node->alpha, @@ -1091,13 +1067,13 @@ static void xmb_frame(void) str = ""; snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str); - xmb_render_background(true); + xmb_render_background(gl, xmb, true); xmb_render_messagebox(msg); } if (xmb->box_message[0] != '\0') { - xmb_render_background(true); + xmb_render_background(gl, xmb, true); xmb_render_messagebox(xmb->box_message); xmb->box_message[0] = '\0'; } From 44d540eb3ecf7da84d689d80d4e0d718506687ad Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 05:50:37 +0100 Subject: [PATCH 035/147] (GLUI) Cleanups --- menu/drivers/glui.c | 52 ++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 38 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index bab1f4d905..7c0cd193b9 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -60,13 +60,9 @@ static int glui_entry_iterate(unsigned action) return -1; } -static void glui_blit_line(float x, float y, const char *message, bool green) +static void glui_blit_line(gl_t *gl, float x, float y, const char *message, bool green) { struct font_params params = {0}; - gl_t *gl = (gl_t*)video_driver_resolve(NULL); - - if (!driver.menu || !gl) - return; gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); @@ -90,7 +86,8 @@ static void glui_blit_line(float x, float y, const char *message, bool green) message, ¶ms, NULL); } -static void glui_render_background(bool force_transparency) +static void glui_render_background(gl_t *gl, glui_handle_t *glui, + bool force_transparency) { static const GLfloat vertex[] = { 0, 0, @@ -107,8 +104,6 @@ static void glui_render_background(bool force_transparency) }; struct gl_coords coords; float alpha = 0.75f; - gl_t *gl = NULL; - glui_handle_t *glui = NULL; GLfloat color[] = { 1.0f, 1.0f, 1.0f, alpha, 1.0f, 1.0f, 1.0f, alpha, @@ -123,19 +118,6 @@ static void glui_render_background(bool force_transparency) 0.0f, 0.0f, 0.0f, alpha, }; - if (!driver.menu) - return; - - glui = (glui_handle_t*)driver.menu->userdata; - - if (!glui) - return; - - gl = (gl_t*)video_driver_resolve(NULL); - - if (!gl) - return; - glViewport(0, 0, gl->win_width, gl->win_height); coords.vertices = 4; @@ -168,7 +150,7 @@ static void glui_render_background(bool force_transparency) gl->coords.color = gl->white_color_ptr; } -static void glui_draw_cursor(float x, float y) +static void glui_draw_cursor(gl_t *gl, float x, float y) { static const GLfloat vertex[] = { 0, 0, @@ -190,7 +172,6 @@ static void glui_draw_cursor(float x, float y) 1.0f, 1.0f, 1.0f, 1.0f, }; struct gl_coords coords; - gl_t *gl = NULL; glui_handle_t *glui = NULL; if (!driver.menu) @@ -201,11 +182,6 @@ static void glui_draw_cursor(float x, float y) if (!glui) return; - gl = (gl_t*)video_driver_resolve(NULL); - - if (!gl) - return; - glViewport(x - 5, gl->win_height - y, 11, 11); coords.vertices = 4; @@ -271,7 +247,7 @@ static void glui_render_messagebox(const char *message) { const char *msg = list->elems[i].data; if (msg) - glui_blit_line(x, y + i * glui->line_height, msg, false); + glui_blit_line(gl, x, y + i * glui->line_height, msg, false); } end: @@ -334,7 +310,7 @@ static void glui_frame(void) driver.menu->begin + glui->term_height : menu_list_get_size(driver.menu->menu_list); - glui_render_background(false); + glui_render_background(gl, glui, false); menu_list_get_last_stack(driver.menu->menu_list, &dir, &label, &menu_type); @@ -342,7 +318,7 @@ static void glui_frame(void) menu_ticker_line(title_buf, glui->term_width - 3, g_extern.frame_count / glui->margin, title, true); - glui_blit_line(glui->margin * 2, glui->margin + glui->line_height, + glui_blit_line(gl, glui->margin * 2, glui->margin + glui->line_height, title_buf, true); core_name = g_extern.menu.info.library_name; @@ -362,13 +338,13 @@ static void glui_frame(void) disp_timedate_set_label(timedate, sizeof(timedate), 0); - glui_blit_line( + glui_blit_line(gl, glui->margin * 2, glui->margin + glui->term_height * glui->line_height + glui->line_height * 2, title_msg, true); if (g_settings.menu.timedate_enable) - glui_blit_line( + glui_blit_line(gl, glui->margin * 14, glui->margin + glui->term_height * glui->line_height + glui->line_height * 2, timedate, true); @@ -410,9 +386,9 @@ static void glui_frame(void) strlcpy(message, entry_title_buf, sizeof(message)); - glui_blit_line(x, y, message, selected); + glui_blit_line(gl, x, y, message, selected); - glui_blit_line(gl->win_width - glui->glyph_width * w - glui->margin , + glui_blit_line(gl, gl->win_width - glui->glyph_width * w - glui->margin , y, type_str_buf, selected); } @@ -436,20 +412,20 @@ static void glui_frame(void) const char *str = *driver.menu->keyboard.buffer; if (!str) str = ""; - glui_render_background(true); + glui_render_background(gl, glui, true); snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str); glui_render_messagebox(msg); } if (glui->box_message[0] != '\0') { - glui_render_background(true); + glui_render_background(gl, glui, true); glui_render_messagebox(glui->box_message); glui->box_message[0] = '\0'; } if (driver.menu->mouse.enable) - glui_draw_cursor(driver.menu->mouse.x, driver.menu->mouse.y); + glui_draw_cursor(gl, driver.menu->mouse.x, driver.menu->mouse.y); gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); } From 56aa3ddb5c5968ed0ffd32bcc12a41baa4b28bba Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 05:55:36 +0100 Subject: [PATCH 036/147] (GLUI) Cleanups --- menu/drivers/glui.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 7c0cd193b9..dc3188a538 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -150,8 +150,9 @@ static void glui_render_background(gl_t *gl, glui_handle_t *glui, gl->coords.color = gl->white_color_ptr; } -static void glui_draw_cursor(gl_t *gl, float x, float y) +static void glui_draw_cursor(gl_t *gl, glui_handle_t *glui, float x, float y) { + struct gl_coords coords; static const GLfloat vertex[] = { 0, 0, 1, 0, @@ -171,16 +172,6 @@ static void glui_draw_cursor(gl_t *gl, float x, float y) 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, }; - struct gl_coords coords; - glui_handle_t *glui = NULL; - - if (!driver.menu) - return; - - glui = (glui_handle_t*)driver.menu->userdata; - - if (!glui) - return; glViewport(x - 5, gl->win_height - y, 11, 11); @@ -425,7 +416,7 @@ static void glui_frame(void) } if (driver.menu->mouse.enable) - glui_draw_cursor(gl, driver.menu->mouse.x, driver.menu->mouse.y); + glui_draw_cursor(gl, glui, driver.menu->mouse.x, driver.menu->mouse.y); gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); } From d8a0126203f3d0e6920253b11bdae8f5ffe5e5d3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 06:05:27 +0100 Subject: [PATCH 037/147] (XMB) Cleanups to xmb_draw_items --- menu/drivers/xmb.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 8ce61cdc1a..74dc6371fd 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -792,7 +792,7 @@ static void xmb_populate_entries(void *data, const char *path, xmb_list_switch(); } -static void xmb_draw_items(xmb_handle_t *xmb, +static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, file_list_t *list, file_list_t *stack, size_t current, size_t cat_selection_ptr) { @@ -802,9 +802,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, unsigned menu_type = 0; xmb_node_t *core_node = NULL; size_t end = file_list_get_size(list); - gl_t *gl = (gl_t*)video_driver_resolve(NULL); - if (!list->size || !gl) + if (!list->size) return; file_list_get_last(stack, &dir, &label, &menu_type); @@ -1018,14 +1017,14 @@ static void xmb_frame(void) depth = file_list_get_size(driver.menu->menu_list->menu_stack); - xmb_draw_items(xmb, + xmb_draw_items(xmb, gl, xmb->selection_buf_old, xmb->menu_stack_old, xmb->selection_ptr_old, depth > 1 ? driver.menu->cat_selection_ptr : xmb->cat_selection_ptr_old); - xmb_draw_items(xmb, + xmb_draw_items(xmb, gl, driver.menu->menu_list->selection_buf, driver.menu->menu_list->menu_stack, driver.menu->selection_ptr, From d85a8d5452fbedafaa22b9472720f303746b4132 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 06:11:25 +0100 Subject: [PATCH 038/147] (XMB) Cleanups pt. 2 --- menu/drivers/xmb.c | 50 ++++++++++++---------------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 74dc6371fd..9d34423836 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -461,13 +461,9 @@ static void xmb_selection_pointer_changed(void) } } -static void xmb_list_open_old(file_list_t *list, int dir, size_t current) +static void xmb_list_open_old(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; - - if (!xmb) - return; for (i = 0; i < file_list_get_size(list); i++) { @@ -488,13 +484,9 @@ static void xmb_list_open_old(file_list_t *list, int dir, size_t current) } } -static void xmb_list_open_new(file_list_t *list, int dir, size_t current) +static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; - - if (!xmb) - return; for (i = 0; i < file_list_get_size(list); i++) { @@ -586,20 +578,16 @@ static xmb_node_t* xmb_node_for_core(int i) return node; } -static void xmb_list_switch_old(file_list_t *list, int dir, size_t current) +static void xmb_list_switch_old(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; - - if (!xmb) - return; for (i = 0; i < file_list_get_size(list); i++) { xmb_node_t *node = (xmb_node_t*) file_list_get_userdata_at_offset(list, i); - if (!xmb) + if (!node) continue; menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->alpha, EASING_IN_OUT_QUAD, NULL); @@ -608,13 +596,9 @@ static void xmb_list_switch_old(file_list_t *list, int dir, size_t current) } } -static void xmb_list_switch_new(file_list_t *list, int dir, size_t current) +static void xmb_list_switch_new(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; - - if (!xmb) - return; for (i = 0; i < file_list_get_size(list); i++) { @@ -669,14 +653,10 @@ static void xmb_set_title(void) } } -static void xmb_list_open(void) +static void xmb_list_open(xmb_handle_t *xmb) { unsigned j; int dir = -1; - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; - - if (!xmb) - return; if (driver.menu->cat_selection_ptr > xmb->cat_selection_ptr_old) dir = 1; @@ -710,19 +690,15 @@ static void xmb_list_open(void) if (driver.menu->cat_selection_ptr > xmb->cat_selection_ptr_old) dir = 1; - xmb_list_switch_old(xmb->selection_buf_old, dir, xmb->selection_ptr_old); - xmb_list_switch_new(driver.menu->menu_list->selection_buf, dir, driver.menu->selection_ptr); + xmb_list_switch_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); + xmb_list_switch_new(xmb, driver.menu->menu_list->selection_buf, dir, driver.menu->selection_ptr); xmb->active_category_old = driver.menu->cat_selection_ptr; } -static void xmb_list_switch(void) +static void xmb_list_switch(xmb_handle_t *xmb) { unsigned j; int dir = 0; - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; - - if (!xmb) - return; xmb->depth = file_list_get_size(driver.menu->menu_list->menu_stack); @@ -748,8 +724,8 @@ static void xmb_list_switch(void) &node->alpha, EASING_IN_OUT_QUAD, NULL); } - xmb_list_open_old(xmb->selection_buf_old, dir, xmb->selection_ptr_old); - xmb_list_open_new(driver.menu->menu_list->selection_buf, dir, driver.menu->selection_ptr); + xmb_list_open_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); + xmb_list_open_new(xmb, driver.menu->menu_list->selection_buf, dir, driver.menu->selection_ptr); switch (xmb->depth) { @@ -787,9 +763,9 @@ static void xmb_populate_entries(void *data, const char *path, xmb_set_title(); if (driver.menu->cat_selection_ptr != xmb->active_category_old) - xmb_list_open(); + xmb_list_open(xmb); else - xmb_list_switch(); + xmb_list_switch(xmb); } static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, From cc9d5dae28e6f7f9c82bbb614e5122ef28f6ef8e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 06:15:15 +0100 Subject: [PATCH 039/147] (XMB) Cleanups pt. 3 --- menu/drivers/xmb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 9d34423836..7792bd66e4 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -512,7 +512,7 @@ static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, siz float ia; xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); - if (!xmb) + if (!node) continue; ia = xmb->i_passive_alpha; @@ -606,7 +606,7 @@ static void xmb_list_switch_new(xmb_handle_t *xmb, file_list_t *list, int dir, s xmb_node_t *node = (xmb_node_t*) file_list_get_userdata_at_offset(list, i); - if (!xmb) + if (!node) continue; node->x = xmb->hspacing * dir; From 1c4d628498168589679273bdb8defa34b4cda6e4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 06:21:03 +0100 Subject: [PATCH 040/147] (XMB) Cleanups pt. 4 --- menu/drivers/xmb.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 7792bd66e4..189532a9b9 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -527,18 +527,11 @@ static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, siz xmb->old_depth = xmb->depth; } -static xmb_node_t* xmb_node_for_core(int i) +static xmb_node_t* xmb_node_for_core(xmb_handle_t *xmb, int i) { core_info_t *info = NULL; - core_info_list_t *info_list = NULL; xmb_node_t *node = NULL; - - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; - - if (!xmb) - return NULL; - - info_list = (core_info_list_t*)g_extern.core_info; + core_info_list_t *info_list = (core_info_list_t*)g_extern.core_info; if (!info_list) return NULL; @@ -622,13 +615,8 @@ static void xmb_list_switch_new(xmb_handle_t *xmb, file_list_t *list, int dir, s } } -static void xmb_set_title(void) +static void xmb_set_title(xmb_handle_t *xmb) { - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; - - if (!xmb) - return; - if (driver.menu->cat_selection_ptr == 0) { const char *dir = NULL; @@ -667,7 +655,7 @@ static void xmb_list_open(xmb_handle_t *xmb) { float ia = xmb->c_passive_alpha; float iz = xmb->c_passive_zoom; - xmb_node_t *node = j ? xmb_node_for_core(j-1) : &xmb->settings_node; + xmb_node_t *node = j ? xmb_node_for_core(xmb, j - 1) : &xmb->settings_node; if (!node) continue; @@ -710,7 +698,7 @@ static void xmb_list_switch(xmb_handle_t *xmb) for (j = 0; j < driver.menu->num_categories; j++) { float ia = 0; - xmb_node_t *node = j ? xmb_node_for_core(j-1) : &xmb->settings_node; + xmb_node_t *node = j ? xmb_node_for_core(xmb, j - 1) : &xmb->settings_node; if (!node) continue; @@ -760,7 +748,7 @@ static void xmb_populate_entries(void *data, const char *path, return; } - xmb_set_title(); + xmb_set_title(xmb); if (driver.menu->cat_selection_ptr != xmb->active_category_old) xmb_list_open(xmb); @@ -785,7 +773,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, file_list_get_last(stack, &dir, &label, &menu_type); if (xmb->active_category) - core_node = xmb_node_for_core(cat_selection_ptr - 1); + core_node = xmb_node_for_core(xmb, cat_selection_ptr - 1); for (i = 0; i < end; i++) { @@ -1008,7 +996,7 @@ static void xmb_frame(void) for (i = 0; i < driver.menu->num_categories; i++) { - xmb_node_t *node = i ? xmb_node_for_core(i-1) : &xmb->settings_node; + xmb_node_t *node = i ? xmb_node_for_core(xmb, i - 1) : &xmb->settings_node; if (node) xmb_draw_icon(gl, xmb, node->icon, @@ -1299,7 +1287,7 @@ static void xmb_context_reset(void *data) for (i = 1; i < driver.menu->num_categories; i++) { - node = xmb_node_for_core(i-1); + node = xmb_node_for_core(xmb, i - 1); fill_pathname_join(mediapath, g_settings.assets_directory, "lakka", sizeof(mediapath)); @@ -1525,7 +1513,7 @@ static void xmb_context_destroy(void *data) for (i = 1; i < driver.menu->num_categories; i++) { - xmb_node_t *node = xmb_node_for_core(i-1); + xmb_node_t *node = xmb_node_for_core(xmb, i - 1); if (!node) continue; @@ -1564,7 +1552,7 @@ static void xmb_toggle(bool menu_on) for (i = 0; i < driver.menu->num_categories; i++) { - xmb_node_t *node = i ? xmb_node_for_core(i-1) : &xmb->settings_node; + xmb_node_t *node = i ? xmb_node_for_core(xmb, i - 1) : &xmb->settings_node; if (!node) continue; From b20ab24fa22a1dbe87377113b665dd880844105a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 06:22:00 +0100 Subject: [PATCH 041/147] (XMB) Cleanups pt. 5 --- menu/drivers/xmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 189532a9b9..c96a8198ea 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -492,7 +492,7 @@ static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, siz { xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); - if (!xmb) + if (!node) continue; if (dir == 1 || (dir == -1 && i != current)) From a687907bde8db835c747c1df68e9c3eb39ae849f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 06:27:28 +0100 Subject: [PATCH 042/147] Cleanup xmb_render_messagebox --- menu/drivers/xmb.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c96a8198ea..ab263c8333 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -404,10 +404,7 @@ static void xmb_render_messagebox(const char *message) return; if (list->elems == 0) - { - string_list_free(list); - return; - } + goto end; x = gl->win_width / 2 - strlen(list->elems[0].data) * xmb->font_size / 4; y = gl->win_height / 2 - list->size * xmb->font_size / 2; @@ -420,6 +417,7 @@ static void xmb_render_messagebox(const char *message) xmb_draw_text(gl, xmb, msg, x, y + i * xmb->font_size, 1, 1, 0); } +end: string_list_free(list); } From 37d9661846e4004ade88ae83e3da37d404b57800 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 06:34:30 +0100 Subject: [PATCH 043/147] (XMB/GLUI) Cleanups --- menu/drivers/glui.c | 21 +++++++++++---------- menu/drivers/xmb.c | 45 ++++++++++++++++----------------------------- 2 files changed, 27 insertions(+), 39 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index dc3188a538..fb6aeb2a1e 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -498,7 +498,8 @@ static void glui_context_reset(void *data) static void glui_navigation_clear(void *data, bool pending_push) { - driver.menu->begin = 0; + if (driver.menu) + driver.menu->begin = 0; } static void glui_navigation_set(void *data, bool scroll) @@ -518,15 +519,15 @@ static void glui_navigation_set(void *data, bool scroll) if (!scroll) return; - if (driver.menu->selection_ptr < glui->term_height/2) - driver.menu->begin = 0; - else if (driver.menu->selection_ptr >= glui->term_height/2 - && driver.menu->selection_ptr < - menu_list_get_size(driver.menu->menu_list) - glui->term_height/2) - driver.menu->begin = driver.menu->selection_ptr - glui->term_height/2; - else if (driver.menu->selection_ptr >= - menu_list_get_size(driver.menu->menu_list) - glui->term_height/2) - driver.menu->begin = menu_list_get_size(driver.menu->menu_list) + if (menu->selection_ptr < glui->term_height/2) + menu->begin = 0; + else if (menu->selection_ptr >= glui->term_height/2 + && menu->selection_ptr < + menu_list_get_size(menu->menu_list) - glui->term_height/2) + menu->begin = menu->selection_ptr - glui->term_height/2; + else if (menu->selection_ptr >= + menu_list_get_size(menu->menu_list) - glui->term_height/2) + menu->begin = menu_list_get_size(menu->menu_list) - glui->term_height; } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index ab263c8333..c7f1af7b16 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -421,17 +421,17 @@ end: string_list_free(list); } -static void xmb_selection_pointer_changed(void) +static void xmb_selection_pointer_changed(menu_handle_t *menu) { int i; unsigned current, end; - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; + xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata; if (!xmb) return; - current = driver.menu->selection_ptr; - end = menu_list_get_size(driver.menu->menu_list); + current = menu->selection_ptr; + end = menu_list_get_size(menu->menu_list); for (i = 0; i < end; i++) { @@ -439,7 +439,7 @@ static void xmb_selection_pointer_changed(void) float ia = xmb->i_passive_alpha; float iz = xmb->i_passive_zoom; xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( - driver.menu->menu_list->selection_buf, i); + menu->menu_list->selection_buf, i); if (!node) continue; @@ -452,10 +452,10 @@ static void xmb_selection_pointer_changed(void) iz = xmb->i_active_zoom; } - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, iz, &node->zoom, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, iy, &node->y, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, iz, &node->zoom, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, iy, &node->y, EASING_IN_OUT_QUAD, NULL); } } @@ -1335,55 +1335,42 @@ static void xmb_context_reset(void *data) static void xmb_navigation_clear(void *data, bool pending_push) { - (void)data; - if (!pending_push) - xmb_selection_pointer_changed(); + xmb_selection_pointer_changed(data); } static void xmb_navigation_decrement(void *data) { - (void)data; - - xmb_selection_pointer_changed(); + xmb_selection_pointer_changed(data); } static void xmb_navigation_increment(void *data) { - (void)data; - - xmb_selection_pointer_changed(); + xmb_selection_pointer_changed(data); } static void xmb_navigation_set(void *data, bool scroll) { - (void)data; (void)scroll; - xmb_selection_pointer_changed(); + xmb_selection_pointer_changed(data); } static void xmb_navigation_set_last(void *data) { - (void)data; - - xmb_selection_pointer_changed(); + xmb_selection_pointer_changed(data); } static void xmb_navigation_descend_alphabet(void *data, size_t *unused) { - (void)data; (void)unused; - - xmb_selection_pointer_changed(); + xmb_selection_pointer_changed(data); } static void xmb_navigation_ascend_alphabet(void *data, size_t *unused) { - (void)data; (void)unused; - - xmb_selection_pointer_changed(); + xmb_selection_pointer_changed(data); } static void xmb_list_insert(void *data, From 3b2e11c446b0cdc3f162c44da56272dbed018859 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 06:44:16 +0100 Subject: [PATCH 044/147] (udev_joypad.c) Cleanup --- input/drivers_joypad/udev_joypad.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c index 288074b6cc..f28aa04442 100644 --- a/input/drivers_joypad/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -85,11 +85,10 @@ static inline int16_t compute_axis(const struct input_absinfo *info, int value) return axis; } -static void udev_poll_pad(unsigned p) +static void udev_poll_pad(struct udev_joypad *pad, unsigned p) { int i, len; struct input_event events[32]; - struct udev_joypad *pad = (struct udev_joypad*)&udev_pads[p]; if (pad->fd < 0) return; @@ -268,7 +267,7 @@ static void udev_joypad_poll(void) handle_hotplug(); for (i = 0; i < MAX_USERS; i++) - udev_poll_pad(i); + udev_poll_pad(&udev_pads[i], i); } #define test_bit(nr, addr) \ From cf57120fdd29629a98de6dc55040384312a10253 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 06:59:19 +0100 Subject: [PATCH 045/147] (RMenu) Cleanups --- menu/drivers/rmenu.c | 7 +++---- menu/drivers/rmenu_xui.cpp | 28 +++++++++++----------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index eadce12fb3..4ac8d7ef86 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -101,10 +101,7 @@ static void rmenu_render_messagebox(const char *message) return; if (list->elems == 0) - { - string_list_free(list); - return; - } + goto end; j = 0; @@ -134,6 +131,8 @@ static void rmenu_render_messagebox(const char *message) } render_normal = false; +end: + string_list_free(list); } static void rmenu_render(void) diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index 562ae0fa72..2648523c5e 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -374,33 +374,24 @@ static void xui_render_message(const char *msg) struct font_params font_parms; size_t i = 0; size_t j = 0; - - struct string_list *list = string_split(msg, "\n"); + struct string_list *list = NULL; d3d_video_t *d3d = (d3d_video_t*)driver.video_data; + if (!d3d) + return; + + list = string_split(msg, "\n"); + if (!list) return; - if (!d3d || list->elems == 0) - { - string_list_free(list); - return; - } + if (list->elems == 0) + goto end; for (i = 0; i < list->size; i++, j++) { char *msg = (char*)list->elems[i].data; unsigned msglen = strlen(msg); - #if 0 - if (msglen > RMENU_TERM_WIDTH) - { - msg[RMENU_TERM_WIDTH - 2] = '.'; - msg[RMENU_TERM_WIDTH - 1] = '.'; - msg[RMENU_TERM_WIDTH - 0] = '.'; - msg[RMENU_TERM_WIDTH + 1] = '\0'; - msglen = RMENU_TERM_WIDTH; - } - #endif float msg_width = d3d->resolution_hd_enable ? 160 : 100; float msg_height = 120; float msg_offset = 32; @@ -413,6 +404,9 @@ static void xui_render_message(const char *msg) driver.video_poke->set_osd_msg(driver.video_data, msg, &font_parms, NULL); } + +end: + string_list_free(list); } static void rmenu_xui_frame(void) From 3d83c1fa752387254beeaa8e8680ac89e6d787d6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 07:02:12 +0100 Subject: [PATCH 046/147] Free menu->frame_buf in menu_free --- menu/drivers/rgui.c | 3 --- menu/menu.c | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 1abf126289..3515e01424 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -511,9 +511,6 @@ static void rgui_free(void *data) if (!menu) return; - if (menu->frame_buf) - free(menu->frame_buf); - if (menu->userdata) free(menu->userdata); driver.menu->userdata = NULL; diff --git a/menu/menu.c b/menu/menu.c index e92ed670e1..80913a4d5b 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -257,6 +257,10 @@ void menu_free(void *data) menu_animation_free(menu->animation); menu->animation = NULL; + if (menu->frame_buf) + free(menu->frame_buf); + menu->frame_buf = NULL; + menu_list_free(menu->menu_list); menu->menu_list = NULL; From 18aefdd83ba788c622304fe66f8605d398228792 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 07:12:21 +0100 Subject: [PATCH 047/147] Rename rnpg_image_load_tga_shift --- gfx/image/image_rpng.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/gfx/image/image_rpng.c b/gfx/image/image_rpng.c index cf2aed2647..e548d82de2 100644 --- a/gfx/image/image_rpng.c +++ b/gfx/image/image_rpng.c @@ -27,31 +27,20 @@ #include "../../general.h" #include -static bool rpng_image_load_tga_shift(const char *path, +static bool rtga_image_load_shift(uint8_t *buf, struct texture_image *out_img, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift) { unsigned i, bits, size, bits_mul; - uint8_t info[6], *buf; + uint8_t info[6]; unsigned width = 0; unsigned height = 0; const uint8_t *tmp = NULL; - void *raw_buf = NULL; - ssize_t len = read_file(path, &raw_buf); - - if (len < 0) - { - RARCH_ERR("Failed to read image: %s.\n", path); - return false; - } - - buf = (uint8_t*)raw_buf; if (buf[2] != 2) { RARCH_ERR("TGA image is not uncompressed RGB.\n"); - free(buf); return false; } @@ -71,7 +60,6 @@ static bool rpng_image_load_tga_shift(const char *path, if (!out_img->pixels) { RARCH_ERR("Failed to allocate TGA pixels.\n"); - free(buf); return false; } @@ -81,7 +69,6 @@ static bool rpng_image_load_tga_shift(const char *path, if (bits != 32 && bits != 24) { RARCH_ERR("Bit depth of TGA image is wrong. Only 32-bit and 24-bit supported.\n"); - free(buf); free(out_img->pixels); out_img->pixels = NULL; return false; @@ -104,7 +91,6 @@ static bool rpng_image_load_tga_shift(const char *path, (r << r_shift) | (g << g_shift) | (b << b_shift); } - free(buf); return true; } @@ -225,12 +211,31 @@ bool texture_image_load(struct texture_image *out_img, const char *path) unsigned b_shift = use_rgba ? 16 : 0; if (strstr(path, ".tga")) - ret = rpng_image_load_tga_shift(path, out_img, + { + void *raw_buf = NULL; + uint8_t *buf = NULL; + ssize_t len = read_file(path, &raw_buf); + + if (len < 0) + { + RARCH_ERR("Failed to read image: %s.\n", path); + return false; + } + + buf = (uint8_t*)raw_buf; + + ret = rtga_image_load_shift(buf, out_img, a_shift, r_shift, g_shift, b_shift); + + if (buf) + free(buf); + } #ifdef HAVE_ZLIB else if (strstr(path, ".png")) + { ret = rpng_image_load_argb_shift(path, out_img, a_shift, r_shift, g_shift, b_shift); + } #endif #ifdef GEKKO From 21ff16471a08ede0df82396d07e5224939825f4b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 14:22:43 +0100 Subject: [PATCH 048/147] Alcaro - not a useless cast at all. Broke Windows build. --- database_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database_info.c b/database_info.c index 5bff7341b8..c5be621e33 100644 --- a/database_info.c +++ b/database_info.c @@ -35,7 +35,7 @@ int database_open_cursor(libretrodb_t *db, libretrodb_query_t *q = NULL; if (query) - q = libretrodb_query_compile(db, query, + q = (libretrodb_query_t*)libretrodb_query_compile(db, query, strlen(query), &error); if (error) From bcfd2f7667c54670b37cb18fb2ed859f1442310b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 14:25:06 +0100 Subject: [PATCH 049/147] (Windows) Build fixes --- menu/drivers/xmb.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c7f1af7b16..f82d83704e 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1336,41 +1336,41 @@ static void xmb_context_reset(void *data) static void xmb_navigation_clear(void *data, bool pending_push) { if (!pending_push) - xmb_selection_pointer_changed(data); + xmb_selection_pointer_changed((menu_handle_t*)data); } static void xmb_navigation_decrement(void *data) { - xmb_selection_pointer_changed(data); + xmb_selection_pointer_changed((menu_handle_t*)data); } static void xmb_navigation_increment(void *data) { - xmb_selection_pointer_changed(data); + xmb_selection_pointer_changed((menu_handle_t*)data); } static void xmb_navigation_set(void *data, bool scroll) { (void)scroll; - xmb_selection_pointer_changed(data); + xmb_selection_pointer_changed((menu_handle_t*)data); } static void xmb_navigation_set_last(void *data) { - xmb_selection_pointer_changed(data); + xmb_selection_pointer_changed((menu_handle_t*)data); } static void xmb_navigation_descend_alphabet(void *data, size_t *unused) { (void)unused; - xmb_selection_pointer_changed(data); + xmb_selection_pointer_changed((menu_handle_t*)data); } static void xmb_navigation_ascend_alphabet(void *data, size_t *unused) { (void)unused; - xmb_selection_pointer_changed(data); + xmb_selection_pointer_changed((menu_handle_t*)data); } static void xmb_list_insert(void *data, From b64584672fc3a4cf2b4519ff701e4e5d01ae68fc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 14:32:09 +0100 Subject: [PATCH 050/147] (GLUI) Cleanups --- menu/drivers/glui.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index fb6aeb2a1e..e08fef8d01 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -498,24 +498,23 @@ static void glui_context_reset(void *data) static void glui_navigation_clear(void *data, bool pending_push) { - if (driver.menu) - driver.menu->begin = 0; + menu_handle_t *menu = (menu_handle_t*)data; + if (menu) + menu->begin = 0; } static void glui_navigation_set(void *data, bool scroll) { glui_handle_t *glui = NULL; - menu_handle_t *menu = (menu_handle_t*)data; if (!menu) return; - + glui = (glui_handle_t*)menu->userdata; if (!glui) return; - if (!scroll) return; From f19339eb38b7cbb39f51bf439cacb8612604556e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 15:19:21 +0100 Subject: [PATCH 051/147] Have menu_texture.c reuse gl_common.c's gl_load_texture_data --- gfx/gl_common.c | 78 ++++++++++++++++++++++++++++++++++----------- gfx/gl_common.h | 6 ++-- gfx/video_driver.h | 7 ++++ menu/drivers/glui.c | 5 +-- menu/drivers/xmb.c | 6 ++-- menu/menu_texture.c | 35 ++++---------------- menu/menu_texture.h | 8 ++--- 7 files changed, 86 insertions(+), 59 deletions(-) diff --git a/gfx/gl_common.c b/gfx/gl_common.c index 9dfbe2aa7d..0d72fd7d2b 100644 --- a/gfx/gl_common.c +++ b/gfx/gl_common.c @@ -16,20 +16,49 @@ #include "gl_common.h" -void gl_load_texture_data(GLuint obj, const struct texture_image *img, - GLenum wrap, bool linear, bool mipmap) +void gl_load_texture_data(GLuint id, + const struct texture_image *img, + enum gfx_wrap_type wrap_type, + enum texture_filter_type filter_type) { - glBindTexture(GL_TEXTURE_2D, obj); + GLint mag_filter, min_filter; + GLenum wrap; + bool want_mipmap = false; + + glBindTexture(GL_TEXTURE_2D, id); + + wrap = driver.video->wrap_type_to_enum(wrap_type); -#ifdef HAVE_PSGL - mipmap = false; -#endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); - GLint mag_filter = linear ? GL_LINEAR : GL_NEAREST; - GLint min_filter = linear ? (mipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR) : - (mipmap ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST); + switch (filter_type) + { + case TEXTURE_FILTER_MIPMAP_LINEAR: + min_filter = GL_LINEAR_MIPMAP_LINEAR; + mag_filter = GL_LINEAR; +#ifndef HAVE_PSGL + want_mipmap = true; +#endif + break; + case TEXTURE_FILTER_MIPMAP_NEAREST: + min_filter = GL_NEAREST_MIPMAP_NEAREST; + mag_filter = GL_NEAREST; +#ifndef HAVE_PSGL + want_mipmap = true; +#endif + break; + case TEXTURE_FILTER_NEAREST: + min_filter = GL_NEAREST; + mag_filter = GL_NEAREST; + break; + case TEXTURE_FILTER_LINEAR: + default: + min_filter = GL_LINEAR; + mag_filter = GL_LINEAR; + break; + } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter); @@ -37,14 +66,14 @@ void gl_load_texture_data(GLuint obj, const struct texture_image *img, glPixelStorei(GL_UNPACK_ALIGNMENT, 4); #endif glTexImage2D(GL_TEXTURE_2D, - 0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, - img->width, img->height, - 0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, + 0, + driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, + img->width, img->height, 0, + driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, RARCH_GL_FORMAT32, img->pixels); -#ifndef HAVE_PSGL - if (mipmap) + + if (want_mipmap) glGenerateMipmap(GL_TEXTURE_2D); -#endif } bool gl_load_luts(const struct video_shader *generic_shader, @@ -60,9 +89,12 @@ bool gl_load_luts(const struct video_shader *generic_shader, * texture handle. I assume it was a bug, but if not, * replace num_luts with 1 when GLSL is used. */ glGenTextures(num_luts, textures_lut); + for (i = 0; i < num_luts; i++) { struct texture_image img = {0}; + enum texture_filter_type filter_type = TEXTURE_FILTER_LINEAR; + RARCH_LOG("Loading texture image from: \"%s\" ...\n", generic_shader->lut[i].path); @@ -73,10 +105,20 @@ bool gl_load_luts(const struct video_shader *generic_shader, return false; } + if (generic_shader->lut[i].filter == RARCH_FILTER_NEAREST) + filter_type = TEXTURE_FILTER_NEAREST; + + if (generic_shader->lut[i].mipmap) + { + if (filter_type == TEXTURE_FILTER_NEAREST) + filter_type = TEXTURE_FILTER_MIPMAP_NEAREST; + else + filter_type = TEXTURE_FILTER_MIPMAP_LINEAR; + } + gl_load_texture_data(textures_lut[i], &img, - driver.video->wrap_type_to_enum(generic_shader->lut[i].wrap), - generic_shader->lut[i].filter != RARCH_FILTER_NEAREST, - generic_shader->lut[i].mipmap); + generic_shader->lut[i].wrap, + filter_type); texture_image_free(&img); } diff --git a/gfx/gl_common.h b/gfx/gl_common.h index dd589d9f5b..a7b0261ee7 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -403,8 +403,10 @@ static inline bool gl_check_error(void) void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate); -void gl_load_texture_data(GLuint obj, const struct texture_image *img, - GLenum wrap, bool linear, bool mipmap); +void gl_load_texture_data(GLuint id, + const struct texture_image *img, + enum gfx_wrap_type wrap_type, + enum texture_filter_type filter_type); bool gl_load_luts(const struct video_shader *generic_shader, GLuint *lut_textures); diff --git a/gfx/video_driver.h b/gfx/video_driver.h index dfacbc979c..bde75854ce 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -74,6 +74,13 @@ struct font_params bool align_right; }; +enum texture_filter_type +{ + TEXTURE_FILTER_LINEAR = 0, + TEXTURE_FILTER_NEAREST, + TEXTURE_FILTER_MIPMAP_LINEAR, + TEXTURE_FILTER_MIPMAP_NEAREST, +}; #define FONT_COLOR_RGBA(r, g, b, a) (((r) << 0) | ((g) << 8) | ((b) << 16) | ((a) << 24)) #define FONT_COLOR_GET_RED(col) (((col) >> 0) & 0xff) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index e08fef8d01..fecb46fbb8 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -492,8 +492,9 @@ static void glui_context_reset(void *data) fill_pathname_join(bgpath, bgpath, "bg.png", sizeof(bgpath)); if (path_file_exists(bgpath)) - glui->bg = (GLuint)menu_texture_load(bgpath, TEXTURE_BACKEND_OPENGL, - TEXTURE_FILTER_DEFAULT); + glui->bg = (GLuint)menu_texture_load(bgpath, + TEXTURE_BACKEND_OPENGL, + TEXTURE_FILTER_LINEAR); } static void glui_navigation_clear(void *data, bool pending_push) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index f82d83704e..56e7e8373d 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1272,7 +1272,7 @@ static void xmb_context_reset(void *data) for (k = 0; k < XMB_TEXTURE_LAST; k++) xmb->textures[k].id = menu_texture_load(xmb->textures[k].path, - TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP); + TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); xmb->settings_node.icon = xmb->textures[XMB_TEXTURE_SETTINGS].id; xmb->settings_node.alpha = xmb->c_active_alpha; @@ -1318,9 +1318,9 @@ static void xmb_context_reset(void *data) node->alpha = 0; node->zoom = xmb->c_passive_zoom; node->icon = menu_texture_load(texturepath, - TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP); + TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); node->content_icon = menu_texture_load(content_texturepath, - TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP); + TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); if (i == xmb->active_category) diff --git a/menu/menu_texture.c b/menu/menu_texture.c index 817d032029..2b875cf6c8 100644 --- a/menu/menu_texture.c +++ b/menu/menu_texture.c @@ -28,30 +28,8 @@ static void menu_texture_png_load_gl(struct texture_image *ti, { /* Generate the OpenGL texture object */ glGenTextures(1, id); - glBindTexture(GL_TEXTURE_2D, (GLuint)*id); - glTexImage2D(GL_TEXTURE_2D, 0, driver.gfx_use_rgba ? - GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, - ti->width, ti->height, 0, - driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, - RARCH_GL_FORMAT32, ti->pixels); - - switch (filter_type) - { - case TEXTURE_FILTER_MIPMAP: - glTexParameterf(GL_TEXTURE_2D, - GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); - glTexParameterf(GL_TEXTURE_2D, - GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glGenerateMipmap(GL_TEXTURE_2D); - break; - case TEXTURE_FILTER_DEFAULT: - default: - glTexParameterf(GL_TEXTURE_2D, - GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, - GL_TEXTURE_MAG_FILTER, GL_LINEAR); - break; - } + gl_load_texture_data((GLuint)*id, + ti, RARCH_WRAP_EDGE, filter_type); } #endif @@ -89,7 +67,7 @@ static int menu_texture_png_load_wrap(void *data) if (!filename) return 0; return menu_texture_png_load(filename, TEXTURE_BACKEND_DEFAULT, - TEXTURE_FILTER_DEFAULT); + TEXTURE_FILTER_LINEAR); } static int menu_texture_png_load_wrap_gl_mipmap(void *data) @@ -98,7 +76,7 @@ static int menu_texture_png_load_wrap_gl_mipmap(void *data) if (!filename) return 0; return menu_texture_png_load(filename, TEXTURE_BACKEND_OPENGL, - TEXTURE_FILTER_MIPMAP); + TEXTURE_FILTER_MIPMAP_LINEAR); } static int menu_texture_png_load_wrap_gl(void *data) @@ -107,7 +85,7 @@ static int menu_texture_png_load_wrap_gl(void *data) if (!filename) return 0; return menu_texture_png_load(filename, TEXTURE_BACKEND_OPENGL, - TEXTURE_FILTER_DEFAULT); + TEXTURE_FILTER_LINEAR); } unsigned menu_texture_load(const char *path, @@ -125,7 +103,8 @@ unsigned menu_texture_load(const char *path, switch (type) { case TEXTURE_BACKEND_OPENGL: - if (filter_type == TEXTURE_FILTER_MIPMAP) + if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR || + filter_type == TEXTURE_FILTER_MIPMAP_NEAREST) thr->cmd_data.custom_command.method = menu_texture_png_load_wrap_gl_mipmap; else thr->cmd_data.custom_command.method = menu_texture_png_load_wrap_gl; diff --git a/menu/menu_texture.h b/menu/menu_texture.h index d5ef3ffd22..202eac5006 100644 --- a/menu/menu_texture.h +++ b/menu/menu_texture.h @@ -17,18 +17,14 @@ #ifndef _MENU_TEXTURE_MANAGER_H #define _MENU_TEXTURE_MANAGER_H +#include "../gfx/video_driver.h" + enum texture_backend_type { TEXTURE_BACKEND_DEFAULT = 0, TEXTURE_BACKEND_OPENGL, }; -enum texture_filter_type -{ - TEXTURE_FILTER_DEFAULT = 0, - TEXTURE_FILTER_MIPMAP, -}; - #ifdef __cplusplus extern "C" { #endif From 77f6b98aa9846f9b25ba2c4576dbe25c6a81aeb0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 15:46:55 +0100 Subject: [PATCH 052/147] Reuse gl_load_texture_data some more --- gfx/drivers/gl.c | 41 +++++++++++-------------------------- gfx/gl_common.c | 7 ++++--- gfx/gl_common.h | 3 ++- gfx/video_pixel_converter.c | 11 ++++++++++ gfx/video_pixel_converter.h | 2 ++ menu/menu_texture.c | 3 ++- 6 files changed, 33 insertions(+), 34 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 23d9665e47..a1d2f5567e 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -38,6 +38,7 @@ #include "../gl_common.h" #include "../video_viewport.h" +#include "../video_pixel_converter.h" #include "../video_context_driver.h" #include @@ -87,17 +88,6 @@ static const GLfloat white_color[] = { 1, 1, 1, 1, }; -static inline unsigned get_alignment(unsigned pitch) -{ - if (pitch & 1) - return 1; - if (pitch & 2) - return 2; - if (pitch & 4) - return 4; - return 8; -} - static inline bool gl_query_extension(gl_t *gl, const char *ext) { bool ret = false; @@ -1084,7 +1074,7 @@ static void gl_update_input_size(gl_t *gl, unsigned width, if (clear) { glPixelStorei(GL_UNPACK_ALIGNMENT, - get_alignment(width * sizeof(uint32_t))); + video_pixel_get_alignment(width * sizeof(uint32_t))); #if defined(HAVE_PSGL) glBufferSubData(GL_TEXTURE_REFERENCE_BUFFER_SCE, gl->tex_w * gl->tex_h * gl->tex_index * gl->base_size, @@ -1292,7 +1282,7 @@ static inline void gl_copy_frame(gl_t *gl, const void *frame, else #endif { - glPixelStorei(GL_UNPACK_ALIGNMENT, get_alignment(width * gl->base_size)); + glPixelStorei(GL_UNPACK_ALIGNMENT, video_pixel_get_alignment(width * gl->base_size)); /* Fallback for GLES devices without GL_BGRA_EXT. */ if (gl->base_size == 4 && driver.gfx_use_rgba) @@ -1355,7 +1345,7 @@ static inline void gl_copy_frame(gl_t *gl, const void *frame, glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE); #else const GLvoid *data_buf = frame; - glPixelStorei(GL_UNPACK_ALIGNMENT, get_alignment(pitch)); + glPixelStorei(GL_UNPACK_ALIGNMENT, video_pixel_get_alignment(pitch)); if (gl->base_size == 2 && !gl->have_es2_compat) { @@ -1403,7 +1393,7 @@ static void gl_pbo_async_readback(gl_t *gl) glPixelStorei(GL_PACK_ROW_LENGTH, 0); glPixelStorei(GL_PACK_ALIGNMENT, - get_alignment(gl->vp.width * sizeof(uint32_t))); + video_pixel_get_alignment(gl->vp.width * sizeof(uint32_t))); /* Read asynchronously into PBO buffer. */ RARCH_PERFORMANCE_INIT(async_readback); @@ -2789,20 +2779,13 @@ static bool gl_overlay_load(void *data, for (i = 0; i < num_images; i++) { - glBindTexture(GL_TEXTURE_2D, gl->overlay_tex[i]); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + unsigned alignment = video_pixel_get_alignment(images[i].width + * sizeof(uint32_t)); - glPixelStorei(GL_UNPACK_ALIGNMENT, - get_alignment(images[i].width * sizeof(uint32_t))); - - glTexImage2D(GL_TEXTURE_2D, 0, driver.gfx_use_rgba ? - GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, - images[i].width, images[i].height, 0, - driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, - RARCH_GL_FORMAT32, images[i].pixels); + gl_load_texture_data(gl->overlay_tex[i], + &images[i], + RARCH_WRAP_EDGE, TEXTURE_FILTER_LINEAR, + alignment); /* Default. Stretch to whole screen. */ gl_overlay_tex_geom(gl, i, 0, 0, 1, 1); @@ -3030,7 +3013,7 @@ static void gl_set_texture_frame(void *data, gl->menu_texture_alpha = alpha; base_size = rgb32 ? sizeof(uint32_t) : sizeof(uint16_t); - glPixelStorei(GL_UNPACK_ALIGNMENT, get_alignment(width * base_size)); + glPixelStorei(GL_UNPACK_ALIGNMENT, video_pixel_get_alignment(width * base_size)); if (rgb32) { diff --git a/gfx/gl_common.c b/gfx/gl_common.c index 0d72fd7d2b..0c632a2778 100644 --- a/gfx/gl_common.c +++ b/gfx/gl_common.c @@ -19,7 +19,8 @@ void gl_load_texture_data(GLuint id, const struct texture_image *img, enum gfx_wrap_type wrap_type, - enum texture_filter_type filter_type) + enum texture_filter_type filter_type, + unsigned alignment) { GLint mag_filter, min_filter; GLenum wrap; @@ -63,7 +64,7 @@ void gl_load_texture_data(GLuint id, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter); #ifndef HAVE_PSGL - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); #endif glTexImage2D(GL_TEXTURE_2D, 0, @@ -118,7 +119,7 @@ bool gl_load_luts(const struct video_shader *generic_shader, gl_load_texture_data(textures_lut[i], &img, generic_shader->lut[i].wrap, - filter_type); + filter_type, 4); texture_image_free(&img); } diff --git a/gfx/gl_common.h b/gfx/gl_common.h index a7b0261ee7..78efa3dc1e 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -406,7 +406,8 @@ void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, void gl_load_texture_data(GLuint id, const struct texture_image *img, enum gfx_wrap_type wrap_type, - enum texture_filter_type filter_type); + enum texture_filter_type filter_type, + unsigned alignment); bool gl_load_luts(const struct video_shader *generic_shader, GLuint *lut_textures); diff --git a/gfx/video_pixel_converter.c b/gfx/video_pixel_converter.c index 9a0bab90b8..6e2f979c4b 100644 --- a/gfx/video_pixel_converter.c +++ b/gfx/video_pixel_converter.c @@ -52,3 +52,14 @@ bool init_video_pixel_converter(unsigned size) return true; } + +unsigned video_pixel_get_alignment(unsigned pitch) +{ + if (pitch & 1) + return 1; + if (pitch & 2) + return 2; + if (pitch & 4) + return 4; + return 8; +} diff --git a/gfx/video_pixel_converter.h b/gfx/video_pixel_converter.h index d6a8d22f16..f08abed0c4 100644 --- a/gfx/video_pixel_converter.h +++ b/gfx/video_pixel_converter.h @@ -27,6 +27,8 @@ void deinit_pixel_converter(void); bool init_video_pixel_converter(unsigned size); +unsigned video_pixel_get_alignment(unsigned pitch); + #ifdef __cplusplus } #endif diff --git a/menu/menu_texture.c b/menu/menu_texture.c index 2b875cf6c8..1b020c6f66 100644 --- a/menu/menu_texture.c +++ b/menu/menu_texture.c @@ -17,6 +17,7 @@ #include "menu_texture.h" #include #include "../general.h" +#include "../gfx/video_pixel_converter.h" #include "../gfx/video_thread_wrapper.h" #ifdef HAVE_OPENGL @@ -29,7 +30,7 @@ static void menu_texture_png_load_gl(struct texture_image *ti, /* Generate the OpenGL texture object */ glGenTextures(1, id); gl_load_texture_data((GLuint)*id, - ti, RARCH_WRAP_EDGE, filter_type); + ti, RARCH_WRAP_EDGE, filter_type, 4 /* TODO/FIXME - dehardcode */); } #endif From 118ce66dec677ded18bdfd7968f31104d3296ae3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 15:53:37 +0100 Subject: [PATCH 053/147] Refactor gl_load_texture_data --- gfx/drivers/gl.c | 4 ++-- gfx/gl_common.c | 15 +++++++++------ gfx/gl_common.h | 5 +++-- menu/menu_texture.c | 3 ++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index a1d2f5567e..90fcca305a 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2783,9 +2783,9 @@ static bool gl_overlay_load(void *data, * sizeof(uint32_t)); gl_load_texture_data(gl->overlay_tex[i], - &images[i], RARCH_WRAP_EDGE, TEXTURE_FILTER_LINEAR, - alignment); + alignment, + images[i].width, images[i].height, images[i].pixels); /* Default. Stretch to whole screen. */ gl_overlay_tex_geom(gl, i, 0, 0, 1, 1); diff --git a/gfx/gl_common.c b/gfx/gl_common.c index 0c632a2778..ab6e680b4e 100644 --- a/gfx/gl_common.c +++ b/gfx/gl_common.c @@ -17,10 +17,11 @@ #include "gl_common.h" void gl_load_texture_data(GLuint id, - const struct texture_image *img, enum gfx_wrap_type wrap_type, enum texture_filter_type filter_type, - unsigned alignment) + unsigned alignment, + unsigned width, unsigned height, + const void *frame) { GLint mag_filter, min_filter; GLenum wrap; @@ -69,9 +70,9 @@ void gl_load_texture_data(GLuint id, glTexImage2D(GL_TEXTURE_2D, 0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, - img->width, img->height, 0, + width, height, 0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, - RARCH_GL_FORMAT32, img->pixels); + RARCH_GL_FORMAT32, frame); if (want_mipmap) glGenerateMipmap(GL_TEXTURE_2D); @@ -117,9 +118,11 @@ bool gl_load_luts(const struct video_shader *generic_shader, filter_type = TEXTURE_FILTER_MIPMAP_LINEAR; } - gl_load_texture_data(textures_lut[i], &img, + gl_load_texture_data(textures_lut[i], generic_shader->lut[i].wrap, - filter_type, 4); + filter_type, 4, + img.width, img.height, + img.pixels); texture_image_free(&img); } diff --git a/gfx/gl_common.h b/gfx/gl_common.h index 78efa3dc1e..3f8f4399e2 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -404,10 +404,11 @@ void gl_set_viewport(gl_t *gl, unsigned width, unsigned height, bool force_full, bool allow_rotate); void gl_load_texture_data(GLuint id, - const struct texture_image *img, enum gfx_wrap_type wrap_type, enum texture_filter_type filter_type, - unsigned alignment); + unsigned alignment, + unsigned width, unsigned height, + const void *frame); bool gl_load_luts(const struct video_shader *generic_shader, GLuint *lut_textures); diff --git a/menu/menu_texture.c b/menu/menu_texture.c index 1b020c6f66..24268e0ffa 100644 --- a/menu/menu_texture.c +++ b/menu/menu_texture.c @@ -30,7 +30,8 @@ static void menu_texture_png_load_gl(struct texture_image *ti, /* Generate the OpenGL texture object */ glGenTextures(1, id); gl_load_texture_data((GLuint)*id, - ti, RARCH_WRAP_EDGE, filter_type, 4 /* TODO/FIXME - dehardcode */); + RARCH_WRAP_EDGE, filter_type, 4 /* TODO/FIXME - dehardcode */, + ti->width, ti->height, ti->pixels); } #endif From 821a3283dc0706d1e9b6719347d724ca4aae03d4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 16:05:11 +0100 Subject: [PATCH 054/147] Refactor gl_set_texture_frame --- gfx/drivers/gl.c | 41 +++++++++++------------------------------ gfx/gl_common.c | 11 ++++++----- gfx/gl_common.h | 3 ++- menu/menu_texture.c | 7 +++++-- 4 files changed, 24 insertions(+), 38 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 90fcca305a..5044eb3d42 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2785,7 +2785,8 @@ static bool gl_overlay_load(void *data, gl_load_texture_data(gl->overlay_tex[i], RARCH_WRAP_EDGE, TEXTURE_FILTER_LINEAR, alignment, - images[i].width, images[i].height, images[i].pixels); + images[i].width, images[i].height, images[i].pixels, + sizeof(uint32_t)); /* Default. Stretch to whole screen. */ gl_overlay_tex_geom(gl, i, 0, 0, 1, 1); @@ -2991,7 +2992,7 @@ static void gl_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { - unsigned base_size; + unsigned base_size = rgb32 ? sizeof(uint32_t) : sizeof(uint16_t); gl_t *gl = (gl_t*)data; if (!gl) return; @@ -2999,38 +3000,18 @@ static void gl_set_texture_frame(void *data, context_bind_hw_render(gl, false); if (!gl->menu_texture) - { glGenTextures(1, &gl->menu_texture); - glBindTexture(GL_TEXTURE_2D, gl->menu_texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - } - else - glBindTexture(GL_TEXTURE_2D, gl->menu_texture); + + + gl_load_texture_data(gl->menu_texture, + RARCH_WRAP_EDGE, TEXTURE_FILTER_LINEAR, + video_pixel_get_alignment(width * base_size), + width, height, frame, + base_size); gl->menu_texture_alpha = alpha; - - base_size = rgb32 ? sizeof(uint32_t) : sizeof(uint16_t); - glPixelStorei(GL_UNPACK_ALIGNMENT, video_pixel_get_alignment(width * base_size)); - - if (rgb32) - { - glTexImage2D(GL_TEXTURE_2D, - 0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, - width, height, - 0, driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, - RARCH_GL_FORMAT32, frame); - } - else - { - glTexImage2D(GL_TEXTURE_2D, - 0, GL_RGBA, width, height, 0, GL_RGBA, - GL_UNSIGNED_SHORT_4_4_4_4, frame); - } - glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); + context_bind_hw_render(gl, true); } diff --git a/gfx/gl_common.c b/gfx/gl_common.c index ab6e680b4e..7471a56139 100644 --- a/gfx/gl_common.c +++ b/gfx/gl_common.c @@ -21,11 +21,12 @@ void gl_load_texture_data(GLuint id, enum texture_filter_type filter_type, unsigned alignment, unsigned width, unsigned height, - const void *frame) + const void *frame, unsigned base_size) { GLint mag_filter, min_filter; GLenum wrap; bool want_mipmap = false; + bool rgb32 = (base_size == (sizeof(uint32_t))); glBindTexture(GL_TEXTURE_2D, id); @@ -69,10 +70,10 @@ void gl_load_texture_data(GLuint id, #endif glTexImage2D(GL_TEXTURE_2D, 0, - driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, + (driver.gfx_use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32, width, height, 0, - driver.gfx_use_rgba ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, - RARCH_GL_FORMAT32, frame); + (driver.gfx_use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, + (rgb32) ? RARCH_GL_FORMAT32 : GL_UNSIGNED_SHORT_4_4_4_4, frame); if (want_mipmap) glGenerateMipmap(GL_TEXTURE_2D); @@ -122,7 +123,7 @@ bool gl_load_luts(const struct video_shader *generic_shader, generic_shader->lut[i].wrap, filter_type, 4, img.width, img.height, - img.pixels); + img.pixels, sizeof(uint32_t)); texture_image_free(&img); } diff --git a/gfx/gl_common.h b/gfx/gl_common.h index 3f8f4399e2..8480aa3659 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -408,7 +408,8 @@ void gl_load_texture_data(GLuint id, enum texture_filter_type filter_type, unsigned alignment, unsigned width, unsigned height, - const void *frame); + const void *frame, + unsigned base_size); bool gl_load_luts(const struct video_shader *generic_shader, GLuint *lut_textures); diff --git a/menu/menu_texture.c b/menu/menu_texture.c index 24268e0ffa..7518c3176c 100644 --- a/menu/menu_texture.c +++ b/menu/menu_texture.c @@ -30,8 +30,11 @@ static void menu_texture_png_load_gl(struct texture_image *ti, /* Generate the OpenGL texture object */ glGenTextures(1, id); gl_load_texture_data((GLuint)*id, - RARCH_WRAP_EDGE, filter_type, 4 /* TODO/FIXME - dehardcode */, - ti->width, ti->height, ti->pixels); + RARCH_WRAP_EDGE, filter_type, + 4 /* TODO/FIXME - dehardcode */, + ti->width, ti->height, ti->pixels, + sizeof(uint32_t) /* TODO/FIXME - dehardcode */ + ); } #endif From 539c26c61187817c6c12c5804ca4bd8df62cbfad Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 16:11:05 +0100 Subject: [PATCH 055/147] Refactor gl_set_texture_fmts --- gfx/drivers/gl.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 5044eb3d42..349dcc13cb 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1925,19 +1925,26 @@ static bool resolve_extensions(gl_t *gl) static inline void gl_set_texture_fmts(gl_t *gl, bool rgb32) { - gl->internal_fmt = rgb32 ? RARCH_GL_INTERNAL_FORMAT32 : RARCH_GL_INTERNAL_FORMAT16; - gl->texture_type = rgb32 ? RARCH_GL_TEXTURE_TYPE32 : RARCH_GL_TEXTURE_TYPE16; - gl->texture_fmt = rgb32 ? RARCH_GL_FORMAT32 : RARCH_GL_FORMAT16; - gl->base_size = rgb32 ? sizeof(uint32_t) : sizeof(uint16_t); + gl->internal_fmt = RARCH_GL_INTERNAL_FORMAT16; + gl->texture_type = RARCH_GL_TEXTURE_TYPE16; + gl->texture_fmt = RARCH_GL_FORMAT16; + gl->base_size = sizeof(uint16_t); - if (driver.gfx_use_rgba && rgb32) + if (rgb32) { - gl->internal_fmt = GL_RGBA; - gl->texture_type = GL_RGBA; - } + gl->internal_fmt = RARCH_GL_INTERNAL_FORMAT32; + gl->texture_type = RARCH_GL_TEXTURE_TYPE32; + gl->texture_fmt = RARCH_GL_FORMAT32; + gl->base_size = sizeof(uint32_t); + if (driver.gfx_use_rgba) + { + gl->internal_fmt = GL_RGBA; + gl->texture_type = GL_RGBA; + } + } #ifndef HAVE_OPENGLES - if (!rgb32 && gl->have_es2_compat) + else if (gl->have_es2_compat) { RARCH_LOG("[GL]: Using GL_RGB565 for texture uploads.\n"); gl->internal_fmt = RARCH_GL_INTERNAL_FORMAT16_565; From d99a224688d77803ad19d8720c1b8c6b2556136a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 16:40:05 +0100 Subject: [PATCH 056/147] gl_load_texture_data - add early return if driver.video is NULL --- gfx/gl_common.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gfx/gl_common.c b/gfx/gl_common.c index 7471a56139..8da3d7c2d4 100644 --- a/gfx/gl_common.c +++ b/gfx/gl_common.c @@ -28,6 +28,9 @@ void gl_load_texture_data(GLuint id, bool want_mipmap = false; bool rgb32 = (base_size == (sizeof(uint32_t))); + if (!driver.video) + return; + glBindTexture(GL_TEXTURE_2D, id); wrap = driver.video->wrap_type_to_enum(wrap_type); From d0e6685d3dc4c335d7e81da6a85b0dba005bb9e7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 17:36:31 +0100 Subject: [PATCH 057/147] Move readjust_input_rate function to audio_driver.c --- audio/audio_driver.c | 34 ++++++++++++++++++++++++++++++++++ audio/audio_driver.h | 7 +++++++ libretro_version_1.c | 29 +---------------------------- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 3384e9ac05..81fc90a977 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -409,3 +409,37 @@ bool audio_driver_mute_toggle(void) return true; } + +/* + * audio_driver_readjust_input_rate: + * + * Readjust the audio input rate. + */ +void audio_driver_readjust_input_rate(void) +{ + double direction, adjust; + int half_size, delta_mid, avail; + unsigned write_idx; + + avail = driver.audio->write_avail(driver.audio_data); + +#if 0 + RARCH_LOG_OUTPUT("Audio buffer is %u%% full\n", + (unsigned)(100 - (avail * 100) / g_extern.audio_data.driver_buffer_size)); +#endif + + write_idx = g_extern.measure_data.buffer_free_samples_count++ & + (AUDIO_BUFFER_FREE_SAMPLES_COUNT - 1); + half_size = g_extern.audio_data.driver_buffer_size / 2; + delta_mid = avail - half_size; + direction = (double)delta_mid / half_size; + adjust = 1.0 + g_settings.audio.rate_control_delta * direction; + + g_extern.measure_data.buffer_free_samples[write_idx] = avail; + g_extern.audio_data.src_ratio = g_extern.audio_data.orig_src_ratio * adjust; + +#if 0 + RARCH_LOG_OUTPUT("New rate: %lf, Orig rate: %lf\n", + g_extern.audio_data.src_ratio, g_extern.audio_data.orig_src_ratio); +#endif +} diff --git a/audio/audio_driver.h b/audio/audio_driver.h index ad789483bb..206b552d20 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -112,6 +112,13 @@ const char *audio_driver_find_ident(int index); bool audio_driver_mute_toggle(void); +/* + * audio_driver_readjust_input_rate: + * + * Readjust the audio input rate. + */ +void audio_driver_readjust_input_rate(void); + /** * config_get_audio_driver_options: * diff --git a/libretro_version_1.c b/libretro_version_1.c index 4f139c3d1f..555734abcb 100644 --- a/libretro_version_1.c +++ b/libretro_version_1.c @@ -141,33 +141,6 @@ static void video_frame(const void *data, unsigned width, driver.video_active = false; } -/* - * readjust_audio_input_rate: - * - * Readjust the audio input rate. - */ -static void readjust_audio_input_rate(void) -{ - int avail = driver.audio->write_avail(driver.audio_data); - - //RARCH_LOG_OUTPUT("Audio buffer is %u%% full\n", - // (unsigned)(100 - (avail * 100) / g_extern.audio_data.driver_buffer_size)); - - unsigned write_idx = g_extern.measure_data.buffer_free_samples_count++ & - (AUDIO_BUFFER_FREE_SAMPLES_COUNT - 1); - int half_size = g_extern.audio_data.driver_buffer_size / 2; - int delta_mid = avail - half_size; - double direction = (double)delta_mid / half_size; - double adjust = 1.0 + g_settings.audio.rate_control_delta * - direction; - - g_extern.measure_data.buffer_free_samples[write_idx] = avail; - g_extern.audio_data.src_ratio = g_extern.audio_data.orig_src_ratio * adjust; - - //RARCH_LOG_OUTPUT("New rate: %lf, Orig rate: %lf\n", - // g_extern.audio_data.src_ratio, g_extern.audio_data.orig_src_ratio); -} - /** * retro_flush_audio: * @data : pointer to audio buffer. @@ -231,7 +204,7 @@ bool retro_flush_audio(const int16_t *data, size_t samples) src_data.data_out = g_extern.audio_data.outsamples; if (g_extern.audio_data.rate_control) - readjust_audio_input_rate(); + audio_driver_readjust_input_rate(); src_data.ratio = g_extern.audio_data.src_ratio; if (g_extern.is_slowmotion) From 5ee4e6da738a761460ca19f8b1f035d2570aaca6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 17:53:38 +0100 Subject: [PATCH 058/147] Guard against entering video filter or audio filter directory if path is not correct --- menu/menu_entries_cbs.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index a63a212c69..f8af20da16 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -414,6 +414,30 @@ static int action_ok_cheat_file(const char *path, label, type, idx); } +static int action_ok_audio_dsp_plugin(const char *path, + const char *label, unsigned type, size_t idx) +{ + if (!path_file_exists(path)) + { + msg_queue_clear(g_extern.msg_queue); + msg_queue_push(g_extern.msg_queue, "Audio Filter Directory doesn't exist or cannot be accessed.\n", 1, 180); + return -1; + } + return 0; +} + +static int action_ok_video_filter(const char *path, + const char *label, unsigned type, size_t idx) +{ + if (!path_file_exists(path)) + { + msg_queue_clear(g_extern.msg_queue); + msg_queue_push(g_extern.msg_queue, "Video Filter Directory doesn't exist or cannot be accessed.\n", 1, 180); + return -1; + } + return 0; +} + static int action_ok_remap_file(const char *path, const char *label, unsigned type, size_t idx) { @@ -5026,6 +5050,10 @@ static void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, cbs->action_ok = action_ok_shader_preset; else if (!strcmp(label, "cheat_file_load")) cbs->action_ok = action_ok_cheat_file; + else if (!strcmp(label, "audio_dsp_plugin")) + cbs->action_ok = action_ok_audio_dsp_plugin; + else if (!strcmp(label, "video_filter")) + cbs->action_ok = action_ok_video_filter; else if (!strcmp(label, "remap_file_load")) cbs->action_ok = action_ok_remap_file; else if (!strcmp(label, "video_shader_parameters") || From 3ca18c14d4f0aa2a618b13d9d9ec82bb67b4f116 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 18:14:53 +0100 Subject: [PATCH 059/147] (menu_entries_cbs.c) Cut down code duplication --- menu/menu_entries_cbs.c | 89 ++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index f8af20da16..c5ceb6fead 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -4635,6 +4635,20 @@ static void menu_action_setting_disp_set_label_menu_video_resolution( #endif } +static void menu_action_setting_generic_disp_set_label( + unsigned *w, char *type_str, size_t type_str_size, + const char *path, const char *label, + char *path_buf, size_t path_buf_size) +{ + *type_str = '\0'; + + if (label) + strlcpy(type_str, label, type_str_size); + *w = strlen(type_str); + + strlcpy(path_buf, path, path_buf_size); +} + static void menu_action_setting_disp_set_label_menu_file_use_directory( file_list_t* list, unsigned *w, unsigned type, unsigned i, @@ -4644,9 +4658,8 @@ static void menu_action_setting_disp_set_label_menu_file_use_directory( const char *path, char *path_buf, size_t path_buf_size) { - *type_str = '\0'; - *w = 0; - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, NULL, path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_directory( @@ -4658,9 +4671,8 @@ static void menu_action_setting_disp_set_label_menu_file_directory( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(DIR)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(DIR)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_carchive( @@ -4672,9 +4684,8 @@ static void menu_action_setting_disp_set_label_menu_file_carchive( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(COMP)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(COMP)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_shader( @@ -4686,9 +4697,8 @@ static void menu_action_setting_disp_set_label_menu_file_shader( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(SHADER)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(SHADER)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_subgroup( @@ -4700,9 +4710,8 @@ static void menu_action_setting_disp_set_label_menu_file_subgroup( const char *path, char *path_buf, size_t path_buf_size) { - *type_str = '\0'; - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, NULL, path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_shader_preset( @@ -4714,9 +4723,8 @@ static void menu_action_setting_disp_set_label_menu_file_shader_preset( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(PRESET)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(PRESET)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_in_carchive( @@ -4728,9 +4736,8 @@ static void menu_action_setting_disp_set_label_menu_file_in_carchive( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(CFILE)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(CFILE)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_overlay( @@ -4742,9 +4749,8 @@ static void menu_action_setting_disp_set_label_menu_file_overlay( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(OVERLAY)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(OVERLAY)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_config( @@ -4756,9 +4762,8 @@ static void menu_action_setting_disp_set_label_menu_file_config( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(CONFIG)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(CONFIG)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_font( @@ -4770,9 +4775,8 @@ static void menu_action_setting_disp_set_label_menu_file_font( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(FONT)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(FONT)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_filter( @@ -4784,9 +4788,8 @@ static void menu_action_setting_disp_set_label_menu_file_filter( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(FILTER)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(FILTER)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_url( @@ -4798,9 +4801,8 @@ static void menu_action_setting_disp_set_label_menu_file_url( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(URL)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(URL)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_rdb( @@ -4812,9 +4814,8 @@ static void menu_action_setting_disp_set_label_menu_file_rdb( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(RDB)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(RDB)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_cursor( @@ -4826,9 +4827,8 @@ static void menu_action_setting_disp_set_label_menu_file_cursor( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(CURSOR)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(CURSOR)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label_menu_file_cheat( @@ -4840,9 +4840,8 @@ static void menu_action_setting_disp_set_label_menu_file_cheat( const char *path, char *path_buf, size_t path_buf_size) { - strlcpy(type_str, "(CHEAT)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(CHEAT)", path_buf, path_buf_size); } static void menu_action_setting_disp_set_label(file_list_t* list, From 97564dd1bea8221a23c58ab101b28cfb8ef22593 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 18:17:02 +0100 Subject: [PATCH 060/147] (menu_entries_cbs.c) Cut down on code duplication pt. 2 --- menu/menu_entries_cbs.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index c5ceb6fead..52d82e9223 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -4560,19 +4560,6 @@ static void menu_action_setting_disp_set_label_menu_more( strlcpy(path_buf, path, path_buf_size); } -static void menu_action_setting_disp_set_label_menu_file_plain( - file_list_t* list, - unsigned *w, unsigned type, unsigned i, - const char *label, - char *type_str, size_t type_str_size, - const char *entry_label, - const char *path, - char *path_buf, size_t path_buf_size) -{ - strlcpy(type_str, "(FILE)", type_str_size); - *w = strlen(type_str); - strlcpy(path_buf, path, path_buf_size); -} static void menu_action_setting_disp_set_label_menu_disk_index( file_list_t* list, @@ -4649,6 +4636,19 @@ static void menu_action_setting_generic_disp_set_label( strlcpy(path_buf, path, path_buf_size); } +static void menu_action_setting_disp_set_label_menu_file_plain( + file_list_t* list, + unsigned *w, unsigned type, unsigned i, + const char *label, + char *type_str, size_t type_str_size, + const char *entry_label, + const char *path, + char *path_buf, size_t path_buf_size) +{ + menu_action_setting_generic_disp_set_label(w, type_str, type_str_size, + path, "(FILE)", path_buf, path_buf_size); +} + static void menu_action_setting_disp_set_label_menu_file_use_directory( file_list_t* list, unsigned *w, unsigned type, unsigned i, From 915c97b76fac554ee7c685f10333602f0595c65d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 18:36:37 +0100 Subject: [PATCH 061/147] Refactor menu_driver.h --- menu/drivers/rgui.c | 24 ++++++++++++------------ menu/menu.c | 6 +++--- menu/menu_driver.h | 7 +++++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 3515e01424..85931b823b 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -121,12 +121,12 @@ static void fill_rect(menu_handle_t *menu, { unsigned i, j; - if (!menu->frame_buf || !col) + if (!menu->frame_buf.data || !col) return; for (j = y; j < y + height; j++) for (i = x; i < x + width; i++) - menu->frame_buf[j * (menu->frame_buf_pitch >> 1) + i] = col(i, j); + menu->frame_buf.data[j * (menu->frame_buf.pitch >> 1) + i] = col(i, j); } static void color_rect(menu_handle_t *menu, @@ -136,13 +136,13 @@ static void color_rect(menu_handle_t *menu, { unsigned i, j; - if (!menu->frame_buf) + if (!menu->frame_buf.data) return; for (j = y; j < y + height; j++) for (i = x; i < x + width; i++) if (i < driver.menu->width && j < driver.menu->height) - menu->frame_buf[j * (menu->frame_buf_pitch >> 1) + i] = color; + menu->frame_buf.data[j * (menu->frame_buf.pitch >> 1) + i] = color; } static void blit_line(int x, int y, const char *message, bool green) @@ -167,8 +167,8 @@ static void blit_line(int x, int y, const char *message, bool green) if (!col) continue; - menu->frame_buf[(y + j) * - (menu->frame_buf_pitch >> 1) + (x + i)] = green ? + menu->frame_buf.data[(y + j) * + (menu->frame_buf.pitch >> 1) + (x + i)] = green ? #if defined(GEKKO)|| defined(PSP) (3 << 0) | (10 << 4) | (3 << 8) | (7 << 12) : 0x7FFF; #else @@ -470,15 +470,15 @@ static void *rgui_init(void) if (!menu) return NULL; - menu->frame_buf = (uint16_t*)malloc(400 * 240 * sizeof(uint16_t)); + menu->frame_buf.data = (uint16_t*)malloc(400 * 240 * sizeof(uint16_t)); - if (!menu->frame_buf) + if (!menu->frame_buf.data) goto error; menu->width = 320; menu->height = 240; menu->begin = 0; - menu->frame_buf_pitch = menu->width * sizeof(uint16_t); + menu->frame_buf.pitch = menu->width * sizeof(uint16_t); ret = rguidisp_init_font(menu); @@ -495,8 +495,8 @@ static void *rgui_init(void) error: if (menu) { - if (menu->frame_buf) - free(menu->frame_buf); + if (menu->frame_buf.data) + free(menu->frame_buf.data); if (menu->userdata) free(menu->userdata); free(menu); @@ -533,7 +533,7 @@ static void rgui_set_texture(void *data) return; driver.video_poke->set_texture_frame(driver.video_data, - menu->frame_buf, false, menu->width, menu->height, 1.0f); + menu->frame_buf.data, false, menu->width, menu->height, 1.0f); } static void rgui_navigation_clear(void *data, bool pending_push) diff --git a/menu/menu.c b/menu/menu.c index 80913a4d5b..ff2e38a402 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -257,9 +257,9 @@ void menu_free(void *data) menu_animation_free(menu->animation); menu->animation = NULL; - if (menu->frame_buf) - free(menu->frame_buf); - menu->frame_buf = NULL; + if (menu->frame_buf.data) + free(menu->frame_buf.data); + menu->frame_buf.data = NULL; menu_list_free(menu->menu_list); menu->menu_list = NULL; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index b473119165..96e5f87378 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -106,8 +106,11 @@ typedef struct char default_glslp[PATH_MAX_LENGTH]; char default_cgp[PATH_MAX_LENGTH]; - uint16_t *frame_buf; - size_t frame_buf_pitch; + struct + { + uint16_t *data; + size_t pitch; + } frame_buf; const uint8_t *font; bool alloc_font; From 00cd281a1f784f0f3b996b30977df1b211f9b873 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 18:52:59 +0100 Subject: [PATCH 062/147] Move menu_ticker_line to menu_animation.c --- menu/drivers/glui.c | 6 ++--- menu/drivers/rgui.c | 6 ++--- menu/drivers/xmb.c | 4 +-- menu/menu.c | 59 ------------------------------------------ menu/menu.h | 14 ---------- menu/menu_animation.c | 60 +++++++++++++++++++++++++++++++++++++++++++ menu/menu_animation.h | 14 ++++++++++ 7 files changed, 82 insertions(+), 81 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index fecb46fbb8..3eb77bc192 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -307,7 +307,7 @@ static void glui_frame(void) get_title(label, dir, menu_type, title, sizeof(title)); - menu_ticker_line(title_buf, glui->term_width - 3, + menu_animation_ticker_line(title_buf, glui->term_width - 3, g_extern.frame_count / glui->margin, title, true); glui_blit_line(gl, glui->margin * 2, glui->margin + glui->line_height, title_buf, true); @@ -370,9 +370,9 @@ static void glui_frame(void) selected = (i == driver.menu->selection_ptr); - menu_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2), + menu_animation_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2), g_extern.frame_count / glui->margin, path_buf, selected); - menu_ticker_line(type_str_buf, w, + menu_animation_ticker_line(type_str_buf, w, g_extern.frame_count / glui->margin, type_str, selected); strlcpy(message, entry_title_buf, sizeof(message)); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 85931b823b..6f53ea0fd1 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -354,7 +354,7 @@ static void rgui_render(void) get_title(label, dir, menu_type, title, sizeof(title)); - menu_ticker_line(title_buf, RGUI_TERM_WIDTH - 3, + menu_animation_ticker_line(title_buf, RGUI_TERM_WIDTH - 3, g_extern.frame_count / RGUI_TERM_START_X, title, true); blit_line(RGUI_TERM_START_X + RGUI_TERM_START_X, RGUI_TERM_START_X, title_buf, true); @@ -418,9 +418,9 @@ static void rgui_render(void) if (i > (driver.menu->selection_ptr + 100)) continue; - menu_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2), + menu_animation_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2), g_extern.frame_count / RGUI_TERM_START_X, path_buf, selected); - menu_ticker_line(type_str_buf, w, g_extern.frame_count / RGUI_TERM_START_X, + menu_animation_ticker_line(type_str_buf, w, g_extern.frame_count / RGUI_TERM_START_X, type_str, selected); snprintf(message, sizeof(message), "%c %-*.*s %-*s", diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 56e7e8373d..1315c78ebe 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -867,7 +867,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, xmb_draw_icon(gl, xmb, icon, icon_x, icon_y, node->alpha, 0, node->zoom); - menu_ticker_line(name, 35, g_extern.frame_count / 20, path_buf, + menu_animation_ticker_line(name, 35, g_extern.frame_count / 20, path_buf, (i == current)); xmb_draw_text(gl, xmb, name, @@ -875,7 +875,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, xmb->margin_top + node->y + xmb->label_margin_top, 1, node->label_alpha, 0); - menu_ticker_line(value, 35, g_extern.frame_count / 20, type_str, + menu_animation_ticker_line(value, 35, g_extern.frame_count / 20, type_str, (i == current)); if(( strcmp(type_str, "...") diff --git a/menu/menu.c b/menu/menu.c index ff2e38a402..35f569e20c 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -275,65 +275,6 @@ void menu_free(void *data) free(data); } -/** - * menu_ticker_line: - * @buf : buffer to write new message line to. - * @len : length of buffer @input. - * @idx : Index. Will be used for ticker logic. - * @str : Input string. - * @selected : Is the item currently selected in the menu? - * - * Take the contents of @str and apply a ticker effect to it, - * and write the results in @buf. - **/ -void menu_ticker_line(char *buf, size_t len, unsigned idx, - const char *str, bool selected) -{ - unsigned ticker_period, phase, phase_left_stop; - unsigned phase_left_moving, phase_right_stop; - unsigned left_offset, right_offset; - size_t str_len = strlen(str); - - if (str_len <= len) - { - strlcpy(buf, str, len + 1); - return; - } - - if (!selected) - { - strlcpy(buf, str, len + 1 - 3); - strlcat(buf, "...", len + 1); - return; - } - - /* Wrap long strings in options with some kind of ticker line. */ - ticker_period = 2 * (str_len - len) + 4; - phase = idx % ticker_period; - - phase_left_stop = 2; - phase_left_moving = phase_left_stop + (str_len - len); - phase_right_stop = phase_left_moving + 2; - - left_offset = phase - phase_left_stop; - right_offset = (str_len - len) - (phase - phase_right_stop); - - /* Ticker period: - * [Wait at left (2 ticks), - * Progress to right(type_len - w), - * Wait at right (2 ticks), - * Progress to left]. - */ - if (phase < phase_left_stop) - strlcpy(buf, str, len + 1); - else if (phase < phase_left_moving) - strlcpy(buf, str + left_offset, len + 1); - else if (phase < phase_right_stop) - strlcpy(buf, str + str_len - len, len + 1); - else - strlcpy(buf, str + right_offset, len + 1); -} - void menu_apply_deferred_settings(void) { rarch_setting_t *setting = NULL; diff --git a/menu/menu.h b/menu/menu.h index 56eaae055b..28366d84e1 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -177,20 +177,6 @@ int menu_iterate(retro_input_t input, **/ void menu_free(void *data); -/** - * menu_ticker_line: - * @buf : buffer to write new message line to. - * @len : length of buffer @input. - * @idx : Index. Will be used for ticker logic. - * @str : Input string. - * @selected : Is the item currently selected in the menu? - * - * Take the contents of @str and apply a ticker effect to it, - * and write the results in @buf. - **/ -void menu_ticker_line(char *buf, size_t len, unsigned tick, - const char *str, bool selected); - /** * menu_load_content: * diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 9bf8e6534e..67797be801 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -17,6 +17,8 @@ #include "menu_animation.h" #include "../driver.h" #include +#include +#include /* from https://github.com/kikito/tween.lua/blob/master/tween.lua */ @@ -444,3 +446,61 @@ void menu_animation_update(animation_t *animation, float dt) animation->size = 0; } +/** + * menu_animation_ticker_line: + * @buf : buffer to write new message line to. + * @len : length of buffer @input. + * @idx : Index. Will be used for ticker logic. + * @str : Input string. + * @selected : Is the item currently selected in the menu? + * + * Take the contents of @str and apply a ticker effect to it, + * and write the results in @buf. + **/ +void menu_animation_ticker_line(char *buf, size_t len, unsigned idx, + const char *str, bool selected) +{ + unsigned ticker_period, phase, phase_left_stop; + unsigned phase_left_moving, phase_right_stop; + unsigned left_offset, right_offset; + size_t str_len = strlen(str); + + if (str_len <= len) + { + strlcpy(buf, str, len + 1); + return; + } + + if (!selected) + { + strlcpy(buf, str, len + 1 - 3); + strlcat(buf, "...", len + 1); + return; + } + + /* Wrap long strings in options with some kind of ticker line. */ + ticker_period = 2 * (str_len - len) + 4; + phase = idx % ticker_period; + + phase_left_stop = 2; + phase_left_moving = phase_left_stop + (str_len - len); + phase_right_stop = phase_left_moving + 2; + + left_offset = phase - phase_left_stop; + right_offset = (str_len - len) - (phase - phase_right_stop); + + /* Ticker period: + * [Wait at left (2 ticks), + * Progress to right(type_len - w), + * Wait at right (2 ticks), + * Progress to left]. + */ + if (phase < phase_left_stop) + strlcpy(buf, str, len + 1); + else if (phase < phase_left_moving) + strlcpy(buf, str + left_offset, len + 1); + else if (phase < phase_right_stop) + strlcpy(buf, str + str_len - len, len + 1); + else + strlcpy(buf, str + right_offset, len + 1); +} diff --git a/menu/menu_animation.h b/menu/menu_animation.h index 69e7a6aef5..0bbca69282 100644 --- a/menu/menu_animation.h +++ b/menu/menu_animation.h @@ -102,6 +102,20 @@ bool menu_animation_push(animation_t *animation, float duration, void menu_animation_update(animation_t *animation, float dt); +/** + * menu_animation_ticker_line: + * @buf : buffer to write new message line to. + * @len : length of buffer @input. + * @idx : Index. Will be used for ticker logic. + * @str : Input string. + * @selected : Is the item currently selected in the menu? + * + * Take the contents of @str and apply a ticker effect to it, + * and write the results in @buf. + **/ +void menu_animation_ticker_line(char *buf, size_t len, unsigned tick, + const char *str, bool selected); + #ifdef __cplusplus } #endif From 8e42857488ae4a49640a071d133bfd9d9bf965ec Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 19:16:06 +0100 Subject: [PATCH 063/147] (Menu) Move set_texture call to higher-level iterate function --- menu/drivers/glui.c | 3 --- menu/drivers/ios.c | 3 --- menu/drivers/rgui.c | 11 +++-------- menu/drivers/rmenu.c | 3 --- menu/drivers/rmenu_xui.cpp | 3 --- menu/drivers/xmb.c | 3 --- menu/menu.c | 3 +++ 7 files changed, 6 insertions(+), 23 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 3eb77bc192..8941c614ea 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -51,9 +51,6 @@ static int glui_entry_iterate(unsigned action) menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL); - if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture) - driver.menu_ctx->set_texture(driver.menu); - if (cbs && cbs->action_iterate) return cbs->action_iterate(label, action); diff --git a/menu/drivers/ios.c b/menu/drivers/ios.c index 6df78ff90a..8136177512 100644 --- a/menu/drivers/ios.c +++ b/menu/drivers/ios.c @@ -48,9 +48,6 @@ static int ios_entry_iterate(unsigned action) menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL); - if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture) - driver.menu_ctx->set_texture(driver.menu); - if (cbs && cbs->action_iterate) return cbs->action_iterate(label, action); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 6f53ea0fd1..e2d71ccba9 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -49,15 +49,10 @@ static int rgui_entry_iterate(unsigned action) menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL); - if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture) - driver.menu_ctx->set_texture(driver.menu); + if (cbs && cbs->action_iterate) + return cbs->action_iterate(label, action); - if (!cbs) - return -1; - if (!cbs->action_iterate) - return -1; - - return cbs->action_iterate(label, action); + return -1; } static void rgui_copy_glyph(uint8_t *glyph, const uint8_t *buf) diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index 4ac8d7ef86..ca15af886c 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -73,9 +73,6 @@ static int rmenu_entry_iterate(unsigned action) menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL); - if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture) - driver.menu_ctx->set_texture(driver.menu); - if (cbs && cbs->action_iterate) return cbs->action_iterate(label, action); diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index 2648523c5e..78f935788a 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -67,9 +67,6 @@ static int rmenu_xui_entry_iterate(unsigned action) menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL); - if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture) - driver.menu_ctx->set_texture(driver.menu); - if (cbs && cbs->action_iterate) return cbs->action_iterate(label, action); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 1315c78ebe..6162180895 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -170,9 +170,6 @@ static int xmb_entry_iterate(unsigned action) menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL); - if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture) - driver.menu_ctx->set_texture(driver.menu); - if (cbs && cbs->action_iterate) return cbs->action_iterate(label, action); diff --git a/menu/menu.c b/menu/menu.c index 35f569e20c..e724e87039 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -355,6 +355,9 @@ int menu_iterate(retro_input_t input, int32_t ret = 0; unsigned action = menu_input_frame(input, trigger_input); + if (driver.menu_ctx && driver.menu_ctx->set_texture) + driver.menu_ctx->set_texture(driver.menu); + if (driver.menu_ctx && driver.menu_ctx->entry_iterate) ret = driver.menu_ctx->entry_iterate(action); From b0bd9fdd9daed1e203e135686761e058ca4137f8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 19:17:30 +0100 Subject: [PATCH 064/147] (menu.c) menu_iterate - cleanups --- menu/menu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/menu/menu.c b/menu/menu.c index e724e87039..cf756436bd 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -355,11 +355,13 @@ int menu_iterate(retro_input_t input, int32_t ret = 0; unsigned action = menu_input_frame(input, trigger_input); - if (driver.menu_ctx && driver.menu_ctx->set_texture) - driver.menu_ctx->set_texture(driver.menu); - - if (driver.menu_ctx && driver.menu_ctx->entry_iterate) - ret = driver.menu_ctx->entry_iterate(action); + if (driver.menu_ctx) + { + if (driver.menu_ctx->set_texture) + driver.menu_ctx->set_texture(driver.menu); + if (driver.menu_ctx->entry_iterate) + ret = driver.menu_ctx->entry_iterate(action); + } if (g_extern.is_menu) draw_frame(); From 6b8aece1f783d9f6b4e88b38ae59a7eb1fe7456a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 19:28:06 +0100 Subject: [PATCH 065/147] (Menu) Cleanups --- menu/drivers/glui.c | 8 +-- menu/drivers/ios.c | 24 +-------- menu/drivers/rgui.c | 104 ++++++++++++++++++------------------- menu/drivers/rmenu.c | 8 +-- menu/drivers/rmenu_xui.cpp | 8 +-- menu/drivers/xmb.c | 8 +-- menu/menu.c | 6 +-- menu/menu_driver.h | 2 +- 8 files changed, 73 insertions(+), 95 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 8941c614ea..8500e4d202 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -42,14 +42,14 @@ typedef struct glui_handle GLuint bg; } glui_handle_t; -static int glui_entry_iterate(unsigned action) +static int glui_entry_iterate(menu_handle_t *menu, unsigned action) { const char *label = NULL; menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr); + menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, + menu->selection_ptr); - menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL); + menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); if (cbs && cbs->action_iterate) return cbs->action_iterate(label, action); diff --git a/menu/drivers/ios.c b/menu/drivers/ios.c index 8136177512..4f15356e21 100644 --- a/menu/drivers/ios.c +++ b/menu/drivers/ios.c @@ -25,35 +25,15 @@ #include "ios.h" #include "../menu_input.h" -#if 1 -static int ios_entry_iterate(unsigned action) +static int ios_entry_iterate(menu_handle_t *menu, unsigned action) { - ios_handle_t *ios = NULL; - if (!driver.menu) - return 0; + ios_handle_t *ios = (ios_handle_t*)menu->userdata; - ios = (ios_handle_t*)driver.menu->userdata; if (ios->switch_to_ios) ios->switch_to_ios(); return 0; } -#else -static int ios_entry_iterate(unsigned action) -{ - const char *label = NULL; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr); - - menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL); - - if (cbs && cbs->action_iterate) - return cbs->action_iterate(label, action); - - return -1; -} -#endif static void *ios_init(void) { diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index e2d71ccba9..e855604cd1 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -36,18 +36,18 @@ #define RGUI_TERM_WIDTH (((driver.menu->width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE))) #define RGUI_TERM_HEIGHT (((driver.menu->height - RGUI_TERM_START_Y - RGUI_TERM_START_X) / (FONT_HEIGHT_STRIDE)) - 1) -static int rgui_entry_iterate(unsigned action) +static int rgui_entry_iterate(menu_handle_t *menu, unsigned action) { const char *label = NULL; - if (!driver.menu || !driver.menu->menu_list) + if (!menu || !menu->menu_list) return -1; menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr); + menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, + menu->selection_ptr); - menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL); + menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); if (cbs && cbs->action_iterate) return cbs->action_iterate(label, action); @@ -136,17 +136,13 @@ static void color_rect(menu_handle_t *menu, for (j = y; j < y + height; j++) for (i = x; i < x + width; i++) - if (i < driver.menu->width && j < driver.menu->height) + if (i < menu->width && j < menu->height) menu->frame_buf.data[j * (menu->frame_buf.pitch >> 1) + i] = color; } -static void blit_line(int x, int y, const char *message, bool green) +static void blit_line(menu_handle_t *menu, int x, int y, const char *message, bool green) { unsigned i, j; - menu_handle_t *menu = driver.menu; - - if (!menu) - return; while (*message) { @@ -240,8 +236,9 @@ static void rgui_render_messagebox(const char *message) int x, y; unsigned width, glyphs_width, height; struct string_list *list = NULL; + menu_handle_t *menu = driver.menu; - if (!driver.menu || !message || !*message) + if (!menu || !message || !*message) return; list = string_split(message, "\n"); @@ -274,21 +271,21 @@ static void rgui_render_messagebox(const char *message) } height = FONT_HEIGHT_STRIDE * list->size + 6 + 10; - x = (driver.menu->width - width) / 2; - y = (driver.menu->height - height) / 2; + x = (menu->width - width) / 2; + y = (menu->height - height) / 2; - fill_rect(driver.menu, x + 5, y + 5, width - 10, height - 10, gray_filler); - fill_rect(driver.menu, x, y, width - 5, 5, green_filler); - fill_rect(driver.menu, x + width - 5, y, 5, height - 5, green_filler); - fill_rect(driver.menu, x + 5, y + height - 5, width - 5, 5, green_filler); - fill_rect(driver.menu, x, y + 5, 5, height - 5, green_filler); + fill_rect(menu, x + 5, y + 5, width - 10, height - 10, gray_filler); + fill_rect(menu, x, y, width - 5, 5, green_filler); + fill_rect(menu, x + width - 5, y, 5, height - 5, green_filler); + fill_rect(menu, x + 5, y + height - 5, width - 5, 5, green_filler); + fill_rect(menu, x, y + 5, 5, height - 5, green_filler); for (i = 0; i < list->size; i++) { const char *msg = list->elems[i].data; int offset_x = FONT_WIDTH_STRIDE * (glyphs_width - strlen(msg)) / 2; int offset_y = FONT_HEIGHT_STRIDE * i; - blit_line(x + 8 + offset_x, y + 8 + offset_y, msg, false); + blit_line(menu, x + 8 + offset_x, y + 8 + offset_y, msg, false); } end: @@ -314,33 +311,34 @@ static void rgui_render(void) const char *label = NULL; const char *core_name = NULL; const char *core_version = NULL; + menu_handle_t *menu = driver.menu; - if (driver.menu->need_refresh + if (!menu || (menu->need_refresh && g_extern.is_menu - && !driver.menu->msg_force) + && !menu->msg_force)) return; - driver.menu->mouse.ptr = driver.menu->mouse.y / 11 - 2 + driver.menu->begin; + menu->mouse.ptr = menu->mouse.y / 11 - 2 + menu->begin; - if (driver.menu->mouse.wheeldown && driver.menu->begin - < menu_list_get_size(driver.menu->menu_list) - RGUI_TERM_HEIGHT) - driver.menu->begin++; + if (menu->mouse.wheeldown && menu->begin + < menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT) + menu->begin++; - if (driver.menu->mouse.wheelup && driver.menu->begin > 0) - driver.menu->begin--; + if (menu->mouse.wheelup && menu->begin > 0) + menu->begin--; /* Do not scroll if all items are visible. */ - if (menu_list_get_size(driver.menu->menu_list) <= RGUI_TERM_HEIGHT) - driver.menu->begin = 0; + if (menu_list_get_size(menu->menu_list) <= RGUI_TERM_HEIGHT) + menu->begin = 0; - end = (driver.menu->begin + RGUI_TERM_HEIGHT <= - menu_list_get_size(driver.menu->menu_list)) ? - driver.menu->begin + RGUI_TERM_HEIGHT : - menu_list_get_size(driver.menu->menu_list); + end = (menu->begin + RGUI_TERM_HEIGHT <= + menu_list_get_size(menu->menu_list)) ? + menu->begin + RGUI_TERM_HEIGHT : + menu_list_get_size(menu->menu_list); - rgui_render_background(driver.menu); + rgui_render_background(menu); - menu_list_get_last_stack(driver.menu->menu_list, + menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type); #if 0 @@ -351,7 +349,7 @@ static void rgui_render(void) menu_animation_ticker_line(title_buf, RGUI_TERM_WIDTH - 3, g_extern.frame_count / RGUI_TERM_START_X, title, true); - blit_line(RGUI_TERM_START_X + RGUI_TERM_START_X, RGUI_TERM_START_X, title_buf, true); + blit_line(menu, RGUI_TERM_START_X + RGUI_TERM_START_X, RGUI_TERM_START_X, title_buf, true); core_name = g_extern.menu.info.library_name; if (!core_name) @@ -369,13 +367,13 @@ static void rgui_render(void) snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION, core_name, core_version); - blit_line( + blit_line(menu, RGUI_TERM_START_X + RGUI_TERM_START_X, (RGUI_TERM_HEIGHT * FONT_HEIGHT_STRIDE) + RGUI_TERM_START_Y + 2, title_msg, true); if (g_settings.menu.timedate_enable) - blit_line( + blit_line(menu, (RGUI_TERM_WIDTH * FONT_HEIGHT_STRIDE) + (60), (RGUI_TERM_HEIGHT * FONT_HEIGHT_STRIDE) + RGUI_TERM_START_Y + 2, timedate, true); @@ -384,7 +382,7 @@ static void rgui_render(void) x = RGUI_TERM_START_X; y = RGUI_TERM_START_Y; - for (i = driver.menu->begin; i < end; i++, y += FONT_HEIGHT_STRIDE) + for (i = menu->begin; i < end; i++, y += FONT_HEIGHT_STRIDE) { char message[PATH_MAX_LENGTH], type_str[PATH_MAX_LENGTH], entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH], @@ -394,23 +392,23 @@ static void rgui_render(void) bool selected = false; menu_file_list_cbs_t *cbs = NULL; - menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path, + menu_list_get_at_offset(menu->menu_list->selection_buf, i, &path, &entry_label, &type); cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, + menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, i); if (cbs && cbs->action_get_representation) - cbs->action_get_representation(driver.menu->menu_list->selection_buf, + cbs->action_get_representation(menu->menu_list->selection_buf, &w, type, i, label, type_str, sizeof(type_str), entry_label, path, path_buf, sizeof(path_buf)); - selected = (i == driver.menu->selection_ptr); + selected = (i == menu->selection_ptr); - if (i > (driver.menu->selection_ptr + 100)) + if (i > (menu->selection_ptr + 100)) continue; menu_animation_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2), @@ -426,16 +424,16 @@ static void rgui_render(void) w, type_str_buf); - blit_line(x, y, message, selected); + blit_line(menu, x, y, message, selected); } #ifdef GEKKO const char *message_queue; - if (driver.menu->msg_force) + if (menu->msg_force) { message_queue = msg_queue_pull(g_extern.msg_queue); - driver.menu->msg_force = false; + menu->msg_force = false; } else message_queue = driver.current_msg; @@ -443,18 +441,18 @@ static void rgui_render(void) rgui_render_messagebox(message_queue); #endif - if (driver.menu->keyboard.display) + if (menu->keyboard.display) { char msg[PATH_MAX_LENGTH]; - const char *str = *driver.menu->keyboard.buffer; + const char *str = *menu->keyboard.buffer; if (!str) str = ""; - snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str); + snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str); rgui_render_messagebox(msg); } - if (driver.menu->mouse.enable) - rgui_blit_cursor(driver.menu); + if (menu->mouse.enable) + rgui_blit_cursor(menu); } static void *rgui_init(void) diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index ca15af886c..7bdb2736b6 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -64,14 +64,14 @@ struct texture_image *menu_texture; static bool render_normal = true; static bool menu_texture_inited =false; -static int rmenu_entry_iterate(unsigned action) +static int rmenu_entry_iterate(menu_handle_t *menu, unsigned action) { const char *label = NULL; menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr); + menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, + menu->selection_ptr); - menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL); + menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); if (cbs && cbs->action_iterate) return cbs->action_iterate(label, action); diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index 78f935788a..60012067d0 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -58,14 +58,14 @@ HXUIOBJ root_menu; HXUIOBJ current_menu; static msg_queue_t *xui_msg_queue; -static int rmenu_xui_entry_iterate(unsigned action) +static int rmenu_xui_entry_iterate(menu_handle_t *menu, unsigned action) { const char *label = NULL; menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr); + menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, + menu->selection_ptr); - menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL); + menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); if (cbs && cbs->action_iterate) return cbs->action_iterate(label, action); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 6162180895..79c09ca4b6 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -161,14 +161,14 @@ static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current) return iy; } -static int xmb_entry_iterate(unsigned action) +static int xmb_entry_iterate(menu_handle_t *menu, unsigned action) { const char *label = NULL; menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr); + menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, + menu->selection_ptr); - menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, NULL); + menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); if (cbs && cbs->action_iterate) return cbs->action_iterate(label, action); diff --git a/menu/menu.c b/menu/menu.c index cf756436bd..9cd25d3b52 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -131,7 +131,7 @@ bool menu_load_content(void) driver.menu->msg_force = true; if (driver.menu_ctx && driver.menu_ctx->entry_iterate) - driver.menu_ctx->entry_iterate(MENU_ACTION_NOOP); + driver.menu_ctx->entry_iterate(driver.menu, MENU_ACTION_NOOP); draw_frame(); @@ -355,12 +355,12 @@ int menu_iterate(retro_input_t input, int32_t ret = 0; unsigned action = menu_input_frame(input, trigger_input); - if (driver.menu_ctx) + if (driver.menu && driver.menu_ctx) { if (driver.menu_ctx->set_texture) driver.menu_ctx->set_texture(driver.menu); if (driver.menu_ctx->entry_iterate) - ret = driver.menu_ctx->entry_iterate(action); + ret = driver.menu_ctx->entry_iterate(driver.menu, action); } if (g_extern.is_menu) diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 96e5f87378..e17eb913a4 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -204,7 +204,7 @@ typedef struct menu_ctx_driver void (*list_clear)(void *); void (*list_cache)(bool, unsigned); void (*list_set_selection)(void *); - int (*entry_iterate)(unsigned); + int (*entry_iterate)(menu_handle_t *menu, unsigned); const char *ident; } menu_ctx_driver_t; From 3cb62678863766530c3bf8a9d035d73f23ec8421 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 11 Feb 2015 19:29:24 +0100 Subject: [PATCH 066/147] (iOS) Build fix --- apple/common/utility.m | 2 -- apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apple/common/utility.m b/apple/common/utility.m index c187f6135e..8610da2846 100644 --- a/apple/common/utility.m +++ b/apple/common/utility.m @@ -18,8 +18,6 @@ #include "RetroArch_Apple.h" #include "../../settings_data.h" -#import - void apple_display_alert(const char *message, const char *title) { #ifdef IOS diff --git a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj index e954f4d9ec..f233fa8af7 100644 --- a/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj +++ b/apple/iOS/RetroArch_iOS.xcodeproj/project.pbxproj @@ -496,6 +496,7 @@ HEADER_SEARCH_PATHS = ( ../, "../../libretro-sdk/include", + ../../, ); INFOPLIST_FILE = "$(SRCROOT)/iOS/RetroArch-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.0; @@ -558,6 +559,7 @@ HEADER_SEARCH_PATHS = ( ../, "../../libretro-sdk/include", + ../../, ); INFOPLIST_FILE = "$(SRCROOT)/iOS/RetroArch-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.0; From 4d478434c7b7b69198bd72a15f2a19539d5ce6d7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 20:28:54 +0100 Subject: [PATCH 067/147] (Menu) Start getting rid of void * pointer --- gfx/d3d/d3d.cpp | 2 +- gfx/drivers/gl.c | 2 +- gfx/drivers/sdl2_gfx.c | 2 +- menu/drivers/glui.c | 80 +++++++++++++------------- menu/drivers/rgui.c | 14 ++--- menu/drivers/rmenu.c | 12 ++-- menu/drivers/rmenu_xui.cpp | 36 ++++++------ menu/drivers/xmb.c | 103 +++++++++++++++++++-------------- menu/menu_driver.h | 8 +-- menu/menu_entries_cbs.c | 114 ++++++++++++++++++++++--------------- menu/menu_input.c | 12 ++-- 11 files changed, 210 insertions(+), 175 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 3ed18f9863..e5b9c90d0d 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1668,7 +1668,7 @@ static bool d3d_frame(void *data, const void *frame, #ifdef HAVE_MENU if (g_extern.is_menu && driver.menu_ctx && driver.menu_ctx->frame) - driver.menu_ctx->frame(); + driver.menu_ctx->frame(driver.menu); #ifdef _XBOX /* TODO - should be refactored. */ diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 349dcc13cb..5e69b6f1f5 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1586,7 +1586,7 @@ static bool gl_frame(void *data, const void *frame, #if defined(HAVE_MENU) if (g_extern.is_menu && driver.menu_ctx && driver.menu_ctx->frame) - driver.menu_ctx->frame(); + driver.menu_ctx->frame(driver.menu); if (gl->menu_texture_enable) gl_draw_texture(gl); diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index bb2d83b1fc..4503da928a 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -500,7 +500,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, #ifdef HAVE_MENU if (g_extern.is_menu && driver.menu_ctx && driver.menu_ctx->frame) - driver.menu_ctx->frame(); + driver.menu_ctx->frame(driver.menu); #endif if (vid->menu.active) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 8500e4d202..f5be37a9a5 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -191,20 +191,20 @@ static void glui_draw_cursor(gl_t *gl, glui_handle_t *glui, float x, float y) gl->coords.color = gl->white_color_ptr; } -static void glui_get_message(const char *message) +static void glui_get_message(menu_handle_t *menu, const char *message) { glui_handle_t *glui = NULL; - if (!driver.menu || !message || !*message) + if (!menu || !message || !*message) return; - glui = (glui_handle_t*)driver.menu->userdata; + glui = (glui_handle_t*)menu->userdata; if (glui) strlcpy(glui->box_message, message, sizeof(glui->box_message)); } -static void glui_render_messagebox(const char *message) +static void glui_render_messagebox(menu_handle_t *menu, const char *message) { unsigned i; int x, y; @@ -212,10 +212,10 @@ static void glui_render_messagebox(const char *message) glui_handle_t *glui = NULL; gl_t *gl = (gl_t*)video_driver_resolve(NULL); - if (!driver.menu || !gl) + if (!menu || !gl) return; - glui = (glui_handle_t*)driver.menu->userdata; + glui = (glui_handle_t*)menu->userdata; if (!glui) return; @@ -242,7 +242,7 @@ end: string_list_free(list); } -static void glui_frame(void) +static void glui_frame(menu_handle_t *menu) { unsigned x, y; size_t i; @@ -258,17 +258,17 @@ static void glui_frame(void) const char *core_name = NULL; const char *core_version = NULL; - if (!driver.menu || !gl) + if (!menu || !gl) return; - glui = (glui_handle_t*)driver.menu->userdata; + glui = (glui_handle_t*)menu->userdata; if (!glui) return; - if (driver.menu->need_refresh + if (menu->need_refresh && g_extern.is_menu - && !driver.menu->msg_force) + && !menu->msg_force) return; glui->line_height = g_settings.video.font_size * 4 / 3; @@ -277,30 +277,30 @@ static void glui_frame(void) glui->term_width = (gl->win_width - glui->margin * 2) / glui->glyph_width; glui->term_height = (gl->win_height - glui->margin * 2) / glui->line_height - 2; - driver.menu->mouse.ptr = (driver.menu->mouse.y - glui->margin) / - glui->line_height - 2 + driver.menu->begin; + menu->mouse.ptr = (menu->mouse.y - glui->margin) / + glui->line_height - 2 + menu->begin; glViewport(0, 0, gl->win_width, gl->win_height); - if (driver.menu->mouse.wheeldown && driver.menu->begin - < menu_list_get_size(driver.menu->menu_list) - glui->term_height) - driver.menu->begin++; + if (menu->mouse.wheeldown && menu->begin + < menu_list_get_size(menu->menu_list) - glui->term_height) + menu->begin++; - if (driver.menu->mouse.wheelup && driver.menu->begin > 0) - driver.menu->begin--; + if (menu->mouse.wheelup && menu->begin > 0) + menu->begin--; /* Do not scroll if all items are visible. */ - if (menu_list_get_size(driver.menu->menu_list) <= glui->term_height) - driver.menu->begin = 0; + if (menu_list_get_size(menu->menu_list) <= glui->term_height) + menu->begin = 0; - end = (driver.menu->begin + glui->term_height <= - menu_list_get_size(driver.menu->menu_list)) ? - driver.menu->begin + glui->term_height : - menu_list_get_size(driver.menu->menu_list); + end = (menu->begin + glui->term_height <= + menu_list_get_size(menu->menu_list)) ? + menu->begin + glui->term_height : + menu_list_get_size(menu->menu_list); glui_render_background(gl, glui, false); - menu_list_get_last_stack(driver.menu->menu_list, &dir, &label, &menu_type); + menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type); get_title(label, dir, menu_type, title, sizeof(title)); @@ -341,7 +341,7 @@ static void glui_frame(void) x = glui->margin; y = glui->margin + glui->line_height * 2; - for (i = driver.menu->begin; i < end; i++, y += glui->line_height) + for (i = menu->begin; i < end; i++, y += glui->line_height) { char message[PATH_MAX_LENGTH], type_str[PATH_MAX_LENGTH], entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH], @@ -351,21 +351,21 @@ static void glui_frame(void) bool selected = false; menu_file_list_cbs_t *cbs = NULL; - menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path, + menu_list_get_at_offset(menu->menu_list->selection_buf, i, &path, &entry_label, &type); cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, + menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, i); if (cbs && cbs->action_get_representation) - cbs->action_get_representation(driver.menu->menu_list->selection_buf, + cbs->action_get_representation(menu->menu_list->selection_buf, &w, type, i, label, type_str, sizeof(type_str), entry_label, path, path_buf, sizeof(path_buf)); - selected = (i == driver.menu->selection_ptr); + selected = (i == menu->selection_ptr); menu_animation_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2), g_extern.frame_count / glui->margin, path_buf, selected); @@ -383,37 +383,37 @@ static void glui_frame(void) #ifdef GEKKO const char *message_queue; - if (driver.menu->msg_force) + if (menu->msg_force) { message_queue = msg_queue_pull(g_extern.msg_queue); - driver.menu->msg_force = false; + menu->msg_force = false; } else message_queue = driver.current_msg; - glui_render_messagebox(message_queue); + glui_render_messagebox(menu, message_queue); #endif - if (driver.menu->keyboard.display) + if (menu->keyboard.display) { char msg[PATH_MAX_LENGTH]; - const char *str = *driver.menu->keyboard.buffer; + const char *str = *menu->keyboard.buffer; if (!str) str = ""; glui_render_background(gl, glui, true); - snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str); - glui_render_messagebox(msg); + snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str); + glui_render_messagebox(menu, msg); } if (glui->box_message[0] != '\0') { glui_render_background(gl, glui, true); - glui_render_messagebox(glui->box_message); + glui_render_messagebox(menu, glui->box_message); glui->box_message[0] = '\0'; } - if (driver.menu->mouse.enable) - glui_draw_cursor(gl, glui, driver.menu->mouse.x, driver.menu->mouse.y); + if (menu->mouse.enable) + glui_draw_cursor(gl, glui, menu->mouse.x, menu->mouse.y); gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); } diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index e855604cd1..456a351379 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -230,13 +230,12 @@ static void rgui_render_background(menu_handle_t *menu) green_filler); } -static void rgui_render_messagebox(const char *message) +static void rgui_render_messagebox(menu_handle_t *menu, const char *message) { size_t i; int x, y; unsigned width, glyphs_width, height; struct string_list *list = NULL; - menu_handle_t *menu = driver.menu; if (!menu || !message || !*message) return; @@ -301,7 +300,7 @@ static void rgui_blit_cursor(menu_handle_t *menu) color_rect(driver.menu, x - 5, y, 11, 1, 0xFFFF); } -static void rgui_render(void) +static void rgui_render(menu_handle_t *menu) { size_t i, end; char title[256], title_buf[256], title_msg[64]; @@ -311,7 +310,6 @@ static void rgui_render(void) const char *label = NULL; const char *core_name = NULL; const char *core_version = NULL; - menu_handle_t *menu = driver.menu; if (!menu || (menu->need_refresh && g_extern.is_menu @@ -438,7 +436,7 @@ static void rgui_render(void) else message_queue = driver.current_msg; - rgui_render_messagebox(message_queue); + rgui_render_messagebox(menu, message_queue); #endif if (menu->keyboard.display) @@ -448,7 +446,7 @@ static void rgui_render(void) if (!str) str = ""; snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str); - rgui_render_messagebox(msg); + rgui_render_messagebox(menu, msg); } if (menu->mouse.enable) @@ -512,10 +510,8 @@ static void rgui_free(void *data) free((uint8_t*)menu->font); } -static void rgui_set_texture(void *data) +static void rgui_set_texture(menu_handle_t *menu) { - menu_handle_t *menu = (menu_handle_t*)data; - if (!menu) return; if (!driver.video_data) diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index 7bdb2736b6..910c21cba5 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -83,7 +83,7 @@ static void rmenu_render_background(void) { } -static void rmenu_render_messagebox(const char *message) +static void rmenu_render_messagebox(menu_handle_t *menu, const char *message) { struct font_params font_parms; size_t i, j; @@ -132,7 +132,7 @@ end: string_list_free(list); } -static void rmenu_render(void) +static void rmenu_render(menu_handle_t *menu) { size_t begin, end; size_t i, j; @@ -144,7 +144,6 @@ static void rmenu_render(void) const char *core_name = NULL; const char *core_version = NULL; unsigned menu_type = 0; - menu_handle_t *menu = (menu_handle_t*)driver.menu; if (!menu) return; @@ -279,13 +278,12 @@ static void rmenu_render(void) } } -static void rmenu_set_texture(void *data) +static void rmenu_set_texture(menu_handle_t *menu) { - menu_handle_t *menu = (menu_handle_t*)data; - + if (!menu) + return; if (menu_texture_inited) return; - if (!driver.video_data) return; if (!driver.video_poke) diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index 60012067d0..d0273a5f11 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -46,8 +46,8 @@ #define FONT_HEIGHT_STRIDE (FONT_HEIGHT + 1) #define RXUI_TERM_START_X 15 #define RXUI_TERM_START_Y 27 -#define RXUI_TERM_WIDTH (((driver.menu->width - RXUI_TERM_START_X - 15) / (FONT_WIDTH_STRIDE))) -#define RXUI_TERM_HEIGHT (((driver.menu->height - RXUI_TERM_START_Y - 15) / (FONT_HEIGHT_STRIDE)) - 1) +#define RXUI_TERM_WIDTH (((menu->width - RXUI_TERM_START_X - 15) / (FONT_WIDTH_STRIDE))) +#define RXUI_TERM_HEIGHT (((menu->height - RXUI_TERM_START_Y - 15) / (FONT_HEIGHT_STRIDE)) - 1) HXUIOBJ m_menulist; HXUIOBJ m_menutitle; @@ -406,7 +406,7 @@ end: string_list_free(list); } -static void rmenu_xui_frame(void) +static void rmenu_xui_frame(menu_handle_t *menu) { XUIMessage msg; XUIMessageRender msgRender; @@ -415,6 +415,8 @@ static void rmenu_xui_frame(void) d3d_video_t *d3d = (d3d_video_t*)driver.video_data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; + (void)menu; + vp_full.X = 0; vp_full.Y = 0; vp_full.Width = d3d->screen_width; @@ -462,7 +464,7 @@ static void rmenu_xui_render_background(void) XuiElementSetShow(m_background, TRUE); } -static void rmenu_xui_render_messagebox(const char *message) +static void rmenu_xui_render_messagebox(menu_handle_t *menu, const char *message) { msg_queue_clear(xui_msg_queue); msg_queue_push(xui_msg_queue, message, 2, 1); @@ -525,20 +527,20 @@ static void rmenu_xui_set_list_text(int index, const wchar_t* leftText, } } -static void rmenu_xui_render(void) +static void rmenu_xui_render(menu_handle_t *menu) { size_t end, i; char title[PATH_MAX_LENGTH]; const char *dir = NULL, *label = NULL; unsigned menu_type = 0; - if (!driver.menu || driver.menu->need_refresh && - g_extern.is_menu && !driver.menu->msg_force) + if (!menu || menu->need_refresh && + g_extern.is_menu && !menu->msg_force) return; rmenu_xui_render_background(); - menu_list_get_last_stack(driver.menu->menu_list, &dir, &label, &menu_type); + menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type); if (XuiHandleIsValid(m_menutitle)) { @@ -570,7 +572,7 @@ static void rmenu_xui_render(void) XuiTextElementSetText(m_menutitlebottom, strw_buffer); } - end = menu_list_get_size(driver.menu->menu_list); + end = menu_list_get_size(menu->menu_list); for (i = 0; i < end; i++) { wchar_t msg_left[PATH_MAX_LENGTH], msg_right[PATH_MAX_LENGTH]; @@ -579,15 +581,15 @@ static void rmenu_xui_render(void) unsigned type = 0, w = 0; menu_file_list_cbs_t *cbs = NULL; - menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path, + menu_list_get_at_offset(menu->menu_list->selection_buf, i, &path, &entry_label, &type); cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, + menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, i); if (cbs && cbs->action_get_representation) - cbs->action_get_representation(driver.menu->menu_list->selection_buf, + cbs->action_get_representation(menu->menu_list->selection_buf, &w, type, i, label, type_str, sizeof(type_str), entry_label, path, @@ -597,16 +599,16 @@ static void rmenu_xui_render(void) mbstowcs(msg_right, type_str, sizeof(msg_right) / sizeof(wchar_t)); rmenu_xui_set_list_text(i, msg_left, msg_right); } - XuiListSetCurSelVisible(m_menulist, driver.menu->selection_ptr); + XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); - if (driver.menu->keyboard.display) + if (menu->keyboard.display) { char msg[1024]; - const char *str = *driver.menu->keyboard.buffer; + const char *str = *menu->keyboard.buffer; if (!str) str = ""; - snprintf(msg, sizeof(msg), "%s\n%s", driver.menu->keyboard.label, str); - rmenu_xui_render_messagebox(msg); + snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str); + rmenu_xui_render_messagebox(menu, msg); } } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 79c09ca4b6..bb8626ba9d 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -375,9 +375,14 @@ static void xmb_render_background(gl_t *gl, xmb_handle_t *xmb, gl->coords.color = gl->white_color_ptr; } -static void xmb_get_message(const char *message) +static void xmb_get_message(menu_handle_t *menu, const char *message) { - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; + xmb_handle_t *xmb = NULL; + + if (!menu) + return; + + xmb = (xmb_handle_t*)menu->userdata; if (!xmb || !message || !*message) return; @@ -385,13 +390,18 @@ static void xmb_get_message(const char *message) strlcpy(xmb->box_message, message, sizeof(xmb->box_message)); } -static void xmb_render_messagebox(const char *message) +static void xmb_render_messagebox(menu_handle_t *menu, const char *message) { int x, y; unsigned i; struct string_list *list = NULL; gl_t *gl = (gl_t*)video_driver_resolve(NULL); - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; + xmb_handle_t *xmb = NULL; + + if (!menu) + return; + + xmb = (xmb_handle_t*)menu->userdata; if (!gl || !xmb) return; @@ -456,7 +466,7 @@ static void xmb_selection_pointer_changed(menu_handle_t *menu) } } -static void xmb_list_open_old(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) +static void xmb_list_open_old(menu_handle_t *menu, xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; @@ -473,13 +483,14 @@ static void xmb_list_open_old(xmb_handle_t *xmb, file_list_t *list, int dir, siz if (dir == -1) ia = 0; - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, xmb->icon_size*dir*-2, &node->x, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, 0, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, xmb->icon_size*dir*-2, &node->x, EASING_IN_OUT_QUAD, NULL); } } -static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) +static void xmb_list_open_new(menu_handle_t *menu, + xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; @@ -514,9 +525,9 @@ static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, siz if (i == current) ia = xmb->i_active_alpha; - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->x, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, 0, &node->x, EASING_IN_OUT_QUAD, NULL); } xmb->old_depth = xmb->depth; @@ -678,19 +689,19 @@ static void xmb_list_open(xmb_handle_t *xmb) xmb->active_category_old = driver.menu->cat_selection_ptr; } -static void xmb_list_switch(xmb_handle_t *xmb) +static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) { unsigned j; int dir = 0; - xmb->depth = file_list_get_size(driver.menu->menu_list->menu_stack); + xmb->depth = file_list_get_size(menu->menu_list->menu_stack); if (xmb->depth > xmb->old_depth) dir = 1; else if (xmb->depth < xmb->old_depth) dir = -1; - for (j = 0; j < driver.menu->num_categories; j++) + for (j = 0; j < menu->num_categories; j++) { float ia = 0; xmb_node_t *node = j ? xmb_node_for_core(xmb, j - 1) : &xmb->settings_node; @@ -703,25 +714,25 @@ static void xmb_list_switch(xmb_handle_t *xmb) else if (xmb->depth <= 1) ia = xmb->c_passive_alpha; - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); } - xmb_list_open_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); - xmb_list_open_new(xmb, driver.menu->menu_list->selection_buf, dir, driver.menu->selection_ptr); + xmb_list_open_old(menu, xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); + xmb_list_open_new(menu, xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); switch (xmb->depth) { case 1: - menu_animation_push(driver.menu->animation, XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), + menu_animation_push(menu->animation, XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &xmb->arrow_alpha, + menu_animation_push(menu->animation, XMB_DELAY, 0, &xmb->arrow_alpha, EASING_IN_OUT_QUAD, NULL); break; case 2: - menu_animation_push(driver.menu->animation, XMB_DELAY, + menu_animation_push(menu->animation, XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), &xmb->x, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, 1, &xmb->arrow_alpha, + menu_animation_push(menu->animation, XMB_DELAY, 1, &xmb->arrow_alpha, EASING_IN_OUT_QUAD, NULL); break; } @@ -732,7 +743,13 @@ static void xmb_list_switch(xmb_handle_t *xmb) static void xmb_populate_entries(void *data, const char *path, const char *label, unsigned k) { - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; + menu_handle_t *menu = driver.menu; + xmb_handle_t *xmb = NULL; + + if (!menu) + return; + + xmb = (xmb_handle_t*)driver.menu->userdata; if (!xmb) return; @@ -748,7 +765,7 @@ static void xmb_populate_entries(void *data, const char *path, if (driver.menu->cat_selection_ptr != xmb->active_category_old) xmb_list_open(xmb); else - xmb_list_switch(xmb); + xmb_list_switch(menu, xmb); } static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, @@ -916,20 +933,20 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, } } -static void xmb_frame(void) +static void xmb_frame(menu_handle_t *menu) { int i, depth; char title_msg[PATH_MAX_LENGTH], timedate[PATH_MAX_LENGTH]; const char *core_name = NULL; const char *core_version = NULL; - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; + xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata; gl_t *gl = (gl_t*)video_driver_resolve(NULL); if (!xmb || !gl) return; - menu_animation_update(driver.menu->animation, 0.002); + menu_animation_update(menu->animation, 0.002); glViewport(0, 0, gl->win_width, gl->win_height); @@ -974,22 +991,22 @@ static void xmb_frame(void) xmb->margin_top + xmb->icon_size/2.0 + xmb->vspacing * xmb->active_item_factor, xmb->arrow_alpha, 0, 1); - depth = file_list_get_size(driver.menu->menu_list->menu_stack); + depth = file_list_get_size(menu->menu_list->menu_stack); xmb_draw_items(xmb, gl, xmb->selection_buf_old, xmb->menu_stack_old, xmb->selection_ptr_old, - depth > 1 ? driver.menu->cat_selection_ptr : + depth > 1 ? menu->cat_selection_ptr : xmb->cat_selection_ptr_old); xmb_draw_items(xmb, gl, - driver.menu->menu_list->selection_buf, - driver.menu->menu_list->menu_stack, - driver.menu->selection_ptr, - driver.menu->cat_selection_ptr); + menu->menu_list->selection_buf, + menu->menu_list->menu_stack, + menu->selection_ptr, + menu->cat_selection_ptr); - for (i = 0; i < driver.menu->num_categories; i++) + for (i = 0; i < menu->num_categories; i++) { xmb_node_t *node = i ? xmb_node_for_core(xmb, i - 1) : &xmb->settings_node; @@ -1005,34 +1022,34 @@ static void xmb_frame(void) #ifdef GEKKO const char *message_queue; - if (driver.menu->msg_force) + if (menu->msg_force) { message_queue = msg_queue_pull(g_extern.msg_queue); - driver.menu->msg_force = false; + menu->msg_force = false; } else message_queue = driver.current_msg; - xmb_render_messagebox(message_queue); + xmb_render_messagebox(menu, message_queue); #endif - if (driver.menu->keyboard.display) + if (menu->keyboard.display) { char msg[PATH_MAX_LENGTH]; - const char *str = *driver.menu->keyboard.buffer; + const char *str = *menu->keyboard.buffer; if (!str) str = ""; snprintf(msg, sizeof(msg), "%s\n%s", - driver.menu->keyboard.label, str); + menu->keyboard.label, str); xmb_render_background(gl, xmb, true); - xmb_render_messagebox(msg); + xmb_render_messagebox(menu, msg); } if (xmb->box_message[0] != '\0') { xmb_render_background(gl, xmb, true); - xmb_render_messagebox(xmb->box_message); + xmb_render_messagebox(menu, xmb->box_message); xmb->box_message[0] = '\0'; } @@ -1280,7 +1297,7 @@ static void xmb_context_reset(void *data) if (!info_list) return; - for (i = 1; i < driver.menu->num_categories; i++) + for (i = 1; i < menu->num_categories; i++) { node = xmb_node_for_core(xmb, i - 1); diff --git a/menu/menu_driver.h b/menu/menu_driver.h index e17eb913a4..04a7e640fd 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -181,10 +181,10 @@ typedef struct menu_file_list_cbs typedef struct menu_ctx_driver { - void (*set_texture)(void*); - void (*render_messagebox)(const char*); - void (*render)(void); - void (*frame)(void); + void (*set_texture)(menu_handle_t *menu); + void (*render_messagebox)(menu_handle_t *menu, const char *msg); + void (*render)(menu_handle_t *menu); + void (*frame)(menu_handle_t *menu); void* (*init)(void); void (*free)(void*); void (*context_reset)(void*); diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 52d82e9223..de0fe256ae 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -215,6 +215,10 @@ static int archive_load(void) static int load_or_open_zip_iterate(unsigned action) { char msg[PATH_MAX_LENGTH]; + menu_handle_t *menu = driver.menu; + + if (!menu) + return -1; snprintf(msg, sizeof(msg), "Opening compressed file\n" " \n" @@ -226,7 +230,7 @@ static int load_or_open_zip_iterate(unsigned action) && driver.menu_ctx->render_messagebox) { if (*msg && msg[0] != '\0') - driver.menu_ctx->render_messagebox(msg); + driver.menu_ctx->render_messagebox(menu, msg); } switch (action) @@ -3685,12 +3689,13 @@ static int action_iterate_help(const char *label, unsigned action) }; char desc[ARRAY_SIZE(binds)][64]; char msg[PATH_MAX_LENGTH]; + menu_handle_t *menu = driver.menu; - if (!driver.menu) + if (!menu) return 0; if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(); + driver.menu_ctx->render(menu); for (i = 0; i < ARRAY_SIZE(binds); i++) { @@ -3727,10 +3732,10 @@ static int action_iterate_help(const char *label, unsigned action) desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6]); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(msg); + driver.menu_ctx->render_messagebox(menu, msg); if (action == MENU_ACTION_OK) - menu_list_pop(driver.menu->menu_list->menu_stack, NULL); + menu_list_pop(menu->menu_list->menu_stack, NULL); return 0; } @@ -3741,23 +3746,26 @@ static int action_iterate_info(const char *label, unsigned action) char needle[PATH_MAX_LENGTH]; unsigned info_type = 0; rarch_setting_t *current_setting = NULL; - file_list_t *list = (file_list_t*)driver.menu->menu_list->selection_buf; + file_list_t *list = NULL; + menu_handle_t *menu = driver.menu; - if (!driver.menu) + if (!menu) return 0; + + list = (file_list_t*)menu->menu_list->selection_buf; if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(); + driver.menu_ctx->render(menu); current_setting = (rarch_setting_t*)setting_data_find_setting( - driver.menu->list_settings, - list->list[driver.menu->selection_ptr].label); + menu->list_settings, + list->list[menu->selection_ptr].label); if (current_setting) strlcpy(needle, current_setting->name, sizeof(needle)); else if ((current_setting = (rarch_setting_t*)setting_data_find_setting( - driver.menu->list_settings, - list->list[driver.menu->selection_ptr].label))) + menu->list_settings, + list->list[menu->selection_ptr].label))) { if (current_setting) strlcpy(needle, current_setting->name, sizeof(needle)); @@ -3765,8 +3773,8 @@ static int action_iterate_info(const char *label, unsigned action) else { const char *lbl = NULL; - menu_list_get_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr, NULL, &lbl, + menu_list_get_at_offset(list, + menu->selection_ptr, NULL, &lbl, &info_type); if (lbl) @@ -3779,11 +3787,11 @@ static int action_iterate_info(const char *label, unsigned action) driver.menu_ctx->render_messagebox) { if (*msg && msg[0] != '\0') - driver.menu_ctx->render_messagebox(msg); + driver.menu_ctx->render_messagebox(menu, msg); } if (action == MENU_ACTION_OK) - menu_list_pop(driver.menu->menu_list->menu_stack, &driver.menu->selection_ptr); + menu_list_pop(menu->menu_list->menu_stack, &menu->selection_ptr); return 0; } @@ -3814,8 +3822,12 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) unsigned type = 0; rarch_viewport_t *custom = (rarch_viewport_t*) &g_extern.console.screen.viewports.custom_vp; + menu_handle_t *menu = driver.menu; - menu_list_get_last_stack(driver.menu->menu_list, NULL, NULL, &type); + if (!menu) + return -1; + + menu_list_get_last_stack(menu->menu_list, NULL, NULL, &type); geom = (struct retro_game_geometry*)&g_extern.system.av_info.geometry; @@ -3878,24 +3890,24 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) break; case MENU_ACTION_CANCEL: - menu_list_pop_stack(driver.menu->menu_list); + menu_list_pop_stack(menu->menu_list); if (!strcmp(label, "custom_viewport_2")) { - menu_list_push_stack(driver.menu->menu_list, "", "", + menu_list_push_stack(menu->menu_list, "", "", MENU_SETTINGS_CUSTOM_VIEWPORT, - driver.menu->selection_ptr); + menu->selection_ptr); } break; case MENU_ACTION_OK: - menu_list_pop_stack(driver.menu->menu_list); + menu_list_pop_stack(menu->menu_list); if (type == MENU_SETTINGS_CUSTOM_VIEWPORT && !g_settings.video.scale_integer) { - menu_list_push_stack(driver.menu->menu_list, "", - "custom_viewport_2", 0, driver.menu->selection_ptr); + menu_list_push_stack(menu->menu_list, "", + "custom_viewport_2", 0, menu->selection_ptr); } break; @@ -3926,17 +3938,17 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) break; case MENU_ACTION_MESSAGE: - driver.menu->msg_force = true; + menu->msg_force = true; break; default: break; } - menu_list_get_last_stack(driver.menu->menu_list, NULL, &label, &type); + menu_list_get_last_stack(menu->menu_list, NULL, &label, &type); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(); + driver.menu_ctx->render(menu); if (g_settings.video.scale_integer) { @@ -3967,7 +3979,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(msg); + driver.menu_ctx->render_messagebox(menu, msg); if (!custom->width) custom->width = stride_x; @@ -3998,12 +4010,17 @@ static int action_iterate_custom_bind_keyboard(const char *label, unsigned actio static int action_iterate_message(const char *label, unsigned action) { + menu_handle_t *menu = driver.menu; + + if (!menu) + return -1; + if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(driver.menu->message_contents); + driver.menu_ctx->render_messagebox(menu, menu->message_contents); if (action == MENU_ACTION_OK) - menu_list_pop_stack(driver.menu->menu_list); + menu_list_pop_stack(menu->menu_list); return 0; } @@ -4055,13 +4072,18 @@ static int action_iterate_main(const char *label, unsigned action) unsigned type_offset = 0; const char *label_offset = NULL; const char *path_offset = NULL; + menu_file_list_cbs_t *cbs = NULL; + menu_handle_t *menu = driver.menu; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr); + if (!menu) + return 0; + + cbs = (menu_file_list_cbs_t*) + menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, + menu->selection_ptr); - menu_list_get_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr, &path_offset, &label_offset, &type_offset); + menu_list_get_at_offset(menu->menu_list->selection_buf, + menu->selection_ptr, &path_offset, &label_offset, &type_offset); mouse_iterate(action); @@ -4090,7 +4112,7 @@ static int action_iterate_main(const char *label, unsigned action) return action_iterate_custom_bind(label, action); } - if (driver.menu->need_refresh && action != MENU_ACTION_MESSAGE) + if (menu->need_refresh && action != MENU_ACTION_MESSAGE) action = MENU_ACTION_REFRESH; switch (action) @@ -4101,20 +4123,20 @@ static int action_iterate_main(const char *label, unsigned action) ret = cbs->action_up_or_down(type_offset, label_offset, action); break; case MENU_ACTION_SCROLL_UP: - menu_navigation_descend_alphabet(driver.menu, &driver.menu->selection_ptr); + menu_navigation_descend_alphabet(menu, &menu->selection_ptr); break; case MENU_ACTION_SCROLL_DOWN: - menu_navigation_ascend_alphabet(driver.menu, &driver.menu->selection_ptr); + menu_navigation_ascend_alphabet(menu, &menu->selection_ptr); break; case MENU_ACTION_CANCEL: if (cbs && cbs->action_cancel) - return cbs->action_cancel(path_offset, label_offset, type_offset, driver.menu->selection_ptr); + return cbs->action_cancel(path_offset, label_offset, type_offset, menu->selection_ptr); break; case MENU_ACTION_OK: if (cbs && cbs->action_ok) - return cbs->action_ok(path_offset, label_offset, type_offset, driver.menu->selection_ptr); + return cbs->action_ok(path_offset, label_offset, type_offset, menu->selection_ptr); break; case MENU_ACTION_START: if (cbs && cbs->action_start) @@ -4132,12 +4154,12 @@ static int action_iterate_main(const char *label, unsigned action) case MENU_ACTION_REFRESH: if (cbs && cbs->action_refresh) - ret = cbs->action_refresh(driver.menu->menu_list->selection_buf, - driver.menu->menu_list->menu_stack); + ret = cbs->action_refresh(menu->menu_list->selection_buf, + menu->menu_list->menu_stack); break; case MENU_ACTION_MESSAGE: - driver.menu->msg_force = true; + menu->msg_force = true; break; case MENU_ACTION_SEARCH: @@ -4157,13 +4179,13 @@ static int action_iterate_main(const char *label, unsigned action) ret = mouse_post_iterate(cbs, path_offset, label_offset, type_offset, action); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(); + driver.menu_ctx->render(menu); /* Have to defer it so we let settings refresh. */ - if (driver.menu->push_start_screen) + if (menu->push_start_screen) { - menu_list_push_stack(driver.menu->menu_list, "", "help", 0, 0); - driver.menu->push_start_screen = false; + menu_list_push_stack(menu->menu_list, "", "help", 0, 0); + menu->push_start_screen = false; } return ret; diff --git a/menu/menu_input.c b/menu/menu_input.c index 622186d6ae..66da5a5ebb 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -363,7 +363,7 @@ int menu_input_bind_iterate(void *data) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(); + driver.menu_ctx->render(menu); snprintf(msg, sizeof(msg), "[%s]\npress joypad\n(RETURN to skip)", input_config_bind_map[ @@ -371,7 +371,7 @@ int menu_input_bind_iterate(void *data) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(msg); + driver.menu_ctx->render_messagebox(menu, msg); driver.block_input = true; menu_input_poll_bind_state(&binds); @@ -406,18 +406,18 @@ int menu_input_bind_iterate_keyboard(void *data) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(); + driver.menu_ctx->render(menu); current = rarch_get_time_usec(); - timeout = (driver.menu->binds.timeout_end - current) / 1000000; + timeout = (menu->binds.timeout_end - current) / 1000000; snprintf(msg, sizeof(msg), "[%s]\npress keyboard\n(timeout %d seconds)", input_config_bind_map[ - driver.menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc, + menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc, timeout); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(msg); + driver.menu_ctx->render_messagebox(menu, msg); if (timeout <= 0) { From 0c170ab56e0f96c0a6c5a2fdcf108630ea1bf585 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 20:40:48 +0100 Subject: [PATCH 068/147] (Menu) Get rid of void * pt. 2 --- menu/drivers/glui.c | 24 ++++++++----------- menu/drivers/rgui.c | 25 ++++++++++---------- menu/drivers/rmenu_xui.cpp | 16 +++++-------- menu/drivers/xmb.c | 47 ++++++++++++++++++-------------------- menu/menu_driver.h | 24 +++++++++---------- 5 files changed, 61 insertions(+), 75 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index f5be37a9a5..654e278bd3 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -463,15 +463,11 @@ static void glui_free(void *data) } -static void glui_context_reset(void *data) +static void glui_context_reset(menu_handle_t *menu) { char bgpath[PATH_MAX_LENGTH]; glui_handle_t *glui = NULL; - menu_handle_t *menu = (menu_handle_t*)data; - gl_t *gl = (gl_t*)video_driver_resolve(NULL); - (void)gl; - if (!menu) return; @@ -494,17 +490,15 @@ static void glui_context_reset(void *data) TEXTURE_FILTER_LINEAR); } -static void glui_navigation_clear(void *data, bool pending_push) +static void glui_navigation_clear(menu_handle_t *menu, bool pending_push) { - menu_handle_t *menu = (menu_handle_t*)data; if (menu) menu->begin = 0; } -static void glui_navigation_set(void *data, bool scroll) +static void glui_navigation_set(menu_handle_t *menu, bool scroll) { glui_handle_t *glui = NULL; - menu_handle_t *menu = (menu_handle_t*)data; if (!menu) return; @@ -528,19 +522,19 @@ static void glui_navigation_set(void *data, bool scroll) - glui->term_height; } -static void glui_navigation_set_last(void *data) +static void glui_navigation_set_last(menu_handle_t *menu) { - glui_navigation_set(data, true); + glui_navigation_set(menu, true); } -static void glui_navigation_descend_alphabet(void *data, size_t *unused) +static void glui_navigation_descend_alphabet(menu_handle_t *menu, size_t *unused) { - glui_navigation_set(data, true); + glui_navigation_set(menu, true); } -static void glui_navigation_ascend_alphabet(void *data, size_t *unused) +static void glui_navigation_ascend_alphabet(menu_handle_t *menu, size_t *unused) { - glui_navigation_set(data, true); + glui_navigation_set(menu, true); } menu_ctx_driver_t menu_ctx_glui = { diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 456a351379..d9149a9f93 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -525,15 +525,14 @@ static void rgui_set_texture(menu_handle_t *menu) menu->frame_buf.data, false, menu->width, menu->height, 1.0f); } -static void rgui_navigation_clear(void *data, bool pending_push) +static void rgui_navigation_clear(menu_handle_t *menu, bool pending_push) { - driver.menu->begin = 0; + if (menu) + menu->begin = 0; } -static void rgui_navigation_set(void *data, bool scroll) +static void rgui_navigation_set(menu_handle_t *menu, bool scroll) { - menu_handle_t *menu = (menu_handle_t*)data; - if (!menu) return; if (!scroll) @@ -551,25 +550,25 @@ static void rgui_navigation_set(void *data, bool scroll) - RGUI_TERM_HEIGHT; } -static void rgui_navigation_set_last(void *data) +static void rgui_navigation_set_last(menu_handle_t *menu) { - rgui_navigation_set(data, true); + rgui_navigation_set(menu, true); } -static void rgui_navigation_descend_alphabet(void *data, size_t *unused) +static void rgui_navigation_descend_alphabet(menu_handle_t *menu, size_t *unused) { - rgui_navigation_set(data, true); + rgui_navigation_set(menu, true); } -static void rgui_navigation_ascend_alphabet(void *data, size_t *unused) +static void rgui_navigation_ascend_alphabet(menu_handle_t *menu, size_t *unused) { - rgui_navigation_set(data, true); + rgui_navigation_set(menu, true); } -static void rgui_populate_entries(void *data, const char *path, +static void rgui_populate_entries(menu_handle_t *menu, const char *path, const char *label, unsigned k) { - rgui_navigation_set(data, true); + rgui_navigation_set(menu, true); } menu_ctx_driver_t menu_ctx_rgui = { diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index d0273a5f11..2b9f856623 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -612,33 +612,30 @@ static void rmenu_xui_render(menu_handle_t *menu) } } -static void rmenu_xui_populate_entries(void *data, const char *path, +static void rmenu_xui_populate_entries(menu_handle_t *menu, const char *path, const char *label, unsigned i) { - menu_handle_t *menu = (menu_handle_t*)data; + (void)menu; (void)label; (void)path; XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); } -static void rmenu_xui_navigation_clear(void *data, bool pending_push) +static void rmenu_xui_navigation_clear(menu_handle_t *menu, bool pending_push) { - menu_handle_t *menu = (menu_handle_t*)data; - (void)pending_push; if (menu) XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); } -static void rmenu_xui_navigation_set_visible(void *data) +static void rmenu_xui_navigation_set_visible(menu_handle_t *menu) { - menu_handle_t *menu = (menu_handle_t*)data; XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); } -static void rmenu_xui_navigation_alphabet(void *data, size_t *ptr_out) +static void rmenu_xui_navigation_alphabet(menu_handle_t *menu, size_t *ptr_out) { XuiListSetCurSelVisible(m_menulist, *ptr_out); } @@ -674,9 +671,8 @@ static void rmenu_xui_list_clear(void *data) XuiListDeleteItems(m_menulist, 0, XuiListGetItemCount(m_menulist)); } -static void rmenu_xui_list_set_selection(void *data) +static void rmenu_xui_list_set_selection(file_list_t *list) { - file_list_t *list = (file_list_t*)data; if (list) XuiListSetCurSel(m_menulist, file_list_get_directory_ptr(list)); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index bb8626ba9d..fdcd9a823f 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -740,16 +740,15 @@ static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) xmb->old_depth = xmb->depth; } -static void xmb_populate_entries(void *data, const char *path, +static void xmb_populate_entries(menu_handle_t *menu, const char *path, const char *label, unsigned k) { - menu_handle_t *menu = driver.menu; xmb_handle_t *xmb = NULL; if (!menu) return; - xmb = (xmb_handle_t*)driver.menu->userdata; + xmb = (xmb_handle_t*)menu->userdata; if (!xmb) return; @@ -762,7 +761,7 @@ static void xmb_populate_entries(void *data, const char *path, xmb_set_title(xmb); - if (driver.menu->cat_selection_ptr != xmb->active_category_old) + if (menu->cat_selection_ptr != xmb->active_category_old) xmb_list_open(xmb); else xmb_list_switch(menu, xmb); @@ -1198,7 +1197,7 @@ static bool xmb_font_init_first(const gl_font_renderer_t **font_driver, font_path, xmb_font_size); } -static void xmb_context_reset(void *data) +static void xmb_context_reset(menu_handle_t *menu) { int i, k; char bgpath[PATH_MAX_LENGTH]; @@ -1210,7 +1209,6 @@ static void xmb_context_reset(void *data) core_info_list_t* info_list = NULL; gl_t *gl = NULL; xmb_handle_t *xmb = NULL; - menu_handle_t *menu = (menu_handle_t*)data; xmb_node_t *node = NULL; if (!menu) @@ -1347,44 +1345,44 @@ static void xmb_context_reset(void *data) } } -static void xmb_navigation_clear(void *data, bool pending_push) +static void xmb_navigation_clear(menu_handle_t *menu, bool pending_push) { if (!pending_push) - xmb_selection_pointer_changed((menu_handle_t*)data); + xmb_selection_pointer_changed(menu); } -static void xmb_navigation_decrement(void *data) +static void xmb_navigation_decrement(menu_handle_t *menu) { - xmb_selection_pointer_changed((menu_handle_t*)data); + xmb_selection_pointer_changed(menu); } -static void xmb_navigation_increment(void *data) +static void xmb_navigation_increment(menu_handle_t *menu) { - xmb_selection_pointer_changed((menu_handle_t*)data); + xmb_selection_pointer_changed(menu); } -static void xmb_navigation_set(void *data, bool scroll) +static void xmb_navigation_set(menu_handle_t *menu, bool scroll) { (void)scroll; - xmb_selection_pointer_changed((menu_handle_t*)data); + xmb_selection_pointer_changed(menu); } -static void xmb_navigation_set_last(void *data) +static void xmb_navigation_set_last(menu_handle_t *menu) { - xmb_selection_pointer_changed((menu_handle_t*)data); + xmb_selection_pointer_changed(menu); } -static void xmb_navigation_descend_alphabet(void *data, size_t *unused) +static void xmb_navigation_descend_alphabet(menu_handle_t *menu, size_t *unused) { (void)unused; - xmb_selection_pointer_changed((menu_handle_t*)data); + xmb_selection_pointer_changed(menu); } -static void xmb_navigation_ascend_alphabet(void *data, size_t *unused) +static void xmb_navigation_ascend_alphabet(menu_handle_t *menu, size_t *unused) { (void)unused; - xmb_selection_pointer_changed((menu_handle_t*)data); + xmb_selection_pointer_changed(menu); } static void xmb_list_insert(void *data, @@ -1488,16 +1486,15 @@ static void xmb_list_cache(bool horizontal, unsigned action) MENU_SETTING_HORIZONTAL_MENU; } -static void xmb_list_set_selection(void *data) +static void xmb_list_set_selection(file_list_t *list) { - (void)data; + (void)list; } -static void xmb_context_destroy(void *data) +static void xmb_context_destroy(menu_handle_t *menu) { unsigned i; xmb_handle_t *xmb = NULL; - menu_handle_t *menu = (menu_handle_t*)driver.menu; if (!menu) return; @@ -1510,7 +1507,7 @@ static void xmb_context_destroy(void *data) for (i = 0; i < XMB_TEXTURE_LAST; i++) glDeleteTextures(1, &xmb->textures[i].id); - for (i = 1; i < driver.menu->num_categories; i++) + for (i = 1; i < menu->num_categories; i++) { xmb_node_t *node = xmb_node_for_core(xmb, i - 1); diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 04a7e640fd..28692c3315 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -187,23 +187,23 @@ typedef struct menu_ctx_driver void (*frame)(menu_handle_t *menu); void* (*init)(void); void (*free)(void*); - void (*context_reset)(void*); - void (*context_destroy)(void*); - void (*populate_entries)(void*, const char *, const char *, - unsigned); + void (*context_reset)(menu_handle_t *menu); + void (*context_destroy)(menu_handle_t *menu); + void (*populate_entries)(menu_handle_t *menu, const char *path, const char *label, + unsigned k); void (*toggle)(bool); - void (*navigation_clear)(void *, bool); - void (*navigation_decrement)(void *); - void (*navigation_increment)(void *); - void (*navigation_set)(void *, bool); - void (*navigation_set_last)(void *); - void (*navigation_descend_alphabet)(void *, size_t *); - void (*navigation_ascend_alphabet)(void *, size_t *); + void (*navigation_clear)(menu_handle_t *menu, bool); + void (*navigation_decrement)(menu_handle_t *menu); + void (*navigation_increment)(menu_handle_t *menu); + void (*navigation_set)(menu_handle_t *menu, bool); + void (*navigation_set_last)(menu_handle_t *menu); + void (*navigation_descend_alphabet)(menu_handle_t *menu, size_t *); + void (*navigation_ascend_alphabet)(menu_handle_t *menu, size_t *); void (*list_insert)(void *, const char *, const char *, size_t); void (*list_delete)(void *, size_t, size_t); void (*list_clear)(void *); void (*list_cache)(bool, unsigned); - void (*list_set_selection)(void *); + void (*list_set_selection)(file_list_t *list); int (*entry_iterate)(menu_handle_t *menu, unsigned); const char *ident; } menu_ctx_driver_t; From fb3122758509614276f359733fc72ecf874f4bbd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 21:00:34 +0100 Subject: [PATCH 069/147] (Menu) Refactors --- menu/drivers/rmenu_xui.cpp | 11 ++++--- menu/drivers/xmb.c | 60 +++++++++++++++++--------------------- menu/menu_driver.h | 8 ++--- menu/menu_entries_cbs.c | 2 +- menu/menu_list.c | 12 ++++---- 5 files changed, 43 insertions(+), 50 deletions(-) diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index 2b9f856623..3c5f0207d9 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -640,10 +640,10 @@ static void rmenu_xui_navigation_alphabet(menu_handle_t *menu, size_t *ptr_out) XuiListSetCurSelVisible(m_menulist, *ptr_out); } -static void rmenu_xui_list_insert(void *data, +static void rmenu_xui_list_insert(menu_handle_t *menu, + file_list_t *list, const char *path, const char *, size_t list_size) { - (void)data; wchar_t buf[PATH_MAX_LENGTH]; XuiListInsertItems(m_menulist, list_size, 1); @@ -651,12 +651,12 @@ static void rmenu_xui_list_insert(void *data, XuiListSetText(m_menulist, list_size, buf); } -static void rmenu_xui_list_delete(void *data, size_t idx, +static void rmenu_xui_list_delete(menu_handle_t *menu, + file_list_t *list, size_t idx, size_t list_size) { int x = XuiListGetItemCount( m_menulist ); - (void)data; (void)idx; if( list_size > x ) @@ -665,9 +665,8 @@ static void rmenu_xui_list_delete(void *data, size_t idx, XuiListDeleteItems(m_menulist, 0, list_size); } -static void rmenu_xui_list_clear(void *data) +static void rmenu_xui_list_clear(menu_handle_t *menu, file_list_t *list) { - (void)data; XuiListDeleteItems(m_menulist, 0, XuiListGetItemCount(m_menulist)); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index fdcd9a823f..ad5f3f1e4a 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1385,13 +1385,17 @@ static void xmb_navigation_ascend_alphabet(menu_handle_t *menu, size_t *unused) xmb_selection_pointer_changed(menu); } -static void xmb_list_insert(void *data, +static void xmb_list_insert(menu_handle_t *menu, file_list_t *list, const char *path, const char *unused, size_t list_size) { int current = 0, i = list_size; xmb_node_t *node = NULL; - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; - file_list_t *list = (file_list_t*)data; + xmb_handle_t *xmb = NULL; + + if (!menu) + return; + + xmb = (xmb_handle_t*)menu->userdata; if (!list || !xmb) return; @@ -1409,7 +1413,7 @@ static void xmb_list_insert(void *data, if (!node) return; - current = driver.menu->selection_ptr; + current = menu->selection_ptr; node->alpha = xmb->i_passive_alpha; node->zoom = xmb->i_passive_zoom; @@ -1425,11 +1429,10 @@ static void xmb_list_insert(void *data, } } -static void xmb_list_delete(void *data, size_t idx, +static void xmb_list_delete(menu_handle_t *menu, + file_list_t *list, size_t idx, size_t list_size) { - file_list_t *list = (file_list_t*)data; - if (!list) return; @@ -1438,59 +1441,50 @@ static void xmb_list_delete(void *data, size_t idx, list->list[idx].userdata = NULL; } -static void xmb_list_clear(void *data) -{ - (void)data; -} - -static void xmb_list_cache(bool horizontal, unsigned action) +static void xmb_list_cache(menu_handle_t *menu, + bool horizontal, unsigned action) { size_t stack_size; - xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; + xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata; if (!xmb) return; - file_list_copy(driver.menu->menu_list->selection_buf, xmb->selection_buf_old); - file_list_copy(driver.menu->menu_list->menu_stack, xmb->menu_stack_old); - xmb->selection_ptr_old = driver.menu->selection_ptr; + file_list_copy(menu->menu_list->selection_buf, xmb->selection_buf_old); + file_list_copy(menu->menu_list->menu_stack, xmb->menu_stack_old); + xmb->selection_ptr_old = menu->selection_ptr; if(!horizontal) return; - xmb->cat_selection_ptr_old = driver.menu->cat_selection_ptr; + xmb->cat_selection_ptr_old = menu->cat_selection_ptr; switch (action) { case MENU_ACTION_LEFT: - driver.menu->cat_selection_ptr--; + menu->cat_selection_ptr--; break; default: - driver.menu->cat_selection_ptr++; + menu->cat_selection_ptr++; break; } - stack_size = driver.menu->menu_list->menu_stack->size; + stack_size = menu->menu_list->menu_stack->size; - strlcpy(driver.menu->menu_list->menu_stack->list[stack_size-1].label, + strlcpy(menu->menu_list->menu_stack->list[stack_size-1].label, "Main Menu", PATH_MAX_LENGTH); - driver.menu->menu_list->menu_stack->list[stack_size-1].type = + menu->menu_list->menu_stack->list[stack_size-1].type = MENU_SETTINGS; - if (driver.menu->cat_selection_ptr == 0) + if (menu->cat_selection_ptr == 0) return; - strlcpy(driver.menu->menu_list->menu_stack->list[stack_size-1].label, + strlcpy(menu->menu_list->menu_stack->list[stack_size-1].label, "Horizontal Menu", PATH_MAX_LENGTH); - driver.menu->menu_list->menu_stack->list[stack_size-1].type = + menu->menu_list->menu_stack->list[stack_size-1].type = MENU_SETTING_HORIZONTAL_MENU; } -static void xmb_list_set_selection(file_list_t *list) -{ - (void)list; -} - static void xmb_context_destroy(menu_handle_t *menu) { unsigned i; @@ -1586,9 +1580,9 @@ menu_ctx_driver_t menu_ctx_xmb = { xmb_navigation_ascend_alphabet, xmb_list_insert, xmb_list_delete, - xmb_list_clear, + NULL, xmb_list_cache, - xmb_list_set_selection, + NULL, xmb_entry_iterate, "xmb", }; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 28692c3315..050a680436 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -199,10 +199,10 @@ typedef struct menu_ctx_driver void (*navigation_set_last)(menu_handle_t *menu); void (*navigation_descend_alphabet)(menu_handle_t *menu, size_t *); void (*navigation_ascend_alphabet)(menu_handle_t *menu, size_t *); - void (*list_insert)(void *, const char *, const char *, size_t); - void (*list_delete)(void *, size_t, size_t); - void (*list_clear)(void *); - void (*list_cache)(bool, unsigned); + void (*list_insert)(menu_handle_t *menu, file_list_t *list, const char *, const char *, size_t); + void (*list_delete)(menu_handle_t *menu, file_list_t *list, size_t, size_t); + void (*list_clear)(menu_handle_t *menu, file_list_t *list); + void (*list_cache)(menu_handle_t *menu, bool, unsigned); void (*list_set_selection)(file_list_t *list); int (*entry_iterate)(menu_handle_t *menu, unsigned); const char *ident; diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index de0fe256ae..9aa54bfd67 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -2096,7 +2096,7 @@ static int action_toggle_mainmenu(unsigned type, const char *label, { case 1: if (driver.menu_ctx->list_cache) - driver.menu_ctx->list_cache(true, action); + driver.menu_ctx->list_cache(driver.menu, true, action); if (cbs && cbs->action_content_list_switch) return cbs->action_content_list_switch( diff --git a/menu/menu_list.c b/menu/menu_list.c index d8b9337204..6778069908 100644 --- a/menu/menu_list.c +++ b/menu/menu_list.c @@ -136,7 +136,7 @@ void menu_list_destroy(file_list_t *list) for (i = 0; i < list->size; i++) { if (driver.menu_ctx->list_delete) - driver.menu_ctx->list_delete(list, i, list->size); + driver.menu_ctx->list_delete(driver.menu, list, i, list->size); menu_common_list_delete(list, i, list->size); } @@ -271,7 +271,7 @@ void menu_list_pop_stack(menu_list_t *list) return; if (driver.menu_ctx->list_cache) - driver.menu_ctx->list_cache(false, 0); + driver.menu_ctx->list_cache(driver.menu, false, 0); menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); driver.menu->need_refresh = true; @@ -307,7 +307,7 @@ void menu_list_pop(file_list_t *list, size_t *directory_ptr) size_t list_size = list->size - 1; if (driver.menu_ctx->list_delete) - driver.menu_ctx->list_delete(list, list_size, list_size); + driver.menu_ctx->list_delete(driver.menu, list, list_size, list_size); menu_common_list_delete(list, list_size, list_size); } @@ -329,7 +329,7 @@ void menu_list_clear(file_list_t *list) goto end; if (driver.menu_ctx->list_clear) - driver.menu_ctx->list_clear(list); + driver.menu_ctx->list_clear(driver.menu, list); end: menu_common_list_clear(list); @@ -343,7 +343,7 @@ static void menu_list_insert(file_list_t *list, return; if (driver.menu_ctx->list_insert) - driver.menu_ctx->list_insert(list, path, label, list->size - 1); + driver.menu_ctx->list_insert(driver.menu, list, path, label, list->size - 1); menu_common_list_insert(list, path, label, type, list->size - 1); } @@ -387,7 +387,7 @@ int menu_list_push_stack_refresh(menu_list_t *list, return -1; if (driver.menu_ctx->list_cache) - driver.menu_ctx->list_cache(false, 0); + driver.menu_ctx->list_cache(driver.menu, false, 0); menu_list_push_stack(list, path, label, type, directory_ptr); menu_navigation_clear(driver.menu, true); From 7ade44cbc387fb7c380d016f93c8f1ea5f79c648 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 21:06:50 +0100 Subject: [PATCH 070/147] (360) Build fixes --- menu/drivers/rmenu_xui.cpp | 3 ++- msvc/RetroArch-360/RetroArch-360.vcxproj | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index 3c5f0207d9..cf73dfa8ae 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -547,7 +547,7 @@ static void rmenu_xui_render(menu_handle_t *menu) get_title(label, dir, menu_type, title, sizeof(title)); mbstowcs(strw_buffer, title, sizeof(strw_buffer) / sizeof(wchar_t)); XuiTextElementSetText(m_menutitle, strw_buffer); - menu_ticker_line(title, RXUI_TERM_WIDTH - 3, g_extern.frame_count / 15, title, true); + menu_animation_ticker_line(title, RXUI_TERM_WIDTH - 3, g_extern.frame_count / 15, title, true); } if (XuiHandleIsValid(m_menutitle)) @@ -686,6 +686,7 @@ menu_ctx_driver_t menu_ctx_rmenu_xui = { NULL, NULL, rmenu_xui_populate_entries, + NULL, rmenu_xui_navigation_clear, rmenu_xui_navigation_set_visible, rmenu_xui_navigation_set_visible, diff --git a/msvc/RetroArch-360/RetroArch-360.vcxproj b/msvc/RetroArch-360/RetroArch-360.vcxproj index 1ea7fac582..5ca8c859c4 100644 --- a/msvc/RetroArch-360/RetroArch-360.vcxproj +++ b/msvc/RetroArch-360/RetroArch-360.vcxproj @@ -115,7 +115,7 @@ MultiThreadedDebug _DEBUG;_XBOX;HAVE_XINPUT2;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU_XUI;HAVE_MENU;HAVE_NETPLAY;HAVE_NETWORKING;HAVE_NETWORKING;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG;HAVE_FILTERS_BUILTIN Callcap - $(SolutionDir)\..\deps\rzlib;$(SolutionDir)\..\libretro-sdk\include;%(AdditionalIncludeDirectories) + $(SolutionDir)\..\deps\rzlib;$(SolutionDir)\..\libretro-sdk\include;$(SolutionDir)\..\;%(AdditionalIncludeDirectories) true @@ -154,7 +154,7 @@ MultiThreadedDebug _DEBUG;_XBOX;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU_XUI;HAVE_MENU;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;WANT_MINIZ;SINC_LOWER_QUALITY;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG;HAVE_FILTERS_BUILTIN Callcap - $(SolutionDir)\..\deps\rzlib;$(SolutionDir)\..\libretro-sdk\include;%(AdditionalIncludeDirectories) + $(SolutionDir)\..\deps\rzlib;$(SolutionDir)\..\libretro-sdk\include;$(SolutionDir)\..\;%(AdditionalIncludeDirectories) true @@ -194,7 +194,7 @@ MultiThreaded NDEBUG;_XBOX;PROFILE;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU_XUI;HAVE_MENU;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG;HAVE_FILTERS_BUILTIN Callcap - $(SolutionDir)\..\deps\rzlib;$(SolutionDir)\..\libretro-sdk\include;%(AdditionalIncludeDirectories) + $(SolutionDir)\..\deps\rzlib;$(SolutionDir)\..\libretro-sdk\include;$(SolutionDir)\..\;%(AdditionalIncludeDirectories) true @@ -238,7 +238,7 @@ false MultiThreaded NDEBUG;_XBOX;PROFILE;FASTCAP;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_RMENU_XUI;HAVE_MENU;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG;HAVE_FILTERS_BUILTIN - $(SolutionDir)\..\deps\rzlib;$(SolutionDir)\..\libretro-sdk\include;%(AdditionalIncludeDirectories) + $(SolutionDir)\..\deps\rzlib;$(SolutionDir)\..\libretro-sdk\include;$(SolutionDir)\..\;%(AdditionalIncludeDirectories) true @@ -280,7 +280,7 @@ false MultiThreaded NDEBUG;_XBOX;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE=1;HAVE_NETPLAY;HAVE_NETWORKING;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_RMENU_XUI;HAVE_MENU;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG;HAVE_FILTERS_BUILTIN - $(SolutionDir)\..\deps\rzlib;$(SolutionDir)\..\libretro-sdk\include;%(AdditionalIncludeDirectories) + $(SolutionDir)\..\deps\rzlib;$(SolutionDir)\..\libretro-sdk\include;$(SolutionDir)\..\;%(AdditionalIncludeDirectories) true @@ -322,7 +322,7 @@ false MultiThreaded NDEBUG;_XBOX;LTCG;%(PreprocessorDefinitions);HAVE_XINPUT2;_CRT_SECURE_NO_WARNINGS;RARCH_CONSOLE;HAVE_RMENU_XUI;HAVE_MENU;HAVE_NETPLAY;HAVE_NETWORKING;HAVE_SOCKET_LEGACY;HAVE_ZLIB;HAVE_RARCH_EXEC;HAVE_LIBRETRO_MANAGEMENT;D3DCOMPILE_USEVOIDS;HAVE_GRIFFIN;HAVE_HLSL;HAVE_D3D9;RARCH_INTERNAL;MSB_FIRST;_XBOX360;WANT_MINIZ;SINC_LOWER_QUALITY;HAVE_XAUDIO;WANT_RPNG;HAVE_THREADS;HAVE_BUILTIN_AUTOCONFIG;HAVE_FILTERS_BUILTIN - $(SolutionDir)\..\deps\rzlib;$(SolutionDir)\..\libretro-sdk\include;%(AdditionalIncludeDirectories) + $(SolutionDir)\..\deps\rzlib;$(SolutionDir)\..\libretro-sdk\include;$(SolutionDir)\..\;%(AdditionalIncludeDirectories) true @@ -437,4 +437,4 @@ - + \ No newline at end of file From c3fdd42fb089ce92032d8a0acb17cee1d50f6367 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 21:15:39 +0100 Subject: [PATCH 071/147] Refactor menu --- menu/drivers/rgui.c | 14 +++++----- menu/drivers/rmenu.c | 16 +++++------ menu/drivers/xmb.c | 66 ++++++++++++++++++++------------------------ menu/menu_driver.h | 2 +- retroarch.c | 4 +-- 5 files changed, 48 insertions(+), 54 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index d9149a9f93..d0cfaf30e1 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -31,10 +31,10 @@ #include "shared.h" -#define RGUI_TERM_START_X (driver.menu->width / 21) -#define RGUI_TERM_START_Y (driver.menu->height / 9) -#define RGUI_TERM_WIDTH (((driver.menu->width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE))) -#define RGUI_TERM_HEIGHT (((driver.menu->height - RGUI_TERM_START_Y - RGUI_TERM_START_X) / (FONT_HEIGHT_STRIDE)) - 1) +#define RGUI_TERM_START_X (menu->width / 21) +#define RGUI_TERM_START_Y (menu->height / 9) +#define RGUI_TERM_WIDTH (((menu->width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE))) +#define RGUI_TERM_HEIGHT (((menu->height - RGUI_TERM_START_Y - RGUI_TERM_START_X) / (FONT_HEIGHT_STRIDE)) - 1) static int rgui_entry_iterate(menu_handle_t *menu, unsigned action) { @@ -296,8 +296,8 @@ static void rgui_blit_cursor(menu_handle_t *menu) int16_t x = menu->mouse.x; int16_t y = menu->mouse.y; - color_rect(driver.menu, x, y - 5, 1, 11, 0xFFFF); - color_rect(driver.menu, x - 5, y, 11, 1, 0xFFFF); + color_rect(menu, x, y - 5, 1, 11, 0xFFFF); + color_rect(menu, x - 5, y, 11, 1, 0xFFFF); } static void rgui_render(menu_handle_t *menu) @@ -504,7 +504,7 @@ static void rgui_free(void *data) if (menu->userdata) free(menu->userdata); - driver.menu->userdata = NULL; + menu->userdata = NULL; if (menu->alloc_font) free((uint8_t*)menu->font); diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index 910c21cba5..d9bd82b638 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -158,17 +158,17 @@ static void rmenu_render(menu_handle_t *menu) && !menu->msg_force) return; - if (!driver.menu->menu_list->selection_buf) + if (!menu->menu_list->selection_buf) return; begin = (menu->selection_ptr >= (ENTRIES_HEIGHT / 2)) ? (menu->selection_ptr - (ENTRIES_HEIGHT / 2)) : 0; end = ((menu->selection_ptr + ENTRIES_HEIGHT) <= - menu_list_get_size(driver.menu->menu_list)) ? + menu_list_get_size(menu->menu_list)) ? menu->selection_ptr + ENTRIES_HEIGHT : - menu_list_get_size(driver.menu->menu_list); + menu_list_get_size(menu->menu_list); - if (menu_list_get_size(driver.menu->menu_list) <= ENTRIES_HEIGHT) + if (menu_list_get_size(menu->menu_list) <= ENTRIES_HEIGHT) begin = 0; if (end - begin > ENTRIES_HEIGHT) @@ -176,7 +176,7 @@ static void rmenu_render(menu_handle_t *menu) rmenu_render_background(); - menu_list_get_last_stack(driver.menu->menu_list, &dir, &label, &menu_type); + menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type); get_title(label, dir, menu_type, title, sizeof(title)); @@ -235,17 +235,17 @@ static void rmenu_render(menu_handle_t *menu) &path, &entry_label, &type); cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, + menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, i); if (cbs && cbs->action_get_representation) - cbs->action_get_representation(driver.menu->menu_list->selection_buf, + cbs->action_get_representation(menu->menu_list->selection_buf, &w, type, i, label, type_str, sizeof(type_str), entry_label, path, path_buf, sizeof(path_buf)); - selected = (i == driver.menu->selection_ptr); + selected = (i == menu->selection_ptr); menu_ticker_line(entry_title_buf, RMENU_TERM_WIDTH - (w + 1 + 2), g_extern.frame_count / 15, path, selected); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index ad5f3f1e4a..2676ba881d 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -577,7 +577,7 @@ static xmb_node_t* xmb_node_for_core(xmb_handle_t *xmb, int i) return node; } -static void xmb_list_switch_old(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) +static void xmb_list_switch_old(menu_handle_t *menu, xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; @@ -589,13 +589,13 @@ static void xmb_list_switch_old(xmb_handle_t *xmb, file_list_t *list, int dir, s if (!node) continue; - menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, -xmb->hspacing*dir, &node->x, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, 0, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, 0, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, -xmb->hspacing*dir, &node->x, EASING_IN_OUT_QUAD, NULL); } } -static void xmb_list_switch_new(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) +static void xmb_list_switch_new(menu_handle_t *menu, xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; @@ -615,21 +615,21 @@ static void xmb_list_switch_new(xmb_handle_t *xmb, file_list_t *list, int dir, s if (i == current) ia = 1.0; - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, 0, &node->x, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, 0, &node->x, EASING_IN_OUT_QUAD, NULL); } } -static void xmb_set_title(xmb_handle_t *xmb) +static void xmb_set_title(menu_handle_t *menu, xmb_handle_t *xmb) { - if (driver.menu->cat_selection_ptr == 0) + if (menu->cat_selection_ptr == 0) { const char *dir = NULL; const char *label = NULL; unsigned menu_type = 0; - menu_list_get_last_stack(driver.menu->menu_list, &dir, &label, &menu_type); + menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type); get_title(label, dir, menu_type, xmb->title, sizeof(xmb->title)); } else @@ -640,24 +640,24 @@ static void xmb_set_title(xmb_handle_t *xmb) if (!info_list) return; - info = (core_info_t*)&info_list->list[driver.menu->cat_selection_ptr - 1]; + info = (core_info_t*)&info_list->list[menu->cat_selection_ptr - 1]; if (info) strlcpy(xmb->title, info->display_name, sizeof(xmb->title)); } } -static void xmb_list_open(xmb_handle_t *xmb) +static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) { unsigned j; int dir = -1; - if (driver.menu->cat_selection_ptr > xmb->cat_selection_ptr_old) + if (menu->cat_selection_ptr > xmb->cat_selection_ptr_old) dir = 1; xmb->active_category += dir; - for (j = 0; j < driver.menu->num_categories; j++) + for (j = 0; j < menu->num_categories; j++) { float ia = xmb->c_passive_alpha; float iz = xmb->c_passive_zoom; @@ -672,21 +672,21 @@ static void xmb_list_open(xmb_handle_t *xmb) iz = xmb->c_active_zoom; } - menu_animation_push(driver.menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(driver.menu->animation, XMB_DELAY, iz, &node->zoom, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, iz, &node->zoom, EASING_IN_OUT_QUAD, NULL); } - menu_animation_push(driver.menu->animation, XMB_DELAY, - xmb->hspacing * -(float)driver.menu->cat_selection_ptr, + menu_animation_push(menu->animation, XMB_DELAY, + xmb->hspacing * -(float)menu->cat_selection_ptr, &xmb->categories_x, EASING_IN_OUT_QUAD, NULL); dir = -1; - if (driver.menu->cat_selection_ptr > xmb->cat_selection_ptr_old) + if (menu->cat_selection_ptr > xmb->cat_selection_ptr_old) dir = 1; - xmb_list_switch_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); - xmb_list_switch_new(xmb, driver.menu->menu_list->selection_buf, dir, driver.menu->selection_ptr); - xmb->active_category_old = driver.menu->cat_selection_ptr; + xmb_list_switch_old(menu, xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); + xmb_list_switch_new(menu, xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); + xmb->active_category_old = menu->cat_selection_ptr; } static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) @@ -759,10 +759,10 @@ static void xmb_populate_entries(menu_handle_t *menu, const char *path, return; } - xmb_set_title(xmb); + xmb_set_title(menu, xmb); if (menu->cat_selection_ptr != xmb->active_category_old) - xmb_list_open(xmb); + xmb_list_open(menu, xmb); else xmb_list_switch(menu, xmb); } @@ -1513,21 +1513,15 @@ static void xmb_context_destroy(menu_handle_t *menu) } } -static void xmb_toggle(bool menu_on) +static void xmb_toggle(menu_handle_t *menu, bool menu_on) { int i; - xmb_handle_t *xmb = NULL; - menu_handle_t *menu = (menu_handle_t*)driver.menu; - - if (!menu) - return; - - xmb = (xmb_handle_t*)menu->userdata; + xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata; if (!xmb) return; - xmb->depth = file_list_get_size(driver.menu->menu_list->menu_stack); + xmb->depth = file_list_get_size(menu->menu_list->menu_stack); if (!menu_on) { @@ -1535,12 +1529,12 @@ static void xmb_toggle(bool menu_on) return; } - menu_animation_push(driver.menu->animation, XMB_DELAY, 1.0f, + menu_animation_push(menu->animation, XMB_DELAY, 1.0f, &xmb->alpha, EASING_IN_OUT_QUAD, NULL); xmb->prevent_populate = !menu->need_refresh; - for (i = 0; i < driver.menu->num_categories; i++) + for (i = 0; i < menu->num_categories; i++) { xmb_node_t *node = i ? xmb_node_for_core(xmb, i - 1) : &xmb->settings_node; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 050a680436..a226b2b79e 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -191,7 +191,7 @@ typedef struct menu_ctx_driver void (*context_destroy)(menu_handle_t *menu); void (*populate_entries)(menu_handle_t *menu, const char *path, const char *label, unsigned k); - void (*toggle)(bool); + void (*toggle)(menu_handle_t *menu, bool); void (*navigation_clear)(menu_handle_t *menu, bool); void (*navigation_decrement)(menu_handle_t *menu); void (*navigation_increment)(menu_handle_t *menu); diff --git a/retroarch.c b/retroarch.c index c02e3e0e28..06ceb70dda 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1959,7 +1959,7 @@ void rarch_main_set_state(unsigned cmd) return; if (driver.menu && driver.menu_ctx && driver.menu_ctx->toggle) - driver.menu_ctx->toggle(true); + driver.menu_ctx->toggle(driver.menu, true); /* Menu should always run with vsync on. */ rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE); @@ -1994,7 +1994,7 @@ void rarch_main_set_state(unsigned cmd) menu_apply_deferred_settings(); if (driver.menu && driver.menu_ctx && driver.menu_ctx->toggle) - driver.menu_ctx->toggle(false); + driver.menu_ctx->toggle(driver.menu, false); g_extern.is_menu = false; From 7ce598c891123e22fbfec7c767d86d7622598308 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 21:21:03 +0100 Subject: [PATCH 072/147] (Wii) Fix warnings - unused values --- menu/menu_entries_cbs.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 9aa54bfd67..528a4f86b4 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -4268,6 +4268,9 @@ static void menu_action_setting_disp_set_label_shader_filter_pass( "Nearest" }; + (void)pass; + (void)modes; + *type_str = '\0'; *w = 19; strlcpy(path_buf, path, path_buf_size); @@ -4311,6 +4314,8 @@ static void menu_action_setting_disp_set_label_shader_pass( { unsigned pass = (type - MENU_SETTINGS_SHADER_PASS_0); + (void)pass; + *type_str = '\0'; *w = 19; strlcpy(path_buf, path, path_buf_size); @@ -4421,12 +4426,16 @@ static void menu_action_setting_disp_set_label_shader_scale_pass( const char *path, char *path_buf, size_t path_buf_size) { - unsigned pass, scale_value; + unsigned pass = 0; + unsigned scale_value = 0; *type_str = '\0'; *w = 19; strlcpy(path_buf, path, path_buf_size); + (void)pass; + (void)scale_value; + #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL) if (!driver.menu->shader) return; From 10fdaff1b645239e67aa3b3e678b7cda083d0f06 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 21:27:01 +0100 Subject: [PATCH 073/147] (Menu) Cleanups --- menu/menu_entries_cbs.c | 16 ++++++---------- menu/menu_shader.c | 3 +-- menu/menu_shader.h | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 528a4f86b4..b447156511 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -5355,27 +5355,23 @@ static void menu_entries_cbs_init_bind_refresh(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, const char *elem0, const char *elem1) { - if (!cbs || !driver.menu) - return; - - cbs->action_refresh = action_refresh_default; + if (cbs) + cbs->action_refresh = action_refresh_default; } static void menu_entries_cbs_init_bind_iterate(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, const char *elem0, const char *elem1) { - if (!cbs || !driver.menu) - return; - - cbs->action_iterate = action_iterate_main; + if (cbs) + cbs->action_iterate = action_iterate_main; } static void menu_entries_cbs_init_bind_get_string_representation(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, const char *elem0, const char *elem1) { - if (!cbs || !driver.menu) + if (!cbs) return; if (type >= MENU_SETTINGS_INPUT_DESC_BEGIN @@ -5524,7 +5520,7 @@ 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 idx, const char *elem0, const char *elem1) { - if (!cbs || !driver.menu) + if (!cbs) return; cbs->action_deferred_push = deferred_push_default; diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 2cb73f094e..6b14d1c92e 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -24,7 +24,7 @@ * * Initializes shader manager. **/ -void menu_shader_manager_init(void *data) +void menu_shader_manager_init(menu_handle_t *menu) { #ifdef HAVE_SHADER_MANAGER char preset_path[PATH_MAX_LENGTH]; @@ -32,7 +32,6 @@ void menu_shader_manager_init(void *data) struct video_shader *shader = NULL; config_file_t *conf = NULL; const char *config_path = NULL; - menu_handle_t *menu = (menu_handle_t*)data; if (!menu) return; diff --git a/menu/menu_shader.h b/menu/menu_shader.h index c62c20a7d1..991441d53b 100644 --- a/menu/menu_shader.h +++ b/menu/menu_shader.h @@ -28,7 +28,7 @@ extern "C" { * * Initializes shader manager. **/ -void menu_shader_manager_init(void *data); +void menu_shader_manager_init(menu_handle_t *menu); /** * menu_shader_manager_set_preset: From 8f77b7d52a1a70af87f371e88c0646f71cdf72a3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 21:29:14 +0100 Subject: [PATCH 074/147] (Menu) Cleanups pt. 2 --- menu/drivers/glui.c | 1 - menu/drivers/rgui.c | 1 - menu/drivers/xmb.c | 1 - menu/menu_animation.c | 1 - 4 files changed, 4 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 654e278bd3..ad8adcf596 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -23,7 +23,6 @@ #include "../menu.h" #include "../menu_texture.h" -#include "../menu_input.h" #include #include "../../gfx/gl_common.h" diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index d0cfaf30e1..f1f9b004ab 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -22,7 +22,6 @@ #include #include "../menu.h" -#include "../menu_input.h" #include "../../retroarch.h" #include #include diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 2676ba881d..5be0738bf1 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -21,7 +21,6 @@ #include #include "../menu.h" -#include "../menu_input.h" #include "../menu_animation.h" #include "../menu_texture.h" diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 67797be801..8b83f6e721 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -15,7 +15,6 @@ */ #include "menu_animation.h" -#include "../driver.h" #include #include #include From b1c775849a20eb135452c99cc881b0eb8c0c76d3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 21:30:57 +0100 Subject: [PATCH 075/147] (RGUI) Cleanups --- menu/drivers/rgui.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index f1f9b004ab..67092e18aa 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -22,7 +22,6 @@ #include #include "../menu.h" -#include "../../retroarch.h" #include #include @@ -475,8 +474,6 @@ static void *rgui_init(void) if (!ret) { RARCH_ERR("No font bitmap or binary, abort"); - - rarch_main_command(RARCH_CMD_QUIT_RETROARCH); goto error; } From eb7a68a1823ee7e4177586d1bc519b7a226cd107 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 21:36:07 +0100 Subject: [PATCH 076/147] (Menu) Put scroll indices into struct --- menu/menu_driver.h | 12 +++++++++--- menu/menu_entries_cbs.c | 4 ++-- menu/menu_input.c | 5 +++-- menu/menu_list.c | 10 +++++----- menu/menu_navigation.c | 18 +++++++++--------- 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/menu/menu_driver.h b/menu/menu_driver.h index a226b2b79e..d02ef44195 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -99,9 +99,15 @@ typedef struct /* Quick jumping indices with L/R. * Rebuilt when parsing directory. */ - size_t scroll_indices[2 * (26 + 2) + 1]; - unsigned scroll_indices_size; - unsigned scroll_accel; + struct + { + struct + { + size_t list[2 * (26 + 2) + 1]; + unsigned size; + } indices; + unsigned acceleration; + } scroll; char default_glslp[PATH_MAX_LENGTH]; char default_cgp[PATH_MAX_LENGTH]; diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index b447156511..622d364668 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -2030,7 +2030,7 @@ static int action_toggle_scroll(unsigned type, const char *label, if (!driver.menu) return -1; - scroll_speed = (max(driver.menu->scroll_accel, 2) - 2) / 4 + 1; + scroll_speed = (max(driver.menu->scroll.acceleration, 2) - 2) / 4 + 1; fast_scroll_speed = 4 + 4 * scroll_speed; switch (action) @@ -3593,7 +3593,7 @@ static int deferred_push_default(void *data, void *userdata, static int action_bind_up_or_down_generic(unsigned type, const char *label, unsigned action) { - unsigned scroll_speed = (max(driver.menu->scroll_accel, 2) - 2) / 4 + 1; + unsigned scroll_speed = (max(driver.menu->scroll.acceleration, 2) - 2) / 4 + 1; if (menu_list_get_size(driver.menu->menu_list) <= 0) return 0; diff --git a/menu/menu_input.c b/menu/menu_input.c index 66da5a5ebb..010cf5171c 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -478,7 +478,8 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input) { first_held = false; trigger_input |= input & input_repeat; - driver.menu->scroll_accel = min(driver.menu->scroll_accel + 1, 64); + driver.menu->scroll.acceleration = + min(driver.menu->scroll.acceleration + 1, 64); } initial_held = false; @@ -487,7 +488,7 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input) { first_held = false; initial_held = true; - driver.menu->scroll_accel = 0; + driver.menu->scroll.acceleration = 0; } driver.menu->mouse.enable = g_settings.menu.mouse_enable; diff --git a/menu/menu_list.c b/menu/menu_list.c index 6778069908..2ed31e94da 100644 --- a/menu/menu_list.c +++ b/menu/menu_list.c @@ -98,11 +98,11 @@ static void menu_entries_build_scroll_indices(file_list_t *list) if (!driver.menu || !list) return; - driver.menu->scroll_indices_size = 0; + driver.menu->scroll.indices.size = 0; if (!list->size) return; - driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = 0; + driver.menu->scroll.indices.list[driver.menu->scroll.indices.size++] = 0; current = menu_entries_list_get_first_char(list, 0); current_is_dir = menu_entries_list_elem_is_dir(list, 0); @@ -113,13 +113,13 @@ static void menu_entries_build_scroll_indices(file_list_t *list) bool is_dir = menu_entries_list_elem_is_dir(list, i); if ((current_is_dir && !is_dir) || (first > current)) - driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = i; + driver.menu->scroll.indices.list[driver.menu->scroll.indices.size++] = i; current = first; current_is_dir = is_dir; } - driver.menu->scroll_indices[driver.menu->scroll_indices_size++] = + driver.menu->scroll.indices.list[driver.menu->scroll.indices.size++] = list->size - 1; } @@ -422,7 +422,7 @@ int menu_list_populate_generic(void *data, if (!menu) return -1; - driver.menu->scroll_indices_size = 0; + driver.menu->scroll.indices.size = 0; menu_entries_build_scroll_indices(list); menu_entries_refresh(menu, list); diff --git a/menu/menu_navigation.c b/menu/menu_navigation.c index 14d2907f6a..91319321ed 100644 --- a/menu/menu_navigation.c +++ b/menu/menu_navigation.c @@ -111,17 +111,17 @@ void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out) size_t i = 0; size_t ptr = *ptr_out; - if (!menu->scroll_indices_size) + if (!menu->scroll.indices.size) return; if (ptr == 0) return; - i = menu->scroll_indices_size - 1; + i = menu->scroll.indices.size - 1; - while (i && menu->scroll_indices[i - 1] >= ptr) + while (i && menu->scroll.indices.list[i - 1] >= ptr) i--; - *ptr_out = menu->scroll_indices[i - 1]; + *ptr_out = menu->scroll.indices.list[i - 1]; if (driver.menu_ctx && driver.menu_ctx->navigation_descend_alphabet) driver.menu_ctx->navigation_descend_alphabet(menu, ptr_out); @@ -143,16 +143,16 @@ void menu_navigation_ascend_alphabet(menu_handle_t *menu, size_t *ptr_out) size_t i = 0; size_t ptr = *ptr_out; - if (!menu->scroll_indices_size) + if (!menu->scroll.indices.size) return; - if (ptr == menu->scroll_indices[menu->scroll_indices_size - 1]) + if (ptr == menu->scroll.indices.list[menu->scroll.indices.size - 1]) return; - while (i < menu->scroll_indices_size - 1 - && menu->scroll_indices[i + 1] <= ptr) + while (i < menu->scroll.indices.size - 1 + && menu->scroll.indices.list[i + 1] <= ptr) i++; - *ptr_out = menu->scroll_indices[i + 1]; + *ptr_out = menu->scroll.indices.list[i + 1]; if (driver.menu_ctx && driver.menu_ctx->navigation_descend_alphabet) driver.menu_ctx->navigation_descend_alphabet(menu, ptr_out); From fe1ac4b8b94231ba33b1a0c3d99d0da9797101ef Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 21:43:16 +0100 Subject: [PATCH 077/147] (Menu) Create struct for categories --- menu/drivers/xmb.c | 42 ++++++++++++++++++++--------------------- menu/menu_driver.h | 9 +++++++-- menu/menu_entries.c | 2 +- menu/menu_entries_cbs.c | 4 ++-- 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 5be0738bf1..adbf34e37a 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -622,7 +622,7 @@ static void xmb_list_switch_new(menu_handle_t *menu, xmb_handle_t *xmb, file_lis static void xmb_set_title(menu_handle_t *menu, xmb_handle_t *xmb) { - if (menu->cat_selection_ptr == 0) + if (menu->categories.selection_ptr == 0) { const char *dir = NULL; const char *label = NULL; @@ -639,7 +639,7 @@ static void xmb_set_title(menu_handle_t *menu, xmb_handle_t *xmb) if (!info_list) return; - info = (core_info_t*)&info_list->list[menu->cat_selection_ptr - 1]; + info = (core_info_t*)&info_list->list[menu->categories.selection_ptr - 1]; if (info) strlcpy(xmb->title, info->display_name, sizeof(xmb->title)); @@ -651,12 +651,12 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) unsigned j; int dir = -1; - if (menu->cat_selection_ptr > xmb->cat_selection_ptr_old) + if (menu->categories.selection_ptr > xmb->cat_selection_ptr_old) dir = 1; xmb->active_category += dir; - for (j = 0; j < menu->num_categories; j++) + for (j = 0; j < menu->categories.size; j++) { float ia = xmb->c_passive_alpha; float iz = xmb->c_passive_zoom; @@ -676,16 +676,16 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) } menu_animation_push(menu->animation, XMB_DELAY, - xmb->hspacing * -(float)menu->cat_selection_ptr, + xmb->hspacing * -(float)menu->categories.selection_ptr, &xmb->categories_x, EASING_IN_OUT_QUAD, NULL); dir = -1; - if (menu->cat_selection_ptr > xmb->cat_selection_ptr_old) + if (menu->categories.selection_ptr > xmb->cat_selection_ptr_old) dir = 1; xmb_list_switch_old(menu, xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); xmb_list_switch_new(menu, xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); - xmb->active_category_old = menu->cat_selection_ptr; + xmb->active_category_old = menu->categories.selection_ptr; } static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) @@ -700,7 +700,7 @@ static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) else if (xmb->depth < xmb->old_depth) dir = -1; - for (j = 0; j < menu->num_categories; j++) + for (j = 0; j < menu->categories.size; j++) { float ia = 0; xmb_node_t *node = j ? xmb_node_for_core(xmb, j - 1) : &xmb->settings_node; @@ -760,7 +760,7 @@ static void xmb_populate_entries(menu_handle_t *menu, const char *path, xmb_set_title(menu, xmb); - if (menu->cat_selection_ptr != xmb->active_category_old) + if (menu->categories.selection_ptr != xmb->active_category_old) xmb_list_open(menu, xmb); else xmb_list_switch(menu, xmb); @@ -995,16 +995,16 @@ static void xmb_frame(menu_handle_t *menu) xmb->selection_buf_old, xmb->menu_stack_old, xmb->selection_ptr_old, - depth > 1 ? menu->cat_selection_ptr : + depth > 1 ? menu->categories.selection_ptr : xmb->cat_selection_ptr_old); xmb_draw_items(xmb, gl, menu->menu_list->selection_buf, menu->menu_list->menu_stack, menu->selection_ptr, - menu->cat_selection_ptr); + menu->categories.selection_ptr); - for (i = 0; i < menu->num_categories; i++) + for (i = 0; i < menu->categories.size; i++) { xmb_node_t *node = i ? xmb_node_for_core(xmb, i - 1) : &xmb->settings_node; @@ -1144,9 +1144,9 @@ static void *xmb_init(void) xmb->label_margin_top = xmb->font_size/3.0; xmb->setting_margin_left = 600.0 * scale_factor; - menu->num_categories = 1; + menu->categories.size = 1; if (g_extern.core_info) - menu->num_categories = g_extern.core_info->count + 1; + menu->categories.size = g_extern.core_info->count + 1; return menu; @@ -1294,7 +1294,7 @@ static void xmb_context_reset(menu_handle_t *menu) if (!info_list) return; - for (i = 1; i < menu->num_categories; i++) + for (i = 1; i < menu->categories.size; i++) { node = xmb_node_for_core(xmb, i - 1); @@ -1456,15 +1456,15 @@ static void xmb_list_cache(menu_handle_t *menu, if(!horizontal) return; - xmb->cat_selection_ptr_old = menu->cat_selection_ptr; + xmb->cat_selection_ptr_old = menu->categories.selection_ptr; switch (action) { case MENU_ACTION_LEFT: - menu->cat_selection_ptr--; + menu->categories.selection_ptr--; break; default: - menu->cat_selection_ptr++; + menu->categories.selection_ptr++; break; } @@ -1475,7 +1475,7 @@ static void xmb_list_cache(menu_handle_t *menu, menu->menu_list->menu_stack->list[stack_size-1].type = MENU_SETTINGS; - if (menu->cat_selection_ptr == 0) + if (menu->categories.selection_ptr == 0) return; strlcpy(menu->menu_list->menu_stack->list[stack_size-1].label, @@ -1500,7 +1500,7 @@ static void xmb_context_destroy(menu_handle_t *menu) for (i = 0; i < XMB_TEXTURE_LAST; i++) glDeleteTextures(1, &xmb->textures[i].id); - for (i = 1; i < menu->num_categories; i++) + for (i = 1; i < menu->categories.size; i++) { xmb_node_t *node = xmb_node_for_core(xmb, i - 1); @@ -1533,7 +1533,7 @@ static void xmb_toggle(menu_handle_t *menu, bool menu_on) xmb->prevent_populate = !menu->need_refresh; - for (i = 0; i < menu->num_categories; i++) + for (i = 0; i < menu->categories.size; i++) { xmb_node_t *node = i ? xmb_node_for_core(xmb, i - 1) : &xmb->settings_node; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index d02ef44195..2212c317aa 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -81,8 +81,13 @@ typedef struct size_t begin; menu_list_t *menu_list; - size_t cat_selection_ptr; - size_t num_categories; + + struct + { + size_t selection_ptr; + size_t size; + } categories; + size_t selection_ptr; bool need_refresh; bool msg_force; diff --git a/menu/menu_entries.c b/menu/menu_entries.c index b6af0ca9ee..3ba7533da3 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -211,7 +211,7 @@ int menu_entries_push_horizontal_menu_list(menu_handle_t *menu, if (!info_list) return -1; - info = (core_info_t*)&info_list->list[driver.menu->cat_selection_ptr - 1]; + info = (core_info_t*)&info_list->list[driver.menu->categories.selection_ptr - 1]; if (!info) return -1; diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 622d364668..9341f2db7f 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -2073,12 +2073,12 @@ static int action_toggle_mainmenu(unsigned type, const char *label, switch (action) { case MENU_ACTION_LEFT: - if (driver.menu->cat_selection_ptr == 0) + if (driver.menu->categories.selection_ptr == 0) break; push_list = 1; break; case MENU_ACTION_RIGHT: - if (driver.menu->cat_selection_ptr == driver.menu->num_categories-1) + if (driver.menu->categories.selection_ptr == (driver.menu->categories.size - 1)) break; push_list = 1; break; From 6ded569b8731ce8d19f9bd85cf42bb536f93c91f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 21:48:20 +0100 Subject: [PATCH 078/147] (Menu) Create struct for delay timer --- menu/menu_driver.h | 7 +++++-- menu/menu_input.c | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 2212c317aa..6bc82e0659 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -73,8 +73,11 @@ typedef struct void *userdata; /* Used for key repeat */ - unsigned delay_timer; - unsigned delay_count; + struct + { + unsigned timer; + unsigned count; + } delay; unsigned width; unsigned height; diff --git a/menu/menu_input.c b/menu/menu_input.c index 010cf5171c..de9851a5d1 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -470,11 +470,11 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input) if (!first_held) { first_held = true; - driver.menu->delay_timer = initial_held ? 12 : 6; - driver.menu->delay_count = 0; + driver.menu->delay.timer = initial_held ? 12 : 6; + driver.menu->delay.count = 0; } - if (driver.menu->delay_count >= driver.menu->delay_timer) + if (driver.menu->delay.count >= driver.menu->delay.timer) { first_held = false; trigger_input |= input & input_repeat; @@ -493,7 +493,7 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input) driver.menu->mouse.enable = g_settings.menu.mouse_enable; - driver.menu->delay_count++; + driver.menu->delay.count++; if (driver.block_input) trigger_input = 0; From 5bb11314d517fc524613ce05571c0835f53fde79 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 21:52:21 +0100 Subject: [PATCH 079/147] (Menu) Move width and height to frame_buf struct - mouse code needs to be entirely rewritten --- menu/drivers/rgui.c | 34 +++++++++++++++++----------------- menu/menu_driver.h | 4 ++-- menu/menu_entries_cbs.c | 10 +++++----- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 67092e18aa..59377d5355 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -29,10 +29,10 @@ #include "shared.h" -#define RGUI_TERM_START_X (menu->width / 21) -#define RGUI_TERM_START_Y (menu->height / 9) -#define RGUI_TERM_WIDTH (((menu->width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE))) -#define RGUI_TERM_HEIGHT (((menu->height - RGUI_TERM_START_Y - RGUI_TERM_START_X) / (FONT_HEIGHT_STRIDE)) - 1) +#define RGUI_TERM_START_X (menu->frame_buf.width / 21) +#define RGUI_TERM_START_Y (menu->frame_buf.height / 9) +#define RGUI_TERM_WIDTH (((menu->frame_buf.width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE))) +#define RGUI_TERM_HEIGHT (((menu->frame_buf.height - RGUI_TERM_START_Y - RGUI_TERM_START_X) / (FONT_HEIGHT_STRIDE)) - 1) static int rgui_entry_iterate(menu_handle_t *menu, unsigned action) { @@ -134,7 +134,7 @@ static void color_rect(menu_handle_t *menu, for (j = y; j < y + height; j++) for (i = x; i < x + width; i++) - if (i < menu->width && j < menu->height) + if (i < menu->frame_buf.width && j < menu->frame_buf.height) menu->frame_buf.data[j * (menu->frame_buf.pitch >> 1) + i] = color; } @@ -218,13 +218,13 @@ static void rgui_render_background(menu_handle_t *menu) if (!menu) return; - fill_rect(menu, 0, 0, menu->width, menu->height, gray_filler); - fill_rect(menu, 5, 5, menu->width - 10, 5, green_filler); - fill_rect(menu, 5, menu->height - 10, menu->width - 10, 5, + fill_rect(menu, 0, 0, menu->frame_buf.width, menu->frame_buf.height, gray_filler); + fill_rect(menu, 5, 5, menu->frame_buf.width - 10, 5, green_filler); + fill_rect(menu, 5, menu->frame_buf.height - 10, menu->frame_buf.width - 10, 5, green_filler); - fill_rect(menu, 5, 5, 5, menu->height - 10, green_filler); - fill_rect(menu, menu->width - 10, 5, 5, menu->height - 10, + fill_rect(menu, 5, 5, 5, menu->frame_buf.height - 10, green_filler); + fill_rect(menu, menu->frame_buf.width - 10, 5, 5, menu->frame_buf.height - 10, green_filler); } @@ -268,8 +268,8 @@ static void rgui_render_messagebox(menu_handle_t *menu, const char *message) } height = FONT_HEIGHT_STRIDE * list->size + 6 + 10; - x = (menu->width - width) / 2; - y = (menu->height - height) / 2; + x = (menu->frame_buf.width - width) / 2; + y = (menu->frame_buf.height - height) / 2; fill_rect(menu, x + 5, y + 5, width - 10, height - 10, gray_filler); fill_rect(menu, x, y, width - 5, 5, green_filler); @@ -464,10 +464,10 @@ static void *rgui_init(void) if (!menu->frame_buf.data) goto error; - menu->width = 320; - menu->height = 240; - menu->begin = 0; - menu->frame_buf.pitch = menu->width * sizeof(uint16_t); + menu->frame_buf.width = 320; + menu->frame_buf.height = 240; + menu->begin = 0; + menu->frame_buf.pitch = menu->frame_buf.width * sizeof(uint16_t); ret = rguidisp_init_font(menu); @@ -518,7 +518,7 @@ static void rgui_set_texture(menu_handle_t *menu) return; driver.video_poke->set_texture_frame(driver.video_data, - menu->frame_buf.data, false, menu->width, menu->height, 1.0f); + menu->frame_buf.data, false, menu->frame_buf.width, menu->frame_buf.height, 1.0f); } static void rgui_navigation_clear(menu_handle_t *menu, bool pending_push) diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 6bc82e0659..68a48d45c4 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -79,8 +79,6 @@ typedef struct unsigned count; } delay; - unsigned width; - unsigned height; size_t begin; menu_list_t *menu_list; @@ -123,6 +121,8 @@ typedef struct struct { uint16_t *data; + unsigned width; + unsigned height; size_t pitch; } frame_buf; diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 9341f2db7f..1068e5220e 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -4044,10 +4044,10 @@ static int mouse_iterate(unsigned action) driver.menu->mouse.x = 5; if (driver.menu->mouse.y < 5) driver.menu->mouse.y = 5; - if (driver.menu->mouse.x > driver.menu->width - 5) - driver.menu->mouse.x = driver.menu->width - 5; - if (driver.menu->mouse.y > driver.menu->height - 5) - driver.menu->mouse.y = driver.menu->height - 5; + if (driver.menu->mouse.x > driver.menu->frame_buf.width - 5) + driver.menu->mouse.x = driver.menu->frame_buf.width - 5; + if (driver.menu->mouse.y > driver.menu->frame_buf.height - 5) + driver.menu->mouse.y = driver.menu->frame_buf.height - 5; driver.menu->mouse.left = driver.input->input_state(driver.input_data, binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT); @@ -4061,7 +4061,7 @@ static int mouse_iterate(unsigned action) driver.menu->mouse.wheeldown = driver.input->input_state(driver.input_data, binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELDOWN) - || driver.menu->mouse.y == driver.menu->height - 5; + || driver.menu->mouse.y == driver.menu->frame_buf.height - 5; return 0; } From 6c6850a6718cc229d11abd34c9de9dbd8064fe52 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 21:56:32 +0100 Subject: [PATCH 080/147] (menu_entries_cbs.c) Start refactoring away driver.menu --- menu/menu_entries_cbs.c | 50 +++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 1068e5220e..72b580aa61 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -134,7 +134,7 @@ unsigned menu_current_gx_resolution = GX_RESOLUTIONS_640_480; static unsigned rdb_entry_start_game_selection_ptr; -static int archive_open(void) +static int archive_open(menu_handle_t *menu) { char cat_path[PATH_MAX_LENGTH]; const char *menu_path = NULL; @@ -142,24 +142,24 @@ static int archive_open(void) const char* path = NULL; unsigned int type = 0; - menu_list_pop_stack(driver.menu->menu_list); + menu_list_pop_stack(menu->menu_list); - menu_list_get_last_stack(driver.menu->menu_list, + menu_list_get_last_stack(menu->menu_list, &menu_path, &menu_label, NULL); - if (menu_list_get_size(driver.menu->menu_list) == 0) + if (menu_list_get_size(menu->menu_list) == 0) return 0; - menu_list_get_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr, &path, NULL, &type); + menu_list_get_at_offset(menu->menu_list->selection_buf, + menu->selection_ptr, &path, NULL, &type); fill_pathname_join(cat_path, menu_path, path, sizeof(cat_path)); menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, cat_path, menu_label, type, - driver.menu->selection_ptr); + menu->selection_ptr); return 0; } @@ -171,7 +171,7 @@ static void common_load_content(bool persist) driver.menu->msg_force = true; } -static int archive_load(void) +static int archive_load(menu_handle_t *menu) { int ret; const char *menu_path = NULL; @@ -179,19 +179,19 @@ static int archive_load(void) const char* path = NULL; unsigned int type = 0; - menu_list_pop_stack(driver.menu->menu_list); + menu_list_pop_stack(menu->menu_list); - menu_list_get_last_stack(driver.menu->menu_list, + menu_list_get_last_stack(menu->menu_list, &menu_path, &menu_label, NULL); - if (menu_list_get_size(driver.menu->menu_list) == 0) + if (menu_list_get_size(menu->menu_list) == 0) return 0; - menu_list_get_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr, &path, NULL, &type); + menu_list_get_at_offset(menu->menu_list->selection_buf, + menu->selection_ptr, &path, NULL, &type); ret = rarch_defer_core(g_extern.core_info, menu_path, path, menu_label, - driver.menu->deferred_path, sizeof(driver.menu->deferred_path)); + menu->deferred_path, sizeof(menu->deferred_path)); switch (ret) { @@ -201,24 +201,20 @@ static int archive_load(void) break; case 0: menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, g_settings.libretro_directory, "deferred_core_list", 0, - driver.menu->selection_ptr); + menu->selection_ptr); break; } return 0; } -static int load_or_open_zip_iterate(unsigned action) +static int load_or_open_zip_iterate(menu_handle_t *menu, unsigned action) { char msg[PATH_MAX_LENGTH]; - menu_handle_t *menu = driver.menu; - - if (!menu) - return -1; snprintf(msg, sizeof(msg), "Opening compressed file\n" " \n" @@ -236,10 +232,10 @@ static int load_or_open_zip_iterate(unsigned action) switch (action) { case MENU_ACTION_OK: - archive_open(); + archive_open(menu); break; case MENU_ACTION_CANCEL: - archive_load(); + archive_load(menu); break; } @@ -3801,11 +3797,11 @@ static int action_iterate_load_open_zip(const char *label, unsigned action) switch (g_settings.archive.mode) { case 0: - return load_or_open_zip_iterate(action); + return load_or_open_zip_iterate(driver.menu, action); case 1: - return archive_load(); + return archive_load(driver.menu); case 2: - return archive_open(); + return archive_open(driver.menu); default: break; } From 6654d2eb6c55170c9ce5bffb7deec3be30843c38 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 22:05:56 +0100 Subject: [PATCH 081/147] (menu_input.c) Cleanups --- menu/menu_input.c | 16 +++++----------- menu/menu_input.h | 6 +++--- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index de9851a5d1..2c1af75020 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -32,12 +32,10 @@ #include "../input/input_joypad.h" #include "../input/input_remapping.h" -void menu_input_key_start_line(void *data, const char *label, +void menu_input_key_start_line(menu_handle_t *menu, const char *label, const char *label_setting, unsigned type, unsigned idx, input_keyboard_line_complete_t cb) { - menu_handle_t *menu = (menu_handle_t*)data; - if (!menu) return; @@ -49,10 +47,8 @@ void menu_input_key_start_line(void *data, const char *label, menu->keyboard.buffer = input_keyboard_start_line(menu, cb); } -static void menu_input_key_end_line(void *data) +static void menu_input_key_end_line(menu_handle_t *menu) { - menu_handle_t *menu = (menu_handle_t*)data; - if (!menu) return; @@ -350,11 +346,10 @@ bool menu_input_custom_bind_keyboard_cb(void *data, unsigned code) return (menu->binds.begin <= menu->binds.last); } -int menu_input_bind_iterate(void *data) +int menu_input_bind_iterate(menu_handle_t *menu) { char msg[PATH_MAX_LENGTH]; struct menu_bind_state binds; - menu_handle_t *menu = (menu_handle_t*)data; if (!menu) return 1; @@ -367,7 +362,7 @@ int menu_input_bind_iterate(void *data) snprintf(msg, sizeof(msg), "[%s]\npress joypad\n(RETURN to skip)", input_config_bind_map[ - driver.menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc); + menu->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) @@ -396,13 +391,12 @@ int menu_input_bind_iterate(void *data) return 0; } -int menu_input_bind_iterate_keyboard(void *data) +int menu_input_bind_iterate_keyboard(menu_handle_t *menu) { char msg[PATH_MAX_LENGTH]; int64_t current; int timeout = 0; bool timed_out = false; - menu_handle_t *menu = (menu_handle_t*)data; if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) diff --git a/menu/menu_input.h b/menu/menu_input.h index 081f53d5dc..1b333c9f55 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -47,7 +47,7 @@ typedef enum void menu_input_key_event(bool down, unsigned keycode, uint32_t character, uint16_t key_modifiers); -void menu_input_key_start_line(void *data, const char *label, +void menu_input_key_start_line(menu_handle_t *menu, const char *label, const char *label_setting, unsigned type, unsigned idx, input_keyboard_line_complete_t cb); @@ -66,9 +66,9 @@ bool menu_input_poll_find_trigger(struct menu_bind_state *state, bool menu_input_custom_bind_keyboard_cb(void *data, unsigned code); -int menu_input_bind_iterate(void *data); +int menu_input_bind_iterate(menu_handle_t *menu); -int menu_input_bind_iterate_keyboard(void *data); +int menu_input_bind_iterate_keyboard(menu_handle_t *menu); unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_state); From 728210bdf79e26dfd89be53591fbfa25d1aaa243 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 22:10:21 +0100 Subject: [PATCH 082/147] Remove bunch of header dependencies in menu.h --- menu/menu.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/menu/menu.h b/menu/menu.h index 28366d84e1..4be29ee518 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -25,10 +25,7 @@ #include #include "../../general.h" #include "menu_navigation.h" -#include "../../core_info.h" -#include "../../playlist.h" #include "menu_input.h" -#include "../gfx/video_shader_driver.h" #ifndef GFX_MAX_SHADERS #define GFX_MAX_SHADERS 16 From 8d050f23aafe17ce6cd0d0be7fd48e9a6283cb29 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 22:15:13 +0100 Subject: [PATCH 083/147] Remove more header dependencies (menu.h) --- menu/menu.h | 1 - menu/menu_entries.c | 1 + menu/menu_entries_cbs.c | 1 + menu/menu_input.c | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) diff --git a/menu/menu.h b/menu/menu.h index 4be29ee518..0557603f59 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -24,7 +24,6 @@ #include #include #include "../../general.h" -#include "menu_navigation.h" #include "menu_input.h" #ifndef GFX_MAX_SHADERS diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 3ba7533da3..6cec1126b7 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -16,6 +16,7 @@ #include "menu_entries.h" #include "menu_action.h" +#include "menu_navigation.h" #include #include #include "../file_extract.h" diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 72b580aa61..ea4f779856 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -20,6 +20,7 @@ #include "menu_input.h" #include "menu_entries.h" #include "menu_shader.h" +#include "menu_navigation.h" #include "../file_ext.h" #include "../file_extract.h" diff --git a/menu/menu_input.c b/menu/menu_input.c index 2c1af75020..94abbdc3ed 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -26,6 +26,7 @@ #include "menu.h" #include "menu_action.h" #include "menu_shader.h" +#include "menu_navigation.h" #include "../cheats.h" #include "../performance.h" #include "../settings_data.h" From 23c56cc998d57b118851e83c3a1154fe7d4b9526 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 22:34:07 +0100 Subject: [PATCH 084/147] (RMenu XUI) Buildfix --- menu/drivers/rmenu_xui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index cf73dfa8ae..1e368e086d 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -46,8 +46,8 @@ #define FONT_HEIGHT_STRIDE (FONT_HEIGHT + 1) #define RXUI_TERM_START_X 15 #define RXUI_TERM_START_Y 27 -#define RXUI_TERM_WIDTH (((menu->width - RXUI_TERM_START_X - 15) / (FONT_WIDTH_STRIDE))) -#define RXUI_TERM_HEIGHT (((menu->height - RXUI_TERM_START_Y - 15) / (FONT_HEIGHT_STRIDE)) - 1) +#define RXUI_TERM_WIDTH (((menu->frame_buf.width - RXUI_TERM_START_X - 15) / (FONT_WIDTH_STRIDE))) +#define RXUI_TERM_HEIGHT (((menu->frame_buf.height - RXUI_TERM_START_Y - 15) / (FONT_HEIGHT_STRIDE)) - 1) HXUIOBJ m_menulist; HXUIOBJ m_menutitle; From 1d3ce967b458b7ffa3d4b7c8673186ba11a85298 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 22:38:05 +0100 Subject: [PATCH 085/147] (PS3/RMenu) Buildfixes --- menu/drivers/rmenu.c | 12 ++++++------ menu/menu_entries_cbs.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index d9bd82b638..17cae8b30f 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -180,7 +180,7 @@ static void rmenu_render(menu_handle_t *menu) get_title(label, dir, menu_type, title, sizeof(title)); - menu_ticker_line(title_buf, RMENU_TERM_WIDTH, + menu_animation_ticker_line(title_buf, RMENU_TERM_WIDTH, g_extern.frame_count / 15, title, true); font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET; @@ -247,9 +247,9 @@ static void rmenu_render(menu_handle_t *menu) selected = (i == menu->selection_ptr); - menu_ticker_line(entry_title_buf, RMENU_TERM_WIDTH - (w + 1 + 2), + menu_animation_ticker_line(entry_title_buf, RMENU_TERM_WIDTH - (w + 1 + 2), g_extern.frame_count / 15, path, selected); - menu_ticker_line(type_str_buf, w, g_extern.frame_count / 15, + menu_animation_ticker_line(type_str_buf, w, g_extern.frame_count / 15, type_str, selected); snprintf(message, sizeof(message), "%c %s", @@ -297,7 +297,7 @@ static void rmenu_set_texture(menu_handle_t *menu) driver.video_poke->set_texture_frame(driver.video_data, menu_texture->pixels, - true, menu->width, menu->height, 1.0f); + true, menu->frame_buf.width, menu->frame_buf.height, 1.0f); menu_texture_inited = true; } @@ -328,8 +328,8 @@ static void rmenu_context_reset(void *data) if (path_file_exists(menu_bg)) texture_image_load(menu_texture, menu_bg); - menu->width = menu_texture->width; - menu->height = menu_texture->height; + menu->frame_buf.width = menu_texture->width; + menu->frame_buf.height = menu_texture->height; menu_texture_inited = false; } diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index ea4f779856..7a85d7357d 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -4258,7 +4258,7 @@ static void menu_action_setting_disp_set_label_shader_filter_pass( const char *path, char *path_buf, size_t path_buf_size) { - unsigned pass; + unsigned pass = 0; static const char *modes[] = { "Don't care", "Linear", From 6a38206b42b37d140da6a00c68ddd2442267a5e3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 22:41:08 +0100 Subject: [PATCH 086/147] (audio_utils.c) Buildfix --- audio/audio_utils.c | 1 - 1 file changed, 1 deletion(-) diff --git a/audio/audio_utils.c b/audio/audio_utils.c index a703b2981e..99bcd48638 100644 --- a/audio/audio_utils.c +++ b/audio/audio_utils.c @@ -26,7 +26,6 @@ #ifdef RARCH_INTERNAL #include "../performance.h" #endif -#include "libretro.h" /** * audio_convert_s16_to_float_C: From 31cff5bec387d17bf11e8fd27ed51566a7c5f922 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 22:51:58 +0100 Subject: [PATCH 087/147] Set OSK overlay default to overlay directory by default --- settings.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/settings.c b/settings.c index f3db9cefda..4848e332e1 100644 --- a/settings.c +++ b/settings.c @@ -679,6 +679,9 @@ static void config_set_defaults(void) sizeof(g_settings.osk.overlay)); #endif } + else + strlcpy(g_extern.osk_overlay_dir, + g_extern.overlay_dir, sizeof(g_extern.osk_overlay_dir)); #endif #ifdef HAVE_MENU if (*g_defaults.menu_config_dir) From 0c64543eb8d87639b47dedd0f84655cc57fe1ec8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 23:30:29 +0100 Subject: [PATCH 088/147] (menu_entries_cbs.c) Cleanups --- menu/menu_entries_cbs.c | 61 +++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 7a85d7357d..71a1ac6ab4 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -165,11 +165,12 @@ static int archive_open(menu_handle_t *menu) return 0; } -static void common_load_content(bool persist) +static void common_load_content(menu_handle_t *menu, bool persist) { rarch_main_command(persist ? RARCH_CMD_LOAD_CONTENT_PERSIST : RARCH_CMD_LOAD_CONTENT); - menu_list_flush_stack(driver.menu->menu_list, MENU_SETTINGS); - driver.menu->msg_force = true; + + menu_list_flush_stack(menu->menu_list, MENU_SETTINGS); + menu->msg_force = true; } static int archive_load(menu_handle_t *menu) @@ -198,7 +199,7 @@ static int archive_load(menu_handle_t *menu) { case -1: rarch_main_command(RARCH_CMD_LOAD_CORE); - common_load_content(false); + common_load_content(menu, false); break; case 0: menu_list_push_stack_refresh( @@ -640,7 +641,7 @@ static int action_ok_core_load_deferred(const char *path, strlcpy(g_extern.fullpath, driver.menu->deferred_path, sizeof(g_extern.fullpath)); - common_load_content(false); + common_load_content(driver.menu, false); return -1; } @@ -1193,7 +1194,7 @@ static int action_ok_core_load(const char *path, if (driver.menu->load_no_content) { *g_extern.fullpath = '\0'; - common_load_content(false); + common_load_content(driver.menu, false); return -1; } @@ -1364,7 +1365,7 @@ static int action_ok_file_load_with_detect_core(const char *path, if (ret == -1) { rarch_main_command(RARCH_CMD_LOAD_CORE); - common_load_content(false); + common_load_content(driver.menu, false); return -1; } @@ -1415,7 +1416,7 @@ static int action_ok_file_load(const char *path, fill_pathname_join(g_extern.fullpath, menu_path, path, sizeof(g_extern.fullpath)); - common_load_content(true); + common_load_content(driver.menu, true); return -1; } @@ -2024,29 +2025,30 @@ static int action_toggle_scroll(unsigned type, const char *label, unsigned action) { unsigned scroll_speed = 0, fast_scroll_speed = 0; - if (!driver.menu) + menu_handle_t *menu = driver.menu; + if (!menu) return -1; - scroll_speed = (max(driver.menu->scroll.acceleration, 2) - 2) / 4 + 1; + scroll_speed = (max(menu->scroll.acceleration, 2) - 2) / 4 + 1; fast_scroll_speed = 4 + 4 * scroll_speed; switch (action) { case MENU_ACTION_LEFT: - if (driver.menu->selection_ptr > fast_scroll_speed) - menu_navigation_set(driver.menu, - driver.menu->selection_ptr - fast_scroll_speed, true); + if (menu->selection_ptr > fast_scroll_speed) + menu_navigation_set(menu, + menu->selection_ptr - fast_scroll_speed, true); else - menu_navigation_clear(driver.menu, false); + menu_navigation_clear(menu, false); break; case MENU_ACTION_RIGHT: - if (driver.menu->selection_ptr + fast_scroll_speed < (menu_list_get_size(driver.menu->menu_list))) - menu_navigation_set(driver.menu, - driver.menu->selection_ptr + fast_scroll_speed, true); + if (menu->selection_ptr + fast_scroll_speed < (menu_list_get_size(menu->menu_list))) + menu_navigation_set(menu, + menu->selection_ptr + fast_scroll_speed, true); else { - if ((menu_list_get_size(driver.menu->menu_list) > 0)) - menu_navigation_set_last(driver.menu); + if ((menu_list_get_size(menu->menu_list) > 0)) + menu_navigation_set_last(menu); } break; } @@ -2059,23 +2061,24 @@ static int action_toggle_mainmenu(unsigned type, const char *label, { menu_file_list_cbs_t *cbs = NULL; unsigned push_list = 0; - if (!driver.menu) + menu_handle_t *menu = driver.menu; + if (!menu) return -1; - if (file_list_get_size(driver.menu->menu_list->menu_stack) == 1) + if (file_list_get_size(menu->menu_list->menu_stack) == 1) { if (!strcmp(driver.menu_ctx->ident, "xmb")) { - driver.menu->selection_ptr = 0; + menu->selection_ptr = 0; switch (action) { case MENU_ACTION_LEFT: - if (driver.menu->categories.selection_ptr == 0) + if (menu->categories.selection_ptr == 0) break; push_list = 1; break; case MENU_ACTION_RIGHT: - if (driver.menu->categories.selection_ptr == (driver.menu->categories.size - 1)) + if (menu->categories.selection_ptr == (menu->categories.size - 1)) break; push_list = 1; break; @@ -2086,19 +2089,19 @@ static int action_toggle_mainmenu(unsigned type, const char *label, push_list = 2; cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(driver.menu->menu_list->selection_buf, - driver.menu->selection_ptr); + menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, + menu->selection_ptr); switch (push_list) { case 1: if (driver.menu_ctx->list_cache) - driver.menu_ctx->list_cache(driver.menu, true, action); + driver.menu_ctx->list_cache(menu, true, action); if (cbs && cbs->action_content_list_switch) return cbs->action_content_list_switch( - driver.menu->menu_list->selection_buf, - driver.menu->menu_list->menu_stack, + menu->menu_list->selection_buf, + menu->menu_list->menu_stack, "", "", 0); From e9c42cf0387ce77bf8f8b5ec8b3df420473b5866 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Feb 2015 23:40:34 +0100 Subject: [PATCH 089/147] (menu_entries_cbs.c) Shader cleanups --- menu/menu_entries_cbs.c | 73 ++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 71a1ac6ab4..a6dcb07b13 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -2122,23 +2122,29 @@ static int action_toggle_shader_scale_pass(unsigned type, const char *label, { #ifdef HAVE_SHADER_MANAGER unsigned pass = type - MENU_SETTINGS_SHADER_PASS_SCALE_0; - struct video_shader *shader = driver.menu->shader; - struct video_shader_pass *shader_pass = &shader->pass[pass]; + struct video_shader *shader = NULL; + struct video_shader_pass *shader_pass = NULL; + + if (!driver.menu) + return -1; + shader = driver.menu->shader; + if (!shader) + return -1; + shader_pass = &shader->pass[pass]; + if (!shader_pass) + return -1; switch (action) { case MENU_ACTION_LEFT: case MENU_ACTION_RIGHT: { - unsigned current_scale = shader_pass->fbo.scale_x; - unsigned delta = action == MENU_ACTION_LEFT ? 5 : 1; - current_scale = (current_scale + delta) % 6; + 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; - } + shader_pass->fbo.valid = current_scale; + shader_pass->fbo.scale_x = shader_pass->fbo.scale_y = current_scale; } break; } @@ -2151,11 +2157,19 @@ static int action_start_shader_filter_pass(unsigned type, const char *label, { #ifdef HAVE_SHADER_MANAGER unsigned pass = type - MENU_SETTINGS_SHADER_PASS_FILTER_0; - struct video_shader *shader = driver.menu->shader; - struct video_shader_pass *shader_pass = &shader->pass[pass]; + struct video_shader *shader = NULL; + struct video_shader_pass *shader_pass = NULL; + + if (!driver.menu) + return -1; + shader = driver.menu->shader; + if (!shader) + return -1; + shader_pass = &shader->pass[pass]; + if (!shader_pass) + return -1; - if (shader && shader_pass) - shader_pass->filter = RARCH_FILTER_UNSPEC; + shader_pass->filter = RARCH_FILTER_UNSPEC; #endif return 0; @@ -2166,8 +2180,17 @@ static int action_toggle_shader_filter_pass(unsigned type, const char *label, { #ifdef HAVE_SHADER_MANAGER unsigned pass = type - MENU_SETTINGS_SHADER_PASS_FILTER_0; - struct video_shader *shader = driver.menu->shader; - struct video_shader_pass *shader_pass = &shader->pass[pass]; + struct video_shader *shader = NULL; + struct video_shader_pass *shader_pass = NULL; + + if (!driver.menu) + return -1; + shader = driver.menu->shader; + if (!shader) + return -1; + shader_pass = &shader->pass[pass]; + if (!shader_pass) + return -1; switch (action) { @@ -2175,8 +2198,7 @@ static int action_toggle_shader_filter_pass(unsigned type, const char *label, case MENU_ACTION_RIGHT: { unsigned delta = (action == MENU_ACTION_LEFT) ? 2 : 1; - if (shader_pass) - shader_pass->filter = ((shader_pass->filter + delta) % 3); + shader_pass->filter = ((shader_pass->filter + delta) % 3); } break; } @@ -2199,11 +2221,13 @@ static int action_start_shader_num_passes(unsigned type, const char *label, unsigned action) { #ifdef HAVE_SHADER_MANAGER - struct video_shader *shader = driver.menu->shader; - + struct video_shader *shader = NULL; + + if (!driver.menu) + return -1; + shader = driver.menu->shader; if (!shader) return -1; - if (shader->passes) shader->passes = 0; driver.menu->need_refresh = true; @@ -2263,8 +2287,11 @@ static int action_toggle_shader_num_passes(unsigned type, const char *label, unsigned action) { #ifdef HAVE_SHADER_MANAGER - struct video_shader *shader = driver.menu->shader; - + struct video_shader *shader = NULL; + + if (!driver.menu) + return -1; + shader = driver.menu->shader; if (!shader) return -1; From f20ede45a1c438cd84aee428dcf19481522b4c76 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 15:14:05 +0100 Subject: [PATCH 090/147] Rename xmb_node_for_core to xmb_get_userdata_from_core --- menu/drivers/xmb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index adbf34e37a..e1286efafd 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -532,7 +532,7 @@ static void xmb_list_open_new(menu_handle_t *menu, xmb->old_depth = xmb->depth; } -static xmb_node_t* xmb_node_for_core(xmb_handle_t *xmb, int i) +static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, int i) { core_info_t *info = NULL; xmb_node_t *node = NULL; @@ -660,7 +660,7 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) { float ia = xmb->c_passive_alpha; float iz = xmb->c_passive_zoom; - xmb_node_t *node = j ? xmb_node_for_core(xmb, j - 1) : &xmb->settings_node; + xmb_node_t *node = j ? xmb_get_userdata_from_core(xmb, j - 1) : &xmb->settings_node; if (!node) continue; @@ -703,7 +703,7 @@ static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) for (j = 0; j < menu->categories.size; j++) { float ia = 0; - xmb_node_t *node = j ? xmb_node_for_core(xmb, j - 1) : &xmb->settings_node; + xmb_node_t *node = j ? xmb_get_userdata_from_core(xmb, j - 1) : &xmb->settings_node; if (!node) continue; @@ -783,7 +783,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, file_list_get_last(stack, &dir, &label, &menu_type); if (xmb->active_category) - core_node = xmb_node_for_core(xmb, cat_selection_ptr - 1); + core_node = xmb_get_userdata_from_core(xmb, cat_selection_ptr - 1); for (i = 0; i < end; i++) { @@ -1006,7 +1006,7 @@ static void xmb_frame(menu_handle_t *menu) for (i = 0; i < menu->categories.size; i++) { - xmb_node_t *node = i ? xmb_node_for_core(xmb, i - 1) : &xmb->settings_node; + xmb_node_t *node = i ? xmb_get_userdata_from_core(xmb, i - 1) : &xmb->settings_node; if (node) xmb_draw_icon(gl, xmb, node->icon, @@ -1296,7 +1296,7 @@ static void xmb_context_reset(menu_handle_t *menu) for (i = 1; i < menu->categories.size; i++) { - node = xmb_node_for_core(xmb, i - 1); + node = xmb_get_userdata_from_core(xmb, i - 1); fill_pathname_join(mediapath, g_settings.assets_directory, "lakka", sizeof(mediapath)); @@ -1502,7 +1502,7 @@ static void xmb_context_destroy(menu_handle_t *menu) for (i = 1; i < menu->categories.size; i++) { - xmb_node_t *node = xmb_node_for_core(xmb, i - 1); + xmb_node_t *node = xmb_get_userdata_from_core(xmb, i - 1); if (!node) continue; @@ -1535,7 +1535,7 @@ static void xmb_toggle(menu_handle_t *menu, bool menu_on) for (i = 0; i < menu->categories.size; i++) { - xmb_node_t *node = i ? xmb_node_for_core(xmb, i - 1) : &xmb->settings_node; + xmb_node_t *node = i ? xmb_get_userdata_from_core(xmb, i - 1) : &xmb->settings_node; if (!node) continue; From 179661098f71bd8afe41cc601690c85a2ba71368 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 17:05:56 +0100 Subject: [PATCH 091/147] (XMB) xmb_draw_items - cleanups --- menu/drivers/xmb.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index e1286efafd..bf6cc986d0 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -789,16 +789,16 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, { float icon_x, icon_y; char type_str[PATH_MAX_LENGTH], path_buf[PATH_MAX_LENGTH]; - char name[256], value[256]; + char name[PATH_MAX_LENGTH], value[PATH_MAX_LENGTH]; const char *path = NULL, *entry_label = NULL; unsigned type = 0, w = 0; - xmb_node_t *node = NULL; menu_file_list_cbs_t *cbs = NULL; GLuint icon = 0; + xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); - menu_list_get_at_offset(list, i, &path, &entry_label, &type); - node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); - + if (!node) + continue; + icon_x = node->x + xmb->margin_left + xmb->hspacing - xmb->icon_size/2.0; icon_y = xmb->margin_top + node->y + xmb->icon_size/2.0; @@ -809,6 +809,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, icon_y > gl->win_height + xmb->icon_size) continue; + menu_list_get_at_offset(list, i, &path, &entry_label, &type); + cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset(list, i); if (cbs && cbs->action_get_representation) From b709baf8e5ffa7c266b863d8706562751e08d0fc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 17:08:57 +0100 Subject: [PATCH 092/147] xmb_draw_items - cleanups --- menu/drivers/xmb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index bf6cc986d0..8a0fbbfee8 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -771,20 +771,20 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, size_t current, size_t cat_selection_ptr) { unsigned i; - const char *dir = NULL; const char *label = NULL; - unsigned menu_type = 0; xmb_node_t *core_node = NULL; - size_t end = file_list_get_size(list); + size_t end = 0; - if (!list->size) + if (!list || !list->size) return; - file_list_get_last(stack, &dir, &label, &menu_type); + file_list_get_last(stack, NULL, &label, NULL); if (xmb->active_category) core_node = xmb_get_userdata_from_core(xmb, cat_selection_ptr - 1); + end = file_list_get_size(list); + for (i = 0; i < end; i++) { float icon_x, icon_y; From 7b4e3353a86799611d16499f29c7bfce2818f26e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 17:22:24 +0100 Subject: [PATCH 093/147] (XMB) Cleanups - create xmb_push_animations --- menu/drivers/xmb.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 8a0fbbfee8..0cde4b5047 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -576,33 +576,41 @@ static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, int i) return node; } +static void xmb_push_animations(menu_handle_t *menu, xmb_node_t *node, float ia, float ix) +{ + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, ix, &node->x, EASING_IN_OUT_QUAD, NULL); +} + static void xmb_list_switch_old(menu_handle_t *menu, xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; + size_t end = file_list_get_size(list); - for (i = 0; i < file_list_get_size(list); i++) + for (i = 0; i < end; i++) { xmb_node_t *node = (xmb_node_t*) file_list_get_userdata_at_offset(list, i); + float ia = 0; if (!node) continue; - menu_animation_push(menu->animation, XMB_DELAY, 0, &node->alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(menu->animation, XMB_DELAY, 0, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(menu->animation, XMB_DELAY, -xmb->hspacing*dir, &node->x, EASING_IN_OUT_QUAD, NULL); + xmb_push_animations(menu, node, ia, -xmb->hspacing * dir); } } static void xmb_list_switch_new(menu_handle_t *menu, xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; + size_t end = file_list_get_size(list); - for (i = 0; i < file_list_get_size(list); i++) + for (i = 0; i < end; i++) { - float ia = 0.5; xmb_node_t *node = (xmb_node_t*) file_list_get_userdata_at_offset(list, i); + float ia = 0.5; if (!node) continue; @@ -614,9 +622,7 @@ static void xmb_list_switch_new(menu_handle_t *menu, xmb_handle_t *xmb, file_lis if (i == current) ia = 1.0; - menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(menu->animation, XMB_DELAY, 0, &node->x, EASING_IN_OUT_QUAD, NULL); + xmb_push_animations(menu, node, ia, 0); } } From 2c8998aa88f66dc44e16a03dfa4d2d7339e6a494 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 18:18:38 +0100 Subject: [PATCH 094/147] (XMB) Make this code somewhat easier to read --- menu/drivers/xmb.c | 197 +++++++++++++++++++++++++-------------------- 1 file changed, 109 insertions(+), 88 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 0cde4b5047..1221106350 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -111,17 +111,37 @@ typedef struct xmb_handle float label_margin_top; float setting_margin_left; float above_item_offset; - float active_item_factor; float under_item_offset; float above_subitem_offset; - float c_active_zoom; - float c_active_alpha; - float i_active_zoom; - float i_active_alpha; - float c_passive_zoom; - float c_passive_alpha; - float i_passive_zoom; - float i_passive_alpha; + struct + { + struct + { + float zoom; + float alpha; + } active; + struct + { + float zoom; + float alpha; + } passive; + } category; + + struct + { + struct + { + float zoom; + float alpha; + float factor; + } active; + struct + { + float zoom; + float alpha; + } passive; + } item; + void *font; int font_size; xmb_node_t settings_node; @@ -155,7 +175,7 @@ static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current) iy *= (i - (int)current + xmb->under_item_offset); if (i == current) - iy = xmb->vspacing * xmb->active_item_factor; + iy = xmb->vspacing * xmb->item.active.factor; return iy; } @@ -442,8 +462,8 @@ static void xmb_selection_pointer_changed(menu_handle_t *menu) for (i = 0; i < end; i++) { float iy; - float ia = xmb->i_passive_alpha; - float iz = xmb->i_passive_zoom; + float ia = xmb->item.passive.alpha; + float iz = xmb->item.passive.zoom; xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset( menu->menu_list->selection_buf, i); @@ -454,8 +474,8 @@ static void xmb_selection_pointer_changed(menu_handle_t *menu) if (i == current) { - ia = xmb->i_active_alpha; - iz = xmb->i_active_zoom; + ia = xmb->item.active.alpha; + iz = xmb->item.active.zoom; } menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); @@ -478,7 +498,7 @@ static void xmb_list_open_old(menu_handle_t *menu, xmb_handle_t *xmb, file_list_ continue; if (i == current) - ia = xmb->i_active_alpha; + ia = xmb->item.active.alpha; if (dir == -1) ia = 0; @@ -520,9 +540,9 @@ static void xmb_list_open_new(menu_handle_t *menu, if (!node) continue; - ia = xmb->i_passive_alpha; + ia = xmb->item.passive.alpha; if (i == current) - ia = xmb->i_active_alpha; + ia = xmb->item.active.alpha; menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); menu_animation_push(menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); @@ -564,13 +584,13 @@ static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, int i) if (!node) return NULL; - node->alpha = xmb->c_passive_alpha; - node->zoom = xmb->c_passive_zoom; + node->alpha = xmb->category.passive.alpha; + node->zoom = xmb->category.passive.zoom; if ((i + 1) == xmb->active_category) { - node->alpha = xmb->c_active_alpha; - node->zoom = xmb->c_active_zoom; + node->alpha = xmb->category.active.alpha; + node->zoom = xmb->category.active.zoom; } return node; @@ -664,8 +684,8 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) for (j = 0; j < menu->categories.size; j++) { - float ia = xmb->c_passive_alpha; - float iz = xmb->c_passive_zoom; + float ia = xmb->category.passive.alpha; + float iz = xmb->category.passive.zoom; xmb_node_t *node = j ? xmb_get_userdata_from_core(xmb, j - 1) : &xmb->settings_node; if (!node) @@ -673,8 +693,8 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) if (j == xmb->active_category) { - ia = xmb->c_active_alpha; - iz = xmb->c_active_zoom; + ia = xmb->category.active.alpha; + iz = xmb->category.active.zoom; } menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); @@ -715,9 +735,9 @@ static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) continue; if (j == xmb->active_category) - ia = xmb->c_active_alpha; + ia = xmb->category.active.alpha; else if (xmb->depth <= 1) - ia = xmb->c_passive_alpha; + ia = xmb->category.passive.alpha; menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); @@ -994,7 +1014,7 @@ static void xmb_frame(menu_handle_t *menu) xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_ARROW].id, xmb->x + xmb->margin_left + xmb->hspacing - xmb->icon_size/2.0 + xmb->icon_size, - xmb->margin_top + xmb->icon_size/2.0 + xmb->vspacing * xmb->active_item_factor, + xmb->margin_top + xmb->icon_size/2.0 + xmb->vspacing * xmb->item.active.factor, xmb->arrow_alpha, 0, 1); depth = file_list_get_size(menu->menu_list->menu_stack); @@ -1081,80 +1101,81 @@ static void *xmb_init(void) if (!menu) goto error; - menu->userdata = (xmb_handle_t*)calloc(1, sizeof(xmb_handle_t)); + menu->userdata = (xmb_handle_t*)calloc(1, sizeof(xmb_handle_t)); if (!menu->userdata) goto error; xmb = (xmb_handle_t*)menu->userdata; - xmb->menu_stack_old = (file_list_t*)calloc(1, sizeof(file_list_t)); + xmb->menu_stack_old = (file_list_t*)calloc(1, sizeof(file_list_t)); if (!xmb->menu_stack_old) goto error; - xmb->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t)); + xmb->selection_buf_old = (file_list_t*)calloc(1, sizeof(file_list_t)); if (!xmb->selection_buf_old) goto error; - xmb->active_category = 0; - xmb->active_category_old = 0; - xmb->x = 0; - xmb->categories_x = 0; - xmb->alpha = 1.0f; - xmb->arrow_alpha = 0; - xmb->depth = 1; - xmb->old_depth = 1; - xmb->alpha = 0; - xmb->prevent_populate = false; + xmb->active_category = 0; + xmb->active_category_old = 0; + xmb->x = 0; + xmb->categories_x = 0; + xmb->alpha = 1.0f; + xmb->arrow_alpha = 0; + xmb->depth = 1; + xmb->old_depth = 1; + xmb->alpha = 0; + xmb->prevent_populate = false; - xmb->c_active_zoom = 1.0; - xmb->c_passive_zoom = 0.5; - xmb->i_active_zoom = 1.0; - xmb->i_passive_zoom = 0.5; + xmb->category.active.zoom = 1.0; + xmb->category.passive.zoom = 0.5; + xmb->item.active.zoom = 1.0; + xmb->item.passive.zoom = 0.5; - xmb->c_active_alpha = 1.0; - xmb->c_passive_alpha = 0.5; - xmb->i_active_alpha = 1.0; - xmb->i_passive_alpha = 0.5; + xmb->category.active.alpha = 1.0; + xmb->category.passive.alpha= 0.5; + xmb->item.active.alpha = 1.0; + xmb->item.passive.alpha = 0.5; - xmb->above_subitem_offset = 1.5; - xmb->above_item_offset = -1.0; - xmb->active_item_factor = 3.0; - xmb->under_item_offset = 5.0; + xmb->above_subitem_offset = 1.5; + xmb->above_item_offset = -1.0; + xmb->item.active.factor = 3.0; + xmb->under_item_offset = 5.0; if (gl->win_width >= 3840) - scale_factor = 2.0; + scale_factor = 2.0; else if (gl->win_width >= 2560) - scale_factor = 1.5; + scale_factor = 1.5; else if (gl->win_width >= 1920) - scale_factor = 1.0; + scale_factor = 1.0; else if (gl->win_width >= 1280) - scale_factor = 0.75; + scale_factor = 0.75; else if (gl->win_width >= 640) - scale_factor = 0.5; + scale_factor = 0.5; else if (gl->win_width >= 320) - scale_factor = 0.25; + scale_factor = 0.25; strlcpy(xmb->icon_dir, "256", sizeof(xmb->icon_dir)); - xmb->icon_size = 128.0 * scale_factor; - xmb->font_size = 32.0 * scale_factor; - xmb->hspacing = 200.0 * scale_factor; - xmb->vspacing = 64.0 * scale_factor; - xmb->margin_left = 336.0 * scale_factor; - xmb->margin_top = (256+32) * scale_factor; - xmb->title_margin_left = 60 * scale_factor; - xmb->title_margin_top = 60 * scale_factor + xmb->font_size/3; - xmb->title_margin_bottom = 60 * scale_factor - xmb->font_size/3; - xmb->label_margin_left = 85.0 * scale_factor; - xmb->label_margin_top = xmb->font_size/3.0; - xmb->setting_margin_left = 600.0 * scale_factor; + xmb->icon_size = 128.0 * scale_factor; + xmb->font_size = 32.0 * scale_factor; + xmb->hspacing = 200.0 * scale_factor; + xmb->vspacing = 64.0 * scale_factor; + xmb->margin_left = 336.0 * scale_factor; + xmb->margin_top = (256+32) * scale_factor; + xmb->title_margin_left = 60 * scale_factor; + xmb->title_margin_top = 60 * scale_factor + xmb->font_size/3; + xmb->title_margin_bottom = 60 * scale_factor - xmb->font_size/3; + xmb->label_margin_left = 85.0 * scale_factor; + xmb->label_margin_top = xmb->font_size/3.0; + xmb->setting_margin_left = 600.0 * scale_factor; + + menu->categories.size = 1; - menu->categories.size = 1; if (g_extern.core_info) - menu->categories.size = g_extern.core_info->count + 1; + menu->categories.size = g_extern.core_info->count + 1; return menu; @@ -1294,8 +1315,8 @@ static void xmb_context_reset(menu_handle_t *menu) TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); xmb->settings_node.icon = xmb->textures[XMB_TEXTURE_SETTINGS].id; - xmb->settings_node.alpha = xmb->c_active_alpha; - xmb->settings_node.zoom = xmb->c_active_zoom; + xmb->settings_node.alpha = xmb->category.active.alpha; + xmb->settings_node.zoom = xmb->category.active.zoom; info_list = (core_info_list_t*)g_extern.core_info; @@ -1335,7 +1356,7 @@ static void xmb_context_reset(menu_handle_t *menu) strlcat(content_texturepath, "-content.png", sizeof(content_texturepath)); node->alpha = 0; - node->zoom = xmb->c_passive_zoom; + node->zoom = xmb->category.passive.zoom; node->icon = menu_texture_load(texturepath, TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); node->content_icon = menu_texture_load(content_texturepath, @@ -1344,11 +1365,11 @@ static void xmb_context_reset(menu_handle_t *menu) if (i == xmb->active_category) { - node->alpha = xmb->c_active_alpha; - node->zoom = xmb->c_active_zoom; + node->alpha = xmb->category.active.alpha; + node->zoom = xmb->category.active.zoom; } else if (xmb->depth <= 1) - node->alpha = xmb->c_passive_alpha; + node->alpha = xmb->category.passive.alpha; } } @@ -1422,17 +1443,17 @@ static void xmb_list_insert(menu_handle_t *menu, file_list_t *list, current = menu->selection_ptr; - node->alpha = xmb->i_passive_alpha; - node->zoom = xmb->i_passive_zoom; + node->alpha = xmb->item.passive.alpha; + node->zoom = xmb->item.passive.zoom; node->label_alpha = node->alpha; node->y = xmb_item_y(xmb, i, current); node->x = 0; if (i == current) { - node->alpha = xmb->i_active_alpha; - node->label_alpha = xmb->i_active_alpha; - node->zoom = xmb->i_active_zoom; + node->alpha = xmb->item.active.alpha; + node->label_alpha = xmb->item.active.alpha; + node->zoom = xmb->item.active.zoom; } } @@ -1549,15 +1570,15 @@ static void xmb_toggle(menu_handle_t *menu, bool menu_on) continue; node->alpha = 0; - node->zoom = xmb->c_passive_zoom; + node->zoom = xmb->category.passive.zoom; if (i == xmb->active_category) { - node->alpha = xmb->c_active_alpha; - node->zoom = xmb->c_active_zoom; + node->alpha = xmb->category.active.alpha; + node->zoom = xmb->category.active.zoom; } else if (xmb->depth <= 1) - node->alpha = xmb->c_passive_alpha; + node->alpha = xmb->category.passive.alpha; } } From 5c2d5edff0b16d1cda631dcf2397876ab79d7c5e Mon Sep 17 00:00:00 2001 From: Alcaro Date: Thu, 12 Feb 2015 18:21:13 +0100 Subject: [PATCH 095/147] Shut up some Valgrind errors. --- menu/menu_entries_cbs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index a6dcb07b13..abe908d75f 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -5680,8 +5680,10 @@ void menu_entries_cbs_init(void *data, if (str_list && str_list->size > 0) strlcpy(elem0, str_list->elems[0].data, sizeof(elem0)); + else elem0[0]='\0'; if (str_list && str_list->size > 1) strlcpy(elem1, str_list->elems[1].data, sizeof(elem1)); + else elem1[0]='\0'; if (str_list) { From b2c9a34fc1d52190d3b668394fc97b66ac68c1b7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 18:23:47 +0100 Subject: [PATCH 096/147] (XMB) Cleanup this stuff some more --- menu/drivers/xmb.c | 59 +++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 1221106350..bd30f2fcde 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -93,7 +93,6 @@ typedef struct xmb_handle int old_depth; char icon_dir[4]; char box_message[PATH_MAX_LENGTH]; - char title[PATH_MAX_LENGTH]; struct xmb_texture_item textures[XMB_TEXTURE_LAST]; int icon_size; float x; @@ -104,15 +103,31 @@ typedef struct xmb_handle float vspacing; float margin_left; float margin_top; - float title_margin_left; - float title_margin_top; - float title_margin_bottom; - float label_margin_left; - float label_margin_top; float setting_margin_left; float above_item_offset; float under_item_offset; float above_subitem_offset; + + struct + { + char name[PATH_MAX_LENGTH]; + struct + { + float left; + float top; + float bottom; + } margin; + } title; + + struct + { + struct + { + float left; + float top; + } margin; + } label; + struct { struct @@ -655,7 +670,7 @@ static void xmb_set_title(menu_handle_t *menu, xmb_handle_t *xmb) unsigned menu_type = 0; menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type); - get_title(label, dir, menu_type, xmb->title, sizeof(xmb->title)); + get_title(label, dir, menu_type, xmb->title.name, sizeof(xmb->title)); } else { @@ -668,7 +683,7 @@ static void xmb_set_title(menu_handle_t *menu, xmb_handle_t *xmb) info = (core_info_t*)&info_list->list[menu->categories.selection_ptr - 1]; if (info) - strlcpy(xmb->title, info->display_name, sizeof(xmb->title)); + strlcpy(xmb->title.name, info->display_name, sizeof(xmb->title)); } } @@ -911,8 +926,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, (i == current)); xmb_draw_text(gl, xmb, name, - node->x + xmb->margin_left + xmb->hspacing + xmb->label_margin_left, - xmb->margin_top + node->y + xmb->label_margin_top, + node->x + xmb->margin_left + xmb->hspacing + xmb->label.margin.left, + xmb->margin_top + node->y + xmb->label.margin.top, 1, node->label_alpha, 0); menu_animation_ticker_line(value, 35, g_extern.frame_count / 20, type_str, @@ -933,8 +948,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, && !xmb->textures[XMB_TEXTURE_SWITCH_OFF].id))) xmb_draw_text(gl, xmb, value, node->x + xmb->margin_left + xmb->hspacing + - xmb->label_margin_left + xmb->setting_margin_left, - xmb->margin_top + node->y + xmb->label_margin_top, + xmb->label.margin.left + xmb->setting_margin_left, + xmb->margin_top + node->y + xmb->label.margin.top, 1, node->label_alpha, 0); @@ -986,15 +1001,15 @@ static void xmb_frame(menu_handle_t *menu) core_name = "No Core"; xmb_draw_text(gl, xmb, - xmb->title, xmb->title_margin_left, xmb->title_margin_top, 1, 1, 0); + xmb->title.name, xmb->title.margin.left, xmb->title.margin.top, 1, 1, 0); disp_timedate_set_label(timedate, sizeof(timedate), 0); if (g_settings.menu.timedate_enable) { xmb_draw_text(gl, xmb, - timedate, gl->win_width - xmb->title_margin_left - xmb->icon_size/4, - xmb->title_margin_top, 1, 1, 1); + timedate, gl->win_width - xmb->title.margin.left - xmb->icon_size/4, + xmb->title.margin.top, 1, 1, 1); xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_CLOCK].id, gl->win_width - xmb->icon_size, xmb->icon_size, 1, 0, 1); @@ -1009,8 +1024,8 @@ static void xmb_frame(menu_handle_t *menu) snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION, core_name, core_version); - xmb_draw_text(gl, xmb, title_msg, xmb->title_margin_left, - gl->win_height - xmb->title_margin_bottom, 1, 1, 0); + xmb_draw_text(gl, xmb, title_msg, xmb->title.margin.left, + gl->win_height - xmb->title.margin.bottom, 1, 1, 0); xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_ARROW].id, xmb->x + xmb->margin_left + xmb->hspacing - xmb->icon_size/2.0 + xmb->icon_size, @@ -1165,11 +1180,11 @@ static void *xmb_init(void) xmb->vspacing = 64.0 * scale_factor; xmb->margin_left = 336.0 * scale_factor; xmb->margin_top = (256+32) * scale_factor; - xmb->title_margin_left = 60 * scale_factor; - xmb->title_margin_top = 60 * scale_factor + xmb->font_size/3; - xmb->title_margin_bottom = 60 * scale_factor - xmb->font_size/3; - xmb->label_margin_left = 85.0 * scale_factor; - xmb->label_margin_top = xmb->font_size/3.0; + xmb->title.margin.left = 60 * scale_factor; + xmb->title.margin.top = 60 * scale_factor + xmb->font_size/3; + xmb->title.margin.bottom = 60 * scale_factor - xmb->font_size/3; + xmb->label.margin.left = 85.0 * scale_factor; + xmb->label.margin.top = xmb->font_size/3.0; xmb->setting_margin_left = 600.0 * scale_factor; menu->categories.size = 1; From 852842beaf59b9adcf524eddcde44f6e996f47e6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 18:25:48 +0100 Subject: [PATCH 097/147] (XMB) Move font variables to struct --- menu/drivers/xmb.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index bd30f2fcde..7a2da77470 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -157,8 +157,12 @@ typedef struct xmb_handle } passive; } item; - void *font; - int font_size; + struct + { + void *buf; + int size; + } font; + xmb_node_t settings_node; bool prevent_populate; } xmb_handle_t; @@ -338,7 +342,7 @@ static void xmb_draw_text(gl_t *gl, xmb_handle_t *xmb, const char *str, float x, if (driver.video_data && driver.video_poke && driver.video_poke->set_osd_msg) driver.video_poke->set_osd_msg(driver.video_data, - str, ¶ms, xmb->font); + str, ¶ms, xmb->font.buf); } static void xmb_render_background(gl_t *gl, xmb_handle_t *xmb, @@ -447,15 +451,15 @@ static void xmb_render_messagebox(menu_handle_t *menu, const char *message) if (list->elems == 0) goto end; - x = gl->win_width / 2 - strlen(list->elems[0].data) * xmb->font_size / 4; - y = gl->win_height / 2 - list->size * xmb->font_size / 2; + x = gl->win_width / 2 - strlen(list->elems[0].data) * xmb->font.size / 4; + y = gl->win_height / 2 - list->size * xmb->font.size / 2; for (i = 0; i < list->size; i++) { const char *msg = list->elems[i].data; if (msg) - xmb_draw_text(gl, xmb, msg, x, y + i * xmb->font_size, 1, 1, 0); + xmb_draw_text(gl, xmb, msg, x, y + i * xmb->font.size, 1, 1, 0); } end: @@ -1175,16 +1179,16 @@ static void *xmb_init(void) strlcpy(xmb->icon_dir, "256", sizeof(xmb->icon_dir)); xmb->icon_size = 128.0 * scale_factor; - xmb->font_size = 32.0 * scale_factor; + xmb->font.size = 32.0 * scale_factor; xmb->hspacing = 200.0 * scale_factor; xmb->vspacing = 64.0 * scale_factor; xmb->margin_left = 336.0 * scale_factor; xmb->margin_top = (256+32) * scale_factor; xmb->title.margin.left = 60 * scale_factor; - xmb->title.margin.top = 60 * scale_factor + xmb->font_size/3; - xmb->title.margin.bottom = 60 * scale_factor - xmb->font_size/3; + xmb->title.margin.top = 60 * scale_factor + xmb->font.size/3; + xmb->title.margin.bottom = 60 * scale_factor - xmb->font.size/3; xmb->label.margin.left = 85.0 * scale_factor; - xmb->label.margin.top = xmb->font_size/3.0; + xmb->label.margin.top = xmb->font.size/3.0; xmb->setting_margin_left = 600.0 * scale_factor; menu->categories.size = 1; @@ -1278,7 +1282,7 @@ static void xmb_context_reset(menu_handle_t *menu) fill_pathname_join(fontpath, themepath, "font.ttf", sizeof(fontpath)); - xmb_font_init_first(&gl->font_driver, &xmb->font, gl, fontpath, xmb->font_size); + xmb_font_init_first(&gl->font_driver, &xmb->font.buf, gl, fontpath, xmb->font.size); if (*g_settings.menu.wallpaper) strlcpy(xmb->textures[XMB_TEXTURE_BG].path, g_settings.menu.wallpaper, From 7938e05b9cbf40b3e44598e118905bbaa2a333c7 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Thu, 12 Feb 2015 18:30:15 +0100 Subject: [PATCH 098/147] Shut up some more Valgrind errors. (Why is r600_dri.so branching on the frame buffer?) --- menu/drivers/rgui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 59377d5355..e58fc1495f 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -459,7 +459,7 @@ static void *rgui_init(void) if (!menu) return NULL; - menu->frame_buf.data = (uint16_t*)malloc(400 * 240 * sizeof(uint16_t)); + menu->frame_buf.data = (uint16_t*)calloc(400 * 240, sizeof(uint16_t)); if (!menu->frame_buf.data) goto error; From 7fb3b7e4a01520626626459ccdbe40c8bb330cea Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 18:31:46 +0100 Subject: [PATCH 099/147] (XMB) Move icon variables to struct --- menu/drivers/xmb.c | 66 ++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 7a2da77470..8d71f1e006 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -91,10 +91,8 @@ typedef struct xmb_handle int active_category_old; int depth; int old_depth; - char icon_dir[4]; char box_message[PATH_MAX_LENGTH]; struct xmb_texture_item textures[XMB_TEXTURE_LAST]; - int icon_size; float x; float categories_x; float alpha; @@ -108,6 +106,12 @@ typedef struct xmb_handle float under_item_offset; float above_subitem_offset; + struct + { + char dir[4]; + int size; + } icon; + struct { char name[PATH_MAX_LENGTH]; @@ -271,10 +275,10 @@ static void xmb_draw_icon(gl_t *gl, xmb_handle_t *xmb, return; if ( - x < -xmb->icon_size/2 || + x < -xmb->icon.size/2 || x > gl->win_width || - y < xmb->icon_size/2 || - y > gl->win_height + xmb->icon_size) + y < xmb->icon.size/2 || + y > gl->win_height + xmb->icon.size) return; GLfloat color[] = { @@ -287,7 +291,7 @@ static void xmb_draw_icon(gl_t *gl, xmb_handle_t *xmb, if (gl->shader && gl->shader->use) gl->shader->use(gl, GL_SHADER_STOCK_BLEND); - glViewport(x, gl->win_height - y, xmb->icon_size, xmb->icon_size); + glViewport(x, gl->win_height - y, xmb->icon.size, xmb->icon.size); coords.vertices = 4; coords.vertex = rmb_vertex; @@ -325,8 +329,8 @@ static void xmb_draw_text(gl_t *gl, xmb_handle_t *xmb, const char *str, float x, if (a8 == 0) return; - if (x < -xmb->icon_size || x > gl->win_width + xmb->icon_size - || y < -xmb->icon_size || y > gl->win_height + xmb->icon_size) + if (x < -xmb->icon.size || x > gl->win_width + xmb->icon.size + || y < -xmb->icon.size || y > gl->win_height + xmb->icon.size) return; gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); @@ -523,7 +527,7 @@ static void xmb_list_open_old(menu_handle_t *menu, xmb_handle_t *xmb, file_list_ menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); menu_animation_push(menu->animation, XMB_DELAY, 0, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(menu->animation, XMB_DELAY, xmb->icon_size*dir*-2, &node->x, EASING_IN_OUT_QUAD, NULL); + menu_animation_push(menu->animation, XMB_DELAY, xmb->icon.size * dir * -2, &node->x, EASING_IN_OUT_QUAD, NULL); } } @@ -545,7 +549,7 @@ static void xmb_list_open_new(menu_handle_t *menu, if (dir == 1 || dir == -1) node->label_alpha = 0; - node->x = xmb->icon_size * dir * 2; + node->x = xmb->icon.size * dir * 2; node->y = xmb_item_y(xmb, i, current); if (i == current) @@ -768,14 +772,14 @@ static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) switch (xmb->depth) { case 1: - menu_animation_push(menu->animation, XMB_DELAY, xmb->icon_size*-(xmb->depth*2-2), + menu_animation_push(menu->animation, XMB_DELAY, xmb->icon.size * -(xmb->depth*2-2), &xmb->x, EASING_IN_OUT_QUAD, NULL); menu_animation_push(menu->animation, XMB_DELAY, 0, &xmb->arrow_alpha, EASING_IN_OUT_QUAD, NULL); break; case 2: menu_animation_push(menu->animation, XMB_DELAY, - xmb->icon_size*-(xmb->depth*2-2), &xmb->x, EASING_IN_OUT_QUAD, NULL); + xmb->icon.size * -(xmb->depth*2-2), &xmb->x, EASING_IN_OUT_QUAD, NULL); menu_animation_push(menu->animation, XMB_DELAY, 1, &xmb->arrow_alpha, EASING_IN_OUT_QUAD, NULL); break; @@ -844,14 +848,14 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, if (!node) continue; - icon_x = node->x + xmb->margin_left + xmb->hspacing - xmb->icon_size/2.0; - icon_y = xmb->margin_top + node->y + xmb->icon_size/2.0; + icon_x = node->x + xmb->margin_left + xmb->hspacing - xmb->icon.size / 2.0; + icon_y = xmb->margin_top + node->y + xmb->icon.size / 2.0; if ( - icon_x < -xmb->icon_size/2 || + icon_x < -xmb->icon.size / 2 || icon_x > gl->win_width || - icon_y < xmb->icon_size/2 || - icon_y > gl->win_height + xmb->icon_size) + icon_y < xmb->icon.size / 2 || + icon_y > gl->win_height + xmb->icon.size) continue; menu_list_get_at_offset(list, i, &path, &entry_label, &type); @@ -961,8 +965,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, if (!strcmp(type_str, "ON") && xmb->textures[XMB_TEXTURE_SWITCH_ON].id) xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_SWITCH_ON].id, node->x + xmb->margin_left + xmb->hspacing - + xmb->icon_size/2.0 + xmb->setting_margin_left, - xmb->margin_top + node->y + xmb->icon_size/2.0, + + xmb->icon.size / 2.0 + xmb->setting_margin_left, + xmb->margin_top + node->y + xmb->icon.size / 2.0, node->alpha, 0, 1); @@ -970,8 +974,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, if (!strcmp(type_str, "OFF") && xmb->textures[XMB_TEXTURE_SWITCH_OFF].id) xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_SWITCH_OFF].id, node->x + xmb->margin_left + xmb->hspacing - + xmb->icon_size/2.0 + xmb->setting_margin_left, - xmb->margin_top + node->y + xmb->icon_size/2.0, + + xmb->icon.size / 2.0 + xmb->setting_margin_left, + xmb->margin_top + node->y + xmb->icon.size / 2.0, node->alpha, 0, 1); @@ -1012,11 +1016,11 @@ static void xmb_frame(menu_handle_t *menu) if (g_settings.menu.timedate_enable) { xmb_draw_text(gl, xmb, - timedate, gl->win_width - xmb->title.margin.left - xmb->icon_size/4, + timedate, gl->win_width - xmb->title.margin.left - xmb->icon.size / 4, xmb->title.margin.top, 1, 1, 1); xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_CLOCK].id, - gl->win_width - xmb->icon_size, xmb->icon_size, 1, 0, 1); + gl->win_width - xmb->icon.size, xmb->icon.size, 1, 0, 1); } core_version = g_extern.menu.info.library_version; @@ -1032,8 +1036,8 @@ static void xmb_frame(menu_handle_t *menu) gl->win_height - xmb->title.margin.bottom, 1, 1, 0); xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_ARROW].id, - xmb->x + xmb->margin_left + xmb->hspacing - xmb->icon_size/2.0 + xmb->icon_size, - xmb->margin_top + xmb->icon_size/2.0 + xmb->vspacing * xmb->item.active.factor, + xmb->x + xmb->margin_left + xmb->hspacing - xmb->icon.size / 2.0 + xmb->icon.size, + xmb->margin_top + xmb->icon.size / 2.0 + xmb->vspacing * xmb->item.active.factor, xmb->arrow_alpha, 0, 1); depth = file_list_get_size(menu->menu_list->menu_stack); @@ -1057,8 +1061,8 @@ static void xmb_frame(menu_handle_t *menu) if (node) xmb_draw_icon(gl, xmb, node->icon, - xmb->x + xmb->categories_x + xmb->margin_left + xmb->hspacing * (i + 1) - xmb->icon_size / 2.0, - xmb->margin_top + xmb->icon_size / 2.0, + xmb->x + xmb->categories_x + xmb->margin_left + xmb->hspacing * (i + 1) - xmb->icon.size / 2.0, + xmb->margin_top + xmb->icon.size / 2.0, node->alpha, 0, node->zoom); @@ -1176,9 +1180,9 @@ static void *xmb_init(void) else if (gl->win_width >= 320) scale_factor = 0.25; - strlcpy(xmb->icon_dir, "256", sizeof(xmb->icon_dir)); + strlcpy(xmb->icon.dir, "256", sizeof(xmb->icon.dir)); - xmb->icon_size = 128.0 * scale_factor; + xmb->icon.size = 128.0 * scale_factor; xmb->font.size = 32.0 * scale_factor; xmb->hspacing = 200.0 * scale_factor; xmb->vspacing = 64.0 * scale_factor; @@ -1277,7 +1281,7 @@ static void xmb_context_reset(menu_handle_t *menu) fill_pathname_join(mediapath, g_settings.assets_directory, "lakka", sizeof(mediapath)); fill_pathname_join(themepath, mediapath, XMB_THEME, sizeof(themepath)); - fill_pathname_join(iconpath, themepath, xmb->icon_dir, sizeof(iconpath)); + fill_pathname_join(iconpath, themepath, xmb->icon.dir, sizeof(iconpath)); fill_pathname_slash(iconpath, sizeof(iconpath)); fill_pathname_join(fontpath, themepath, "font.ttf", sizeof(fontpath)); @@ -1349,7 +1353,7 @@ static void xmb_context_reset(menu_handle_t *menu) fill_pathname_join(mediapath, g_settings.assets_directory, "lakka", sizeof(mediapath)); fill_pathname_join(themepath, mediapath, XMB_THEME, sizeof(themepath)); - fill_pathname_join(iconpath, themepath, xmb->icon_dir, sizeof(iconpath)); + fill_pathname_join(iconpath, themepath, xmb->icon.dir, sizeof(iconpath)); fill_pathname_slash(iconpath, sizeof(iconpath)); info = (core_info_t*)&info_list->list[i-1]; From ecbd841289d8e9960c800bdec9e4ffdd2a96119d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 18:34:36 +0100 Subject: [PATCH 100/147] Move 'offset' variables to structs --- menu/drivers/xmb.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 8d71f1e006..c520c3b167 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -102,9 +102,17 @@ typedef struct xmb_handle float margin_left; float margin_top; float setting_margin_left; - float above_item_offset; - float under_item_offset; - float above_subitem_offset; + + struct + { + float item; + float subitem; + } above_offset; + + struct + { + float item; + } under_offset; struct { @@ -191,11 +199,11 @@ static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current) if (i < current) if (xmb->depth > 1) - iy *= (i - (int)current + xmb->above_subitem_offset); + iy *= (i - (int)current + xmb->above_offset.subitem); else - iy *= (i - (int)current + xmb->above_item_offset); + iy *= (i - (int)current + xmb->above_offset.item); else - iy *= (i - (int)current + xmb->under_item_offset); + iy *= (i - (int)current + xmb->under_offset.item); if (i == current) iy = xmb->vspacing * xmb->item.active.factor; @@ -1162,10 +1170,10 @@ static void *xmb_init(void) xmb->item.active.alpha = 1.0; xmb->item.passive.alpha = 0.5; - xmb->above_subitem_offset = 1.5; - xmb->above_item_offset = -1.0; + xmb->above_offset.subitem = 1.5; + xmb->above_offset.item = -1.0; xmb->item.active.factor = 3.0; - xmb->under_item_offset = 5.0; + xmb->under_offset.item = 5.0; if (gl->win_width >= 3840) scale_factor = 2.0; From 12825086b96945a78adddc58b2cb48bf64671179 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 18:38:27 +0100 Subject: [PATCH 101/147] (XMB) Move active_category variables to 'category' struct --- menu/drivers/xmb.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c520c3b167..d2ee6e7a33 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -87,8 +87,6 @@ typedef struct xmb_handle file_list_t *selection_buf_old; size_t cat_selection_ptr_old; size_t selection_ptr_old; - int active_category; - int active_category_old; int depth; int old_depth; char box_message[PATH_MAX_LENGTH]; @@ -146,6 +144,8 @@ typedef struct xmb_handle { float zoom; float alpha; + int idx; + int idx_old; } active; struct { @@ -618,7 +618,7 @@ static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, int i) node->alpha = xmb->category.passive.alpha; node->zoom = xmb->category.passive.zoom; - if ((i + 1) == xmb->active_category) + if ((i + 1) == xmb->category.active.idx) { node->alpha = xmb->category.active.alpha; node->zoom = xmb->category.active.zoom; @@ -711,7 +711,7 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) if (menu->categories.selection_ptr > xmb->cat_selection_ptr_old) dir = 1; - xmb->active_category += dir; + xmb->category.active.idx += dir; for (j = 0; j < menu->categories.size; j++) { @@ -722,7 +722,7 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) if (!node) continue; - if (j == xmb->active_category) + if (j == xmb->category.active.idx) { ia = xmb->category.active.alpha; iz = xmb->category.active.zoom; @@ -742,7 +742,7 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) xmb_list_switch_old(menu, xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); xmb_list_switch_new(menu, xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); - xmb->active_category_old = menu->categories.selection_ptr; + xmb->category.active.idx_old = menu->categories.selection_ptr; } static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) @@ -765,7 +765,7 @@ static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) if (!node) continue; - if (j == xmb->active_category) + if (j == xmb->category.active.idx) ia = xmb->category.active.alpha; else if (xmb->depth <= 1) ia = xmb->category.passive.alpha; @@ -817,7 +817,7 @@ static void xmb_populate_entries(menu_handle_t *menu, const char *path, xmb_set_title(menu, xmb); - if (menu->categories.selection_ptr != xmb->active_category_old) + if (menu->categories.selection_ptr != xmb->category.active.idx_old) xmb_list_open(menu, xmb); else xmb_list_switch(menu, xmb); @@ -837,7 +837,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, file_list_get_last(stack, NULL, &label, NULL); - if (xmb->active_category) + if (xmb->category.active.idx) core_node = xmb_get_userdata_from_core(xmb, cat_selection_ptr - 1); end = file_list_get_size(list); @@ -1149,8 +1149,8 @@ static void *xmb_init(void) if (!xmb->selection_buf_old) goto error; - xmb->active_category = 0; - xmb->active_category_old = 0; + xmb->category.active.idx = 0; + xmb->category.active.idx_old = 0; xmb->x = 0; xmb->categories_x = 0; xmb->alpha = 1.0f; @@ -1394,7 +1394,7 @@ static void xmb_context_reset(menu_handle_t *menu) TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); - if (i == xmb->active_category) + if (i == xmb->category.active.idx) { node->alpha = xmb->category.active.alpha; node->zoom = xmb->category.active.zoom; @@ -1603,7 +1603,7 @@ static void xmb_toggle(menu_handle_t *menu, bool menu_on) node->alpha = 0; node->zoom = xmb->category.passive.zoom; - if (i == xmb->active_category) + if (i == xmb->category.active.idx) { node->alpha = xmb->category.active.alpha; node->zoom = xmb->category.active.zoom; From 655cabc18655eef10cfb89970f5a0ac243d85e13 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Thu, 12 Feb 2015 18:39:31 +0100 Subject: [PATCH 102/147] Shut up Valgrind yet again. --- database_info.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/database_info.c b/database_info.c index c5be621e33..14cdfd8f8c 100644 --- a/database_info.c +++ b/database_info.c @@ -253,9 +253,7 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q for (i = 0; i < val->binary.len; i++) { - char crc32_cat[PATH_MAX_LENGTH]; - snprintf(crc32_cat, sizeof(crc32_cat), "%02X", (unsigned char)val->binary.buff[i]); - strlcat(crc32, crc32_cat, sizeof(crc32)); + snprintf(crc32+i*2, sizeof(crc32)-i*2, "%02X", (unsigned char)val->binary.buff[i]); } db_info->crc32 = strdup(crc32); } @@ -267,9 +265,7 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q for (i = 0; i < val->binary.len; i++) { - char sha1_cat[PATH_MAX_LENGTH]; - snprintf(sha1_cat, sizeof(sha1_cat), "%02X", (unsigned char)val->binary.buff[i]); - strlcat(sha1, sha1_cat, sizeof(sha1)); + snprintf(sha1+i*2, sizeof(sha1)-i*2, "%02X", (unsigned char)val->binary.buff[i]); } db_info->sha1 = strdup(sha1); } @@ -281,9 +277,7 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q for (i = 0; i < val->binary.len; i++) { - char md5_cat[PATH_MAX_LENGTH]; - snprintf(md5_cat, sizeof(md5_cat), "%02X", (unsigned char)val->binary.buff[i]); - strlcat(md5, md5_cat, sizeof(md5)); + snprintf(md5+i*2, sizeof(md5)-i*2, "%02X", (unsigned char)val->binary.buff[i]); } db_info->md5 = strdup(md5); } From bd970322ee78f6b007c422aef01fb8c45b209bcc Mon Sep 17 00:00:00 2001 From: Alcaro Date: Thu, 12 Feb 2015 18:40:30 +0100 Subject: [PATCH 103/147] These have nothing to do with paths. Replace with the size of a NUL-terminated hash. --- database_info.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/database_info.c b/database_info.c index 14cdfd8f8c..75c5279604 100644 --- a/database_info.c +++ b/database_info.c @@ -246,10 +246,10 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q if (!strcmp(key->string.buff, "analog")) db_info->analog_supported = val->uint_; - if (!strcmp(key->string.buff, "crc")) + if (!strcmp(key->string.buff, "crc") && val->binary.len==4) { size_t i; - char crc32[PATH_MAX_LENGTH]; + char crc32[9]; for (i = 0; i < val->binary.len; i++) { @@ -258,10 +258,10 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q db_info->crc32 = strdup(crc32); } - if (!strcmp(key->string.buff, "sha1")) + if (!strcmp(key->string.buff, "sha1") && val->binary.len==20) { size_t i; - char sha1[PATH_MAX_LENGTH]; + char sha1[41]; for (i = 0; i < val->binary.len; i++) { @@ -270,10 +270,10 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q db_info->sha1 = strdup(sha1); } - if (!strcmp(key->string.buff, "md5")) + if (!strcmp(key->string.buff, "md5") && val->binary.len==16) { size_t i; - char md5[PATH_MAX_LENGTH]; + char md5[33]; for (i = 0; i < val->binary.len; i++) { From 722b349e9ce3e68f286a0de9f35d6298b5a9b3e7 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Thu, 12 Feb 2015 18:45:39 +0100 Subject: [PATCH 104/147] Refactor this into a function to get rid of some dupe code. --- database_info.c | 53 +++++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 35 deletions(-) diff --git a/database_info.c b/database_info.c index 75c5279604..bc93b61a09 100644 --- a/database_info.c +++ b/database_info.c @@ -118,6 +118,18 @@ int database_info_write_rdl(const char *dir) return 0; } +static char* bin_to_hex_alloc(const uint8_t* data, size_t len) +{ + size_t i; + char* ret=malloc(len*2+1); + + for (i = 0; i < len; i++) + { + snprintf(ret+i*2, 3, "%02X", data[i]); + } + return ret; +} + database_info_list_t *database_info_list_new(const char *rdb_path, const char *query) { libretrodb_t db; @@ -246,41 +258,12 @@ database_info_list_t *database_info_list_new(const char *rdb_path, const char *q if (!strcmp(key->string.buff, "analog")) db_info->analog_supported = val->uint_; - if (!strcmp(key->string.buff, "crc") && val->binary.len==4) - { - size_t i; - char crc32[9]; - - for (i = 0; i < val->binary.len; i++) - { - snprintf(crc32+i*2, sizeof(crc32)-i*2, "%02X", (unsigned char)val->binary.buff[i]); - } - db_info->crc32 = strdup(crc32); - } - - if (!strcmp(key->string.buff, "sha1") && val->binary.len==20) - { - size_t i; - char sha1[41]; - - for (i = 0; i < val->binary.len; i++) - { - snprintf(sha1+i*2, sizeof(sha1)-i*2, "%02X", (unsigned char)val->binary.buff[i]); - } - db_info->sha1 = strdup(sha1); - } - - if (!strcmp(key->string.buff, "md5") && val->binary.len==16) - { - size_t i; - char md5[33]; - - for (i = 0; i < val->binary.len; i++) - { - snprintf(md5+i*2, sizeof(md5)-i*2, "%02X", (unsigned char)val->binary.buff[i]); - } - db_info->md5 = strdup(md5); - } + if (!strcmp(key->string.buff, "crc")) + db_info->crc32 = bin_to_hex_alloc((uint8_t*)val->binary.buff, val->binary.len); + if (!strcmp(key->string.buff, "sha1")) + db_info->sha1 = bin_to_hex_alloc((uint8_t*)val->binary.buff, val->binary.len); + if (!strcmp(key->string.buff, "md5")) + db_info->md5 = bin_to_hex_alloc((uint8_t*)val->binary.buff, val->binary.len); } k++; } From 56f2888aabc720d5dcd35b500edc6421c179c08f Mon Sep 17 00:00:00 2001 From: Alcaro Date: Thu, 12 Feb 2015 18:46:19 +0100 Subject: [PATCH 105/147] Coding style says three-space indentation and backwards-placed asterisks... --- database_info.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/database_info.c b/database_info.c index bc93b61a09..825220469b 100644 --- a/database_info.c +++ b/database_info.c @@ -118,16 +118,16 @@ int database_info_write_rdl(const char *dir) return 0; } -static char* bin_to_hex_alloc(const uint8_t* data, size_t len) +static char *bin_to_hex_alloc(const uint8_t *data, size_t len) { - size_t i; - char* ret=malloc(len*2+1); - - for (i = 0; i < len; i++) - { - snprintf(ret+i*2, 3, "%02X", data[i]); - } - return ret; + size_t i; + char *ret=malloc(len*2+1); + + for (i = 0; i < len; i++) + { + snprintf(ret+i*2, 3, "%02X", data[i]); + } + return ret; } database_info_list_t *database_info_list_new(const char *rdb_path, const char *query) From 4acb177e373ea1a0125e8667505db2f365636726 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 18:47:22 +0100 Subject: [PATCH 106/147] Can now scroll on shader presets in browser --- menu/menu_entries_cbs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index abe908d75f..256e5e9f4a 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -5312,6 +5312,7 @@ static void menu_entries_cbs_init_bind_toggle(menu_file_list_cbs_t *cbs, case MENU_FILE_RDB_ENTRY: case MENU_FILE_CURSOR: case MENU_FILE_SHADER: + case MENU_FILE_SHADER_PRESET: case MENU_FILE_IMAGE: case MENU_FILE_OVERLAY: case MENU_FILE_VIDEOFILTER: From 0cb72b34970dfb85f3d61c5d246dde75bfd2adda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Thu, 12 Feb 2015 18:50:13 +0100 Subject: [PATCH 107/147] (XMB) Fix a crash in xmb_get_userdata_from_core. Fixes #1408 --- menu/drivers/xmb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index d2ee6e7a33..9a5e180141 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -592,6 +592,9 @@ static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, int i) if (!info_list) return NULL; + if (!info_list->count) + return NULL; + info = (core_info_t*)&info_list->list[i]; if (!info) From 3f46f97abd448d84a40056412297a88e237219c8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 19:14:10 +0100 Subject: [PATCH 108/147] Prevent some memory leaks in menu_init --- menu/menu.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/menu/menu.c b/menu/menu.c index 9cd25d3b52..5e17ea6405 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -186,11 +186,16 @@ void *menu_init(const void *data) sizeof(g_settings.menu.driver)); if (!(menu->menu_list = (menu_list_t*)menu_list_new())) - return NULL; + goto error; g_extern.core_info_current = (core_info_t*)calloc(1, sizeof(core_info_t)); + if (!g_extern.core_info_current) + goto error; + #ifdef HAVE_SHADER_MANAGER menu->shader = (struct video_shader*)calloc(1, sizeof(struct video_shader)); + if (!menu->shader) + goto error; #endif menu->push_start_screen = g_settings.menu_show_start_screen; g_settings.menu_show_start_screen = false; @@ -200,12 +205,22 @@ void *menu_init(const void *data) menu->animation = (animation_t*)calloc(1, sizeof(animation_t)); if (!menu->animation) - { - free(menu); - return NULL; - } + goto error; return menu; +error: + if (menu->menu_list) + menu_list_free(menu->menu_list); + menu->menu_list = NULL; + if (g_extern.core_info_current) + free(g_extern.core_info_current); + g_extern.core_info_current = NULL; + if (menu->shader) + free(menu->shader); + menu->shader = NULL; + if (menu) + free(menu); + return NULL; } /** From 2ec829ebc1a8022c0b60ca7734641877f2be50d7 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Thu, 12 Feb 2015 19:17:04 +0100 Subject: [PATCH 109/147] Fix releaseyear queries giving empty result sets. --- menu/menu_database.c | 2 +- menu/menu_entries_cbs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/menu_database.c b/menu/menu_database.c index fe10269ab2..816f93b2aa 100644 --- a/menu/menu_database.c +++ b/menu/menu_database.c @@ -27,7 +27,7 @@ int menu_database_populate_query(file_list_t *list, const char *path, #ifdef HAVE_LIBRETRODB libretrodb_t db; libretrodb_cursor_t cur; - + if ((libretrodb_open(path, &db)) != 0) return -1; if ((database_open_cursor(&db, &cur, query) != 0)) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 256e5e9f4a..e1d8026e21 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -853,8 +853,8 @@ static uint32_t create_string_list_rdb_entry_int(const char *desc, const char *l str_len += strlen(label) + 1; string_list_append(str_list, label, attr); - str_len += sizeof(actual_int); snprintf(str, sizeof(str), "%d", actual_int); + str_len += strlen(str) + 1; string_list_append(str_list, str, attr); str_len += strlen(path) + 1; From 2ae66e05e5c14f46f6b50d8e4c1cae75d8b70643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Thu, 12 Feb 2015 19:15:48 +0100 Subject: [PATCH 110/147] (XMB) Add a setting to display or hide the core name and core version --- general.h | 1 + menu/drivers/xmb.c | 21 ++++++++++++--------- retroarch.cfg | 3 +++ settings.c | 3 +++ settings_data.c | 12 ++++++++++++ 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/general.h b/general.h index 8e27757c67..8ccc5937c7 100644 --- a/general.h +++ b/general.h @@ -205,6 +205,7 @@ struct settings bool pause_libretro; bool mouse_enable; bool timedate_enable; + bool core_enable; bool throttle; char wallpaper[PATH_MAX_LENGTH]; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 9a5e180141..5b66b58378 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1034,17 +1034,20 @@ static void xmb_frame(menu_handle_t *menu) gl->win_width - xmb->icon.size, xmb->icon.size, 1, 0, 1); } - core_version = g_extern.menu.info.library_version; + if (g_settings.menu.core_enable) + { + core_version = g_extern.menu.info.library_version; - if (!core_version) - core_version = g_extern.system.info.library_version; - if (!core_version) - core_version = ""; + if (!core_version) + core_version = g_extern.system.info.library_version; + if (!core_version) + core_version = ""; - snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION, - core_name, core_version); - xmb_draw_text(gl, xmb, title_msg, xmb->title.margin.left, - gl->win_height - xmb->title.margin.bottom, 1, 1, 0); + snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION, + core_name, core_version); + xmb_draw_text(gl, xmb, title_msg, xmb->title.margin.left, + gl->win_height - xmb->title.margin.bottom, 1, 1, 0); + } xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_ARROW].id, xmb->x + xmb->margin_left + xmb->hspacing - xmb->icon.size / 2.0 + xmb->icon.size, diff --git a/retroarch.cfg b/retroarch.cfg index 784b4e28db..ff5b9d0c86 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -597,6 +597,9 @@ # Shows current date and/or time inside menu. # menu_timedate_enable = true +# Shows current core inside menu. +# menu_core_enable = true + # Throttle the menu to ~60 FPS instead of using v-sync. Useful for 120+Hz monitors. # menu_throttle = false diff --git a/settings.c b/settings.c index 4848e332e1..4ecf4b7af8 100644 --- a/settings.c +++ b/settings.c @@ -485,6 +485,7 @@ static void config_set_defaults(void) g_settings.menu.pause_libretro = true; g_settings.menu.mouse_enable = false; g_settings.menu.timedate_enable = true; + g_settings.menu.core_enable = true; g_settings.menu.throttle = false; *g_settings.menu.wallpaper = '\0'; g_settings.menu.navigation.wraparound.horizontal_enable = true; @@ -1107,6 +1108,7 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL(menu.pause_libretro, "menu_pause_libretro"); CONFIG_GET_BOOL(menu.mouse_enable, "menu_mouse_enable"); CONFIG_GET_BOOL(menu.timedate_enable, "menu_timedate_enable"); + CONFIG_GET_BOOL(menu.core_enable, "menu_core_enable"); CONFIG_GET_BOOL(menu.navigation.wraparound.horizontal_enable, "menu_navigation_wraparound_horizontal_enable"); CONFIG_GET_BOOL(menu.navigation.wraparound.vertical_enable, "menu_navigation_wraparound_vertical_enable"); CONFIG_GET_BOOL(menu.navigation.browser.filter.supported_extensions_enable, "menu_navigation_browser_filter_supported_extensions_enable"); @@ -1881,6 +1883,7 @@ bool config_save_file(const char *path) config_set_bool(conf,"menu_pause_libretro", g_settings.menu.pause_libretro); config_set_bool(conf,"menu_mouse_enable", g_settings.menu.mouse_enable); config_set_bool(conf,"menu_timedate_enable", g_settings.menu.timedate_enable); + config_set_bool(conf,"menu_core_enable", g_settings.menu.core_enable); config_set_bool(conf,"menu_throttle", g_settings.menu.throttle); config_set_path(conf, "menu_wallpaper", g_settings.menu.wallpaper); #endif diff --git a/settings_data.c b/settings_data.c index 81250fa8ec..4c10bcbb3f 100644 --- a/settings_data.c +++ b/settings_data.c @@ -5255,6 +5255,18 @@ static bool setting_data_append_list_menu_options( general_write_handler, general_read_handler); + CONFIG_BOOL( + g_settings.menu.core_enable, + "menu_core_enable", + "Core enable", + true, + "OFF", + "ON", + group_info.name, + subgroup_info.name, + general_write_handler, + general_read_handler); + END_SUB_GROUP(list, list_info); From 2252e47028d2f7952e1cc878ac154978c15c6a3f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 19:23:11 +0100 Subject: [PATCH 111/147] (XMB) Move some more variables around --- menu/drivers/xmb.c | 92 +++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 9a5e180141..669171455a 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -85,14 +85,12 @@ typedef struct xmb_handle { file_list_t *menu_stack_old; file_list_t *selection_buf_old; - size_t cat_selection_ptr_old; size_t selection_ptr_old; int depth; int old_depth; char box_message[PATH_MAX_LENGTH]; struct xmb_texture_item textures[XMB_TEXTURE_LAST]; float x; - float categories_x; float alpha; float arrow_alpha; float hspacing; @@ -147,12 +145,16 @@ typedef struct xmb_handle int idx; int idx_old; } active; + struct { float zoom; float alpha; } passive; - } category; + + float x_pos; + size_t selection_ptr_old; + } categories; struct { @@ -618,13 +620,13 @@ static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, int i) if (!node) return NULL; - node->alpha = xmb->category.passive.alpha; - node->zoom = xmb->category.passive.zoom; + node->alpha = xmb->categories.passive.alpha; + node->zoom = xmb->categories.passive.zoom; - if ((i + 1) == xmb->category.active.idx) + if ((i + 1) == xmb->categories.active.idx) { - node->alpha = xmb->category.active.alpha; - node->zoom = xmb->category.active.zoom; + node->alpha = xmb->categories.active.alpha; + node->zoom = xmb->categories.active.zoom; } return node; @@ -711,24 +713,24 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) unsigned j; int dir = -1; - if (menu->categories.selection_ptr > xmb->cat_selection_ptr_old) + if (menu->categories.selection_ptr > xmb->categories.selection_ptr_old) dir = 1; - xmb->category.active.idx += dir; + xmb->categories.active.idx += dir; for (j = 0; j < menu->categories.size; j++) { - float ia = xmb->category.passive.alpha; - float iz = xmb->category.passive.zoom; + float ia = xmb->categories.passive.alpha; + float iz = xmb->categories.passive.zoom; xmb_node_t *node = j ? xmb_get_userdata_from_core(xmb, j - 1) : &xmb->settings_node; if (!node) continue; - if (j == xmb->category.active.idx) + if (j == xmb->categories.active.idx) { - ia = xmb->category.active.alpha; - iz = xmb->category.active.zoom; + ia = xmb->categories.active.alpha; + iz = xmb->categories.active.zoom; } menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); @@ -737,15 +739,15 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) menu_animation_push(menu->animation, XMB_DELAY, xmb->hspacing * -(float)menu->categories.selection_ptr, - &xmb->categories_x, EASING_IN_OUT_QUAD, NULL); + &xmb->categories.x_pos, EASING_IN_OUT_QUAD, NULL); dir = -1; - if (menu->categories.selection_ptr > xmb->cat_selection_ptr_old) + if (menu->categories.selection_ptr > xmb->categories.selection_ptr_old) dir = 1; xmb_list_switch_old(menu, xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); xmb_list_switch_new(menu, xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); - xmb->category.active.idx_old = menu->categories.selection_ptr; + xmb->categories.active.idx_old = menu->categories.selection_ptr; } static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) @@ -768,10 +770,10 @@ static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) if (!node) continue; - if (j == xmb->category.active.idx) - ia = xmb->category.active.alpha; + if (j == xmb->categories.active.idx) + ia = xmb->categories.active.alpha; else if (xmb->depth <= 1) - ia = xmb->category.passive.alpha; + ia = xmb->categories.passive.alpha; menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); @@ -820,7 +822,7 @@ static void xmb_populate_entries(menu_handle_t *menu, const char *path, xmb_set_title(menu, xmb); - if (menu->categories.selection_ptr != xmb->category.active.idx_old) + if (menu->categories.selection_ptr != xmb->categories.active.idx_old) xmb_list_open(menu, xmb); else xmb_list_switch(menu, xmb); @@ -840,7 +842,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, file_list_get_last(stack, NULL, &label, NULL); - if (xmb->category.active.idx) + if (xmb->categories.active.idx) core_node = xmb_get_userdata_from_core(xmb, cat_selection_ptr - 1); end = file_list_get_size(list); @@ -1058,7 +1060,7 @@ static void xmb_frame(menu_handle_t *menu) xmb->menu_stack_old, xmb->selection_ptr_old, depth > 1 ? menu->categories.selection_ptr : - xmb->cat_selection_ptr_old); + xmb->categories.selection_ptr_old); xmb_draw_items(xmb, gl, menu->menu_list->selection_buf, @@ -1072,7 +1074,7 @@ static void xmb_frame(menu_handle_t *menu) if (node) xmb_draw_icon(gl, xmb, node->icon, - xmb->x + xmb->categories_x + xmb->margin_left + xmb->hspacing * (i + 1) - xmb->icon.size / 2.0, + xmb->x + xmb->categories.x_pos + xmb->margin_left + xmb->hspacing * (i + 1) - xmb->icon.size / 2.0, xmb->margin_top + xmb->icon.size / 2.0, node->alpha, 0, @@ -1152,10 +1154,10 @@ static void *xmb_init(void) if (!xmb->selection_buf_old) goto error; - xmb->category.active.idx = 0; - xmb->category.active.idx_old = 0; + xmb->categories.active.idx = 0; + xmb->categories.active.idx_old = 0; xmb->x = 0; - xmb->categories_x = 0; + xmb->categories.x_pos = 0; xmb->alpha = 1.0f; xmb->arrow_alpha = 0; xmb->depth = 1; @@ -1163,13 +1165,13 @@ static void *xmb_init(void) xmb->alpha = 0; xmb->prevent_populate = false; - xmb->category.active.zoom = 1.0; - xmb->category.passive.zoom = 0.5; + xmb->categories.active.zoom = 1.0; + xmb->categories.passive.zoom = 0.5; xmb->item.active.zoom = 1.0; xmb->item.passive.zoom = 0.5; - xmb->category.active.alpha = 1.0; - xmb->category.passive.alpha= 0.5; + xmb->categories.active.alpha = 1.0; + xmb->categories.passive.alpha= 0.5; xmb->item.active.alpha = 1.0; xmb->item.passive.alpha = 0.5; @@ -1349,8 +1351,8 @@ static void xmb_context_reset(menu_handle_t *menu) TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); xmb->settings_node.icon = xmb->textures[XMB_TEXTURE_SETTINGS].id; - xmb->settings_node.alpha = xmb->category.active.alpha; - xmb->settings_node.zoom = xmb->category.active.zoom; + xmb->settings_node.alpha = xmb->categories.active.alpha; + xmb->settings_node.zoom = xmb->categories.active.zoom; info_list = (core_info_list_t*)g_extern.core_info; @@ -1390,20 +1392,20 @@ static void xmb_context_reset(menu_handle_t *menu) strlcat(content_texturepath, "-content.png", sizeof(content_texturepath)); node->alpha = 0; - node->zoom = xmb->category.passive.zoom; + node->zoom = xmb->categories.passive.zoom; node->icon = menu_texture_load(texturepath, TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); node->content_icon = menu_texture_load(content_texturepath, TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); - if (i == xmb->category.active.idx) + if (i == xmb->categories.active.idx) { - node->alpha = xmb->category.active.alpha; - node->zoom = xmb->category.active.zoom; + node->alpha = xmb->categories.active.alpha; + node->zoom = xmb->categories.active.zoom; } else if (xmb->depth <= 1) - node->alpha = xmb->category.passive.alpha; + node->alpha = xmb->categories.passive.alpha; } } @@ -1519,7 +1521,7 @@ static void xmb_list_cache(menu_handle_t *menu, if(!horizontal) return; - xmb->cat_selection_ptr_old = menu->categories.selection_ptr; + xmb->categories.selection_ptr_old = menu->categories.selection_ptr; switch (action) { @@ -1604,15 +1606,15 @@ static void xmb_toggle(menu_handle_t *menu, bool menu_on) continue; node->alpha = 0; - node->zoom = xmb->category.passive.zoom; + node->zoom = xmb->categories.passive.zoom; - if (i == xmb->category.active.idx) + if (i == xmb->categories.active.idx) { - node->alpha = xmb->category.active.alpha; - node->zoom = xmb->category.active.zoom; + node->alpha = xmb->categories.active.alpha; + node->zoom = xmb->categories.active.zoom; } else if (xmb->depth <= 1) - node->alpha = xmb->category.passive.alpha; + node->alpha = xmb->categories.passive.alpha; } } From 9c29348305f684036f55950f4f160a01cc3aa19e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 19:27:13 +0100 Subject: [PATCH 112/147] (XMB) Reorganize some more settings in struct --- menu/drivers/xmb.c | 166 ++++++++++++++++++++++++--------------------- 1 file changed, 87 insertions(+), 79 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 669171455a..7e60ae8467 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -89,16 +89,24 @@ typedef struct xmb_handle int depth; int old_depth; char box_message[PATH_MAX_LENGTH]; - struct xmb_texture_item textures[XMB_TEXTURE_LAST]; float x; float alpha; - float arrow_alpha; float hspacing; float vspacing; float margin_left; float margin_top; float setting_margin_left; + struct + { + struct + { + float alpha; + } arrow; + + struct xmb_texture_item list[XMB_TEXTURE_LAST]; + } textures; + struct { float item; @@ -164,6 +172,7 @@ typedef struct xmb_handle float alpha; float factor; } active; + struct { float zoom; @@ -405,10 +414,10 @@ static void xmb_render_background(gl_t *gl, xmb_handle_t *xmb, if ((g_settings.menu.pause_libretro || !g_extern.main_is_init || g_extern.libretro_dummy) && !force_transparency - && xmb->textures[XMB_TEXTURE_BG].id) + && xmb->textures.list[XMB_TEXTURE_BG].id) { coords.color = color; - glBindTexture(GL_TEXTURE_2D, xmb->textures[XMB_TEXTURE_BG].id); + glBindTexture(GL_TEXTURE_2D, xmb->textures.list[XMB_TEXTURE_BG].id); } else { @@ -787,13 +796,13 @@ static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) case 1: menu_animation_push(menu->animation, XMB_DELAY, xmb->icon.size * -(xmb->depth*2-2), &xmb->x, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(menu->animation, XMB_DELAY, 0, &xmb->arrow_alpha, + menu_animation_push(menu->animation, XMB_DELAY, 0, &xmb->textures.arrow.alpha, EASING_IN_OUT_QUAD, NULL); break; case 2: menu_animation_push(menu->animation, XMB_DELAY, xmb->icon.size * -(xmb->depth*2-2), &xmb->x, EASING_IN_OUT_QUAD, NULL); - menu_animation_push(menu->animation, XMB_DELAY, 1, &xmb->arrow_alpha, + menu_animation_push(menu->animation, XMB_DELAY, 1, &xmb->textures.arrow.alpha, EASING_IN_OUT_QUAD, NULL); break; } @@ -888,56 +897,56 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, switch(type) { case MENU_FILE_DIRECTORY: - icon = xmb->textures[XMB_TEXTURE_FOLDER].id; + icon = xmb->textures.list[XMB_TEXTURE_FOLDER].id; break; case MENU_FILE_PLAIN: - icon = xmb->textures[XMB_TEXTURE_FILE].id; + icon = xmb->textures.list[XMB_TEXTURE_FILE].id; break; case MENU_FILE_PLAYLIST_ENTRY: - icon = xmb->textures[XMB_TEXTURE_FILE].id; + icon = xmb->textures.list[XMB_TEXTURE_FILE].id; break; case MENU_FILE_CONTENTLIST_ENTRY: - icon = xmb->textures[XMB_TEXTURE_FILE].id; + icon = xmb->textures.list[XMB_TEXTURE_FILE].id; if (core_node) icon = core_node->content_icon; break; case MENU_FILE_CARCHIVE: - icon = xmb->textures[XMB_TEXTURE_ZIP].id; + icon = xmb->textures.list[XMB_TEXTURE_ZIP].id; break; case MENU_FILE_CORE: - icon = xmb->textures[XMB_TEXTURE_CORE].id; + icon = xmb->textures.list[XMB_TEXTURE_CORE].id; break; case MENU_FILE_RDB: - icon = xmb->textures[XMB_TEXTURE_RDB].id; + icon = xmb->textures.list[XMB_TEXTURE_RDB].id; break; case MENU_FILE_CURSOR: - icon = xmb->textures[XMB_TEXTURE_CURSOR].id; + icon = xmb->textures.list[XMB_TEXTURE_CURSOR].id; break; case MENU_SETTING_ACTION_RUN: - icon = xmb->textures[XMB_TEXTURE_RUN].id; + icon = xmb->textures.list[XMB_TEXTURE_RUN].id; break; case MENU_SETTING_ACTION_SAVESTATE: - icon = xmb->textures[XMB_TEXTURE_SAVESTATE].id; + icon = xmb->textures.list[XMB_TEXTURE_SAVESTATE].id; break; case MENU_SETTING_ACTION_LOADSTATE: - icon = xmb->textures[XMB_TEXTURE_LOADSTATE].id; + icon = xmb->textures.list[XMB_TEXTURE_LOADSTATE].id; break; case MENU_SETTING_ACTION_SCREENSHOT: - icon = xmb->textures[XMB_TEXTURE_SCREENSHOT].id; + icon = xmb->textures.list[XMB_TEXTURE_SCREENSHOT].id; break; case MENU_SETTING_ACTION_RESET: - icon = xmb->textures[XMB_TEXTURE_RELOAD].id; + icon = xmb->textures.list[XMB_TEXTURE_RELOAD].id; break; case MENU_SETTING_ACTION: - icon = xmb->textures[XMB_TEXTURE_SETTING].id; + icon = xmb->textures.list[XMB_TEXTURE_SETTING].id; if (xmb->depth == 3) - icon = xmb->textures[XMB_TEXTURE_SUBSETTING].id; + icon = xmb->textures.list[XMB_TEXTURE_SUBSETTING].id; break; case MENU_SETTING_GROUP: - icon = xmb->textures[XMB_TEXTURE_SETTING].id; + icon = xmb->textures.list[XMB_TEXTURE_SETTING].id; break; default: - icon = xmb->textures[XMB_TEXTURE_SUBSETTING].id; + icon = xmb->textures.list[XMB_TEXTURE_SUBSETTING].id; break; } @@ -964,9 +973,9 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, && strcmp(type_str, "ON") && strcmp(type_str, "OFF")) || ((!strcmp(type_str, "ON") - && !xmb->textures[XMB_TEXTURE_SWITCH_ON].id) + && !xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id) || (!strcmp(type_str, "OFF") - && !xmb->textures[XMB_TEXTURE_SWITCH_OFF].id))) + && !xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id))) xmb_draw_text(gl, xmb, value, node->x + xmb->margin_left + xmb->hspacing + xmb->label.margin.left + xmb->setting_margin_left, @@ -975,8 +984,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, node->label_alpha, 0); - if (!strcmp(type_str, "ON") && xmb->textures[XMB_TEXTURE_SWITCH_ON].id) - xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_SWITCH_ON].id, + if (!strcmp(type_str, "ON") && xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id) + xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id, node->x + xmb->margin_left + xmb->hspacing + xmb->icon.size / 2.0 + xmb->setting_margin_left, xmb->margin_top + node->y + xmb->icon.size / 2.0, @@ -984,8 +993,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, 0, 1); - if (!strcmp(type_str, "OFF") && xmb->textures[XMB_TEXTURE_SWITCH_OFF].id) - xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_SWITCH_OFF].id, + if (!strcmp(type_str, "OFF") && xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id) + xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id, node->x + xmb->margin_left + xmb->hspacing + xmb->icon.size / 2.0 + xmb->setting_margin_left, xmb->margin_top + node->y + xmb->icon.size / 2.0, @@ -1032,7 +1041,7 @@ static void xmb_frame(menu_handle_t *menu) timedate, gl->win_width - xmb->title.margin.left - xmb->icon.size / 4, xmb->title.margin.top, 1, 1, 1); - xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_CLOCK].id, + xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_CLOCK].id, gl->win_width - xmb->icon.size, xmb->icon.size, 1, 0, 1); } @@ -1048,10 +1057,10 @@ static void xmb_frame(menu_handle_t *menu) xmb_draw_text(gl, xmb, title_msg, xmb->title.margin.left, gl->win_height - xmb->title.margin.bottom, 1, 1, 0); - xmb_draw_icon(gl, xmb, xmb->textures[XMB_TEXTURE_ARROW].id, + xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_ARROW].id, xmb->x + xmb->margin_left + xmb->hspacing - xmb->icon.size / 2.0 + xmb->icon.size, xmb->margin_top + xmb->icon.size / 2.0 + xmb->vspacing * xmb->item.active.factor, - xmb->arrow_alpha, 0, 1); + xmb->textures.arrow.alpha, 0, 1); depth = file_list_get_size(menu->menu_list->menu_stack); @@ -1158,8 +1167,7 @@ static void *xmb_init(void) xmb->categories.active.idx_old = 0; xmb->x = 0; xmb->categories.x_pos = 0; - xmb->alpha = 1.0f; - xmb->arrow_alpha = 0; + xmb->textures.arrow.alpha = 0; xmb->depth = 1; xmb->old_depth = 1; xmb->alpha = 0; @@ -1302,55 +1310,55 @@ static void xmb_context_reset(menu_handle_t *menu) xmb_font_init_first(&gl->font_driver, &xmb->font.buf, gl, fontpath, xmb->font.size); if (*g_settings.menu.wallpaper) - strlcpy(xmb->textures[XMB_TEXTURE_BG].path, g_settings.menu.wallpaper, - sizeof(xmb->textures[XMB_TEXTURE_BG].path)); + strlcpy(xmb->textures.list[XMB_TEXTURE_BG].path, g_settings.menu.wallpaper, + sizeof(xmb->textures.list[XMB_TEXTURE_BG].path)); else - fill_pathname_join(xmb->textures[XMB_TEXTURE_BG].path, iconpath, - "bg.png", sizeof(xmb->textures[XMB_TEXTURE_BG].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_SETTINGS].path, iconpath, - "settings.png", sizeof(xmb->textures[XMB_TEXTURE_SETTINGS].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_SETTING].path, iconpath, - "setting.png", sizeof(xmb->textures[XMB_TEXTURE_SETTING].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_SUBSETTING].path, iconpath, - "subsetting.png", sizeof(xmb->textures[XMB_TEXTURE_SUBSETTING].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_ARROW].path, iconpath, - "arrow.png", sizeof(xmb->textures[XMB_TEXTURE_ARROW].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_RUN].path, iconpath, - "run.png", sizeof(xmb->textures[XMB_TEXTURE_RUN].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_RESUME].path, iconpath, - "resume.png", sizeof(xmb->textures[XMB_TEXTURE_RESUME].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_SAVESTATE].path, iconpath, - "savestate.png", sizeof(xmb->textures[XMB_TEXTURE_SAVESTATE].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_LOADSTATE].path, iconpath, - "loadstate.png", sizeof(xmb->textures[XMB_TEXTURE_LOADSTATE].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_SCREENSHOT].path, iconpath, - "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_FILE].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_FOLDER].path, iconpath, - "folder.png", sizeof(xmb->textures[XMB_TEXTURE_FOLDER].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_ZIP].path, iconpath, - "zip.png", sizeof(xmb->textures[XMB_TEXTURE_ZIP].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_CORE].path, iconpath, - "core.png", sizeof(xmb->textures[XMB_TEXTURE_CORE].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_RDB].path, iconpath, - "database.png", sizeof(xmb->textures[XMB_TEXTURE_RDB].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_CURSOR].path, iconpath, - "cursor.png", sizeof(xmb->textures[XMB_TEXTURE_CURSOR].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_SWITCH_ON].path, iconpath, - "on.png", sizeof(xmb->textures[XMB_TEXTURE_SWITCH_ON].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_SWITCH_OFF].path, iconpath, - "off.png", sizeof(xmb->textures[XMB_TEXTURE_SWITCH_OFF].path)); - fill_pathname_join(xmb->textures[XMB_TEXTURE_CLOCK].path, iconpath, - "clock.png", sizeof(xmb->textures[XMB_TEXTURE_CLOCK].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_BG].path, iconpath, + "bg.png", sizeof(xmb->textures.list[XMB_TEXTURE_BG].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SETTINGS].path, iconpath, + "settings.png", sizeof(xmb->textures.list[XMB_TEXTURE_SETTINGS].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SETTING].path, iconpath, + "setting.png", sizeof(xmb->textures.list[XMB_TEXTURE_SETTING].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SUBSETTING].path, iconpath, + "subsetting.png", sizeof(xmb->textures.list[XMB_TEXTURE_SUBSETTING].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_ARROW].path, iconpath, + "arrow.png", sizeof(xmb->textures.list[XMB_TEXTURE_ARROW].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_RUN].path, iconpath, + "run.png", sizeof(xmb->textures.list[XMB_TEXTURE_RUN].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_RESUME].path, iconpath, + "resume.png", sizeof(xmb->textures.list[XMB_TEXTURE_RESUME].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SAVESTATE].path, iconpath, + "savestate.png", sizeof(xmb->textures.list[XMB_TEXTURE_SAVESTATE].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_LOADSTATE].path, iconpath, + "loadstate.png", sizeof(xmb->textures.list[XMB_TEXTURE_LOADSTATE].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SCREENSHOT].path, iconpath, + "screenshot.png", sizeof(xmb->textures.list[XMB_TEXTURE_SCREENSHOT].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_RELOAD].path, iconpath, + "reload.png", sizeof(xmb->textures.list[XMB_TEXTURE_RELOAD].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_FILE].path, iconpath, + "file.png", sizeof(xmb->textures.list[XMB_TEXTURE_FILE].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_FOLDER].path, iconpath, + "folder.png", sizeof(xmb->textures.list[XMB_TEXTURE_FOLDER].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_ZIP].path, iconpath, + "zip.png", sizeof(xmb->textures.list[XMB_TEXTURE_ZIP].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_CORE].path, iconpath, + "core.png", sizeof(xmb->textures.list[XMB_TEXTURE_CORE].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_RDB].path, iconpath, + "database.png", sizeof(xmb->textures.list[XMB_TEXTURE_RDB].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_CURSOR].path, iconpath, + "cursor.png", sizeof(xmb->textures.list[XMB_TEXTURE_CURSOR].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SWITCH_ON].path, iconpath, + "on.png", sizeof(xmb->textures.list[XMB_TEXTURE_SWITCH_ON].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].path, iconpath, + "off.png", sizeof(xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].path)); + fill_pathname_join(xmb->textures.list[XMB_TEXTURE_CLOCK].path, iconpath, + "clock.png", sizeof(xmb->textures.list[XMB_TEXTURE_CLOCK].path)); for (k = 0; k < XMB_TEXTURE_LAST; k++) - xmb->textures[k].id = menu_texture_load(xmb->textures[k].path, + xmb->textures.list[k].id = menu_texture_load(xmb->textures.list[k].path, TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); - xmb->settings_node.icon = xmb->textures[XMB_TEXTURE_SETTINGS].id; + xmb->settings_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS].id; xmb->settings_node.alpha = xmb->categories.active.alpha; xmb->settings_node.zoom = xmb->categories.active.zoom; @@ -1563,7 +1571,7 @@ static void xmb_context_destroy(menu_handle_t *menu) return; for (i = 0; i < XMB_TEXTURE_LAST; i++) - glDeleteTextures(1, &xmb->textures[i].id); + glDeleteTextures(1, &xmb->textures.list[i].id); for (i = 1; i < menu->categories.size; i++) { From 2107273898ba1a7602967d95dc1adfba70e4f643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Thu, 12 Feb 2015 19:34:28 +0100 Subject: [PATCH 113/147] (XMB) Move the savestate and loadstate entries on top of the contextual menu --- menu/menu_entries_cbs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index abe908d75f..5da5d7c380 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -3444,6 +3444,8 @@ static int deferred_push_content_actions(void *data, void *userdata, !strcmp(driver.menu->deferred_path, g_extern.fullpath)) { menu_list_push(list, "Resume", "file_load_or_resume", MENU_SETTING_ACTION_RUN, 0); + menu_list_push(list, "Save State", "savestate", MENU_SETTING_ACTION_SAVESTATE, 0); + menu_list_push(list, "Load State", "loadstate", MENU_SETTING_ACTION_LOADSTATE, 0); menu_list_push(list, "Core Informations", "core_information", MENU_SETTING_ACTION_CORE_INFORMATION, 0); menu_list_push(list, "Core Options", "core_options", MENU_SETTING_ACTION_CORE_OPTIONS, 0); if (g_extern.has_set_input_descriptors) @@ -3451,8 +3453,6 @@ static int deferred_push_content_actions(void *data, void *userdata, menu_list_push(list, "Core Cheat Options", "core_cheat_options", MENU_SETTING_ACTION_CORE_CHEAT_OPTIONS, 0); if ( !g_extern.libretro_dummy && g_extern.system.disk_control.get_num_images) menu_list_push(list, "Core Disk Options", "disk_options", MENU_SETTING_ACTION_CORE_DISK_OPTIONS, 0); - menu_list_push(list, "Save State", "savestate", MENU_SETTING_ACTION_SAVESTATE, 0); - menu_list_push(list, "Load State", "loadstate", MENU_SETTING_ACTION_LOADSTATE, 0); menu_list_push(list, "Take Screenshot", "take_screenshot", MENU_SETTING_ACTION_SCREENSHOT, 0); menu_list_push(list, "Reset", "restart_content", MENU_SETTING_ACTION_RESET, 0); } From 50c89847f061ad67dcbf89b1e6ffa198f9a02552 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 19:35:24 +0100 Subject: [PATCH 114/147] Backport new element display settings to GLUI/RGUI --- menu/drivers/glui.c | 30 +++++++++++++++++------------- menu/drivers/rgui.c | 30 ++++++++++++++++++------------ menu/drivers/xmb.c | 18 +++++++++--------- 3 files changed, 44 insertions(+), 34 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index ad8adcf596..d91b5ab629 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -314,28 +314,32 @@ static void glui_frame(menu_handle_t *menu) if (!core_name) core_name = "No Core"; - core_version = g_extern.menu.info.library_version; - if (!core_version) - core_version = g_extern.system.info.library_version; - if (!core_version) - core_version = ""; + if (g_settings.menu.core_enable) + { + core_version = g_extern.menu.info.library_version; + if (!core_version) + core_version = g_extern.system.info.library_version; + if (!core_version) + core_version = ""; - snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION, - core_name, core_version); + snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION, + core_name, core_version); - disp_timedate_set_label(timedate, sizeof(timedate), 0); + glui_blit_line(gl, + glui->margin * 2, + glui->margin + glui->term_height * glui->line_height + + glui->line_height * 2, title_msg, true); + } - glui_blit_line(gl, - glui->margin * 2, - glui->margin + glui->term_height * glui->line_height - + glui->line_height * 2, title_msg, true); if (g_settings.menu.timedate_enable) + { + disp_timedate_set_label(timedate, sizeof(timedate), 0); glui_blit_line(gl, glui->margin * 14, glui->margin + glui->term_height * glui->line_height + glui->line_height * 2, timedate, true); - + } x = glui->margin; y = glui->margin + glui->line_height * 2; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index e58fc1495f..4dce438936 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -353,26 +353,32 @@ static void rgui_render(menu_handle_t *menu) if (!core_name) core_name = "No Core"; - core_version = g_extern.menu.info.library_version; - if (!core_version) - core_version = g_extern.system.info.library_version; - if (!core_version) - core_version = ""; + if (g_settings.menu.core_enable) + { + core_version = g_extern.menu.info.library_version; + if (!core_version) + core_version = g_extern.system.info.library_version; + if (!core_version) + core_version = ""; - disp_timedate_set_label(timedate, sizeof(timedate), 3); - snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION, - core_name, core_version); - blit_line(menu, - RGUI_TERM_START_X + RGUI_TERM_START_X, - (RGUI_TERM_HEIGHT * FONT_HEIGHT_STRIDE) + - RGUI_TERM_START_Y + 2, title_msg, true); + snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION, + core_name, core_version); + blit_line(menu, + RGUI_TERM_START_X + RGUI_TERM_START_X, + (RGUI_TERM_HEIGHT * FONT_HEIGHT_STRIDE) + + RGUI_TERM_START_Y + 2, title_msg, true); + } if (g_settings.menu.timedate_enable) + { + disp_timedate_set_label(timedate, sizeof(timedate), 3); + blit_line(menu, (RGUI_TERM_WIDTH * FONT_HEIGHT_STRIDE) + (60), (RGUI_TERM_HEIGHT * FONT_HEIGHT_STRIDE) + RGUI_TERM_START_Y + 2, timedate, true); + } x = RGUI_TERM_START_X; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 19b2e69fe8..98e6f48636 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1023,20 +1023,13 @@ static void xmb_frame(menu_handle_t *menu) xmb_render_background(gl, xmb, false); - core_name = g_extern.menu.info.library_name; - - if (!core_name) - core_name = g_extern.system.info.library_name; - if (!core_name) - core_name = "No Core"; - xmb_draw_text(gl, xmb, xmb->title.name, xmb->title.margin.left, xmb->title.margin.top, 1, 1, 0); - disp_timedate_set_label(timedate, sizeof(timedate), 0); - if (g_settings.menu.timedate_enable) { + disp_timedate_set_label(timedate, sizeof(timedate), 0); + xmb_draw_text(gl, xmb, timedate, gl->win_width - xmb->title.margin.left - xmb->icon.size / 4, xmb->title.margin.top, 1, 1, 1); @@ -1047,6 +1040,13 @@ static void xmb_frame(menu_handle_t *menu) if (g_settings.menu.core_enable) { + core_name = g_extern.menu.info.library_name; + + if (!core_name) + core_name = g_extern.system.info.library_name; + if (!core_name) + core_name = "No Core"; + core_version = g_extern.menu.info.library_version; if (!core_version) From 41f1ffe0bb5c1f62396fe1540469f318777ddece Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 19:52:57 +0100 Subject: [PATCH 115/147] Have a clear distinction between 'settings' and 'options' --- menu/drivers/shared.h | 78 +++++++++++++++++++++-------------------- menu/menu_entries.c | 2 +- menu/menu_entries_cbs.c | 52 +++++++++++++-------------- settings_data.c | 44 +++++++++++++---------- 4 files changed, 92 insertions(+), 84 deletions(-) diff --git a/menu/drivers/shared.h b/menu/drivers/shared.h index b78e3b175d..42d164a69e 100644 --- a/menu/drivers/shared.h +++ b/menu/drivers/shared.h @@ -93,9 +93,9 @@ static INLINE void get_title(const char *label, const char *dir, snprintf(title, sizeof_title, "CONFIG %s", dir); else if (!strcmp(label, "disk_image_append")) snprintf(title, sizeof_title, "DISK APPEND %s", dir); - else if (!strcmp(elem0, "Video Options")) + else if (!strcmp(elem0, "Video Settings")) { - strlcpy(title, "VIDEO OPTIONS", sizeof_title); + strlcpy(title, "VIDEO SETTINGS", sizeof_title); if (!strcmp(elem1, "Monitor")) strlcat(title, " - MONITOR", sizeof_title); else if (!strcmp(elem1, "Aspect")) @@ -109,11 +109,11 @@ static INLINE void get_title(const char *label, const char *dir, else if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); } - else if (!strcmp(elem0, "Input Options") || + else if (!strcmp(elem0, "Input Settings") || menu_type == MENU_SETTINGS_CUSTOM_BIND || menu_type == MENU_SETTINGS_CUSTOM_BIND_KEYBOARD) { - strlcpy(title, "INPUT OPTIONS", sizeof_title); + strlcpy(title, "INPUT SETTINGS", sizeof_title); if (strstr(elem1, "User")) strlcat(title, " - USER", sizeof_title); else if (!strcmp(elem1, "Meta Keys")) @@ -127,15 +127,15 @@ static INLINE void get_title(const char *label, const char *dir, else if (!strcmp(elem1, "Miscellaneous")) strlcat(title, " - MISCELLANEOUS", sizeof_title); } - else if (!strcmp(elem0, "Overlay Options")) + else if (!strcmp(elem0, "Overlay Settings")) { - strlcpy(title, "OVERLAY OPTIONS", sizeof_title); + strlcpy(title, "OVERLAY SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); } - else if (!strcmp(elem0, "Menu Options")) + else if (!strcmp(elem0, "Menu Settings")) { - strlcpy(title, "MENU OPTIONS", sizeof_title); + strlcpy(title, "MENU SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); else if (!strcmp(elem1, "Navigation")) @@ -145,35 +145,35 @@ static INLINE void get_title(const char *label, const char *dir, else if (!strcmp(elem1, "Browser")) strlcat(title, " - BROWSER", sizeof_title); } - else if (!strcmp(elem0, "Onscreen Keyboard Overlay Options")) + else if (!strcmp(elem0, "Onscreen Keyboard Overlay Settings")) { - strlcpy(title, "ONSCREEN KEYBOARD OVERLAY OPTIONS", sizeof_title); + strlcpy(title, "ONSCREEN KEYBOARD OVERLAY SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); } - else if (!strcmp(elem0, "Patch Options")) + else if (!strcmp(elem0, "Patch Settings")) { - strlcpy(title, "PATCH OPTIONS", sizeof_title); + strlcpy(title, "PATCH SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); } - else if (!strcmp(elem0, "UI Options")) + else if (!strcmp(elem0, "UI Settings")) { - strlcpy(title, "UI OPTIONS", sizeof_title); + strlcpy(title, "UI SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); } - else if (!strcmp(elem0, "Playlist Options")) + else if (!strcmp(elem0, "Playlist Settings")) { - strlcpy(title, "PLAYLIST OPTIONS", sizeof_title); + strlcpy(title, "PLAYLIST SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); if (!strcmp(elem1, "History")) strlcat(title, " - HISTORY", sizeof_title); } - else if (!strcmp(elem0, "Network Options")) + else if (!strcmp(elem0, "Network Settings")) { - strlcpy(title, "NETWORK OPTIONS", sizeof_title); + strlcpy(title, "NETWORK SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); if (!strcmp(elem1, "Netplay")) @@ -181,21 +181,21 @@ static INLINE void get_title(const char *label, const char *dir, if (!strcmp(elem1, "Miscellaneous")) strlcat(title, " - MISCELLANEOUS", sizeof_title); } - else if (!strcmp(elem0, "Core Updater Options")) + else if (!strcmp(elem0, "Core Updater Settings")) { - strlcpy(title, "CORE UPDATER OPTIONS", sizeof_title); + strlcpy(title, "CORE UPDATER SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); } - else if (!strcmp(elem0, "User Options")) + else if (!strcmp(elem0, "User Settings")) { - strlcpy(title, "USER OPTIONS", sizeof_title); + strlcpy(title, "USER SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); } - else if (!strcmp(elem0, "Path Options")) + else if (!strcmp(elem0, "Path Settings")) { - strlcpy(title, "PATH OPTIONS", sizeof_title); + strlcpy(title, "PATH SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); if (!strcmp(elem1, "Paths")) @@ -203,9 +203,9 @@ static INLINE void get_title(const char *label, const char *dir, } else if (!strcmp(label, "settings")) strlcpy(title, "SETTINGS", sizeof_title); - else if (!strcmp(elem0, "Driver Options")) + else if (!strcmp(elem0, "Driver Settings")) { - strlcpy(title, "DRIVER OPTIONS", sizeof_title); + strlcpy(title, "DRIVER SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); } @@ -215,15 +215,15 @@ static INLINE void get_title(const char *label, const char *dir, strlcpy(title, "FRONTEND PERFORMANCE COUNTERS", sizeof_title); else if (!strcmp(label, "core_counters")) strlcpy(title, "CORE PERFORMANCE COUNTERS", sizeof_title); - else if (!strcmp(elem0, "Shader Options")) + else if (!strcmp(elem0, "Shader Settings")) { - strlcpy(title, "SHADER OPTIONS", sizeof_title); + strlcpy(title, "SHADER SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); } - else if (!strcmp(elem0, "Archive Options")) + else if (!strcmp(elem0, "Archive Settings")) { - strlcpy(title, "ARCHIVE OPTIONS", sizeof_title); + strlcpy(title, "ARCHIVE SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); } @@ -231,21 +231,21 @@ static INLINE void get_title(const char *label, const char *dir, strlcpy(title, "SHADER PARAMETERS (CURRENT)", sizeof_title); else if (!strcmp(label, "video_shader_preset_parameters")) strlcpy(title, "SHADER PARAMETERS (MENU PRESET)", sizeof_title); - else if (!strcmp(elem0, "Font Options")) + else if (!strcmp(elem0, "Font Settings")) { - strlcpy(title, "FONT OPTIONS", sizeof_title); + strlcpy(title, "FONT SETTINGS", sizeof_title); if (!strcmp(elem1, "Messages")) strlcat(title, " - MESSAGES", sizeof_title); } - else if (!strcmp(elem0, "General Options")) + else if (!strcmp(elem0, "General Settings")) { - strlcpy(title, "GENERAL OPTIONS", sizeof_title); + strlcpy(title, "GENERAL SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); } - else if (!strcmp(elem0, "Audio Options")) + else if (!strcmp(elem0, "Audio Settings")) { - strlcpy(title, "AUDIO OPTIONS", sizeof_title); + strlcpy(title, "AUDIO SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); else if (!strcmp(elem1, "Synchronization")) @@ -257,15 +257,17 @@ static INLINE void get_title(const char *label, const char *dir, strlcpy(title, "DISK OPTIONS", sizeof_title); else if (!strcmp(label, "core_options")) strlcpy(title, "CORE OPTIONS", sizeof_title); + else if (!strcmp(label, "shader_options")) + strlcpy(title, "SHADER OPTIONS", sizeof_title); else if (!strcmp(label, "core_cheat_options")) strlcpy(title, "CORE CHEAT OPTIONS", sizeof_title); else if (!strcmp(label, "core_input_remapping_options")) strlcpy(title, "CORE INPUT REMAPPING OPTIONS", sizeof_title); else if (!strcmp(label, "core_information")) strlcpy(title, "CORE INFO", sizeof_title); - else if (!strcmp(elem0, "Privacy Options")) + else if (!strcmp(elem0, "Privacy Settings")) { - strlcpy(title, "PRIVACY OPTIONS", sizeof_title); + strlcpy(title, "PRIVACY SETTINGS", sizeof_title); if (!strcmp(elem1, "State")) strlcat(title, " - STATE", sizeof_title); } diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 6cec1126b7..f2425b5cbc 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -98,7 +98,7 @@ int menu_entries_push_list(menu_handle_t *menu, /* Hack - should come up with something cleaner * here. */ - if (!strcmp(label, "Video Options")) + if (!strcmp(label, "Video Settings")) { #if defined(GEKKO) || defined(__CELLOS_LV2__) menu_list_push(list, "Screen Resolution", "", diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index a00ab8b8f2..a6ef8def37 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -312,7 +312,7 @@ static int action_ok_shader_pass_load(const char *path, /* This will reset any changed parameters. */ video_shader_resolve_parameters(NULL, driver.menu->shader); - menu_list_flush_stack_by_needle(driver.menu->menu_list, "Shader Options"); + menu_list_flush_stack_by_needle(driver.menu->menu_list, "shader_options"); return 0; #else return -1; @@ -564,7 +564,7 @@ static int action_ok_shader_preset_load(const char *path, menu_shader_manager_set_preset(driver.menu->shader, video_shader_parse_type(shader_path, RARCH_SHADER_NONE), shader_path); - menu_list_flush_stack_by_needle(driver.menu->menu_list, "Shader Options"); + menu_list_flush_stack_by_needle(driver.menu->menu_list, "shader_options"); return 0; #else return -1; @@ -2888,7 +2888,7 @@ static int deferred_push_settings(void *data, void *userdata, settings_list_free(driver.menu->list_settings); driver.menu->list_settings = (rarch_setting_t *)setting_data_new(SL_FLAG_ALL_SETTINGS); - setting = menu_action_find_setting("Driver Options"); + setting = menu_action_find_setting("Driver Settings"); menu_list_clear(list); @@ -3752,7 +3752,7 @@ static int action_iterate_help(const char *label, unsigned action) "Load a libretro core (Core).\n" "Load a content file (Load Content). \n" " \n" - "See Path Options to set directories for faster access to files.\n" + "See Path Settings to set directories for faster access to files.\n" " \n" "Press Accept/OK to continue.", @@ -5029,25 +5029,25 @@ static int is_rdb_entry(const char *label) static int is_settings_entry(const char *label) { return ( - !strcmp(label, "Driver Options") || - !strcmp(label, "General Options") || - !strcmp(label, "Video Options") || - !strcmp(label, "Shader Options") || - !strcmp(label, "Font Options") || - !strcmp(label, "Audio Options") || - !strcmp(label, "Input Options") || - !strcmp(label, "Overlay Options") || - !strcmp(label, "Menu Options") || - !strcmp(label, "UI Options") || - !strcmp(label, "Patch Options") || - !strcmp(label, "Playlist Options") || - !strcmp(label, "Onscreen Keyboard Overlay Options") || - !strcmp(label, "Core Updater Options") || - !strcmp(label, "Network Options") || - !strcmp(label, "Archive Options") || - !strcmp(label, "User Options") || - !strcmp(label, "Path Options") || - !strcmp(label, "Privacy Options")); + !strcmp(label, "Driver Settings") || + !strcmp(label, "General Settings") || + !strcmp(label, "Video Settings") || + !strcmp(label, "Shader Settings") || + !strcmp(label, "Font Settings") || + !strcmp(label, "Audio Settings") || + !strcmp(label, "Input Settings") || + !strcmp(label, "Overlay Settings") || + !strcmp(label, "Menu Settings") || + !strcmp(label, "UI Settings") || + !strcmp(label, "Patch Settings") || + !strcmp(label, "Playlist Settings") || + !strcmp(label, "Onscreen Keyboard Overlay Settings") || + !strcmp(label, "Core Updater Settings") || + !strcmp(label, "Network Settings") || + !strcmp(label, "Archive Settings") || + !strcmp(label, "User Settings") || + !strcmp(label, "Path Settings") || + !strcmp(label, "Privacy Settings")); } static void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, @@ -5118,8 +5118,8 @@ static void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, ) cbs->action_ok = action_ok_shader_parameters; else if ( - !strcmp(label, "Shader Options") || - !strcmp(label, "Input Options") || + !strcmp(label, "shader_options") || + !strcmp(label, "Input Settings") || !strcmp(label, "core_options") || !strcmp(label, "core_cheat_options") || !strcmp(label, "core_input_remapping_options") || @@ -5581,7 +5581,7 @@ static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs, cbs->action_deferred_push = deferred_push_remap_file_load; else if (!strcmp(label, "content_actions")) cbs->action_deferred_push = deferred_push_content_actions; - else if (!strcmp(label, "Shader Options")) + else if (!strcmp(label, "shader_options")) cbs->action_deferred_push = deferred_push_shader_options; else if (type == MENU_SETTING_GROUP) cbs->action_deferred_push = deferred_push_category; diff --git a/settings_data.c b/settings_data.c index 4c10bcbb3f..37d3d4991b 100644 --- a/settings_data.c +++ b/settings_data.c @@ -3279,6 +3279,12 @@ static bool setting_data_append_list_main_menu_options( } } + CONFIG_ACTION( + "shader_options", + "Shader Options", + group_info.name, + subgroup_info.name); + CONFIG_ACTION( "settings", "Settings", @@ -3391,7 +3397,7 @@ static bool setting_data_append_list_driver_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Driver Options"); + START_GROUP(group_info, "Driver Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); @@ -3506,7 +3512,7 @@ static bool setting_data_append_list_general_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "General Options"); + START_GROUP(group_info, "General Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -3750,7 +3756,7 @@ static bool setting_data_append_list_video_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Video Options"); + START_GROUP(group_info, "Video Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -4327,7 +4333,7 @@ static bool setting_data_append_list_shader_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Shader Options"); + START_GROUP(group_info, "Shader Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -4366,7 +4372,7 @@ static bool setting_data_append_list_font_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Font Options"); + START_GROUP(group_info, "Font Settings"); START_SUB_GROUP(list, list_info, "Messages", group_info.name, subgroup_info); CONFIG_PATH( @@ -4443,7 +4449,7 @@ static bool setting_data_append_list_audio_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Audio Options"); + START_GROUP(group_info, "Audio Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -4635,7 +4641,7 @@ static bool setting_data_append_list_input_options( rarch_setting_group_info_t subgroup_info; unsigned i, user; - START_GROUP(group_info, "Input Options"); + START_GROUP(group_info, "Input Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_UINT( @@ -5004,7 +5010,7 @@ static bool setting_data_append_list_overlay_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Overlay Options"); + START_GROUP(group_info, "Overlay Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -5076,7 +5082,7 @@ static bool setting_data_append_list_osk_overlay_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Onscreen Keyboard Overlay Options"); + START_GROUP(group_info, "Onscreen Keyboard Overlay Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -5118,7 +5124,7 @@ static bool setting_data_append_list_menu_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Menu Options"); + START_GROUP(group_info, "Menu Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_PATH( @@ -5283,7 +5289,7 @@ static bool setting_data_append_list_ui_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "UI Options"); + START_GROUP(group_info, "UI Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -5350,7 +5356,7 @@ static bool setting_data_append_list_archive_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Archive Options"); + START_GROUP(group_info, "Archive Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_UINT( @@ -5380,7 +5386,7 @@ static bool setting_data_append_list_core_updater_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Core Updater Options"); + START_GROUP(group_info, "Core Updater Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); @@ -5433,7 +5439,7 @@ static bool setting_data_append_list_netplay_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Network Options"); + START_GROUP(group_info, "Network Settings"); START_SUB_GROUP(list, list_info, "Netplay", group_info.name, subgroup_info); @@ -5565,7 +5571,7 @@ static bool setting_data_append_list_patch_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Patch Options"); + START_GROUP(group_info, "Patch Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( @@ -5617,7 +5623,7 @@ static bool setting_data_append_list_playlist_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Playlist Options"); + START_GROUP(group_info, "Playlist Settings"); START_SUB_GROUP(list, list_info, "History", group_info.name, subgroup_info); CONFIG_BOOL( @@ -5656,7 +5662,7 @@ static bool setting_data_append_list_user_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "User Options"); + START_GROUP(group_info, "User Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_STRING( @@ -5704,7 +5710,7 @@ static bool setting_data_append_list_path_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Path Options"); + START_GROUP(group_info, "Path Settings"); START_SUB_GROUP(list, list_info, "Paths", group_info.name, subgroup_info); #ifdef HAVE_MENU @@ -6086,7 +6092,7 @@ static bool setting_data_append_list_privacy_options( rarch_setting_group_info_t group_info; rarch_setting_group_info_t subgroup_info; - START_GROUP(group_info, "Privacy Options"); + START_GROUP(group_info, "Privacy Settings"); START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info); CONFIG_BOOL( From 073e683846284f0ac5de232d6a24c5f47c9ba8b4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 20:23:14 +0100 Subject: [PATCH 116/147] Organize variables in struct some more --- menu/drivers/xmb.c | 115 ++++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 54 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 98e6f48636..0be781ee9f 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -93,9 +93,35 @@ typedef struct xmb_handle float alpha; float hspacing; float vspacing; - float margin_left; - float margin_top; - float setting_margin_left; + + struct + { + struct + { + float left; + float top; + } screen; + + struct + { + float left; + } setting; + + struct + { + float left; + float top; + float bottom; + } title; + + struct + { + float left; + float top; + } label; + } margins; + + char title_name[PATH_MAX_LENGTH]; struct { @@ -124,25 +150,6 @@ typedef struct xmb_handle int size; } icon; - struct - { - char name[PATH_MAX_LENGTH]; - struct - { - float left; - float top; - float bottom; - } margin; - } title; - - struct - { - struct - { - float left; - float top; - } margin; - } label; struct { @@ -700,7 +707,7 @@ static void xmb_set_title(menu_handle_t *menu, xmb_handle_t *xmb) unsigned menu_type = 0; menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type); - get_title(label, dir, menu_type, xmb->title.name, sizeof(xmb->title)); + get_title(label, dir, menu_type, xmb->title_name, sizeof(xmb->title_name)); } else { @@ -713,7 +720,7 @@ static void xmb_set_title(menu_handle_t *menu, xmb_handle_t *xmb) info = (core_info_t*)&info_list->list[menu->categories.selection_ptr - 1]; if (info) - strlcpy(xmb->title.name, info->display_name, sizeof(xmb->title)); + strlcpy(xmb->title_name, info->display_name, sizeof(xmb->title_name)); } } @@ -870,8 +877,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, if (!node) continue; - icon_x = node->x + xmb->margin_left + xmb->hspacing - xmb->icon.size / 2.0; - icon_y = xmb->margin_top + node->y + xmb->icon.size / 2.0; + icon_x = node->x + xmb->margins.screen.left + xmb->hspacing - xmb->icon.size / 2.0; + icon_y = xmb->margins.screen.top + node->y + xmb->icon.size / 2.0; if ( icon_x < -xmb->icon.size / 2 || @@ -956,8 +963,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, (i == current)); xmb_draw_text(gl, xmb, name, - node->x + xmb->margin_left + xmb->hspacing + xmb->label.margin.left, - xmb->margin_top + node->y + xmb->label.margin.top, + node->x + xmb->margins.screen.left + xmb->hspacing + xmb->margins.label.left, + xmb->margins.screen.top + node->y + xmb->margins.label.top, 1, node->label_alpha, 0); menu_animation_ticker_line(value, 35, g_extern.frame_count / 20, type_str, @@ -977,27 +984,27 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, || (!strcmp(type_str, "OFF") && !xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id))) xmb_draw_text(gl, xmb, value, - node->x + xmb->margin_left + xmb->hspacing + - xmb->label.margin.left + xmb->setting_margin_left, - xmb->margin_top + node->y + xmb->label.margin.top, + node->x + xmb->margins.screen.left + xmb->hspacing + + xmb->margins.label.left + xmb->margins.setting.left, + xmb->margins.screen.top + node->y + xmb->margins.label.top, 1, node->label_alpha, 0); if (!strcmp(type_str, "ON") && xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id) xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id, - node->x + xmb->margin_left + xmb->hspacing - + xmb->icon.size / 2.0 + xmb->setting_margin_left, - xmb->margin_top + node->y + xmb->icon.size / 2.0, + node->x + xmb->margins.screen.left + xmb->hspacing + + xmb->icon.size / 2.0 + xmb->margins.setting.left, + xmb->margins.screen.top + node->y + xmb->icon.size / 2.0, node->alpha, 0, 1); if (!strcmp(type_str, "OFF") && xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id) xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id, - node->x + xmb->margin_left + xmb->hspacing - + xmb->icon.size / 2.0 + xmb->setting_margin_left, - xmb->margin_top + node->y + xmb->icon.size / 2.0, + node->x + xmb->margins.screen.left + xmb->hspacing + + xmb->icon.size / 2.0 + xmb->margins.setting.left, + xmb->margins.screen.top + node->y + xmb->icon.size / 2.0, node->alpha, 0, 1); @@ -1024,15 +1031,15 @@ static void xmb_frame(menu_handle_t *menu) xmb_render_background(gl, xmb, false); xmb_draw_text(gl, xmb, - xmb->title.name, xmb->title.margin.left, xmb->title.margin.top, 1, 1, 0); + xmb->title_name, xmb->margins.title.left, xmb->margins.title.top, 1, 1, 0); if (g_settings.menu.timedate_enable) { disp_timedate_set_label(timedate, sizeof(timedate), 0); xmb_draw_text(gl, xmb, - timedate, gl->win_width - xmb->title.margin.left - xmb->icon.size / 4, - xmb->title.margin.top, 1, 1, 1); + timedate, gl->win_width - xmb->margins.title.left - xmb->icon.size / 4, + xmb->margins.title.top, 1, 1, 1); xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_CLOCK].id, gl->win_width - xmb->icon.size, xmb->icon.size, 1, 0, 1); @@ -1056,13 +1063,13 @@ static void xmb_frame(menu_handle_t *menu) snprintf(title_msg, sizeof(title_msg), "%s - %s %s", PACKAGE_VERSION, core_name, core_version); - xmb_draw_text(gl, xmb, title_msg, xmb->title.margin.left, - gl->win_height - xmb->title.margin.bottom, 1, 1, 0); + xmb_draw_text(gl, xmb, title_msg, xmb->margins.title.left, + gl->win_height - xmb->margins.title.bottom, 1, 1, 0); } xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_ARROW].id, - xmb->x + xmb->margin_left + xmb->hspacing - xmb->icon.size / 2.0 + xmb->icon.size, - xmb->margin_top + xmb->icon.size / 2.0 + xmb->vspacing * xmb->item.active.factor, + xmb->x + xmb->margins.screen.left + xmb->hspacing - xmb->icon.size / 2.0 + xmb->icon.size, + xmb->margins.screen.top + xmb->icon.size / 2.0 + xmb->vspacing * xmb->item.active.factor, xmb->textures.arrow.alpha, 0, 1); depth = file_list_get_size(menu->menu_list->menu_stack); @@ -1086,8 +1093,8 @@ static void xmb_frame(menu_handle_t *menu) if (node) xmb_draw_icon(gl, xmb, node->icon, - xmb->x + xmb->categories.x_pos + xmb->margin_left + xmb->hspacing * (i + 1) - xmb->icon.size / 2.0, - xmb->margin_top + xmb->icon.size / 2.0, + xmb->x + xmb->categories.x_pos + xmb->margins.screen.left + xmb->hspacing * (i + 1) - xmb->icon.size / 2.0, + xmb->margins.screen.top + xmb->icon.size / 2.0, node->alpha, 0, node->zoom); @@ -1210,14 +1217,14 @@ static void *xmb_init(void) xmb->font.size = 32.0 * scale_factor; xmb->hspacing = 200.0 * scale_factor; xmb->vspacing = 64.0 * scale_factor; - xmb->margin_left = 336.0 * scale_factor; - xmb->margin_top = (256+32) * scale_factor; - xmb->title.margin.left = 60 * scale_factor; - xmb->title.margin.top = 60 * scale_factor + xmb->font.size/3; - xmb->title.margin.bottom = 60 * scale_factor - xmb->font.size/3; - xmb->label.margin.left = 85.0 * scale_factor; - xmb->label.margin.top = xmb->font.size/3.0; - xmb->setting_margin_left = 600.0 * scale_factor; + xmb->margins.screen.left = 336.0 * scale_factor; + xmb->margins.screen.top = (256+32) * scale_factor; + xmb->margins.title.left = 60 * scale_factor; + xmb->margins.title.top = 60 * scale_factor + xmb->font.size/3; + xmb->margins.title.bottom = 60 * scale_factor - xmb->font.size/3; + xmb->margins.label.left = 85.0 * scale_factor; + xmb->margins.label.top = xmb->font.size/3.0; + xmb->margins.setting.left = 600.0 * scale_factor; menu->categories.size = 1; From c7d5b82ccedb34bb2107c1e5d8fd44137a5aa72f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 20:26:04 +0100 Subject: [PATCH 117/147] (XMB) Refactor vspacing/hspacing --- menu/drivers/xmb.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 0be781ee9f..89294f4c4b 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -91,8 +91,6 @@ typedef struct xmb_handle char box_message[PATH_MAX_LENGTH]; float x; float alpha; - float hspacing; - float vspacing; struct { @@ -100,6 +98,12 @@ typedef struct xmb_handle { float left; float top; + + struct + { + float horizontal; + float vertical; + } spacing; } screen; struct @@ -213,7 +217,7 @@ static const GLfloat rmb_tex_coord[] = { static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current) { - float iy = xmb->vspacing; + float iy = xmb->margins.screen.spacing.vertical; if (i < current) if (xmb->depth > 1) @@ -224,7 +228,7 @@ static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current) iy *= (i - (int)current + xmb->under_offset.item); if (i == current) - iy = xmb->vspacing * xmb->item.active.factor; + iy = xmb->margins.screen.spacing.vertical * xmb->item.active.factor; return iy; } @@ -669,7 +673,7 @@ static void xmb_list_switch_old(menu_handle_t *menu, xmb_handle_t *xmb, file_lis if (!node) continue; - xmb_push_animations(menu, node, ia, -xmb->hspacing * dir); + xmb_push_animations(menu, node, ia, -xmb->margins.screen.spacing.horizontal * dir); } } @@ -687,7 +691,7 @@ static void xmb_list_switch_new(menu_handle_t *menu, xmb_handle_t *xmb, file_lis if (!node) continue; - node->x = xmb->hspacing * dir; + node->x = xmb->margins.screen.spacing.horizontal * dir; node->alpha = 0; node->label_alpha = 0; @@ -754,7 +758,7 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) } menu_animation_push(menu->animation, XMB_DELAY, - xmb->hspacing * -(float)menu->categories.selection_ptr, + xmb->margins.screen.spacing.horizontal * -(float)menu->categories.selection_ptr, &xmb->categories.x_pos, EASING_IN_OUT_QUAD, NULL); dir = -1; @@ -877,7 +881,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, if (!node) continue; - icon_x = node->x + xmb->margins.screen.left + xmb->hspacing - xmb->icon.size / 2.0; + icon_x = node->x + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal - xmb->icon.size / 2.0; icon_y = xmb->margins.screen.top + node->y + xmb->icon.size / 2.0; if ( @@ -963,7 +967,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, (i == current)); xmb_draw_text(gl, xmb, name, - node->x + xmb->margins.screen.left + xmb->hspacing + xmb->margins.label.left, + node->x + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal + xmb->margins.label.left, xmb->margins.screen.top + node->y + xmb->margins.label.top, 1, node->label_alpha, 0); @@ -984,7 +988,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, || (!strcmp(type_str, "OFF") && !xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id))) xmb_draw_text(gl, xmb, value, - node->x + xmb->margins.screen.left + xmb->hspacing + + node->x + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal + xmb->margins.label.left + xmb->margins.setting.left, xmb->margins.screen.top + node->y + xmb->margins.label.top, 1, @@ -993,7 +997,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, if (!strcmp(type_str, "ON") && xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id) xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id, - node->x + xmb->margins.screen.left + xmb->hspacing + node->x + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal + xmb->icon.size / 2.0 + xmb->margins.setting.left, xmb->margins.screen.top + node->y + xmb->icon.size / 2.0, node->alpha, @@ -1002,7 +1006,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, if (!strcmp(type_str, "OFF") && xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id) xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id, - node->x + xmb->margins.screen.left + xmb->hspacing + node->x + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal + xmb->icon.size / 2.0 + xmb->margins.setting.left, xmb->margins.screen.top + node->y + xmb->icon.size / 2.0, node->alpha, @@ -1068,8 +1072,8 @@ static void xmb_frame(menu_handle_t *menu) } xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_ARROW].id, - xmb->x + xmb->margins.screen.left + xmb->hspacing - xmb->icon.size / 2.0 + xmb->icon.size, - xmb->margins.screen.top + xmb->icon.size / 2.0 + xmb->vspacing * xmb->item.active.factor, + xmb->x + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal - xmb->icon.size / 2.0 + xmb->icon.size, + xmb->margins.screen.top + xmb->icon.size / 2.0 + xmb->margins.screen.spacing.vertical * xmb->item.active.factor, xmb->textures.arrow.alpha, 0, 1); depth = file_list_get_size(menu->menu_list->menu_stack); @@ -1093,7 +1097,7 @@ static void xmb_frame(menu_handle_t *menu) if (node) xmb_draw_icon(gl, xmb, node->icon, - xmb->x + xmb->categories.x_pos + xmb->margins.screen.left + xmb->hspacing * (i + 1) - xmb->icon.size / 2.0, + xmb->x + xmb->categories.x_pos + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal * (i + 1) - xmb->icon.size / 2.0, xmb->margins.screen.top + xmb->icon.size / 2.0, node->alpha, 0, @@ -1215,8 +1219,8 @@ static void *xmb_init(void) xmb->icon.size = 128.0 * scale_factor; xmb->font.size = 32.0 * scale_factor; - xmb->hspacing = 200.0 * scale_factor; - xmb->vspacing = 64.0 * scale_factor; + xmb->margins.screen.spacing.horizontal = 200.0 * scale_factor; + xmb->margins.screen.spacing.vertical = 64.0 * scale_factor; xmb->margins.screen.left = 336.0 * scale_factor; xmb->margins.screen.top = (256+32) * scale_factor; xmb->margins.title.left = 60 * scale_factor; From 7daf9fae038af952f3d742098315ebf95ea48744 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 21:58:35 +0100 Subject: [PATCH 118/147] Fix crash on startup with threaded video --- gfx/drivers/gl.c | 21 --------------------- gfx/gl_common.c | 2 +- gfx/gl_common.h | 21 +++++++++++++++++++++ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 5e69b6f1f5..e11210534a 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -319,27 +319,6 @@ static inline GLenum min_filter_to_mag(GLenum type) } } -static unsigned gl_wrap_type_to_enum(enum gfx_wrap_type type) -{ - switch (type) - { -#ifndef HAVE_OPENGLES - case RARCH_WRAP_BORDER: - return GL_CLAMP_TO_BORDER; -#else - case RARCH_WRAP_BORDER: -#endif - case RARCH_WRAP_EDGE: - return GL_CLAMP_TO_EDGE; - case RARCH_WRAP_REPEAT: - return GL_REPEAT; - case RARCH_WRAP_MIRRORED_REPEAT: - return GL_MIRRORED_REPEAT; - } - - return 0; -} - #ifdef HAVE_FBO static void gl_shader_scale(gl_t *gl, unsigned idx, struct gfx_fbo_scale *scale) diff --git a/gfx/gl_common.c b/gfx/gl_common.c index 8da3d7c2d4..9323d39ebe 100644 --- a/gfx/gl_common.c +++ b/gfx/gl_common.c @@ -33,7 +33,7 @@ void gl_load_texture_data(GLuint id, glBindTexture(GL_TEXTURE_2D, id); - wrap = driver.video->wrap_type_to_enum(wrap_type); + wrap = gl_wrap_type_to_enum(wrap_type); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); diff --git a/gfx/gl_common.h b/gfx/gl_common.h index 8480aa3659..221c291f7c 100644 --- a/gfx/gl_common.h +++ b/gfx/gl_common.h @@ -414,4 +414,25 @@ void gl_load_texture_data(GLuint id, bool gl_load_luts(const struct video_shader *generic_shader, GLuint *lut_textures); +static INLINE unsigned gl_wrap_type_to_enum(enum gfx_wrap_type type) +{ + switch (type) + { +#ifndef HAVE_OPENGLES + case RARCH_WRAP_BORDER: + return GL_CLAMP_TO_BORDER; +#else + case RARCH_WRAP_BORDER: +#endif + case RARCH_WRAP_EDGE: + return GL_CLAMP_TO_EDGE; + case RARCH_WRAP_REPEAT: + return GL_REPEAT; + case RARCH_WRAP_MIRRORED_REPEAT: + return GL_MIRRORED_REPEAT; + } + + return 0; +} + #endif From 025cb112d322f37bda8591d62c8584792d1d995f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 23:38:44 +0100 Subject: [PATCH 119/147] Move spacing to 'icon' --- menu/drivers/xmb.c | 105 +++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 89294f4c4b..19f1d0b10e 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -99,11 +99,6 @@ typedef struct xmb_handle float left; float top; - struct - { - float horizontal; - float vertical; - } spacing; } screen; struct @@ -150,6 +145,12 @@ typedef struct xmb_handle struct { + struct + { + float horizontal; + float vertical; + } spacing; + char dir[4]; int size; } icon; @@ -217,7 +218,7 @@ static const GLfloat rmb_tex_coord[] = { static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current) { - float iy = xmb->margins.screen.spacing.vertical; + float iy = xmb->icon.spacing.vertical; if (i < current) if (xmb->depth > 1) @@ -228,7 +229,7 @@ static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current) iy *= (i - (int)current + xmb->under_offset.item); if (i == current) - iy = xmb->margins.screen.spacing.vertical * xmb->item.active.factor; + iy = xmb->icon.spacing.vertical * xmb->item.active.factor; return iy; } @@ -673,7 +674,7 @@ static void xmb_list_switch_old(menu_handle_t *menu, xmb_handle_t *xmb, file_lis if (!node) continue; - xmb_push_animations(menu, node, ia, -xmb->margins.screen.spacing.horizontal * dir); + xmb_push_animations(menu, node, ia, -xmb->icon.spacing.horizontal * dir); } } @@ -691,7 +692,7 @@ static void xmb_list_switch_new(menu_handle_t *menu, xmb_handle_t *xmb, file_lis if (!node) continue; - node->x = xmb->margins.screen.spacing.horizontal * dir; + node->x = xmb->icon.spacing.horizontal * dir; node->alpha = 0; node->label_alpha = 0; @@ -758,7 +759,7 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) } menu_animation_push(menu->animation, XMB_DELAY, - xmb->margins.screen.spacing.horizontal * -(float)menu->categories.selection_ptr, + xmb->icon.spacing.horizontal * -(float)menu->categories.selection_ptr, &xmb->categories.x_pos, EASING_IN_OUT_QUAD, NULL); dir = -1; @@ -881,7 +882,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, if (!node) continue; - icon_x = node->x + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal - xmb->icon.size / 2.0; + icon_x = node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal - xmb->icon.size / 2.0; icon_y = xmb->margins.screen.top + node->y + xmb->icon.size / 2.0; if ( @@ -967,7 +968,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, (i == current)); xmb_draw_text(gl, xmb, name, - node->x + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal + xmb->margins.label.left, + node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal + xmb->margins.label.left, xmb->margins.screen.top + node->y + xmb->margins.label.top, 1, node->label_alpha, 0); @@ -988,7 +989,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, || (!strcmp(type_str, "OFF") && !xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id))) xmb_draw_text(gl, xmb, value, - node->x + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal + + node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal + xmb->margins.label.left + xmb->margins.setting.left, xmb->margins.screen.top + node->y + xmb->margins.label.top, 1, @@ -997,7 +998,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, if (!strcmp(type_str, "ON") && xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id) xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_SWITCH_ON].id, - node->x + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal + node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal + xmb->icon.size / 2.0 + xmb->margins.setting.left, xmb->margins.screen.top + node->y + xmb->icon.size / 2.0, node->alpha, @@ -1006,7 +1007,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, if (!strcmp(type_str, "OFF") && xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id) xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_SWITCH_OFF].id, - node->x + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal + node->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal + xmb->icon.size / 2.0 + xmb->margins.setting.left, xmb->margins.screen.top + node->y + xmb->icon.size / 2.0, node->alpha, @@ -1072,8 +1073,8 @@ static void xmb_frame(menu_handle_t *menu) } xmb_draw_icon(gl, xmb, xmb->textures.list[XMB_TEXTURE_ARROW].id, - xmb->x + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal - xmb->icon.size / 2.0 + xmb->icon.size, - xmb->margins.screen.top + xmb->icon.size / 2.0 + xmb->margins.screen.spacing.vertical * xmb->item.active.factor, + xmb->x + xmb->margins.screen.left + xmb->icon.spacing.horizontal - xmb->icon.size / 2.0 + xmb->icon.size, + xmb->margins.screen.top + xmb->icon.size / 2.0 + xmb->icon.spacing.vertical * xmb->item.active.factor, xmb->textures.arrow.alpha, 0, 1); depth = file_list_get_size(menu->menu_list->menu_stack); @@ -1097,7 +1098,7 @@ static void xmb_frame(menu_handle_t *menu) if (node) xmb_draw_icon(gl, xmb, node->icon, - xmb->x + xmb->categories.x_pos + xmb->margins.screen.left + xmb->margins.screen.spacing.horizontal * (i + 1) - xmb->icon.size / 2.0, + xmb->x + xmb->categories.x_pos + xmb->margins.screen.left + xmb->icon.spacing.horizontal * (i + 1) - xmb->icon.size / 2.0, xmb->margins.screen.top + xmb->icon.size / 2.0, node->alpha, 0, @@ -1177,58 +1178,58 @@ static void *xmb_init(void) if (!xmb->selection_buf_old) goto error; - xmb->categories.active.idx = 0; + xmb->categories.active.idx = 0; xmb->categories.active.idx_old = 0; - xmb->x = 0; - xmb->categories.x_pos = 0; - xmb->textures.arrow.alpha = 0; - xmb->depth = 1; - xmb->old_depth = 1; - xmb->alpha = 0; - xmb->prevent_populate = false; + xmb->x = 0; + xmb->categories.x_pos = 0; + xmb->textures.arrow.alpha = 0; + xmb->depth = 1; + xmb->old_depth = 1; + xmb->alpha = 0; + xmb->prevent_populate = false; xmb->categories.active.zoom = 1.0; xmb->categories.passive.zoom = 0.5; - xmb->item.active.zoom = 1.0; - xmb->item.passive.zoom = 0.5; + xmb->item.active.zoom = 1.0; + xmb->item.passive.zoom = 0.5; xmb->categories.active.alpha = 1.0; xmb->categories.passive.alpha= 0.5; - xmb->item.active.alpha = 1.0; - xmb->item.passive.alpha = 0.5; + xmb->item.active.alpha = 1.0; + xmb->item.passive.alpha = 0.5; - xmb->above_offset.subitem = 1.5; - xmb->above_offset.item = -1.0; - xmb->item.active.factor = 3.0; - xmb->under_offset.item = 5.0; + xmb->above_offset.subitem = 1.5; + xmb->above_offset.item = -1.0; + xmb->item.active.factor = 3.0; + xmb->under_offset.item = 5.0; if (gl->win_width >= 3840) - scale_factor = 2.0; + scale_factor = 2.0; else if (gl->win_width >= 2560) - scale_factor = 1.5; + scale_factor = 1.5; else if (gl->win_width >= 1920) - scale_factor = 1.0; + scale_factor = 1.0; else if (gl->win_width >= 1280) - scale_factor = 0.75; + scale_factor = 0.75; else if (gl->win_width >= 640) - scale_factor = 0.5; + scale_factor = 0.5; else if (gl->win_width >= 320) - scale_factor = 0.25; + scale_factor = 0.25; strlcpy(xmb->icon.dir, "256", sizeof(xmb->icon.dir)); - xmb->icon.size = 128.0 * scale_factor; - xmb->font.size = 32.0 * scale_factor; - xmb->margins.screen.spacing.horizontal = 200.0 * scale_factor; - xmb->margins.screen.spacing.vertical = 64.0 * scale_factor; - xmb->margins.screen.left = 336.0 * scale_factor; - xmb->margins.screen.top = (256+32) * scale_factor; - xmb->margins.title.left = 60 * scale_factor; - xmb->margins.title.top = 60 * scale_factor + xmb->font.size/3; - xmb->margins.title.bottom = 60 * scale_factor - xmb->font.size/3; - xmb->margins.label.left = 85.0 * scale_factor; - xmb->margins.label.top = xmb->font.size/3.0; - xmb->margins.setting.left = 600.0 * scale_factor; + xmb->icon.size = 128.0 * scale_factor; + xmb->font.size = 32.0 * scale_factor; + xmb->icon.spacing.horizontal = 200.0 * scale_factor; + xmb->icon.spacing.vertical = 64.0 * scale_factor; + xmb->margins.screen.left = 336.0 * scale_factor; + xmb->margins.screen.top = (256+32) * scale_factor; + xmb->margins.title.left = 60 * scale_factor; + xmb->margins.title.top = 60 * scale_factor + xmb->font.size/3; + xmb->margins.title.bottom = 60 * scale_factor - xmb->font.size/3; + xmb->margins.label.left = 85.0 * scale_factor; + xmb->margins.label.top = xmb->font.size/3.0; + xmb->margins.setting.left = 600.0 * scale_factor; menu->categories.size = 1; From 8bac249bb81f74ec18358b99b7d0b0ce4e77238d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 Feb 2015 23:43:34 +0100 Subject: [PATCH 120/147] gl_load_texture_data - take out early return --- gfx/gl_common.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/gfx/gl_common.c b/gfx/gl_common.c index 9323d39ebe..0991dc8fd2 100644 --- a/gfx/gl_common.c +++ b/gfx/gl_common.c @@ -28,9 +28,6 @@ void gl_load_texture_data(GLuint id, bool want_mipmap = false; bool rgb32 = (base_size == (sizeof(uint32_t))); - if (!driver.video) - return; - glBindTexture(GL_TEXTURE_2D, id); wrap = gl_wrap_type_to_enum(wrap_type); From e58c1491a2c91afbfc5ab09bc1799aad37602fdb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 00:12:15 +0100 Subject: [PATCH 121/147] Selecting wallpaper now directly changes background image - implemented only for XMB so far, GLUI coming up next --- menu/drivers/glui.c | 1 + menu/drivers/ios.c | 1 + menu/drivers/rgui.c | 1 + menu/drivers/rmenu.c | 1 + menu/drivers/rmenu_xui.cpp | 1 + menu/drivers/xmb.c | 44 +++++++++++++++++++++++++++++++------- menu/menu_driver.h | 1 + menu/menu_entries_cbs.c | 8 +++++++ 8 files changed, 50 insertions(+), 8 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index d91b5ab629..310a1dd28d 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -564,5 +564,6 @@ menu_ctx_driver_t menu_ctx_glui = { NULL, NULL, glui_entry_iterate, + NULL, "glui", }; diff --git a/menu/drivers/ios.c b/menu/drivers/ios.c index 4f15356e21..29a14202c4 100644 --- a/menu/drivers/ios.c +++ b/menu/drivers/ios.c @@ -90,5 +90,6 @@ menu_ctx_driver_t menu_ctx_ios = { NULL, // list_cache NULL, // list_set_selection ios_entry_iterate, + NULL, "ios", }; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 4dce438936..31a95819f7 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -597,5 +597,6 @@ menu_ctx_driver_t menu_ctx_rgui = { NULL, NULL, rgui_entry_iterate, + NULL, "rgui", }; diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index 17cae8b30f..ee27258954 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -385,5 +385,6 @@ menu_ctx_driver_t menu_ctx_rmenu = { NULL, NULL, rmenu_entry_iterate, + NULL, "rmenu", }; diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index 1e368e086d..e71129ca29 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -700,5 +700,6 @@ menu_ctx_driver_t menu_ctx_rmenu_xui = { NULL, rmenu_xui_list_set_selection, rmenu_xui_entry_iterate, + NULL, "rmenu_xui", }; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 19f1d0b10e..bb7b61d4f9 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -52,8 +52,7 @@ typedef struct enum { - XMB_TEXTURE_BG = 0, - XMB_TEXTURE_SETTINGS, + XMB_TEXTURE_SETTINGS = 0, XMB_TEXTURE_SETTING, XMB_TEXTURE_SUBSETTING, XMB_TEXTURE_ARROW, @@ -129,6 +128,7 @@ typedef struct xmb_handle float alpha; } arrow; + struct xmb_texture_item bg; struct xmb_texture_item list[XMB_TEXTURE_LAST]; } textures; @@ -426,10 +426,10 @@ static void xmb_render_background(gl_t *gl, xmb_handle_t *xmb, if ((g_settings.menu.pause_libretro || !g_extern.main_is_init || g_extern.libretro_dummy) && !force_transparency - && xmb->textures.list[XMB_TEXTURE_BG].id) + && xmb->textures.bg.id) { coords.color = color; - glBindTexture(GL_TEXTURE_2D, xmb->textures.list[XMB_TEXTURE_BG].id); + glBindTexture(GL_TEXTURE_2D, xmb->textures.bg.id); } else { @@ -1284,6 +1284,31 @@ static bool xmb_font_init_first(const gl_font_renderer_t **font_driver, font_path, xmb_font_size); } +static bool xmb_load_background(menu_handle_t *menu, const char *path) +{ + xmb_handle_t *xmb = NULL; + + if (!menu) + return false; + + xmb = (xmb_handle_t*)menu->userdata; + + if (!xmb) + return false; + if (!path) + return false; + + if (xmb->textures.bg.id) + glDeleteTextures(1, &xmb->textures.bg.id); + + strlcpy(xmb->textures.bg.path, path, sizeof(xmb->textures.bg.path)); + + xmb->textures.bg.id = menu_texture_load(xmb->textures.bg.path, + TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); + + return true; +} + static void xmb_context_reset(menu_handle_t *menu) { int i, k; @@ -1325,11 +1350,11 @@ static void xmb_context_reset(menu_handle_t *menu) xmb_font_init_first(&gl->font_driver, &xmb->font.buf, gl, fontpath, xmb->font.size); if (*g_settings.menu.wallpaper) - strlcpy(xmb->textures.list[XMB_TEXTURE_BG].path, g_settings.menu.wallpaper, - sizeof(xmb->textures.list[XMB_TEXTURE_BG].path)); + strlcpy(xmb->textures.bg.path, g_settings.menu.wallpaper, + sizeof(xmb->textures.bg.path)); else - fill_pathname_join(xmb->textures.list[XMB_TEXTURE_BG].path, iconpath, - "bg.png", sizeof(xmb->textures.list[XMB_TEXTURE_BG].path)); + fill_pathname_join(xmb->textures.bg.path, iconpath, + "bg.png", sizeof(xmb->textures.bg.path)); fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SETTINGS].path, iconpath, "settings.png", sizeof(xmb->textures.list[XMB_TEXTURE_SETTINGS].path)); fill_pathname_join(xmb->textures.list[XMB_TEXTURE_SETTING].path, iconpath, @@ -1373,6 +1398,8 @@ static void xmb_context_reset(menu_handle_t *menu) xmb->textures.list[k].id = menu_texture_load(xmb->textures.list[k].path, TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); + xmb_load_background(driver.menu, xmb->textures.bg.path); + xmb->settings_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS].id; xmb->settings_node.alpha = xmb->categories.active.alpha; xmb->settings_node.zoom = xmb->categories.active.zoom; @@ -1665,5 +1692,6 @@ menu_ctx_driver_t menu_ctx_xmb = { xmb_list_cache, NULL, xmb_entry_iterate, + xmb_load_background, "xmb", }; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 68a48d45c4..e453b43a24 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -219,6 +219,7 @@ typedef struct menu_ctx_driver void (*list_cache)(menu_handle_t *menu, bool, unsigned); void (*list_set_selection)(file_list_t *list); int (*entry_iterate)(menu_handle_t *menu, unsigned); + bool (*load_background)(menu_handle_t *menu, const char * path); const char *ident; } menu_ctx_driver_t; diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index a6ef8def37..eb32305389 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -540,7 +540,15 @@ static int action_ok_menu_wallpaper_load(const char *path, fill_pathname_join(wallpaper_path, menu_path, path, sizeof(wallpaper_path)); + if (!path_file_exists(wallpaper_path)) + goto end; + strlcpy(g_settings.menu.wallpaper, wallpaper_path, sizeof(g_settings.menu.wallpaper)); + + if (driver.menu_ctx && driver.menu_ctx->load_background) + driver.menu_ctx->load_background(driver.menu, wallpaper_path); + +end: menu_list_pop_stack_by_needle(driver.menu->menu_list, setting->name); return 0; From f3315c256e6a4dd2945011c45ad86d41713f6ce8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 00:20:39 +0100 Subject: [PATCH 122/147] (GLUI) Hookup load_wallpaper - and also free background image at exit --- menu/drivers/glui.c | 81 ++++++++++++++++++++++++++++++++++++--------- menu/drivers/xmb.c | 6 ++-- 2 files changed, 68 insertions(+), 19 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 310a1dd28d..5e365cd347 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -38,7 +38,14 @@ typedef struct glui_handle unsigned term_width; unsigned term_height; char box_message[PATH_MAX_LENGTH]; - GLuint bg; + struct + { + struct + { + GLuint id; + char path[PATH_MAX_LENGTH]; + } bg; + } textures; } glui_handle_t; static int glui_entry_iterate(menu_handle_t *menu, unsigned action) @@ -124,10 +131,10 @@ static void glui_render_background(gl_t *gl, glui_handle_t *glui, if ((g_settings.menu.pause_libretro || !g_extern.main_is_init || g_extern.libretro_dummy) && !force_transparency - && glui->bg) + && glui->textures.bg.id) { coords.color = color; - glBindTexture(GL_TEXTURE_2D, glui->bg); + glBindTexture(GL_TEXTURE_2D, glui->textures.bg.id); } else { @@ -445,7 +452,7 @@ static void *glui_init(void) goto error; glui = (glui_handle_t*)menu->userdata; - glui->bg = 0; + glui->textures.bg.id = 0; return menu; error: @@ -466,9 +473,9 @@ static void glui_free(void *data) } -static void glui_context_reset(menu_handle_t *menu) + +static void glui_context_destroy(menu_handle_t *menu) { - char bgpath[PATH_MAX_LENGTH]; glui_handle_t *glui = NULL; if (!menu) @@ -479,18 +486,60 @@ static void glui_context_reset(menu_handle_t *menu) if (!glui) return; - fill_pathname_join(bgpath, g_settings.assets_directory, - "glui", sizeof(bgpath)); + if (glui->textures.bg.id) + glDeleteTextures(1, &glui->textures.bg.id); +} + +static bool glui_load_wallpaper(menu_handle_t *menu, const char *path) +{ + glui_handle_t *glui = NULL; + + if (!menu) + return false; + + glui = (glui_handle_t*)menu->userdata; + + if (!glui) + return false; + if (!path) + return false; + + if (glui->textures.bg.id) + glDeleteTextures(1, &glui->textures.bg.id); + + strlcpy(glui->textures.bg.path, path, sizeof(glui->textures.bg.path)); + + glui->textures.bg.id = menu_texture_load(glui->textures.bg.path, + TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); + + return true; +} + +static void glui_context_reset(menu_handle_t *menu) +{ + glui_handle_t *glui = NULL; + + if (!menu) + return; + + glui = (glui_handle_t*)menu->userdata; + + if (!glui) + return; + + fill_pathname_join(glui->textures.bg.path, g_settings.assets_directory, + "glui", sizeof(glui->textures.bg.path)); if (*g_settings.menu.wallpaper) - strlcpy(bgpath, g_settings.menu.wallpaper, sizeof(bgpath)); + strlcpy(glui->textures.bg.path, + g_settings.menu.wallpaper, sizeof(glui->textures.bg.path)); else - fill_pathname_join(bgpath, bgpath, "bg.png", sizeof(bgpath)); + fill_pathname_join(glui->textures.bg.path, + glui->textures.bg.path, "bg.png", + sizeof(glui->textures.bg.path)); - if (path_file_exists(bgpath)) - glui->bg = (GLuint)menu_texture_load(bgpath, - TEXTURE_BACKEND_OPENGL, - TEXTURE_FILTER_LINEAR); + if (path_file_exists(glui->textures.bg.path)) + glui_load_wallpaper(driver.menu, glui->textures.bg.path); } static void glui_navigation_clear(menu_handle_t *menu, bool pending_push) @@ -548,7 +597,7 @@ menu_ctx_driver_t menu_ctx_glui = { glui_init, glui_free, glui_context_reset, - NULL, + glui_context_destroy, NULL, NULL, glui_navigation_clear, @@ -564,6 +613,6 @@ menu_ctx_driver_t menu_ctx_glui = { NULL, NULL, glui_entry_iterate, - NULL, + glui_load_wallpaper, "glui", }; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index bb7b61d4f9..1cc8bf7d59 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1284,7 +1284,7 @@ static bool xmb_font_init_first(const gl_font_renderer_t **font_driver, font_path, xmb_font_size); } -static bool xmb_load_background(menu_handle_t *menu, const char *path) +static bool xmb_load_wallpaper(menu_handle_t *menu, const char *path) { xmb_handle_t *xmb = NULL; @@ -1398,7 +1398,7 @@ static void xmb_context_reset(menu_handle_t *menu) xmb->textures.list[k].id = menu_texture_load(xmb->textures.list[k].path, TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); - xmb_load_background(driver.menu, xmb->textures.bg.path); + xmb_load_wallpaper(driver.menu, xmb->textures.bg.path); xmb->settings_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS].id; xmb->settings_node.alpha = xmb->categories.active.alpha; @@ -1692,6 +1692,6 @@ menu_ctx_driver_t menu_ctx_xmb = { xmb_list_cache, NULL, xmb_entry_iterate, - xmb_load_background, + xmb_load_wallpaper, "xmb", }; From 748556dd576dfc6c2df2de27c9ff9097f2a4957b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 01:50:44 +0100 Subject: [PATCH 123/147] (gl_common.c) Cleanups --- gfx/gl_common.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/gfx/gl_common.c b/gfx/gl_common.c index 0991dc8fd2..888fb3d322 100644 --- a/gfx/gl_common.c +++ b/gfx/gl_common.c @@ -79,18 +79,15 @@ void gl_load_texture_data(GLuint id, glGenerateMipmap(GL_TEXTURE_2D); } -bool gl_load_luts(const struct video_shader *generic_shader, +bool gl_load_luts(const struct video_shader *shader, GLuint *textures_lut) { unsigned i; - unsigned num_luts = min(generic_shader->luts, GFX_MAX_TEXTURES); + unsigned num_luts = min(shader->luts, GFX_MAX_TEXTURES); - if (!generic_shader->luts) + if (!shader->luts) return true; - /* Original shader_glsl.c code only generated one - * texture handle. I assume it was a bug, but if not, - * replace num_luts with 1 when GLSL is used. */ glGenTextures(num_luts, textures_lut); for (i = 0; i < num_luts; i++) @@ -99,19 +96,19 @@ bool gl_load_luts(const struct video_shader *generic_shader, enum texture_filter_type filter_type = TEXTURE_FILTER_LINEAR; RARCH_LOG("Loading texture image from: \"%s\" ...\n", - generic_shader->lut[i].path); + shader->lut[i].path); - if (!texture_image_load(&img, generic_shader->lut[i].path)) + if (!texture_image_load(&img, shader->lut[i].path)) { RARCH_ERR("Failed to load texture image from: \"%s\"\n", - generic_shader->lut[i].path); + shader->lut[i].path); return false; } - if (generic_shader->lut[i].filter == RARCH_FILTER_NEAREST) + if (shader->lut[i].filter == RARCH_FILTER_NEAREST) filter_type = TEXTURE_FILTER_NEAREST; - if (generic_shader->lut[i].mipmap) + if (shader->lut[i].mipmap) { if (filter_type == TEXTURE_FILTER_NEAREST) filter_type = TEXTURE_FILTER_MIPMAP_NEAREST; @@ -120,7 +117,7 @@ bool gl_load_luts(const struct video_shader *generic_shader, } gl_load_texture_data(textures_lut[i], - generic_shader->lut[i].wrap, + shader->lut[i].wrap, filter_type, 4, img.width, img.height, img.pixels, sizeof(uint32_t)); From fafd472b2f833593807b49e5b245477ff3970ccd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 02:02:03 +0100 Subject: [PATCH 124/147] (GL) Refactor gl_check_fbo_dimensions --- gfx/drivers/gl.c | 65 ++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index e11210534a..ca018d78fb 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -891,39 +891,50 @@ static void gl_check_fbo_dimensions(gl_t *gl) /* Check if we have to recreate our FBO textures. */ for (i = 0; i < gl->fbo_pass; i++) { - if (gl->fbo_rect[i].max_img_width > gl->fbo_rect[i].width || - gl->fbo_rect[i].max_img_height > gl->fbo_rect[i].height) - { - /* Check proactively since we might suddently - * get sizes of tex_w width or tex_h height. */ - unsigned img_width = gl->fbo_rect[i].max_img_width; - unsigned img_height = gl->fbo_rect[i].max_img_height; - unsigned max = img_width > img_height ? img_width : img_height; - unsigned pow2_size = next_pow2(max); + GLenum status; + unsigned img_width, img_height, max, pow2_size; + bool check_dimensions = false; + struct gl_fbo_rect *fbo_rect = &gl->fbo_rect[i]; - gl->fbo_rect[i].width = gl->fbo_rect[i].height = pow2_size; + if (!fbo_rect) + continue; - glBindFramebuffer(RARCH_GL_FRAMEBUFFER, gl->fbo[i]); - glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i]); + check_dimensions = + (fbo_rect->max_img_width > fbo_rect->width) || + (fbo_rect->max_img_height > fbo_rect->height); - glTexImage2D(GL_TEXTURE_2D, - 0, RARCH_GL_INTERNAL_FORMAT32, - gl->fbo_rect[i].width, - gl->fbo_rect[i].height, - 0, RARCH_GL_TEXTURE_TYPE32, - RARCH_GL_FORMAT32, NULL); + if (!check_dimensions) + continue; - glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, - RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, - gl->fbo_texture[i], 0); + /* Check proactively since we might suddently + * get sizes of tex_w width or tex_h height. */ + img_width = fbo_rect->max_img_width; + img_height = fbo_rect->max_img_height; + max = img_width > img_height ? img_width : img_height; + pow2_size = next_pow2(max); - GLenum status = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER); - if (status != RARCH_GL_FRAMEBUFFER_COMPLETE) - RARCH_WARN("Failed to reinitialize FBO texture.\n"); + fbo_rect->width = fbo_rect->height = pow2_size; - RARCH_LOG("[GL]: Recreating FBO texture #%d: %ux%u\n", - i, gl->fbo_rect[i].width, gl->fbo_rect[i].height); - } + glBindFramebuffer(RARCH_GL_FRAMEBUFFER, gl->fbo[i]); + glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i]); + + glTexImage2D(GL_TEXTURE_2D, + 0, RARCH_GL_INTERNAL_FORMAT32, + fbo_rect->width, + fbo_rect->height, + 0, RARCH_GL_TEXTURE_TYPE32, + RARCH_GL_FORMAT32, NULL); + + glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, + RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + gl->fbo_texture[i], 0); + + status = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER); + if (status != RARCH_GL_FRAMEBUFFER_COMPLETE) + RARCH_WARN("Failed to reinitialize FBO texture.\n"); + + RARCH_LOG("[GL]: Recreating FBO texture #%d: %ux%u\n", + i, fbo_rect->width, fbo_rect->height); } } From 948847edc148cda6cb3a7318a3e3bec739c8d48e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 02:21:54 +0100 Subject: [PATCH 125/147] (GL) Style nits --- gfx/drivers/gl.c | 238 ++++++++++++++++++++++++++--------------------- 1 file changed, 133 insertions(+), 105 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index ca018d78fb..9aa51de3af 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -347,69 +347,72 @@ static void gl_compute_fbo_geometry(gl_t *gl, unsigned width, unsigned height, /* Calculate viewports for FBOs. */ for (i = 0; i < gl->fbo_pass; i++) { + struct gl_fbo_rect *fbo_rect = &gl->fbo_rect[i]; + struct gfx_fbo_scale *fbo_scale = &gl->fbo_scale[i]; + switch (gl->fbo_scale[i].type_x) { case RARCH_SCALE_INPUT: - gl->fbo_rect[i].img_width = last_width * gl->fbo_scale[i].scale_x; - gl->fbo_rect[i].max_img_width = last_max_width * gl->fbo_scale[i].scale_x; + fbo_rect->img_width = last_width * fbo_scale->scale_x; + fbo_rect->max_img_width = last_max_width * fbo_scale->scale_x; break; case RARCH_SCALE_ABSOLUTE: - gl->fbo_rect[i].img_width = gl->fbo_rect[i].max_img_width = gl->fbo_scale[i].abs_x; + fbo_rect->img_width = fbo_rect->max_img_width = fbo_scale->abs_x; break; case RARCH_SCALE_VIEWPORT: - gl->fbo_rect[i].img_width = gl->fbo_rect[i].max_img_width = gl->fbo_scale[i].scale_x * vp_width; + fbo_rect->img_width = fbo_rect->max_img_width = fbo_scale->scale_x * vp_width; break; } - switch (gl->fbo_scale[i].type_y) + switch (fbo_scale->type_y) { case RARCH_SCALE_INPUT: - gl->fbo_rect[i].img_height = last_height * gl->fbo_scale[i].scale_y; - gl->fbo_rect[i].max_img_height = last_max_height * gl->fbo_scale[i].scale_y; + fbo_rect->img_height = last_height * fbo_scale->scale_y; + fbo_rect->max_img_height = last_max_height * fbo_scale->scale_y; break; case RARCH_SCALE_ABSOLUTE: - gl->fbo_rect[i].img_height = gl->fbo_rect[i].max_img_height = gl->fbo_scale[i].abs_y; + fbo_rect->img_height = fbo_rect->max_img_height = fbo_scale->abs_y; break; case RARCH_SCALE_VIEWPORT: - gl->fbo_rect[i].img_height = gl->fbo_rect[i].max_img_height = gl->fbo_scale[i].scale_y * vp_height; + fbo_rect->img_height = fbo_rect->max_img_height = fbo_scale->scale_y * vp_height; break; } - if (gl->fbo_rect[i].img_width > (unsigned)max_size) + if (fbo_rect->img_width > (unsigned)max_size) { size_modified = true; - gl->fbo_rect[i].img_width = max_size; + fbo_rect->img_width = max_size; } - if (gl->fbo_rect[i].img_height > (unsigned)max_size) + if (fbo_rect->img_height > (unsigned)max_size) { size_modified = true; - gl->fbo_rect[i].img_height = max_size; + fbo_rect->img_height = max_size; } - if (gl->fbo_rect[i].max_img_width > (unsigned)max_size) + if (fbo_rect->max_img_width > (unsigned)max_size) { size_modified = true; - gl->fbo_rect[i].max_img_width = max_size; + fbo_rect->max_img_width = max_size; } - if (gl->fbo_rect[i].max_img_height > (unsigned)max_size) + if (fbo_rect->max_img_height > (unsigned)max_size) { size_modified = true; - gl->fbo_rect[i].max_img_height = max_size; + fbo_rect->max_img_height = max_size; } if (size_modified) RARCH_WARN("FBO textures exceeded maximum size of GPU (%ux%u). Resizing to fit.\n", max_size, max_size); - last_width = gl->fbo_rect[i].img_width; - last_height = gl->fbo_rect[i].img_height; - last_max_width = gl->fbo_rect[i].max_img_width; - last_max_height = gl->fbo_rect[i].max_img_height; + last_width = fbo_rect->img_width; + last_height = fbo_rect->img_height; + last_max_width = fbo_rect->max_img_width; + last_max_height = fbo_rect->max_img_height; } } @@ -446,7 +449,7 @@ static void gl_create_fbo_textures(gl_t *gl) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_enum); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_enum); - bool fp_fbo = gl->fbo_scale[i].fp_fbo; + bool fp_fbo = gl->fbo_scale[i].fp_fbo; bool srgb_fbo = gl->fbo_scale[i].srgb_fbo; if (fp_fbo) @@ -966,11 +969,11 @@ static void gl_frame_fbo(gl_t *gl, set_texture_coords(fbo_tex_coords, xamt, yamt); - fbo_info->tex = gl->fbo_texture[i - 1]; + fbo_info->tex = gl->fbo_texture[i - 1]; fbo_info->input_size[0] = prev_rect->img_width; fbo_info->input_size[1] = prev_rect->img_height; - fbo_info->tex_size[0] = prev_rect->width; - fbo_info->tex_size[1] = prev_rect->height; + fbo_info->tex_size[0] = prev_rect->width; + fbo_info->tex_size[1] = prev_rect->height; memcpy(fbo_info->coord, fbo_tex_coords, sizeof(fbo_tex_coords)); fbo_tex_info_cnt++; @@ -1004,18 +1007,19 @@ static void gl_frame_fbo(gl_t *gl, /* Render our last FBO texture directly to screen. */ prev_rect = &gl->fbo_rect[gl->fbo_pass - 1]; - xamt = (GLfloat)prev_rect->img_width / prev_rect->width; - yamt = (GLfloat)prev_rect->img_height / prev_rect->height; + xamt = (GLfloat)prev_rect->img_width / prev_rect->width; + yamt = (GLfloat)prev_rect->img_height / prev_rect->height; set_texture_coords(fbo_tex_coords, xamt, yamt); /* Push final FBO to list. */ fbo_info = &fbo_tex_info[gl->fbo_pass - 1]; - fbo_info->tex = gl->fbo_texture[gl->fbo_pass - 1]; + + fbo_info->tex = gl->fbo_texture[gl->fbo_pass - 1]; fbo_info->input_size[0] = prev_rect->img_width; fbo_info->input_size[1] = prev_rect->img_height; - fbo_info->tex_size[0] = prev_rect->width; - fbo_info->tex_size[1] = prev_rect->height; + fbo_info->tex_size[0] = prev_rect->width; + fbo_info->tex_size[1] = prev_rect->height; memcpy(fbo_info->coord, fbo_tex_coords, sizeof(fbo_tex_coords)); fbo_tex_info_cnt++; @@ -1031,7 +1035,8 @@ static void gl_frame_fbo(gl_t *gl, glClear(GL_COLOR_BUFFER_BIT); gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); - gl->shader->set_params(gl, prev_rect->img_width, prev_rect->img_height, + gl->shader->set_params(gl, + prev_rect->img_width, prev_rect->img_height, prev_rect->width, prev_rect->height, gl->vp.width, gl->vp.height, g_extern.frame_count, tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt); @@ -1050,6 +1055,7 @@ static void gl_frame_fbo(gl_t *gl, static void gl_update_input_size(gl_t *gl, unsigned width, unsigned height, unsigned pitch, bool clear) { + GLfloat xamt, yamt; bool set_coords = false; @@ -1080,21 +1086,21 @@ static void gl_update_input_size(gl_t *gl, unsigned width, set_coords = true; } else if ((width != - gl->last_width[(gl->tex_index + gl->textures - 1) % gl->textures]) || + gl->last_width[(gl->tex_index + gl->textures - 1) % gl->textures]) || (height != - gl->last_height[(gl->tex_index + gl->textures - 1) % gl->textures])) + gl->last_height[(gl->tex_index + gl->textures - 1) % gl->textures])) { /* We might have used different texture coordinates * last frame. Edge case if resolution changes very rapidly. */ set_coords = true; } - if (set_coords) - { - GLfloat xamt = (GLfloat)width / gl->tex_w; - GLfloat yamt = (GLfloat)height / gl->tex_h; - set_texture_coords(gl->tex_info.coord, xamt, yamt); - } + if (!set_coords) + return; + + xamt = (GLfloat)width / gl->tex_w; + yamt = (GLfloat)height / gl->tex_h; + set_texture_coords(gl->tex_info.coord, xamt, yamt); } /* It is *much* faster (order of magnitude on my setup) @@ -1256,7 +1262,7 @@ static inline void gl_copy_frame(gl_t *gl, const void *frame, if (gl->egl_images) { EGLImageKHR img = 0; - bool new_egl = gl->ctx_driver->write_egl_image(gl, + bool new_egl = gl->ctx_driver->write_egl_image(gl, frame, width, height, pitch, (gl->base_size == 4), gl->tex_index, &img); @@ -1297,7 +1303,7 @@ static inline void gl_copy_frame(gl_t *gl, const void *frame, /* No GL_UNPACK_ROW_LENGTH. */ const GLvoid *data_buf = frame; - unsigned pitch_width = pitch / gl->base_size; + unsigned pitch_width = pitch / gl->base_size; if (width != pitch_width) { @@ -1306,13 +1312,13 @@ static inline void gl_copy_frame(gl_t *gl, const void *frame, unsigned h; const unsigned line_bytes = width * gl->base_size; - uint8_t *dst = (uint8_t*)gl->conv_buffer; - const uint8_t *src = (const uint8_t*)frame; + uint8_t *dst = (uint8_t*)gl->conv_buffer; + const uint8_t *src = (const uint8_t*)frame; for (h = 0; h < height; h++, src += pitch, dst += line_bytes) memcpy(dst, src, line_bytes); - data_buf = gl->conv_buffer; + data_buf = gl->conv_buffer; } glTexSubImage2D(GL_TEXTURE_2D, @@ -1416,13 +1422,13 @@ static inline void gl_draw_texture(gl_t *gl) if (!gl->menu_texture) return; - gl->coords.vertex = vertexes_flipped; + gl->coords.vertex = vertexes_flipped; gl->coords.tex_coord = tex_coords; - gl->coords.color = color; + gl->coords.color = color; glBindTexture(GL_TEXTURE_2D, gl->menu_texture); gl->shader->use(gl, GL_SHADER_STOCK_BLEND); - gl->coords.vertices = 4; + gl->coords.vertices = 4; gl->shader->set_coords(&gl->coords); gl->shader->set_mvp(gl, &gl->mvp_no_rot); @@ -1439,9 +1445,9 @@ static inline void gl_draw_texture(gl_t *gl) glDisable(GL_BLEND); - gl->coords.vertex = gl->vertex_ptr; + gl->coords.vertex = gl->vertex_ptr; gl->coords.tex_coord = gl->tex_info.coord; - gl->coords.color = gl->white_color_ptr; + gl->coords.color = gl->white_color_ptr; } #endif @@ -1707,6 +1713,7 @@ static void gl_free(void *data) if (gl->have_sync) { unsigned i; + for (i = 0; i < gl->fence_count; i++) { glClientWaitSync(gl->fences[i], @@ -1791,9 +1798,12 @@ static void gl_set_nonblock_state(void *data, bool state) static bool resolve_extensions(gl_t *gl) { #ifndef HAVE_OPENGLES - gl->core_context = + const char *vendor = NULL; + const char *renderer = NULL; + gl->core_context = (g_extern.system.hw_render_callback.context_type == RETRO_HW_CONTEXT_OPENGL_CORE); + if (gl->core_context) { RARCH_LOG("[GL]: Using Core GL context.\n"); @@ -1811,8 +1821,9 @@ static bool resolve_extensions(gl_t *gl) * The speed gain from using GL_RGB565 is worth * adding some workarounds for. */ - const char *vendor = (const char*)glGetString(GL_VENDOR); - const char *renderer = (const char*)glGetString(GL_RENDERER); + vendor = (const char*)glGetString(GL_VENDOR); + renderer = (const char*)glGetString(GL_RENDERER); + if (vendor && renderer && (strstr(vendor, "ATI") || strstr(renderer, "ATI"))) RARCH_LOG("[GL]: ATI card detected, skipping check for GL_RGB565 support.\n"); else @@ -1827,6 +1838,10 @@ static bool resolve_extensions(gl_t *gl) driver.gfx_use_rgba = false; #ifdef HAVE_OPENGLES2 + const char *version = NULL; + bool gles3 = false; + unsigned gles_major = 0, gles_minor = 0; + /* There are both APPLE and EXT variants. */ if (gl_query_extension(gl, "BGRA8888")) RARCH_LOG("[GL]: BGRA8888 extension found for GLES.\n"); @@ -1837,9 +1852,9 @@ static bool resolve_extensions(gl_t *gl) "32-bit path will require conversion.\n"); } - bool gles3 = false; - const char *version = (const char*)glGetString(GL_VERSION); - unsigned gles_major = 0, gles_minor = 0; + + version = (const char*)glGetString(GL_VERSION); + /* This format is mandated by GLES. */ if (version && sscanf(version, "OpenGL ES %u.%u", &gles_major, &gles_minor) == 2 && gles_major >= 3) @@ -1898,6 +1913,7 @@ static bool resolve_extensions(gl_t *gl) else { const char *ext = (const char*)glGetString(GL_EXTENSIONS); + if (ext) { size_t i; @@ -2258,15 +2274,14 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo gl->full_y = gl->win_height; } - hw_render = &g_extern.system.hw_render_callback; - - gl->vertex_ptr = hw_render->bottom_left_origin ? vertexes : vertexes_flipped; + hw_render = &g_extern.system.hw_render_callback; + gl->vertex_ptr = hw_render->bottom_left_origin ? vertexes : vertexes_flipped; /* Better pipelining with GPU due to synchronous glSubTexImage. * Multiple async PBOs would be an alternative, * but still need multiple textures with PREV. */ - gl->textures = 4; + gl->textures = 4; #ifdef HAVE_FBO gl->hw_render_use = hw_render->context_type != RETRO_HW_CONTEXT_NONE; @@ -2290,7 +2305,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo hw_render->version_major, hw_render->version_minor); #endif - gl->shader = (const shader_backend_t*)shader_ctx_init_first(); + gl->shader = (const shader_backend_t*)shader_ctx_init_first(); if (gl->shader) { @@ -2309,23 +2324,21 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo if (gl->shader) { unsigned minimum = gl->shader->get_prev_textures(); - gl->textures = max(minimum + 1, gl->textures); + gl->textures = max(minimum + 1, gl->textures); } RARCH_LOG("[GL]: Using %u textures.\n", gl->textures); RARCH_LOG("[GL]: Loaded %u program(s).\n", gl->shader->num_shaders()); - gl->tex_w = RARCH_SCALE_BASE * video->input_scale; - gl->tex_h = RARCH_SCALE_BASE * video->input_scale; - - gl->keep_aspect = video->force_aspect; + gl->tex_w = gl->tex_h = (RARCH_SCALE_BASE * video->input_scale); + gl->keep_aspect = video->force_aspect; /* Apparently need to set viewport for passes * when we aren't using FBOs. */ gl_set_shader_viewport(gl, 0); gl_set_shader_viewport(gl, 1); - gl->tex_mipmap = gl->shader->mipmap_input(1); + gl->tex_mipmap = gl->shader->mipmap_input(1); if (gl->shader->filter_type(1, &force_smooth)) gl->tex_min_filter = gl->tex_mipmap ? (force_smooth ? @@ -2337,7 +2350,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo : (video->smooth ? GL_LINEAR : GL_NEAREST); gl->tex_mag_filter = min_filter_to_mag(gl->tex_min_filter); - gl->wrap_mode = gl_wrap_type_to_enum(gl->shader->wrap_type(1)); + gl->wrap_mode = gl_wrap_type_to_enum(gl->shader->wrap_type(1)); gl_set_texture_fmts(gl, video->rgb32); @@ -2359,10 +2372,10 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo /* Empty buffer that we use to clear out * the texture with on res change. */ - gl->empty_buf = calloc(sizeof(uint32_t), gl->tex_w * gl->tex_h); + gl->empty_buf = calloc(sizeof(uint32_t), gl->tex_w * gl->tex_h); #if !defined(HAVE_PSGL) - gl->conv_buffer = calloc(sizeof(uint32_t), gl->tex_w * gl->tex_h); + gl->conv_buffer = calloc(sizeof(uint32_t), gl->tex_w * gl->tex_h); if (!gl->conv_buffer) { @@ -2473,23 +2486,25 @@ static void gl_update_tex_filter_frame(gl_t *gl) return; context_bind_hw_render(gl, false); + if (!gl->shader->filter_type(1, &smooth)) smooth = g_settings.video.smooth; - wrap_mode = gl_wrap_type_to_enum(gl->shader->wrap_type(1)); - gl->tex_mipmap = gl->shader->mipmap_input(1); + wrap_mode = gl_wrap_type_to_enum(gl->shader->wrap_type(1)); + gl->tex_mipmap = gl->shader->mipmap_input(1); gl->video_info.smooth = smooth; new_filt = gl->tex_mipmap ? (smooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST) : (smooth ? GL_LINEAR : GL_NEAREST); + if (new_filt == gl->tex_min_filter && wrap_mode == gl->wrap_mode) return; - gl->tex_min_filter = new_filt; - gl->tex_mag_filter = min_filter_to_mag(gl->tex_min_filter); + gl->tex_min_filter = new_filt; + gl->tex_mag_filter = min_filter_to_mag(gl->tex_min_filter); + gl->wrap_mode = wrap_mode; - gl->wrap_mode = wrap_mode; for (i = 0; i < gl->textures; i++) { if (!gl->texture[i]) @@ -2554,8 +2569,11 @@ static bool gl_set_shader(void *data, if (!gl->shader->init(gl, path)) { + bool ret = false; + RARCH_WARN("[GL]: Failed to set multipass shader. Falling back to stock.\n"); - bool ret = gl->shader->init(gl, NULL); + ret = gl->shader->init(gl, NULL); + if (!ret) gl->shader = NULL; context_bind_hw_render(gl, true); @@ -2609,16 +2627,15 @@ static bool gl_set_shader(void *data, static void gl_viewport_info(void *data, struct rarch_viewport *vp) { unsigned top_y, top_dist; - gl_t *gl = (gl_t*)data; - - *vp = gl->vp; + gl_t *gl = (gl_t*)data; + *vp = gl->vp; vp->full_width = gl->win_width; vp->full_height = gl->win_height; /* Adjust as GL viewport is bottom-up. */ - top_y = vp->y + vp->height; - top_dist = gl->win_height - top_y; - vp->y = top_dist; + top_y = vp->y + vp->height; + top_dist = gl->win_height - top_y; + vp->y = top_dist; } #ifdef NO_GL_READ_PIXELS @@ -2759,6 +2776,7 @@ static bool gl_overlay_load(void *data, gl_free_overlay(gl); gl->overlay_tex = (GLuint*)calloc(num_images, sizeof(*gl->overlay_tex)); + if (!gl->overlay_tex) { context_bind_hw_render(gl, true); @@ -2768,10 +2786,11 @@ static bool gl_overlay_load(void *data, gl->overlay_vertex_coord = (GLfloat*)calloc(2 * 4 * num_images, sizeof(GLfloat)); gl->overlay_tex_coord = (GLfloat*)calloc(2 * 4 * num_images, sizeof(GLfloat)); gl->overlay_color_coord = (GLfloat*)calloc(4 * 4 * num_images, sizeof(GLfloat)); + if (!gl->overlay_vertex_coord || !gl->overlay_tex_coord || !gl->overlay_color_coord) return false; - gl->overlays = num_images; + gl->overlays = num_images; glGenTextures(num_images, gl->overlay_tex); for (i = 0; i < num_images; i++) @@ -2803,20 +2822,24 @@ static void gl_overlay_tex_geom(void *data, GLfloat w, GLfloat h) { GLfloat *tex = NULL; - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; if (!gl) return; - tex = (GLfloat*)&gl->overlay_tex_coord[image * 8]; + tex = (GLfloat*)&gl->overlay_tex_coord[image * 8]; if (!tex) return; - tex[0] = x; tex[1] = y; - tex[2] = x + w; tex[3] = y; - tex[4] = x; tex[5] = y + h; - tex[6] = x + w; tex[7] = y + h; + tex[0] = x; + tex[1] = y; + tex[2] = x + w; + tex[3] = y; + tex[4] = x; + tex[5] = y + h; + tex[6] = x + w; + tex[7] = y + h; } static void gl_overlay_vertex_geom(void *data, @@ -2825,34 +2848,39 @@ static void gl_overlay_vertex_geom(void *data, float w, float h) { GLfloat *vertex = NULL; - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; if (!gl) return; - vertex = (GLfloat*)&gl->overlay_vertex_coord[image * 8]; + vertex = (GLfloat*)&gl->overlay_vertex_coord[image * 8]; /* Flipped, so we preserve top-down semantics. */ - y = 1.0f - y; - h = -h; + y = 1.0f - y; + h = -h; if (!vertex) return; - vertex[0] = x; vertex[1] = y; - vertex[2] = x + w; vertex[3] = y; - vertex[4] = x; vertex[5] = y + h; - vertex[6] = x + w; vertex[7] = y + h; + vertex[0] = x; + vertex[1] = y; + vertex[2] = x + w; + vertex[3] = y; + vertex[4] = x; + vertex[5] = y + h; + vertex[6] = x + w; + vertex[7] = y + h; } static void gl_overlay_enable(void *data, bool state) { - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; if (!gl) return; gl->overlay_enable = state; + if (gl->ctx_driver->show_mouse && gl->fullscreen) gl->ctx_driver->show_mouse(gl, state); } @@ -2868,19 +2896,19 @@ static void gl_overlay_full_screen(void *data, bool enable) static void gl_overlay_set_alpha(void *data, unsigned image, float mod) { GLfloat *color = NULL; - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; if (!gl) return; - color = (GLfloat*)&gl->overlay_color_coord[image * 16]; + color = (GLfloat*)&gl->overlay_color_coord[image * 16]; if (!color) return; - color[ 0 + 3] = mod; - color[ 4 + 3] = mod; - color[ 8 + 3] = mod; - color[12 + 3] = mod; + color[ 0 + 3] = mod; + color[ 4 + 3] = mod; + color[ 8 + 3] = mod; + color[12 + 3] = mod; } static void gl_render_overlay(void *data) @@ -3014,12 +3042,12 @@ static void gl_set_texture_frame(void *data, static void gl_set_texture_enable(void *data, bool state, bool full_screen) { - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; if (!gl) return; - gl->menu_texture_enable = state; + gl->menu_texture_enable = state; gl->menu_texture_full_screen = full_screen; } #endif From d8294c8dc0bd9e8aed68aa048a32f2e69c70e45b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 02:59:13 +0100 Subject: [PATCH 126/147] Move Options to new category --- menu/menu_entries_cbs.c | 38 +++++++++++++++++++++++++++++++++++++- settings_data.c | 36 ++---------------------------------- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index eb32305389..b46e5c26ce 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -3071,6 +3071,39 @@ static int deferred_push_shader_options(void *data, void *userdata, return 0; } +static int deferred_push_options(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + unsigned i; + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + menu_list_clear(list); + menu_list_push(list, "Core Options", "core_options", + MENU_SETTING_ACTION, 0); + if (g_extern.main_is_init) + { + if (g_extern.has_set_input_descriptors) + menu_list_push(list, "Core Input Remapping Options", "core_input_remapping_options", + MENU_SETTING_ACTION, 0); + menu_list_push(list, "Core Cheat Options", "core_cheat_options", + MENU_SETTING_ACTION, 0); + if (!g_extern.libretro_dummy && g_extern.system.disk_control.get_num_images) + menu_list_push(list, "Core Disk Options", "core_disk_options", + MENU_SETTING_ACTION, 0); + } + menu_list_push(list, "Shader Options", "shader_options", + MENU_SETTING_ACTION, 0); + + if (driver.menu_ctx && driver.menu_ctx->populate_entries) + driver.menu_ctx->populate_entries(driver.menu, path, label, type); + + return 0; +} + static void push_perfcounter(menu_handle_t *menu, file_list_t *list, @@ -5136,7 +5169,8 @@ static void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, !strcmp(label, "settings") || !strcmp(label, "performance_counters") || !strcmp(label, "frontend_counters") || - !strcmp(label, "core_counters") + !strcmp(label, "core_counters") || + !strcmp(label, "options") ) cbs->action_ok = action_ok_push_default; else if ( @@ -5591,6 +5625,8 @@ static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs, cbs->action_deferred_push = deferred_push_content_actions; else if (!strcmp(label, "shader_options")) cbs->action_deferred_push = deferred_push_shader_options; + else if (!strcmp(label, "options")) + cbs->action_deferred_push = deferred_push_options; else if (type == MENU_SETTING_GROUP) cbs->action_deferred_push = deferred_push_category; else if (!strcmp(label, "deferred_core_list")) diff --git a/settings_data.c b/settings_data.c index 37d3d4991b..a484c49987 100644 --- a/settings_data.c +++ b/settings_data.c @@ -3240,12 +3240,6 @@ static bool setting_data_append_list_main_menu_options( (*list)[list_info->index - 1].change_handler = load_content_change_handler; settings_data_list_current_add_flags(list, list_info, SD_FLAG_BROWSER_ACTION); - CONFIG_ACTION( - "core_options", - "Core Options", - group_info.name, - subgroup_info.name); - CONFIG_ACTION( "core_information", @@ -3253,35 +3247,9 @@ static bool setting_data_append_list_main_menu_options( group_info.name, subgroup_info.name); - if (g_extern.main_is_init) - { - if (g_extern.has_set_input_descriptors) - CONFIG_ACTION( - "core_input_remapping_options", - "Core Input Remapping Options", - group_info.name, - subgroup_info.name); - - CONFIG_ACTION( - "core_cheat_options", - "Core Cheat Options", - group_info.name, - subgroup_info.name); - - if ( !g_extern.libretro_dummy - && g_extern.system.disk_control.get_num_images) - { - CONFIG_ACTION( - "disk_options", - "Core Disk Options", - group_info.name, - subgroup_info.name); - } - } - CONFIG_ACTION( - "shader_options", - "Shader Options", + "options", + "Options", group_info.name, subgroup_info.name); From 650ce81d745cb375bc9869f745069bfc771ba2b3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 03:20:25 +0100 Subject: [PATCH 127/147] Move Database Manager/Cursor Manager to 'Management' --- menu/menu_entries_cbs.c | 28 ++++++++++++++++++++++++++++ settings_data.c | 20 ++++++-------------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index b46e5c26ce..719ca82007 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -3104,6 +3104,31 @@ static int deferred_push_options(void *data, void *userdata, return 0; } +static int deferred_push_management_options(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + unsigned i; + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + menu_list_clear(list); + +#ifdef HAVE_LIBRETRODB + menu_list_push(list, "Database Manager", "database_manager_list", + MENU_SETTING_ACTION, 0); + menu_list_push(list, "Cursor Manager", "cursor_manager_list", + MENU_SETTING_ACTION, 0); +#endif + + if (driver.menu_ctx && driver.menu_ctx->populate_entries) + driver.menu_ctx->populate_entries(driver.menu, path, label, type); + + return 0; +} + static void push_perfcounter(menu_handle_t *menu, file_list_t *list, @@ -5170,6 +5195,7 @@ static void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, !strcmp(label, "performance_counters") || !strcmp(label, "frontend_counters") || !strcmp(label, "core_counters") || + !strcmp(label, "management") || !strcmp(label, "options") ) cbs->action_ok = action_ok_push_default; @@ -5627,6 +5653,8 @@ static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs, cbs->action_deferred_push = deferred_push_shader_options; else if (!strcmp(label, "options")) cbs->action_deferred_push = deferred_push_options; + else if (!strcmp(label, "management")) + cbs->action_deferred_push = deferred_push_management_options; else if (type == MENU_SETTING_GROUP) cbs->action_deferred_push = deferred_push_category; else if (!strcmp(label, "deferred_core_list")) diff --git a/settings_data.c b/settings_data.c index a484c49987..008777e8aa 100644 --- a/settings_data.c +++ b/settings_data.c @@ -3195,20 +3195,6 @@ static bool setting_data_append_list_main_menu_options( subgroup_info.name); #endif -#ifdef HAVE_LIBRETRODB - CONFIG_ACTION( - "database_manager_list", - "Database Manager", - group_info.name, - subgroup_info.name); - - CONFIG_ACTION( - "cursor_manager_list", - "Cursor Manager", - group_info.name, - subgroup_info.name); -#endif - if (g_settings.history_list_enable) { CONFIG_ACTION( @@ -3247,6 +3233,12 @@ static bool setting_data_append_list_main_menu_options( group_info.name, subgroup_info.name); + CONFIG_ACTION( + "management", + "Management", + group_info.name, + subgroup_info.name); + CONFIG_ACTION( "options", "Options", From 481570d822e50012bdad7d69b3d7617ef7ff6085 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 03:38:28 +0100 Subject: [PATCH 128/147] (Menu) Fix labels --- menu/drivers/shared.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/menu/drivers/shared.h b/menu/drivers/shared.h index 42d164a69e..01928db5e5 100644 --- a/menu/drivers/shared.h +++ b/menu/drivers/shared.h @@ -49,14 +49,16 @@ static INLINE void get_title(const char *label, const char *dir, #endif if (!strcmp(label, "core_list")) snprintf(title, sizeof_title, "CORE SELECTION %s", dir); - else if (!strcmp(label, "core_manager_list")) + else if (!strcmp(label, "core_updater_list")) snprintf(title, sizeof_title, "CORE UPDATER %s", dir); + else if (!strcmp(label, "deferred_database_manager_list")) + snprintf(title, sizeof_title, "DATABASE SELECTION - %s", (elem0_path[0] != '\0') ? path_basename(elem0_path) : ""); else if (!strcmp(label, "database_manager_list")) - snprintf(title, sizeof_title, "DATABASE SELECTION %s", dir); + snprintf(title, sizeof_title, "DATABASE SELECTION"); else if (!strcmp(label, "cursor_manager_list")) - snprintf(title, sizeof_title, "DATABASE CURSOR SELECTION %s", dir); + snprintf(title, sizeof_title, "DATABASE CURSOR SELECTION"); else if (!strcmp(label, "deferred_cursor_manager_list")) - snprintf(title, sizeof_title, "DATABASE CURSOR LIST %s", dir); + snprintf(title, sizeof_title, "DATABASE CURSOR LIST - %s", (elem0_path[0] != '\0') ? path_basename(elem0_path) : ""); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_developer")) snprintf(title, sizeof_title, "DATABASE CURSOR LIST (FILTER: DEVELOPER - %s)", elem0_path); else if (!strcmp(label, "deferred_cursor_manager_list_rdb_entry_publisher")) @@ -201,6 +203,10 @@ static INLINE void get_title(const char *label, const char *dir, if (!strcmp(elem1, "Paths")) strlcat(title, " - PATHS", sizeof_title); } + else if (!strcmp(label, "management")) + strlcpy(title, "MANAGEMENT", sizeof_title); + else if (!strcmp(label, "options")) + strlcpy(title, "OPTIONS", sizeof_title); else if (!strcmp(label, "settings")) strlcpy(title, "SETTINGS", sizeof_title); else if (!strcmp(elem0, "Driver Settings")) From 3feb89a8b28fcdea59ffd1e8e3b675c683ba3fab Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 04:03:52 +0100 Subject: [PATCH 129/147] (XMB) Rename 'Core Informations' --- menu/menu_entries_cbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 719ca82007..834b163255 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -3512,7 +3512,7 @@ static int deferred_push_content_actions(void *data, void *userdata, menu_list_push(list, "Resume", "file_load_or_resume", MENU_SETTING_ACTION_RUN, 0); menu_list_push(list, "Save State", "savestate", MENU_SETTING_ACTION_SAVESTATE, 0); menu_list_push(list, "Load State", "loadstate", MENU_SETTING_ACTION_LOADSTATE, 0); - menu_list_push(list, "Core Informations", "core_information", MENU_SETTING_ACTION_CORE_INFORMATION, 0); + menu_list_push(list, "Core Information", "core_information", MENU_SETTING_ACTION_CORE_INFORMATION, 0); menu_list_push(list, "Core Options", "core_options", MENU_SETTING_ACTION_CORE_OPTIONS, 0); if (g_extern.has_set_input_descriptors) menu_list_push(list, "Core Input Remapping Options", "core_input_remapping_options", MENU_SETTING_ACTION_CORE_INPUT_REMAPPING_OPTIONS, 0); From d48998448623707bce965c22c0589804b7797c78 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 04:46:34 +0100 Subject: [PATCH 130/147] Rename some settings --- settings_data.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/settings_data.c b/settings_data.c index 008777e8aa..f72234e6f1 100644 --- a/settings_data.c +++ b/settings_data.c @@ -5111,17 +5111,6 @@ static bool setting_data_append_list_menu_options( general_write_handler, general_read_handler); - CONFIG_BOOL( - g_settings.menu_show_start_screen, - "rgui_show_start_screen", - "Show Start Screen", - menu_show_start_screen, - "OFF", - "ON", - group_info.name, - subgroup_info.name, - general_write_handler, - general_read_handler); CONFIG_BOOL( g_settings.menu.pause_libretro, @@ -5209,10 +5198,22 @@ static bool setting_data_append_list_menu_options( general_write_handler, general_read_handler); + CONFIG_BOOL( + g_settings.menu_show_start_screen, + "rgui_show_start_screen", + "Show Start Screen", + menu_show_start_screen, + "OFF", + "ON", + group_info.name, + subgroup_info.name, + general_write_handler, + general_read_handler); + CONFIG_BOOL( g_settings.menu.timedate_enable, "menu_timedate_enable", - "Time / date enable", + "Show time / date", true, "OFF", "ON", @@ -5224,7 +5225,7 @@ static bool setting_data_append_list_menu_options( CONFIG_BOOL( g_settings.menu.core_enable, "menu_core_enable", - "Core enable", + "Show core name", true, "OFF", "ON", From 56cce66121994c792a135a2fe681fd6251bd7ce5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 04:54:42 +0100 Subject: [PATCH 131/147] Add button description to 'Help' --- menu/menu_entries_cbs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 834b163255..162d432a7b 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -3779,6 +3779,7 @@ static int action_iterate_help(const char *label, unsigned action) RETRO_DEVICE_ID_JOYPAD_SELECT, RARCH_MENU_TOGGLE, RARCH_QUIT_KEY, + RETRO_DEVICE_ID_JOYPAD_X, }; char desc[ARRAY_SIZE(binds)][64]; char msg[PATH_MAX_LENGTH]; @@ -3812,6 +3813,7 @@ static int action_iterate_help(const char *label, unsigned action) " Info: %-20s\n" "Enter/Exit Menu: %-20s\n" " Exit RetroArch: %-20s\n" + "Toggle Keyboard: %-20s\n" " \n" "To run content:\n" @@ -3822,7 +3824,7 @@ static int action_iterate_help(const char *label, unsigned action) " \n" "Press Accept/OK to continue.", - desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6]); + desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6], desc[7]); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) driver.menu_ctx->render_messagebox(menu, msg); From 9ef984d5252453f776828d7305368f309493b94f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 13 Feb 2015 09:48:07 -0500 Subject: [PATCH 132/147] menu_entries_cbs: Remove unused variables --- menu/menu_entries_cbs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 162d432a7b..eea2ff8d75 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -3074,7 +3074,6 @@ static int deferred_push_shader_options(void *data, void *userdata, static int deferred_push_options(void *data, void *userdata, const char *path, const char *label, unsigned type) { - unsigned i; file_list_t *list = (file_list_t*)data; file_list_t *menu_list = (file_list_t*)userdata; @@ -3107,7 +3106,6 @@ static int deferred_push_options(void *data, void *userdata, static int deferred_push_management_options(void *data, void *userdata, const char *path, const char *label, unsigned type) { - unsigned i; file_list_t *list = (file_list_t*)data; file_list_t *menu_list = (file_list_t*)userdata; From 55e9c2b593ca46400446c2fa2ca4a40db1c8a2fe Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 13 Feb 2015 09:54:45 -0500 Subject: [PATCH 133/147] Apply static to some local-only functions --- audio/audio_resampler_driver.c | 2 +- menu/menu_animation.c | 2 +- menu/menu_entries.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/audio/audio_resampler_driver.c b/audio/audio_resampler_driver.c index 1af57e4dc0..06042ab12f 100644 --- a/audio/audio_resampler_driver.c +++ b/audio/audio_resampler_driver.c @@ -177,7 +177,7 @@ retro_get_cpu_features_t perf_get_cpu_features_cb; #endif -resampler_simd_mask_t resampler_get_cpu_features(void) +static resampler_simd_mask_t resampler_get_cpu_features(void) { #ifdef RARCH_INTERNAL return rarch_get_cpu_features(); diff --git a/menu/menu_animation.c b/menu/menu_animation.c index 8b83f6e721..ffe71b7521 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -62,7 +62,7 @@ static float easing_out_cubic(float t, float b, float c, float d) return c * (pow(t / d - 1, 3) + 1) + b; } -float easing_in_out_cubic(float t, float b, float c, float d) +static float easing_in_out_cubic(float t, float b, float c, float d) { t = t / d * 2; if (t < 1) diff --git a/menu/menu_entries.c b/menu/menu_entries.c index f2425b5cbc..65c453bba2 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -163,7 +163,7 @@ static void menu_entries_content_list_push( string_list_free(str_list); } -int menu_entries_push_cores_list(file_list_t *list, core_info_t *info, +static int menu_entries_push_cores_list(file_list_t *list, core_info_t *info, const char *path, bool push_databases_enable) { size_t i; From 4d316878991949846adf2e787fbdf3671d9dacbf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 19:00:34 +0100 Subject: [PATCH 134/147] Create menu_driver_resolve to avoid having to pass state pointer around between functions --- driver.c | 8 +- gfx/d3d/d3d.cpp | 2 +- gfx/drivers/gl.c | 2 +- gfx/drivers/sdl2_gfx.c | 2 +- menu/drivers/glui.c | 88 ++++++++++----- menu/drivers/ios.c | 12 ++- menu/drivers/rgui.c | 107 ++++++++++-------- menu/drivers/rmenu.c | 30 ++++-- menu/drivers/rmenu_xui.cpp | 73 +++++++++---- menu/drivers/xmb.c | 215 +++++++++++++++++++++++++------------ menu/menu.c | 10 +- menu/menu_driver.c | 7 ++ menu/menu_driver.h | 60 ++++++----- menu/menu_entries.c | 4 +- menu/menu_entries_cbs.c | 52 ++++----- menu/menu_input.c | 8 +- menu/menu_list.c | 14 +-- menu/menu_navigation.c | 14 +-- retroarch.c | 8 +- 19 files changed, 451 insertions(+), 265 deletions(-) diff --git a/driver.c b/driver.c index 77ca46144e..6e978c4a9f 100644 --- a/driver.c +++ b/driver.c @@ -335,8 +335,8 @@ void init_drivers(int flags) { init_menu(); - if (driver.menu && driver.menu_ctx && driver.menu_ctx->context_reset) - driver.menu_ctx->context_reset(driver.menu); + if (driver.menu_ctx && driver.menu_ctx->context_reset) + driver.menu_ctx->context_reset(); } #endif @@ -371,8 +371,8 @@ void uninit_drivers(int flags) #ifdef HAVE_MENU if (flags & DRIVER_MENU) { - if (driver.menu && driver.menu_ctx && driver.menu_ctx->context_destroy) - driver.menu_ctx->context_destroy(driver.menu); + if (driver.menu_ctx && driver.menu_ctx->context_destroy) + driver.menu_ctx->context_destroy(); if (!driver.menu_data_own) { diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index e5b9c90d0d..3ed18f9863 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1668,7 +1668,7 @@ static bool d3d_frame(void *data, const void *frame, #ifdef HAVE_MENU if (g_extern.is_menu && driver.menu_ctx && driver.menu_ctx->frame) - driver.menu_ctx->frame(driver.menu); + driver.menu_ctx->frame(); #ifdef _XBOX /* TODO - should be refactored. */ diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 9aa51de3af..2796957536 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1582,7 +1582,7 @@ static bool gl_frame(void *data, const void *frame, #if defined(HAVE_MENU) if (g_extern.is_menu && driver.menu_ctx && driver.menu_ctx->frame) - driver.menu_ctx->frame(driver.menu); + driver.menu_ctx->frame(); if (gl->menu_texture_enable) gl_draw_texture(gl); diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 4503da928a..bb2d83b1fc 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -500,7 +500,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, #ifdef HAVE_MENU if (g_extern.is_menu && driver.menu_ctx && driver.menu_ctx->frame) - driver.menu_ctx->frame(driver.menu); + driver.menu_ctx->frame(); #endif if (vid->menu.active) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 5e365cd347..1eebcbf770 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -48,12 +48,17 @@ typedef struct glui_handle } textures; } glui_handle_t; -static int glui_entry_iterate(menu_handle_t *menu, unsigned action) +static int glui_entry_iterate(unsigned action) { const char *label = NULL; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr); + menu_file_list_cbs_t *cbs = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + + cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( + menu->menu_list->selection_buf, menu->selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -197,11 +202,15 @@ static void glui_draw_cursor(gl_t *gl, glui_handle_t *glui, float x, float y) gl->coords.color = gl->white_color_ptr; } -static void glui_get_message(menu_handle_t *menu, const char *message) +static void glui_get_message(const char *message) { glui_handle_t *glui = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || !message || !*message) + if (!menu) + return; + + if (!message || !*message) return; glui = (glui_handle_t*)menu->userdata; @@ -210,15 +219,21 @@ static void glui_get_message(menu_handle_t *menu, const char *message) strlcpy(glui->box_message, message, sizeof(glui->box_message)); } -static void glui_render_messagebox(menu_handle_t *menu, const char *message) +static void glui_render_messagebox(const char *message) { unsigned i; int x, y; struct string_list *list = NULL; glui_handle_t *glui = NULL; - gl_t *gl = (gl_t*)video_driver_resolve(NULL); + gl_t *gl = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || !gl) + if (!menu) + return; + + gl = (gl_t*)video_driver_resolve(NULL); + + if (!gl) return; glui = (glui_handle_t*)menu->userdata; @@ -248,7 +263,7 @@ end: string_list_free(list); } -static void glui_frame(menu_handle_t *menu) +static void glui_frame(void) { unsigned x, y; size_t i; @@ -259,12 +274,18 @@ static void glui_frame(menu_handle_t *menu) const char *label = NULL; unsigned menu_type = 0; size_t end; - gl_t *gl = (gl_t*)video_driver_resolve(NULL); + gl_t *gl = NULL; glui_handle_t *glui = NULL; const char *core_name = NULL; const char *core_version = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || !gl) + if (!menu) + return; + + gl = (gl_t*)video_driver_resolve(NULL); + + if (!gl) return; glui = (glui_handle_t*)menu->userdata; @@ -401,7 +422,7 @@ static void glui_frame(menu_handle_t *menu) else message_queue = driver.current_msg; - glui_render_messagebox(menu, message_queue); + glui_render_messagebox(message_queue); #endif if (menu->keyboard.display) @@ -412,13 +433,13 @@ static void glui_frame(menu_handle_t *menu) str = ""; glui_render_background(gl, glui, true); snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str); - glui_render_messagebox(menu, msg); + glui_render_messagebox(msg); } if (glui->box_message[0] != '\0') { glui_render_background(gl, glui, true); - glui_render_messagebox(menu, glui->box_message); + glui_render_messagebox(glui->box_message); glui->box_message[0] = '\0'; } @@ -430,9 +451,9 @@ static void glui_frame(menu_handle_t *menu) static void *glui_init(void) { - menu_handle_t *menu; glui_handle_t *glui = NULL; const video_driver_t *video_driver = NULL; + menu_handle_t *menu = NULL; gl_t *gl = (gl_t*)video_driver_resolve(&video_driver); if (video_driver != &video_gl || !gl) @@ -474,9 +495,10 @@ static void glui_free(void *data) -static void glui_context_destroy(menu_handle_t *menu) +static void glui_context_destroy(void) { glui_handle_t *glui = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -490,9 +512,10 @@ static void glui_context_destroy(menu_handle_t *menu) glDeleteTextures(1, &glui->textures.bg.id); } -static bool glui_load_wallpaper(menu_handle_t *menu, const char *path) +static bool glui_load_wallpaper(const char *path) { glui_handle_t *glui = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return false; @@ -515,9 +538,10 @@ static bool glui_load_wallpaper(menu_handle_t *menu, const char *path) return true; } -static void glui_context_reset(menu_handle_t *menu) +static void glui_context_reset(void) { glui_handle_t *glui = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -539,18 +563,20 @@ static void glui_context_reset(menu_handle_t *menu) sizeof(glui->textures.bg.path)); if (path_file_exists(glui->textures.bg.path)) - glui_load_wallpaper(driver.menu, glui->textures.bg.path); + glui_load_wallpaper(glui->textures.bg.path); } -static void glui_navigation_clear(menu_handle_t *menu, bool pending_push) +static void glui_navigation_clear(bool pending_push) { + menu_handle_t *menu = menu_driver_resolve(); if (menu) menu->begin = 0; } -static void glui_navigation_set(menu_handle_t *menu, bool scroll) +static void glui_navigation_set(bool scroll) { glui_handle_t *glui = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -574,19 +600,25 @@ static void glui_navigation_set(menu_handle_t *menu, bool scroll) - glui->term_height; } -static void glui_navigation_set_last(menu_handle_t *menu) +static void glui_navigation_set_last(void) { - glui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + glui_navigation_set(true); } -static void glui_navigation_descend_alphabet(menu_handle_t *menu, size_t *unused) +static void glui_navigation_descend_alphabet(size_t *unused) { - glui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + glui_navigation_set(true); } -static void glui_navigation_ascend_alphabet(menu_handle_t *menu, size_t *unused) +static void glui_navigation_ascend_alphabet(size_t *unused) { - glui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + glui_navigation_set(true); } menu_ctx_driver_t menu_ctx_glui = { diff --git a/menu/drivers/ios.c b/menu/drivers/ios.c index 29a14202c4..d06a8ff50a 100644 --- a/menu/drivers/ios.c +++ b/menu/drivers/ios.c @@ -25,11 +25,17 @@ #include "ios.h" #include "../menu_input.h" -static int ios_entry_iterate(menu_handle_t *menu, unsigned action) +static int ios_entry_iterate(unsigned action) { - ios_handle_t *ios = (ios_handle_t*)menu->userdata; + ios_handle_t *ios = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (ios->switch_to_ios) + if (!menu) + return -1; + + ios = (ios_handle_t*)menu->userdata; + + if (ios && ios->switch_to_ios) ios->switch_to_ios(); return 0; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 31a95819f7..84606c315e 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -34,16 +34,19 @@ #define RGUI_TERM_WIDTH (((menu->frame_buf.width - RGUI_TERM_START_X - RGUI_TERM_START_X) / (FONT_WIDTH_STRIDE))) #define RGUI_TERM_HEIGHT (((menu->frame_buf.height - RGUI_TERM_START_Y - RGUI_TERM_START_X) / (FONT_HEIGHT_STRIDE)) - 1) -static int rgui_entry_iterate(menu_handle_t *menu, unsigned action) +static int rgui_entry_iterate(unsigned action) { const char *label = NULL; + menu_file_list_cbs_t *cbs = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || !menu->menu_list) + if (!menu) + return -1; + if (!menu->menu_list) return -1; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr); + cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( + menu->menu_list->selection_buf, menu->selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -107,19 +110,19 @@ static uint16_t green_filler(unsigned x, unsigned y) #endif } -static void fill_rect(menu_handle_t *menu, +static void fill_rect(menu_framebuf_t *frame_buf, unsigned x, unsigned y, unsigned width, unsigned height, uint16_t (*col)(unsigned x, unsigned y)) { unsigned i, j; - if (!menu->frame_buf.data || !col) + if (!frame_buf->data || !col) return; for (j = y; j < y + height; j++) for (i = x; i < x + width; i++) - menu->frame_buf.data[j * (menu->frame_buf.pitch >> 1) + i] = col(i, j); + frame_buf->data[j * (frame_buf->pitch >> 1) + i] = col(i, j); } static void color_rect(menu_handle_t *menu, @@ -195,13 +198,14 @@ static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf) return true; } -static bool rguidisp_init_font(void *data) +static bool rguidisp_init_font(menu_handle_t *menu) { - menu_handle_t *menu = (menu_handle_t*)data; - const uint8_t *font_bmp_buf = NULL; const uint8_t *font_bin_buf = bitmap_bin; + if (!menu) + return false; + if (font_bmp_buf) return init_font(menu, font_bmp_buf); @@ -213,29 +217,33 @@ static bool rguidisp_init_font(void *data) return true; } -static void rgui_render_background(menu_handle_t *menu) +static void rgui_render_background(void) { + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; - fill_rect(menu, 0, 0, menu->frame_buf.width, menu->frame_buf.height, gray_filler); - fill_rect(menu, 5, 5, menu->frame_buf.width - 10, 5, green_filler); - fill_rect(menu, 5, menu->frame_buf.height - 10, menu->frame_buf.width - 10, 5, + fill_rect(&menu->frame_buf, 0, 0, menu->frame_buf.width, menu->frame_buf.height, gray_filler); + fill_rect(&menu->frame_buf, 5, 5, menu->frame_buf.width - 10, 5, green_filler); + fill_rect(&menu->frame_buf, 5, menu->frame_buf.height - 10, menu->frame_buf.width - 10, 5, green_filler); - fill_rect(menu, 5, 5, 5, menu->frame_buf.height - 10, green_filler); - fill_rect(menu, menu->frame_buf.width - 10, 5, 5, menu->frame_buf.height - 10, + fill_rect(&menu->frame_buf, 5, 5, 5, menu->frame_buf.height - 10, green_filler); + fill_rect(&menu->frame_buf, menu->frame_buf.width - 10, 5, 5, menu->frame_buf.height - 10, green_filler); } -static void rgui_render_messagebox(menu_handle_t *menu, const char *message) +static void rgui_render_messagebox(const char *message) { size_t i; int x, y; unsigned width, glyphs_width, height; struct string_list *list = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || !message || !*message) + if (!menu) + return; + if (!message || !*message) return; list = string_split(message, "\n"); @@ -271,11 +279,11 @@ static void rgui_render_messagebox(menu_handle_t *menu, const char *message) x = (menu->frame_buf.width - width) / 2; y = (menu->frame_buf.height - height) / 2; - fill_rect(menu, x + 5, y + 5, width - 10, height - 10, gray_filler); - fill_rect(menu, x, y, width - 5, 5, green_filler); - fill_rect(menu, x + width - 5, y, 5, height - 5, green_filler); - fill_rect(menu, x + 5, y + height - 5, width - 5, 5, green_filler); - fill_rect(menu, x, y + 5, 5, height - 5, green_filler); + fill_rect(&menu->frame_buf, x + 5, y + 5, width - 10, height - 10, gray_filler); + fill_rect(&menu->frame_buf, x, y, width - 5, 5, green_filler); + fill_rect(&menu->frame_buf, x + width - 5, y, 5, height - 5, green_filler); + fill_rect(&menu->frame_buf, x + 5, y + height - 5, width - 5, 5, green_filler); + fill_rect(&menu->frame_buf, x, y + 5, 5, height - 5, green_filler); for (i = 0; i < list->size; i++) { @@ -298,7 +306,7 @@ static void rgui_blit_cursor(menu_handle_t *menu) color_rect(menu, x - 5, y, 11, 1, 0xFFFF); } -static void rgui_render(menu_handle_t *menu) +static void rgui_render(void) { size_t i, end; char title[256], title_buf[256], title_msg[64]; @@ -308,10 +316,12 @@ static void rgui_render(menu_handle_t *menu) const char *label = NULL; const char *core_name = NULL; const char *core_version = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || (menu->need_refresh - && g_extern.is_menu - && !menu->msg_force)) + if (!menu) + return; + if (menu->need_refresh && g_extern.is_menu + && !menu->msg_force) return; menu->mouse.ptr = menu->mouse.y / 11 - 2 + menu->begin; @@ -332,7 +342,7 @@ static void rgui_render(menu_handle_t *menu) menu->begin + RGUI_TERM_HEIGHT : menu_list_get_size(menu->menu_list); - rgui_render_background(menu); + rgui_render_background(); menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type); @@ -440,7 +450,7 @@ static void rgui_render(menu_handle_t *menu) else message_queue = driver.current_msg; - rgui_render_messagebox(menu, message_queue); + rgui_render_messagebox( message_queue); #endif if (menu->keyboard.display) @@ -450,7 +460,7 @@ static void rgui_render(menu_handle_t *menu) if (!str) str = ""; snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str); - rgui_render_messagebox(menu, msg); + rgui_render_messagebox(msg); } if (menu->mouse.enable) @@ -512,10 +522,12 @@ static void rgui_free(void *data) free((uint8_t*)menu->font); } -static void rgui_set_texture(menu_handle_t *menu) +static void rgui_set_texture(void) { + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; + if (!driver.video_data) return; if (!driver.video_poke) @@ -527,16 +539,19 @@ static void rgui_set_texture(menu_handle_t *menu) menu->frame_buf.data, false, menu->frame_buf.width, menu->frame_buf.height, 1.0f); } -static void rgui_navigation_clear(menu_handle_t *menu, bool pending_push) +static void rgui_navigation_clear(bool pending_push) { + menu_handle_t *menu = menu_driver_resolve(); if (menu) menu->begin = 0; } -static void rgui_navigation_set(menu_handle_t *menu, bool scroll) +static void rgui_navigation_set(bool scroll) { + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; + if (!scroll) return; @@ -552,25 +567,33 @@ static void rgui_navigation_set(menu_handle_t *menu, bool scroll) - RGUI_TERM_HEIGHT; } -static void rgui_navigation_set_last(menu_handle_t *menu) +static void rgui_navigation_set_last(void) { - rgui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + rgui_navigation_set(true); } -static void rgui_navigation_descend_alphabet(menu_handle_t *menu, size_t *unused) +static void rgui_navigation_descend_alphabet(size_t *unused) { - rgui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + rgui_navigation_set(true); } -static void rgui_navigation_ascend_alphabet(menu_handle_t *menu, size_t *unused) +static void rgui_navigation_ascend_alphabet(size_t *unused) { - rgui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + rgui_navigation_set(true); } -static void rgui_populate_entries(menu_handle_t *menu, const char *path, +static void rgui_populate_entries(const char *path, const char *label, unsigned k) { - rgui_navigation_set(menu, true); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + rgui_navigation_set(true); } menu_ctx_driver_t menu_ctx_rgui = { diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index ee27258954..e92c22bf43 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -64,12 +64,17 @@ struct texture_image *menu_texture; static bool render_normal = true; static bool menu_texture_inited =false; -static int rmenu_entry_iterate(menu_handle_t *menu, unsigned action) +static int rmenu_entry_iterate(unsigned action) { const char *label = NULL; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr); + menu_file_list_cbs_t *cbs = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( + menu->menu_list->selection_buf, menu->selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -83,11 +88,15 @@ static void rmenu_render_background(void) { } -static void rmenu_render_messagebox(menu_handle_t *menu, const char *message) +static void rmenu_render_messagebox(const char *message) { struct font_params font_parms; size_t i, j; struct string_list *list = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; if (!message || !*message) return; @@ -132,7 +141,7 @@ end: string_list_free(list); } -static void rmenu_render(menu_handle_t *menu) +static void rmenu_render(void) { size_t begin, end; size_t i, j; @@ -144,6 +153,7 @@ static void rmenu_render(menu_handle_t *menu) const char *core_name = NULL; const char *core_version = NULL; unsigned menu_type = 0; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -256,7 +266,7 @@ static void rmenu_render(menu_handle_t *menu) selected ? '>' : ' ', entry_title_buf); #if 0 - blit_line(menu, x, y, message, selected); + blit_line(x, y, message, selected); #endif font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET; font_parms.y = POSITION_EDGE_MIN + POSITION_RENDER_OFFSET @@ -278,8 +288,10 @@ static void rmenu_render(menu_handle_t *menu) } } -static void rmenu_set_texture(menu_handle_t *menu) +static void rmenu_set_texture(void) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return; if (menu_texture_inited) @@ -316,7 +328,7 @@ static void rmenu_wallpaper_set_defaults(char *menu_bg, size_t sizeof_menu_bg) static void rmenu_context_reset(void *data) { char menu_bg[PATH_MAX_LENGTH]; - menu_handle_t *menu = (menu_handle_t*)data; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index e71129ca29..7344c5620f 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -58,12 +58,17 @@ HXUIOBJ root_menu; HXUIOBJ current_menu; static msg_queue_t *xui_msg_queue; -static int rmenu_xui_entry_iterate(menu_handle_t *menu, unsigned action) +static int rmenu_xui_entry_iterate(unsigned action) { const char *label = NULL; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr); + menu_file_list_cbs_t *cbs = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + + cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( + menu->menu_list->selection_buf, menu->selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -406,14 +411,28 @@ end: string_list_free(list); } -static void rmenu_xui_frame(menu_handle_t *menu) +static void rmenu_xui_frame(void) { XUIMessage msg; XUIMessageRender msgRender; D3DXMATRIX matOrigView; D3DVIEWPORT vp_full; - d3d_video_t *d3d = (d3d_video_t*)driver.video_data; - LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; + LPDIRECT3DDEVICE d3dr; + d3d_video_t *d3d = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + d3d = (d3d_video_t*)driver.video_data; + + if (!d3d) + return; + + d3dr = (LPDIRECT3DDEVICE)d3d->dev; + + if (!d3dr) + return; (void)menu; @@ -464,7 +483,7 @@ static void rmenu_xui_render_background(void) XuiElementSetShow(m_background, TRUE); } -static void rmenu_xui_render_messagebox(menu_handle_t *menu, const char *message) +static void rmenu_xui_render_messagebox(const char *message) { msg_queue_clear(xui_msg_queue); msg_queue_push(xui_msg_queue, message, 2, 1); @@ -527,14 +546,17 @@ static void rmenu_xui_set_list_text(int index, const wchar_t* leftText, } } -static void rmenu_xui_render(menu_handle_t *menu) +static void rmenu_xui_render(void) { size_t end, i; char title[PATH_MAX_LENGTH]; const char *dir = NULL, *label = NULL; unsigned menu_type = 0; + menu_handle_t *menu = menu_driver_resolve(); - if (!menu || menu->need_refresh && + if (!menu) + return; + if (menu->need_refresh && g_extern.is_menu && !menu->msg_force) return; @@ -608,40 +630,46 @@ static void rmenu_xui_render(menu_handle_t *menu) if (!str) str = ""; snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str); - rmenu_xui_render_messagebox(menu, msg); + rmenu_xui_render_messagebox(msg); } } -static void rmenu_xui_populate_entries(menu_handle_t *menu, const char *path, +static void rmenu_xui_populate_entries(const char *path, const char *label, unsigned i) { - (void)menu; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + (void)label; (void)path; XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); } -static void rmenu_xui_navigation_clear(menu_handle_t *menu, bool pending_push) +static void rmenu_xui_navigation_clear(bool pending_push) { - (void)pending_push; + menu_handle_t *menu = menu_driver_resolve(); if (menu) XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); } -static void rmenu_xui_navigation_set_visible(menu_handle_t *menu) +static void rmenu_xui_navigation_set_visible(void) { - XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); + menu_handle_t *menu = menu_driver_resolve(); + + if (menu) + XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); } -static void rmenu_xui_navigation_alphabet(menu_handle_t *menu, size_t *ptr_out) +static void rmenu_xui_navigation_alphabet(size_t *ptr_out) { XuiListSetCurSelVisible(m_menulist, *ptr_out); } -static void rmenu_xui_list_insert(menu_handle_t *menu, - file_list_t *list, +static void rmenu_xui_list_insert(file_list_t *list, const char *path, const char *, size_t list_size) { wchar_t buf[PATH_MAX_LENGTH]; @@ -651,8 +679,7 @@ static void rmenu_xui_list_insert(menu_handle_t *menu, XuiListSetText(m_menulist, list_size, buf); } -static void rmenu_xui_list_delete(menu_handle_t *menu, - file_list_t *list, size_t idx, +static void rmenu_xui_list_delete(file_list_t *list, size_t idx, size_t list_size) { int x = XuiListGetItemCount( m_menulist ); @@ -665,7 +692,7 @@ static void rmenu_xui_list_delete(menu_handle_t *menu, XuiListDeleteItems(m_menulist, 0, list_size); } -static void rmenu_xui_list_clear(menu_handle_t *menu, file_list_t *list) +static void rmenu_xui_list_clear(file_list_t *list) { XuiListDeleteItems(m_menulist, 0, XuiListGetItemCount(m_menulist)); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 1cc8bf7d59..236f4e5511 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -234,10 +234,16 @@ static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current) return iy; } -static int xmb_entry_iterate(menu_handle_t *menu, unsigned action) +static int xmb_entry_iterate(unsigned action) { const char *label = NULL; - menu_file_list_cbs_t *cbs = (menu_file_list_cbs_t*) + menu_file_list_cbs_t *cbs = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + + cbs = (menu_file_list_cbs_t*) menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, menu->selection_ptr); @@ -448,9 +454,10 @@ static void xmb_render_background(gl_t *gl, xmb_handle_t *xmb, gl->coords.color = gl->white_color_ptr; } -static void xmb_get_message(menu_handle_t *menu, const char *message) +static void xmb_get_message(const char *message) { xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -463,20 +470,26 @@ static void xmb_get_message(menu_handle_t *menu, const char *message) strlcpy(xmb->box_message, message, sizeof(xmb->box_message)); } -static void xmb_render_messagebox(menu_handle_t *menu, const char *message) +static void xmb_render_messagebox(const char *message) { int x, y; unsigned i; struct string_list *list = NULL; - gl_t *gl = (gl_t*)video_driver_resolve(NULL); + gl_t *gl = NULL; xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; - + xmb = (xmb_handle_t*)menu->userdata; - if (!gl || !xmb) + if (!xmb) + return; + + gl = (gl_t*)video_driver_resolve(NULL); + + if (!gl) return; list = string_split(message, "\n"); @@ -501,11 +514,17 @@ end: string_list_free(list); } -static void xmb_selection_pointer_changed(menu_handle_t *menu) +static void xmb_selection_pointer_changed(void) { int i; unsigned current, end; - xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata; + xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + xmb = (xmb_handle_t*)menu->userdata; if (!xmb) return; @@ -539,9 +558,13 @@ static void xmb_selection_pointer_changed(menu_handle_t *menu) } } -static void xmb_list_open_old(menu_handle_t *menu, xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) +static void xmb_list_open_old(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; for (i = 0; i < file_list_get_size(list); i++) { @@ -562,10 +585,13 @@ static void xmb_list_open_old(menu_handle_t *menu, xmb_handle_t *xmb, file_list_ } } -static void xmb_list_open_new(menu_handle_t *menu, - xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) +static void xmb_list_open_new(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; for (i = 0; i < file_list_get_size(list); i++) { @@ -653,17 +679,27 @@ static xmb_node_t* xmb_get_userdata_from_core(xmb_handle_t *xmb, int i) return node; } -static void xmb_push_animations(menu_handle_t *menu, xmb_node_t *node, float ia, float ix) +static void xmb_push_animations(xmb_node_t *node, float ia, float ix) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; + menu_animation_push(menu->animation, XMB_DELAY, ia, &node->alpha, EASING_IN_OUT_QUAD, NULL); menu_animation_push(menu->animation, XMB_DELAY, ia, &node->label_alpha, EASING_IN_OUT_QUAD, NULL); menu_animation_push(menu->animation, XMB_DELAY, ix, &node->x, EASING_IN_OUT_QUAD, NULL); } -static void xmb_list_switch_old(menu_handle_t *menu, xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) +static void xmb_list_switch_old(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; - size_t end = file_list_get_size(list); + size_t end = 0; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + end = file_list_get_size(list); for (i = 0; i < end; i++) { @@ -674,14 +710,20 @@ static void xmb_list_switch_old(menu_handle_t *menu, xmb_handle_t *xmb, file_lis if (!node) continue; - xmb_push_animations(menu, node, ia, -xmb->icon.spacing.horizontal * dir); + xmb_push_animations(node, ia, -xmb->icon.spacing.horizontal * dir); } } -static void xmb_list_switch_new(menu_handle_t *menu, xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) +static void xmb_list_switch_new(xmb_handle_t *xmb, file_list_t *list, int dir, size_t current) { int i; - size_t end = file_list_get_size(list); + size_t end = 0; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + end = file_list_get_size(list); for (i = 0; i < end; i++) { @@ -699,12 +741,17 @@ static void xmb_list_switch_new(menu_handle_t *menu, xmb_handle_t *xmb, file_lis if (i == current) ia = 1.0; - xmb_push_animations(menu, node, ia, 0); + xmb_push_animations(node, ia, 0); } } -static void xmb_set_title(menu_handle_t *menu, xmb_handle_t *xmb) +static void xmb_set_title(xmb_handle_t *xmb) { + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + if (menu->categories.selection_ptr == 0) { const char *dir = NULL; @@ -729,10 +776,14 @@ static void xmb_set_title(menu_handle_t *menu, xmb_handle_t *xmb) } } -static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) +static void xmb_list_open(xmb_handle_t *xmb) { unsigned j; int dir = -1; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; if (menu->categories.selection_ptr > xmb->categories.selection_ptr_old) dir = 1; @@ -766,15 +817,19 @@ static void xmb_list_open(menu_handle_t *menu, xmb_handle_t *xmb) if (menu->categories.selection_ptr > xmb->categories.selection_ptr_old) dir = 1; - xmb_list_switch_old(menu, xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); - xmb_list_switch_new(menu, xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); + xmb_list_switch_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); + xmb_list_switch_new(xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); xmb->categories.active.idx_old = menu->categories.selection_ptr; } -static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) +static void xmb_list_switch(xmb_handle_t *xmb) { unsigned j; int dir = 0; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; xmb->depth = file_list_get_size(menu->menu_list->menu_stack); @@ -800,8 +855,8 @@ static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) &node->alpha, EASING_IN_OUT_QUAD, NULL); } - xmb_list_open_old(menu, xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); - xmb_list_open_new(menu, xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); + xmb_list_open_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); + xmb_list_open_new(xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); switch (xmb->depth) { @@ -822,14 +877,15 @@ static void xmb_list_switch(menu_handle_t *menu, xmb_handle_t *xmb) xmb->old_depth = xmb->depth; } -static void xmb_populate_entries(menu_handle_t *menu, const char *path, +static void xmb_populate_entries(const char *path, const char *label, unsigned k) { xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; - + xmb = (xmb_handle_t*)menu->userdata; if (!xmb) @@ -841,12 +897,12 @@ static void xmb_populate_entries(menu_handle_t *menu, const char *path, return; } - xmb_set_title(menu, xmb); + xmb_set_title(xmb); if (menu->categories.selection_ptr != xmb->categories.active.idx_old) - xmb_list_open(menu, xmb); + xmb_list_open(xmb); else - xmb_list_switch(menu, xmb); + xmb_list_switch(xmb); } static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, @@ -1016,17 +1072,27 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, } } -static void xmb_frame(menu_handle_t *menu) +static void xmb_frame(void) { int i, depth; char title_msg[PATH_MAX_LENGTH], timedate[PATH_MAX_LENGTH]; const char *core_name = NULL; const char *core_version = NULL; - xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata; + xmb_handle_t *xmb = NULL; + gl_t *gl = NULL; + menu_handle_t *menu = menu_driver_resolve(); - gl_t *gl = (gl_t*)video_driver_resolve(NULL); + if (!menu) + return; - if (!xmb || !gl) + xmb = (xmb_handle_t*)menu->userdata; + + if (!xmb) + return; + + gl = (gl_t*)video_driver_resolve(NULL); + + if (!gl) return; menu_animation_update(menu->animation, 0.002); @@ -1116,7 +1182,7 @@ static void xmb_frame(menu_handle_t *menu) else message_queue = driver.current_msg; - xmb_render_messagebox(menu, message_queue); + xmb_render_messagebox(message_queue); #endif if (menu->keyboard.display) @@ -1129,13 +1195,13 @@ static void xmb_frame(menu_handle_t *menu) snprintf(msg, sizeof(msg), "%s\n%s", menu->keyboard.label, str); xmb_render_background(gl, xmb, true); - xmb_render_messagebox(menu, msg); + xmb_render_messagebox(msg); } if (xmb->box_message[0] != '\0') { xmb_render_background(gl, xmb, true); - xmb_render_messagebox(menu, xmb->box_message); + xmb_render_messagebox(xmb->box_message); xmb->box_message[0] = '\0'; } @@ -1284,9 +1350,10 @@ static bool xmb_font_init_first(const gl_font_renderer_t **font_driver, font_path, xmb_font_size); } -static bool xmb_load_wallpaper(menu_handle_t *menu, const char *path) +static bool xmb_load_wallpaper(const char *path) { xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return false; @@ -1309,7 +1376,7 @@ static bool xmb_load_wallpaper(menu_handle_t *menu, const char *path) return true; } -static void xmb_context_reset(menu_handle_t *menu) +static void xmb_context_reset(void) { int i, k; char bgpath[PATH_MAX_LENGTH]; @@ -1322,6 +1389,7 @@ static void xmb_context_reset(menu_handle_t *menu) gl_t *gl = NULL; xmb_handle_t *xmb = NULL; xmb_node_t *node = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -1398,7 +1466,7 @@ static void xmb_context_reset(menu_handle_t *menu) xmb->textures.list[k].id = menu_texture_load(xmb->textures.list[k].path, TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); - xmb_load_wallpaper(driver.menu, xmb->textures.bg.path); + xmb_load_wallpaper(xmb->textures.bg.path); xmb->settings_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS].id; xmb->settings_node.alpha = xmb->categories.active.alpha; @@ -1459,52 +1527,48 @@ static void xmb_context_reset(menu_handle_t *menu) } } -static void xmb_navigation_clear(menu_handle_t *menu, bool pending_push) +static void xmb_navigation_clear(bool pending_push) { - if (!pending_push) - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_navigation_decrement(menu_handle_t *menu) +static void xmb_navigation_decrement(void) { - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_navigation_increment(menu_handle_t *menu) +static void xmb_navigation_increment(void) { - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_navigation_set(menu_handle_t *menu, bool scroll) +static void xmb_navigation_set(bool scroll) { - (void)scroll; - - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_navigation_set_last(menu_handle_t *menu) +static void xmb_navigation_set_last(void) { - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_navigation_descend_alphabet(menu_handle_t *menu, size_t *unused) +static void xmb_navigation_descend_alphabet(size_t *unused) { - (void)unused; - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_navigation_ascend_alphabet(menu_handle_t *menu, size_t *unused) +static void xmb_navigation_ascend_alphabet(size_t *unused) { - (void)unused; - xmb_selection_pointer_changed(menu); + xmb_selection_pointer_changed(); } -static void xmb_list_insert(menu_handle_t *menu, file_list_t *list, +static void xmb_list_insert(file_list_t *list, const char *path, const char *unused, size_t list_size) { int current = 0, i = list_size; xmb_node_t *node = NULL; xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -1543,9 +1607,8 @@ static void xmb_list_insert(menu_handle_t *menu, file_list_t *list, } } -static void xmb_list_delete(menu_handle_t *menu, - file_list_t *list, size_t idx, - size_t list_size) +static void xmb_list_delete(file_list_t *list, + size_t idx, size_t list_size) { if (!list) return; @@ -1555,11 +1618,16 @@ static void xmb_list_delete(menu_handle_t *menu, list->list[idx].userdata = NULL; } -static void xmb_list_cache(menu_handle_t *menu, - bool horizontal, unsigned action) +static void xmb_list_cache(bool horizontal, unsigned action) { size_t stack_size; - xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata; + xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + xmb = (xmb_handle_t*)menu->userdata; if (!xmb) return; @@ -1599,10 +1667,11 @@ static void xmb_list_cache(menu_handle_t *menu, MENU_SETTING_HORIZONTAL_MENU; } -static void xmb_context_destroy(menu_handle_t *menu) +static void xmb_context_destroy(void) { unsigned i; xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -1627,10 +1696,16 @@ static void xmb_context_destroy(menu_handle_t *menu) } } -static void xmb_toggle(menu_handle_t *menu, bool menu_on) +static void xmb_toggle(bool menu_on) { int i; - xmb_handle_t *xmb = (xmb_handle_t*)menu->userdata; + xmb_handle_t *xmb = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return; + + xmb = (xmb_handle_t*)menu->userdata; if (!xmb) return; diff --git a/menu/menu.c b/menu/menu.c index 5e17ea6405..60a701ed85 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -67,7 +67,7 @@ void menu_update_libretro_info(struct retro_system_info *info) if (*g_settings.libretro_directory) g_extern.core_info = core_info_list_new(g_settings.libretro_directory); if (driver.menu_ctx && driver.menu_ctx->context_reset) - driver.menu_ctx->context_reset(driver.menu); + driver.menu_ctx->context_reset(); rarch_update_system_info(info, NULL); } @@ -131,7 +131,7 @@ bool menu_load_content(void) driver.menu->msg_force = true; if (driver.menu_ctx && driver.menu_ctx->entry_iterate) - driver.menu_ctx->entry_iterate(driver.menu, MENU_ACTION_NOOP); + driver.menu_ctx->entry_iterate(MENU_ACTION_NOOP); draw_frame(); @@ -370,12 +370,12 @@ int menu_iterate(retro_input_t input, int32_t ret = 0; unsigned action = menu_input_frame(input, trigger_input); - if (driver.menu && driver.menu_ctx) + if (driver.menu_ctx) { if (driver.menu_ctx->set_texture) - driver.menu_ctx->set_texture(driver.menu); + driver.menu_ctx->set_texture(); if (driver.menu_ctx->entry_iterate) - ret = driver.menu_ctx->entry_iterate(driver.menu, action); + ret = driver.menu_ctx->entry_iterate(action); } if (g_extern.is_menu) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 04502c23d5..46ee40bc7d 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -160,3 +160,10 @@ void init_menu(void) rarch_fail(1, "init_menu()"); } } + +menu_handle_t *menu_driver_resolve(void) +{ + if (!driver.menu) + return NULL; + return driver.menu; +} diff --git a/menu/menu_driver.h b/menu/menu_driver.h index e453b43a24..2156c9c140 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -68,6 +68,14 @@ struct menu_bind_state bool skip; }; +typedef struct menu_framebuf +{ + uint16_t *data; + unsigned width; + unsigned height; + size_t pitch; +} menu_framebuf_t; + typedef struct { void *userdata; @@ -118,13 +126,7 @@ typedef struct char default_glslp[PATH_MAX_LENGTH]; char default_cgp[PATH_MAX_LENGTH]; - struct - { - uint16_t *data; - unsigned width; - unsigned height; - size_t pitch; - } frame_buf; + menu_framebuf_t frame_buf; const uint8_t *font; bool alloc_font; @@ -195,31 +197,31 @@ typedef struct menu_file_list_cbs typedef struct menu_ctx_driver { - void (*set_texture)(menu_handle_t *menu); - void (*render_messagebox)(menu_handle_t *menu, const char *msg); - void (*render)(menu_handle_t *menu); - void (*frame)(menu_handle_t *menu); + void (*set_texture)(void); + void (*render_messagebox)(const char *msg); + void (*render)(void); + void (*frame)(void); void* (*init)(void); void (*free)(void*); - void (*context_reset)(menu_handle_t *menu); - void (*context_destroy)(menu_handle_t *menu); - void (*populate_entries)(menu_handle_t *menu, const char *path, const char *label, + void (*context_reset)(void); + void (*context_destroy)(void); + void (*populate_entries)(const char *path, const char *label, unsigned k); - void (*toggle)(menu_handle_t *menu, bool); - void (*navigation_clear)(menu_handle_t *menu, bool); - void (*navigation_decrement)(menu_handle_t *menu); - void (*navigation_increment)(menu_handle_t *menu); - void (*navigation_set)(menu_handle_t *menu, bool); - void (*navigation_set_last)(menu_handle_t *menu); - void (*navigation_descend_alphabet)(menu_handle_t *menu, size_t *); - void (*navigation_ascend_alphabet)(menu_handle_t *menu, size_t *); - void (*list_insert)(menu_handle_t *menu, file_list_t *list, const char *, const char *, size_t); - void (*list_delete)(menu_handle_t *menu, file_list_t *list, size_t, size_t); - void (*list_clear)(menu_handle_t *menu, file_list_t *list); - void (*list_cache)(menu_handle_t *menu, bool, unsigned); + void (*toggle)(bool); + void (*navigation_clear)(bool); + void (*navigation_decrement)(void); + void (*navigation_increment)(void); + void (*navigation_set)(bool); + void (*navigation_set_last)(void); + void (*navigation_descend_alphabet)(size_t *); + void (*navigation_ascend_alphabet)(size_t *); + void (*list_insert)(file_list_t *list, const char *, const char *, size_t); + void (*list_delete)(file_list_t *list, size_t, size_t); + void (*list_clear)(file_list_t *list); + void (*list_cache)(bool, unsigned); void (*list_set_selection)(file_list_t *list); - int (*entry_iterate)(menu_handle_t *menu, unsigned); - bool (*load_background)(menu_handle_t *menu, const char * path); + int (*entry_iterate)(unsigned); + bool (*load_background)(const char * path); const char *ident; } menu_ctx_driver_t; @@ -263,6 +265,8 @@ void find_menu_driver(void); void init_menu(void); +menu_handle_t *menu_driver_resolve(void); + #ifdef __cplusplus } #endif diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 65c453bba2..3015e8ebd1 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -122,7 +122,7 @@ int menu_entries_push_list(menu_handle_t *menu, } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -345,7 +345,7 @@ int menu_entries_parse_list( { menu_entries_parse_drive_list(list); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, dir, label, type); + driver.menu_ctx->populate_entries(dir, label, type); return 0; } #if defined(GEKKO) && defined(HW_RVL) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index eea2ff8d75..51be8db759 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -228,7 +228,7 @@ static int load_or_open_zip_iterate(menu_handle_t *menu, unsigned action) && driver.menu_ctx->render_messagebox) { if (*msg && msg[0] != '\0') - driver.menu_ctx->render_messagebox(menu, msg); + driver.menu_ctx->render_messagebox(msg); } switch (action) @@ -546,7 +546,7 @@ static int action_ok_menu_wallpaper_load(const char *path, strlcpy(g_settings.menu.wallpaper, wallpaper_path, sizeof(g_settings.menu.wallpaper)); if (driver.menu_ctx && driver.menu_ctx->load_background) - driver.menu_ctx->load_background(driver.menu, wallpaper_path); + driver.menu_ctx->load_background(wallpaper_path); end: menu_list_pop_stack_by_needle(driver.menu->menu_list, setting->name); @@ -798,7 +798,7 @@ static int deferred_push_core_information(void *data, void *userdata, MENU_SETTINGS_CORE_OPTION_NONE, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -1149,7 +1149,7 @@ static int deferred_push_rdb_entry_detail(void *data, void *userdata, 0, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, + driver.menu_ctx->populate_entries(path, str_list->elems[0].data, type); ret = 0; @@ -2104,7 +2104,7 @@ static int action_toggle_mainmenu(unsigned type, const char *label, { case 1: if (driver.menu_ctx->list_cache) - driver.menu_ctx->list_cache(menu, true, action); + driver.menu_ctx->list_cache(true, action); if (cbs && cbs->action_content_list_switch) return cbs->action_content_list_switch( @@ -2793,7 +2793,7 @@ static int deferred_push_core_information(void *data, void *userdata, MENU_SETTINGS_CORE_OPTION_NONE, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -2815,7 +2815,7 @@ static int deferred_push_performance_counters(void *data, void *userdata, MENU_SETTING_ACTION, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -2852,7 +2852,7 @@ static int deferred_push_video_shader_parameters_common(void *data, void *userda } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -2937,7 +2937,7 @@ static int deferred_push_settings(void *data, void *userdata, } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3004,7 +3004,7 @@ static int deferred_push_settings_subgroup(void *data, void *userdata, } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3066,7 +3066,7 @@ static int deferred_push_shader_options(void *data, void *userdata, } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3098,7 +3098,7 @@ static int deferred_push_options(void *data, void *userdata, MENU_SETTING_ACTION, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3122,7 +3122,7 @@ static int deferred_push_management_options(void *data, void *userdata, #endif if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3161,7 +3161,7 @@ static int push_perfcounter_generic( push_perfcounter(driver.menu, list, counters, num, ident); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3224,7 +3224,7 @@ static int deferred_push_core_cheat_options(void *data, void *userdata, } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3267,7 +3267,7 @@ static int deferred_push_core_input_remapping_options(void *data, void *userdata } if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3299,7 +3299,7 @@ static int deferred_push_core_options(void *data, void *userdata, MENU_SETTINGS_CORE_OPTION_NONE, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3323,7 +3323,7 @@ static int deferred_push_disk_options(void *data, void *userdata, MENU_SETTINGS_CORE_DISK_OPTIONS_DISK_IMAGE_APPEND, 0); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(driver.menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } @@ -3787,7 +3787,7 @@ static int action_iterate_help(const char *label, unsigned action) return 0; if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(menu); + driver.menu_ctx->render(); for (i = 0; i < ARRAY_SIZE(binds); i++) { @@ -3825,7 +3825,7 @@ static int action_iterate_help(const char *label, unsigned action) desc[0], desc[1], desc[2], desc[3], desc[4], desc[5], desc[6], desc[7]); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(menu, msg); + driver.menu_ctx->render_messagebox(msg); if (action == MENU_ACTION_OK) menu_list_pop(menu->menu_list->menu_stack, NULL); @@ -3848,7 +3848,7 @@ static int action_iterate_info(const char *label, unsigned action) list = (file_list_t*)menu->menu_list->selection_buf; if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(menu); + driver.menu_ctx->render(); current_setting = (rarch_setting_t*)setting_data_find_setting( menu->list_settings, @@ -3880,7 +3880,7 @@ static int action_iterate_info(const char *label, unsigned action) driver.menu_ctx->render_messagebox) { if (*msg && msg[0] != '\0') - driver.menu_ctx->render_messagebox(menu, msg); + driver.menu_ctx->render_messagebox(msg); } if (action == MENU_ACTION_OK) @@ -4041,7 +4041,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) menu_list_get_last_stack(menu->menu_list, NULL, &label, &type); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(menu); + driver.menu_ctx->render(); if (g_settings.video.scale_integer) { @@ -4072,7 +4072,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(menu, msg); + driver.menu_ctx->render_messagebox(msg); if (!custom->width) custom->width = stride_x; @@ -4110,7 +4110,7 @@ static int action_iterate_message(const char *label, unsigned action) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(menu, menu->message_contents); + driver.menu_ctx->render_messagebox(menu->message_contents); if (action == MENU_ACTION_OK) menu_list_pop_stack(menu->menu_list); @@ -4272,7 +4272,7 @@ static int action_iterate_main(const char *label, unsigned action) ret = mouse_post_iterate(cbs, path_offset, label_offset, type_offset, action); if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(menu); + driver.menu_ctx->render(); /* Have to defer it so we let settings refresh. */ if (menu->push_start_screen) diff --git a/menu/menu_input.c b/menu/menu_input.c index 94abbdc3ed..cf19ca0d28 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -359,7 +359,7 @@ int menu_input_bind_iterate(menu_handle_t *menu) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(menu); + driver.menu_ctx->render(); snprintf(msg, sizeof(msg), "[%s]\npress joypad\n(RETURN to skip)", input_config_bind_map[ @@ -367,7 +367,7 @@ int menu_input_bind_iterate(menu_handle_t *menu) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(menu, msg); + driver.menu_ctx->render_messagebox( msg); driver.block_input = true; menu_input_poll_bind_state(&binds); @@ -401,7 +401,7 @@ int menu_input_bind_iterate_keyboard(menu_handle_t *menu) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) - driver.menu_ctx->render(menu); + driver.menu_ctx->render(); current = rarch_get_time_usec(); timeout = (menu->binds.timeout_end - current) / 1000000; @@ -412,7 +412,7 @@ int menu_input_bind_iterate_keyboard(menu_handle_t *menu) if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox) - driver.menu_ctx->render_messagebox(menu, msg); + driver.menu_ctx->render_messagebox(msg); if (timeout <= 0) { diff --git a/menu/menu_list.c b/menu/menu_list.c index 2ed31e94da..4cc037068d 100644 --- a/menu/menu_list.c +++ b/menu/menu_list.c @@ -136,7 +136,7 @@ void menu_list_destroy(file_list_t *list) for (i = 0; i < list->size; i++) { if (driver.menu_ctx->list_delete) - driver.menu_ctx->list_delete(driver.menu, list, i, list->size); + driver.menu_ctx->list_delete(list, i, list->size); menu_common_list_delete(list, i, list->size); } @@ -271,7 +271,7 @@ void menu_list_pop_stack(menu_list_t *list) return; if (driver.menu_ctx->list_cache) - driver.menu_ctx->list_cache(driver.menu, false, 0); + driver.menu_ctx->list_cache(false, 0); menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); driver.menu->need_refresh = true; @@ -307,7 +307,7 @@ void menu_list_pop(file_list_t *list, size_t *directory_ptr) size_t list_size = list->size - 1; if (driver.menu_ctx->list_delete) - driver.menu_ctx->list_delete(driver.menu, list, list_size, list_size); + driver.menu_ctx->list_delete(list, list_size, list_size); menu_common_list_delete(list, list_size, list_size); } @@ -329,7 +329,7 @@ void menu_list_clear(file_list_t *list) goto end; if (driver.menu_ctx->list_clear) - driver.menu_ctx->list_clear(driver.menu, list); + driver.menu_ctx->list_clear(list); end: menu_common_list_clear(list); @@ -343,7 +343,7 @@ static void menu_list_insert(file_list_t *list, return; if (driver.menu_ctx->list_insert) - driver.menu_ctx->list_insert(driver.menu, list, path, label, list->size - 1); + driver.menu_ctx->list_insert(list, path, label, list->size - 1); menu_common_list_insert(list, path, label, type, list->size - 1); } @@ -387,7 +387,7 @@ int menu_list_push_stack_refresh(menu_list_t *list, return -1; if (driver.menu_ctx->list_cache) - driver.menu_ctx->list_cache(driver.menu, false, 0); + driver.menu_ctx->list_cache(false, 0); menu_list_push_stack(list, path, label, type, directory_ptr); menu_navigation_clear(driver.menu, true); @@ -427,7 +427,7 @@ int menu_list_populate_generic(void *data, menu_entries_refresh(menu, list); if (driver.menu_ctx && driver.menu_ctx->populate_entries) - driver.menu_ctx->populate_entries(menu, path, label, type); + driver.menu_ctx->populate_entries(path, label, type); return 0; } diff --git a/menu/menu_navigation.c b/menu/menu_navigation.c index 91319321ed..14336f3aba 100644 --- a/menu/menu_navigation.c +++ b/menu/menu_navigation.c @@ -34,7 +34,7 @@ void menu_navigation_clear(menu_handle_t *menu, bool pending_push) menu->selection_ptr = 0; if (driver.menu_ctx && driver.menu_ctx->navigation_clear) - driver.menu_ctx->navigation_clear(menu, pending_push); + driver.menu_ctx->navigation_clear(pending_push); } /** @@ -48,7 +48,7 @@ void menu_navigation_decrement(menu_handle_t *menu) menu->selection_ptr--; if (driver.menu_ctx && driver.menu_ctx->navigation_decrement) - driver.menu_ctx->navigation_decrement(menu); + driver.menu_ctx->navigation_decrement(); } /** @@ -62,7 +62,7 @@ void menu_navigation_increment(menu_handle_t *menu) menu->selection_ptr++; if (driver.menu_ctx && driver.menu_ctx->navigation_increment) - driver.menu_ctx->navigation_increment(menu); + driver.menu_ctx->navigation_increment(); } /** @@ -78,7 +78,7 @@ void menu_navigation_set(menu_handle_t *menu, size_t idx, bool scroll) menu->selection_ptr = idx; if (driver.menu_ctx && driver.menu_ctx->navigation_set) - driver.menu_ctx->navigation_set(menu, scroll); + driver.menu_ctx->navigation_set(scroll); } /** @@ -92,7 +92,7 @@ void menu_navigation_set_last(menu_handle_t *menu) menu->selection_ptr = menu_list_get_size(driver.menu->menu_list) - 1; if (driver.menu_ctx && driver.menu_ctx->navigation_set_last) - driver.menu_ctx->navigation_set_last(menu); + driver.menu_ctx->navigation_set_last(); } /** @@ -124,7 +124,7 @@ void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out) *ptr_out = menu->scroll.indices.list[i - 1]; if (driver.menu_ctx && driver.menu_ctx->navigation_descend_alphabet) - driver.menu_ctx->navigation_descend_alphabet(menu, ptr_out); + driver.menu_ctx->navigation_descend_alphabet(ptr_out); } /** @@ -155,5 +155,5 @@ void menu_navigation_ascend_alphabet(menu_handle_t *menu, size_t *ptr_out) *ptr_out = menu->scroll.indices.list[i + 1]; if (driver.menu_ctx && driver.menu_ctx->navigation_descend_alphabet) - driver.menu_ctx->navigation_descend_alphabet(menu, ptr_out); + driver.menu_ctx->navigation_descend_alphabet(ptr_out); } diff --git a/retroarch.c b/retroarch.c index 06ceb70dda..f47b2fffd2 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1958,8 +1958,8 @@ void rarch_main_set_state(unsigned cmd) if (!driver.menu) return; - if (driver.menu && driver.menu_ctx && driver.menu_ctx->toggle) - driver.menu_ctx->toggle(driver.menu, true); + if (driver.menu_ctx && driver.menu_ctx->toggle) + driver.menu_ctx->toggle(true); /* Menu should always run with vsync on. */ rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE); @@ -1993,8 +1993,8 @@ void rarch_main_set_state(unsigned cmd) #ifdef HAVE_MENU menu_apply_deferred_settings(); - if (driver.menu && driver.menu_ctx && driver.menu_ctx->toggle) - driver.menu_ctx->toggle(driver.menu, false); + if (driver.menu_ctx && driver.menu_ctx->toggle) + driver.menu_ctx->toggle(false); g_extern.is_menu = false; From d1483d1530e82a42e39a4619cce5020dc36e6f2a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 19:11:53 +0100 Subject: [PATCH 135/147] (GX) Buildfix --- gfx/drivers/gx_gfx.c | 32 ++++++++++++++++++-------------- menu/menu.c | 5 +++-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index 9bb1b66bda..0d26faa34c 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -18,7 +18,7 @@ #include "../../driver.h" #include "../../general.h" #include "../drivers_font_renderer/bitmap.h" -#include "../../menu/menu.h" +#include "../../menu/menu_driver.h" #include "../video_viewport.h" #include "../video_monitor.h" @@ -118,6 +118,7 @@ void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines) max_width, max_height, i; bool progressive; gx_video_t *gx = (gx_video_t*)data; + menu_handle_t *menu = menu_driver_resolve(); (void)level; @@ -277,17 +278,17 @@ void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines) gx_mode.efbHeight, (gx_mode.viTVMode & 3) == VI_INTERLACE ? "interlaced" : "progressive"); - if (driver.menu) + if (menu) { - driver.menu->height = gx_mode.efbHeight / (gx->double_strike ? 1 : 2); - driver.menu->height &= ~3; - if (driver.menu->height > 240) - driver.menu->height = 240; + menu->frame_buf.height = gx_mode.efbHeight / (gx->double_strike ? 1 : 2); + menu->frame_buf.height &= ~3; + if (menu->frame_buf.height > 240) + menu->frame_buf.height = 240; - driver.menu->width = gx_mode.fbWidth / (gx_mode.fbWidth < 400 ? 1 : 2); - driver.menu->width &= ~3; - if (driver.menu->width > 400) - driver.menu->width = 400; + menu->frame_buf.width = gx_mode.fbWidth / (gx_mode.fbWidth < 400 ? 1 : 2); + menu->frame_buf.width &= ~3; + if (menu->frame_buf.width > 400) + menu->frame_buf.width = 400; } if (tvmode == VI_PAL) @@ -366,8 +367,8 @@ static void init_texture(void *data, unsigned width, unsigned height) if (driver.menu) { - menu_w = driver.menu->width; - menu_h = driver.menu->height; + menu_w = driver.menu->frame_buf.width; + menu_h = driver.menu->frame_buf.height; } __GX_InitTexObj(fb_ptr, g_tex.data, width, height, @@ -961,9 +962,12 @@ static bool gx_frame(void *data, const void *frame, if (gx->menu_texture_enable && gx->menu_data) { convert_texture16(gx->menu_data, menu_tex.data, - driver.menu->width, driver.menu->height, driver.menu->width * 2); + driver.menu->frame_buf.width, + driver.menu->frame_buf.height, + driver.menu->frame_buf.width * 2); DCFlushRange(menu_tex.data, - driver.menu->width * driver.menu->height * 2); + driver.menu->frame_buf.width * + driver.menu->frame_buf.height * 2); } __GX_InvalidateTexAll(__gx); diff --git a/menu/menu.c b/menu/menu.c index 60a701ed85..a95c7506fe 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -293,11 +293,12 @@ void menu_free(void *data) void menu_apply_deferred_settings(void) { rarch_setting_t *setting = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!driver.menu) + if (!menu) return; - setting = (rarch_setting_t*)driver.menu->list_settings; + setting = (rarch_setting_t*)menu->list_settings; if (!setting) return; From 4bc117222b732b2e025fc1d98d400c83f50b1640 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 19:44:08 +0100 Subject: [PATCH 136/147] Cleanup menu_entries_cbs.c - don't use driver.menu directly - always go through menu_driver_resolve --- menu/menu_entries_cbs.c | 794 +++++++++++++++++++++++++++------------- 1 file changed, 534 insertions(+), 260 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 51be8db759..652ca4a465 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -165,8 +165,12 @@ static int archive_open(menu_handle_t *menu) return 0; } -static void common_load_content(menu_handle_t *menu, bool persist) +static void common_load_content(bool persist) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; + rarch_main_command(persist ? RARCH_CMD_LOAD_CONTENT_PERSIST : RARCH_CMD_LOAD_CONTENT); menu_list_flush_stack(menu->menu_list, MENU_SETTINGS); @@ -199,7 +203,7 @@ static int archive_load(menu_handle_t *menu) { case -1: rarch_main_command(RARCH_CMD_LOAD_CORE); - common_load_content(menu, false); + common_load_content(false); break; case 0: menu_list_push_stack_refresh( @@ -254,10 +258,11 @@ int menu_action_setting_set_current_string( static int action_ok_rdb_playlist_entry(const char *path, const char *label, unsigned type, size_t idx) { - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; - rarch_playlist_load_content(driver.menu->db_playlist, + rarch_playlist_load_content(menu->db_playlist, rdb_entry_start_game_selection_ptr); return -1; } @@ -265,12 +270,13 @@ static int action_ok_rdb_playlist_entry(const char *path, static int action_ok_playlist_entry(const char *path, const char *label, unsigned type, size_t idx) { - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; rarch_playlist_load_content(g_defaults.history, - driver.menu->selection_ptr); - menu_list_flush_stack(driver.menu->menu_list, MENU_SETTINGS); + menu->selection_ptr); + menu_list_flush_stack(menu->menu_list, MENU_SETTINGS); return -1; } @@ -296,23 +302,23 @@ static int action_ok_shader_pass_load(const char *path, const char *label, unsigned type, size_t idx) { const char *menu_path = NULL; - - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; (void)menu_path; #ifdef HAVE_SHADER_MANAGER - menu_list_get_last_stack(driver.menu->menu_list, &menu_path, NULL, + menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); - fill_pathname_join(driver.menu->shader->pass[hack_shader_pass].source.path, + fill_pathname_join(menu->shader->pass[hack_shader_pass].source.path, menu_path, path, - sizeof(driver.menu->shader->pass[hack_shader_pass].source.path)); + sizeof(menu->shader->pass[hack_shader_pass].source.path)); /* This will reset any changed parameters. */ - video_shader_resolve_parameters(NULL, driver.menu->shader); - menu_list_flush_stack_by_needle(driver.menu->menu_list, "shader_options"); + video_shader_resolve_parameters(NULL, menu->shader); + menu_list_flush_stack_by_needle(menu->menu_list, "shader_options"); return 0; #else return -1; @@ -327,9 +333,12 @@ static int action_ok_shader_pass(const char *path, const char *label, unsigned type, size_t idx) { hack_shader_pass = type - MENU_SETTINGS_SHADER_PASS_0; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, g_settings.video.shader_dir, label, type, @@ -339,8 +348,11 @@ static int action_ok_shader_pass(const char *path, static int action_ok_shader_parameters(const char *path, const char *label, unsigned type, size_t idx) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, "", label, MENU_SETTING_ACTION, idx); } @@ -348,27 +360,38 @@ static int action_ok_shader_parameters(const char *path, static int action_ok_push_generic_list(const char *path, const char *label, unsigned type, size_t idx) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + if (path) - strlcpy(driver.menu->deferred_path, path, - sizeof(driver.menu->deferred_path)); + strlcpy(menu->deferred_path, path, + sizeof(menu->deferred_path)); + return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, "", label, type, idx); } static int action_ok_push_default(const char *path, const char *label, unsigned type, size_t idx) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, label, label, type, idx); } static int action_ok_shader_preset(const char *path, const char *label, unsigned type, size_t idx) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, g_settings.video.shader_dir, label, type, idx); } @@ -376,8 +399,11 @@ static int action_ok_shader_preset(const char *path, static int action_ok_push_content_list(const char *path, const char *label, unsigned type, size_t idx) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, g_settings.menu_content_directory, label, MENU_FILE_DIRECTORY, idx); } @@ -385,8 +411,11 @@ static int action_ok_push_content_list(const char *path, static int action_ok_disk_image_append_list(const char *path, const char *label, unsigned type, size_t idx) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, g_settings.menu_content_directory, label, type, idx); } @@ -395,8 +424,12 @@ static int action_ok_configurations_list(const char *path, const char *label, unsigned type, size_t idx) { const char *dir = g_settings.menu_config_directory; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, dir ? dir : label, label, type, idx); } @@ -404,14 +437,19 @@ static int action_ok_configurations_list(const char *path, static int action_ok_cheat_file(const char *path, const char *label, unsigned type, size_t idx) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + if (!path_file_exists(g_settings.cheat_database)) { msg_queue_clear(g_extern.msg_queue); msg_queue_push(g_extern.msg_queue, "Cheat Directory doesn't exist or cannot be accessed.\n", 1, 180); return -1; } + return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, g_settings.cheat_database, label, type, idx); } @@ -443,6 +481,10 @@ static int action_ok_video_filter(const char *path, static int action_ok_remap_file(const char *path, const char *label, unsigned type, size_t idx) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + if (!path_file_exists(g_settings.input_remapping_directory)) { msg_queue_clear(g_extern.msg_queue); @@ -450,7 +492,7 @@ static int action_ok_remap_file(const char *path, return -1; } return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, g_settings.input_remapping_directory, label, type, idx); } @@ -458,6 +500,10 @@ static int action_ok_remap_file(const char *path, static int action_ok_core_list(const char *path, const char *label, unsigned type, size_t idx) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + if (!path_file_exists(g_settings.libretro_directory)) { msg_queue_clear(g_extern.msg_queue); @@ -465,7 +511,7 @@ static int action_ok_core_list(const char *path, return -1; } return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, g_settings.libretro_directory, label, type, idx); } @@ -475,18 +521,20 @@ static int action_ok_remap_file_load(const char *path, { const char *menu_path = NULL; char remap_path[PATH_MAX_LENGTH]; - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; (void)remap_path; (void)menu_path; - menu_list_get_last_stack(driver.menu->menu_list, &menu_path, NULL, + + menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); fill_pathname_join(remap_path, menu_path, path, sizeof(remap_path)); input_remapping_load_file(remap_path); - menu_list_flush_stack_by_needle(driver.menu->menu_list, "core_input_remapping_options"); + menu_list_flush_stack_by_needle(menu->menu_list, "core_input_remapping_options"); return 0; } @@ -496,12 +544,13 @@ static int action_ok_cheat_file_load(const char *path, { const char *menu_path = NULL; char cheat_path[PATH_MAX_LENGTH]; - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; (void)cheat_path; (void)menu_path; - menu_list_get_last_stack(driver.menu->menu_list, &menu_path, NULL, + menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); fill_pathname_join(cheat_path, menu_path, path, sizeof(cheat_path)); @@ -514,7 +563,7 @@ static int action_ok_cheat_file_load(const char *path, if (!g_extern.cheat) return -1; - menu_list_flush_stack_by_needle(driver.menu->menu_list, "core_cheat_options"); + menu_list_flush_stack_by_needle(menu->menu_list, "core_cheat_options"); return 0; } @@ -526,11 +575,11 @@ static int action_ok_menu_wallpaper_load(const char *path, const char *menu_path = NULL; rarch_setting_t *setting = NULL; char wallpaper_path[PATH_MAX_LENGTH]; - - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; - menu_list_get_last_stack(driver.menu->menu_list, &menu_path, &menu_label, + menu_list_get_last_stack(menu->menu_list, &menu_path, &menu_label, NULL); setting = menu_action_find_setting(menu_label); @@ -549,7 +598,7 @@ static int action_ok_menu_wallpaper_load(const char *path, driver.menu_ctx->load_background(wallpaper_path); end: - menu_list_pop_stack_by_needle(driver.menu->menu_list, setting->name); + menu_list_pop_stack_by_needle(menu->menu_list, setting->name); return 0; } @@ -559,20 +608,21 @@ static int action_ok_shader_preset_load(const char *path, { const char *menu_path = NULL; char shader_path[PATH_MAX_LENGTH]; - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; (void)shader_path; (void)menu_path; #ifdef HAVE_SHADER_MANAGER - menu_list_get_last_stack(driver.menu->menu_list, &menu_path, NULL, + menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); fill_pathname_join(shader_path, menu_path, path, sizeof(shader_path)); - menu_shader_manager_set_preset(driver.menu->shader, + menu_shader_manager_set_preset(menu->shader, video_shader_parse_type(shader_path, RARCH_SHADER_NONE), shader_path); - menu_list_flush_stack_by_needle(driver.menu->menu_list, "shader_options"); + menu_list_flush_stack_by_needle(menu->menu_list, "shader_options"); return 0; #else return -1; @@ -582,7 +632,10 @@ static int action_ok_shader_preset_load(const char *path, static int action_ok_cheat(const char *path, const char *label, unsigned type, size_t idx) { - menu_input_key_start_line(driver.menu, "Input Cheat", + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + menu_input_key_start_line(menu, "Input Cheat", label, type, idx, menu_input_st_cheat_callback); return 0; } @@ -590,7 +643,10 @@ static int action_ok_cheat(const char *path, static int action_ok_shader_preset_save_as(const char *path, const char *label, unsigned type, size_t idx) { - menu_input_key_start_line(driver.menu, "Preset Filename", + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + menu_input_key_start_line(menu, "Preset Filename", label, type, idx, menu_input_st_string_callback); return 0; } @@ -598,7 +654,10 @@ static int action_ok_shader_preset_save_as(const char *path, static int action_ok_cheat_file_save_as(const char *path, const char *label, unsigned type, size_t idx) { - menu_input_key_start_line(driver.menu, "Cheat Filename", + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + menu_input_key_start_line(menu, "Cheat Filename", label, type, idx, menu_input_st_string_callback); return 0; } @@ -606,7 +665,10 @@ static int action_ok_cheat_file_save_as(const char *path, static int action_ok_remap_file_save_as(const char *path, const char *label, unsigned type, size_t idx) { - menu_input_key_start_line(driver.menu, "Remapping Filename", + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + menu_input_key_start_line(menu, "Remapping Filename", label, type, idx, menu_input_st_string_callback); return 0; } @@ -617,11 +679,11 @@ static int action_ok_path_use_directory(const char *path, const char *menu_label = NULL; const char *menu_path = NULL; rarch_setting_t *setting = NULL; - - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; - menu_list_get_last_stack(driver.menu->menu_list, + menu_list_get_last_stack(menu->menu_list, &menu_path, &menu_label, NULL); setting = menu_action_find_setting(menu_label); @@ -633,7 +695,7 @@ static int action_ok_path_use_directory(const char *path, return -1; menu_action_setting_set_current_string(setting, menu_path); - menu_list_pop_stack_by_needle(driver.menu->menu_list, setting->name); + menu_list_pop_stack_by_needle(menu->menu_list, setting->name); return 0; } @@ -641,15 +703,16 @@ static int action_ok_path_use_directory(const char *path, static int action_ok_core_load_deferred(const char *path, const char *label, unsigned type, size_t idx) { - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; if (path) strlcpy(g_settings.libretro, path, sizeof(g_settings.libretro)); - strlcpy(g_extern.fullpath, driver.menu->deferred_path, + strlcpy(g_extern.fullpath, menu->deferred_path, sizeof(g_extern.fullpath)); - common_load_content(driver.menu, false); + common_load_content(false); return -1; } @@ -901,9 +964,16 @@ static int deferred_push_rdb_entry_detail(void *data, void *userdata, unsigned i, j; int ret = 0; database_info_list_t *db_info = NULL; - file_list_t *list = (file_list_t*)data; - file_list_t *menu_list = (file_list_t*)userdata; - struct string_list *str_list = string_split(label, "|"); + file_list_t *list = NULL; + file_list_t *menu_list = NULL; + struct string_list *str_list = NULL; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + + list = (file_list_t*)data; + menu_list = (file_list_t*)userdata; + str_list = string_split(label, "|"); if (!str_list) return -1; @@ -935,7 +1005,7 @@ static int deferred_push_rdb_entry_detail(void *data, void *userdata, menu_database_realloc(driver.menu, path_rdl, false); - playlist = driver.menu->db_playlist; + playlist = menu->db_playlist; for (i = 0; i < db_info->count; i++) { @@ -1167,11 +1237,15 @@ static int action_ok_rdb_entry(const char *path, const char *label, unsigned type, size_t idx) { char tmp[PATH_MAX_LENGTH]; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + strlcpy(tmp, "deferred_rdb_entry_detail|", sizeof(tmp)); strlcat(tmp, path, sizeof(tmp)); return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, label, tmp, 0, idx); @@ -1187,22 +1261,23 @@ static int action_ok_core_load(const char *path, const char *label, unsigned type, size_t idx) { const char *menu_path = NULL; - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; - menu_list_get_last_stack(driver.menu->menu_list, + menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); fill_pathname_join(g_settings.libretro, menu_path, path, sizeof(g_settings.libretro)); rarch_main_command(RARCH_CMD_LOAD_CORE); - menu_list_flush_stack(driver.menu->menu_list, MENU_SETTINGS); + menu_list_flush_stack(menu->menu_list, MENU_SETTINGS); #if defined(HAVE_DYNAMIC) /* No content needed for this core, load core immediately. */ - if (driver.menu->load_no_content) + if (menu->load_no_content) { *g_extern.fullpath = '\0'; - common_load_content(driver.menu, false); + common_load_content(false); return -1; } @@ -1224,11 +1299,12 @@ static int action_ok_core_download(const char *path, static int action_ok_compressed_archive_push(const char *path, const char *label, unsigned type, size_t idx) { - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; menu_list_push_stack( - driver.menu->menu_list, + menu->menu_list, path, "load_open_zip", 0, @@ -1243,19 +1319,19 @@ static int action_ok_directory_push(const char *path, const char *menu_path = NULL; const char *menu_label = NULL; char cat_path[PATH_MAX_LENGTH]; - - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; if (!path) return -1; - menu_list_get_last_stack(driver.menu->menu_list, + menu_list_get_last_stack(menu->menu_list, &menu_path, &menu_label, NULL); fill_pathname_join(cat_path, menu_path, path, sizeof(cat_path)); - return menu_list_push_stack_refresh(driver.menu->menu_list, + return menu_list_push_stack_refresh(menu->menu_list, cat_path, menu_label, type, idx); } @@ -1263,6 +1339,9 @@ static int action_ok_database_manager_list(const char *path, const char *label, unsigned type, size_t idx) { char rdb_path[PATH_MAX_LENGTH]; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; if (!path) return -1; if (!label) @@ -1280,7 +1359,7 @@ static int action_ok_database_manager_list(const char *path, return -1; } return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, rdb_path, "deferred_database_manager_list", 0, idx); @@ -1290,6 +1369,10 @@ static int action_ok_cursor_manager_list(const char *path, const char *label, unsigned type, size_t idx) { char cursor_path[PATH_MAX_LENGTH]; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; fill_pathname_join(cursor_path, g_settings.cursor_directory, path, sizeof(cursor_path)); @@ -1303,7 +1386,7 @@ static int action_ok_cursor_manager_list(const char *path, return -1; } return menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, cursor_path, "deferred_cursor_manager_list", 0, idx); @@ -1314,19 +1397,20 @@ static int action_ok_config_load(const char *path, { const char *menu_path = NULL; char config[PATH_MAX_LENGTH]; + menu_handle_t *menu = menu_driver_resolve(); - if (!driver.menu) + if (!menu) return -1; - menu_list_get_last_stack(driver.menu->menu_list, + menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); fill_pathname_join(config, menu_path, path, sizeof(config)); - menu_list_flush_stack(driver.menu->menu_list, MENU_SETTINGS); - driver.menu->msg_force = true; + menu_list_flush_stack(menu->menu_list, MENU_SETTINGS); + menu->msg_force = true; if (rarch_replace_config(config)) { - menu_navigation_clear(driver.menu, false); + menu_navigation_clear(menu, false); return -1; } @@ -1336,13 +1420,14 @@ static int action_ok_config_load(const char *path, static int action_ok_disk_image_append(const char *path, const char *label, unsigned type, size_t idx) { - const char *menu_path = NULL; char image[PATH_MAX_LENGTH]; + const char *menu_path = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!driver.menu) + if (!menu) return -1; - menu_list_get_last_stack(driver.menu->menu_list, + menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); fill_pathname_join(image, menu_path, path, sizeof(image)); @@ -1350,36 +1435,37 @@ static int action_ok_disk_image_append(const char *path, rarch_main_command(RARCH_CMD_RESUME); - menu_list_flush_stack(driver.menu->menu_list, MENU_SETTINGS); + menu_list_flush_stack(menu->menu_list, MENU_SETTINGS); return -1; } static int action_ok_file_load_with_detect_core(const char *path, const char *label, unsigned type, size_t idx) { - const char *menu_path = NULL; int ret; + const char *menu_path = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!driver.menu) + if (!menu) return -1; - menu_list_get_last_stack(driver.menu->menu_list, + menu_list_get_last_stack(menu->menu_list, &menu_path, NULL, NULL); ret = rarch_defer_core(g_extern.core_info, - menu_path, path, label, driver.menu->deferred_path, - sizeof(driver.menu->deferred_path)); + menu_path, path, label, menu->deferred_path, + sizeof(menu->deferred_path)); if (ret == -1) { rarch_main_command(RARCH_CMD_LOAD_CORE); - common_load_content(driver.menu, false); + common_load_content(false); return -1; } if (ret == 0) menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, g_settings.libretro_directory, "deferred_core_list", 0, idx); @@ -1401,11 +1487,12 @@ static int action_ok_file_load(const char *path, const char *menu_label = NULL; const char *menu_path = NULL; rarch_setting_t *setting = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!driver.menu) + if (!menu) return -1; - menu_list_get_last(driver.menu->menu_list->menu_stack, + menu_list_get_last(menu->menu_list->menu_stack, &menu_path, &menu_label, NULL); setting = menu_action_find_setting(menu_label); @@ -1413,7 +1500,7 @@ static int action_ok_file_load(const char *path, if (setting && setting->type == ST_PATH) { menu_action_setting_set_current_string_path(setting, menu_path, path); - menu_list_pop_stack_by_needle(driver.menu->menu_list, setting->name); + menu_list_pop_stack_by_needle(menu->menu_list, setting->name); } else { @@ -1424,7 +1511,7 @@ static int action_ok_file_load(const char *path, fill_pathname_join(g_extern.fullpath, menu_path, path, sizeof(g_extern.fullpath)); - common_load_content(driver.menu, true); + common_load_content(true); return -1; } @@ -1438,11 +1525,12 @@ static int action_ok_set_path(const char *path, const char *menu_path = NULL; const char *menu_label = NULL; rarch_setting_t *setting = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!driver.menu) + if (!menu) return -1; - menu_list_get_last_stack(driver.menu->menu_list, + menu_list_get_last_stack(menu->menu_list, &menu_path, &menu_label, NULL); setting = menu_action_find_setting(menu_label); @@ -1451,7 +1539,7 @@ static int action_ok_set_path(const char *path, return -1; menu_action_setting_set_current_string_path(setting, menu_path, path); - menu_list_pop_stack_by_needle(driver.menu->menu_list, setting->name); + menu_list_pop_stack_by_needle(menu->menu_list, setting->name); return 0; } @@ -1459,12 +1547,18 @@ static int action_ok_set_path(const char *path, static int action_ok_custom_viewport(const char *path, const char *label, unsigned type, size_t idx) { + rarch_viewport_t *custom = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + /* Start with something sane. */ - rarch_viewport_t *custom = (rarch_viewport_t*) + custom = (rarch_viewport_t*) &g_extern.console.screen.viewports.custom_vp; menu_list_push_stack( - driver.menu->menu_list, + menu->menu_list, "", "custom_viewport_1", MENU_SETTINGS_CUSTOM_VIEWPORT, @@ -1486,8 +1580,6 @@ static int action_ok_custom_viewport(const char *path, static int generic_action_ok_command(unsigned cmd) { - if (!driver.menu) - return -1; if (!rarch_main_command(cmd)) return -1; @@ -1661,12 +1753,17 @@ static int action_ok_screenshot(const char *path, static int action_ok_file_load_or_resume(const char *path, const char *label, unsigned type, size_t idx) { - if (!strcmp(driver.menu->deferred_path, g_extern.fullpath)) + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + + if (!strcmp(menu->deferred_path, g_extern.fullpath)) return generic_action_ok_command(RARCH_CMD_RESUME); else { strlcpy(g_extern.fullpath, - driver.menu->deferred_path, sizeof(g_extern.fullpath)); + menu->deferred_path, sizeof(g_extern.fullpath)); rarch_main_command(RARCH_CMD_LOAD_CORE); rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT); return -1; @@ -1695,6 +1792,10 @@ static int action_ok_rdb_entry_submenu(const char *path, int len = 0; struct string_list *str_list = NULL; struct string_list *str_list2 = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; if (!label) return -1; @@ -1737,7 +1838,7 @@ static int action_ok_rdb_entry_submenu(const char *path, strlcat(new_label, str_list->elems[0].data, sizeof(new_label)); ret = menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, rdb, new_label, 0, idx); @@ -1758,8 +1859,12 @@ static int action_cancel_lookup_setting(const char *path, static int action_cancel_pop_default(const char *path, const char *label, unsigned type, size_t idx) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + menu_apply_deferred_settings(); - menu_list_pop_stack(driver.menu->menu_list); + menu_list_pop_stack(menu->menu_list); return 0; } @@ -1767,16 +1872,17 @@ static int action_cancel_pop_default(const char *path, static int action_ok_help(const char *path, const char *label, unsigned type, size_t idx) { - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; menu_list_push_stack( - driver.menu->menu_list, + menu->menu_list, "", "help", 0, 0); - driver.menu->push_start_screen = false; + menu->push_start_screen = false; return 0; } @@ -1851,8 +1957,11 @@ static int action_start_shader_action_preset_parameter(unsigned type, const char #ifdef HAVE_SHADER_MANAGER struct video_shader *shader = NULL; struct video_shader_parameter *param = NULL; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; - if (!(shader = driver.menu->shader)) + if (!(shader = menu->shader)) return 0; param = &shader->parameters[type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0]; @@ -1904,8 +2013,11 @@ static int shader_action_parameter_preset_toggle(unsigned type, const char *labe #ifdef HAVE_SHADER_MANAGER struct video_shader *shader = NULL; struct video_shader_parameter *param = NULL; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; - if (!(shader = driver.menu->shader)) + if (!(shader = menu->shader)) return 0; param = &shader->parameters[type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0]; @@ -1979,8 +2091,13 @@ static int action_start_shader_pass(unsigned type, const char *label, { #ifdef HAVE_SHADER_MANAGER hack_shader_pass = type - MENU_SETTINGS_SHADER_PASS_0; - struct video_shader *shader = driver.menu->shader; + struct video_shader *shader = NULL; struct video_shader_pass *shader_pass = NULL; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + + shader = menu->shader; if (shader) shader_pass = &shader->pass[hack_shader_pass]; @@ -1997,14 +2114,24 @@ static int action_start_shader_scale_pass(unsigned type, const char *label, unsigned action) { #ifdef HAVE_SHADER_MANAGER + struct video_shader *shader = NULL; + struct video_shader_pass *shader_pass = NULL; unsigned pass = type - MENU_SETTINGS_SHADER_PASS_SCALE_0; - struct video_shader *shader = driver.menu->shader; - struct video_shader_pass *shader_pass = &shader->pass[pass]; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + + shader = menu->shader; if (shader) { - shader_pass->fbo.scale_x = shader_pass->fbo.scale_y = 0; - shader_pass->fbo.valid = false; + shader_pass = &shader->pass[pass]; + + if (shader_pass) + { + shader_pass->fbo.scale_x = shader_pass->fbo.scale_y = 0; + shader_pass->fbo.valid = false; + } } #endif @@ -2033,7 +2160,7 @@ static int action_toggle_scroll(unsigned type, const char *label, unsigned action) { unsigned scroll_speed = 0, fast_scroll_speed = 0; - menu_handle_t *menu = driver.menu; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return -1; @@ -2069,7 +2196,7 @@ static int action_toggle_mainmenu(unsigned type, const char *label, { menu_file_list_cbs_t *cbs = NULL; unsigned push_list = 0; - menu_handle_t *menu = driver.menu; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return -1; @@ -2132,10 +2259,11 @@ static int action_toggle_shader_scale_pass(unsigned type, const char *label, unsigned pass = type - MENU_SETTINGS_SHADER_PASS_SCALE_0; struct video_shader *shader = NULL; struct video_shader_pass *shader_pass = NULL; - - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; - shader = driver.menu->shader; + + shader = menu->shader; if (!shader) return -1; shader_pass = &shader->pass[pass]; @@ -2167,10 +2295,11 @@ static int action_start_shader_filter_pass(unsigned type, const char *label, unsigned pass = type - MENU_SETTINGS_SHADER_PASS_FILTER_0; struct video_shader *shader = NULL; struct video_shader_pass *shader_pass = NULL; - - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; - shader = driver.menu->shader; + + shader = menu->shader; if (!shader) return -1; shader_pass = &shader->pass[pass]; @@ -2190,10 +2319,11 @@ static int action_toggle_shader_filter_pass(unsigned type, const char *label, unsigned pass = type - MENU_SETTINGS_SHADER_PASS_FILTER_0; struct video_shader *shader = NULL; struct video_shader_pass *shader_pass = NULL; - - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; - shader = driver.menu->shader; + + shader = menu->shader; if (!shader) return -1; shader_pass = &shader->pass[pass]; @@ -2230,17 +2360,18 @@ static int action_start_shader_num_passes(unsigned type, const char *label, { #ifdef HAVE_SHADER_MANAGER struct video_shader *shader = NULL; - - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; - shader = driver.menu->shader; + + shader = menu->shader; if (!shader) return -1; if (shader->passes) shader->passes = 0; - driver.menu->need_refresh = true; + menu->need_refresh = true; - video_shader_resolve_parameters(NULL, driver.menu->shader); + video_shader_resolve_parameters(NULL, menu->shader); #endif return 0; } @@ -2249,6 +2380,9 @@ static int action_start_cheat_num_passes(unsigned type, const char *label, unsigned action) { cheat_manager_t *cheat = g_extern.cheat; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; if (!cheat) return -1; @@ -2256,7 +2390,7 @@ static int action_start_cheat_num_passes(unsigned type, const char *label, if (cheat->size) { cheat_manager_realloc(cheat, 0); - driver.menu->need_refresh = true; + menu->need_refresh = true; } return 0; @@ -2267,6 +2401,9 @@ static int action_toggle_cheat_num_passes(unsigned type, const char *label, { unsigned new_size = 0; cheat_manager_t *cheat = g_extern.cheat; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; if (!cheat) return -1; @@ -2276,16 +2413,16 @@ static int action_toggle_cheat_num_passes(unsigned type, const char *label, case MENU_ACTION_LEFT: if (cheat->size) new_size = cheat->size - 1; - driver.menu->need_refresh = true; + menu->need_refresh = true; break; case MENU_ACTION_RIGHT: new_size = cheat->size + 1; - driver.menu->need_refresh = true; + menu->need_refresh = true; break; } - if (driver.menu->need_refresh) + if (menu->need_refresh) cheat_manager_realloc(cheat, new_size); return 0; @@ -2296,10 +2433,11 @@ static int action_toggle_shader_num_passes(unsigned type, const char *label, { #ifdef HAVE_SHADER_MANAGER struct video_shader *shader = NULL; - - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return -1; - shader = driver.menu->shader; + + shader = menu->shader; if (!shader) return -1; @@ -2308,18 +2446,18 @@ static int action_toggle_shader_num_passes(unsigned type, const char *label, case MENU_ACTION_LEFT: if (shader->passes) shader->passes--; - driver.menu->need_refresh = true; + menu->need_refresh = true; break; case MENU_ACTION_RIGHT: if ((shader->passes < GFX_MAX_SHADERS)) shader->passes++; - driver.menu->need_refresh = true; + menu->need_refresh = true; break; } - if (driver.menu->need_refresh) - video_shader_resolve_parameters(NULL, driver.menu->shader); + if (menu->need_refresh) + video_shader_resolve_parameters(NULL, menu->shader); #endif return 0; @@ -2477,15 +2615,21 @@ static int deferred_push_core_list_deferred(void *data, void *userdata, unsigned i; size_t list_size = 0; const core_info_t *info = NULL; - file_list_t *list = (file_list_t*)data; - file_list_t *menu_list = (file_list_t*)userdata; + file_list_t *list = NULL; + file_list_t *menu_list = NULL; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + + list = (file_list_t*)data; + menu_list = (file_list_t*)userdata; if (!list || !menu_list) return -1; menu_list_clear(list); core_info_list_get_supported_cores(g_extern.core_info, - driver.menu->deferred_path, &info, &list_size); + menu->deferred_path, &info, &list_size); for (i = 0; i < list_size; i++) { @@ -2497,7 +2641,7 @@ static int deferred_push_core_list_deferred(void *data, void *userdata, menu_list_sort_on_alt(list); - menu_list_populate_generic(driver.menu, list, path, label, type); + menu_list_populate_generic(menu, list, path, label, type); return 0; } @@ -2505,8 +2649,14 @@ static int deferred_push_core_list_deferred(void *data, void *userdata, static int deferred_push_database_manager_list_deferred(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; + file_list_t *list = NULL; + file_list_t *menu_list = NULL; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + + list = (file_list_t*)data; + menu_list = (file_list_t*)userdata; if (!list || !menu_list) return -1; @@ -2517,7 +2667,7 @@ static int deferred_push_database_manager_list_deferred(void *data, void *userda menu_list_sort_on_alt(list); - menu_list_populate_generic(driver.menu, list, path, label, type); + menu_list_populate_generic(menu, list, path, label, type); return 0; } @@ -2528,8 +2678,14 @@ static int deferred_push_cursor_manager_list_deferred(void *data, void *userdata char *query = NULL, *rdb = NULL; char rdb_path[PATH_MAX_LENGTH]; config_file_t *conf = NULL; - file_list_t *list = (file_list_t*)data; - file_list_t *menu_list = (file_list_t*)userdata; + file_list_t *list = NULL; + file_list_t *menu_list = NULL; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + + list = (file_list_t*)data; + menu_list = (file_list_t*)userdata; if (!list || !menu_list) return -1; @@ -2554,7 +2710,7 @@ static int deferred_push_cursor_manager_list_deferred(void *data, void *userdata menu_list_sort_on_alt(list); - menu_list_populate_generic(driver.menu, list, path, label, type); + menu_list_populate_generic(menu, list, path, label, type); return 0; } @@ -2564,10 +2720,18 @@ static int deferred_push_cursor_manager_list_deferred_query_subsearch( const char *path, const char *label, unsigned type) { char query[PATH_MAX_LENGTH]; - file_list_t *list = (file_list_t*)data; - file_list_t *menu_list = (file_list_t*)userdata; - struct string_list *str_list = string_split(path, "|"); + struct string_list *str_list = NULL; bool add_quotes = true; + file_list_t *list = NULL; + file_list_t *menu_list = NULL; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + + str_list = string_split(path, "|"); + + list = (file_list_t*)data; + menu_list = (file_list_t*)userdata; if (!list || !menu_list) { @@ -2647,7 +2811,7 @@ static int deferred_push_cursor_manager_list_deferred_query_subsearch( menu_list_sort_on_alt(list); - menu_list_populate_generic(driver.menu, list, str_list->elems[0].data, label, type); + menu_list_populate_generic(menu, list, str_list->elems[0].data, label, type); string_list_free(str_list); @@ -2820,9 +2984,12 @@ static int deferred_push_performance_counters(void *data, void *userdata, return 0; } -static inline struct video_shader *shader_manager_get_current_shader( - menu_handle_t *menu, const char *label, unsigned type) +static inline struct video_shader *shader_manager_get_current_shader(const char *label, unsigned type) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return NULL; + if (!strcmp(label, "video_shader_preset_parameters")) return menu->shader; else if (!strcmp(label, "video_shader_parameters") && @@ -2860,12 +3027,15 @@ static int deferred_push_video_shader_parameters_common(void *data, void *userda static int deferred_push_video_shader_preset_parameters(void *data, void *userdata, const char *path, const char *label, unsigned type) { - if (!driver.menu->shader) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + if (!menu->shader) return 0; return deferred_push_video_shader_parameters_common(data, userdata, path, label, type, - driver.menu->shader, MENU_SETTINGS_SHADER_PRESET_PARAMETER_0); + menu->shader, MENU_SETTINGS_SHADER_PRESET_PARAMETER_0); } static int deferred_push_video_shader_parameters(void *data, void *userdata, @@ -2887,14 +3057,21 @@ static int deferred_push_settings(void *data, void *userdata, const char *path, const char *label, unsigned type) { rarch_setting_t *setting = NULL; - file_list_t *list = (file_list_t*)data; - file_list_t *menu_list = (file_list_t*)userdata; + file_list_t *list = NULL; + file_list_t *menu_list = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + + list = (file_list_t*)data; + menu_list = (file_list_t*)userdata; if (!list || !menu_list) return -1; - settings_list_free(driver.menu->list_settings); - driver.menu->list_settings = (rarch_setting_t *)setting_data_new(SL_FLAG_ALL_SETTINGS); + settings_list_free(menu->list_settings); + menu->list_settings = (rarch_setting_t *)setting_data_new(SL_FLAG_ALL_SETTINGS); setting = menu_action_find_setting("Driver Settings"); @@ -2948,8 +3125,15 @@ static int deferred_push_settings_subgroup(void *data, void *userdata, char elem0[PATH_MAX_LENGTH], elem1[PATH_MAX_LENGTH]; rarch_setting_t *setting = NULL; struct string_list *str_list = NULL; - file_list_t *list = (file_list_t*)data; - file_list_t *menu_list = (file_list_t*)userdata; + file_list_t *list = NULL; + file_list_t *menu_list = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + + list = (file_list_t*)data; + menu_list = (file_list_t*)userdata; if (!list || !menu_list) return -1; @@ -2970,8 +3154,8 @@ static int deferred_push_settings_subgroup(void *data, void *userdata, } } - settings_list_free(driver.menu->list_settings); - driver.menu->list_settings = (rarch_setting_t *)setting_data_new(SL_FLAG_ALL_SETTINGS); + settings_list_free(menu->list_settings); + menu->list_settings = (rarch_setting_t *)setting_data_new(SL_FLAG_ALL_SETTINGS); setting = menu_action_find_setting(elem0); @@ -3012,7 +3196,11 @@ static int deferred_push_settings_subgroup(void *data, void *userdata, static int deferred_push_category(void *data, void *userdata, const char *path, const char *label, unsigned type) { - return menu_entries_push_list(driver.menu, (file_list_t*)data, + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + return menu_entries_push_list(menu, (file_list_t*)data, path, label, type, SL_FLAG_ALL_SETTINGS); } @@ -3021,13 +3209,20 @@ static int deferred_push_shader_options(void *data, void *userdata, { unsigned i; struct video_shader *shader = NULL; - file_list_t *list = (file_list_t*)data; - file_list_t *menu_list = (file_list_t*)userdata; + file_list_t *list = NULL; + file_list_t *menu_list = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + + list = (file_list_t*)data; + menu_list = (file_list_t*)userdata; if (!list || !menu_list) return -1; - shader = driver.menu->shader; + shader = menu->shader; if (!shader) return -1; @@ -3151,14 +3346,21 @@ static int push_perfcounter_generic( unsigned num, unsigned ident, unsigned type) { - file_list_t *list = (file_list_t*)data; - file_list_t *menu_list = (file_list_t*)userdata; + file_list_t *list = NULL; + file_list_t *menu_list = NULL; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; + + list = (file_list_t*)data; + menu_list = (file_list_t*)userdata; if (!list || !menu_list) return -1; menu_list_clear(list); - push_perfcounter(driver.menu, list, counters, num, ident); + push_perfcounter(menu, list, counters, num, ident); if (driver.menu_ctx && driver.menu_ctx->populate_entries) driver.menu_ctx->populate_entries(path, label, type); @@ -3381,11 +3583,14 @@ static int cb_core_updater_list(void *data_, size_t len) { char *data = (char*)data_; file_list_t *list = NULL; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; if (!data) return -1; - list = (file_list_t*)driver.menu->menu_list->selection_buf; + list = (file_list_t*)menu->menu_list->selection_buf; if (!list) return -1; @@ -3395,7 +3600,7 @@ static int cb_core_updater_list(void *data_, size_t len) print_buf_lines(list, data, len, MENU_FILE_DOWNLOAD_CORE); - menu_list_populate_generic(driver.menu, + menu_list_populate_generic(menu, list, core_updater_list_path, core_updater_list_label, core_updater_list_type); @@ -3407,6 +3612,10 @@ static int cb_core_updater_list(void *data_, size_t len) static int deferred_push_core_updater_list(void *data, void *userdata, const char *path, const char *label, unsigned type) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + #ifdef HAVE_NETWORKING char url_path[PATH_MAX_LENGTH]; @@ -3430,7 +3639,7 @@ static int deferred_push_core_updater_list(void *data, void *userdata, 0, 0); #endif - menu_list_populate_generic(driver.menu, list, path, label, type); + menu_list_populate_generic(menu, list, path, label, type); return 0; } @@ -3456,10 +3665,13 @@ static int deferred_push_history_list(void *data, void *userdata, unsigned i; size_t list_size = 0; file_list_t *list = (file_list_t*)data; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; (void)userdata; - if (!list || !driver.menu) + if (!list || !menu) return -1; menu_list_clear(list); @@ -3486,7 +3698,7 @@ static int deferred_push_history_list(void *data, void *userdata, MENU_FILE_PLAYLIST_ENTRY, 0); } - menu_list_populate_generic(driver.menu, list, path, label, type); + menu_list_populate_generic(menu, list, path, label, type); return 0; } @@ -3495,17 +3707,20 @@ static int deferred_push_content_actions(void *data, void *userdata, const char *path, const char *label, unsigned type) { file_list_t *list = (file_list_t*)data; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; (void)userdata; - if (!list || !driver.menu) + if (!list || !menu) return -1; menu_list_clear(list); if (g_extern.main_is_init && !g_extern.libretro_dummy && - !strcmp(driver.menu->deferred_path, g_extern.fullpath)) + !strcmp(menu->deferred_path, g_extern.fullpath)) { menu_list_push(list, "Resume", "file_load_or_resume", MENU_SETTING_ACTION_RUN, 0); menu_list_push(list, "Save State", "savestate", MENU_SETTING_ACTION_SAVESTATE, 0); @@ -3523,7 +3738,7 @@ static int deferred_push_content_actions(void *data, void *userdata, else menu_list_push(list, "Run", "file_load_or_resume", MENU_SETTING_ACTION_RUN, 0); - menu_list_populate_generic(driver.menu, list, path, label, type); + menu_list_populate_generic(menu, list, path, label, type); return 0; } @@ -3531,7 +3746,10 @@ static int deferred_push_content_actions(void *data, void *userdata, static int deferred_push_content_list(void *data, void *userdata, const char *path, const char *label, unsigned type) { - return menu_entries_deferred_push((file_list_t*)data, driver.menu->menu_list->selection_buf); + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + return menu_entries_deferred_push((file_list_t*)data, menu->menu_list->selection_buf); } static int deferred_push_database_manager_list(void *data, void *userdata, @@ -3684,38 +3902,43 @@ static int deferred_push_default(void *data, void *userdata, static int action_bind_up_or_down_generic(unsigned type, const char *label, unsigned action) { - unsigned scroll_speed = (max(driver.menu->scroll.acceleration, 2) - 2) / 4 + 1; + unsigned scroll_speed = 0; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; - if (menu_list_get_size(driver.menu->menu_list) <= 0) + scroll_speed = (max(menu->scroll.acceleration, 2) - 2) / 4 + 1; + + if (menu_list_get_size(menu->menu_list) <= 0) return 0; switch (action) { case MENU_ACTION_UP: - if (driver.menu->selection_ptr >= scroll_speed) - menu_navigation_set(driver.menu, - driver.menu->selection_ptr - scroll_speed, true); + if (menu->selection_ptr >= scroll_speed) + menu_navigation_set(menu, + menu->selection_ptr - scroll_speed, true); else { if (g_settings.menu.navigation.wraparound.vertical_enable) - menu_navigation_set(driver.menu, - menu_list_get_size(driver.menu->menu_list) - 1, true); + menu_navigation_set(menu, + menu_list_get_size(menu->menu_list) - 1, true); else - menu_navigation_set(driver.menu, + menu_navigation_set(menu, 0, true); } break; case MENU_ACTION_DOWN: - if (driver.menu->selection_ptr + scroll_speed < (menu_list_get_size(driver.menu->menu_list))) - menu_navigation_set(driver.menu, - driver.menu->selection_ptr + scroll_speed, true); + if (menu->selection_ptr + scroll_speed < (menu_list_get_size(menu->menu_list))) + menu_navigation_set(menu, + menu->selection_ptr + scroll_speed, true); else { if (g_settings.menu.navigation.wraparound.vertical_enable) - menu_navigation_clear(driver.menu, false); + menu_navigation_clear(menu, false); else - menu_navigation_set(driver.menu, - menu_list_get_size(driver.menu->menu_list) - 1, true); + menu_navigation_set(menu, + menu_list_get_size(menu->menu_list) - 1, true); } break; } @@ -3725,43 +3948,54 @@ static int action_bind_up_or_down_generic(unsigned type, const char *label, static int action_refresh_default(file_list_t *list, file_list_t *menu_list) { - int ret = menu_entries_deferred_push(list, menu_list); - driver.menu->need_refresh = false; + int ret = 0; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + + ret = menu_entries_deferred_push(list, menu_list); + + menu->need_refresh = false; + return ret; } static int mouse_post_iterate(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, unsigned action) { - if (!driver.menu->mouse.enable) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + + if (!menu->mouse.enable) return 0; - if (driver.menu->mouse.ptr <= menu_list_get_size(driver.menu->menu_list)-1) - menu_navigation_set(driver.menu, driver.menu->mouse.ptr, false); + if (menu->mouse.ptr <= menu_list_get_size(menu->menu_list)-1) + menu_navigation_set(menu, menu->mouse.ptr, false); - if (driver.menu->mouse.left) + if (menu->mouse.left) { - if (!driver.menu->mouse.oldleft) + if (!menu->mouse.oldleft) { - driver.menu->mouse.oldleft = true; + menu->mouse.oldleft = true; if (cbs && cbs->action_ok) - return cbs->action_ok(path, label, type, driver.menu->selection_ptr); + return cbs->action_ok(path, label, type, menu->selection_ptr); } } else - driver.menu->mouse.oldleft = false; + menu->mouse.oldleft = false; - if (driver.menu->mouse.right) + if (menu->mouse.right) { - if (!driver.menu->mouse.oldright) + if (!menu->mouse.oldright) { - driver.menu->mouse.oldright = true; - menu_list_pop_stack(driver.menu->menu_list); + menu->mouse.oldright = true; + menu_list_pop_stack(menu->menu_list); } } else - driver.menu->mouse.oldright = false; + menu->mouse.oldright = false; return 0; } @@ -3781,8 +4015,7 @@ static int action_iterate_help(const char *label, unsigned action) }; char desc[ARRAY_SIZE(binds)][64]; char msg[PATH_MAX_LENGTH]; - menu_handle_t *menu = driver.menu; - + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return 0; @@ -3840,11 +4073,10 @@ static int action_iterate_info(const char *label, unsigned action) unsigned info_type = 0; rarch_setting_t *current_setting = NULL; file_list_t *list = NULL; - menu_handle_t *menu = driver.menu; - + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return 0; - + list = (file_list_t*)menu->menu_list->selection_buf; if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) @@ -3891,14 +4123,18 @@ static int action_iterate_info(const char *label, unsigned action) static int action_iterate_load_open_zip(const char *label, unsigned action) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + switch (g_settings.archive.mode) { case 0: - return load_or_open_zip_iterate(driver.menu, action); + return load_or_open_zip_iterate(menu, action); case 1: - return archive_load(driver.menu); + return archive_load(menu); case 2: - return archive_open(driver.menu); + return archive_open(menu); default: break; } @@ -3915,8 +4151,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) unsigned type = 0; rarch_viewport_t *custom = (rarch_viewport_t*) &g_extern.console.screen.viewports.custom_vp; - menu_handle_t *menu = driver.menu; - + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return -1; @@ -4089,22 +4324,27 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) static int action_iterate_custom_bind(const char *label, unsigned action) { - if (menu_input_bind_iterate(driver.menu)) - menu_list_pop_stack(driver.menu->menu_list); + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + if (menu_input_bind_iterate(menu)) + menu_list_pop_stack(menu->menu_list); return 0; } static int action_iterate_custom_bind_keyboard(const char *label, unsigned action) { - if (menu_input_bind_iterate_keyboard(driver.menu)) - menu_list_pop_stack(driver.menu->menu_list); + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; + if (menu_input_bind_iterate_keyboard(menu)) + menu_list_pop_stack(menu->menu_list); return 0; } static int action_iterate_message(const char *label, unsigned action) { - menu_handle_t *menu = driver.menu; - + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return -1; @@ -4121,40 +4361,43 @@ static int action_iterate_message(const char *label, unsigned action) static int mouse_iterate(unsigned action) { const struct retro_keybind *binds[MAX_USERS]; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; - if (!driver.menu->mouse.enable) + if (!menu->mouse.enable) return 0; - driver.menu->mouse.dx = driver.input->input_state(driver.input_data, + menu->mouse.dx = driver.input->input_state(driver.input_data, binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X); - driver.menu->mouse.dy = driver.input->input_state(driver.input_data, + menu->mouse.dy = driver.input->input_state(driver.input_data, binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_Y); - driver.menu->mouse.x += driver.menu->mouse.dx; - driver.menu->mouse.y += driver.menu->mouse.dy; + menu->mouse.x += menu->mouse.dx; + menu->mouse.y += menu->mouse.dy; - if (driver.menu->mouse.x < 5) - driver.menu->mouse.x = 5; - if (driver.menu->mouse.y < 5) - driver.menu->mouse.y = 5; - if (driver.menu->mouse.x > driver.menu->frame_buf.width - 5) - driver.menu->mouse.x = driver.menu->frame_buf.width - 5; - if (driver.menu->mouse.y > driver.menu->frame_buf.height - 5) - driver.menu->mouse.y = driver.menu->frame_buf.height - 5; + if (menu->mouse.x < 5) + menu->mouse.x = 5; + if (menu->mouse.y < 5) + menu->mouse.y = 5; + if (menu->mouse.x > menu->frame_buf.width - 5) + menu->mouse.x = menu->frame_buf.width - 5; + if (menu->mouse.y > menu->frame_buf.height - 5) + menu->mouse.y = menu->frame_buf.height - 5; - driver.menu->mouse.left = driver.input->input_state(driver.input_data, + menu->mouse.left = driver.input->input_state(driver.input_data, binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT); - driver.menu->mouse.right = driver.input->input_state(driver.input_data, + menu->mouse.right = driver.input->input_state(driver.input_data, binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT); - driver.menu->mouse.wheelup = driver.input->input_state(driver.input_data, + menu->mouse.wheelup = driver.input->input_state(driver.input_data, binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELUP) - || driver.menu->mouse.y == 5; + || menu->mouse.y == 5; - driver.menu->mouse.wheeldown = driver.input->input_state(driver.input_data, + menu->mouse.wheeldown = driver.input->input_state(driver.input_data, binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELDOWN) - || driver.menu->mouse.y == driver.menu->frame_buf.height - 5; + || menu->mouse.y == menu->frame_buf.height - 5; return 0; } @@ -4166,11 +4409,10 @@ static int action_iterate_main(const char *label, unsigned action) const char *label_offset = NULL; const char *path_offset = NULL; menu_file_list_cbs_t *cbs = NULL; - menu_handle_t *menu = driver.menu; - + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return 0; - + cbs = (menu_file_list_cbs_t*) menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, menu->selection_ptr); @@ -4287,8 +4529,11 @@ static int action_iterate_main(const char *label, unsigned action) static int action_select_default(unsigned type, const char *label, unsigned action) { - menu_list_push_stack(driver.menu->menu_list, "", "info_screen", - 0, driver.menu->selection_ptr); + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return 0; + menu_list_push_stack(menu->menu_list, "", "info_screen", + 0, menu->selection_ptr); return 0; } @@ -4360,21 +4605,25 @@ static void menu_action_setting_disp_set_label_shader_filter_pass( "Linear", "Nearest" }; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; (void)pass; (void)modes; + (void)menu; *type_str = '\0'; *w = 19; strlcpy(path_buf, path, path_buf_size); #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL) - if (!driver.menu->shader) + if (!menu->shader) return; pass = (type - MENU_SETTINGS_SHADER_PASS_FILTER_0); - strlcpy(type_str, modes[driver.menu->shader->pass[pass].filter], + strlcpy(type_str, modes[menu->shader->pass[pass].filter], type_str_size); #endif } @@ -4388,11 +4637,17 @@ static void menu_action_setting_disp_set_label_shader_num_passes( const char *path, char *path_buf, size_t path_buf_size) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; + + (void)menu; + *type_str = '\0'; *w = 19; strlcpy(path_buf, path, path_buf_size); #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL) - snprintf(type_str, type_str_size, "%u", driver.menu->shader->passes); + snprintf(type_str, type_str_size, "%u", menu->shader->passes); #endif } @@ -4406,8 +4661,12 @@ static void menu_action_setting_disp_set_label_shader_pass( char *path_buf, size_t path_buf_size) { unsigned pass = (type - MENU_SETTINGS_SHADER_PASS_0); + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; (void)pass; + (void)menu; *type_str = '\0'; *w = 19; @@ -4415,9 +4674,9 @@ static void menu_action_setting_disp_set_label_shader_pass( strlcpy(type_str, "N/A", type_str_size); #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL) - if (*driver.menu->shader->pass[pass].source.path) + if (*menu->shader->pass[pass].source.path) fill_pathname_base(type_str, - driver.menu->shader->pass[pass].source.path, type_str_size); + menu->shader->pass[pass].source.path, type_str_size); #endif } @@ -4491,16 +4750,21 @@ static void menu_action_setting_disp_set_label_shader_preset_parameter( #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL) const struct video_shader_parameter *param = NULL; #endif + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; + + (void)menu; *type_str = '\0'; *w = 19; strlcpy(path_buf, path, path_buf_size); #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL) - if (!driver.menu->shader) + if (!menu->shader) return; - param = &driver.menu->shader->parameters[type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0]; + param = &menu->shader->parameters[type - MENU_SETTINGS_SHADER_PRESET_PARAMETER_0]; if (!param) return; @@ -4521,6 +4785,9 @@ static void menu_action_setting_disp_set_label_shader_scale_pass( { unsigned pass = 0; unsigned scale_value = 0; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; *type_str = '\0'; *w = 19; @@ -4528,13 +4795,14 @@ static void menu_action_setting_disp_set_label_shader_scale_pass( (void)pass; (void)scale_value; + (void)menu; #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL) - if (!driver.menu->shader) + if (!menu->shader) return; pass = (type - MENU_SETTINGS_SHADER_PASS_SCALE_0); - scale_value = driver.menu->shader->pass[pass].fbo.scale_x; + scale_value = menu->shader->pass[pass].fbo.scale_x; if (!scale_value) strlcpy(type_str, "Don't care", type_str_size); @@ -5121,10 +5389,13 @@ static void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, const char *elem0, const char *elem1, const char *menu_label) { rarch_setting_t *setting = menu_action_find_setting(label); + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; if (!cbs) return; - if (!driver.menu) + if (!menu) return; cbs->action_ok = action_ok_lookup_setting; @@ -5738,6 +6009,9 @@ void menu_entries_cbs_init(void *data, const char *menu_label = NULL; menu_file_list_cbs_t *cbs = NULL; file_list_t *list = (file_list_t*)data; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; if (!list) return; @@ -5745,7 +6019,7 @@ void menu_entries_cbs_init(void *data, if (!(cbs = (menu_file_list_cbs_t*)list->list[idx].actiondata)) return; - menu_list_get_last_stack(driver.menu->menu_list, + menu_list_get_last_stack(menu->menu_list, NULL, &menu_label, NULL); if (label) From 6a68b56e7128ca134c9b6e9a372e95d7a24be0a2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 19:46:07 +0100 Subject: [PATCH 137/147] Don't pass driver.menu to menu_database_realloc --- menu/menu_database.c | 6 +++++- menu/menu_database.h | 2 +- menu/menu_entries_cbs.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/menu/menu_database.c b/menu/menu_database.c index 816f93b2aa..3e26caabf4 100644 --- a/menu/menu_database.c +++ b/menu/menu_database.c @@ -54,9 +54,13 @@ void menu_database_free(menu_handle_t *menu) menu_database_playlist_free(menu); } -bool menu_database_realloc(menu_handle_t *menu, const char *path, +bool menu_database_realloc(const char *path, bool force) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return false; + if (!strcmp(menu->db_playlist_file, path) && !force) return true; diff --git a/menu/menu_database.h b/menu/menu_database.h index 41ba3c7b40..84c035f682 100644 --- a/menu/menu_database.h +++ b/menu/menu_database.h @@ -32,7 +32,7 @@ int menu_database_populate_query(file_list_t *list, const char *path, void menu_database_free(menu_handle_t *menu); -bool menu_database_realloc(menu_handle_t *menu, const char *path, +bool menu_database_realloc(const char *path, bool force); #ifdef __cplusplus diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 652ca4a465..62fca6121e 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -1003,7 +1003,7 @@ static int deferred_push_rdb_entry_detail(void *data, void *userdata, fill_pathname_join(path_rdl, g_settings.content_database, path_base, sizeof(path_rdl)); - menu_database_realloc(driver.menu, path_rdl, false); + menu_database_realloc(path_rdl, false); playlist = menu->db_playlist; From 856873223435c76bb6c94f523975375e4086fef1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 19:49:32 +0100 Subject: [PATCH 138/147] (menu_entries_cbs.c) Avoid passing 'menu' handle around --- menu/menu_entries_cbs.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 62fca6121e..36cd9dfeeb 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -135,13 +135,17 @@ unsigned menu_current_gx_resolution = GX_RESOLUTIONS_640_480; static unsigned rdb_entry_start_game_selection_ptr; -static int archive_open(menu_handle_t *menu) +static int archive_open(void) { char cat_path[PATH_MAX_LENGTH]; const char *menu_path = NULL; const char *menu_label = NULL; const char* path = NULL; unsigned int type = 0; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; menu_list_pop_stack(menu->menu_list); @@ -177,13 +181,17 @@ static void common_load_content(bool persist) menu->msg_force = true; } -static int archive_load(menu_handle_t *menu) +static int archive_load(void) { int ret; const char *menu_path = NULL; const char *menu_label = NULL; const char* path = NULL; unsigned int type = 0; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; menu_list_pop_stack(menu->menu_list); @@ -218,9 +226,13 @@ static int archive_load(menu_handle_t *menu) return 0; } -static int load_or_open_zip_iterate(menu_handle_t *menu, unsigned action) +static int load_or_open_zip_iterate(unsigned action) { char msg[PATH_MAX_LENGTH]; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; snprintf(msg, sizeof(msg), "Opening compressed file\n" " \n" @@ -238,10 +250,10 @@ static int load_or_open_zip_iterate(menu_handle_t *menu, unsigned action) switch (action) { case MENU_ACTION_OK: - archive_open(menu); + archive_open(); break; case MENU_ACTION_CANCEL: - archive_load(menu); + archive_load(); break; } @@ -4123,18 +4135,14 @@ static int action_iterate_info(const char *label, unsigned action) static int action_iterate_load_open_zip(const char *label, unsigned action) { - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) - return -1; - switch (g_settings.archive.mode) { case 0: - return load_or_open_zip_iterate(menu, action); + return load_or_open_zip_iterate(action); case 1: - return archive_load(menu); + return archive_load(); case 2: - return archive_open(menu); + return archive_open(); default: break; } From 55844f06d7d0a5e47e028c625731fe7cf4685f17 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 20:04:50 +0100 Subject: [PATCH 139/147] Cleanups - start using menu_driver_resolve everywhere in menu code for safety reasons --- menu/menu_entries.c | 8 ++--- menu/menu_entries_cbs.c | 65 +++++++++++++-------------------- menu/menu_input.c | 2 +- menu/menu_list.c | 80 ++++++++++++++++++++++------------------- menu/menu_list.h | 2 +- menu/menu_navigation.c | 47 ++++++++++++++++-------- menu/menu_navigation.h | 21 ++++------- 7 files changed, 115 insertions(+), 110 deletions(-) diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 3015e8ebd1..2f67c51878 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -212,7 +212,7 @@ int menu_entries_push_horizontal_menu_list(menu_handle_t *menu, if (!info_list) return -1; - info = (core_info_t*)&info_list->list[driver.menu->categories.selection_ptr - 1]; + info = (core_info_t*)&info_list->list[menu->categories.selection_ptr - 1]; if (!info) return -1; @@ -223,7 +223,7 @@ int menu_entries_push_horizontal_menu_list(menu_handle_t *menu, menu_entries_push_cores_list(list, info, g_settings.content_directory, true); - menu_list_populate_generic(menu, list, path, label, menu_type); + menu_list_populate_generic(list, path, label, menu_type); return 0; } @@ -476,7 +476,7 @@ int menu_entries_parse_list( menu_list_sort_on_alt(list); } - menu_list_populate_generic(driver.menu, list, dir, label, type); + menu_list_populate_generic(list, dir, label, type); return 0; } @@ -521,7 +521,7 @@ bool menu_entries_init(menu_handle_t *menu) menu->list_settings = setting_data_new(SL_FLAG_ALL); menu_list_push_stack(menu->menu_list, "", "Main Menu", MENU_SETTINGS, 0); - menu_navigation_clear(menu, true); + menu_navigation_clear(true); menu_entries_push_list(menu, menu->menu_list->selection_buf, "", "Main Menu", 0, SL_FLAG_MAIN_MENU); diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 36cd9dfeeb..7967a0ac1c 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -1422,7 +1422,7 @@ static int action_ok_config_load(const char *path, menu->msg_force = true; if (rarch_replace_config(config)) { - menu_navigation_clear(menu, false); + menu_navigation_clear(false); return -1; } @@ -2183,19 +2183,17 @@ static int action_toggle_scroll(unsigned type, const char *label, { case MENU_ACTION_LEFT: if (menu->selection_ptr > fast_scroll_speed) - menu_navigation_set(menu, - menu->selection_ptr - fast_scroll_speed, true); + menu_navigation_set(menu->selection_ptr - fast_scroll_speed, true); else - menu_navigation_clear(menu, false); + menu_navigation_clear(false); break; case MENU_ACTION_RIGHT: if (menu->selection_ptr + fast_scroll_speed < (menu_list_get_size(menu->menu_list))) - menu_navigation_set(menu, - menu->selection_ptr + fast_scroll_speed, true); + menu_navigation_set(menu->selection_ptr + fast_scroll_speed, true); else { if ((menu_list_get_size(menu->menu_list) > 0)) - menu_navigation_set_last(menu); + menu_navigation_set_last(); } break; } @@ -2653,7 +2651,7 @@ static int deferred_push_core_list_deferred(void *data, void *userdata, menu_list_sort_on_alt(list); - menu_list_populate_generic(menu, list, path, label, type); + menu_list_populate_generic(list, path, label, type); return 0; } @@ -2679,7 +2677,7 @@ static int deferred_push_database_manager_list_deferred(void *data, void *userda menu_list_sort_on_alt(list); - menu_list_populate_generic(menu, list, path, label, type); + menu_list_populate_generic(list, path, label, type); return 0; } @@ -2722,7 +2720,7 @@ static int deferred_push_cursor_manager_list_deferred(void *data, void *userdata menu_list_sort_on_alt(list); - menu_list_populate_generic(menu, list, path, label, type); + menu_list_populate_generic(list, path, label, type); return 0; } @@ -2823,7 +2821,7 @@ static int deferred_push_cursor_manager_list_deferred_query_subsearch( menu_list_sort_on_alt(list); - menu_list_populate_generic(menu, list, str_list->elems[0].data, label, type); + menu_list_populate_generic(list, str_list->elems[0].data, label, type); string_list_free(str_list); @@ -3612,8 +3610,7 @@ static int cb_core_updater_list(void *data_, size_t len) print_buf_lines(list, data, len, MENU_FILE_DOWNLOAD_CORE); - menu_list_populate_generic(menu, - list, core_updater_list_path, + menu_list_populate_generic(list, core_updater_list_path, core_updater_list_label, core_updater_list_type); return 0; @@ -3624,10 +3621,6 @@ static int cb_core_updater_list(void *data_, size_t len) static int deferred_push_core_updater_list(void *data, void *userdata, const char *path, const char *label, unsigned type) { - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) - return -1; - #ifdef HAVE_NETWORKING char url_path[PATH_MAX_LENGTH]; @@ -3651,7 +3644,7 @@ static int deferred_push_core_updater_list(void *data, void *userdata, 0, 0); #endif - menu_list_populate_generic(menu, list, path, label, type); + menu_list_populate_generic(list, path, label, type); return 0; } @@ -3677,15 +3670,12 @@ static int deferred_push_history_list(void *data, void *userdata, unsigned i; size_t list_size = 0; file_list_t *list = (file_list_t*)data; - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) + + if (!list) return -1; (void)userdata; - if (!list || !menu) - return -1; - menu_list_clear(list); list_size = content_playlist_size(g_defaults.history); @@ -3710,7 +3700,7 @@ static int deferred_push_history_list(void *data, void *userdata, MENU_FILE_PLAYLIST_ENTRY, 0); } - menu_list_populate_generic(menu, list, path, label, type); + menu_list_populate_generic(list, path, label, type); return 0; } @@ -3725,7 +3715,7 @@ static int deferred_push_content_actions(void *data, void *userdata, (void)userdata; - if (!list || !menu) + if (!list) return -1; menu_list_clear(list); @@ -3750,7 +3740,7 @@ static int deferred_push_content_actions(void *data, void *userdata, else menu_list_push(list, "Run", "file_load_or_resume", MENU_SETTING_ACTION_RUN, 0); - menu_list_populate_generic(menu, list, path, label, type); + menu_list_populate_generic(list, path, label, type); return 0; } @@ -3928,29 +3918,24 @@ static int action_bind_up_or_down_generic(unsigned type, const char *label, { case MENU_ACTION_UP: if (menu->selection_ptr >= scroll_speed) - menu_navigation_set(menu, - menu->selection_ptr - scroll_speed, true); + menu_navigation_set(menu->selection_ptr - scroll_speed, true); else { if (g_settings.menu.navigation.wraparound.vertical_enable) - menu_navigation_set(menu, - menu_list_get_size(menu->menu_list) - 1, true); + menu_navigation_set(menu_list_get_size(menu->menu_list) - 1, true); else - menu_navigation_set(menu, - 0, true); + menu_navigation_set(0, true); } break; case MENU_ACTION_DOWN: if (menu->selection_ptr + scroll_speed < (menu_list_get_size(menu->menu_list))) - menu_navigation_set(menu, - menu->selection_ptr + scroll_speed, true); + menu_navigation_set(menu->selection_ptr + scroll_speed, true); else { if (g_settings.menu.navigation.wraparound.vertical_enable) - menu_navigation_clear(menu, false); + menu_navigation_clear(false); else - menu_navigation_set(menu, - menu_list_get_size(menu->menu_list) - 1, true); + menu_navigation_set(menu_list_get_size(menu->menu_list) - 1, true); } break; } @@ -3983,7 +3968,7 @@ static int mouse_post_iterate(menu_file_list_cbs_t *cbs, const char *path, return 0; if (menu->mouse.ptr <= menu_list_get_size(menu->menu_list)-1) - menu_navigation_set(menu, menu->mouse.ptr, false); + menu_navigation_set(menu->mouse.ptr, false); if (menu->mouse.left) { @@ -4466,10 +4451,10 @@ static int action_iterate_main(const char *label, unsigned action) ret = cbs->action_up_or_down(type_offset, label_offset, action); break; case MENU_ACTION_SCROLL_UP: - menu_navigation_descend_alphabet(menu, &menu->selection_ptr); + menu_navigation_descend_alphabet(&menu->selection_ptr); break; case MENU_ACTION_SCROLL_DOWN: - menu_navigation_ascend_alphabet(menu, &menu->selection_ptr); + menu_navigation_ascend_alphabet(&menu->selection_ptr); break; case MENU_ACTION_CANCEL: diff --git a/menu/menu_input.c b/menu/menu_input.c index cf19ca0d28..e9ad6c0f69 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -70,7 +70,7 @@ static void menu_input_search_callback(void *userdata, const char *str) return; if (str && *str && file_list_search(menu->menu_list->selection_buf, str, &idx)) - menu_navigation_set(menu, idx, true); + menu_navigation_set(idx, true); menu_input_key_end_line(menu); } diff --git a/menu/menu_list.c b/menu/menu_list.c index 4cc037068d..e2b990cc11 100644 --- a/menu/menu_list.c +++ b/menu/menu_list.c @@ -28,16 +28,19 @@ * * Ensure it doesn't overflow. **/ -static void menu_entries_refresh(menu_handle_t *menu, file_list_t *list) +static void menu_entries_refresh(file_list_t *list) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; if (!list) return; if (menu->selection_ptr >= menu_list_get_size(menu->menu_list) && menu_list_get_size(menu->menu_list)) - menu_navigation_set(menu, menu_list_get_size(menu->menu_list) - 1, true); + menu_navigation_set(menu_list_get_size(menu->menu_list) - 1, true); else if (!menu_list_get_size(menu->menu_list)) - menu_navigation_clear(menu, true); + menu_navigation_clear(true); } /** @@ -94,15 +97,16 @@ static void menu_entries_build_scroll_indices(file_list_t *list) size_t i; int current; bool current_is_dir; + menu_handle_t *menu = menu_driver_resolve(); - if (!driver.menu || !list) + if (!menu || !list) return; - driver.menu->scroll.indices.size = 0; + menu->scroll.indices.size = 0; if (!list->size) return; - driver.menu->scroll.indices.list[driver.menu->scroll.indices.size++] = 0; + menu->scroll.indices.list[menu->scroll.indices.size++] = 0; current = menu_entries_list_get_first_char(list, 0); current_is_dir = menu_entries_list_elem_is_dir(list, 0); @@ -113,13 +117,13 @@ static void menu_entries_build_scroll_indices(file_list_t *list) bool is_dir = menu_entries_list_elem_is_dir(list, i); if ((current_is_dir && !is_dir) || (first > current)) - driver.menu->scroll.indices.list[driver.menu->scroll.indices.size++] = i; + menu->scroll.indices.list[menu->scroll.indices.size++] = i; current = first; current_is_dir = is_dir; } - driver.menu->scroll.indices.list[driver.menu->scroll.indices.size++] = + menu->scroll.indices.list[menu->scroll.indices.size++] = list->size - 1; } @@ -228,16 +232,16 @@ void menu_list_flush_stack(menu_list_t *list, const char *path = NULL; const char *label = NULL; unsigned type = 0; - - if (!driver.menu || !list) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu || !list) return; - driver.menu->need_refresh = true; + menu->need_refresh = true; file_list_get_last(list->menu_stack, &path, &label, &type); while (type != final_type) { - menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); + menu_list_pop(list->menu_stack, &menu->selection_ptr); file_list_get_last(list->menu_stack, &path, &label, &type); } } @@ -248,23 +252,24 @@ void menu_list_flush_stack_by_needle(menu_list_t *list, const char *path = NULL; const char *label = NULL; unsigned type = 0; - - if (!driver.menu || !list) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu || !list) return; - driver.menu->need_refresh = true; + menu->need_refresh = true; file_list_get_last(list->menu_stack, &path, &label, &type); while (strcmp(needle, label) != 0) { - menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); + menu_list_pop(list->menu_stack, &menu->selection_ptr); file_list_get_last(list->menu_stack, &path, &label, &type); } } void menu_list_pop_stack(menu_list_t *list) { - if (!list) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu || !list) return; if (file_list_get_size(list->menu_stack) <= 1) @@ -273,8 +278,8 @@ void menu_list_pop_stack(menu_list_t *list) if (driver.menu_ctx->list_cache) driver.menu_ctx->list_cache(false, 0); - menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); - driver.menu->need_refresh = true; + menu_list_pop(list->menu_stack, &menu->selection_ptr); + menu->need_refresh = true; } void menu_list_pop_stack_by_needle(menu_list_t *list, @@ -283,16 +288,17 @@ void menu_list_pop_stack_by_needle(menu_list_t *list, const char *path = NULL; const char *label = NULL; unsigned type = 0; + menu_handle_t *menu = menu_driver_resolve(); - if (!driver.menu || !list) + if (!menu || !list) return; - driver.menu->need_refresh = true; + menu->need_refresh = true; file_list_get_last(list->menu_stack, &path, &label, &type); while (strcmp(needle, label) == 0) { - menu_list_pop(list->menu_stack, &driver.menu->selection_ptr); + menu_list_pop(list->menu_stack, &menu->selection_ptr); file_list_get_last(list->menu_stack, &path, &label, &type); } } @@ -363,26 +369,28 @@ void menu_list_push_refresh(file_list_t *list, const char *path, const char *label, unsigned type, size_t directory_ptr) { - if (!list) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu || !list) return; menu_list_push(list, path, label, type, directory_ptr); - menu_navigation_clear(driver.menu, true); - driver.menu->need_refresh = true; + menu_navigation_clear(true); + menu->need_refresh = true; } -void menu_list_push_stack(menu_list_t *list, - const char *path, const char *label, +void menu_list_push_stack(menu_list_t *list, const char *path, const char *label, unsigned type, size_t directory_ptr) { if (list) menu_list_push(list->menu_stack, path, label, type, directory_ptr); } -int menu_list_push_stack_refresh(menu_list_t *list, - const char *path, const char *label, +int menu_list_push_stack_refresh(menu_list_t *list, const char *path, const char *label, unsigned type, size_t directory_ptr) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; if (!list) return -1; @@ -390,8 +398,8 @@ int menu_list_push_stack_refresh(menu_list_t *list, driver.menu_ctx->list_cache(false, 0); menu_list_push_stack(list, path, label, type, directory_ptr); - menu_navigation_clear(driver.menu, true); - driver.menu->need_refresh = true; + menu_navigation_clear(true); + menu->need_refresh = true; return 0; } @@ -413,18 +421,18 @@ void menu_list_sort_on_alt(file_list_t *list) file_list_sort_on_alt(list); } -int menu_list_populate_generic(void *data, - file_list_t *list, const char *path, +int menu_list_populate_generic(file_list_t *list, const char *path, const char *label, unsigned type) { - menu_handle_t *menu = (menu_handle_t*)data; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return -1; - driver.menu->scroll.indices.size = 0; + menu->scroll.indices.size = 0; + menu_entries_build_scroll_indices(list); - menu_entries_refresh(menu, list); + menu_entries_refresh(list); if (driver.menu_ctx && driver.menu_ctx->populate_entries) driver.menu_ctx->populate_entries(path, label, type); diff --git a/menu/menu_list.h b/menu/menu_list.h index 29183c06db..7e866291ad 100644 --- a/menu/menu_list.h +++ b/menu/menu_list.h @@ -94,7 +94,7 @@ void menu_list_get_alt_at_offset(const file_list_t *list, size_t idx, void menu_list_set_alt_at_offset(file_list_t *list, size_t idx, const char *alt); -int menu_list_populate_generic(void *data, file_list_t *list, +int menu_list_populate_generic(file_list_t *list, const char *path, const char *label, unsigned type); #ifdef __cplusplus diff --git a/menu/menu_navigation.c b/menu/menu_navigation.c index 14336f3aba..23559d47ca 100644 --- a/menu/menu_navigation.c +++ b/menu/menu_navigation.c @@ -24,13 +24,16 @@ /** * menu_navigation_clear: - * @menu : menu handle * @pending_push : pending push ? * * Clears the navigation pointer. **/ -void menu_navigation_clear(menu_handle_t *menu, bool pending_push) +void menu_navigation_clear(bool pending_push) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; + menu->selection_ptr = 0; if (driver.menu_ctx && driver.menu_ctx->navigation_clear) @@ -39,12 +42,15 @@ void menu_navigation_clear(menu_handle_t *menu, bool pending_push) /** * menu_navigation_decrement: - * @menu : menu handle * * Decrement the navigation pointer. **/ -void menu_navigation_decrement(menu_handle_t *menu) +void menu_navigation_decrement(void) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; + menu->selection_ptr--; if (driver.menu_ctx && driver.menu_ctx->navigation_decrement) @@ -53,12 +59,15 @@ void menu_navigation_decrement(menu_handle_t *menu) /** * menu_navigation_increment: - * @menu : menu handle * * Increment the navigation pointer. **/ -void menu_navigation_increment(menu_handle_t *menu) +void menu_navigation_increment(void) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; + menu->selection_ptr++; if (driver.menu_ctx && driver.menu_ctx->navigation_increment) @@ -67,14 +76,17 @@ void menu_navigation_increment(menu_handle_t *menu) /** * menu_navigation_set: - * @menu : menu handle * @idx : index to set navigation pointer to. * @scroll : should we scroll when needed? * * Sets navigation pointer to index @idx. **/ -void menu_navigation_set(menu_handle_t *menu, size_t idx, bool scroll) +void menu_navigation_set(size_t idx, bool scroll) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; + menu->selection_ptr = idx; if (driver.menu_ctx && driver.menu_ctx->navigation_set) @@ -83,12 +95,15 @@ void menu_navigation_set(menu_handle_t *menu, size_t idx, bool scroll) /** * menu_navigation_set_last: - * @menu : menu handle * * Sets navigation pointer to last index. **/ -void menu_navigation_set_last(menu_handle_t *menu) +void menu_navigation_set_last(void) { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; + menu->selection_ptr = menu_list_get_size(driver.menu->menu_list) - 1; if (driver.menu_ctx && driver.menu_ctx->navigation_set_last) @@ -97,7 +112,6 @@ void menu_navigation_set_last(menu_handle_t *menu) /** * menu_navigation_descend_alphabet: - * @menu : menu handle * @ptr_out : Amount of indices to 'scroll' to get * to the next entry. * @@ -106,10 +120,13 @@ void menu_navigation_set_last(menu_handle_t *menu) * If navigation points to an entry called 'Beta', * navigation pointer will be set to an entry called 'Alpha'. **/ -void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out) +void menu_navigation_descend_alphabet(size_t *ptr_out) { size_t i = 0; size_t ptr = *ptr_out; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; if (!menu->scroll.indices.size) return; @@ -129,7 +146,6 @@ void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out) /** * menu_navigation_ascends_alphabet: - * @menu : menu handle * @ptr_out : Amount of indices to 'scroll' to get * to the next entry. * @@ -138,10 +154,13 @@ void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out) * If navigation points to an entry called 'Alpha', * navigation pointer will be set to an entry called 'Beta'. **/ -void menu_navigation_ascend_alphabet(menu_handle_t *menu, size_t *ptr_out) +void menu_navigation_ascend_alphabet(size_t *ptr_out) { size_t i = 0; size_t ptr = *ptr_out; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; if (!menu->scroll.indices.size) return; diff --git a/menu/menu_navigation.h b/menu/menu_navigation.h index 5222a46154..597ce377bc 100644 --- a/menu/menu_navigation.h +++ b/menu/menu_navigation.h @@ -25,50 +25,44 @@ extern "C" { /** * menu_navigation_clear: - * @menu : menu handle * @pending_push : pending push ? * * Clears the navigation pointer. **/ -void menu_navigation_clear(menu_handle_t *menu, bool pending_push); +void menu_navigation_clear(bool pending_push); /** * menu_navigation_decrement: - * @menu : menu handle * * Decrement the navigation pointer. **/ -void menu_navigation_decrement(menu_handle_t *menu); +void menu_navigation_decrement(void); /** * menu_navigation_increment: - * @menu : menu handle * * Increment the navigation pointer. **/ -void menu_navigation_increment(menu_handle_t *menu); +void menu_navigation_increment(void); /** * menu_navigation_set: - * @menu : menu handle * @idx : index to set navigation pointer to. * @scroll : should we scroll when needed? * * Sets navigation pointer to index @idx. **/ -void menu_navigation_set(menu_handle_t *menu, size_t i, bool scroll); +void menu_navigation_set(size_t i, bool scroll); /** * menu_navigation_set_last: - * @menu : menu handle * * Sets navigation pointer to last index. **/ -void menu_navigation_set_last(menu_handle_t *menu); +void menu_navigation_set_last(void); /** * menu_navigation_descend_alphabet: - * @menu : menu handle * @ptr_out : Amount of indices to 'scroll' to get * to the next entry. * @@ -77,11 +71,10 @@ void menu_navigation_set_last(menu_handle_t *menu); * If navigation points to an entry called 'Beta', * navigation pointer will be set to an entry called 'Alpha'. **/ -void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out); +void menu_navigation_descend_alphabet(size_t *ptr_out); /** * menu_navigation_ascends_alphabet: - * @menu : menu handle * @ptr_out : Amount of indices to 'scroll' to get * to the next entry. * @@ -90,7 +83,7 @@ void menu_navigation_descend_alphabet(menu_handle_t *menu, size_t *ptr_out); * If navigation points to an entry called 'Alpha', * navigation pointer will be set to an entry called 'Beta'. **/ -void menu_navigation_ascend_alphabet(menu_handle_t *menu, size_t *ptr_out); +void menu_navigation_ascend_alphabet(size_t *ptr_out); #ifdef __cplusplus } From 31b272f25ac8eacde588322efeb41757e3339886 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 20:19:20 +0100 Subject: [PATCH 140/147] Don't pass menu_handle_t * state around --- menu/menu_entries_cbs.c | 24 ++++------------ menu/menu_input.c | 61 +++++++++++++++++++++++------------------ menu/menu_input.h | 6 ++-- settings_data.c | 6 ++-- 4 files changed, 47 insertions(+), 50 deletions(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 7967a0ac1c..5fdc9fcc52 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -644,10 +644,7 @@ static int action_ok_shader_preset_load(const char *path, static int action_ok_cheat(const char *path, const char *label, unsigned type, size_t idx) { - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) - return -1; - menu_input_key_start_line(menu, "Input Cheat", + menu_input_key_start_line("Input Cheat", label, type, idx, menu_input_st_cheat_callback); return 0; } @@ -655,10 +652,7 @@ static int action_ok_cheat(const char *path, static int action_ok_shader_preset_save_as(const char *path, const char *label, unsigned type, size_t idx) { - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) - return -1; - menu_input_key_start_line(menu, "Preset Filename", + menu_input_key_start_line("Preset Filename", label, type, idx, menu_input_st_string_callback); return 0; } @@ -666,10 +660,7 @@ static int action_ok_shader_preset_save_as(const char *path, static int action_ok_cheat_file_save_as(const char *path, const char *label, unsigned type, size_t idx) { - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) - return -1; - menu_input_key_start_line(menu, "Cheat Filename", + menu_input_key_start_line("Cheat Filename", label, type, idx, menu_input_st_string_callback); return 0; } @@ -677,10 +668,7 @@ static int action_ok_cheat_file_save_as(const char *path, static int action_ok_remap_file_save_as(const char *path, const char *label, unsigned type, size_t idx) { - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) - return -1; - menu_input_key_start_line(menu, "Remapping Filename", + menu_input_key_start_line("Remapping Filename", label, type, idx, menu_input_st_string_callback); return 0; } @@ -4320,7 +4308,7 @@ static int action_iterate_custom_bind(const char *label, unsigned action) menu_handle_t *menu = menu_driver_resolve(); if (!menu) return -1; - if (menu_input_bind_iterate(menu)) + if (menu_input_bind_iterate()) menu_list_pop_stack(menu->menu_list); return 0; } @@ -4330,7 +4318,7 @@ static int action_iterate_custom_bind_keyboard(const char *label, unsigned actio menu_handle_t *menu = menu_driver_resolve(); if (!menu) return -1; - if (menu_input_bind_iterate_keyboard(menu)) + if (menu_input_bind_iterate_keyboard()) menu_list_pop_stack(menu->menu_list); return 0; } diff --git a/menu/menu_input.c b/menu/menu_input.c index e9ad6c0f69..d8c6c21fba 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -33,10 +33,11 @@ #include "../input/input_joypad.h" #include "../input/input_remapping.h" -void menu_input_key_start_line(menu_handle_t *menu, const char *label, +void menu_input_key_start_line(const char *label, const char *label_setting, unsigned type, unsigned idx, input_keyboard_line_complete_t cb) { + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -48,8 +49,9 @@ void menu_input_key_start_line(menu_handle_t *menu, const char *label, menu->keyboard.buffer = input_keyboard_start_line(menu, cb); } -static void menu_input_key_end_line(menu_handle_t *menu) +static void menu_input_key_end_line(void) { + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -64,7 +66,7 @@ static void menu_input_key_end_line(menu_handle_t *menu) static void menu_input_search_callback(void *userdata, const char *str) { size_t idx; - menu_handle_t *menu = (menu_handle_t*)userdata; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -72,12 +74,12 @@ static void menu_input_search_callback(void *userdata, const char *str) if (str && *str && file_list_search(menu->menu_list->selection_buf, str, &idx)) menu_navigation_set(idx, true); - menu_input_key_end_line(menu); + menu_input_key_end_line(); } void menu_input_st_uint_callback(void *userdata, const char *str) { - menu_handle_t *menu = (menu_handle_t*)userdata; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -91,13 +93,13 @@ void menu_input_st_uint_callback(void *userdata, const char *str) *current_setting->value.unsigned_integer = strtoul(str, NULL, 0); } - menu_input_key_end_line(menu); + menu_input_key_end_line(); } void menu_input_st_string_callback(void *userdata, const char *str) { - menu_handle_t *menu = (menu_handle_t*)userdata; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return; @@ -121,7 +123,7 @@ void menu_input_st_string_callback(void *userdata, const char *str) } } - menu_input_key_end_line(menu); + menu_input_key_end_line(); } void menu_input_st_cheat_callback(void *userdata, const char *str) @@ -141,26 +143,24 @@ void menu_input_st_cheat_callback(void *userdata, const char *str) cheat->cheats[cheat_index].state = true; } - menu_input_key_end_line(menu); + menu_input_key_end_line(); } void menu_input_search_start(void) { - if (!driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) return; - driver.menu->keyboard.display = true; - driver.menu->keyboard.label = "Search: "; - driver.menu->keyboard.buffer = + menu->keyboard.display = true; + menu->keyboard.label = "Search: "; + menu->keyboard.buffer = input_keyboard_start_line(driver.menu, menu_input_search_callback); } void menu_input_key_event(bool down, unsigned keycode, uint32_t character, uint16_t mod) { - if (!driver.menu) - return; - (void)down; (void)keycode; (void)mod; @@ -347,10 +347,11 @@ bool menu_input_custom_bind_keyboard_cb(void *data, unsigned code) return (menu->binds.begin <= menu->binds.last); } -int menu_input_bind_iterate(menu_handle_t *menu) +int menu_input_bind_iterate(void) { char msg[PATH_MAX_LENGTH]; struct menu_bind_state binds; + menu_handle_t *menu = menu_driver_resolve(); if (!menu) return 1; @@ -392,12 +393,16 @@ int menu_input_bind_iterate(menu_handle_t *menu) return 0; } -int menu_input_bind_iterate_keyboard(menu_handle_t *menu) +int menu_input_bind_iterate_keyboard(void) { char msg[PATH_MAX_LENGTH]; int64_t current; int timeout = 0; bool timed_out = false; + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return -1; if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render) @@ -454,6 +459,10 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input) | (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT) | (1ULL << RETRO_DEVICE_ID_JOYPAD_L) | (1ULL << RETRO_DEVICE_ID_JOYPAD_R); + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu) + return 0; driver.retro_ctx.poll_cb(); @@ -465,16 +474,16 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input) if (!first_held) { first_held = true; - driver.menu->delay.timer = initial_held ? 12 : 6; - driver.menu->delay.count = 0; + menu->delay.timer = initial_held ? 12 : 6; + menu->delay.count = 0; } - if (driver.menu->delay.count >= driver.menu->delay.timer) + if (menu->delay.count >= menu->delay.timer) { first_held = false; trigger_input |= input & input_repeat; - driver.menu->scroll.acceleration = - min(driver.menu->scroll.acceleration + 1, 64); + menu->scroll.acceleration = + min(menu->scroll.acceleration + 1, 64); } initial_held = false; @@ -483,12 +492,12 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input) { first_held = false; initial_held = true; - driver.menu->scroll.acceleration = 0; + menu->scroll.acceleration = 0; } - driver.menu->mouse.enable = g_settings.menu.mouse_enable; + menu->mouse.enable = g_settings.menu.mouse_enable; - driver.menu->delay.count++; + menu->delay.count++; if (driver.block_input) trigger_input = 0; diff --git a/menu/menu_input.h b/menu/menu_input.h index 1b333c9f55..126c2d9c91 100644 --- a/menu/menu_input.h +++ b/menu/menu_input.h @@ -47,7 +47,7 @@ typedef enum void menu_input_key_event(bool down, unsigned keycode, uint32_t character, uint16_t key_modifiers); -void menu_input_key_start_line(menu_handle_t *menu, const char *label, +void menu_input_key_start_line(const char *label, const char *label_setting, unsigned type, unsigned idx, input_keyboard_line_complete_t cb); @@ -66,9 +66,9 @@ bool menu_input_poll_find_trigger(struct menu_bind_state *state, bool menu_input_custom_bind_keyboard_cb(void *data, unsigned code); -int menu_input_bind_iterate(menu_handle_t *menu); +int menu_input_bind_iterate(void); -int menu_input_bind_iterate_keyboard(menu_handle_t *menu); +int menu_input_bind_iterate_keyboard(void); unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_state); diff --git a/settings_data.c b/settings_data.c index f72234e6f1..085763a2e5 100644 --- a/settings_data.c +++ b/settings_data.c @@ -978,7 +978,7 @@ static int setting_data_uint_action_ok_linefeed(void *data, unsigned action) if (!setting) return -1; - menu_input_key_start_line(driver.menu, setting->short_description, + menu_input_key_start_line(setting->short_description, setting->name, 0, 0, menu_input_st_uint_callback); return 0; @@ -1046,10 +1046,10 @@ static int setting_data_string_action_ok_allow_input(void *data, { rarch_setting_t *setting = (rarch_setting_t*)data; - if (!setting || !driver.menu) + if (!setting) return -1; - menu_input_key_start_line(driver.menu, setting->short_description, + menu_input_key_start_line(setting->short_description, setting->name, 0, 0, menu_input_st_string_callback); return 0; From f3a579260b9f9897813dcc11d26de72578de8fb2 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 13 Feb 2015 20:23:23 +0100 Subject: [PATCH 141/147] (iOS) Cleanups in menu.m --- apple/iOS/menu.m | 49 +++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/apple/iOS/menu.m b/apple/iOS/menu.m index cf56bc5fb3..c5031fe698 100644 --- a/apple/iOS/menu.m +++ b/apple/iOS/menu.m @@ -610,8 +610,12 @@ static void RunActionSheet(const char* title, const struct string_list* items, U const char *dir = NULL; const char *label = NULL; unsigned menu_type = 0; + menu_handle_t *menu = menu_driver_resolve(); - menu_list_get_last_stack(driver.menu->menu_list, + if (!menu) + return; + + menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type); get_title(label, dir, menu_type, title, sizeof(title)); @@ -636,9 +640,9 @@ static void RunActionSheet(const char* title, const struct string_list* items, U everything = [NSMutableArray array]; [everything addObject:BOXSTRING(title)]; - end = menu_list_get_size(driver.menu->menu_list); + end = menu_list_get_size(menu->menu_list); - for (i = driver.menu->begin; i < end; i++) + for (i = menu->begin; i < end; i++) { rarch_setting_t *setting; char type_str[PATH_MAX_LENGTH], path_buf[PATH_MAX_LENGTH]; @@ -646,19 +650,19 @@ static void RunActionSheet(const char* title, const struct string_list* items, U const char *path = NULL, *entry_label = NULL; unsigned type = 0, w = 0; - menu_list_get_at_offset(driver.menu->menu_list->selection_buf, i, &path, + menu_list_get_at_offset(menu->menu_list->selection_buf, i, &path, &entry_label, &type); setting = (rarch_setting_t*)setting_data_find_setting - (driver.menu->list_settings, - driver.menu->menu_list->selection_buf->list[i].label); + (menu->list_settings, + menu->menu_list->selection_buf->list[i].label); cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( - driver.menu->menu_list->selection_buf, i); + menu->menu_list->selection_buf, i); if (cbs && cbs->action_get_representation) { cbs->action_get_representation - (driver.menu->menu_list->selection_buf, + (menu->menu_list->selection_buf, &w, type, i, label, type_str, sizeof(type_str), entry_label, path, @@ -683,7 +687,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U [RAMenuItemGeneralSetting itemForSetting:setting action:^{ - driver.menu->selection_ptr = i; + menu->selection_ptr = i; if (cbs && cbs->action_ok) cbs->action_ok(path, entry_label, type, i); }]]; @@ -695,7 +699,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U [RAMenuItemBasic itemWithDescription:BOXSTRING(path_buf) action:^{ - driver.menu->selection_ptr = i; + menu->selection_ptr = i; if (cbs && cbs->action_ok) cbs->action_ok(path, entry_label, type, i); else @@ -704,7 +708,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U cbs->action_start(type, entry_label, MENU_ACTION_START); if (cbs && cbs->action_toggle) cbs->action_toggle(type, entry_label, MENU_ACTION_RIGHT); - menu_list_push_stack(driver.menu->menu_list, "", + menu_list_push_stack(menu->menu_list, "", "info_screen", 0, i); } @@ -716,29 +720,36 @@ static void RunActionSheet(const char* title, const struct string_list* items, U [self.sections addObject:everything]; - if (menu_list_get_stack_size(driver.menu->menu_list) > 1) + if (menu_list_get_stack_size(menu->menu_list) > 1) self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Back") style:UIBarButtonItemStyleBordered target:weakSelf action:@selector(menuBack)]; else self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Resume") style:UIBarButtonItemStyleBordered target:[RetroArch_iOS get] action:@selector(showGameView)]; - if ( driver.menu->message_contents[0] != '\0' ) - apple_display_alert(driver.menu->message_contents, NULL); + if ( menu->message_contents[0] != '\0' ) + apple_display_alert(menu->message_contents, NULL); } - (void)menuRefresh { - if (!driver.menu->need_refresh) + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; + if (!menu->need_refresh) return; - menu_entries_deferred_push(driver.menu->menu_list->selection_buf, - driver.menu->menu_list->menu_stack); - driver.menu->need_refresh = false; + menu_entries_deferred_push(menu->menu_list->selection_buf, + menu->menu_list->menu_stack); + menu->need_refresh = false; } - (void)menuBack { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; + menu_apply_deferred_settings(); - menu_list_pop_stack(driver.menu->menu_list); + menu_list_pop_stack(menu->menu_list); [self menuRefresh]; [self reloadData]; } From 778f67dcad2f32e12ce809c3c69f92d5f9061905 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 20:28:49 +0100 Subject: [PATCH 142/147] (PS3) Silence warnings --- menu/menu_entries_cbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 5fdc9fcc52..2979e67842 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -908,7 +908,7 @@ static int create_string_list_rdb_entry_string(const char *desc, const char *lab return 0; } -static uint32_t create_string_list_rdb_entry_int(const char *desc, const char *label, +static int create_string_list_rdb_entry_int(const char *desc, const char *label, int actual_int, const char *path, file_list_t *list) { char tmp[PATH_MAX_LENGTH]; From fbff29663825d9ea51712b237125ba9940d146cb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 20:30:06 +0100 Subject: [PATCH 143/147] (RMenu) Fixes --- menu/drivers/rmenu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index e92c22bf43..471dbb1dfd 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -71,7 +71,7 @@ static int rmenu_entry_iterate(unsigned action) menu_handle_t *menu = menu_driver_resolve(); if (!menu) - return; + return -1; cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( menu->menu_list->selection_buf, menu->selection_ptr); @@ -325,7 +325,7 @@ static void rmenu_wallpaper_set_defaults(char *menu_bg, size_t sizeof_menu_bg) fill_pathname_join(menu_bg, menu_bg, "main_menu.png", sizeof_menu_bg); } -static void rmenu_context_reset(void *data) +static void rmenu_context_reset(void) { char menu_bg[PATH_MAX_LENGTH]; menu_handle_t *menu = menu_driver_resolve(); @@ -364,7 +364,7 @@ static void *rmenu_init(void) return menu; } -static void rmenu_context_destroy(void *data) +static void rmenu_context_destroy(void) { texture_image_free(menu_texture); } From 6815604d70de1b2c22440c5ca15582c2ceb1c899 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 23:30:10 +0100 Subject: [PATCH 144/147] Don't access driver.menu directly --- retroarch.c | 69 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/retroarch.c b/retroarch.c index f47b2fffd2..8027d93ffd 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1955,29 +1955,32 @@ void rarch_main_set_state(unsigned cmd) { case RARCH_ACTION_STATE_MENU_RUNNING: #ifdef HAVE_MENU - if (!driver.menu) - return; + { + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return; - if (driver.menu_ctx && driver.menu_ctx->toggle) - driver.menu_ctx->toggle(true); + if (driver.menu_ctx && driver.menu_ctx->toggle) + driver.menu_ctx->toggle(true); - /* Menu should always run with vsync on. */ - rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE); - /* Stop all rumbling before entering the menu. */ - rarch_main_command(RARCH_CMD_RUMBLE_STOP); + /* Menu should always run with vsync on. */ + rarch_main_command(RARCH_CMD_VIDEO_SET_BLOCKING_STATE); + /* Stop all rumbling before entering the menu. */ + rarch_main_command(RARCH_CMD_RUMBLE_STOP); - if (g_settings.menu.pause_libretro) - rarch_main_command(RARCH_CMD_AUDIO_STOP); + if (g_settings.menu.pause_libretro) + rarch_main_command(RARCH_CMD_AUDIO_STOP); - /* Override keyboard callback to redirect to menu instead. - * We'll use this later for something ... - * FIXME: This should probably be moved to menu_common somehow. */ - g_extern.frontend_key_event = g_extern.system.key_event; - g_extern.system.key_event = menu_input_key_event; + /* Override keyboard callback to redirect to menu instead. + * We'll use this later for something ... + * FIXME: This should probably be moved to menu_common somehow. */ + g_extern.frontend_key_event = g_extern.system.key_event; + g_extern.system.key_event = menu_input_key_event; - driver.menu->need_refresh = true; - g_extern.system.frame_time_last = 0; - g_extern.is_menu = true; + menu->need_refresh = true; + g_extern.system.frame_time_last = 0; + g_extern.is_menu = true; + } #endif break; case RARCH_ACTION_STATE_LOAD_CONTENT: @@ -2158,14 +2161,17 @@ bool rarch_main_command(unsigned cmd) #endif break; case RARCH_CMD_LOAD_CORE: + { #ifdef HAVE_MENU - if (driver.menu) - rarch_update_system_info(&g_extern.menu.info, - &driver.menu->load_no_content); + menu_handle_t *menu = menu_driver_resolve(); + if (menu) + rarch_update_system_info(&g_extern.menu.info, + &menu->load_no_content); #endif #ifndef HAVE_DYNAMIC - rarch_main_command(RARCH_CMD_QUIT); + rarch_main_command(RARCH_CMD_QUIT); #endif + } break; case RARCH_CMD_LOAD_STATE: /* Immutable - disallow savestate load when @@ -2220,15 +2226,20 @@ bool rarch_main_command(unsigned cmd) return false; break; case RARCH_CMD_PREPARE_DUMMY: - *g_extern.fullpath = '\0'; + { + menu_handle_t *menu = menu_driver_resolve(); + *g_extern.fullpath = '\0'; + + (void)menu; #ifdef HAVE_MENU - if (driver.menu) - driver.menu->load_no_content = false; + if (menu) + menu->load_no_content = false; #endif - rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT); - g_extern.system.shutdown = false; + rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT); + g_extern.system.shutdown = false; + } break; case RARCH_CMD_QUIT: rarch_main_set_state(RARCH_ACTION_STATE_QUIT); @@ -2825,13 +2836,15 @@ void rarch_playlist_load_content(content_playlist_t *playlist, { const char *path = NULL; const char *core_path = NULL; + menu_handle_t *menu = menu_driver_resolve(); content_playlist_get_index(playlist, idx, &path, &core_path, NULL); strlcpy(g_settings.libretro, core_path, sizeof(g_settings.libretro)); - driver.menu->load_no_content = (path) ? false : true; + if (menu) + menu->load_no_content = (path) ? false : true; rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path); From 7df7201b316e0c5c301e83151acbb339011ed05e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Feb 2015 23:41:34 +0100 Subject: [PATCH 145/147] Go through menu_driver_resolve --- gfx/drivers/gx_gfx.c | 26 ++++++++++------- runloop.c | 3 +- settings_data.c | 69 +++++++++++++++++++++++++------------------- 3 files changed, 57 insertions(+), 41 deletions(-) diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index 0d26faa34c..8006e69dc9 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -358,6 +358,7 @@ static void init_texture(void *data, unsigned width, unsigned height) gx_video_t *gx = (gx_video_t*)data; struct __gx_texobj *fb_ptr = (struct __gx_texobj*)&g_tex.obj; struct __gx_texobj *menu_ptr = (struct __gx_texobj*)&menu_tex.obj; + menu_handle_t *menu = menu_driver_resolve(); width &= ~3; height &= ~3; @@ -365,10 +366,10 @@ static void init_texture(void *data, unsigned width, unsigned height) menu_w = 320; menu_h = 240; - if (driver.menu) + if (menu) { - menu_w = driver.menu->frame_buf.width; - menu_h = driver.menu->frame_buf.height; + menu_w = menu->frame_buf.width; + menu_h = menu->frame_buf.height; } __GX_InitTexObj(fb_ptr, g_tex.data, width, height, @@ -961,13 +962,18 @@ static bool gx_frame(void *data, const void *frame, if (gx->menu_texture_enable && gx->menu_data) { - convert_texture16(gx->menu_data, menu_tex.data, - driver.menu->frame_buf.width, - driver.menu->frame_buf.height, - driver.menu->frame_buf.width * 2); - DCFlushRange(menu_tex.data, - driver.menu->frame_buf.width * - driver.menu->frame_buf.height * 2); + menu_handle_t *menu = menu_driver_resolve(); + + if (menu) + { + convert_texture16(gx->menu_data, menu_tex.data, + menu->frame_buf.width, + menu->frame_buf.height, + menu->frame_buf.width * 2); + DCFlushRange(menu_tex.data, + menu->frame_buf.width * + menu->frame_buf.height * 2); + } } __GX_InvalidateTexAll(__gx); diff --git a/runloop.c b/runloop.c index ceafd0b734..3504d53ca3 100644 --- a/runloop.c +++ b/runloop.c @@ -1036,7 +1036,8 @@ int rarch_main_iterate(void) #ifdef HAVE_MENU if (g_extern.is_menu) { - if (driver.menu) + menu_handle_t *menu = menu_driver_resolve(); + if (menu) if (menu_iterate(input, old_input, trigger_input) == -1) rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED); diff --git a/settings_data.c b/settings_data.c index 085763a2e5..6eb16636f6 100644 --- a/settings_data.c +++ b/settings_data.c @@ -418,7 +418,7 @@ static int setting_data_string_action_start_allow_input(void *data) { rarch_setting_t *setting = (rarch_setting_t*)data; - if (!setting || !driver.menu) + if (!setting) return -1; *setting->value.string = '\0'; @@ -432,7 +432,7 @@ static int setting_data_bind_action_start(void *data) struct retro_keybind *def_binds = (struct retro_keybind *)retro_keybinds_1; struct retro_keybind *keybind = NULL; - if (!setting || !driver.menu) + if (!setting) return -1; keybind = (struct retro_keybind*)setting->value.keybind; @@ -814,37 +814,39 @@ static int load_content_action_toggle(void *data, unsigned action) static int setting_data_action_ok_bind_all(void *data, unsigned action) { rarch_setting_t *setting = (rarch_setting_t*)data; + menu_handle_t *menu = menu_driver_resolve(); - if (!setting || !driver.menu) + if (!setting || !menu) return -1; - driver.menu->binds.target = &g_settings.input.binds + menu->binds.target = &g_settings.input.binds [setting->index_offset][0]; - driver.menu->binds.begin = MENU_SETTINGS_BIND_BEGIN; - driver.menu->binds.last = MENU_SETTINGS_BIND_LAST; + menu->binds.begin = MENU_SETTINGS_BIND_BEGIN; + menu->binds.last = MENU_SETTINGS_BIND_LAST; menu_list_push_stack( - driver.menu->menu_list, + menu->menu_list, "", "custom_bind_all", g_extern.menu.bind_mode_keyboard ? MENU_SETTINGS_CUSTOM_BIND_KEYBOARD : MENU_SETTINGS_CUSTOM_BIND, - driver.menu->selection_ptr); + menu->selection_ptr); if (g_extern.menu.bind_mode_keyboard) { - driver.menu->binds.timeout_end = + menu->binds.timeout_end = rarch_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; - input_keyboard_wait_keys(driver.menu, + input_keyboard_wait_keys(menu, menu_input_custom_bind_keyboard_cb); } else { - menu_input_poll_bind_get_rested_axes(&driver.menu->binds); - menu_input_poll_bind_state(&driver.menu->binds); + menu_input_poll_bind_get_rested_axes(&menu->binds); + menu_input_poll_bind_state(&menu->binds); } + return 0; } @@ -854,7 +856,10 @@ static int setting_data_action_ok_bind_defaults(void *data, unsigned action) struct retro_keybind *target = NULL; const struct retro_keybind *def_binds = NULL; rarch_setting_t *setting = (rarch_setting_t*)data; + menu_handle_t *menu = menu_driver_resolve(); + if (!menu) + return -1; if (!setting) return -1; @@ -863,11 +868,11 @@ static int setting_data_action_ok_bind_defaults(void *data, unsigned action) def_binds = (setting->index_offset) ? retro_keybinds_rest : retro_keybinds_1; - if (!driver.menu || !target) + if (!target) return -1; - driver.menu->binds.begin = MENU_SETTINGS_BIND_BEGIN; - driver.menu->binds.last = MENU_SETTINGS_BIND_LAST; + menu->binds.begin = MENU_SETTINGS_BIND_BEGIN; + menu->binds.last = MENU_SETTINGS_BIND_LAST; for (i = MENU_SETTINGS_BIND_BEGIN; i <= MENU_SETTINGS_BIND_LAST; i++, target++) @@ -1001,11 +1006,12 @@ static int setting_data_bind_action_ok(void *data, unsigned action) { struct retro_keybind *keybind = NULL; rarch_setting_t *setting = (rarch_setting_t*)data; + menu_handle_t *menu = menu_driver_resolve(); if (!setting) return -1; - if (!driver.menu || !driver.menu->menu_list) + if (!menu || !menu->menu_list) return -1; keybind = (struct retro_keybind*)setting->value.keybind; @@ -1013,29 +1019,29 @@ static int setting_data_bind_action_ok(void *data, unsigned action) if (!keybind) return -1; - driver.menu->binds.begin = setting->bind_type; - driver.menu->binds.last = setting->bind_type; - driver.menu->binds.target = keybind; - driver.menu->binds.user = setting->index_offset; + menu->binds.begin = setting->bind_type; + menu->binds.last = setting->bind_type; + menu->binds.target = keybind; + menu->binds.user = setting->index_offset; menu_list_push_stack( - driver.menu->menu_list, + menu->menu_list, "", "custom_bind", g_extern.menu.bind_mode_keyboard ? MENU_SETTINGS_CUSTOM_BIND_KEYBOARD : MENU_SETTINGS_CUSTOM_BIND, - driver.menu->selection_ptr); + menu->selection_ptr); if (g_extern.menu.bind_mode_keyboard) { - driver.menu->binds.timeout_end = rarch_get_time_usec() + + menu->binds.timeout_end = rarch_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; - input_keyboard_wait_keys(driver.menu, + input_keyboard_wait_keys(menu, menu_input_custom_bind_keyboard_cb); } else { - menu_input_poll_bind_get_rested_axes(&driver.menu->binds); - menu_input_poll_bind_state(&driver.menu->binds); + menu_input_poll_bind_get_rested_axes(&menu->binds); + menu_input_poll_bind_state(&menu->binds); } return 0; @@ -2791,11 +2797,12 @@ void setting_data_get_label(file_list_t *list, char *type_str, { rarch_setting_t *setting_data = NULL; rarch_setting_t *setting = NULL; + menu_handle_t *menu = menu_driver_resolve(); - if (!driver.menu || !driver.menu->menu_list || !label) + if (!menu || !menu->menu_list || !label) return; - setting_data = (rarch_setting_t*)driver.menu->list_settings; + setting_data = (rarch_setting_t*)menu->list_settings; if (!setting_data) return; @@ -2867,14 +2874,16 @@ static void general_write_handler(void *data) if (!strcmp(setting->name, "help")) { - if (!driver.menu || !driver.menu->menu_list) + menu_handle_t *menu = menu_driver_resolve(); + + if (!menu || !menu->menu_list) return; if (*setting->value.boolean) { #ifdef HAVE_MENU menu_list_push_stack_refresh( - driver.menu->menu_list, + menu->menu_list, "", "help", 0, From df35e9fb750a0767234bda98f4b79c94b025ab48 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 Feb 2015 00:47:42 +0100 Subject: [PATCH 146/147] Refactor menu_navigation.c --- menu/drivers/glui.c | 14 +++---- menu/drivers/rgui.c | 16 ++++---- menu/drivers/xmb.c | 14 +++---- menu/menu_action.c | 4 +- menu/menu_driver.h | 29 ++++++++------ menu/menu_entries.c | 2 +- menu/menu_entries_cbs.c | 85 ++++++++++++++++++++++------------------- menu/menu_input.c | 8 ++-- menu/menu_list.c | 36 ++++++++++------- menu/menu_navigation.c | 69 +++++++++++++++------------------ menu/menu_navigation.h | 14 +++---- settings_data.c | 4 +- 12 files changed, 154 insertions(+), 141 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 1eebcbf770..4206f570d1 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -58,7 +58,7 @@ static int glui_entry_iterate(unsigned action) return -1; cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( - menu->menu_list->selection_buf, menu->selection_ptr); + menu->menu_list->selection_buf, menu->navigation.selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -396,7 +396,7 @@ static void glui_frame(void) entry_label, path, path_buf, sizeof(path_buf)); - selected = (i == menu->selection_ptr); + selected = (i == menu->navigation.selection_ptr); menu_animation_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2), g_extern.frame_count / glui->margin, path_buf, selected); @@ -588,13 +588,13 @@ static void glui_navigation_set(bool scroll) if (!scroll) return; - if (menu->selection_ptr < glui->term_height/2) + if (menu->navigation.selection_ptr < glui->term_height/2) menu->begin = 0; - else if (menu->selection_ptr >= glui->term_height/2 - && menu->selection_ptr < + else if (menu->navigation.selection_ptr >= glui->term_height/2 + && menu->navigation.selection_ptr < menu_list_get_size(menu->menu_list) - glui->term_height/2) - menu->begin = menu->selection_ptr - glui->term_height/2; - else if (menu->selection_ptr >= + menu->begin = menu->navigation.selection_ptr - glui->term_height/2; + else if (menu->navigation.selection_ptr >= menu_list_get_size(menu->menu_list) - glui->term_height/2) menu->begin = menu_list_get_size(menu->menu_list) - glui->term_height; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 84606c315e..be4a6aecc5 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -46,7 +46,7 @@ static int rgui_entry_iterate(unsigned action) return -1; cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( - menu->menu_list->selection_buf, menu->selection_ptr); + menu->menu_list->selection_buf, menu->navigation.selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -418,9 +418,9 @@ static void rgui_render(void) entry_label, path, path_buf, sizeof(path_buf)); - selected = (i == menu->selection_ptr); + selected = (i == menu->navigation.selection_ptr); - if (i > (menu->selection_ptr + 100)) + if (i > (menu->navigation.selection_ptr + 100)) continue; menu_animation_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2), @@ -555,13 +555,13 @@ static void rgui_navigation_set(bool scroll) if (!scroll) return; - if (menu->selection_ptr < RGUI_TERM_HEIGHT/2) + if (menu->navigation.selection_ptr < RGUI_TERM_HEIGHT/2) menu->begin = 0; - else if (menu->selection_ptr >= RGUI_TERM_HEIGHT/2 - && menu->selection_ptr < + else if (menu->navigation.selection_ptr >= RGUI_TERM_HEIGHT/2 + && menu->navigation.selection_ptr < menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT/2) - menu->begin = menu->selection_ptr - RGUI_TERM_HEIGHT/2; - else if (menu->selection_ptr >= + menu->begin = menu->navigation.selection_ptr - RGUI_TERM_HEIGHT/2; + else if (menu->navigation.selection_ptr >= menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT/2) menu->begin = menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 236f4e5511..44f4391a5d 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -245,7 +245,7 @@ static int xmb_entry_iterate(unsigned action) cbs = (menu_file_list_cbs_t*) menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr); + menu->navigation.selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -529,7 +529,7 @@ static void xmb_selection_pointer_changed(void) if (!xmb) return; - current = menu->selection_ptr; + current = menu->navigation.selection_ptr; end = menu_list_get_size(menu->menu_list); for (i = 0; i < end; i++) @@ -818,7 +818,7 @@ static void xmb_list_open(xmb_handle_t *xmb) dir = 1; xmb_list_switch_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); - xmb_list_switch_new(xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); + xmb_list_switch_new(xmb, menu->menu_list->selection_buf, dir, menu->navigation.selection_ptr); xmb->categories.active.idx_old = menu->categories.selection_ptr; } @@ -856,7 +856,7 @@ static void xmb_list_switch(xmb_handle_t *xmb) } xmb_list_open_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old); - xmb_list_open_new(xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr); + xmb_list_open_new(xmb, menu->menu_list->selection_buf, dir, menu->navigation.selection_ptr); switch (xmb->depth) { @@ -1155,7 +1155,7 @@ static void xmb_frame(void) xmb_draw_items(xmb, gl, menu->menu_list->selection_buf, menu->menu_list->menu_stack, - menu->selection_ptr, + menu->navigation.selection_ptr, menu->categories.selection_ptr); for (i = 0; i < menu->categories.size; i++) @@ -1591,7 +1591,7 @@ static void xmb_list_insert(file_list_t *list, if (!node) return; - current = menu->selection_ptr; + current = menu->navigation.selection_ptr; node->alpha = xmb->item.passive.alpha; node->zoom = xmb->item.passive.zoom; @@ -1634,7 +1634,7 @@ static void xmb_list_cache(bool horizontal, unsigned action) file_list_copy(menu->menu_list->selection_buf, xmb->selection_buf_old); file_list_copy(menu->menu_list->menu_stack, xmb->menu_stack_old); - xmb->selection_ptr_old = menu->selection_ptr; + xmb->selection_ptr_old = menu->navigation.selection_ptr; if(!horizontal) return; diff --git a/menu/menu_action.c b/menu/menu_action.c index 4ed7164e54..eeab07bee6 100644 --- a/menu/menu_action.c +++ b/menu/menu_action.c @@ -95,7 +95,7 @@ static int menu_action_handle_setting(rarch_setting_t *setting, setting->default_value.string, setting->name, type, - driver.menu->selection_ptr); + driver.menu->navigation.selection_ptr); /* fall-through. */ case ST_BOOL: case ST_INT: @@ -124,7 +124,7 @@ int menu_action_setting_set(unsigned type, const char *label, unsigned action) { rarch_setting_t *setting = menu_action_find_setting( driver.menu->menu_list->selection_buf->list - [driver.menu->selection_ptr].label); + [driver.menu->navigation.selection_ptr].label); if (!setting) return 0; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 2156c9c140..1e84e17ea4 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -76,6 +76,22 @@ typedef struct menu_framebuf size_t pitch; } menu_framebuf_t; +typedef struct menu_navigation +{ + struct + { + /* Quick jumping indices with L/R. + * Rebuilt when parsing directory. */ + struct + { + size_t list[2 * (26 + 2) + 1]; + unsigned size; + } indices; + unsigned acceleration; + } scroll; + size_t selection_ptr; +} menu_navigation_t; + typedef struct { void *userdata; @@ -90,6 +106,7 @@ typedef struct size_t begin; menu_list_t *menu_list; + menu_navigation_t navigation; struct { @@ -97,7 +114,6 @@ typedef struct size_t size; } categories; - size_t selection_ptr; bool need_refresh; bool msg_force; bool push_start_screen; @@ -111,17 +127,6 @@ typedef struct */ char message_contents[PATH_MAX_LENGTH]; - /* Quick jumping indices with L/R. - * Rebuilt when parsing directory. */ - struct - { - struct - { - size_t list[2 * (26 + 2) + 1]; - unsigned size; - } indices; - unsigned acceleration; - } scroll; char default_glslp[PATH_MAX_LENGTH]; char default_cgp[PATH_MAX_LENGTH]; diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 2f67c51878..af30776c1a 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -521,7 +521,7 @@ bool menu_entries_init(menu_handle_t *menu) menu->list_settings = setting_data_new(SL_FLAG_ALL); menu_list_push_stack(menu->menu_list, "", "Main Menu", MENU_SETTINGS, 0); - menu_navigation_clear(true); + menu_navigation_clear(&menu->navigation, true); menu_entries_push_list(menu, menu->menu_list->selection_buf, "", "Main Menu", 0, SL_FLAG_MAIN_MENU); diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 2979e67842..7a55c2b5e7 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -156,7 +156,7 @@ static int archive_open(void) return 0; menu_list_get_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr, &path, NULL, &type); + menu->navigation.selection_ptr, &path, NULL, &type); fill_pathname_join(cat_path, menu_path, path, sizeof(cat_path)); menu_list_push_stack_refresh( @@ -164,7 +164,7 @@ static int archive_open(void) cat_path, menu_label, type, - menu->selection_ptr); + menu->navigation.selection_ptr); return 0; } @@ -202,7 +202,7 @@ static int archive_load(void) return 0; menu_list_get_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr, &path, NULL, &type); + menu->navigation.selection_ptr, &path, NULL, &type); ret = rarch_defer_core(g_extern.core_info, menu_path, path, menu_label, menu->deferred_path, sizeof(menu->deferred_path)); @@ -219,7 +219,7 @@ static int archive_load(void) g_settings.libretro_directory, "deferred_core_list", 0, - menu->selection_ptr); + menu->navigation.selection_ptr); break; } @@ -287,7 +287,7 @@ static int action_ok_playlist_entry(const char *path, return -1; rarch_playlist_load_content(g_defaults.history, - menu->selection_ptr); + menu->navigation.selection_ptr); menu_list_flush_stack(menu->menu_list, MENU_SETTINGS); return -1; } @@ -1410,7 +1410,7 @@ static int action_ok_config_load(const char *path, menu->msg_force = true; if (rarch_replace_config(config)) { - menu_navigation_clear(false); + menu_navigation_clear(&menu->navigation, false); return -1; } @@ -2164,24 +2164,26 @@ static int action_toggle_scroll(unsigned type, const char *label, if (!menu) return -1; - scroll_speed = (max(menu->scroll.acceleration, 2) - 2) / 4 + 1; + scroll_speed = (max(menu->navigation.scroll.acceleration, 2) - 2) / 4 + 1; fast_scroll_speed = 4 + 4 * scroll_speed; switch (action) { case MENU_ACTION_LEFT: - if (menu->selection_ptr > fast_scroll_speed) - menu_navigation_set(menu->selection_ptr - fast_scroll_speed, true); + if (menu->navigation.selection_ptr > fast_scroll_speed) + menu_navigation_set(&menu->navigation, + menu->navigation.selection_ptr - fast_scroll_speed, true); else - menu_navigation_clear(false); + menu_navigation_clear(&menu->navigation, false); break; case MENU_ACTION_RIGHT: - if (menu->selection_ptr + fast_scroll_speed < (menu_list_get_size(menu->menu_list))) - menu_navigation_set(menu->selection_ptr + fast_scroll_speed, true); + if (menu->navigation.selection_ptr + fast_scroll_speed < (menu_list_get_size(menu->menu_list))) + menu_navigation_set(&menu->navigation, + menu->navigation.selection_ptr + fast_scroll_speed, true); else { if ((menu_list_get_size(menu->menu_list) > 0)) - menu_navigation_set_last(); + menu_navigation_set_last(&menu->navigation); } break; } @@ -2202,7 +2204,7 @@ static int action_toggle_mainmenu(unsigned type, const char *label, { if (!strcmp(driver.menu_ctx->ident, "xmb")) { - menu->selection_ptr = 0; + menu->navigation.selection_ptr = 0; switch (action) { case MENU_ACTION_LEFT: @@ -2223,7 +2225,7 @@ static int action_toggle_mainmenu(unsigned type, const char *label, cbs = (menu_file_list_cbs_t*) menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr); + menu->navigation.selection_ptr); switch (push_list) { @@ -3897,7 +3899,7 @@ static int action_bind_up_or_down_generic(unsigned type, const char *label, if (!menu) return -1; - scroll_speed = (max(menu->scroll.acceleration, 2) - 2) / 4 + 1; + scroll_speed = (max(menu->navigation.scroll.acceleration, 2) - 2) / 4 + 1; if (menu_list_get_size(menu->menu_list) <= 0) return 0; @@ -3905,25 +3907,29 @@ static int action_bind_up_or_down_generic(unsigned type, const char *label, switch (action) { case MENU_ACTION_UP: - if (menu->selection_ptr >= scroll_speed) - menu_navigation_set(menu->selection_ptr - scroll_speed, true); + if (menu->navigation.selection_ptr >= scroll_speed) + menu_navigation_set(&menu->navigation, + menu->navigation.selection_ptr - scroll_speed, true); else { if (g_settings.menu.navigation.wraparound.vertical_enable) - menu_navigation_set(menu_list_get_size(menu->menu_list) - 1, true); + menu_navigation_set(&menu->navigation, + menu_list_get_size(menu->menu_list) - 1, true); else - menu_navigation_set(0, true); + menu_navigation_set(&menu->navigation, 0, true); } break; case MENU_ACTION_DOWN: - if (menu->selection_ptr + scroll_speed < (menu_list_get_size(menu->menu_list))) - menu_navigation_set(menu->selection_ptr + scroll_speed, true); + if (menu->navigation.selection_ptr + scroll_speed < (menu_list_get_size(menu->menu_list))) + menu_navigation_set(&menu->navigation, + menu->navigation.selection_ptr + scroll_speed, true); else { if (g_settings.menu.navigation.wraparound.vertical_enable) - menu_navigation_clear(false); + menu_navigation_clear(&menu->navigation, false); else - menu_navigation_set(menu_list_get_size(menu->menu_list) - 1, true); + menu_navigation_set(&menu->navigation, + menu_list_get_size(menu->menu_list) - 1, true); } break; } @@ -3956,7 +3962,7 @@ static int mouse_post_iterate(menu_file_list_cbs_t *cbs, const char *path, return 0; if (menu->mouse.ptr <= menu_list_get_size(menu->menu_list)-1) - menu_navigation_set(menu->mouse.ptr, false); + menu_navigation_set(&menu->navigation, menu->mouse.ptr, false); if (menu->mouse.left) { @@ -3965,7 +3971,8 @@ static int mouse_post_iterate(menu_file_list_cbs_t *cbs, const char *path, menu->mouse.oldleft = true; if (cbs && cbs->action_ok) - return cbs->action_ok(path, label, type, menu->selection_ptr); + return cbs->action_ok(path, label, type, + menu->navigation.selection_ptr); } } else @@ -4069,13 +4076,13 @@ static int action_iterate_info(const char *label, unsigned action) current_setting = (rarch_setting_t*)setting_data_find_setting( menu->list_settings, - list->list[menu->selection_ptr].label); + list->list[menu->navigation.selection_ptr].label); if (current_setting) strlcpy(needle, current_setting->name, sizeof(needle)); else if ((current_setting = (rarch_setting_t*)setting_data_find_setting( menu->list_settings, - list->list[menu->selection_ptr].label))) + list->list[menu->navigation.selection_ptr].label))) { if (current_setting) strlcpy(needle, current_setting->name, sizeof(needle)); @@ -4084,7 +4091,7 @@ static int action_iterate_info(const char *label, unsigned action) { const char *lbl = NULL; menu_list_get_at_offset(list, - menu->selection_ptr, NULL, &lbl, + menu->navigation.selection_ptr, NULL, &lbl, &info_type); if (lbl) @@ -4101,7 +4108,7 @@ static int action_iterate_info(const char *label, unsigned action) } if (action == MENU_ACTION_OK) - menu_list_pop(menu->menu_list->menu_stack, &menu->selection_ptr); + menu_list_pop(menu->menu_list->menu_stack, &menu->navigation.selection_ptr); return 0; } @@ -4205,7 +4212,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) { menu_list_push_stack(menu->menu_list, "", "", MENU_SETTINGS_CUSTOM_VIEWPORT, - menu->selection_ptr); + menu->navigation.selection_ptr); } break; @@ -4216,7 +4223,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action) && !g_settings.video.scale_integer) { menu_list_push_stack(menu->menu_list, "", - "custom_viewport_2", 0, menu->selection_ptr); + "custom_viewport_2", 0, menu->navigation.selection_ptr); } break; @@ -4396,10 +4403,10 @@ static int action_iterate_main(const char *label, unsigned action) cbs = (menu_file_list_cbs_t*) menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr); + menu->navigation.selection_ptr); menu_list_get_at_offset(menu->menu_list->selection_buf, - menu->selection_ptr, &path_offset, &label_offset, &type_offset); + menu->navigation.selection_ptr, &path_offset, &label_offset, &type_offset); mouse_iterate(action); @@ -4439,20 +4446,20 @@ static int action_iterate_main(const char *label, unsigned action) ret = cbs->action_up_or_down(type_offset, label_offset, action); break; case MENU_ACTION_SCROLL_UP: - menu_navigation_descend_alphabet(&menu->selection_ptr); + menu_navigation_descend_alphabet(&menu->navigation, &menu->navigation.selection_ptr); break; case MENU_ACTION_SCROLL_DOWN: - menu_navigation_ascend_alphabet(&menu->selection_ptr); + menu_navigation_ascend_alphabet(&menu->navigation, &menu->navigation.selection_ptr); break; case MENU_ACTION_CANCEL: if (cbs && cbs->action_cancel) - return cbs->action_cancel(path_offset, label_offset, type_offset, menu->selection_ptr); + return cbs->action_cancel(path_offset, label_offset, type_offset, menu->navigation.selection_ptr); break; case MENU_ACTION_OK: if (cbs && cbs->action_ok) - return cbs->action_ok(path_offset, label_offset, type_offset, menu->selection_ptr); + return cbs->action_ok(path_offset, label_offset, type_offset, menu->navigation.selection_ptr); break; case MENU_ACTION_START: if (cbs && cbs->action_start) @@ -4514,7 +4521,7 @@ static int action_select_default(unsigned type, const char *label, if (!menu) return 0; menu_list_push_stack(menu->menu_list, "", "info_screen", - 0, menu->selection_ptr); + 0, menu->navigation.selection_ptr); return 0; } diff --git a/menu/menu_input.c b/menu/menu_input.c index d8c6c21fba..454c382e0b 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -72,7 +72,7 @@ static void menu_input_search_callback(void *userdata, const char *str) return; if (str && *str && file_list_search(menu->menu_list->selection_buf, str, &idx)) - menu_navigation_set(idx, true); + menu_navigation_set(&menu->navigation, idx, true); menu_input_key_end_line(); } @@ -482,8 +482,8 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input) { first_held = false; trigger_input |= input & input_repeat; - menu->scroll.acceleration = - min(menu->scroll.acceleration + 1, 64); + menu->navigation.scroll.acceleration = + min(menu->navigation.scroll.acceleration + 1, 64); } initial_held = false; @@ -492,7 +492,7 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input) { first_held = false; initial_held = true; - menu->scroll.acceleration = 0; + menu->navigation.scroll.acceleration = 0; } menu->mouse.enable = g_settings.menu.mouse_enable; diff --git a/menu/menu_list.c b/menu/menu_list.c index e2b990cc11..79ce72c182 100644 --- a/menu/menu_list.c +++ b/menu/menu_list.c @@ -36,11 +36,12 @@ static void menu_entries_refresh(file_list_t *list) if (!list) return; - if (menu->selection_ptr >= menu_list_get_size(menu->menu_list) + if (menu->navigation.selection_ptr >= menu_list_get_size(menu->menu_list) && menu_list_get_size(menu->menu_list)) - menu_navigation_set(menu_list_get_size(menu->menu_list) - 1, true); + menu_navigation_set(&menu->navigation, + menu_list_get_size(menu->menu_list) - 1, true); else if (!menu_list_get_size(menu->menu_list)) - menu_navigation_clear(true); + menu_navigation_clear(&menu->navigation, true); } /** @@ -97,16 +98,23 @@ static void menu_entries_build_scroll_indices(file_list_t *list) size_t i; int current; bool current_is_dir; + menu_navigation_t *nav = NULL; menu_handle_t *menu = menu_driver_resolve(); if (!menu || !list) return; - menu->scroll.indices.size = 0; + nav = &menu->navigation; + + if (!nav) + return; + + nav->scroll.indices.size = 0; + if (!list->size) return; - menu->scroll.indices.list[menu->scroll.indices.size++] = 0; + nav->scroll.indices.list[nav->scroll.indices.size++] = 0; current = menu_entries_list_get_first_char(list, 0); current_is_dir = menu_entries_list_elem_is_dir(list, 0); @@ -117,13 +125,13 @@ static void menu_entries_build_scroll_indices(file_list_t *list) bool is_dir = menu_entries_list_elem_is_dir(list, i); if ((current_is_dir && !is_dir) || (first > current)) - menu->scroll.indices.list[menu->scroll.indices.size++] = i; + nav->scroll.indices.list[nav->scroll.indices.size++] = i; current = first; current_is_dir = is_dir; } - menu->scroll.indices.list[menu->scroll.indices.size++] = + nav->scroll.indices.list[nav->scroll.indices.size++] = list->size - 1; } @@ -241,7 +249,7 @@ void menu_list_flush_stack(menu_list_t *list, while (type != final_type) { - menu_list_pop(list->menu_stack, &menu->selection_ptr); + menu_list_pop(list->menu_stack, &menu->navigation.selection_ptr); file_list_get_last(list->menu_stack, &path, &label, &type); } } @@ -261,7 +269,7 @@ void menu_list_flush_stack_by_needle(menu_list_t *list, while (strcmp(needle, label) != 0) { - menu_list_pop(list->menu_stack, &menu->selection_ptr); + menu_list_pop(list->menu_stack, &menu->navigation.selection_ptr); file_list_get_last(list->menu_stack, &path, &label, &type); } } @@ -278,7 +286,7 @@ void menu_list_pop_stack(menu_list_t *list) if (driver.menu_ctx->list_cache) driver.menu_ctx->list_cache(false, 0); - menu_list_pop(list->menu_stack, &menu->selection_ptr); + menu_list_pop(list->menu_stack, &menu->navigation.selection_ptr); menu->need_refresh = true; } @@ -298,7 +306,7 @@ void menu_list_pop_stack_by_needle(menu_list_t *list, while (strcmp(needle, label) == 0) { - menu_list_pop(list->menu_stack, &menu->selection_ptr); + menu_list_pop(list->menu_stack, &menu->navigation.selection_ptr); file_list_get_last(list->menu_stack, &path, &label, &type); } } @@ -374,7 +382,7 @@ void menu_list_push_refresh(file_list_t *list, return; menu_list_push(list, path, label, type, directory_ptr); - menu_navigation_clear(true); + menu_navigation_clear(&menu->navigation, true); menu->need_refresh = true; } @@ -398,7 +406,7 @@ int menu_list_push_stack_refresh(menu_list_t *list, const char *path, const char driver.menu_ctx->list_cache(false, 0); menu_list_push_stack(list, path, label, type, directory_ptr); - menu_navigation_clear(true); + menu_navigation_clear(&menu->navigation, true); menu->need_refresh = true; return 0; @@ -429,7 +437,7 @@ int menu_list_populate_generic(file_list_t *list, const char *path, if (!menu) return -1; - menu->scroll.indices.size = 0; + menu->navigation.scroll.indices.size = 0; menu_entries_build_scroll_indices(list); menu_entries_refresh(list); diff --git a/menu/menu_navigation.c b/menu/menu_navigation.c index 23559d47ca..a4f3b26339 100644 --- a/menu/menu_navigation.c +++ b/menu/menu_navigation.c @@ -28,13 +28,12 @@ * * Clears the navigation pointer. **/ -void menu_navigation_clear(bool pending_push) +void menu_navigation_clear(menu_navigation_t *nav, bool pending_push) { - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) + if (!nav) return; - menu->selection_ptr = 0; + nav->selection_ptr = 0; if (driver.menu_ctx && driver.menu_ctx->navigation_clear) driver.menu_ctx->navigation_clear(pending_push); @@ -45,13 +44,12 @@ void menu_navigation_clear(bool pending_push) * * Decrement the navigation pointer. **/ -void menu_navigation_decrement(void) +void menu_navigation_decrement(menu_navigation_t *nav) { - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) + if (!nav) return; - menu->selection_ptr--; + nav->selection_ptr--; if (driver.menu_ctx && driver.menu_ctx->navigation_decrement) driver.menu_ctx->navigation_decrement(); @@ -62,13 +60,12 @@ void menu_navigation_decrement(void) * * Increment the navigation pointer. **/ -void menu_navigation_increment(void) +void menu_navigation_increment(menu_navigation_t *nav) { - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) + if (!nav) return; - menu->selection_ptr++; + nav->selection_ptr++; if (driver.menu_ctx && driver.menu_ctx->navigation_increment) driver.menu_ctx->navigation_increment(); @@ -81,13 +78,13 @@ void menu_navigation_increment(void) * * Sets navigation pointer to index @idx. **/ -void menu_navigation_set(size_t idx, bool scroll) +void menu_navigation_set(menu_navigation_t *nav, + size_t idx, bool scroll) { - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) + if (!nav) return; - menu->selection_ptr = idx; + nav->selection_ptr = idx; if (driver.menu_ctx && driver.menu_ctx->navigation_set) driver.menu_ctx->navigation_set(scroll); @@ -98,13 +95,13 @@ void menu_navigation_set(size_t idx, bool scroll) * * Sets navigation pointer to last index. **/ -void menu_navigation_set_last(void) +void menu_navigation_set_last(menu_navigation_t *nav) { menu_handle_t *menu = menu_driver_resolve(); - if (!menu) + if (!menu || !nav) return; - menu->selection_ptr = menu_list_get_size(driver.menu->menu_list) - 1; + nav->selection_ptr = menu_list_get_size(menu->menu_list) - 1; if (driver.menu_ctx && driver.menu_ctx->navigation_set_last) driver.menu_ctx->navigation_set_last(); @@ -120,25 +117,23 @@ void menu_navigation_set_last(void) * If navigation points to an entry called 'Beta', * navigation pointer will be set to an entry called 'Alpha'. **/ -void menu_navigation_descend_alphabet(size_t *ptr_out) +void menu_navigation_descend_alphabet(menu_navigation_t *nav, size_t *ptr_out) { - size_t i = 0; - size_t ptr = *ptr_out; - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) + size_t i = 0, ptr = *ptr_out; + if (!nav) return; - if (!menu->scroll.indices.size) + if (!nav->scroll.indices.size) return; if (ptr == 0) return; - i = menu->scroll.indices.size - 1; + i = nav->scroll.indices.size - 1; - while (i && menu->scroll.indices.list[i - 1] >= ptr) + while (i && nav->scroll.indices.list[i - 1] >= ptr) i--; - *ptr_out = menu->scroll.indices.list[i - 1]; + *ptr_out = nav->scroll.indices.list[i - 1]; if (driver.menu_ctx && driver.menu_ctx->navigation_descend_alphabet) driver.menu_ctx->navigation_descend_alphabet(ptr_out); @@ -154,24 +149,22 @@ void menu_navigation_descend_alphabet(size_t *ptr_out) * If navigation points to an entry called 'Alpha', * navigation pointer will be set to an entry called 'Beta'. **/ -void menu_navigation_ascend_alphabet(size_t *ptr_out) +void menu_navigation_ascend_alphabet(menu_navigation_t *nav, size_t *ptr_out) { - size_t i = 0; - size_t ptr = *ptr_out; - menu_handle_t *menu = menu_driver_resolve(); - if (!menu) + size_t i = 0, ptr = *ptr_out; + if (!nav) return; - if (!menu->scroll.indices.size) + if (!nav->scroll.indices.size) return; - if (ptr == menu->scroll.indices.list[menu->scroll.indices.size - 1]) + if (ptr == nav->scroll.indices.list[nav->scroll.indices.size - 1]) return; - while (i < menu->scroll.indices.size - 1 - && menu->scroll.indices.list[i + 1] <= ptr) + while (i < nav->scroll.indices.size - 1 + && nav->scroll.indices.list[i + 1] <= ptr) i++; - *ptr_out = menu->scroll.indices.list[i + 1]; + *ptr_out = nav->scroll.indices.list[i + 1]; if (driver.menu_ctx && driver.menu_ctx->navigation_descend_alphabet) driver.menu_ctx->navigation_descend_alphabet(ptr_out); diff --git a/menu/menu_navigation.h b/menu/menu_navigation.h index 597ce377bc..25bfd4d14b 100644 --- a/menu/menu_navigation.h +++ b/menu/menu_navigation.h @@ -29,21 +29,21 @@ extern "C" { * * Clears the navigation pointer. **/ -void menu_navigation_clear(bool pending_push); +void menu_navigation_clear(menu_navigation_t *nav, bool pending_push); /** * menu_navigation_decrement: * * Decrement the navigation pointer. **/ -void menu_navigation_decrement(void); +void menu_navigation_decrement(menu_navigation_t *nav); /** * menu_navigation_increment: * * Increment the navigation pointer. **/ -void menu_navigation_increment(void); +void menu_navigation_increment(menu_navigation_t *nav); /** * menu_navigation_set: @@ -52,14 +52,14 @@ void menu_navigation_increment(void); * * Sets navigation pointer to index @idx. **/ -void menu_navigation_set(size_t i, bool scroll); +void menu_navigation_set(menu_navigation_t *nav, size_t i, bool scroll); /** * menu_navigation_set_last: * * Sets navigation pointer to last index. **/ -void menu_navigation_set_last(void); +void menu_navigation_set_last(menu_navigation_t *nav); /** * menu_navigation_descend_alphabet: @@ -71,7 +71,7 @@ void menu_navigation_set_last(void); * If navigation points to an entry called 'Beta', * navigation pointer will be set to an entry called 'Alpha'. **/ -void menu_navigation_descend_alphabet(size_t *ptr_out); +void menu_navigation_descend_alphabet(menu_navigation_t *nav, size_t *ptr_out); /** * menu_navigation_ascends_alphabet: @@ -83,7 +83,7 @@ void menu_navigation_descend_alphabet(size_t *ptr_out); * If navigation points to an entry called 'Alpha', * navigation pointer will be set to an entry called 'Beta'. **/ -void menu_navigation_ascend_alphabet(size_t *ptr_out); +void menu_navigation_ascend_alphabet(menu_navigation_t *nav, size_t *ptr_out); #ifdef __cplusplus } diff --git a/settings_data.c b/settings_data.c index 6eb16636f6..a0239f1989 100644 --- a/settings_data.c +++ b/settings_data.c @@ -831,7 +831,7 @@ static int setting_data_action_ok_bind_all(void *data, unsigned action) g_extern.menu.bind_mode_keyboard ? MENU_SETTINGS_CUSTOM_BIND_KEYBOARD : MENU_SETTINGS_CUSTOM_BIND, - menu->selection_ptr); + menu->navigation.selection_ptr); if (g_extern.menu.bind_mode_keyboard) { @@ -1029,7 +1029,7 @@ static int setting_data_bind_action_ok(void *data, unsigned action) "custom_bind", g_extern.menu.bind_mode_keyboard ? MENU_SETTINGS_CUSTOM_BIND_KEYBOARD : MENU_SETTINGS_CUSTOM_BIND, - menu->selection_ptr); + menu->navigation.selection_ptr); if (g_extern.menu.bind_mode_keyboard) { From 7d32b27024885eb75ccab737a7c3b953aebbad5d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 Feb 2015 00:51:17 +0100 Subject: [PATCH 147/147] (RMenu) Build fixes --- menu/drivers/rmenu.c | 12 ++++++------ menu/drivers/rmenu_xui.cpp | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index 471dbb1dfd..fa6feb614c 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -74,7 +74,7 @@ static int rmenu_entry_iterate(unsigned action) return -1; cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( - menu->menu_list->selection_buf, menu->selection_ptr); + menu->menu_list->selection_buf, menu->navigation.selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -171,11 +171,11 @@ static void rmenu_render(void) if (!menu->menu_list->selection_buf) return; - begin = (menu->selection_ptr >= (ENTRIES_HEIGHT / 2)) ? - (menu->selection_ptr - (ENTRIES_HEIGHT / 2)) : 0; - end = ((menu->selection_ptr + ENTRIES_HEIGHT) <= + begin = (menu->navigation.selection_ptr >= (ENTRIES_HEIGHT / 2)) ? + (menu->navigation.selection_ptr - (ENTRIES_HEIGHT / 2)) : 0; + end = ((menu->navigation.selection_ptr + ENTRIES_HEIGHT) <= menu_list_get_size(menu->menu_list)) ? - menu->selection_ptr + ENTRIES_HEIGHT : + menu->navigation.selection_ptr + ENTRIES_HEIGHT : menu_list_get_size(menu->menu_list); if (menu_list_get_size(menu->menu_list) <= ENTRIES_HEIGHT) @@ -255,7 +255,7 @@ static void rmenu_render(void) entry_label, path, path_buf, sizeof(path_buf)); - selected = (i == menu->selection_ptr); + selected = (i == menu->navigation.selection_ptr); menu_animation_ticker_line(entry_title_buf, RMENU_TERM_WIDTH - (w + 1 + 2), g_extern.frame_count / 15, path, selected); diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index 7344c5620f..9bdc2bc7ef 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -68,7 +68,7 @@ static int rmenu_xui_entry_iterate(unsigned action) return -1; cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset( - menu->menu_list->selection_buf, menu->selection_ptr); + menu->menu_list->selection_buf, menu->navigation.selection_ptr); menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL); @@ -621,7 +621,7 @@ static void rmenu_xui_render(void) mbstowcs(msg_right, type_str, sizeof(msg_right) / sizeof(wchar_t)); rmenu_xui_set_list_text(i, msg_left, msg_right); } - XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); + XuiListSetCurSelVisible(m_menulist, menu->navigation.selection_ptr); if (menu->keyboard.display) { @@ -645,7 +645,7 @@ static void rmenu_xui_populate_entries(const char *path, (void)label; (void)path; - XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); + XuiListSetCurSelVisible(m_menulist, menu->navigation.selection_ptr); } static void rmenu_xui_navigation_clear(bool pending_push) @@ -653,7 +653,7 @@ static void rmenu_xui_navigation_clear(bool pending_push) menu_handle_t *menu = menu_driver_resolve(); if (menu) - XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); + XuiListSetCurSelVisible(m_menulist, menu->navigation.selection_ptr); } static void rmenu_xui_navigation_set_visible(void) @@ -661,7 +661,7 @@ static void rmenu_xui_navigation_set_visible(void) menu_handle_t *menu = menu_driver_resolve(); if (menu) - XuiListSetCurSelVisible(m_menulist, menu->selection_ptr); + XuiListSetCurSelVisible(m_menulist, menu->navigation.selection_ptr); } static void rmenu_xui_navigation_alphabet(size_t *ptr_out)