From e3e7dc22e1d268f8d6a0f9e0412f848a0a732d1e Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 26 Oct 2024 21:40:28 +0200 Subject: [PATCH] improve debug logs --- inc/debug.h | 1 + src/debug.c | 22 ++++++++++++++++++++++ src/directinput.c | 2 ++ 3 files changed, 25 insertions(+) diff --git a/inc/debug.h b/inc/debug.h index c0372f1..4eb5310 100644 --- a/inc/debug.h +++ b/inc/debug.h @@ -27,6 +27,7 @@ void dbg_dump_dds_caps(DWORD caps); void dbg_dump_dds_flags(DWORD flags); void dbg_dump_dds_blt_fast_flags(DWORD flags); void dbg_dump_dds_lock_flags(DWORD flags); +void dbg_dump_di_scm_flags(DWORD flags); char* dbg_d3d9_hr_to_str(HRESULT hr); char* dbg_mes_to_str(int id); void __cdecl dbg_invoke_watson(wchar_t const*, wchar_t const*, wchar_t const*, unsigned int, uintptr_t); diff --git a/src/debug.c b/src/debug.c index 52382c1..650c2b4 100644 --- a/src/debug.c +++ b/src/debug.c @@ -3,6 +3,7 @@ #include #include #include +#include "directinput.h" #include "ddraw.h" #include "dd.h" #include "ddsurface.h" @@ -1086,6 +1087,27 @@ void dbg_dump_dds_lock_flags(DWORD flags) #endif } +void dbg_dump_di_scm_flags(DWORD flags) +{ +#ifdef _DEBUG + if (flags & DISCL_EXCLUSIVE) { + TRACE(" DISCL_EXCLUSIVE\n"); + } + if (flags & DISCL_NONEXCLUSIVE) { + TRACE(" DISCL_NONEXCLUSIVE\n"); + } + if (flags & DISCL_FOREGROUND) { + TRACE(" DISCL_FOREGROUND\n"); + } + if (flags & DISCL_BACKGROUND) { + TRACE(" DISCL_BACKGROUND\n"); + } + if (flags & DISCL_NOWINKEY) { + TRACE(" DISCL_NOWINKEY\n"); + } +#endif +} + char* dbg_d3d9_hr_to_str(HRESULT hr) { #define HR_TO_STR(x) if (x == hr) return #x diff --git a/src/directinput.c b/src/directinput.c index d3f08f6..80d58c6 100644 --- a/src/directinput.c +++ b/src/directinput.c @@ -54,6 +54,8 @@ static PROC hook_func(PROC* org_func, PROC new_func) static HRESULT WINAPI fake_did_SetCooperativeLevel(IDirectInputDeviceA* This, HWND hwnd, DWORD dwFlags) { TRACE("DirectInput SetCooperativeLevel(This=%p, hwnd=%p, dwFlags=0x%08X) [%p]\n", This, hwnd, dwFlags, _ReturnAddress()); + TRACE(" mouse_device = %s\n", This == g_mouse_device ? "TRUE" : "FALSE"); + dbg_dump_di_scm_flags(dwFlags); if (This == g_mouse_device && g_ddraw.ref && (dwFlags & DISCL_EXCLUSIVE)) {