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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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
39 #include "wine/debug.h"
40 #include "wine/unicode.h"
45 #include "dinput_private.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(dinput
);
49 static const IDirectInput7AVtbl ddi7avt
;
50 static const IDirectInput7WVtbl ddi7wvt
;
51 static const IDirectInput8AVtbl ddi8avt
;
52 static const IDirectInput8WVtbl ddi8wvt
;
54 static const struct dinput_device
*dinput_devices
[] =
58 &joystick_linuxinput_device
,
59 &joystick_linux_device
61 #define NB_DINPUT_DEVICES (sizeof(dinput_devices)/sizeof(dinput_devices[0]))
63 HINSTANCE DINPUT_instance
= NULL
;
65 BOOL WINAPI
DllMain( HINSTANCE inst
, DWORD reason
, LPVOID reserv
)
69 case DLL_PROCESS_ATTACH
:
70 DisableThreadLibraryCalls(inst
);
71 DINPUT_instance
= inst
;
73 case DLL_PROCESS_DETACH
:
80 /******************************************************************************
81 * DirectInputCreateEx (DINPUT.@)
83 HRESULT WINAPI
DirectInputCreateEx(
84 HINSTANCE hinst
, DWORD dwVersion
, REFIID riid
, LPVOID
*ppDI
,
87 IDirectInputImpl
* This
;
88 HRESULT res
= DIERR_OLDDIRECTINPUTVERSION
;
89 LPCVOID vtable
= NULL
;
91 TRACE("(%p,%04lx,%s,%p,%p)\n", hinst
,dwVersion
,debugstr_guid(riid
),ppDI
,punkOuter
);
93 if (IsEqualGUID(&IID_IDirectInputA
,riid
) ||
94 IsEqualGUID(&IID_IDirectInput2A
,riid
) ||
95 IsEqualGUID(&IID_IDirectInput7A
,riid
))
101 if (IsEqualGUID(&IID_IDirectInputW
,riid
) ||
102 IsEqualGUID(&IID_IDirectInput2W
,riid
) ||
103 IsEqualGUID(&IID_IDirectInput7W
,riid
))
109 if (IsEqualGUID(&IID_IDirectInput8A
,riid
))
115 if (IsEqualGUID(&IID_IDirectInput8W
,riid
))
123 This
= HeapAlloc(GetProcessHeap(), 0, sizeof(IDirectInputImpl
));
124 This
->lpVtbl
= vtable
;
126 This
->dwVersion
= dwVersion
;
127 This
->evsequence
= 1;
133 /******************************************************************************
134 * DirectInputCreateA (DINPUT.@)
136 HRESULT WINAPI
DirectInputCreateA(HINSTANCE hinst
, DWORD dwVersion
, LPDIRECTINPUTA
*ppDI
, LPUNKNOWN punkOuter
)
138 return DirectInputCreateEx(hinst
, dwVersion
, &IID_IDirectInput7A
, (LPVOID
*)ppDI
, punkOuter
);
141 /******************************************************************************
142 * DirectInputCreateW (DINPUT.@)
144 HRESULT WINAPI
DirectInputCreateW(HINSTANCE hinst
, DWORD dwVersion
, LPDIRECTINPUTW
*ppDI
, LPUNKNOWN punkOuter
)
146 return DirectInputCreateEx(hinst
, dwVersion
, &IID_IDirectInput7W
, (LPVOID
*)ppDI
, punkOuter
);
149 static const char *_dump_DIDEVTYPE_value(DWORD dwDevType
) {
151 case 0: return "All devices";
152 case DIDEVTYPE_MOUSE
: return "DIDEVTYPE_MOUSE";
153 case DIDEVTYPE_KEYBOARD
: return "DIDEVTYPE_KEYBOARD";
154 case DIDEVTYPE_JOYSTICK
: return "DIDEVTYPE_JOYSTICK";
155 case DIDEVTYPE_DEVICE
: return "DIDEVTYPE_DEVICE";
156 default: return "Unknown";
160 static void _dump_EnumDevices_dwFlags(DWORD dwFlags
) {
161 if (TRACE_ON(dinput
)) {
163 static const struct {
167 #define FE(x) { x, #x}
168 FE(DIEDFL_ALLDEVICES
),
169 FE(DIEDFL_ATTACHEDONLY
),
170 FE(DIEDFL_FORCEFEEDBACK
),
171 FE(DIEDFL_INCLUDEALIASES
),
172 FE(DIEDFL_INCLUDEPHANTOMS
)
176 DPRINTF("DIEDFL_ALLDEVICES");
179 for (i
= 0; i
< (sizeof(flags
) / sizeof(flags
[0])); i
++)
180 if (flags
[i
].mask
& dwFlags
)
181 DPRINTF("%s ",flags
[i
].name
);
185 /******************************************************************************
186 * IDirectInputA_EnumDevices
188 static HRESULT WINAPI
IDirectInputAImpl_EnumDevices(
189 LPDIRECTINPUT7A iface
, DWORD dwDevType
, LPDIENUMDEVICESCALLBACKA lpCallback
,
190 LPVOID pvRef
, DWORD dwFlags
)
192 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
193 DIDEVICEINSTANCEA devInstance
;
196 TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
197 This
, dwDevType
, _dump_DIDEVTYPE_value(dwDevType
),
198 lpCallback
, pvRef
, dwFlags
);
199 TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags
); TRACE("\n");
201 for (i
= 0; i
< NB_DINPUT_DEVICES
; i
++) {
202 if (!dinput_devices
[i
]->enum_deviceA
) continue;
203 for (j
= 0, r
= -1; r
!= 0; j
++) {
204 devInstance
.dwSize
= sizeof(devInstance
);
205 TRACE(" - checking device %d ('%s')\n", i
, dinput_devices
[i
]->name
);
206 if ((r
= dinput_devices
[i
]->enum_deviceA(dwDevType
, dwFlags
, &devInstance
, This
->dwVersion
, j
))) {
207 if (lpCallback(&devInstance
,pvRef
) == DIENUM_STOP
)
215 /******************************************************************************
216 * IDirectInputW_EnumDevices
218 static HRESULT WINAPI
IDirectInputWImpl_EnumDevices(
219 LPDIRECTINPUT7W iface
, DWORD dwDevType
, LPDIENUMDEVICESCALLBACKW lpCallback
,
220 LPVOID pvRef
, DWORD dwFlags
)
222 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
223 DIDEVICEINSTANCEW devInstance
;
226 TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
227 This
, dwDevType
, _dump_DIDEVTYPE_value(dwDevType
),
228 lpCallback
, pvRef
, dwFlags
);
229 TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags
); TRACE("\n");
231 for (i
= 0; i
< NB_DINPUT_DEVICES
; i
++) {
232 if (!dinput_devices
[i
]->enum_deviceW
) continue;
233 for (j
= 0, r
= -1; r
!= 0; j
++) {
234 devInstance
.dwSize
= sizeof(devInstance
);
235 TRACE(" - checking device %d ('%s')\n", i
, dinput_devices
[i
]->name
);
236 if ((r
= dinput_devices
[i
]->enum_deviceW(dwDevType
, dwFlags
, &devInstance
, This
->dwVersion
, j
))) {
237 if (lpCallback(&devInstance
,pvRef
) == DIENUM_STOP
)
246 static ULONG WINAPI
IDirectInputAImpl_AddRef(LPDIRECTINPUT7A iface
)
248 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
249 return InterlockedIncrement((&This
->ref
));
252 static ULONG WINAPI
IDirectInputAImpl_Release(LPDIRECTINPUT7A iface
)
254 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
256 ref
= InterlockedDecrement(&(This
->ref
));
258 HeapFree(GetProcessHeap(),0,This
);
262 static HRESULT WINAPI
IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface
, REFIID riid
, LPVOID
*ppobj
) {
263 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
265 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
266 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
267 IsEqualGUID(&IID_IDirectInputA
,riid
) ||
268 IsEqualGUID(&IID_IDirectInput2A
,riid
) ||
269 IsEqualGUID(&IID_IDirectInput7A
,riid
)) {
270 IDirectInputAImpl_AddRef(iface
);
274 TRACE("Unsupported interface !\n");
278 static HRESULT WINAPI
IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface
, REFIID riid
, LPVOID
*ppobj
) {
279 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
281 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
282 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
283 IsEqualGUID(&IID_IDirectInputW
,riid
) ||
284 IsEqualGUID(&IID_IDirectInput2W
,riid
) ||
285 IsEqualGUID(&IID_IDirectInput7W
,riid
)) {
286 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A
) iface
);
290 TRACE("Unsupported interface !\n");
294 static HRESULT WINAPI
IDirectInputAImpl_CreateDevice(
295 LPDIRECTINPUT7A iface
,REFGUID rguid
,LPDIRECTINPUTDEVICEA
* pdev
,
298 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
299 HRESULT ret_value
= DIERR_DEVICENOTREG
;
302 TRACE("(this=%p,%s,%p,%p)\n",This
,debugstr_guid(rguid
),pdev
,punk
);
305 WARN("invalid pointer: pdev == NULL\n");
310 WARN("invalid pointer: rguid == NULL\n");
314 /* Loop on all the devices to see if anyone matches the given GUID */
315 for (i
= 0; i
< NB_DINPUT_DEVICES
; i
++) {
317 if (!dinput_devices
[i
]->create_deviceA
) continue;
318 if ((ret
= dinput_devices
[i
]->create_deviceA(This
, rguid
, NULL
, pdev
)) == DI_OK
)
321 if (ret
== DIERR_NOINTERFACE
)
322 ret_value
= DIERR_NOINTERFACE
;
328 static HRESULT WINAPI
IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7W iface
,
329 REFGUID rguid
, LPDIRECTINPUTDEVICEW
* pdev
, LPUNKNOWN punk
) {
330 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
331 HRESULT ret_value
= DIERR_DEVICENOTREG
;
334 TRACE("(this=%p,%s,%p,%p)\n",This
,debugstr_guid(rguid
),pdev
,punk
);
336 /* Loop on all the devices to see if anyone matches the given GUID */
337 for (i
= 0; i
< NB_DINPUT_DEVICES
; i
++) {
339 if (!dinput_devices
[i
]->create_deviceW
) continue;
340 if ((ret
= dinput_devices
[i
]->create_deviceW(This
, rguid
, NULL
, pdev
)) == DI_OK
)
343 if (ret
== DIERR_NOINTERFACE
)
344 ret_value
= DIERR_NOINTERFACE
;
350 static HRESULT WINAPI
IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface
, HINSTANCE hinst
, DWORD x
) {
351 TRACE("(this=%p,%p,%lx)\n",iface
, hinst
, x
);
353 /* Initialize can return: DIERR_BETADIRECTINPUTVERSION, DIERR_OLDDIRECTINPUTVERSION and DI_OK.
354 * Since we already initialized the device, return DI_OK. In the past we returned DIERR_ALREADYINITIALIZED
355 * which broke applications like Tomb Raider Legend because it isn't a legal return value.
360 static HRESULT WINAPI
IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface
,
362 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
364 FIXME("(%p)->(%s): stub\n",This
,debugstr_guid(rguid
));
369 static HRESULT WINAPI
IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface
,
372 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
373 FIXME("(%p)->(%p,%08lx): stub\n",This
, hwndOwner
, dwFlags
);
378 static HRESULT WINAPI
IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface
, REFGUID rguid
,
379 LPCSTR pszName
, LPGUID pguidInstance
) {
380 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
381 FIXME("(%p)->(%s, %s, %p): stub\n", This
, debugstr_guid(rguid
), pszName
, pguidInstance
);
386 static HRESULT WINAPI
IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface
, REFGUID rguid
,
387 LPCWSTR pszName
, LPGUID pguidInstance
) {
388 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
389 FIXME("(%p)->(%s, %s, %p): stub\n", This
, debugstr_guid(rguid
), debugstr_w(pszName
), pguidInstance
);
394 static HRESULT WINAPI
IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface
, REFGUID rguid
,
395 REFIID riid
, LPVOID
* pvOut
, LPUNKNOWN lpUnknownOuter
)
397 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
398 HRESULT ret_value
= DIERR_DEVICENOTREG
;
401 TRACE("(%p)->(%s, %s, %p, %p)\n", This
, debugstr_guid(rguid
), debugstr_guid(riid
), pvOut
, lpUnknownOuter
);
403 /* Loop on all the devices to see if anyone matches the given GUID */
404 for (i
= 0; i
< NB_DINPUT_DEVICES
; i
++) {
406 if (!dinput_devices
[i
]->create_deviceA
) continue;
407 if ((ret
= dinput_devices
[i
]->create_deviceA(This
, rguid
, riid
, (LPDIRECTINPUTDEVICEA
*) pvOut
)) == DI_OK
)
410 if (ret
== DIERR_NOINTERFACE
)
411 ret_value
= DIERR_NOINTERFACE
;
417 static HRESULT WINAPI
IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface
, REFGUID rguid
,
418 REFIID riid
, LPVOID
* pvOut
, LPUNKNOWN lpUnknownOuter
)
420 IDirectInputImpl
*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
< NB_DINPUT_DEVICES
; i
++) {
429 if (!dinput_devices
[i
]->create_deviceW
) continue;
430 if ((ret
= dinput_devices
[i
]->create_deviceW(This
, rguid
, riid
, (LPDIRECTINPUTDEVICEW
*) pvOut
)) == DI_OK
)
433 if (ret
== DIERR_NOINTERFACE
)
434 ret_value
= DIERR_NOINTERFACE
;
440 static HRESULT WINAPI
IDirectInput8AImpl_QueryInterface(LPDIRECTINPUT8A iface
, REFIID riid
, LPVOID
*ppobj
) {
441 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
443 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
444 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
445 IsEqualGUID(&IID_IDirectInput8A
,riid
)) {
446 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A
) iface
);
450 TRACE("Unsupported interface !\n");
451 return E_NOINTERFACE
;
454 static HRESULT WINAPI
IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface
, REFIID riid
, LPVOID
*ppobj
) {
455 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
457 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
458 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
459 IsEqualGUID(&IID_IDirectInput8W
,riid
)) {
460 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A
) iface
);
464 TRACE("Unsupported interface !\n");
465 return E_NOINTERFACE
;
468 static HRESULT WINAPI
IDirectInput8AImpl_EnumDevicesBySemantics(
469 LPDIRECTINPUT8A iface
, LPCSTR ptszUserName
, LPDIACTIONFORMATA lpdiActionFormat
,
470 LPDIENUMDEVICESBYSEMANTICSCBA lpCallback
,
471 LPVOID pvRef
, DWORD dwFlags
474 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
476 FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This
, ptszUserName
, lpdiActionFormat
,
477 lpCallback
, pvRef
, dwFlags
);
481 static HRESULT WINAPI
IDirectInput8WImpl_EnumDevicesBySemantics(
482 LPDIRECTINPUT8W iface
, LPCWSTR ptszUserName
, LPDIACTIONFORMATW lpdiActionFormat
,
483 LPDIENUMDEVICESBYSEMANTICSCBW lpCallback
,
484 LPVOID pvRef
, DWORD dwFlags
487 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
489 FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This
, debugstr_w(ptszUserName
), lpdiActionFormat
,
490 lpCallback
, pvRef
, dwFlags
);
494 static HRESULT WINAPI
IDirectInput8AImpl_ConfigureDevices(
495 LPDIRECTINPUT8A iface
, LPDICONFIGUREDEVICESCALLBACK lpdiCallback
,
496 LPDICONFIGUREDEVICESPARAMSA lpdiCDParams
, DWORD dwFlags
, LPVOID pvRefData
499 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
501 FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This
, lpdiCallback
, lpdiCDParams
,
506 static HRESULT WINAPI
IDirectInput8WImpl_ConfigureDevices(
507 LPDIRECTINPUT8W iface
, LPDICONFIGUREDEVICESCALLBACK lpdiCallback
,
508 LPDICONFIGUREDEVICESPARAMSW lpdiCDParams
, DWORD dwFlags
, LPVOID pvRefData
511 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
513 FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This
, lpdiCallback
, lpdiCDParams
,
518 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
519 # define XCAST(fun) (typeof(ddi7avt.fun))
521 # define XCAST(fun) (void*)
524 static const IDirectInput7AVtbl ddi7avt
= {
525 XCAST(QueryInterface
)IDirectInputAImpl_QueryInterface
,
526 XCAST(AddRef
)IDirectInputAImpl_AddRef
,
527 XCAST(Release
)IDirectInputAImpl_Release
,
528 XCAST(CreateDevice
)IDirectInputAImpl_CreateDevice
,
529 XCAST(EnumDevices
)IDirectInputAImpl_EnumDevices
,
530 XCAST(GetDeviceStatus
)IDirectInputAImpl_GetDeviceStatus
,
531 XCAST(RunControlPanel
)IDirectInputAImpl_RunControlPanel
,
532 XCAST(Initialize
)IDirectInputAImpl_Initialize
,
533 XCAST(FindDevice
)IDirectInput2AImpl_FindDevice
,
534 XCAST(CreateDeviceEx
)IDirectInput7AImpl_CreateDeviceEx
538 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
539 # define XCAST(fun) (typeof(ddi7wvt.fun))
541 # define XCAST(fun) (void*)
544 static const IDirectInput7WVtbl ddi7wvt
= {
545 XCAST(QueryInterface
)IDirectInputWImpl_QueryInterface
,
546 XCAST(AddRef
)IDirectInputAImpl_AddRef
,
547 XCAST(Release
)IDirectInputAImpl_Release
,
548 XCAST(CreateDevice
)IDirectInputWImpl_CreateDevice
,
549 XCAST(EnumDevices
)IDirectInputWImpl_EnumDevices
,
550 XCAST(GetDeviceStatus
)IDirectInputAImpl_GetDeviceStatus
,
551 XCAST(RunControlPanel
)IDirectInputAImpl_RunControlPanel
,
552 XCAST(Initialize
)IDirectInputAImpl_Initialize
,
553 XCAST(FindDevice
)IDirectInput2WImpl_FindDevice
,
554 XCAST(CreateDeviceEx
)IDirectInput7WImpl_CreateDeviceEx
558 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
559 # define XCAST(fun) (typeof(ddi8avt.fun))
561 # define XCAST(fun) (void*)
564 static const IDirectInput8AVtbl ddi8avt
= {
565 XCAST(QueryInterface
)IDirectInput8AImpl_QueryInterface
,
566 XCAST(AddRef
)IDirectInputAImpl_AddRef
,
567 XCAST(Release
)IDirectInputAImpl_Release
,
568 XCAST(CreateDevice
)IDirectInputAImpl_CreateDevice
,
569 XCAST(EnumDevices
)IDirectInputAImpl_EnumDevices
,
570 XCAST(GetDeviceStatus
)IDirectInputAImpl_GetDeviceStatus
,
571 XCAST(RunControlPanel
)IDirectInputAImpl_RunControlPanel
,
572 XCAST(Initialize
)IDirectInputAImpl_Initialize
,
573 XCAST(FindDevice
)IDirectInput2AImpl_FindDevice
,
574 XCAST(EnumDevicesBySemantics
)IDirectInput8AImpl_EnumDevicesBySemantics
,
575 XCAST(ConfigureDevices
)IDirectInput8AImpl_ConfigureDevices
579 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
580 # define XCAST(fun) (typeof(ddi8wvt.fun))
582 # define XCAST(fun) (void*)
584 static const IDirectInput8WVtbl ddi8wvt
= {
585 XCAST(QueryInterface
)IDirectInput8WImpl_QueryInterface
,
586 XCAST(AddRef
)IDirectInputAImpl_AddRef
,
587 XCAST(Release
)IDirectInputAImpl_Release
,
588 XCAST(CreateDevice
)IDirectInputWImpl_CreateDevice
,
589 XCAST(EnumDevices
)IDirectInputWImpl_EnumDevices
,
590 XCAST(GetDeviceStatus
)IDirectInputAImpl_GetDeviceStatus
,
591 XCAST(RunControlPanel
)IDirectInputAImpl_RunControlPanel
,
592 XCAST(Initialize
)IDirectInputAImpl_Initialize
,
593 XCAST(FindDevice
)IDirectInput2WImpl_FindDevice
,
594 XCAST(EnumDevicesBySemantics
)IDirectInput8WImpl_EnumDevicesBySemantics
,
595 XCAST(ConfigureDevices
)IDirectInput8WImpl_ConfigureDevices
599 /*******************************************************************************
600 * DirectInput ClassFactory
604 /* IUnknown fields */
605 const IClassFactoryVtbl
*lpVtbl
;
609 static HRESULT WINAPI
DICF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
) {
610 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
612 FIXME("(%p)->(%s,%p),stub!\n",This
,debugstr_guid(riid
),ppobj
);
613 return E_NOINTERFACE
;
616 static ULONG WINAPI
DICF_AddRef(LPCLASSFACTORY iface
) {
617 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
618 return InterlockedIncrement(&(This
->ref
));
621 static ULONG WINAPI
DICF_Release(LPCLASSFACTORY iface
) {
622 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
623 /* static class, won't be freed */
624 return InterlockedDecrement(&(This
->ref
));
627 static HRESULT WINAPI
DICF_CreateInstance(
628 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
630 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
632 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
633 if ( IsEqualGUID( &IID_IDirectInputA
, riid
) ||
634 IsEqualGUID( &IID_IDirectInputW
, riid
) ||
635 IsEqualGUID( &IID_IDirectInput2A
, riid
) ||
636 IsEqualGUID( &IID_IDirectInput2W
, riid
) ||
637 IsEqualGUID( &IID_IDirectInput7A
, riid
) ||
638 IsEqualGUID( &IID_IDirectInput7W
, riid
) ||
639 IsEqualGUID( &IID_IDirectInput8A
, riid
) ||
640 IsEqualGUID( &IID_IDirectInput8W
, riid
) ) {
641 /* FIXME: reuse already created dinput if present? */
642 return DirectInputCreateEx(0,0,riid
,ppobj
,pOuter
);
645 FIXME("(%p,%p,%s,%p) Interface not found!\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
646 return E_NOINTERFACE
;
649 static HRESULT WINAPI
DICF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
650 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
651 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
655 static const IClassFactoryVtbl DICF_Vtbl
= {
662 static IClassFactoryImpl DINPUT_CF
= {&DICF_Vtbl
, 1 };
664 /***********************************************************************
665 * DllCanUnloadNow (DINPUT.@)
667 HRESULT WINAPI
DllCanUnloadNow(void)
669 FIXME("(void): stub\n");
674 /***********************************************************************
675 * DllGetClassObject (DINPUT.@)
677 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
679 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
680 if ( IsEqualCLSID( &IID_IClassFactory
, riid
) ) {
681 *ppv
= (LPVOID
)&DINPUT_CF
;
682 IClassFactory_AddRef((IClassFactory
*)*ppv
);
686 FIXME("(%s,%s,%p): no interface found.\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
687 return CLASS_E_CLASSNOTAVAILABLE
;