Skip to content

Commit

Permalink
Convert device type in GetCapabilities (#25)
Browse files Browse the repository at this point in the history
Fixes #24
  • Loading branch information
NicknineTheEagle authored May 29, 2024
1 parent 827e7b3 commit 678b9e5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 56
#define BUILD_NUMBER 57
32 changes: 29 additions & 3 deletions IDirectInputDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,23 @@ HRESULT m_IDirectInputDeviceX::GetCapabilities(LPDIDEVCAPS lpDIDevCaps)
{
Logging::LogDebug() << __FUNCTION__ << " (" << this << ")";

return ProxyInterface->GetCapabilities(lpDIDevCaps);
if (!lpDIDevCaps || !lpDIDevCaps->dwSize)
{
return DIERR_INVALIDPARAM;
}

HRESULT hr = ProxyInterface->GetCapabilities(lpDIDevCaps);

if (SUCCEEDED(hr))
{
DWORD devType = GET_DIDEVICE_TYPE(lpDIDevCaps->dwDevType);
DWORD devSubType = GET_DIDEVICE_SUBTYPE(lpDIDevCaps->dwDevType);
DWORD devType7 = ConvertDevTypeTo7(devType);
DWORD devSubType7 = ConvertDevSubTypeTo7(devType, devSubType);
lpDIDevCaps->dwDevType = devType7 | (devSubType7 << 8);
}

return hr;
}

template HRESULT m_IDirectInputDeviceX::EnumObjectsX<IDirectInputDevice8A, LPDIENUMDEVICEOBJECTSCALLBACKA, DIDEVICEOBJECTINSTANCEA, DIDEVICEOBJECTINSTANCE_DX3A>(LPDIENUMDEVICEOBJECTSCALLBACKA, LPVOID, DWORD);
Expand Down Expand Up @@ -618,11 +634,20 @@ HRESULT m_IDirectInputDeviceX::GetDeviceInfoX(V pdidi)
{
Logging::LogDebug() << __FUNCTION__ << " (" << this << ")";

if (!pdidi || !pdidi->dwSize)
{
return DIERR_INVALIDPARAM;
}

HRESULT hr = GetProxyInterface<T>()->GetDeviceInfo(pdidi);

if (SUCCEEDED(hr) && pdidi && pdidi->dwSize)
if (SUCCEEDED(hr))
{
pdidi->dwDevType = ConvertDevTypeTo7(GET_DIDEVICE_TYPE(pdidi->dwDevType));
DWORD devType = GET_DIDEVICE_TYPE(pdidi->dwDevType);
DWORD devSubType = GET_DIDEVICE_SUBTYPE(pdidi->dwDevType);
DWORD devType7 = ConvertDevTypeTo7(devType);
DWORD devSubType7 = ConvertDevSubTypeTo7(devType, devSubType);
pdidi->dwDevType = devType7 | (devSubType7 << 8);
}

return hr;
Expand All @@ -640,6 +665,7 @@ HRESULT m_IDirectInputDeviceX::Initialize(HINSTANCE hinst, DWORD dwVersion, REFG
Logging::LogDebug() << __FUNCTION__ << " (" << this << ")";

HRESULT hr = hresValidInstanceAndVersion(hinst, dwVersion);

if (SUCCEEDED(hr))
{
hr = ProxyInterface->Initialize(hinst, 0x0800, rguid);
Expand Down

0 comments on commit 678b9e5

Please sign in to comment.