diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 17b7ede080..928d36430c 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -1531,12 +1531,12 @@ error: d3d11_gfx_free(d3d11); #ifdef HAVE_OPENGL - retroarch_force_video_driver_fallback("gl"); + video_driver_force_fallback("gl"); #elif !defined(__WINRT__) #ifdef HAVE_OPENGL1 - retroarch_force_video_driver_fallback("gl1"); + video_driver_force_fallback("gl1"); #else - retroarch_force_video_driver_fallback("gdi"); + video_driver_force_fallback("gdi"); #endif #endif diff --git a/gfx/drivers/gl2.c b/gfx/drivers/gl2.c index b78c7f8409..00f8b4d4c1 100644 --- a/gfx/drivers/gl2.c +++ b/gfx/drivers/gl2.c @@ -3719,12 +3719,12 @@ static void *gl2_init(const video_info_t *video, } #ifdef _WIN32 - if (string_is_equal(vendor, "Microsoft Corporation")) + if ( string_is_equal(vendor, "Microsoft Corporation")) if (string_is_equal(renderer, "GDI Generic")) #ifdef HAVE_OPENGL1 - retroarch_force_video_driver_fallback("gl1"); + video_driver_force_fallback("gl1"); #else - retroarch_force_video_driver_fallback("gdi"); + video_driver_force_fallback("gdi"); #endif #endif diff --git a/gfx/drivers/gl3.c b/gfx/drivers/gl3.c index 9b82c8af1e..e692c6880c 100644 --- a/gfx/drivers/gl3.c +++ b/gfx/drivers/gl3.c @@ -1271,12 +1271,12 @@ static void *gl_core_init(const video_info_t *video, } #ifdef _WIN32 - if (string_is_equal(vendor, "Microsoft Corporation")) + if ( string_is_equal(vendor, "Microsoft Corporation")) if (string_is_equal(renderer, "GDI Generic")) #ifdef HAVE_OPENGL1 - retroarch_force_video_driver_fallback("gl1"); + video_driver_force_fallback("gl1"); #else - retroarch_force_video_driver_fallback("gdi"); + video_driver_force_fallback("gdi"); #endif #endif diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 17917df2a1..00c3fcc6d8 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -16,8 +16,15 @@ #include +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + #include "video_driver.h" +#include "../ui/ui_companion_driver.h" +#include "../verbosity.h" + typedef struct { struct string_list *list; @@ -227,3 +234,66 @@ bool video_driver_translate_coord_viewport( *res_screen_y = scaled_screen_y; return true; } + +/** + * video_monitor_set_refresh_rate: + * @hz : New refresh rate for monitor. + * + * Sets monitor refresh rate to new value. + **/ +void video_monitor_set_refresh_rate(float hz) +{ + char msg[128]; + settings_t *settings = config_get_ptr(); + + snprintf(msg, sizeof(msg), + "Setting refresh rate to: %.3f Hz.", hz); + if (settings->bools.notification_show_refresh_rate) + runloop_msg_queue_push(msg, 1, 180, false, NULL, + MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); + RARCH_LOG("[Video]: %s\n", msg); + + configuration_set_float(settings, + settings->floats.video_refresh_rate, + hz); +} + +void video_driver_force_fallback(const char *driver) +{ + settings_t *settings = config_get_ptr(); + ui_msg_window_t *msg_window = NULL; + + configuration_set_string(settings, + settings->arrays.video_driver, + driver); + + command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL); + +#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) && !defined(WINAPI_FAMILY) + /* UI companion driver is not inited yet, just call into it directly */ + msg_window = &ui_msg_window_win32; +#endif + + if (msg_window) + { + char text[PATH_MAX_LENGTH]; + ui_msg_window_state window_state; + char *title = strdup(msg_hash_to_str(MSG_ERROR)); + + text[0] = '\0'; + + snprintf(text, sizeof(text), + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_DRIVER_FALLBACK), + driver); + + window_state.buttons = UI_MSG_WINDOW_OK; + window_state.text = strdup(text); + window_state.title = title; + window_state.window = NULL; + + msg_window->error(&window_state); + + free(title); + } + exit(1); +} diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 8da3db1152..129c21d229 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -1125,6 +1125,8 @@ void video_driver_set_gpu_api_version_string(const char *str); const char* video_driver_get_gpu_api_version_string(void); +void video_driver_force_fallback(const char *driver); + /* string list stays owned by the caller and must be available at all times after the video driver is inited */ void video_driver_set_gpu_api_devices(enum gfx_ctx_api api, struct string_list *list); diff --git a/retroarch.c b/retroarch.c index 01f1553509..640274eb6a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -21477,30 +21477,6 @@ void video_driver_set_size(unsigned width, unsigned height) #endif } -/** - * video_monitor_set_refresh_rate: - * @hz : New refresh rate for monitor. - * - * Sets monitor refresh rate to new value. - **/ -void video_monitor_set_refresh_rate(float hz) -{ - char msg[128]; - struct rarch_state *p_rarch = &rarch_st; - settings_t *settings = p_rarch->configuration_settings; - - snprintf(msg, sizeof(msg), - "Setting refresh rate to: %.3f Hz.", hz); - if (settings->bools.notification_show_refresh_rate) - runloop_msg_queue_push(msg, 1, 180, false, NULL, - MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); - RARCH_LOG("[Video]: %s\n", msg); - - configuration_set_float(settings, - settings->floats.video_refresh_rate, - hz); -} - /** * video_monitor_fps_statistics * @refresh_rate : Monitor refresh rate. @@ -29350,47 +29326,6 @@ runloop_state_t *runloop_state_get_ptr(void) return &runloop_state; } -void retroarch_force_video_driver_fallback(const char *driver) -{ - struct rarch_state *p_rarch = &rarch_st; - settings_t *settings = p_rarch->configuration_settings; - ui_msg_window_t *msg_window = NULL; - - configuration_set_string(settings, - settings->arrays.video_driver, - driver); - - command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL); - -#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) && !defined(WINAPI_FAMILY) - /* UI companion driver is not inited yet, just call into it directly */ - msg_window = &ui_msg_window_win32; -#endif - - if (msg_window) - { - char text[PATH_MAX_LENGTH]; - ui_msg_window_state window_state; - char *title = strdup(msg_hash_to_str(MSG_ERROR)); - - text[0] = '\0'; - - snprintf(text, sizeof(text), - msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_DRIVER_FALLBACK), - driver); - - window_state.buttons = UI_MSG_WINDOW_OK; - window_state.text = strdup(text); - window_state.title = title; - window_state.window = NULL; - - msg_window->error(&window_state); - - free(title); - } - exit(1); -} - enum retro_language rarch_get_language_from_iso(const char *iso639) { unsigned i; diff --git a/retroarch.h b/retroarch.h index 46817912c5..30401a1457 100644 --- a/retroarch.h +++ b/retroarch.h @@ -424,8 +424,6 @@ void retroarch_menu_running(void); void retroarch_menu_running_finished(bool quit); -void retroarch_force_video_driver_fallback(const char *driver); - enum retro_language rarch_get_language_from_iso(const char *lang); void rarch_favorites_init(void);