Skip to content

Commit

Permalink
Count DI_BUFFEROVERFLOW as DI_OK for mice
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Jun 18, 2024
1 parent b4b47a8 commit 7b3b689
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 66
#define BUILD_NUMBER 67
3 changes: 2 additions & 1 deletion IDirectInputDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions IDirectInputDeviceX.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class m_IDirectInputDeviceX : public AddressLookupTableDinputObject
// For CooperativeLevel
bool CanAquireDevice = false;

// For GetDeviceData
bool IsMouse = false;

// Format memory
DWORD Offset = 0;

Expand Down Expand Up @@ -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; }
};
5 changes: 5 additions & 0 deletions IDirectInputX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down

0 comments on commit 7b3b689

Please sign in to comment.