diff --git a/config.def.h b/config.def.h index 076b8ae828..6d2014ab00 100644 --- a/config.def.h +++ b/config.def.h @@ -421,6 +421,12 @@ static const bool windowed_fullscreen = true; * specific monitors, 1 being the first monitor. */ static const unsigned monitor_index = 0; +/* Window */ +/* Window size. A value of 0 uses window scale + * multiplied by the core framebuffer size. */ +static const unsigned window_x = 0; +static const unsigned window_y = 0; + /* Fullscreen resolution. A value of 0 uses the desktop * resolution. */ static const unsigned fullscreen_x = 0; diff --git a/configuration.c b/configuration.c index 456cd82f7f..4cb16f5df9 100644 --- a/configuration.c +++ b/configuration.c @@ -887,6 +887,8 @@ static int populate_settings_int(settings_t *settings, struct config_int_setting SETTING_INT("video_monitor_index", &settings->video.monitor_index, true, monitor_index, false); SETTING_INT("video_fullscreen_x", &settings->video.fullscreen_x, true, fullscreen_x, false); SETTING_INT("video_fullscreen_y", &settings->video.fullscreen_y, true, fullscreen_y, false); + SETTING_INT("video_window_x", &settings->video.window_x, true, fullscreen_x, false); + SETTING_INT("video_window_y", &settings->video.window_y, true, fullscreen_y, false); #ifdef HAVE_COMMAND SETTING_INT("network_cmd_port", &settings->network_cmd_port, true, network_cmd_port, false); #endif diff --git a/configuration.h b/configuration.h index 4191c4aeae..1980612f95 100644 --- a/configuration.h +++ b/configuration.h @@ -54,6 +54,8 @@ typedef struct settings char driver[32]; char context_driver[32]; float scale; + unsigned window_x; + unsigned window_y; bool fullscreen; bool windowed_fullscreen; unsigned monitor_index; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 3207ce3b47..f40fb0ba0a 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -674,16 +674,24 @@ static bool init_video(void) } else { - if (settings->video.force_aspect) + if(settings->video.window_x || settings->video.window_y) { - /* Do rounding here to simplify integer scale correctness. */ - unsigned base_width = - roundf(geom->base_height * video_driver_get_aspect_ratio()); - width = roundf(base_width * settings->video.scale); + width = settings->video.window_x; + height = settings->video.window_y; } else - width = roundf(geom->base_width * settings->video.scale); - height = roundf(geom->base_height * settings->video.scale); + { + if (settings->video.force_aspect) + { + /* Do rounding here to simplify integer scale correctness. */ + unsigned base_width = + roundf(geom->base_height * video_driver_get_aspect_ratio()); + width = roundf(base_width * settings->video.scale); + } + else + width = roundf(geom->base_width * settings->video.scale); + height = roundf(geom->base_height * settings->video.scale); + } } if (width && height) diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index b8dc055eaa..bfdaadcd0f 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1042,6 +1042,10 @@ MSG_HASH(MENU_ENUM_LABEL_VIDEO_VSYNC, "video_vsync") MSG_HASH(MENU_ENUM_LABEL_VIDEO_WINDOWED_FULLSCREEN, "video_windowed_fullscreen") +MSG_HASH(MENU_ENUM_LABEL_VIDEO_WINDOW_WIDTH, + "video_window_width") +MSG_HASH(MENU_ENUM_LABEL_VIDEO_WINDOW_HEIGHT, + "video_window_height") MSG_HASH(MENU_ENUM_LABEL_WIFI_DRIVER, "wifi_driver") MSG_HASH(MENU_ENUM_LABEL_WIFI_SETTINGS, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 1b8fda7a1c..9aa0a7f6f6 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -1552,6 +1552,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_VSYNC, "Vertical Sync (Vsync)") MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOWED_FULLSCREEN, "Windowed Fullscreen Mode") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_WIDTH, + "Window Width") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_HEIGHT, + "Window Height") MSG_HASH(MENU_ENUM_LABEL_VALUE_WIFI_DRIVER, "Wi-Fi Driver") MSG_HASH(MENU_ENUM_LABEL_VALUE_WIFI_SETTINGS, @@ -1686,6 +1690,8 @@ MSG_HASH(MENU_ENUM_SUBLABEL_SSH_ENABLE, "Enable or disable remote command line access.") MSG_HASH(MENU_ENUM_SUBLABEL_SUSPEND_SCREENSAVER_ENABLE, "Prevents your system's screensaver from becoming active.") +MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_WINDOW_SCALE, + "Sets the window size relative to the core viewport size. Alternatively you can set a window width and height below for a fixed window size") MSG_HASH(MENU_ENUM_SUBLABEL_USER_LANGUAGE, "Sets the language of the interface.") MSG_HASH(MENU_ENUM_SUBLABEL_VIDEO_BLACK_FRAME_INSERTION, diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index f473b081ca..7a5a65789a 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -54,6 +54,7 @@ default_sublabel_macro(action_bind_sublabel_cheevos_hardcore_mode_enable, MENU_ default_sublabel_macro(action_bind_sublabel_menu_settings_list, MENU_ENUM_SUBLABEL_MENU_SETTINGS) default_sublabel_macro(action_bind_sublabel_video_settings_list, MENU_ENUM_SUBLABEL_VIDEO_SETTINGS) default_sublabel_macro(action_bind_sublabel_suspend_screensaver_enable, MENU_ENUM_SUBLABEL_SUSPEND_SCREENSAVER_ENABLE) +default_sublabel_macro(action_bind_sublabel_video_window_scale, MENU_ENUM_SUBLABEL_VIDEO_WINDOW_SCALE) default_sublabel_macro(action_bind_sublabel_audio_settings_list, MENU_ENUM_SUBLABEL_AUDIO_SETTINGS) default_sublabel_macro(action_bind_sublabel_input_settings_list, MENU_ENUM_SUBLABEL_INPUT_SETTINGS) default_sublabel_macro(action_bind_sublabel_wifi_settings_list, MENU_ENUM_SUBLABEL_WIFI_SETTINGS) @@ -367,6 +368,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_SUSPEND_SCREENSAVER_ENABLE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_suspend_screensaver_enable); break; + case MENU_ENUM_LABEL_VIDEO_SCALE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_window_scale); + break; default: case MSG_UNKNOWN: return -1; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index be72df7e75..cbff267def 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5187,6 +5187,12 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_SCALE, PARSE_ONLY_FLOAT, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_VIDEO_WINDOW_WIDTH, + PARSE_ONLY_UINT, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_VIDEO_WINDOW_HEIGHT, + PARSE_ONLY_UINT, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER, PARSE_ONLY_BOOL, false); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 1546088b4d..fe4c9783d5 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3153,7 +3153,6 @@ static bool setting_append_list( general_read_handler, SD_FLAG_NONE); } - CONFIG_FLOAT( list, list_info, &settings->video.refresh_rate, @@ -3331,6 +3330,30 @@ static bool setting_append_list( general_write_handler, general_read_handler); menu_settings_list_current_add_range(list, list_info, 1.0, 10.0, 1.0, true, true); + CONFIG_UINT( + list, list_info, + &settings->video.window_x, + MENU_ENUM_LABEL_VIDEO_WINDOW_WIDTH, + MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_WIDTH, + 0, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + menu_settings_list_current_add_range(list, list_info, 0, 7680, 8, true, true); + CONFIG_UINT( + list, list_info, + &settings->video.window_y, + MENU_ENUM_LABEL_VIDEO_WINDOW_HEIGHT, + MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_HEIGHT, + 0, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + menu_settings_list_current_add_range(list, list_info, 0, 4320, 8, true, true); } CONFIG_BOOL( diff --git a/msg_hash.h b/msg_hash.h index 735bc52e8a..db7e111985 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -574,6 +574,8 @@ enum msg_hash_enums MENU_LABEL(VIDEO_HARD_SYNC), MENU_LABEL(VIDEO_HARD_SYNC_FRAMES), MENU_LABEL(VIDEO_WINDOWED_FULLSCREEN), + MENU_LABEL(VIDEO_WINDOW_WIDTH), + MENU_LABEL(VIDEO_WINDOW_HEIGHT), MENU_LABEL(VIDEO_FORCE_SRGB_DISABLE), MENU_LABEL(VIDEO_ROTATION), MENU_LABEL(VIDEO_SCALE), @@ -595,6 +597,7 @@ enum msg_hash_enums MENU_LABEL(VIDEO_SWAP_INTERVAL), MENU_LABEL(VIDEO_FULLSCREEN), MENU_LABEL(VIDEO_MONITOR_INDEX), + MENU_LABEL(VIDEO_WINDOW_SCALE), MENU_LABEL(VIDEO_REFRESH_RATE), MENU_LABEL(VIDEO_REFRESH_RATE_AUTO),