[2/2] dinput: Semi-stub for IDirectInputJoyConfig8_GetConfig
Lucas Zawacki
lfzawacki at gmail.com
Mon Aug 13 18:36:56 CDT 2012
From: Lucas Zawacki <lfzawacki at gmail.com>
This is just enough to make tests pass and fix bug #23236. Retrieving
the GUID for connected devices seems to a common usage for this function.
---
dlls/dinput/dinput_main.c | 40 ++++++++++++++++++++++++++++++++++++++--
dlls/dinput/tests/dinput.c | 4 ++--
2 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
index 46b7e08..63ff439 100644
--- a/dlls/dinput/dinput_main.c
+++ b/dlls/dinput/dinput_main.c
@@ -1142,8 +1142,44 @@ static HRESULT WINAPI JoyConfig8Impl_DeleteType(IDirectInputJoyConfig8 *iface, L
static HRESULT WINAPI JoyConfig8Impl_GetConfig(IDirectInputJoyConfig8 *iface, UINT id, LPDIJOYCONFIG info, DWORD flags)
{
- FIXME( "(%p)->(%d, %p, 0x%08x): stub!\n", iface, id, info, flags );
- return E_NOTIMPL;
+ IDirectInputImpl *di = impl_from_IDirectInputJoyConfig8(iface);
+ UINT found = 0;
+ int i, j, r;
+
+ FIXME("(%p)->(%d, %p, 0x%08x): semi-stub!\n", iface, id, info, flags);
+
+#define X(x) if (flags & x) FIXME("\tflags |= "#x"\n");
+ X(DIJC_GUIDINSTANCE)
+ X(DIJC_REGHWCONFIGTYPE)
+ X(DIJC_GAIN)
+ X(DIJC_CALLOUT)
+#undef X
+
+ /* Enumerate all joysticks in order */
+ for (i = 0; i < NB_DINPUT_DEVICES; i++)
+ {
+ if (!dinput_devices[i]->enum_deviceA) continue;
+
+ for (j = 0, r = -1; r != 0; j++)
+ {
+ DIDEVICEINSTANCEA dev;
+ dev.dwSize = sizeof(dev);
+ if ((r = dinput_devices[i]->enum_deviceA(DI8DEVCLASS_GAMECTRL, 0, &dev, di->dwVersion, j)))
+ {
+ /* Only take into account the chosen id */
+ if (found == id)
+ {
+ if (flags & DIJC_GUIDINSTANCE)
+ info->guidInstance = dev.guidInstance;
+
+ return DI_OK;
+ }
+ found += 1;
+ }
+ }
+ }
+
+ return DIERR_NOMOREITEMS;
}
static HRESULT WINAPI JoyConfig8Impl_SetConfig(IDirectInputJoyConfig8 *iface, UINT id, LPCDIJOYCONFIG info, DWORD flags)
diff --git a/dlls/dinput/tests/dinput.c b/dlls/dinput/tests/dinput.c
index c5386d6..cc28985 100644
--- a/dlls/dinput/tests/dinput.c
+++ b/dlls/dinput/tests/dinput.c
@@ -595,11 +595,11 @@ static void test_DirectInputJoyConfig8(void)
{
hr = IDirectInputJoyConfig8_GetConfig(pDIJC, i, &info, DIJC_GUIDINSTANCE);
- todo_wine ok (hr == DI_OK || hr == DIERR_NOMOREITEMS,
+ ok (hr == DI_OK || hr == DIERR_NOMOREITEMS,
"IDirectInputJoyConfig8_GetConfig returned 0x%08x\n", hr);
if (SUCCEEDED(hr))
- todo_wine ok (SUCCEEDED(IDirectInput_CreateDevice(pDI, &info.guidInstance, &pDID, NULL)),
+ ok (SUCCEEDED(IDirectInput_CreateDevice(pDI, &info.guidInstance, &pDID, NULL)),
"IDirectInput_CreateDevice failed with guid from GetConfig hr = 0x%08x\n", hr);
}
--
1.7.9.5
More information about the wine-patches
mailing list