diff --git a/driver.c b/driver.c index d57e15ec1b..114dfbb169 100644 --- a/driver.c +++ b/driver.c @@ -498,7 +498,7 @@ void init_video_input(void) init_shader_dir(); #endif - struct retro_game_geometry *geom = &g_extern.system.av_info.geometry; + const struct retro_game_geometry *geom = &g_extern.system.av_info.geometry; unsigned max_dim = max(geom->max_width, geom->max_height); unsigned scale = max_dim / SSNES_SCALE_BASE; scale = max(scale, 1); @@ -529,7 +529,11 @@ void init_video_input(void) if (g_settings.video.aspect_ratio < 0.0f) { - g_settings.video.aspect_ratio = (float)geom->base_width / geom->base_height; + if (geom->aspect_ratio > 0.0f && g_settings.video.aspect_ratio_auto) + g_settings.video.aspect_ratio = geom->aspect_ratio; + else + g_settings.video.aspect_ratio = (float)geom->base_width / geom->base_height; + SSNES_LOG("Adjusting aspect ratio to %.2f\n", g_settings.video.aspect_ratio); } diff --git a/general.h b/general.h index c9929ac73a..105bdfc8f8 100644 --- a/general.h +++ b/general.h @@ -94,6 +94,7 @@ struct settings bool force_aspect; bool crop_overscan; float aspect_ratio; + bool aspect_ratio_auto; char cg_shader_path[PATH_MAX]; char bsnes_shader_path[PATH_MAX]; char filter_path[PATH_MAX]; diff --git a/libretro.h b/libretro.h index 88bc5e1119..fef36cacde 100755 --- a/libretro.h +++ b/libretro.h @@ -119,6 +119,10 @@ struct retro_game_geometry unsigned base_height; // Nominal video height of game. unsigned max_width; // Maximum possible width of game. unsigned max_height; // Maximum possible height of game. + + float aspect_ratio; // Nominal aspect ratio of game. If aspect_ratio is <= 0.0, + // an aspect ratio of base_width / base_height is assumed. + // A frontend could override this setting if desired. }; struct retro_system_timing