From e89889806b4ef49650f85da302c8d1c10b64a1f6 Mon Sep 17 00:00:00 2001 From: icex2 Date: Sat, 19 Dec 2020 16:57:11 +0100 Subject: [PATCH] d3d9ex: Add new config parameters for forcing screen resolution --- src/main/d3d9exhook/config-gfx.c | 42 ++++++++++++++++++++++++++++++++ src/main/d3d9exhook/config-gfx.h | 5 ++++ 2 files changed, 47 insertions(+) diff --git a/src/main/d3d9exhook/config-gfx.c b/src/main/d3d9exhook/config-gfx.c index bfe1137..ac82f80 100644 --- a/src/main/d3d9exhook/config-gfx.c +++ b/src/main/d3d9exhook/config-gfx.c @@ -16,6 +16,8 @@ #define D3D9EXHOOK_CONFIG_GFX_FORCED_REFRESHRATE_KEY "gfx.forced_refresh_rate" #define D3D9EXHOOK_CONFIG_GFX_DEVICE_ADAPTER_KEY "gfx.device_adapter" #define D3D9EXHOOK_CONFIG_GFX_FORCE_ORIENTATION_KEY "gfx.force_orientation" +#define D3D9EXHOOK_CONFIG_GFX_FORCE_SCREEN_RES_WIDTH_KEY "gfx.force_screen_res.width" +#define D3D9EXHOOK_CONFIG_GFX_FORCE_SCREEN_RES_HEIGHT_KEY "gfx.force_screen_res.height" #define D3D9EXHOOK_CONFIG_GFX_DEFAULT_FRAMED_VALUE false #define D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOWED_VALUE false @@ -25,6 +27,8 @@ #define D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCED_RR_VALUE -1 #define D3D9EXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE -1 #define D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCE_ORIENTATION_VALUE -1 +#define D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCE_SCREEN_RES_WIDTH_VALUE -1 +#define D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCE_SCREEN_RES_HEIGHT_VALUE -1 void d3d9exhook_config_gfx_init(struct cconfig *config) { @@ -78,6 +82,20 @@ void d3d9exhook_config_gfx_init(struct cconfig *config) D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCE_ORIENTATION_VALUE, "Orientation to force monitor into, -1 to use default, " "0, 1, 2, 3 to do 0, 90, 180, 270 degrees"); + + cconfig_util_set_int( + config, + D3D9EXHOOK_CONFIG_GFX_FORCE_SCREEN_RES_WIDTH_KEY, + D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCE_SCREEN_RES_WIDTH_VALUE, + "Force a screen resolution (width), -1 to disable. Use this if the game does not auto " + "detect your monitor's resolution properly, e.g. 1368x768 instead of 1280x720."); + + cconfig_util_set_int( + config, + D3D9EXHOOK_CONFIG_GFX_FORCE_SCREEN_RES_HEIGHT_KEY, + D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCE_SCREEN_RES_HEIGHT_VALUE, + "Force a screen resolution (height), -1 to disable. Use this if the game does not auto " + "detect your monitor's resolution properly, e.g. 1368x768 instead of 1280x720."); } void d3d9exhook_config_gfx_get( @@ -178,4 +196,28 @@ void d3d9exhook_config_gfx_get( D3D9EXHOOK_CONFIG_GFX_FORCE_ORIENTATION_KEY, D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCE_ORIENTATION_VALUE); } + + if (!cconfig_util_get_int( + config, + D3D9EXHOOK_CONFIG_GFX_FORCE_SCREEN_RES_WIDTH_KEY, + &config_gfx->force_screen_res.width, + D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCE_SCREEN_RES_WIDTH_VALUE)) { + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default '%d'", + D3D9EXHOOK_CONFIG_GFX_FORCE_SCREEN_RES_WIDTH_KEY, + D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCE_SCREEN_RES_WIDTH_VALUE); + } + + if (!cconfig_util_get_int( + config, + D3D9EXHOOK_CONFIG_GFX_FORCE_SCREEN_RES_HEIGHT_KEY, + &config_gfx->force_screen_res.height, + D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCE_SCREEN_RES_HEIGHT_VALUE)) { + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default '%d'", + D3D9EXHOOK_CONFIG_GFX_FORCE_SCREEN_RES_HEIGHT_KEY, + D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCE_SCREEN_RES_HEIGHT_VALUE); + } } diff --git a/src/main/d3d9exhook/config-gfx.h b/src/main/d3d9exhook/config-gfx.h index 74586c7..305fecf 100644 --- a/src/main/d3d9exhook/config-gfx.h +++ b/src/main/d3d9exhook/config-gfx.h @@ -18,6 +18,11 @@ struct d3d9exhook_config_gfx { int32_t forced_refresh_rate; int32_t device_adapter; int32_t force_orientation; + + struct force_screen_res { + int32_t width; + int32_t height; + } force_screen_res; }; /**