ddr: Fix windowed mode regressions

This commit is contained in:
QCDLZCLW3K
2022-05-30 02:00:49 +00:00
parent da736d2968
commit 4cc81f48f3
6 changed files with 53 additions and 8 deletions
+18 -2
View File
@@ -35,8 +35,9 @@ static BOOL STDCALL my_SetWindowPos(
HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags);
static bool gfx_windowed;
static bool gfx_is_modern;
static const struct hook_symbol misc_user32_syms[] = {
static const struct hook_symbol gfx_user32_syms[] = {
{
.name = "ChangeDisplaySettingsExA",
.patch = my_ChangeDisplaySettingsExA,
@@ -121,6 +122,11 @@ static LONG STDCALL my_SetWindowLongW(HWND hWnd, int nIndex, LONG dwNewLong)
static BOOL STDCALL my_SetWindowPos(
HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
{
// Causes DDR A to have a really wide window
if (gfx_get_is_modern()) {
return true;
}
if (gfx_get_windowed()) {
WINDOWPOS wp;
@@ -138,7 +144,7 @@ static BOOL STDCALL my_SetWindowPos(
void gfx_insert_hooks(HMODULE target)
{
hook_table_apply(
target, "user32.dll", misc_user32_syms, lengthof(misc_user32_syms));
target, "user32.dll", gfx_user32_syms, lengthof(gfx_user32_syms));
log_info("Initialized d3d9 hooks");
}
@@ -153,6 +159,16 @@ void gfx_set_windowed(void)
gfx_windowed = true;
}
bool gfx_get_is_modern(void)
{
return gfx_is_modern;
}
void gfx_set_is_modern(void)
{
gfx_is_modern = true;
}
/* ------------------------------------------------------------------------- */
static void gfx_d3d9_patch_window(struct hook_d3d9_irp *irp)
+3
View File
@@ -13,6 +13,9 @@ struct ddrhook1_d3d9_config {
bool gfx_get_windowed(void);
void gfx_set_windowed(void);
bool gfx_get_is_modern(void);
void gfx_set_is_modern(void);
void gfx_d3d9_calc_win_size_with_framed(
HWND hwnd, DWORD x, DWORD y, DWORD width, DWORD height, LPWINDOWPOS wp);
+19
View File
@@ -13,6 +13,7 @@
static LRESULT(STDCALL *real_SendMessageW)(
HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
static HWND(STDCALL *real_CreateWindowExW)(
DWORD dwExStyle,
LPCWSTR lpClassName,
@@ -30,6 +31,7 @@ static HWND(STDCALL *real_CreateWindowExW)(
static SHORT STDCALL my_GetKeyState(int vk);
static LRESULT STDCALL
my_SendMessageW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
static HWND STDCALL my_CreateWindowExA(
DWORD dwExStyle,
LPCSTR lpClassName,
@@ -92,6 +94,23 @@ static HWND STDCALL my_CreateWindowExW(
HINSTANCE hInstance,
LPVOID lpParam)
{
// This breaks DDR X, X2 and X3
if (gfx_get_is_modern()) {
return real_CreateWindowExW(
dwExStyle,
lpClassName,
lpWindowName,
dwStyle,
X,
Y,
nWidth,
nHeight,
hWndParent,
hMenu,
hInstance,
lpParam);
}
if (gfx_get_windowed()) {
/* use a different style */
dwStyle |= WS_OVERLAPPEDWINDOW;