mirror of
https://github.com/djhackersdev/bemanitools.git
synced 2025-02-21 04:48:42 +01:00
d3d9exhook: Add option to specify the display adapter to open
This commit is contained in:
parent
b1fd175318
commit
8ae06f6f4b
@ -1,3 +1,5 @@
|
||||
#include <d3d9.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "cconfig/cconfig-util.h"
|
||||
@ -11,12 +13,14 @@
|
||||
#define D3D9EXHOOK_CONFIG_GFX_WINDOW_WIDTH_KEY "gfx.window_width"
|
||||
#define D3D9EXHOOK_CONFIG_GFX_WINDOW_HEIGHT_KEY "gfx.window_height"
|
||||
#define D3D9EXHOOK_CONFIG_GFX_FORCED_RR_KEY "gfx.forced_refresh_rate"
|
||||
#define D3D9EXHOOK_CONFIG_GFX_DEVICE_ADAPTER_KEY "gfx.device_adapter"
|
||||
|
||||
#define D3D9EXHOOK_CONFIG_GFX_DEFAULT_FRAMED_VALUE false
|
||||
#define D3D9EXHOOK_CONFIG_GFX_DEFAULT_WINDOWED_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_FORCED_RR_VALUE -1
|
||||
#define D3D9EXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE D3DADAPTER_DEFAULT
|
||||
|
||||
void d3d9exhook_config_gfx_init(struct cconfig *config)
|
||||
{
|
||||
@ -49,6 +53,12 @@ void d3d9exhook_config_gfx_init(struct cconfig *config)
|
||||
D3D9EXHOOK_CONFIG_GFX_FORCED_RR_KEY,
|
||||
D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCED_RR_VALUE,
|
||||
"Forced refresh rate, -1 to not force any (try 59 or 60 if monitor check fails to lock on high refresh rate monitors)");
|
||||
|
||||
cconfig_util_set_int(
|
||||
config,
|
||||
D3D9EXHOOK_CONFIG_GFX_DEVICE_ADAPTER_KEY,
|
||||
D3D9EXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE,
|
||||
"D3D9ex device adapter (monitor), 0 (D3DADAPTER_DEFAULT) to use default, 1, 2 etc. to use specified adapter");
|
||||
}
|
||||
|
||||
void d3d9exhook_config_gfx_get(
|
||||
@ -113,4 +123,25 @@ void d3d9exhook_config_gfx_get(
|
||||
D3D9EXHOOK_CONFIG_GFX_FORCED_RR_KEY,
|
||||
D3D9EXHOOK_CONFIG_GFX_DEFAULT_FORCED_RR_VALUE);
|
||||
}
|
||||
|
||||
if (!cconfig_util_get_int(
|
||||
config,
|
||||
D3D9EXHOOK_CONFIG_GFX_DEVICE_ADAPTER_KEY,
|
||||
&config_gfx->device_adapter,
|
||||
D3D9EXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE)) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
D3D9EXHOOK_CONFIG_GFX_DEVICE_ADAPTER_KEY,
|
||||
D3D9EXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE);
|
||||
}
|
||||
|
||||
if (config_gfx->device_adapter < 0) {
|
||||
log_warning(
|
||||
"Invalid value for key '%s' specified, fallback "
|
||||
"to default '%d'",
|
||||
D3D9EXHOOK_CONFIG_GFX_DEVICE_ADAPTER_KEY,
|
||||
D3D9EXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE);
|
||||
config_gfx->device_adapter = D3D9EXHOOK_CONFIG_GFX_DEFAULT_DEVICE_ADAPTER_VALUE;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ struct d3d9exhook_config_gfx {
|
||||
int32_t window_width;
|
||||
int32_t window_height;
|
||||
int32_t forced_refresh_rate;
|
||||
int32_t device_adapter;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -86,6 +86,7 @@ static int32_t d3d9ex_force_refresh_rate = -1;
|
||||
static int32_t d3d9ex_window_width = -1;
|
||||
static int32_t d3d9ex_window_height = -1;
|
||||
static bool d3d9ex_window_framed;
|
||||
static int32_t d3d9ex_device_adapter = D3DADAPTER_DEFAULT;
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
@ -208,6 +209,11 @@ static HRESULT STDCALL my_CreateDeviceEx(
|
||||
}
|
||||
}
|
||||
|
||||
if (d3d9ex_device_adapter != D3DADAPTER_DEFAULT) {
|
||||
log_info("Forcing adapter %d -> %d", adapter, d3d9ex_device_adapter);
|
||||
adapter = d3d9ex_device_adapter;
|
||||
}
|
||||
|
||||
hr = IDirect3D9Ex_CreateDeviceEx(
|
||||
real, adapter, type, hwnd, flags, pp, fdm, pdev);
|
||||
|
||||
@ -269,6 +275,7 @@ void d3d9ex_configure(struct d3d9exhook_config_gfx* gfx_config)
|
||||
d3d9ex_window_height = gfx_config->window_height;
|
||||
|
||||
d3d9ex_force_refresh_rate = gfx_config->forced_refresh_rate;
|
||||
d3d9ex_device_adapter = gfx_config->device_adapter;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
Loading…
x
Reference in New Issue
Block a user