From f788249c5906ede0835e6e23efa944392b7bb440 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 27 May 2014 17:13:53 +0200 Subject: [PATCH] (Menu) Add get_default_menu function for default settings --- config.def.h | 13 +++++++++++++ driver.c | 2 +- frontend/menu/disp/rmenu.c | 3 +++ frontend/menu/disp/rmenu_xui.cpp | 6 ++---- settings.c | 26 ++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/config.def.h b/config.def.h index b6c8564ccd..6ad6ce3fef 100644 --- a/config.def.h +++ b/config.def.h @@ -99,6 +99,11 @@ enum OSK_PS3, OSK_NULL, + + MENU_RGUI, + MENU_RMENU, + MENU_RMENU_XUI, + MENU_LAKKA, }; #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(__CELLOS_LV2__) @@ -233,6 +238,14 @@ enum #define OSK_DEFAULT_DRIVER OSK_NULL #endif +#if defined(HAVE_RMENU) +#define MENU_DEFAULT_DRIVER MENU_RMENU +#elif defined(HAVE_RMENU_XUI) +#define MENU_DEFAULT_DRIVER MENU_RMENU_XUI +#else +#define MENU_DEFAULT_DRIVER MENU_RGUI +#endif + #if defined(XENON) || defined(_XBOX360) || defined(__CELLOS_LV2__) #define DEFAULT_ASPECT_RATIO 1.7778f #elif defined(_XBOX1) || defined(GEKKO) || defined(ANDROID) || defined(__QNX__) diff --git a/driver.c b/driver.c index 961adc7ad8..c38bd556ee 100644 --- a/driver.c +++ b/driver.c @@ -511,10 +511,10 @@ void global_init_drivers(void) { find_audio_driver(); find_input_driver(); + init_video_input(); #ifdef HAVE_MENU find_menu_driver(); #endif - init_video_input(); } void global_uninit_drivers(void) diff --git a/frontend/menu/disp/rmenu.c b/frontend/menu/disp/rmenu.c index 441ee134df..841773fb6f 100644 --- a/frontend/menu/disp/rmenu.c +++ b/frontend/menu/disp/rmenu.c @@ -454,6 +454,9 @@ static void *rmenu_init(void) { rgui_handle_t *rgui = (rgui_handle_t*)calloc(1, sizeof(*rgui)); + if (!rgui) + return NULL; + rmenu_init_assets(rgui); return rgui; diff --git a/frontend/menu/disp/rmenu_xui.cpp b/frontend/menu/disp/rmenu_xui.cpp index ff5b6021be..33f7831ec4 100644 --- a/frontend/menu/disp/rmenu_xui.cpp +++ b/frontend/menu/disp/rmenu_xui.cpp @@ -155,11 +155,9 @@ static void* rmenu_xui_init(void) HRESULT hr; rgui_handle_t *rgui = (rgui_handle_t*)calloc(1, sizeof(*rgui)); - if (rgui == NULL) - { - RARCH_ERR("Could not allocate RGUI handle.\n"); + + if (!rgui) return NULL; - } d3d_video_t *d3d= (d3d_video_t*)driver.video_data; diff --git a/settings.c b/settings.c index 0683c0c61a..b5387e824b 100644 --- a/settings.c +++ b/settings.c @@ -151,6 +151,25 @@ const char *config_get_default_input(void) } } +#ifdef HAVE_MENU +const char *config_get_default_menu(void) +{ + switch (MENU_DEFAULT_DRIVER) + { + case MENU_RGUI: + return "rgui"; + case MENU_RMENU: + return "rmenu"; + case MENU_RMENU_XUI: + return "rmenu_xui"; + case MENU_LAKKA: + return "lakka"; + default: + return "NULL"; + } +} +#endif + #ifdef HAVE_OSK const char *config_get_default_osk(void) { @@ -226,6 +245,9 @@ void config_set_defaults(void) const char *def_image = config_get_default_image(); const char *def_audio = config_get_default_audio(); const char *def_input = config_get_default_input(); +#ifdef HAVE_MENU + const char *def_menu = config_get_default_menu(); +#endif #ifdef HAVE_CAMERA const char *def_camera = config_get_default_camera(); @@ -254,6 +276,10 @@ void config_set_defaults(void) strlcpy(g_settings.input.driver, def_input, sizeof(g_settings.input.driver)); if (def_image) strlcpy(g_settings.image.driver, def_image, sizeof(g_settings.image.driver)); +#ifdef HAVE_MENU + if (def_menu) + strlcpy(g_settings.menu.driver, def_menu, sizeof(g_settings.menu.driver)); +#endif g_settings.load_dummy_on_core_shutdown = load_dummy_on_core_shutdown;