mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
Move menu_ctx variable over to driver struct
This commit is contained in:
parent
454ef3fa28
commit
6064511cc2
32
driver.h
32
driver.h
@ -480,6 +480,23 @@ typedef struct video_driver
|
||||
void (*poke_interface)(void *data, const video_poke_interface_t **iface);
|
||||
} video_driver_t;
|
||||
|
||||
typedef struct menu_ctx_driver
|
||||
{
|
||||
void (*set_texture)(void*, bool);
|
||||
void (*render_messagebox)(void*, const char*);
|
||||
void (*render)(void*);
|
||||
void* (*init)(void);
|
||||
void (*free)(void*);
|
||||
void (*init_assets)(void*);
|
||||
void (*free_assets)(void*);
|
||||
void (*populate_entries)(void*, unsigned);
|
||||
void (*iterate)(void*, unsigned);
|
||||
int (*input_postprocess)(void *, uint64_t);
|
||||
|
||||
// Human readable string.
|
||||
const char *ident;
|
||||
} menu_ctx_driver_t;
|
||||
|
||||
enum rarch_display_type
|
||||
{
|
||||
RARCH_DISPLAY_NONE = 0, // Non-bindable types like consoles, KMS, VideoCore, etc.
|
||||
@ -508,6 +525,9 @@ typedef struct driver
|
||||
void *audio_data;
|
||||
void *video_data;
|
||||
void *input_data;
|
||||
#ifdef HAVE_MENU
|
||||
const menu_ctx_driver_t *menu_ctx;
|
||||
#endif
|
||||
|
||||
bool threaded_video;
|
||||
|
||||
@ -638,6 +658,13 @@ bool driver_location_get_position(double *lat, double *lon, double *horiz_accura
|
||||
void driver_location_set_interval(unsigned interval_msecs, unsigned interval_distance);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
const void *menu_ctx_find_driver(const char *ident); // Finds driver with ident. Does not initialize.
|
||||
bool menu_ctx_init_first(const void **driver, void **handle); // Finds first suitable driver and initializes.
|
||||
void find_prev_menu_driver(void);
|
||||
void find_next_menu_driver(void);
|
||||
#endif
|
||||
|
||||
// Used by RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO
|
||||
bool driver_update_system_av_info(const struct retro_system_av_info *info);
|
||||
|
||||
@ -699,6 +726,11 @@ extern const location_driver_t location_apple;
|
||||
extern const location_driver_t location_android;
|
||||
extern const input_osk_driver_t input_ps3_osk;
|
||||
|
||||
extern const menu_ctx_driver_t menu_ctx_rmenu;
|
||||
extern const menu_ctx_driver_t menu_ctx_rmenu_xui;
|
||||
extern const menu_ctx_driver_t menu_ctx_rgui;
|
||||
extern const menu_ctx_driver_t menu_ctx_lakka;
|
||||
|
||||
#include "driver_funcs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <limits.h>
|
||||
|
||||
#include "../menu_common.h"
|
||||
#include "../menu_context.h"
|
||||
#include "../file_list.h"
|
||||
#include "../../../general.h"
|
||||
#include "../../../gfx/gfx_common.h"
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <limits.h>
|
||||
|
||||
#include "../menu_common.h"
|
||||
#include "../menu_context.h"
|
||||
#include "../file_list.h"
|
||||
#include "../../../general.h"
|
||||
#include "../../../gfx/gfx_common.h"
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "../../compat/posix_string.h"
|
||||
|
||||
rgui_handle_t *rgui;
|
||||
const menu_ctx_driver_t *menu_ctx;
|
||||
|
||||
static void menu_parse_and_resolve(void *data, unsigned menu_type);
|
||||
|
||||
@ -289,7 +288,7 @@ void load_menu_game_prepare(void)
|
||||
rgui->do_held = false;
|
||||
rgui->msg_force = true;
|
||||
|
||||
if (menu_ctx)
|
||||
if (driver.menu_ctx)
|
||||
menu_iterate_func(rgui, RGUI_ACTION_NOOP);
|
||||
#endif
|
||||
|
||||
@ -433,7 +432,7 @@ bool load_menu_game(void)
|
||||
|
||||
void menu_init(void)
|
||||
{
|
||||
const void **menuctx = (const void**)&menu_ctx;
|
||||
const void **menuctx = (const void**)&driver.menu_ctx;
|
||||
if (!menu_ctx_init_first(menuctx, (void**)&rgui))
|
||||
{
|
||||
RARCH_ERR("Could not initialize menu.\n");
|
||||
@ -466,8 +465,8 @@ void menu_init(void)
|
||||
|
||||
void menu_free(void)
|
||||
{
|
||||
if (menu_ctx && menu_ctx->free)
|
||||
menu_ctx->free(rgui);
|
||||
if (driver.menu_ctx && driver.menu_ctx->free)
|
||||
driver.menu_ctx->free(rgui);
|
||||
|
||||
#ifdef HAVE_DYNAMIC
|
||||
libretro_free_system_info(&rgui->info);
|
||||
@ -573,14 +572,14 @@ static int menu_custom_bind_iterate(void *data, unsigned action)
|
||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
||||
(void)action; // Have to ignore action here. Only bind that should work here is Quit RetroArch or something like that.
|
||||
|
||||
if (driver.video_data && menu_ctx && menu_ctx->render)
|
||||
menu_ctx->render(rgui);
|
||||
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
||||
driver.menu_ctx->render(rgui);
|
||||
|
||||
char msg[256];
|
||||
snprintf(msg, sizeof(msg), "[%s]\npress joypad\n(RETURN to skip)", input_config_bind_map[rgui->binds.begin - RGUI_SETTINGS_BIND_BEGIN].desc);
|
||||
|
||||
if (driver.video_data && menu_ctx && menu_ctx->render_messagebox)
|
||||
menu_ctx->render_messagebox(rgui, msg);
|
||||
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox)
|
||||
driver.menu_ctx->render_messagebox(rgui, msg);
|
||||
|
||||
struct rgui_bind_state binds = rgui->binds;
|
||||
menu_poll_bind_state(&binds);
|
||||
@ -607,8 +606,8 @@ static int menu_start_screen_iterate(void *data, unsigned action)
|
||||
char msg[1024];
|
||||
rgui_handle_t *rgui = (rgui_handle_t*)data;
|
||||
|
||||
if (driver.video_data && menu_ctx && menu_ctx->render)
|
||||
menu_ctx->render(rgui);
|
||||
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
||||
driver.menu_ctx->render(rgui);
|
||||
|
||||
char desc[6][64];
|
||||
static const unsigned binds[] = {
|
||||
@ -662,8 +661,8 @@ static int menu_start_screen_iterate(void *data, unsigned action)
|
||||
"Press Accept/OK to continue.",
|
||||
desc[0], desc[1], desc[2], desc[3], desc[4], desc[5]);
|
||||
|
||||
if (driver.video_data && menu_ctx && menu_ctx->render_messagebox)
|
||||
menu_ctx->render_messagebox(rgui, msg);
|
||||
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox)
|
||||
driver.menu_ctx->render_messagebox(rgui, msg);
|
||||
|
||||
if (action == RGUI_ACTION_OK)
|
||||
file_list_pop(rgui->menu_stack, &rgui->selection_ptr);
|
||||
@ -797,8 +796,8 @@ static int menu_viewport_iterate(void *data, unsigned action)
|
||||
|
||||
file_list_get_last(rgui->menu_stack, NULL, &menu_type);
|
||||
|
||||
if (driver.video_data && menu_ctx && menu_ctx->render)
|
||||
menu_ctx->render(rgui);
|
||||
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
||||
driver.menu_ctx->render(rgui);
|
||||
|
||||
const char *base_msg = NULL;
|
||||
char msg[64];
|
||||
@ -828,8 +827,8 @@ static int menu_viewport_iterate(void *data, unsigned action)
|
||||
base_msg, custom->x, custom->y, custom->width, custom->height);
|
||||
}
|
||||
|
||||
if (driver.video_data && menu_ctx && menu_ctx->render_messagebox)
|
||||
menu_ctx->render_messagebox(rgui, msg);
|
||||
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render_messagebox)
|
||||
driver.menu_ctx->render_messagebox(rgui, msg);
|
||||
|
||||
if (!custom->width)
|
||||
custom->width = stride_x;
|
||||
@ -985,8 +984,8 @@ static int menu_settings_iterate(void *data, unsigned action)
|
||||
menu_populate_entries(rgui, RGUI_SETTINGS);
|
||||
}
|
||||
|
||||
if (driver.video_data && menu_ctx && menu_ctx->render)
|
||||
menu_ctx->render(rgui);
|
||||
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
||||
driver.menu_ctx->render(rgui);
|
||||
|
||||
// Have to defer it so we let settings refresh.
|
||||
if (rgui->push_start_screen)
|
||||
@ -1032,8 +1031,8 @@ static int menu_iterate_func(void *data, unsigned action)
|
||||
file_list_get_last(rgui->menu_stack, &dir, &menu_type);
|
||||
int ret = 0;
|
||||
|
||||
if (driver.video_data && menu_ctx && menu_ctx->set_texture)
|
||||
menu_ctx->set_texture(rgui, false);
|
||||
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->set_texture)
|
||||
driver.menu_ctx->set_texture(rgui, false);
|
||||
|
||||
#ifdef HAVE_OSK
|
||||
// process pending osk init callback
|
||||
@ -1384,11 +1383,11 @@ static int menu_iterate_func(void *data, unsigned action)
|
||||
menu_parse_and_resolve(rgui, menu_type);
|
||||
}
|
||||
|
||||
if (menu_ctx && menu_ctx->iterate)
|
||||
menu_ctx->iterate(rgui, action);
|
||||
if (driver.menu_ctx && driver.menu_ctx->iterate)
|
||||
driver.menu_ctx->iterate(rgui, action);
|
||||
|
||||
if (driver.video_data && menu_ctx && menu_ctx->render)
|
||||
menu_ctx->render(rgui);
|
||||
if (driver.video_data && driver.menu_ctx && driver.menu_ctx->render)
|
||||
driver.menu_ctx->render(rgui);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1480,7 +1479,7 @@ bool menu_iterate(void)
|
||||
else if (rgui->trigger_state & (1ULL << RETRO_DEVICE_ID_JOYPAD_START))
|
||||
action = RGUI_ACTION_START;
|
||||
|
||||
if (menu_ctx)
|
||||
if (driver.menu_ctx)
|
||||
input_entry_ret = menu_iterate_func(rgui, action);
|
||||
|
||||
if (driver.video_data && driver.video_poke && driver.video_poke->set_texture_enable)
|
||||
@ -1501,8 +1500,8 @@ bool menu_iterate(void)
|
||||
driver.video_poke->set_texture_enable(driver.video_data, false,
|
||||
MENU_TEXTURE_FULLSCREEN);
|
||||
|
||||
if (menu_ctx && menu_ctx->input_postprocess)
|
||||
ret = menu_ctx->input_postprocess(rgui, rgui->old_input_state);
|
||||
if (driver.menu_ctx && driver.menu_ctx->input_postprocess)
|
||||
ret = driver.menu_ctx->input_postprocess(rgui, rgui->old_input_state);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -2148,8 +2147,8 @@ void menu_populate_entries(void *data, unsigned menu_type)
|
||||
break;
|
||||
}
|
||||
|
||||
if (menu_ctx && menu_ctx->populate_entries)
|
||||
menu_ctx->populate_entries(rgui, menu_type);
|
||||
if (driver.menu_ctx && driver.menu_ctx->populate_entries)
|
||||
driver.menu_ctx->populate_entries(rgui, menu_type);
|
||||
}
|
||||
|
||||
static void menu_parse_and_resolve(void *data, unsigned menu_type)
|
||||
@ -2321,8 +2320,8 @@ static void menu_parse_and_resolve(void *data, unsigned menu_type)
|
||||
is_dir ? menu_type : RGUI_FILE_PLAIN, 0);
|
||||
}
|
||||
|
||||
if (menu_ctx && menu_ctx->populate_entries)
|
||||
menu_ctx->populate_entries(rgui, menu_type);
|
||||
if (driver.menu_ctx && driver.menu_ctx->populate_entries)
|
||||
driver.menu_ctx->populate_entries(rgui, menu_type);
|
||||
|
||||
string_list_free(list);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include "../../performance.h"
|
||||
#include "../info/core_info.h"
|
||||
#include "menu_context.h"
|
||||
|
||||
#ifdef HAVE_RGUI
|
||||
#define MENU_TEXTURE_FULLSCREEN false
|
||||
@ -446,8 +445,6 @@ unsigned menu_type_is(unsigned type);
|
||||
|
||||
uint64_t menu_input(void);
|
||||
|
||||
extern const menu_ctx_driver_t *menu_ctx;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -13,7 +13,6 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "menu_context.h"
|
||||
#include "menu_common.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@ -63,7 +62,7 @@ void find_prev_menu_driver(void)
|
||||
if (i > 0)
|
||||
{
|
||||
strlcpy(g_settings.menu.driver, menu_ctx_drivers[i - 1]->ident, sizeof(g_settings.menu.driver));
|
||||
menu_ctx = menu_ctx_drivers[i - 1];
|
||||
driver.menu_ctx = (menu_ctx_driver_t*)menu_ctx_drivers[i - 1];
|
||||
}
|
||||
else
|
||||
RARCH_WARN("Couldn't find any previous menu driver (current one: \"%s\").\n", g_settings.menu.driver);
|
||||
@ -75,7 +74,7 @@ void find_next_menu_driver(void)
|
||||
if (i >= 0 && menu_ctx_drivers[i + 1])
|
||||
{
|
||||
strlcpy(g_settings.menu.driver, menu_ctx_drivers[i + 1]->ident, sizeof(g_settings.menu.driver));
|
||||
menu_ctx = menu_ctx_drivers[i + 1];
|
||||
driver.menu_ctx = (menu_ctx_driver_t*)menu_ctx_drivers[i + 1];
|
||||
}
|
||||
else
|
||||
RARCH_WARN("Couldn't find any next menu driver (current one: \"%s\").\n", g_settings.menu.driver);
|
||||
|
@ -1,54 +0,0 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2014 - Daniel De Matteis
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MENU_CONTEXT_H
|
||||
#define __MENU_CONTEXT_H
|
||||
|
||||
#include "../../boolean.h"
|
||||
#include "../../driver.h"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
#endif
|
||||
|
||||
typedef struct menu_ctx_driver
|
||||
{
|
||||
void (*set_texture)(void*, bool);
|
||||
void (*render_messagebox)(void*, const char*);
|
||||
void (*render)(void*);
|
||||
void* (*init)(void);
|
||||
void (*free)(void*);
|
||||
void (*init_assets)(void*);
|
||||
void (*free_assets)(void*);
|
||||
void (*populate_entries)(void*, unsigned);
|
||||
void (*iterate)(void*, unsigned);
|
||||
int (*input_postprocess)(void *, uint64_t);
|
||||
|
||||
// Human readable string.
|
||||
const char *ident;
|
||||
} menu_ctx_driver_t;
|
||||
|
||||
extern const menu_ctx_driver_t menu_ctx_rmenu;
|
||||
extern const menu_ctx_driver_t menu_ctx_rmenu_xui;
|
||||
extern const menu_ctx_driver_t menu_ctx_rgui;
|
||||
extern const menu_ctx_driver_t menu_ctx_lakka;
|
||||
|
||||
const void *menu_ctx_find_driver(const char *ident); // Finds driver with ident. Does not initialize.
|
||||
bool menu_ctx_init_first(const void **driver, void **handle); // Finds first suitable driver and initializes.
|
||||
void find_prev_menu_driver(void);
|
||||
void find_next_menu_driver(void);
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user