Skip to content

Commit 557644b

Browse files
committed
Update to make easier integration into dxwrapper
1 parent 62cd241 commit 557644b

File tree

4 files changed

+39
-39
lines changed

4 files changed

+39
-39
lines changed

BuildNo.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define BUILD_NUMBER 53
1+
#define BUILD_NUMBER 54

IDirectInputDeviceX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static auto FindByDITypeAndInstance(T& collection, DWORD dwType)
4444

4545
void m_IDirectInputDeviceX::InitializeEnumObjectData()
4646
{
47-
DIDEVICEINSTANCE didi { sizeof(didi) };
47+
DIDEVICEINSTANCEW didi { sizeof(didi) };
4848
if (SUCCEEDED(ProxyInterface->GetDeviceInfo(&didi)))
4949
{
5050
DevType7 = ConvertDevTypeTo7(GET_DIDEVICE_TYPE(didi.dwDevType));

InterfaceQuery.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,40 @@ void WINAPI dinputto8::genericQueryInterface(REFIID riid, LPVOID * ppvObj)
108108
QUERYINTERFACE(IDirectInputDevice7W);
109109
QUERYINTERFACE(IDirectInputEffect);
110110
}
111+
112+
HRESULT dinputto8::hresValidInstanceAndVersion(HINSTANCE& hinst, DWORD dwVersion)
113+
{
114+
bool bValidInstance;
115+
if (hinst != nullptr)
116+
{
117+
wchar_t path[4];
118+
bValidInstance = GetModuleFileNameW(hinst, path, std::size(path) - 1) != 0;
119+
}
120+
else
121+
{
122+
// DInput version 0x300 permits no instance...
123+
bValidInstance = dwVersion == 0x300;
124+
}
125+
126+
if (!bValidInstance)
127+
{
128+
return DIERR_INVALIDPARAM;
129+
}
130+
131+
// ...but DInput8 does not, so if the instance is empty, give it one or else it'll fail.
132+
if (hinst == nullptr && dwVersion == 0x300)
133+
{
134+
hinst = ::GetModuleHandle(nullptr);
135+
}
136+
137+
if (dwVersion == 0x300 || dwVersion == 0x500 || dwVersion == 0x50A || dwVersion == 0x5B2 || dwVersion == 0x602 || dwVersion == 0x61A || dwVersion == 0x700)
138+
{
139+
return DI_OK;
140+
}
141+
142+
if (dwVersion == 0)
143+
{
144+
return DIERR_NOTINITIALIZED;
145+
}
146+
return dwVersion < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION;
147+
}

dinputto8.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -173,40 +173,3 @@ HRESULT WINAPI DllUnregisterServer()
173173

174174
return m_pDllUnregisterServer();
175175
}
176-
177-
HRESULT dinputto8::hresValidInstanceAndVersion(HINSTANCE& hinst, DWORD dwVersion)
178-
{
179-
bool bValidInstance;
180-
if (hinst != nullptr)
181-
{
182-
wchar_t path[4];
183-
bValidInstance = GetModuleFileNameW(hinst, path, std::size(path) - 1) != 0;
184-
}
185-
else
186-
{
187-
// DInput version 0x300 permits no instance...
188-
bValidInstance = dwVersion == 0x300;
189-
}
190-
191-
if (!bValidInstance)
192-
{
193-
return DIERR_INVALIDPARAM;
194-
}
195-
196-
// ...but DInput8 does not, so if the instance is empty, give it one or else it'll fail.
197-
if (hinst == nullptr && dwVersion == 0x300)
198-
{
199-
hinst = ::GetModuleHandle(nullptr);
200-
}
201-
202-
if (dwVersion == 0x300 || dwVersion == 0x500 || dwVersion == 0x50A || dwVersion == 0x5B2 || dwVersion == 0x602 || dwVersion == 0x61A || dwVersion == 0x700)
203-
{
204-
return DI_OK;
205-
}
206-
207-
if (dwVersion == 0)
208-
{
209-
return DIERR_NOTINITIALIZED;
210-
}
211-
return dwVersion < 0x700 ? DIERR_BETADIRECTINPUTVERSION : DIERR_OLDDIRECTINPUTVERSION;
212-
}

0 commit comments

Comments
 (0)