From dd44b2c9e24c614a9968ce820a9ef2c31da3d568 Mon Sep 17 00:00:00 2001 From: Will Xyen Date: Thu, 4 Feb 2021 23:18:13 -0800 Subject: [PATCH] d3d9ex: add windowed position setting --- dist/iidx/iidxhook-27.conf | 8 ++++++- dist/sdvx5/sdvxhook2.conf | 8 ++++++- src/main/d3d9exhook/config-gfx.c | 40 ++++++++++++++++++++++++++++++++ src/main/d3d9exhook/config-gfx.h | 2 ++ src/main/d3d9exhook/d3d9ex.c | 15 ++++++++++++ 5 files changed, 71 insertions(+), 2 deletions(-) diff --git a/dist/iidx/iidxhook-27.conf b/dist/iidx/iidxhook-27.conf index 2590c47..01fc938 100644 --- a/dist/iidx/iidxhook-27.conf +++ b/dist/iidx/iidxhook-27.conf @@ -34,7 +34,7 @@ gfx.framed=true # Run the game windowed gfx.windowed=false -# Confine mouse coursor to window +# Confine mouse cursor to window gfx.confined=false # Windowed width, -1 for default size @@ -43,6 +43,12 @@ gfx.window_width=-1 # Windowed height, -1 for default size gfx.window_height=-1 +# Windowed X, -1 for default X position +gfx.window_x=-1 + +# Windowed Y, -1 for default Y position +gfx.window_y=-1 + # Forced refresh rate, -1 to not force any (try 59 or 60 if monitor check fails to lock on high refresh rate monitors) gfx.forced_refresh_rate=-1 diff --git a/dist/sdvx5/sdvxhook2.conf b/dist/sdvx5/sdvxhook2.conf index 464628e..3a0106b 100644 --- a/dist/sdvx5/sdvxhook2.conf +++ b/dist/sdvx5/sdvxhook2.conf @@ -19,7 +19,7 @@ gfx.framed=true # Run the game windowed gfx.windowed=false -# Confine mouse coursor to window +# Confine mouse cursor to window gfx.confined=false # Windowed width, -1 for default size @@ -28,6 +28,12 @@ gfx.window_width=1080 # Windowed height, -1 for default size gfx.window_height=1920 +# Windowed X, -1 for default X position +gfx.window_x=-1 + +# Windowed Y, -1 for default Y position +gfx.window_y=-1 + # Forced refresh rate, -1 to not force any (try 59 or 60 if monitor check fails to lock on high refresh rate monitors) gfx.forced_refresh_rate=-1 diff --git a/src/main/d3d9exhook/config-gfx.c b/src/main/d3d9exhook/config-gfx.c index ac82f80..8b75daf 100644 --- a/src/main/d3d9exhook/config-gfx.c +++ b/src/main/d3d9exhook/config-gfx.c @@ -13,6 +13,8 @@ #define D3D9EXHOOK_CONFIG_GFX_CONFINED_KEY "gfx.confined" #define D3D9EXHOOK_CONFIG_GFX_WINDOW_WIDTH_KEY "gfx.window_width" #define D3D9EXHOOK_CONFIG_GFX_WINDOW_HEIGHT_KEY "gfx.window_height" +#define D3D9EXHOOK_CONFIG_GFX_WINDOW_X_KEY "gfx.window_x" +#define D3D9EXHOOK_CONFIG_GFX_WINDOW_Y_KEY "gfx.window_y" #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" @@ -24,6 +26,8 @@ #define D3D9EXHOOK_CONFIG_GFX_DEFAULT_CONFINED_VALUE false #define D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOW_WIDTH_VALUE -1 #define D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOW_HEIGHT_VALUE -1 +#define D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOW_X_VALUE -1 +#define D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOW_Y_VALUE -1 #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 @@ -62,6 +66,18 @@ void d3d9exhook_config_gfx_init(struct cconfig *config) D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOW_HEIGHT_VALUE, "Windowed height, -1 for default size"); + cconfig_util_set_int( + config, + D3D9EXHOOK_CONFIG_GFX_WINDOW_X_KEY, + D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOW_X_VALUE, + "Windowed X, -1 for default X position"); + + cconfig_util_set_int( + config, + D3D9EXHOOK_CONFIG_GFX_WINDOW_Y_KEY, + D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOW_Y_VALUE, + "Windowed Y, -1 for default Y position"); + cconfig_util_set_int( config, D3D9EXHOOK_CONFIG_GFX_FORCED_REFRESHRATE_KEY, @@ -161,6 +177,30 @@ void d3d9exhook_config_gfx_get( D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOW_HEIGHT_VALUE); } + if (!cconfig_util_get_int( + config, + D3D9EXHOOK_CONFIG_GFX_WINDOW_X_KEY, + &config_gfx->window_x, + D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOW_X_VALUE)) { + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default '%d'", + D3D9EXHOOK_CONFIG_GFX_WINDOW_X_KEY, + D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOW_X_VALUE); + } + + if (!cconfig_util_get_int( + config, + D3D9EXHOOK_CONFIG_GFX_WINDOW_Y_KEY, + &config_gfx->window_y, + D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOW_Y_VALUE)) { + log_warning( + "Invalid value for key '%s' specified, fallback " + "to default '%d'", + D3D9EXHOOK_CONFIG_GFX_WINDOW_Y_KEY, + D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOW_Y_VALUE); + } + if (!cconfig_util_get_int( config, D3D9EXHOOK_CONFIG_GFX_FORCED_REFRESHRATE_KEY, diff --git a/src/main/d3d9exhook/config-gfx.h b/src/main/d3d9exhook/config-gfx.h index 305fecf..e976079 100644 --- a/src/main/d3d9exhook/config-gfx.h +++ b/src/main/d3d9exhook/config-gfx.h @@ -15,6 +15,8 @@ struct d3d9exhook_config_gfx { bool confined; int32_t window_width; int32_t window_height; + int32_t window_x; + int32_t window_y; int32_t forced_refresh_rate; int32_t device_adapter; int32_t force_orientation; diff --git a/src/main/d3d9exhook/d3d9ex.c b/src/main/d3d9exhook/d3d9ex.c index 18d0ef2..9fcb6cd 100644 --- a/src/main/d3d9exhook/d3d9ex.c +++ b/src/main/d3d9exhook/d3d9ex.c @@ -88,6 +88,8 @@ static bool d3d9ex_confined; static int32_t d3d9ex_force_refresh_rate = -1; static int32_t d3d9ex_window_width = -1; static int32_t d3d9ex_window_height = -1; +static int32_t d3d9ex_window_x = -1; +static int32_t d3d9ex_window_y = -1; static bool d3d9ex_window_framed; static int32_t d3d9ex_device_adapter = -1; static int32_t d3d9ex_force_orientation = -1; @@ -174,6 +176,17 @@ my_MoveWindow(HWND hWnd, int X, int Y, int nWidth, int nHeight, BOOL bRepaint) nWidth = d3d9ex_window_width; nHeight = d3d9ex_window_height; } + if (d3d9ex_window_x != -1 && d3d9ex_window_y != -1) { + log_misc( + "Overriding window position from %dx%d with %dx%d", + X, + Y, + d3d9ex_window_x, + d3d9ex_window_y); + + X = d3d9ex_window_x; + Y = d3d9ex_window_y; + } if (d3d9ex_window_framed) { /* we have to adjust the window size, because the window needs to @@ -458,6 +471,8 @@ void d3d9ex_configure(struct d3d9exhook_config_gfx *gfx_config) d3d9ex_window_framed = gfx_config->framed; d3d9ex_window_width = gfx_config->window_width; d3d9ex_window_height = gfx_config->window_height; + d3d9ex_window_x = gfx_config->window_x; + d3d9ex_window_y = gfx_config->window_y; d3d9ex_force_refresh_rate = gfx_config->forced_refresh_rate; d3d9ex_device_adapter = gfx_config->device_adapter;