3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998,1999 Lionel Ulmer
5 * Copyright 2000-2002 TransGaming Technologies Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * - Tomb Raider 2 Demo:
25 * Playable using keyboard only.
26 * - WingCommander Prophecy Demo:
27 * Doesn't get Input Focus.
29 * - Fallout : works great in X and DGA mode
37 #include "wine/debug.h"
38 #include "wine/unicode.h"
43 #include "dinput_private.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
47 static ICOM_VTABLE(IDirectInput7A) ddi7avt;
48 static ICOM_VTABLE(IDirectInput7W) ddi7wvt;
49 static ICOM_VTABLE(IDirectInput8A) ddi8avt;
50 static ICOM_VTABLE(IDirectInput8W) ddi8wvt;
52 /* This array will be filled a dinput.so loading */
53 #define MAX_WINE_DINPUT_DEVICES 4
54 static dinput_device * dinput_devices[MAX_WINE_DINPUT_DEVICES];
55 static int nrof_dinput_devices = 0;
57 HINSTANCE DINPUT_instance = NULL;
59 BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserv)
63 case DLL_PROCESS_ATTACH:
64 DisableThreadLibraryCalls(inst);
65 DINPUT_instance = inst;
67 case DLL_PROCESS_DETACH:
74 /* register a direct draw driver. We better not use malloc for we are in
75 * the ELF startup initialisation at this point.
77 void dinput_register_device(dinput_device *device) {
80 /* insert according to priority */
81 for (i=0;i<nrof_dinput_devices;i++) {
82 if (dinput_devices[i]->pref <= device->pref) {
83 memcpy(dinput_devices+i+1,dinput_devices+i,sizeof(dinput_devices[0])*(nrof_dinput_devices-i));
84 dinput_devices[i] = device;
88 if (i==nrof_dinput_devices) /* not found, or too low priority */
89 dinput_devices[nrof_dinput_devices] = device;
91 nrof_dinput_devices++;
93 /* increase MAX_DDRAW_DRIVERS if the line below triggers */
94 assert(nrof_dinput_devices <= MAX_WINE_DINPUT_DEVICES);
97 /******************************************************************************
98 * DirectInputCreateEx (DINPUT.@)
100 HRESULT WINAPI DirectInputCreateEx(
101 HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI,
104 IDirectInputImpl* This;
106 TRACE("(0x%08lx,%04lx,%s,%p,%p)\n", (DWORD)hinst,dwVersion,debugstr_guid(riid),ppDI,punkOuter);
108 if (IsEqualGUID(&IID_IDirectInputA,riid) ||
109 IsEqualGUID(&IID_IDirectInput2A,riid) ||
110 IsEqualGUID(&IID_IDirectInput7A,riid)) {
111 This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
112 This->lpVtbl = &ddi7avt;
120 if (IsEqualGUID(&IID_IDirectInputW,riid) ||
121 IsEqualGUID(&IID_IDirectInput2W,riid) ||
122 IsEqualGUID(&IID_IDirectInput7W,riid)) {
123 This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
124 This->lpVtbl = &ddi7wvt;
132 if (IsEqualGUID(&IID_IDirectInput8A,riid)) {
133 This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
134 This->lpVtbl = &ddi8avt;
142 if (IsEqualGUID(&IID_IDirectInput8W,riid)) {
143 This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
144 This->lpVtbl = &ddi8wvt;
152 return DIERR_OLDDIRECTINPUTVERSION;
155 /******************************************************************************
156 * DirectInputCreateA (DINPUT.@)
158 HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter)
160 IDirectInputImpl* This;
161 TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
162 This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
163 This->lpVtbl = &ddi7avt;
165 if (dwVersion >= 0x0800) {
168 /* We do not differientiate between version 1, 2 and 7 */
171 *ppDI = (IDirectInputA*)This;
176 /******************************************************************************
177 * DirectInputCreateW (DINPUT.@)
179 HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter)
181 IDirectInputImpl* This;
182 TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
183 This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
184 This->lpVtbl = &ddi7wvt;
186 if (dwVersion >= 0x0800) {
189 /* We do not differientiate between version 1, 2 and 7 */
192 *ppDI = (IDirectInputW*)This;
196 static char *_dump_DIDEVTYPE_value(DWORD dwDevType) {
198 case 0: return "All devices";
199 case DIDEVTYPE_MOUSE: return "DIDEVTYPE_MOUSE";
200 case DIDEVTYPE_KEYBOARD: return "DIDEVTYPE_KEYBOARD";
201 case DIDEVTYPE_JOYSTICK: return "DIDEVTYPE_JOYSTICK";
202 case DIDEVTYPE_DEVICE: return "DIDEVTYPE_DEVICE";
203 default: return "Unkown";
207 static void _dump_EnumDevices_dwFlags(DWORD dwFlags) {
208 if (TRACE_ON(dinput)) {
210 static const struct {
214 #define FE(x) { x, #x}
215 FE(DIEDFL_ALLDEVICES),
216 FE(DIEDFL_ATTACHEDONLY),
217 FE(DIEDFL_FORCEFEEDBACK),
218 FE(DIEDFL_INCLUDEALIASES),
219 FE(DIEDFL_INCLUDEPHANTOMS)
223 DPRINTF("DIEDFL_ALLDEVICES");
226 for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
227 if (flags[i].mask & dwFlags)
228 DPRINTF("%s ",flags[i].name);
232 /******************************************************************************
233 * IDirectInputA_EnumDevices
235 static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
236 LPDIRECTINPUT7A iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback,
237 LPVOID pvRef, DWORD dwFlags)
239 ICOM_THIS(IDirectInputImpl,iface);
240 DIDEVICEINSTANCEA devInstance;
243 TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
244 This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
245 lpCallback, pvRef, dwFlags);
246 TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
248 for (i = 0; i < nrof_dinput_devices; i++) {
249 devInstance.dwSize = sizeof(devInstance);
250 TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name);
251 if (dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->version)) {
252 if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
259 /******************************************************************************
260 * IDirectInputW_EnumDevices
262 static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
263 LPDIRECTINPUT7W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback,
264 LPVOID pvRef, DWORD dwFlags)
266 ICOM_THIS(IDirectInputImpl,iface);
267 DIDEVICEINSTANCEW devInstance;
270 TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
271 This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
272 lpCallback, pvRef, dwFlags);
273 TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
275 for (i = 0; i < nrof_dinput_devices; i++) {
276 devInstance.dwSize = sizeof(devInstance);
277 TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name);
278 if (dinput_devices[i]->enum_deviceW(dwDevType, dwFlags, &devInstance, This->version)) {
279 if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
287 static ULONG WINAPI IDirectInputAImpl_AddRef(LPDIRECTINPUT7A iface)
289 ICOM_THIS(IDirectInputImpl,iface);
290 return ++(This->ref);
293 static ULONG WINAPI IDirectInputAImpl_Release(LPDIRECTINPUT7A iface)
295 ICOM_THIS(IDirectInputImpl,iface);
296 if (!(--This->ref)) {
297 HeapFree(GetProcessHeap(),0,This);
303 static HRESULT WINAPI IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface, REFIID riid, LPVOID *ppobj) {
304 ICOM_THIS(IDirectInputImpl,iface);
306 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
307 if (IsEqualGUID(&IID_IUnknown,riid) ||
308 IsEqualGUID(&IID_IDirectInputA,riid) ||
309 IsEqualGUID(&IID_IDirectInput2A,riid) ||
310 IsEqualGUID(&IID_IDirectInput7A,riid)) {
311 IDirectInputAImpl_AddRef(iface);
315 TRACE("Unsupported interface !\n");
319 static HRESULT WINAPI IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface, REFIID riid, LPVOID *ppobj) {
320 ICOM_THIS(IDirectInputImpl,iface);
322 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
323 if (IsEqualGUID(&IID_IUnknown,riid) ||
324 IsEqualGUID(&IID_IDirectInputW,riid) ||
325 IsEqualGUID(&IID_IDirectInput2W,riid) ||
326 IsEqualGUID(&IID_IDirectInput7W,riid)) {
327 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
331 TRACE("Unsupported interface !\n");
335 static HRESULT WINAPI IDirectInputAImpl_CreateDevice(
336 LPDIRECTINPUT7A iface,REFGUID rguid,LPDIRECTINPUTDEVICEA* pdev,
339 ICOM_THIS(IDirectInputImpl,iface);
340 HRESULT ret_value = DIERR_DEVICENOTREG;
343 TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
345 /* Loop on all the devices to see if anyone matches the given GUID */
346 for (i = 0; i < nrof_dinput_devices; i++) {
348 if ((ret = dinput_devices[i]->create_deviceA(This, rguid, NULL, pdev)) == DI_OK)
351 if (ret == DIERR_NOINTERFACE)
352 ret_value = DIERR_NOINTERFACE;
358 static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7A iface,
359 REFGUID rguid, LPDIRECTINPUTDEVICEW* pdev, LPUNKNOWN punk) {
360 ICOM_THIS(IDirectInputImpl,iface);
361 HRESULT ret_value = DIERR_DEVICENOTREG;
364 TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
366 /* Loop on all the devices to see if anyone matches the given GUID */
367 for (i = 0; i < nrof_dinput_devices; i++) {
369 if ((ret = dinput_devices[i]->create_deviceW(This, rguid, NULL, pdev)) == DI_OK)
372 if (ret == DIERR_NOINTERFACE)
373 ret_value = DIERR_NOINTERFACE;
379 static HRESULT WINAPI IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface, HINSTANCE hinst, DWORD x) {
380 return DIERR_ALREADYINITIALIZED;
383 static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface,
385 ICOM_THIS(IDirectInputImpl,iface);
387 FIXME("(%p)->(%s): stub\n",This,debugstr_guid(rguid));
392 static HRESULT WINAPI IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface,
395 ICOM_THIS(IDirectInputImpl,iface);
396 FIXME("(%p)->(%08lx,%08lx): stub\n",This, (DWORD) hwndOwner, dwFlags);
401 static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid,
402 LPCSTR pszName, LPGUID pguidInstance) {
403 ICOM_THIS(IDirectInputImpl,iface);
404 FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), pszName, pguidInstance);
409 static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGUID rguid,
410 LPCWSTR pszName, LPGUID pguidInstance) {
411 ICOM_THIS(IDirectInputImpl,iface);
412 FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), debugstr_w(pszName), pguidInstance);
417 static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, REFGUID rguid,
418 REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
420 ICOM_THIS(IDirectInputImpl,iface);
421 HRESULT ret_value = DIERR_DEVICENOTREG;
424 TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
426 /* Loop on all the devices to see if anyone matches the given GUID */
427 for (i = 0; i < nrof_dinput_devices; i++) {
429 if ((ret = dinput_devices[i]->create_deviceA(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
432 if (ret == DIERR_NOINTERFACE)
433 ret_value = DIERR_NOINTERFACE;
439 static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, REFGUID rguid,
440 REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
442 ICOM_THIS(IDirectInputImpl,iface);
443 HRESULT ret_value = DIERR_DEVICENOTREG;
446 TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
448 /* Loop on all the devices to see if anyone matches the given GUID */
449 for (i = 0; i < nrof_dinput_devices; i++) {
451 if ((ret = dinput_devices[i]->create_deviceW(This, rguid, riid, (LPDIRECTINPUTDEVICEW*) pvOut)) == DI_OK)
454 if (ret == DIERR_NOINTERFACE)
455 ret_value = DIERR_NOINTERFACE;
461 static HRESULT WINAPI IDirectInput8AImpl_QueryInterface(LPDIRECTINPUT8A iface, REFIID riid, LPVOID *ppobj) {
462 ICOM_THIS(IDirectInputImpl,iface);
464 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
465 if (IsEqualGUID(&IID_IUnknown,riid) ||
466 IsEqualGUID(&IID_IDirectInput8A,riid)) {
467 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
471 TRACE("Unsupported interface !\n");
472 return E_NOINTERFACE;
475 static HRESULT WINAPI IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface, REFIID riid, LPVOID *ppobj) {
476 ICOM_THIS(IDirectInputImpl,iface);
478 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
479 if (IsEqualGUID(&IID_IUnknown,riid) ||
480 IsEqualGUID(&IID_IDirectInput8W,riid)) {
481 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
485 TRACE("Unsupported interface !\n");
486 return E_NOINTERFACE;
489 static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
490 LPDIRECTINPUT8A iface, LPCSTR ptszUserName, LPDIACTIONFORMATA lpdiActionFormat,
491 LPDIENUMDEVICESBYSEMANTICSCBA lpCallback,
492 LPVOID pvRef, DWORD dwFlags
495 ICOM_THIS(IDirectInputImpl,iface);
497 FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, ptszUserName, lpdiActionFormat,
498 lpCallback, pvRef, dwFlags);
502 static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
503 LPDIRECTINPUT8W iface, LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat,
504 LPDIENUMDEVICESBYSEMANTICSCBW lpCallback,
505 LPVOID pvRef, DWORD dwFlags
508 ICOM_THIS(IDirectInputImpl,iface);
510 FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat,
511 lpCallback, pvRef, dwFlags);
515 static HRESULT WINAPI IDirectInput8AImpl_ConfigureDevices(
516 LPDIRECTINPUT8A iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
517 LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
520 ICOM_THIS(IDirectInputImpl,iface);
522 FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
527 static HRESULT WINAPI IDirectInput8WImpl_ConfigureDevices(
528 LPDIRECTINPUT8W iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
529 LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
532 ICOM_THIS(IDirectInputImpl,iface);
534 FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
539 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
540 # define XCAST(fun) (typeof(ddi7avt.fun))
542 # define XCAST(fun) (void*)
545 static ICOM_VTABLE(IDirectInput7A) ddi7avt = {
546 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
547 XCAST(QueryInterface)IDirectInputAImpl_QueryInterface,
548 XCAST(AddRef)IDirectInputAImpl_AddRef,
549 XCAST(Release)IDirectInputAImpl_Release,
550 XCAST(CreateDevice)IDirectInputAImpl_CreateDevice,
551 XCAST(EnumDevices)IDirectInputAImpl_EnumDevices,
552 XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
553 XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
554 XCAST(Initialize)IDirectInputAImpl_Initialize,
555 XCAST(FindDevice)IDirectInput2AImpl_FindDevice,
556 XCAST(CreateDeviceEx)IDirectInput7AImpl_CreateDeviceEx
560 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
561 # define XCAST(fun) (typeof(ddi7wvt.fun))
563 # define XCAST(fun) (void*)
566 static ICOM_VTABLE(IDirectInput7W) ddi7wvt = {
567 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
568 XCAST(QueryInterface)IDirectInputWImpl_QueryInterface,
569 XCAST(AddRef)IDirectInputAImpl_AddRef,
570 XCAST(Release)IDirectInputAImpl_Release,
571 XCAST(CreateDevice)IDirectInputWImpl_CreateDevice,
572 XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
573 XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
574 XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
575 XCAST(Initialize)IDirectInputAImpl_Initialize,
576 XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
577 XCAST(CreateDeviceEx)IDirectInput7WImpl_CreateDeviceEx
581 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
582 # define XCAST(fun) (typeof(ddi8avt.fun))
584 # define XCAST(fun) (void*)
587 static ICOM_VTABLE(IDirectInput8A) ddi8avt = {
588 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
589 XCAST(QueryInterface)IDirectInput8AImpl_QueryInterface,
590 XCAST(AddRef)IDirectInputAImpl_AddRef,
591 XCAST(Release)IDirectInputAImpl_Release,
592 XCAST(CreateDevice)IDirectInputAImpl_CreateDevice,
593 XCAST(EnumDevices)IDirectInputAImpl_EnumDevices,
594 XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
595 XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
596 XCAST(Initialize)IDirectInputAImpl_Initialize,
597 XCAST(FindDevice)IDirectInput2AImpl_FindDevice,
598 XCAST(EnumDevicesBySemantics)IDirectInput8AImpl_EnumDevicesBySemantics,
599 XCAST(ConfigureDevices)IDirectInput8AImpl_ConfigureDevices
603 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
604 # define XCAST(fun) (typeof(ddi8wvt.fun))
606 # define XCAST(fun) (void*)
608 static ICOM_VTABLE(IDirectInput8W) ddi8wvt = {
609 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
610 XCAST(QueryInterface)IDirectInput8WImpl_QueryInterface,
611 XCAST(AddRef)IDirectInputAImpl_AddRef,
612 XCAST(Release)IDirectInputAImpl_Release,
613 XCAST(CreateDevice)IDirectInputWImpl_CreateDevice,
614 XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
615 XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
616 XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
617 XCAST(Initialize)IDirectInputAImpl_Initialize,
618 XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
619 XCAST(EnumDevicesBySemantics)IDirectInput8WImpl_EnumDevicesBySemantics,
620 XCAST(ConfigureDevices)IDirectInput8WImpl_ConfigureDevices
624 /*******************************************************************************
625 * DirectInput ClassFactory
629 /* IUnknown fields */
630 IClassFactoryVtbl *lpVtbl;
634 static HRESULT WINAPI DICF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
635 ICOM_THIS(IClassFactoryImpl,iface);
637 FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
638 return E_NOINTERFACE;
641 static ULONG WINAPI DICF_AddRef(LPCLASSFACTORY iface) {
642 ICOM_THIS(IClassFactoryImpl,iface);
643 return ++(This->ref);
646 static ULONG WINAPI DICF_Release(LPCLASSFACTORY iface) {
647 ICOM_THIS(IClassFactoryImpl,iface);
648 /* static class, won't be freed */
649 return --(This->ref);
652 static HRESULT WINAPI DICF_CreateInstance(
653 LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
655 ICOM_THIS(IClassFactoryImpl,iface);
657 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
658 if ( IsEqualGUID( &IID_IDirectInputA, riid ) ||
659 IsEqualGUID( &IID_IDirectInputW, riid ) ||
660 IsEqualGUID( &IID_IDirectInput2A, riid ) ||
661 IsEqualGUID( &IID_IDirectInput2W, riid ) ||
662 IsEqualGUID( &IID_IDirectInput7A, riid ) ||
663 IsEqualGUID( &IID_IDirectInput7W, riid ) ||
664 IsEqualGUID( &IID_IDirectInput8A, riid ) ||
665 IsEqualGUID( &IID_IDirectInput8W, riid ) ) {
666 /* FIXME: reuse already created dinput if present? */
667 return DirectInputCreateEx(0,0,riid,ppobj,pOuter);
670 FIXME("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
671 return E_NOINTERFACE;
674 static HRESULT WINAPI DICF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
675 ICOM_THIS(IClassFactoryImpl,iface);
676 FIXME("(%p)->(%d),stub!\n",This,dolock);
680 static ICOM_VTABLE(IClassFactory) DICF_Vtbl = {
681 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
688 static IClassFactoryImpl DINPUT_CF = {&DICF_Vtbl, 1 };
690 /***********************************************************************
691 * DllCanUnloadNow (DINPUT.@)
693 HRESULT WINAPI DINPUT_DllCanUnloadNow(void)
695 FIXME("(void): stub\n");
700 /***********************************************************************
701 * DllGetClassObject (DINPUT.@)
703 HRESULT WINAPI DINPUT_DllGetClassObject(REFCLSID rclsid, REFIID riid,
706 TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
707 if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
708 *ppv = (LPVOID)&DINPUT_CF;
709 IClassFactory_AddRef((IClassFactory*)*ppv);
713 FIXME("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
714 return CLASS_E_CLASSNOTAVAILABLE;