From 7b3b68973cffcd40889e924381df490179f28dc0 Mon Sep 17 00:00:00 2001 From: Elisha Riedlinger Date: Tue, 18 Jun 2024 10:06:15 -0700 Subject: [PATCH] Count DI_BUFFEROVERFLOW as DI_OK for mice --- BuildNo.rc | 2 +- IDirectInputDeviceX.cpp | 3 ++- IDirectInputDeviceX.h | 9 +++++---- IDirectInputX.cpp | 5 +++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/BuildNo.rc b/BuildNo.rc index 1c85579..8ccd69d 100644 --- a/BuildNo.rc +++ b/BuildNo.rc @@ -1 +1 @@ -#define BUILD_NUMBER 66 +#define BUILD_NUMBER 67 diff --git a/IDirectInputDeviceX.cpp b/IDirectInputDeviceX.cpp index 6a193a3..8f3ecee 100644 --- a/IDirectInputDeviceX.cpp +++ b/IDirectInputDeviceX.cpp @@ -511,7 +511,8 @@ HRESULT m_IDirectInputDeviceX::GetDeviceData(DWORD cbObjectData, LPDIDEVICEOBJEC LeaveCriticalSection(&dics); - return hr; + // Several games handle DI_BUFFEROVERFLOW as failure + return IsMouse && hr == DI_BUFFEROVERFLOW && rgdod && pdwInOut && *pdwInOut > 0 ? DI_OK : hr; } HRESULT m_IDirectInputDeviceX::SetDataFormat(LPCDIDATAFORMAT lpdf) diff --git a/IDirectInputDeviceX.h b/IDirectInputDeviceX.h index 6083da1..35f94b3 100644 --- a/IDirectInputDeviceX.h +++ b/IDirectInputDeviceX.h @@ -21,6 +21,9 @@ class m_IDirectInputDeviceX : public AddressLookupTableDinputObject // For CooperativeLevel bool CanAquireDevice = false; + // For GetDeviceData + bool IsMouse = false; + // Format memory DWORD Offset = 0; @@ -226,8 +229,6 @@ class m_IDirectInputDeviceX : public AddressLookupTableDinputObject // Helper functions LPVOID GetWrapperInterfaceX(DWORD DXVersion); - void SetVersion(DWORD dwVersion) - { - diVersion = dwVersion; - } + void SetVersion(DWORD dwVersion) { diVersion = dwVersion; } + void SetAsMouse() { IsMouse = true; } }; diff --git a/IDirectInputX.cpp b/IDirectInputX.cpp index dd9df7f..17155a6 100644 --- a/IDirectInputX.cpp +++ b/IDirectInputX.cpp @@ -250,6 +250,11 @@ HRESULT m_IDirectInputX::CreateDeviceExX(REFGUID rguid, REFIID riid, V *ppvObj, m_IDirectInputDeviceX *DIDevice = new m_IDirectInputDeviceX((IDirectInputDevice8W*)*ppvObj, riid); DIDevice->SetVersion(diVersion); + if (IsEqualIID(GUID_SysMouse, rguid) || IsEqualIID(GUID_SysMouseEm, rguid) || IsEqualIID(GUID_SysMouseEm2, rguid)) + { + DIDevice->SetAsMouse(); + } + *ppvObj = (V)DIDevice->GetWrapperInterfaceX(GetGUIDVersion(riid)); }