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 IDirectInput7AVtbl ddi7avt
;
48 static IDirectInput7WVtbl ddi7wvt
;
49 static IDirectInput8AVtbl ddi8avt
;
50 static IDirectInput8WVtbl 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 IDirectInputImpl
*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 for (j
= 0, r
= -1; r
!= 0; j
++) {
250 devInstance
.dwSize
= sizeof(devInstance
);
251 TRACE(" - checking device %d ('%s')\n", i
, dinput_devices
[i
]->name
);
252 if ((r
= dinput_devices
[i
]->enum_deviceA(dwDevType
, dwFlags
, &devInstance
, This
->version
, j
))) {
253 if (lpCallback(&devInstance
,pvRef
) == DIENUM_STOP
)
261 /******************************************************************************
262 * IDirectInputW_EnumDevices
264 static HRESULT WINAPI
IDirectInputWImpl_EnumDevices(
265 LPDIRECTINPUT7W iface
, DWORD dwDevType
, LPDIENUMDEVICESCALLBACKW lpCallback
,
266 LPVOID pvRef
, DWORD dwFlags
)
268 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
269 DIDEVICEINSTANCEW devInstance
;
272 TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
273 This
, dwDevType
, _dump_DIDEVTYPE_value(dwDevType
),
274 lpCallback
, pvRef
, dwFlags
);
275 TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags
); TRACE("\n");
277 for (i
= 0; i
< nrof_dinput_devices
; i
++) {
278 for (j
= 0, r
= -1; r
!= 0; j
++) {
279 devInstance
.dwSize
= sizeof(devInstance
);
280 TRACE(" - checking device %d ('%s')\n", i
, dinput_devices
[i
]->name
);
281 if ((r
= dinput_devices
[i
]->enum_deviceW(dwDevType
, dwFlags
, &devInstance
, This
->version
, j
))) {
282 if (lpCallback(&devInstance
,pvRef
) == DIENUM_STOP
)
291 static ULONG WINAPI
IDirectInputAImpl_AddRef(LPDIRECTINPUT7A iface
)
293 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
294 return InterlockedIncrement((&This
->ref
));
297 static ULONG WINAPI
IDirectInputAImpl_Release(LPDIRECTINPUT7A iface
)
299 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
301 ref
= InterlockedDecrement(&(This
->ref
));
303 HeapFree(GetProcessHeap(),0,This
);
307 static HRESULT WINAPI
IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface
, REFIID riid
, LPVOID
*ppobj
) {
308 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
310 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
311 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
312 IsEqualGUID(&IID_IDirectInputA
,riid
) ||
313 IsEqualGUID(&IID_IDirectInput2A
,riid
) ||
314 IsEqualGUID(&IID_IDirectInput7A
,riid
)) {
315 IDirectInputAImpl_AddRef(iface
);
319 TRACE("Unsupported interface !\n");
323 static HRESULT WINAPI
IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface
, REFIID riid
, LPVOID
*ppobj
) {
324 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
326 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
327 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
328 IsEqualGUID(&IID_IDirectInputW
,riid
) ||
329 IsEqualGUID(&IID_IDirectInput2W
,riid
) ||
330 IsEqualGUID(&IID_IDirectInput7W
,riid
)) {
331 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A
) iface
);
335 TRACE("Unsupported interface !\n");
339 static HRESULT WINAPI
IDirectInputAImpl_CreateDevice(
340 LPDIRECTINPUT7A iface
,REFGUID rguid
,LPDIRECTINPUTDEVICEA
* pdev
,
343 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
344 HRESULT ret_value
= DIERR_DEVICENOTREG
;
347 TRACE("(this=%p,%s,%p,%p)\n",This
,debugstr_guid(rguid
),pdev
,punk
);
349 /* Loop on all the devices to see if anyone matches the given GUID */
350 for (i
= 0; i
< nrof_dinput_devices
; i
++) {
352 if ((ret
= dinput_devices
[i
]->create_deviceA(This
, rguid
, NULL
, pdev
)) == DI_OK
)
355 if (ret
== DIERR_NOINTERFACE
)
356 ret_value
= DIERR_NOINTERFACE
;
362 static HRESULT WINAPI
IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7A iface
,
363 REFGUID rguid
, LPDIRECTINPUTDEVICEW
* pdev
, LPUNKNOWN punk
) {
364 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
365 HRESULT ret_value
= DIERR_DEVICENOTREG
;
368 TRACE("(this=%p,%s,%p,%p)\n",This
,debugstr_guid(rguid
),pdev
,punk
);
370 /* Loop on all the devices to see if anyone matches the given GUID */
371 for (i
= 0; i
< nrof_dinput_devices
; i
++) {
373 if ((ret
= dinput_devices
[i
]->create_deviceW(This
, rguid
, NULL
, pdev
)) == DI_OK
)
376 if (ret
== DIERR_NOINTERFACE
)
377 ret_value
= DIERR_NOINTERFACE
;
383 static HRESULT WINAPI
IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface
, HINSTANCE hinst
, DWORD x
) {
384 return DIERR_ALREADYINITIALIZED
;
387 static HRESULT WINAPI
IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface
,
389 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
391 FIXME("(%p)->(%s): stub\n",This
,debugstr_guid(rguid
));
396 static HRESULT WINAPI
IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface
,
399 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
400 FIXME("(%p)->(%08lx,%08lx): stub\n",This
, (DWORD
) hwndOwner
, dwFlags
);
405 static HRESULT WINAPI
IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface
, REFGUID rguid
,
406 LPCSTR pszName
, LPGUID pguidInstance
) {
407 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
408 FIXME("(%p)->(%s, %s, %p): stub\n", This
, debugstr_guid(rguid
), pszName
, pguidInstance
);
413 static HRESULT WINAPI
IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface
, REFGUID rguid
,
414 LPCWSTR pszName
, LPGUID pguidInstance
) {
415 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
416 FIXME("(%p)->(%s, %s, %p): stub\n", This
, debugstr_guid(rguid
), debugstr_w(pszName
), pguidInstance
);
421 static HRESULT WINAPI
IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface
, REFGUID rguid
,
422 REFIID riid
, LPVOID
* pvOut
, LPUNKNOWN lpUnknownOuter
)
424 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
425 HRESULT ret_value
= DIERR_DEVICENOTREG
;
428 TRACE("(%p)->(%s, %s, %p, %p)\n", This
, debugstr_guid(rguid
), debugstr_guid(riid
), pvOut
, lpUnknownOuter
);
430 /* Loop on all the devices to see if anyone matches the given GUID */
431 for (i
= 0; i
< nrof_dinput_devices
; i
++) {
433 if ((ret
= dinput_devices
[i
]->create_deviceA(This
, rguid
, riid
, (LPDIRECTINPUTDEVICEA
*) pvOut
)) == DI_OK
)
436 if (ret
== DIERR_NOINTERFACE
)
437 ret_value
= DIERR_NOINTERFACE
;
443 static HRESULT WINAPI
IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface
, REFGUID rguid
,
444 REFIID riid
, LPVOID
* pvOut
, LPUNKNOWN lpUnknownOuter
)
446 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
447 HRESULT ret_value
= DIERR_DEVICENOTREG
;
450 TRACE("(%p)->(%s, %s, %p, %p)\n", This
, debugstr_guid(rguid
), debugstr_guid(riid
), pvOut
, lpUnknownOuter
);
452 /* Loop on all the devices to see if anyone matches the given GUID */
453 for (i
= 0; i
< nrof_dinput_devices
; i
++) {
455 if ((ret
= dinput_devices
[i
]->create_deviceW(This
, rguid
, riid
, (LPDIRECTINPUTDEVICEW
*) pvOut
)) == DI_OK
)
458 if (ret
== DIERR_NOINTERFACE
)
459 ret_value
= DIERR_NOINTERFACE
;
465 static HRESULT WINAPI
IDirectInput8AImpl_QueryInterface(LPDIRECTINPUT8A iface
, REFIID riid
, LPVOID
*ppobj
) {
466 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
468 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
469 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
470 IsEqualGUID(&IID_IDirectInput8A
,riid
)) {
471 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A
) iface
);
475 TRACE("Unsupported interface !\n");
476 return E_NOINTERFACE
;
479 static HRESULT WINAPI
IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface
, REFIID riid
, LPVOID
*ppobj
) {
480 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
482 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
483 if (IsEqualGUID(&IID_IUnknown
,riid
) ||
484 IsEqualGUID(&IID_IDirectInput8W
,riid
)) {
485 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A
) iface
);
489 TRACE("Unsupported interface !\n");
490 return E_NOINTERFACE
;
493 static HRESULT WINAPI
IDirectInput8AImpl_EnumDevicesBySemantics(
494 LPDIRECTINPUT8A iface
, LPCSTR ptszUserName
, LPDIACTIONFORMATA lpdiActionFormat
,
495 LPDIENUMDEVICESBYSEMANTICSCBA lpCallback
,
496 LPVOID pvRef
, DWORD dwFlags
499 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
501 FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This
, ptszUserName
, lpdiActionFormat
,
502 lpCallback
, pvRef
, dwFlags
);
506 static HRESULT WINAPI
IDirectInput8WImpl_EnumDevicesBySemantics(
507 LPDIRECTINPUT8W iface
, LPCWSTR ptszUserName
, LPDIACTIONFORMATW lpdiActionFormat
,
508 LPDIENUMDEVICESBYSEMANTICSCBW lpCallback
,
509 LPVOID pvRef
, DWORD dwFlags
512 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
514 FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This
, debugstr_w(ptszUserName
), lpdiActionFormat
,
515 lpCallback
, pvRef
, dwFlags
);
519 static HRESULT WINAPI
IDirectInput8AImpl_ConfigureDevices(
520 LPDIRECTINPUT8A iface
, LPDICONFIGUREDEVICESCALLBACK lpdiCallback
,
521 LPDICONFIGUREDEVICESPARAMSA lpdiCDParams
, DWORD dwFlags
, LPVOID pvRefData
524 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
526 FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This
, lpdiCallback
, lpdiCDParams
,
531 static HRESULT WINAPI
IDirectInput8WImpl_ConfigureDevices(
532 LPDIRECTINPUT8W iface
, LPDICONFIGUREDEVICESCALLBACK lpdiCallback
,
533 LPDICONFIGUREDEVICESPARAMSW lpdiCDParams
, DWORD dwFlags
, LPVOID pvRefData
536 IDirectInputImpl
*This
= (IDirectInputImpl
*)iface
;
538 FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This
, lpdiCallback
, lpdiCDParams
,
543 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
544 # define XCAST(fun) (typeof(ddi7avt.fun))
546 # define XCAST(fun) (void*)
549 static IDirectInput7AVtbl ddi7avt
= {
550 XCAST(QueryInterface
)IDirectInputAImpl_QueryInterface
,
551 XCAST(AddRef
)IDirectInputAImpl_AddRef
,
552 XCAST(Release
)IDirectInputAImpl_Release
,
553 XCAST(CreateDevice
)IDirectInputAImpl_CreateDevice
,
554 XCAST(EnumDevices
)IDirectInputAImpl_EnumDevices
,
555 XCAST(GetDeviceStatus
)IDirectInputAImpl_GetDeviceStatus
,
556 XCAST(RunControlPanel
)IDirectInputAImpl_RunControlPanel
,
557 XCAST(Initialize
)IDirectInputAImpl_Initialize
,
558 XCAST(FindDevice
)IDirectInput2AImpl_FindDevice
,
559 XCAST(CreateDeviceEx
)IDirectInput7AImpl_CreateDeviceEx
563 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
564 # define XCAST(fun) (typeof(ddi7wvt.fun))
566 # define XCAST(fun) (void*)
569 static IDirectInput7WVtbl ddi7wvt
= {
570 XCAST(QueryInterface
)IDirectInputWImpl_QueryInterface
,
571 XCAST(AddRef
)IDirectInputAImpl_AddRef
,
572 XCAST(Release
)IDirectInputAImpl_Release
,
573 XCAST(CreateDevice
)IDirectInputWImpl_CreateDevice
,
574 XCAST(EnumDevices
)IDirectInputWImpl_EnumDevices
,
575 XCAST(GetDeviceStatus
)IDirectInputAImpl_GetDeviceStatus
,
576 XCAST(RunControlPanel
)IDirectInputAImpl_RunControlPanel
,
577 XCAST(Initialize
)IDirectInputAImpl_Initialize
,
578 XCAST(FindDevice
)IDirectInput2WImpl_FindDevice
,
579 XCAST(CreateDeviceEx
)IDirectInput7WImpl_CreateDeviceEx
583 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
584 # define XCAST(fun) (typeof(ddi8avt.fun))
586 # define XCAST(fun) (void*)
589 static IDirectInput8AVtbl ddi8avt
= {
590 XCAST(QueryInterface
)IDirectInput8AImpl_QueryInterface
,
591 XCAST(AddRef
)IDirectInputAImpl_AddRef
,
592 XCAST(Release
)IDirectInputAImpl_Release
,
593 XCAST(CreateDevice
)IDirectInputAImpl_CreateDevice
,
594 XCAST(EnumDevices
)IDirectInputAImpl_EnumDevices
,
595 XCAST(GetDeviceStatus
)IDirectInputAImpl_GetDeviceStatus
,
596 XCAST(RunControlPanel
)IDirectInputAImpl_RunControlPanel
,
597 XCAST(Initialize
)IDirectInputAImpl_Initialize
,
598 XCAST(FindDevice
)IDirectInput2AImpl_FindDevice
,
599 XCAST(EnumDevicesBySemantics
)IDirectInput8AImpl_EnumDevicesBySemantics
,
600 XCAST(ConfigureDevices
)IDirectInput8AImpl_ConfigureDevices
604 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
605 # define XCAST(fun) (typeof(ddi8wvt.fun))
607 # define XCAST(fun) (void*)
609 static IDirectInput8WVtbl ddi8wvt
= {
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 IClassFactoryImpl
*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 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
643 return InterlockedIncrement(&(This
->ref
));
646 static ULONG WINAPI
DICF_Release(LPCLASSFACTORY iface
) {
647 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
648 /* static class, won't be freed */
649 return InterlockedDecrement(&(This
->ref
));
652 static HRESULT WINAPI
DICF_CreateInstance(
653 LPCLASSFACTORY iface
,LPUNKNOWN pOuter
,REFIID riid
,LPVOID
*ppobj
655 IClassFactoryImpl
*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 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
676 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
680 static IClassFactoryVtbl DICF_Vtbl
= {
687 static IClassFactoryImpl DINPUT_CF
= {&DICF_Vtbl
, 1 };
689 /***********************************************************************
690 * DllCanUnloadNow (DINPUT.@)
692 HRESULT WINAPI
DINPUT_DllCanUnloadNow(void)
694 FIXME("(void): stub\n");
699 /***********************************************************************
700 * DllGetClassObject (DINPUT.@)
702 HRESULT WINAPI
DINPUT_DllGetClassObject(REFCLSID rclsid
, REFIID riid
,
705 TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
706 if ( IsEqualCLSID( &IID_IClassFactory
, riid
) ) {
707 *ppv
= (LPVOID
)&DINPUT_CF
;
708 IClassFactory_AddRef((IClassFactory
*)*ppv
);
712 FIXME("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
713 return CLASS_E_CLASSNOTAVAILABLE
;