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 *ppDI
= (IDirectInputA
*)This
;
170 /******************************************************************************
171 * DirectInputCreateW (DINPUT.@)
173 HRESULT WINAPI
DirectInputCreateW(HINSTANCE hinst
, DWORD dwVersion
, LPDIRECTINPUTW
*ppDI
, LPUNKNOWN punkOuter
)
175 IDirectInputImpl
* This
;
176 TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD
)hinst
,dwVersion
,ppDI
,punkOuter
);
177 This
= (IDirectInputImpl
*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl
));
178 This
->lpVtbl
= &ddi7wvt
;
180 *ppDI
= (IDirectInputW
*)This
;
185 /******************************************************************************
186 * IDirectInputA_EnumDevices
188 static HRESULT WINAPI
IDirectInputAImpl_EnumDevices(
189 LPDIRECTINPUT7A iface
, DWORD dwDevType
, LPDIENUMDEVICESCALLBACKA lpCallback
,
190 LPVOID pvRef
, DWORD dwFlags
)
192 ICOM_THIS(IDirectInputImpl
,iface
);
193 DIDEVICEINSTANCEA devInstance
;
196 TRACE("(this=%p,0x%04lx,%p,%p,%04lx)\n", This
, dwDevType
, lpCallback
, pvRef
, dwFlags
);
198 for (i
= 0; i
< nrof_dinput_devices
; i
++) {
199 devInstance
.dwSize
= sizeof(devInstance
);
200 if (dinput_devices
[i
]->enum_deviceA(dwDevType
, dwFlags
, &devInstance
, This
->version
)) {
201 if (lpCallback(&devInstance
,pvRef
) == DIENUM_STOP
)
208 /******************************************************************************
209 * IDirectInputW_EnumDevices
211 static HRESULT WINAPI
IDirectInputWImpl_EnumDevices(
212 LPDIRECTINPUT7W iface
, DWORD dwDevType
, LPDIENUMDEVICESCALLBACKW lpCallback
,
213 LPVOID pvRef
, DWORD dwFlags
)
215 ICOM_THIS(IDirectInputImpl
,iface
);
216 DIDEVICEINSTANCEW devInstance
;
219 TRACE("(this=%p,0x%04lx,%p,%p,%04lx)\n", This
, dwDevType
, lpCallback
, pvRef
, dwFlags
);
221 for (i
= 0; i
< nrof_dinput_devices
; i
++) {
222 devInstance
.dwSize
= sizeof(devInstance
);
223 if (dinput_devices
[i
]->enum_deviceW(dwDevType
, dwFlags
, &devInstance
, This
->version
)) {
224 if (lpCallback(&devInstance
,pvRef
) == DIENUM_STOP
)
232 static ULONG WINAPI
IDirectInputAImpl_AddRef(LPDIRECTINPUT7A iface
)
234 ICOM_THIS(IDirectInputImpl
,iface
);
235 return ++(This
->ref
);
238 static ULONG WINAPI
IDirectInputAImpl_Release(LPDIRECTINPUT7A iface
)
240 ICOM_THIS(IDirectInputImpl
,iface
);
241 if (!(--This
->ref
)) {
242 HeapFree(GetProcessHeap(),0,This
);
248 static HRESULT WINAPI
IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface
, REFIID riid
, LPVOID
*ppobj
) {
249 ICOM_THIS(IDirectInputImpl
,iface
);
251 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
252 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
253 IsEqualGUID(&IID_IDirectInputA
,riid
) ||
254 IsEqualGUID(&IID_IDirectInput2A
,riid
) ||
255 IsEqualGUID(&IID_IDirectInput7A
,riid
)) {
256 IDirectInputAImpl_AddRef(iface
);
260 TRACE("Unsupported interface !\n");
264 static HRESULT WINAPI
IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface
, REFIID riid
, LPVOID
*ppobj
) {
265 ICOM_THIS(IDirectInputImpl
,iface
);
267 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
268 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
269 IsEqualGUID(&IID_IDirectInputW
,riid
) ||
270 IsEqualGUID(&IID_IDirectInput2W
,riid
) ||
271 IsEqualGUID(&IID_IDirectInput7W
,riid
)) {
272 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A
) iface
);
276 TRACE("Unsupported interface !\n");
280 static HRESULT WINAPI
IDirectInputAImpl_CreateDevice(
281 LPDIRECTINPUT7A iface
,REFGUID rguid
,LPDIRECTINPUTDEVICEA
* pdev
,
284 ICOM_THIS(IDirectInputImpl
,iface
);
285 HRESULT ret_value
= DIERR_DEVICENOTREG
;
288 TRACE("(this=%p,%s,%p,%p)\n",This
,debugstr_guid(rguid
),pdev
,punk
);
290 /* Loop on all the devices to see if anyone matches the given GUID */
291 for (i
= 0; i
< nrof_dinput_devices
; i
++) {
293 if ((ret
= dinput_devices
[i
]->create_deviceA(This
, rguid
, NULL
, pdev
)) == DI_OK
)
296 if (ret
== DIERR_NOINTERFACE
)
297 ret_value
= DIERR_NOINTERFACE
;
303 static HRESULT WINAPI
IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7A iface
,
304 REFGUID rguid
, LPDIRECTINPUTDEVICEW
* pdev
, LPUNKNOWN punk
) {
305 ICOM_THIS(IDirectInputImpl
,iface
);
306 HRESULT ret_value
= DIERR_DEVICENOTREG
;
309 TRACE("(this=%p,%s,%p,%p)\n",This
,debugstr_guid(rguid
),pdev
,punk
);
311 /* Loop on all the devices to see if anyone matches the given GUID */
312 for (i
= 0; i
< nrof_dinput_devices
; i
++) {
314 if ((ret
= dinput_devices
[i
]->create_deviceW(This
, rguid
, NULL
, pdev
)) == DI_OK
)
317 if (ret
== DIERR_NOINTERFACE
)
318 ret_value
= DIERR_NOINTERFACE
;
324 static HRESULT WINAPI
IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface
, HINSTANCE hinst
, DWORD x
) {
325 return DIERR_ALREADYINITIALIZED
;
328 static HRESULT WINAPI
IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface
,
330 ICOM_THIS(IDirectInputImpl
,iface
);
332 FIXME("(%p)->(%s): stub\n",This
,debugstr_guid(rguid
));
337 static HRESULT WINAPI
IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface
,
340 ICOM_THIS(IDirectInputImpl
,iface
);
341 FIXME("(%p)->(%08lx,%08lx): stub\n",This
, (DWORD
) hwndOwner
, dwFlags
);
346 static HRESULT WINAPI
IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface
, REFGUID rguid
,
347 LPCSTR pszName
, LPGUID pguidInstance
) {
348 ICOM_THIS(IDirectInputImpl
,iface
);
349 FIXME("(%p)->(%s, %s, %p): stub\n", This
, debugstr_guid(rguid
), pszName
, pguidInstance
);
354 static HRESULT WINAPI
IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface
, REFGUID rguid
,
355 LPCWSTR pszName
, LPGUID pguidInstance
) {
356 ICOM_THIS(IDirectInputImpl
,iface
);
357 FIXME("(%p)->(%s, %s, %p): stub\n", This
, debugstr_guid(rguid
), debugstr_w(pszName
), pguidInstance
);
362 static HRESULT WINAPI
IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface
, REFGUID rguid
,
363 REFIID riid
, LPVOID
* pvOut
, LPUNKNOWN lpUnknownOuter
)
365 ICOM_THIS(IDirectInputImpl
,iface
);
366 HRESULT ret_value
= DIERR_DEVICENOTREG
;
369 TRACE("(%p)->(%s, %s, %p, %p)\n", This
, debugstr_guid(rguid
), debugstr_guid(riid
), pvOut
, lpUnknownOuter
);
371 /* Loop on all the devices to see if anyone matches the given GUID */
372 for (i
= 0; i
< nrof_dinput_devices
; i
++) {
374 if ((ret
= dinput_devices
[i
]->create_deviceA(This
, rguid
, riid
, (LPDIRECTINPUTDEVICEA
*) pvOut
)) == DI_OK
)
377 if (ret
== DIERR_NOINTERFACE
)
378 ret_value
= DIERR_NOINTERFACE
;
384 static HRESULT WINAPI
IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface
, REFGUID rguid
,
385 REFIID riid
, LPVOID
* pvOut
, LPUNKNOWN lpUnknownOuter
)
387 ICOM_THIS(IDirectInputImpl
,iface
);
388 HRESULT ret_value
= DIERR_DEVICENOTREG
;
391 TRACE("(%p)->(%s, %s, %p, %p)\n", This
, debugstr_guid(rguid
), debugstr_guid(riid
), pvOut
, lpUnknownOuter
);
393 /* Loop on all the devices to see if anyone matches the given GUID */
394 for (i
= 0; i
< nrof_dinput_devices
; i
++) {
396 if ((ret
= dinput_devices
[i
]->create_deviceW(This
, rguid
, riid
, (LPDIRECTINPUTDEVICEW
*) pvOut
)) == DI_OK
)
399 if (ret
== DIERR_NOINTERFACE
)
400 ret_value
= DIERR_NOINTERFACE
;
406 static HRESULT WINAPI
IDirectInput8AImpl_QueryInterface(LPDIRECTINPUT8A iface
, REFIID riid
, LPVOID
*ppobj
) {
407 ICOM_THIS(IDirectInputImpl
,iface
);
409 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
410 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
411 IsEqualGUID(&IID_IDirectInput8A
,riid
)) {
412 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A
) iface
);
416 TRACE("Unsupported interface !\n");
417 return E_NOINTERFACE
;
420 static HRESULT WINAPI
IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface
, REFIID riid
, LPVOID
*ppobj
) {
421 ICOM_THIS(IDirectInputImpl
,iface
);
423 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
424 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
425 IsEqualGUID(&IID_IDirectInput8W
,riid
)) {
426 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A
) iface
);
430 TRACE("Unsupported interface !\n");
431 return E_NOINTERFACE
;
434 static HRESULT WINAPI
IDirectInput8AImpl_EnumDevicesBySemantics(
435 LPDIRECTINPUT8A iface
, LPCSTR ptszUserName
, LPDIACTIONFORMATA lpdiActionFormat
,
436 LPDIENUMDEVICESBYSEMANTICSCBA lpCallback
,
437 LPVOID pvRef
, DWORD dwFlags
440 ICOM_THIS(IDirectInputImpl
,iface
);
442 FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This
, ptszUserName
, lpdiActionFormat
,
443 lpCallback
, pvRef
, dwFlags
);
447 static HRESULT WINAPI
IDirectInput8WImpl_EnumDevicesBySemantics(
448 LPDIRECTINPUT8W iface
, LPCWSTR ptszUserName
, LPDIACTIONFORMATW lpdiActionFormat
,
449 LPDIENUMDEVICESBYSEMANTICSCBW lpCallback
,
450 LPVOID pvRef
, DWORD dwFlags
453 ICOM_THIS(IDirectInputImpl
,iface
);
455 FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This
, debugstr_w(ptszUserName
), lpdiActionFormat
,
456 lpCallback
, pvRef
, dwFlags
);
460 static HRESULT WINAPI
IDirectInput8AImpl_ConfigureDevices(
461 LPDIRECTINPUT8A iface
, LPDICONFIGUREDEVICESCALLBACK lpdiCallback
,
462 LPDICONFIGUREDEVICESPARAMSA lpdiCDParams
, DWORD dwFlags
, LPVOID pvRefData
465 ICOM_THIS(IDirectInputImpl
,iface
);
467 FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This
, lpdiCallback
, lpdiCDParams
,
472 static HRESULT WINAPI
IDirectInput8WImpl_ConfigureDevices(
473 LPDIRECTINPUT8W iface
, LPDICONFIGUREDEVICESCALLBACK lpdiCallback
,
474 LPDICONFIGUREDEVICESPARAMSW lpdiCDParams
, DWORD dwFlags
, LPVOID pvRefData
477 ICOM_THIS(IDirectInputImpl
,iface
);
479 FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This
, lpdiCallback
, lpdiCDParams
,
484 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
485 # define XCAST(fun) (typeof(ddi7avt.fun))
487 # define XCAST(fun) (void*)
490 static ICOM_VTABLE(IDirectInput7A
) ddi7avt
= {
491 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
492 XCAST(QueryInterface
)IDirectInputAImpl_QueryInterface
,
493 XCAST(AddRef
)IDirectInputAImpl_AddRef
,
494 XCAST(Release
)IDirectInputAImpl_Release
,
495 XCAST(CreateDevice
)IDirectInputAImpl_CreateDevice
,
496 XCAST(EnumDevices
)IDirectInputAImpl_EnumDevices
,
497 XCAST(GetDeviceStatus
)IDirectInputAImpl_GetDeviceStatus
,
498 XCAST(RunControlPanel
)IDirectInputAImpl_RunControlPanel
,
499 XCAST(Initialize
)IDirectInputAImpl_Initialize
,
500 XCAST(FindDevice
)IDirectInput2AImpl_FindDevice
,
501 XCAST(CreateDeviceEx
)IDirectInput7AImpl_CreateDeviceEx
505 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
506 # define XCAST(fun) (typeof(ddi7wvt.fun))
508 # define XCAST(fun) (void*)
511 static ICOM_VTABLE(IDirectInput7W
) ddi7wvt
= {
512 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
513 XCAST(QueryInterface
)IDirectInputWImpl_QueryInterface
,
514 XCAST(AddRef
)IDirectInputAImpl_AddRef
,
515 XCAST(Release
)IDirectInputAImpl_Release
,
516 XCAST(CreateDevice
)IDirectInputWImpl_CreateDevice
,
517 XCAST(EnumDevices
)IDirectInputWImpl_EnumDevices
,
518 XCAST(GetDeviceStatus
)IDirectInputAImpl_GetDeviceStatus
,
519 XCAST(RunControlPanel
)IDirectInputAImpl_RunControlPanel
,
520 XCAST(Initialize
)IDirectInputAImpl_Initialize
,
521 XCAST(FindDevice
)IDirectInput2WImpl_FindDevice
,
522 XCAST(CreateDeviceEx
)IDirectInput7WImpl_CreateDeviceEx
526 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
527 # define XCAST(fun) (typeof(ddi8avt.fun))
529 # define XCAST(fun) (void*)
532 static ICOM_VTABLE(IDirectInput8A
) ddi8avt
= {
533 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
534 XCAST(QueryInterface
)IDirectInput8AImpl_QueryInterface
,
535 XCAST(AddRef
)IDirectInputAImpl_AddRef
,
536 XCAST(Release
)IDirectInputAImpl_Release
,
537 XCAST(CreateDevice
)IDirectInputAImpl_CreateDevice
,
538 XCAST(EnumDevices
)IDirectInputAImpl_EnumDevices
,
539 XCAST(GetDeviceStatus
)IDirectInputAImpl_GetDeviceStatus
,
540 XCAST(RunControlPanel
)IDirectInputAImpl_RunControlPanel
,
541 XCAST(Initialize
)IDirectInputAImpl_Initialize
,
542 XCAST(FindDevice
)IDirectInput2AImpl_FindDevice
,
543 XCAST(EnumDevicesBySemantics
)IDirectInput8AImpl_EnumDevicesBySemantics
,
544 XCAST(ConfigureDevices
)IDirectInput8AImpl_ConfigureDevices
548 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
549 # define XCAST(fun) (typeof(ddi8wvt.fun))
551 # define XCAST(fun) (void*)
553 static ICOM_VTABLE(IDirectInput8W
) ddi8wvt
= {
554 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
555 XCAST(QueryInterface
)IDirectInput8WImpl_QueryInterface
,
556 XCAST(AddRef
)IDirectInputAImpl_AddRef
,
557 XCAST(Release
)IDirectInputAImpl_Release
,
558 XCAST(CreateDevice
)IDirectInputWImpl_CreateDevice
,
559 XCAST(EnumDevices
)IDirectInputWImpl_EnumDevices
,
560 XCAST(GetDeviceStatus
)IDirectInputAImpl_GetDeviceStatus
,
561 XCAST(RunControlPanel
)IDirectInputAImpl_RunControlPanel
,
562 XCAST(Initialize
)IDirectInputAImpl_Initialize
,
563 XCAST(FindDevice
)IDirectInput2WImpl_FindDevice
,
564 XCAST(EnumDevicesBySemantics
)IDirectInput8WImpl_EnumDevicesBySemantics
,
565 XCAST(ConfigureDevices
)IDirectInput8WImpl_ConfigureDevices
569 /*******************************************************************************
570 * DirectInput ClassFactory
574 /* IUnknown fields */
575 ICOM_VFIELD(IClassFactory
);
579 static HRESULT WINAPI
DICF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
) {
580 ICOM_THIS(IClassFactoryImpl
,iface
);
582 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
583 return E_NOINTERFACE
;
586 static ULONG WINAPI
DICF_AddRef(LPCLASSFACTORY iface
) {
587 ICOM_THIS(IClassFactoryImpl
,iface
);
588 return ++(This
->ref
);
591 static ULONG WINAPI
DICF_Release(LPCLASSFACTORY iface
) {
592 ICOM_THIS(IClassFactoryImpl
,iface
);
593 /* static class, won't be freed */
594 return --(This
->ref
);
597 static HRESULT WINAPI
DICF_CreateInstance(
598 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
600 ICOM_THIS(IClassFactoryImpl
,iface
);
602 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
603 if ( IsEqualGUID( &IID_IDirectInputA
, riid
) ||
604 IsEqualGUID( &IID_IDirectInputW
, riid
) ||
605 IsEqualGUID( &IID_IDirectInput2A
, riid
) ||
606 IsEqualGUID( &IID_IDirectInput2W
, riid
) ||
607 IsEqualGUID( &IID_IDirectInput7A
, riid
) ||
608 IsEqualGUID( &IID_IDirectInput7W
, riid
) ||
609 IsEqualGUID( &IID_IDirectInput8A
, riid
) ||
610 IsEqualGUID( &IID_IDirectInput8W
, riid
) ) {
611 /* FIXME: reuse already created dinput if present? */
612 return DirectInputCreateEx(0,0,riid
,ppobj
,pOuter
);
615 FIXME("(%p,%p,%s,%p) Interface not found!\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
616 return E_NOINTERFACE
;
619 static HRESULT WINAPI
DICF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
620 ICOM_THIS(IClassFactoryImpl
,iface
);
621 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
625 static ICOM_VTABLE(IClassFactory
) DICF_Vtbl
= {
626 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
633 static IClassFactoryImpl DINPUT_CF
= {&DICF_Vtbl
, 1 };
635 /***********************************************************************
636 * DllCanUnloadNow (DINPUT.@)
638 HRESULT WINAPI
DINPUT_DllCanUnloadNow(void)
640 FIXME("(void): stub\n");
645 /***********************************************************************
646 * DllGetClassObject (DINPUT.@)
648 HRESULT WINAPI
DINPUT_DllGetClassObject(REFCLSID rclsid
, REFIID riid
,
651 TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
652 if ( IsEqualCLSID( &IID_IClassFactory
, riid
) ) {
653 *ppv
= (LPVOID
)&DINPUT_CF
;
654 IClassFactory_AddRef((IClassFactory
*)*ppv
);
658 FIXME("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
659 return CLASS_E_CLASSNOTAVAILABLE
;
662 /***********************************************************************
663 * DllRegisterServer (DINPUT.@)
665 HRESULT WINAPI
DINPUT_DllRegisterServer(void)
667 FIXME("(void): stub\n");
672 /***********************************************************************
673 * DllUnregisterServer (DINPUT.@)
675 HRESULT WINAPI
DINPUT_DllUnregisterServer(void)
677 FIXME("(void): stub\n");