From a6268692b64671c9317f827551c94bd538974d68 Mon Sep 17 00:00:00 2001 From: Themaister Date: Sun, 1 Sep 2013 13:46:35 +0200 Subject: [PATCH] Add window scale x/y and crop overscan options. --- frontend/menu/menu_common.h | 3 ++ frontend/menu/rgui.c | 67 +++++++++++++++++++++++++++++++++++++ retroarch.cfg | 2 +- settings.c | 3 ++ 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index 8a3a552ae5..4b465bd718 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -120,6 +120,9 @@ typedef enum RGUI_SETTINGS_VIDEO_HARD_SYNC_FRAMES, RGUI_SETTINGS_VIDEO_BLACK_FRAME_INSERTION, RGUI_SETTINGS_VIDEO_SWAP_INTERVAL, + RGUI_SETTINGS_VIDEO_WINDOW_SCALE_X, + RGUI_SETTINGS_VIDEO_WINDOW_SCALE_Y, + RGUI_SETTINGS_VIDEO_CROP_OVERSCAN, RGUI_SETTINGS_VIDEO_REFRESH_RATE_AUTO, RGUI_SETTINGS_VIDEO_OPTIONS_LAST, #ifdef HAVE_SHADER_MANAGER diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index 9bb5c70d08..754d24b63e 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -608,6 +608,15 @@ static void render_text(rgui_handle_t *rgui) case RGUI_SETTINGS_VIDEO_SWAP_INTERVAL: snprintf(type_str, sizeof(type_str), "%u", g_settings.video.swap_interval); break; + case RGUI_SETTINGS_VIDEO_WINDOW_SCALE_X: + snprintf(type_str, sizeof(type_str), "%.1fx", g_settings.video.xscale); + break; + case RGUI_SETTINGS_VIDEO_WINDOW_SCALE_Y: + snprintf(type_str, sizeof(type_str), "%.1fx", g_settings.video.yscale); + break; + case RGUI_SETTINGS_VIDEO_CROP_OVERSCAN: + strlcpy(type_str, g_settings.video.crop_overscan ? "ON" : "OFF", sizeof(type_str)); + break; case RGUI_SETTINGS_VIDEO_HARD_SYNC_FRAMES: snprintf(type_str, sizeof(type_str), "%u", g_settings.video.hard_sync_frames); break; @@ -1510,13 +1519,20 @@ static void rgui_settings_video_options_populate_entries(rgui_handle_t *rgui) rgui_list_push(rgui->selection_buf, "Integer Scale", RGUI_SETTINGS_VIDEO_INTEGER_SCALE, 0); rgui_list_push(rgui->selection_buf, "Aspect Ratio", RGUI_SETTINGS_VIDEO_ASPECT_RATIO, 0); rgui_list_push(rgui->selection_buf, "Custom Ratio", RGUI_SETTINGS_CUSTOM_VIEWPORT, 0); +#if !defined(RARCH_CONSOLE) && !defined(RARCH_MOBILE) rgui_list_push(rgui->selection_buf, "Toggle Fullscreen", RGUI_SETTINGS_TOGGLE_FULLSCREEN, 0); +#endif rgui_list_push(rgui->selection_buf, "Rotation", RGUI_SETTINGS_VIDEO_ROTATION, 0); rgui_list_push(rgui->selection_buf, "VSync", RGUI_SETTINGS_VIDEO_VSYNC, 0); rgui_list_push(rgui->selection_buf, "Hard GPU Sync", RGUI_SETTINGS_VIDEO_HARD_SYNC, 0); rgui_list_push(rgui->selection_buf, "Hard GPU Sync Frames", RGUI_SETTINGS_VIDEO_HARD_SYNC_FRAMES, 0); rgui_list_push(rgui->selection_buf, "Black Frame Insertion", RGUI_SETTINGS_VIDEO_BLACK_FRAME_INSERTION, 0); rgui_list_push(rgui->selection_buf, "VSync Swap Interval", RGUI_SETTINGS_VIDEO_SWAP_INTERVAL, 0); +#if !defined(RARCH_CONSOLE) && !defined(RARCH_MOBILE) + rgui_list_push(rgui->selection_buf, "Windowed Scale (X)", RGUI_SETTINGS_VIDEO_WINDOW_SCALE_X, 0); + rgui_list_push(rgui->selection_buf, "Windowed Scale (Y)", RGUI_SETTINGS_VIDEO_WINDOW_SCALE_Y, 0); +#endif + rgui_list_push(rgui->selection_buf, "Crop Overscan (reload)", RGUI_SETTINGS_VIDEO_CROP_OVERSCAN, 0); rgui_list_push(rgui->selection_buf, "Estimated Monitor FPS", RGUI_SETTINGS_VIDEO_REFRESH_RATE_AUTO, 0); } @@ -1962,6 +1978,57 @@ static int video_option_toggle_setting(rgui_handle_t *rgui, unsigned setting, rg } break; + case RGUI_SETTINGS_VIDEO_CROP_OVERSCAN: + switch (action) + { + case RGUI_ACTION_START: + g_settings.video.crop_overscan = true; + break; + + case RGUI_ACTION_LEFT: + case RGUI_ACTION_RIGHT: + case RGUI_ACTION_OK: + g_settings.video.crop_overscan = !g_settings.video.crop_overscan; + break; + + default: + break; + } + break; + + case RGUI_SETTINGS_VIDEO_WINDOW_SCALE_X: + case RGUI_SETTINGS_VIDEO_WINDOW_SCALE_Y: + { + float *scale = setting == RGUI_SETTINGS_VIDEO_WINDOW_SCALE_X ? &g_settings.video.xscale : &g_settings.video.yscale; + float old_scale = *scale; + + switch (action) + { + case RGUI_ACTION_START: + *scale = 3.0f; + break; + + case RGUI_ACTION_LEFT: + *scale -= 1.0f; + break; + + case RGUI_ACTION_RIGHT: + *scale += 1.0f; + break; + + default: + break; + } + + *scale = roundf(*scale); + *scale = max(*scale, 1.0f); + + if (old_scale != *scale && !g_settings.video.fullscreen) + rarch_set_fullscreen(g_settings.video.fullscreen); // Reinit video driver. + + break; + } + case RGUI_SETTINGS_VIDEO_SWAP_INTERVAL: { unsigned old = g_settings.video.swap_interval; diff --git a/retroarch.cfg b/retroarch.cfg index ebf66a1b85..29494888c1 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -120,7 +120,7 @@ # Forces cropping of overscanned frames. # Exact behavior of this option is implementation specific. -# video_crop_overscan = false +# video_crop_overscan = true # Path to shader. Shader can be either Cg, CGP (Cg preset) or XML/GLSL format if support is enabled. # video_shader = "/path/to/shader.{cg,cgp,shader}" diff --git a/settings.c b/settings.c index fd95524334..eca070c127 100644 --- a/settings.c +++ b/settings.c @@ -976,6 +976,9 @@ bool config_save_file(const char *path) config_set_string(conf, "video_shader", g_settings.video.shader_path); config_set_bool(conf, "video_shader_enable", g_settings.video.shader_enable); config_set_float(conf, "video_aspect_ratio", g_settings.video.aspect_ratio); + config_set_float(conf, "video_xscale", g_settings.video.xscale); + config_set_float(conf, "video_yscale", g_settings.video.yscale); + config_set_bool(conf, "video_crop_overscan", g_settings.video.crop_overscan); config_set_bool(conf, "video_scale_integer", g_settings.video.scale_integer); config_set_bool(conf, "video_smooth", g_settings.video.smooth); config_set_float(conf, "video_refresh_rate", g_settings.video.refresh_rate);