diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 195e8668b9..e75a76ab6f 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -66,12 +66,13 @@ static enum action_iterate_type action_iterate_type(const char *label) * * Returns: 0 on success, -1 if we need to quit out of the loop. **/ -int generic_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_action action) +int generic_menu_iterate(void *data, void *userdata, enum menu_action action) { enum action_iterate_type iterate_type; unsigned file_type = 0; int ret = 0; const char *label = NULL; + menu_handle_t *menu = (menu_handle_t*)data; if (!menu) return 0; diff --git a/menu/drivers/menu_generic.h b/menu/drivers/menu_generic.h index 8cbdf87752..c2d0892ca9 100644 --- a/menu/drivers/menu_generic.h +++ b/menu/drivers/menu_generic.h @@ -31,7 +31,7 @@ enum action_iterate_type ITERATE_TYPE_BIND }; -int generic_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_action action); +int generic_menu_iterate(void *data, void *userdata, enum menu_action action); bool generic_menu_init_list(void *data); diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 6346d1ac2b..ac723f6e34 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -1800,15 +1800,16 @@ static void ozone_populate_entries(void *data, const char *path, const char *lab } } -static int ozone_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_action action) +static int ozone_menu_iterate(void *data, + void *userdata, enum menu_action action) { int new_selection; enum menu_action new_action; menu_animation_ctx_tag tag; - file_list_t *selection_buf = NULL; ozone_handle_t *ozone = (ozone_handle_t*) userdata; unsigned horizontal_list_size = 0; + menu_handle_t *menu = (menu_handle_t*)data; if (!ozone) return generic_menu_iterate(menu, userdata, action); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index e33a5c360e..974ea24843 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -238,6 +238,11 @@ static retro_time_t menu_driver_datetime_last_time_us = 0; * representation string */ static char menu_datetime_cache[255] = {0}; +menu_handle_t *menu_driver_get_ptr(void) +{ + return menu_driver_data; +} + /* Returns the OSK key at a given position */ int menu_display_osk_ptr_at_pos(void *data, int x, int y, unsigned width, unsigned height) @@ -2037,8 +2042,8 @@ bool menu_driver_render(bool is_idle, bool rarch_is_inited, if (BIT64_GET(menu_driver_data->state, MENU_STATE_RENDER_MESSAGEBOX) && !string_is_empty(menu_driver_data->menu_state_msg)) { - if (menu_driver_ctx->render_messagebox) - menu_driver_ctx->render_messagebox(menu_userdata, + if (menu_driver_data->driver_ctx->render_messagebox) + menu_driver_data->driver_ctx->render_messagebox(menu_userdata, menu_driver_data->menu_state_msg); if (ui_companion_is_on_foreground()) @@ -2051,15 +2056,15 @@ bool menu_driver_render(bool is_idle, bool rarch_is_inited, if (BIT64_GET(menu_driver_data->state, MENU_STATE_BLIT)) { - if (menu_driver_ctx->render) - menu_driver_ctx->render(menu_userdata, is_idle); + if (menu_driver_data->driver_ctx->render) + menu_driver_data->driver_ctx->render(menu_userdata, is_idle); } if (menu_driver_alive && !is_idle) menu_display_libretro(is_idle, rarch_is_inited, rarch_is_dummy_core); - if (menu_driver_ctx->set_texture) - menu_driver_ctx->set_texture(); + if (menu_driver_data->driver_ctx->set_texture) + menu_driver_data->driver_ctx->set_texture(); menu_driver_data->state = 0; @@ -2200,8 +2205,11 @@ static bool menu_driver_init_internal(bool video_is_threaded) return true; if (menu_driver_ctx->init) + { menu_driver_data = (menu_handle_t*) menu_driver_ctx->init(&menu_userdata, video_is_threaded); + menu_driver_data->driver_ctx = menu_driver_ctx; + } if (!menu_driver_data || !menu_init(menu_driver_data)) goto error; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 2712b073ed..766d48c265 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -240,98 +240,13 @@ typedef struct menu_display_ctx_driver void (*scissor_end)(video_frame_info_t *video_info); } menu_display_ctx_driver_t; -typedef struct -{ - unsigned rpl_entry_selection_ptr; - size_t core_len; - uint64_t state; - - char *core_buf; - char menu_state_msg[1024]; - /* Scratchpad variables. These are used for instance - * by the filebrowser when having to store intermediary - * paths (subdirs/previous dirs/current dir/path, etc). - */ - char deferred_path[PATH_MAX_LENGTH]; - char scratch_buf[PATH_MAX_LENGTH]; - char scratch2_buf[PATH_MAX_LENGTH]; - char db_playlist_file[PATH_MAX_LENGTH]; - char filebrowser_label[PATH_MAX_LENGTH]; - char detect_content_path[PATH_MAX_LENGTH]; - - /* This is used for storing intermediary variables - * that get used later on during menu actions - - * for instance, selecting a shader pass for a shader - * slot */ - struct - { - unsigned unsigned_var; - } scratchpad; -} menu_handle_t; - -struct menu_display_ctx_draw -{ - float x; - float y; - float *color; - const float *vertex; - const float *tex_coord; - unsigned width; - unsigned height; - uintptr_t texture; - size_t vertex_count; - struct video_coords *coords; - void *matrix_data; - enum menu_display_prim_type prim_type; - struct - { - unsigned id; - const void *backend_data; - size_t backend_data_size; - bool active; - } pipeline; - float rotation; - float scale_factor; -}; - -typedef struct menu_display_ctx_rotate_draw -{ - bool scale_enable; - float rotation; - float scale_x; - float scale_y; - float scale_z; - math_matrix_4x4 *matrix; -} menu_display_ctx_rotate_draw_t; - -typedef struct menu_display_ctx_coord_draw -{ - const float *ptr; -} menu_display_ctx_coord_draw_t; - -typedef struct menu_display_ctx_datetime -{ - char *s; - size_t len; - unsigned time_mode; -} menu_display_ctx_datetime_t; - -typedef struct menu_display_ctx_powerstate -{ - char *s; - size_t len; - unsigned percent; - bool battery_enabled; - bool charging; -} menu_display_ctx_powerstate_t; - typedef struct menu_ctx_driver { /* Set a framebuffer texture. This is used for instance by RGUI. */ void (*set_texture)(void); /* Render a messagebox to the screen. */ void (*render_messagebox)(void *data, const char *msg); - int (*iterate)(menu_handle_t *menu, void *userdata, enum menu_action action); + int (*iterate)(void *data, void *userdata, enum menu_action action); void (*render)(void *data, bool is_idle); void (*frame)(void *data, video_frame_info_t *video_info); /* Initializes the menu driver. (setup) */ @@ -407,6 +322,93 @@ typedef struct menu_ctx_driver bool (*get_load_content_animation_data)(void *userdata, menu_texture_item *icon, char **playlist_name); } menu_ctx_driver_t; + +typedef struct +{ + unsigned rpl_entry_selection_ptr; + size_t core_len; + uint64_t state; + + char *core_buf; + char menu_state_msg[1024]; + /* Scratchpad variables. These are used for instance + * by the filebrowser when having to store intermediary + * paths (subdirs/previous dirs/current dir/path, etc). + */ + char deferred_path[PATH_MAX_LENGTH]; + char scratch_buf[PATH_MAX_LENGTH]; + char scratch2_buf[PATH_MAX_LENGTH]; + char db_playlist_file[PATH_MAX_LENGTH]; + char filebrowser_label[PATH_MAX_LENGTH]; + char detect_content_path[PATH_MAX_LENGTH]; + + /* This is used for storing intermediary variables + * that get used later on during menu actions - + * for instance, selecting a shader pass for a shader + * slot */ + struct + { + unsigned unsigned_var; + } scratchpad; + const menu_ctx_driver_t *driver_ctx; +} menu_handle_t; + +struct menu_display_ctx_draw +{ + float x; + float y; + float *color; + const float *vertex; + const float *tex_coord; + unsigned width; + unsigned height; + uintptr_t texture; + size_t vertex_count; + struct video_coords *coords; + void *matrix_data; + enum menu_display_prim_type prim_type; + struct + { + unsigned id; + const void *backend_data; + size_t backend_data_size; + bool active; + } pipeline; + float rotation; + float scale_factor; +}; + +typedef struct menu_display_ctx_rotate_draw +{ + bool scale_enable; + float rotation; + float scale_x; + float scale_y; + float scale_z; + math_matrix_4x4 *matrix; +} menu_display_ctx_rotate_draw_t; + +typedef struct menu_display_ctx_coord_draw +{ + const float *ptr; +} menu_display_ctx_coord_draw_t; + +typedef struct menu_display_ctx_datetime +{ + char *s; + size_t len; + unsigned time_mode; +} menu_display_ctx_datetime_t; + +typedef struct menu_display_ctx_powerstate +{ + char *s; + size_t len; + unsigned percent; + bool battery_enabled; + bool charging; +} menu_display_ctx_powerstate_t; + typedef struct menu_ctx_displaylist { menu_displaylist_info_t *info; @@ -702,6 +704,8 @@ void hex32_to_rgba_normalized(uint32_t hex, float* rgba, float alpha); void menu_subsystem_populate(const struct retro_subsystem_info* subsystem, menu_displaylist_info_t *info); +menu_handle_t *menu_driver_get_ptr(void); + extern uintptr_t menu_display_white_texture; extern menu_display_ctx_driver_t menu_display_ctx_gl;