From f77722a213d53052844a92201e514288f9cda3f2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 10 Feb 2016 20:19:21 +0100 Subject: [PATCH] Add RARCH_MENU_CTL_ENVIRONMENT --- menu/cbs/menu_cbs_scan.c | 6 +++++- menu/menu_driver.c | 24 +++++++++++------------- menu/menu_driver.h | 11 ++++++++--- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/menu/cbs/menu_cbs_scan.c b/menu/cbs/menu_cbs_scan.c index d85c3ca632..cadfe27d9e 100644 --- a/menu/cbs/menu_cbs_scan.c +++ b/menu/cbs/menu_cbs_scan.c @@ -33,7 +33,11 @@ #ifdef HAVE_LIBRETRODB static void handle_dbscan_finished(void *task_data, void *user_data, const char *err) { - menu_environment_cb(MENU_ENVIRON_RESET_HORIZONTAL_LIST, NULL); + menu_ctx_environment_t menu_environ; + menu_environ.type = MENU_ENVIRON_RESET_HORIZONTAL_LIST; + menu_environ.data = NULL; + + menu_driver_ctl(RARCH_MENU_CTL_ENVIRONMENT, &menu_environ); } int action_scan_file(const char *path, diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 969a444027..c8a4691292 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -359,19 +359,6 @@ static void menu_driver_toggle(bool latch) } } -bool menu_environment_cb(menu_environ_cb_t type, void *data) -{ - if (menu_driver_ctx->environ_cb) - { - int ret = menu_driver_ctx->environ_cb(type, data, menu_userdata); - - if (ret == 0) - return true; - } - - return false; -} - int menu_driver_pointer_tap(unsigned x, unsigned y, unsigned ptr, menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action) @@ -784,6 +771,17 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) return false; } break; + case RARCH_MENU_CTL_ENVIRONMENT: + { + menu_ctx_environment_t *menu_environ = (menu_ctx_environment_t*)data; + if (menu_driver_ctx->environ_cb) + { + if (menu_driver_ctx->environ_cb(menu_environ->type, menu_environ->data, + menu_userdata) == 0) + return true; + } + } + return false; default: case RARCH_MENU_CTL_NONE: break; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 731744c55e..ff98118b5d 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -147,7 +147,8 @@ enum rarch_menu_ctl_state RARCH_MENU_CTL_LOAD_IMAGE, RARCH_MENU_CTL_LIST_CACHE, RARCH_MENU_CTL_LIST_INSERT, - RARCH_MENU_CTL_ITERATE + RARCH_MENU_CTL_ITERATE, + RARCH_MENU_CTL_ENVIRONMENT }; typedef enum @@ -345,6 +346,12 @@ typedef struct menu_ctx_iterate enum menu_action action; } menu_ctx_iterate_t; +typedef struct menu_ctx_environment +{ + menu_environ_cb_t type; + void *data; +} menu_ctx_environment_t; + /** * menu_driver_find_handle: * @index : index of driver to get handle to. @@ -386,8 +393,6 @@ bool menu_driver_list_push(menu_displaylist_info_t *info, unsigned type); size_t menu_driver_list_get_selection(void); -bool menu_environment_cb(menu_environ_cb_t type, void *data); - int menu_driver_bind_init(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx, const char *elem0, const char *elem1,