diff --git a/console/rarch_console_video.c b/console/rarch_console_video.c index bfdc38b730..9b3b9c4dea 100644 --- a/console/rarch_console_video.c +++ b/console/rarch_console_video.c @@ -26,27 +26,28 @@ #endif struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END] = { - { "1:1", 1.0f }, - { "2:1", 2.0f }, - { "3:2", 1.5f }, - { "3:4", 0.75f }, - { "4:1", 4.0f }, - { "4:3", 1.3333f }, - { "4:4", 1.0f }, - { "5:4", 1.25f }, - { "6:5", 1.2f }, - { "7:9", 0.7777f }, - { "8:3", 2.6666f }, - { "8:7", 1.1428f }, - { "16:9", 1.7778f }, - { "16:10", 1.6f }, - { "16:15", 3.2f }, - { "19:12", 1.5833f }, - { "19:14", 1.3571f }, - { "30:17", 1.7647f }, - { "32:9", 3.5555f }, - { "Auto", 1.0f }, - { "Custom", 0.0f } + { "1:1", 1.0f }, + { "2:1", 2.0f }, + { "3:2", 1.5f }, + { "3:4", 0.75f }, + { "4:1", 4.0f }, + { "4:3", 1.3333f }, + { "4:4", 1.0f }, + { "5:4", 1.25f }, + { "6:5", 1.2f }, + { "7:9", 0.7777f }, + { "8:3", 2.6666f }, + { "8:7", 1.1428f }, + { "16:9", 1.7778f }, + { "16:10", 1.6f }, + { "16:15", 3.2f }, + { "19:12", 1.5833f }, + { "19:14", 1.3571f }, + { "30:17", 1.7647f }, + { "32:9", 3.5555f }, + { "Auto", 1.0f }, + { "Core Provided", 1.0f }, + { "Custom", 0.0f } }; char rotation_lut[ASPECT_RATIO_END][PATH_MAX] = @@ -76,7 +77,19 @@ void rarch_set_auto_viewport(unsigned width, unsigned height) aspect_y = height / highest; snprintf(aspectratio_lut[ASPECT_RATIO_AUTO].name, sizeof(aspectratio_lut[ASPECT_RATIO_AUTO].name), "%d:%d (Auto)", aspect_x, aspect_y); - aspectratio_lut[ASPECT_RATIO_AUTO].value = (int)aspect_x / (int)aspect_y; + aspectratio_lut[ASPECT_RATIO_AUTO].value = (float) aspect_x / aspect_y; +} + +void rarch_set_core_viewport() +{ + struct retro_system_av_info info; + retro_get_system_av_info(&info); + + // fallback to 1:1 pixel ratio if none provided + if (info.geometry.aspect_ratio == 0.0) + aspectratio_lut[ASPECT_RATIO_CORE].value = (float) info.geometry.base_width / info.geometry.base_height; + else + aspectratio_lut[ASPECT_RATIO_CORE].value = info.geometry.aspect_ratio; } #if defined(HAVE_HLSL) || defined(HAVE_CG) || defined(HAVE_GLSL) diff --git a/console/rarch_console_video.h b/console/rarch_console_video.h index ece0e7183d..e3d768f145 100644 --- a/console/rarch_console_video.h +++ b/console/rarch_console_video.h @@ -58,6 +58,7 @@ enum aspect_ratio ASPECT_RATIO_30_17, ASPECT_RATIO_32_9, ASPECT_RATIO_AUTO, + ASPECT_RATIO_CORE, ASPECT_RATIO_CUSTOM, ASPECT_RATIO_END, @@ -101,6 +102,7 @@ struct aspect_ratio_elem extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END]; extern void rarch_set_auto_viewport(unsigned width, unsigned height); +extern void rarch_set_core_viewport(); extern void rarch_load_shader(unsigned slot, const char *path); #endif diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index 9057c2fae6..db1a23e0ee 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -355,6 +355,8 @@ void gfx_ctx_set_aspect_ratio(void *data, unsigned aspectratio_index) if (g_console.aspect_ratio_index == ASPECT_RATIO_AUTO) rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); + else if(g_console.aspect_ratio_index == ASPECT_RATIO_CUSTOM) + rarch_set_core_viewport(); g_settings.video.aspect_ratio = aspectratio_lut[g_console.aspect_ratio_index].value; g_settings.video.force_aspect = false; diff --git a/gfx/context/xdk_ctx.c b/gfx/context/xdk_ctx.c index 31c9a1154b..cc427b3a61 100644 --- a/gfx/context/xdk_ctx.c +++ b/gfx/context/xdk_ctx.c @@ -158,6 +158,8 @@ void gfx_ctx_set_aspect_ratio(void *data, unsigned aspectratio_index) if(g_console.aspect_ratio_index == ASPECT_RATIO_AUTO) rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); + else if(g_console.aspect_ratio_index == ASPECT_RATIO_CUSTOM) + rarch_set_core_viewport(); g_settings.video.aspect_ratio = aspectratio_lut[g_console.aspect_ratio_index].value; g_settings.video.force_aspect = false; diff --git a/gx/frontend/main.c b/gx/frontend/main.c index 3fa990ee7d..2694f6294c 100644 --- a/gx/frontend/main.c +++ b/gx/frontend/main.c @@ -377,6 +377,10 @@ begin_loop: bool repeat = false; input_gx.poll(NULL); + + rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); + rarch_set_core_viewport(); + audio_start_func(); do{ diff --git a/gx/gx_video.c b/gx/gx_video.c index bd2bf15706..91d7f41b20 100644 --- a/gx/gx_video.c +++ b/gx/gx_video.c @@ -92,6 +92,8 @@ void gx_set_aspect_ratio(void *data, unsigned aspectratio_idx) if (g_console.aspect_ratio_index == ASPECT_RATIO_AUTO) rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); + else if(g_console.aspect_ratio_index == ASPECT_RATIO_CUSTOM) + rarch_set_core_viewport(); g_settings.video.aspect_ratio = aspectratio_lut[g_console.aspect_ratio_index].value; g_settings.video.force_aspect = false; diff --git a/ps3/frontend/main.c b/ps3/frontend/main.c index 2b7e1fdc00..5b3951eed6 100644 --- a/ps3/frontend/main.c +++ b/ps3/frontend/main.c @@ -317,6 +317,7 @@ begin_loop: input_ps3.poll(NULL); rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); + rarch_set_core_viewport(); do{ repeat = rarch_main_iterate(); diff --git a/xdk/frontend/main.c b/xdk/frontend/main.c index e53b90f21d..df6069590b 100644 --- a/xdk/frontend/main.c +++ b/xdk/frontend/main.c @@ -188,6 +188,7 @@ begin_loop: input_xinput.poll(NULL); rarch_set_auto_viewport(g_extern.frame_cache.width, g_extern.frame_cache.height); + rarch_set_core_viewport(); do{ repeat = rarch_main_iterate();