Skip to content

Commit

Permalink
Update to make easier integration into dxwrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Sep 13, 2023
1 parent 62cd241 commit 557644b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 53
#define BUILD_NUMBER 54
2 changes: 1 addition & 1 deletion IDirectInputDeviceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static auto FindByDITypeAndInstance(T& collection, DWORD dwType)

void m_IDirectInputDeviceX::InitializeEnumObjectData()
{
DIDEVICEINSTANCE didi { sizeof(didi) };
DIDEVICEINSTANCEW didi { sizeof(didi) };
if (SUCCEEDED(ProxyInterface->GetDeviceInfo(&didi)))
{
DevType7 = ConvertDevTypeTo7(GET_DIDEVICE_TYPE(didi.dwDevType));
Expand Down
37 changes: 37 additions & 0 deletions InterfaceQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,40 @@ void WINAPI dinputto8::genericQueryInterface(REFIID riid, LPVOID * ppvObj)
QUERYINTERFACE(IDirectInputDevice7W);
QUERYINTERFACE(IDirectInputEffect);
}

HRESULT dinputto8::hresValidInstanceAndVersion(HINSTANCE& hinst, DWORD dwVersion)
{
bool bValidInstance;
if (hinst != nullptr)
{
wchar_t path[4];
bValidInstance = GetModuleFileNameW(hinst, path, std::size(path) - 1) != 0;
}
else
{
// DInput version 0x300 permits no instance...
bValidInstance = dwVersion == 0x300;
}

if (!bValidInstance)
{
return DIERR_INVALIDPARAM;
}

// ...but DInput8 does not, so if the instance is empty, give it one or else it'll fail.
if (hinst == nullptr && dwVersion == 0x300)
{
hinst = ::GetModuleHandle(nullptr);
}

if (dwVersion == 0x300 || dwVersion == 0x500 || dwVersion == 0x50A || dwVersion == 0x5B2 || dwVersion == 0x602 || dwVersion == 0x61A || dwVersion == 0x700)
{
return DI_OK;
}

if (dwVersion == 0)
{
return DIERR_NOTINITIALIZED;
}
return dwVersion < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION;
}
37 changes: 0 additions & 37 deletions dinputto8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,40 +173,3 @@ HRESULT WINAPI DllUnregisterServer()

return m_pDllUnregisterServer();
}

HRESULT dinputto8::hresValidInstanceAndVersion(HINSTANCE& hinst, DWORD dwVersion)
{
bool bValidInstance;
if (hinst != nullptr)
{
wchar_t path[4];
bValidInstance = GetModuleFileNameW(hinst, path, std::size(path) - 1) != 0;
}
else
{
// DInput version 0x300 permits no instance...
bValidInstance = dwVersion == 0x300;
}

if (!bValidInstance)
{
return DIERR_INVALIDPARAM;
}

// ...but DInput8 does not, so if the instance is empty, give it one or else it'll fail.
if (hinst == nullptr && dwVersion == 0x300)
{
hinst = ::GetModuleHandle(nullptr);
}

if (dwVersion == 0x300 || dwVersion == 0x500 || dwVersion == 0x50A || dwVersion == 0x5B2 || dwVersion == 0x602 || dwVersion == 0x61A || dwVersion == 0x700)
{
return DI_OK;
}

if (dwVersion == 0)
{
return DIERR_NOTINITIALIZED;
}
return dwVersion < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION;
}

0 comments on commit 557644b

Please sign in to comment.