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
39 #include "wine/debug.h"
40 #include "wine/unicode.h"
45 #include "dinput_private.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
49 static IDirectInput7AVtbl ddi7avt;
50 static IDirectInput7WVtbl ddi7wvt;
51 static IDirectInput8AVtbl ddi8avt;
52 static IDirectInput8WVtbl ddi8wvt;
54 /* This array will be filled a dinput.so loading */
55 #define MAX_WINE_DINPUT_DEVICES 4
56 static dinput_device * dinput_devices[MAX_WINE_DINPUT_DEVICES];
57 static int nrof_dinput_devices = 0;
59 HINSTANCE DINPUT_instance = NULL;
61 BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserv)
65 case DLL_PROCESS_ATTACH:
66 DisableThreadLibraryCalls(inst);
67 DINPUT_instance = inst;
69 case DLL_PROCESS_DETACH:
76 /* register a direct draw driver. We better not use malloc for we are in
77 * the ELF startup initialisation at this point.
79 void dinput_register_device(dinput_device *device) {
82 /* insert according to priority */
83 for (i=0;i<nrof_dinput_devices;i++) {
84 if (dinput_devices[i]->pref <= device->pref) {
85 memcpy(dinput_devices+i+1,dinput_devices+i,sizeof(dinput_devices[0])*(nrof_dinput_devices-i));
86 dinput_devices[i] = device;
90 if (i==nrof_dinput_devices) /* not found, or too low priority */
91 dinput_devices[nrof_dinput_devices] = device;
93 nrof_dinput_devices++;
95 /* increase MAX_DDRAW_DRIVERS if the line below triggers */
96 assert(nrof_dinput_devices <= MAX_WINE_DINPUT_DEVICES);
99 /******************************************************************************
100 * DirectInputCreateEx (DINPUT.@)
102 HRESULT WINAPI DirectInputCreateEx(
103 HINSTANCE hinst, DWORD dwVersion, REFIID riid, LPVOID *ppDI,
106 IDirectInputImpl* This;
108 TRACE("(0x%08lx,%04lx,%s,%p,%p)\n", (DWORD)hinst,dwVersion,debugstr_guid(riid),ppDI,punkOuter);
110 if (IsEqualGUID(&IID_IDirectInputA,riid) ||
111 IsEqualGUID(&IID_IDirectInput2A,riid) ||
112 IsEqualGUID(&IID_IDirectInput7A,riid)) {
113 This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
114 This->lpVtbl = &ddi7avt;
122 if (IsEqualGUID(&IID_IDirectInputW,riid) ||
123 IsEqualGUID(&IID_IDirectInput2W,riid) ||
124 IsEqualGUID(&IID_IDirectInput7W,riid)) {
125 This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
126 This->lpVtbl = &ddi7wvt;
134 if (IsEqualGUID(&IID_IDirectInput8A,riid)) {
135 This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
136 This->lpVtbl = &ddi8avt;
144 if (IsEqualGUID(&IID_IDirectInput8W,riid)) {
145 This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
146 This->lpVtbl = &ddi8wvt;
154 return DIERR_OLDDIRECTINPUTVERSION;
157 /******************************************************************************
158 * DirectInputCreateA (DINPUT.@)
160 HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter)
162 IDirectInputImpl* This;
163 TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
164 This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
165 This->lpVtbl = &ddi7avt;
167 if (dwVersion >= 0x0800) {
170 /* We do not differientiate between version 1, 2 and 7 */
173 *ppDI = (IDirectInputA*)This;
178 /******************************************************************************
179 * DirectInputCreateW (DINPUT.@)
181 HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter)
183 IDirectInputImpl* This;
184 TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
185 This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
186 This->lpVtbl = &ddi7wvt;
188 if (dwVersion >= 0x0800) {
191 /* We do not differientiate between version 1, 2 and 7 */
194 *ppDI = (IDirectInputW*)This;
198 static char *_dump_DIDEVTYPE_value(DWORD dwDevType) {
200 case 0: return "All devices";
201 case DIDEVTYPE_MOUSE: return "DIDEVTYPE_MOUSE";
202 case DIDEVTYPE_KEYBOARD: return "DIDEVTYPE_KEYBOARD";
203 case DIDEVTYPE_JOYSTICK: return "DIDEVTYPE_JOYSTICK";
204 case DIDEVTYPE_DEVICE: return "DIDEVTYPE_DEVICE";
205 default: return "Unkown";
209 static void _dump_EnumDevices_dwFlags(DWORD dwFlags) {
210 if (TRACE_ON(dinput)) {
212 static const struct {
216 #define FE(x) { x, #x}
217 FE(DIEDFL_ALLDEVICES),
218 FE(DIEDFL_ATTACHEDONLY),
219 FE(DIEDFL_FORCEFEEDBACK),
220 FE(DIEDFL_INCLUDEALIASES),
221 FE(DIEDFL_INCLUDEPHANTOMS)
225 DPRINTF("DIEDFL_ALLDEVICES");
228 for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
229 if (flags[i].mask & dwFlags)
230 DPRINTF("%s ",flags[i].name);
234 /******************************************************************************
235 * IDirectInputA_EnumDevices
237 static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
238 LPDIRECTINPUT7A iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback,
239 LPVOID pvRef, DWORD dwFlags)
241 IDirectInputImpl *This = (IDirectInputImpl *)iface;
242 DIDEVICEINSTANCEA devInstance;
245 TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
246 This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
247 lpCallback, pvRef, dwFlags);
248 TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
250 for (i = 0; i < nrof_dinput_devices; i++) {
251 for (j = 0, r = -1; r != 0; j++) {
252 devInstance.dwSize = sizeof(devInstance);
253 TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name);
254 if ((r = dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->version, j))) {
255 if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
263 /******************************************************************************
264 * IDirectInputW_EnumDevices
266 static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
267 LPDIRECTINPUT7W iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKW lpCallback,
268 LPVOID pvRef, DWORD dwFlags)
270 IDirectInputImpl *This = (IDirectInputImpl *)iface;
271 DIDEVICEINSTANCEW devInstance;
274 TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
275 This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
276 lpCallback, pvRef, dwFlags);
277 TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
279 for (i = 0; i < nrof_dinput_devices; i++) {
280 for (j = 0, r = -1; r != 0; j++) {
281 devInstance.dwSize = sizeof(devInstance);
282 TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name);
283 if ((r = dinput_devices[i]->enum_deviceW(dwDevType, dwFlags, &devInstance, This->version, j))) {
284 if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
293 static ULONG WINAPI IDirectInputAImpl_AddRef(LPDIRECTINPUT7A iface)
295 IDirectInputImpl *This = (IDirectInputImpl *)iface;
296 return InterlockedIncrement((&This->ref));
299 static ULONG WINAPI IDirectInputAImpl_Release(LPDIRECTINPUT7A iface)
301 IDirectInputImpl *This = (IDirectInputImpl *)iface;
303 ref = InterlockedDecrement(&(This->ref));
305 HeapFree(GetProcessHeap(),0,This);
309 static HRESULT WINAPI IDirectInputAImpl_QueryInterface(LPDIRECTINPUT7A iface, REFIID riid, LPVOID *ppobj) {
310 IDirectInputImpl *This = (IDirectInputImpl *)iface;
312 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
313 if (IsEqualGUID(&IID_IUnknown,riid) ||
314 IsEqualGUID(&IID_IDirectInputA,riid) ||
315 IsEqualGUID(&IID_IDirectInput2A,riid) ||
316 IsEqualGUID(&IID_IDirectInput7A,riid)) {
317 IDirectInputAImpl_AddRef(iface);
321 TRACE("Unsupported interface !\n");
325 static HRESULT WINAPI IDirectInputWImpl_QueryInterface(LPDIRECTINPUT7W iface, REFIID riid, LPVOID *ppobj) {
326 IDirectInputImpl *This = (IDirectInputImpl *)iface;
328 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
329 if (IsEqualGUID(&IID_IUnknown,riid) ||
330 IsEqualGUID(&IID_IDirectInputW,riid) ||
331 IsEqualGUID(&IID_IDirectInput2W,riid) ||
332 IsEqualGUID(&IID_IDirectInput7W,riid)) {
333 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
337 TRACE("Unsupported interface !\n");
341 static HRESULT WINAPI IDirectInputAImpl_CreateDevice(
342 LPDIRECTINPUT7A iface,REFGUID rguid,LPDIRECTINPUTDEVICEA* pdev,
345 IDirectInputImpl *This = (IDirectInputImpl *)iface;
346 HRESULT ret_value = DIERR_DEVICENOTREG;
349 TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
351 /* Loop on all the devices to see if anyone matches the given GUID */
352 for (i = 0; i < nrof_dinput_devices; i++) {
354 if ((ret = dinput_devices[i]->create_deviceA(This, rguid, NULL, pdev)) == DI_OK)
357 if (ret == DIERR_NOINTERFACE)
358 ret_value = DIERR_NOINTERFACE;
364 static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7A iface,
365 REFGUID rguid, LPDIRECTINPUTDEVICEW* pdev, LPUNKNOWN punk) {
366 IDirectInputImpl *This = (IDirectInputImpl *)iface;
367 HRESULT ret_value = DIERR_DEVICENOTREG;
370 TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
372 /* Loop on all the devices to see if anyone matches the given GUID */
373 for (i = 0; i < nrof_dinput_devices; i++) {
375 if ((ret = dinput_devices[i]->create_deviceW(This, rguid, NULL, pdev)) == DI_OK)
378 if (ret == DIERR_NOINTERFACE)
379 ret_value = DIERR_NOINTERFACE;
385 static HRESULT WINAPI IDirectInputAImpl_Initialize(LPDIRECTINPUT7A iface, HINSTANCE hinst, DWORD x) {
386 return DIERR_ALREADYINITIALIZED;
389 static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUT7A iface,
391 IDirectInputImpl *This = (IDirectInputImpl *)iface;
393 FIXME("(%p)->(%s): stub\n",This,debugstr_guid(rguid));
398 static HRESULT WINAPI IDirectInputAImpl_RunControlPanel(LPDIRECTINPUT7A iface,
401 IDirectInputImpl *This = (IDirectInputImpl *)iface;
402 FIXME("(%p)->(%08lx,%08lx): stub\n",This, (DWORD) hwndOwner, dwFlags);
407 static HRESULT WINAPI IDirectInput2AImpl_FindDevice(LPDIRECTINPUT7A iface, REFGUID rguid,
408 LPCSTR pszName, LPGUID pguidInstance) {
409 IDirectInputImpl *This = (IDirectInputImpl *)iface;
410 FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), pszName, pguidInstance);
415 static HRESULT WINAPI IDirectInput2WImpl_FindDevice(LPDIRECTINPUT7W iface, REFGUID rguid,
416 LPCWSTR pszName, LPGUID pguidInstance) {
417 IDirectInputImpl *This = (IDirectInputImpl *)iface;
418 FIXME("(%p)->(%s, %s, %p): stub\n", This, debugstr_guid(rguid), debugstr_w(pszName), pguidInstance);
423 static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, REFGUID rguid,
424 REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
426 IDirectInputImpl *This = (IDirectInputImpl *)iface;
427 HRESULT ret_value = DIERR_DEVICENOTREG;
430 TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
432 /* Loop on all the devices to see if anyone matches the given GUID */
433 for (i = 0; i < nrof_dinput_devices; i++) {
435 if ((ret = dinput_devices[i]->create_deviceA(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
438 if (ret == DIERR_NOINTERFACE)
439 ret_value = DIERR_NOINTERFACE;
445 static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, REFGUID rguid,
446 REFIID riid, LPVOID* pvOut, LPUNKNOWN lpUnknownOuter)
448 IDirectInputImpl *This = (IDirectInputImpl *)iface;
449 HRESULT ret_value = DIERR_DEVICENOTREG;
452 TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
454 /* Loop on all the devices to see if anyone matches the given GUID */
455 for (i = 0; i < nrof_dinput_devices; i++) {
457 if ((ret = dinput_devices[i]->create_deviceW(This, rguid, riid, (LPDIRECTINPUTDEVICEW*) pvOut)) == DI_OK)
460 if (ret == DIERR_NOINTERFACE)
461 ret_value = DIERR_NOINTERFACE;
467 static HRESULT WINAPI IDirectInput8AImpl_QueryInterface(LPDIRECTINPUT8A iface, REFIID riid, LPVOID *ppobj) {
468 IDirectInputImpl *This = (IDirectInputImpl *)iface;
470 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
471 if (IsEqualGUID(&IID_IUnknown,riid) ||
472 IsEqualGUID(&IID_IDirectInput8A,riid)) {
473 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
477 TRACE("Unsupported interface !\n");
478 return E_NOINTERFACE;
481 static HRESULT WINAPI IDirectInput8WImpl_QueryInterface(LPDIRECTINPUT8W iface, REFIID riid, LPVOID *ppobj) {
482 IDirectInputImpl *This = (IDirectInputImpl *)iface;
484 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
485 if (IsEqualGUID(&IID_IUnknown,riid) ||
486 IsEqualGUID(&IID_IDirectInput8W,riid)) {
487 IDirectInputAImpl_AddRef((LPDIRECTINPUT7A) iface);
491 TRACE("Unsupported interface !\n");
492 return E_NOINTERFACE;
495 static HRESULT WINAPI IDirectInput8AImpl_EnumDevicesBySemantics(
496 LPDIRECTINPUT8A iface, LPCSTR ptszUserName, LPDIACTIONFORMATA lpdiActionFormat,
497 LPDIENUMDEVICESBYSEMANTICSCBA lpCallback,
498 LPVOID pvRef, DWORD dwFlags
501 IDirectInputImpl *This = (IDirectInputImpl *)iface;
503 FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, ptszUserName, lpdiActionFormat,
504 lpCallback, pvRef, dwFlags);
508 static HRESULT WINAPI IDirectInput8WImpl_EnumDevicesBySemantics(
509 LPDIRECTINPUT8W iface, LPCWSTR ptszUserName, LPDIACTIONFORMATW lpdiActionFormat,
510 LPDIENUMDEVICESBYSEMANTICSCBW lpCallback,
511 LPVOID pvRef, DWORD dwFlags
514 IDirectInputImpl *This = (IDirectInputImpl *)iface;
516 FIXME("(this=%p,%s,%p,%p,%p,%04lx): stub\n", This, debugstr_w(ptszUserName), lpdiActionFormat,
517 lpCallback, pvRef, dwFlags);
521 static HRESULT WINAPI IDirectInput8AImpl_ConfigureDevices(
522 LPDIRECTINPUT8A iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
523 LPDICONFIGUREDEVICESPARAMSA lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
526 IDirectInputImpl *This = (IDirectInputImpl *)iface;
528 FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
533 static HRESULT WINAPI IDirectInput8WImpl_ConfigureDevices(
534 LPDIRECTINPUT8W iface, LPDICONFIGUREDEVICESCALLBACK lpdiCallback,
535 LPDICONFIGUREDEVICESPARAMSW lpdiCDParams, DWORD dwFlags, LPVOID pvRefData
538 IDirectInputImpl *This = (IDirectInputImpl *)iface;
540 FIXME("(this=%p,%p,%p,%04lx,%p): stub\n", This, lpdiCallback, lpdiCDParams,
545 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
546 # define XCAST(fun) (typeof(ddi7avt.fun))
548 # define XCAST(fun) (void*)
551 static IDirectInput7AVtbl ddi7avt = {
552 XCAST(QueryInterface)IDirectInputAImpl_QueryInterface,
553 XCAST(AddRef)IDirectInputAImpl_AddRef,
554 XCAST(Release)IDirectInputAImpl_Release,
555 XCAST(CreateDevice)IDirectInputAImpl_CreateDevice,
556 XCAST(EnumDevices)IDirectInputAImpl_EnumDevices,
557 XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
558 XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
559 XCAST(Initialize)IDirectInputAImpl_Initialize,
560 XCAST(FindDevice)IDirectInput2AImpl_FindDevice,
561 XCAST(CreateDeviceEx)IDirectInput7AImpl_CreateDeviceEx
565 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
566 # define XCAST(fun) (typeof(ddi7wvt.fun))
568 # define XCAST(fun) (void*)
571 static IDirectInput7WVtbl ddi7wvt = {
572 XCAST(QueryInterface)IDirectInputWImpl_QueryInterface,
573 XCAST(AddRef)IDirectInputAImpl_AddRef,
574 XCAST(Release)IDirectInputAImpl_Release,
575 XCAST(CreateDevice)IDirectInputWImpl_CreateDevice,
576 XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
577 XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
578 XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
579 XCAST(Initialize)IDirectInputAImpl_Initialize,
580 XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
581 XCAST(CreateDeviceEx)IDirectInput7WImpl_CreateDeviceEx
585 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
586 # define XCAST(fun) (typeof(ddi8avt.fun))
588 # define XCAST(fun) (void*)
591 static IDirectInput8AVtbl ddi8avt = {
592 XCAST(QueryInterface)IDirectInput8AImpl_QueryInterface,
593 XCAST(AddRef)IDirectInputAImpl_AddRef,
594 XCAST(Release)IDirectInputAImpl_Release,
595 XCAST(CreateDevice)IDirectInputAImpl_CreateDevice,
596 XCAST(EnumDevices)IDirectInputAImpl_EnumDevices,
597 XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
598 XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
599 XCAST(Initialize)IDirectInputAImpl_Initialize,
600 XCAST(FindDevice)IDirectInput2AImpl_FindDevice,
601 XCAST(EnumDevicesBySemantics)IDirectInput8AImpl_EnumDevicesBySemantics,
602 XCAST(ConfigureDevices)IDirectInput8AImpl_ConfigureDevices
606 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
607 # define XCAST(fun) (typeof(ddi8wvt.fun))
609 # define XCAST(fun) (void*)
611 static IDirectInput8WVtbl ddi8wvt = {
612 XCAST(QueryInterface)IDirectInput8WImpl_QueryInterface,
613 XCAST(AddRef)IDirectInputAImpl_AddRef,
614 XCAST(Release)IDirectInputAImpl_Release,
615 XCAST(CreateDevice)IDirectInputWImpl_CreateDevice,
616 XCAST(EnumDevices)IDirectInputWImpl_EnumDevices,
617 XCAST(GetDeviceStatus)IDirectInputAImpl_GetDeviceStatus,
618 XCAST(RunControlPanel)IDirectInputAImpl_RunControlPanel,
619 XCAST(Initialize)IDirectInputAImpl_Initialize,
620 XCAST(FindDevice)IDirectInput2WImpl_FindDevice,
621 XCAST(EnumDevicesBySemantics)IDirectInput8WImpl_EnumDevicesBySemantics,
622 XCAST(ConfigureDevices)IDirectInput8WImpl_ConfigureDevices
626 /*******************************************************************************
627 * DirectInput ClassFactory
631 /* IUnknown fields */
632 IClassFactoryVtbl *lpVtbl;
636 static HRESULT WINAPI DICF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
637 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
639 FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
640 return E_NOINTERFACE;
643 static ULONG WINAPI DICF_AddRef(LPCLASSFACTORY iface) {
644 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
645 return InterlockedIncrement(&(This->ref));
648 static ULONG WINAPI DICF_Release(LPCLASSFACTORY iface) {
649 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
650 /* static class, won't be freed */
651 return InterlockedDecrement(&(This->ref));
654 static HRESULT WINAPI DICF_CreateInstance(
655 LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
657 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
659 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
660 if ( IsEqualGUID( &IID_IDirectInputA, riid ) ||
661 IsEqualGUID( &IID_IDirectInputW, riid ) ||
662 IsEqualGUID( &IID_IDirectInput2A, riid ) ||
663 IsEqualGUID( &IID_IDirectInput2W, riid ) ||
664 IsEqualGUID( &IID_IDirectInput7A, riid ) ||
665 IsEqualGUID( &IID_IDirectInput7W, riid ) ||
666 IsEqualGUID( &IID_IDirectInput8A, riid ) ||
667 IsEqualGUID( &IID_IDirectInput8W, riid ) ) {
668 /* FIXME: reuse already created dinput if present? */
669 return DirectInputCreateEx(0,0,riid,ppobj,pOuter);
672 FIXME("(%p,%p,%s,%p) Interface not found!\n",This,pOuter,debugstr_guid(riid),ppobj);
673 return E_NOINTERFACE;
676 static HRESULT WINAPI DICF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
677 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
678 FIXME("(%p)->(%d),stub!\n",This,dolock);
682 static IClassFactoryVtbl DICF_Vtbl = {
689 static IClassFactoryImpl DINPUT_CF = {&DICF_Vtbl, 1 };
691 /***********************************************************************
692 * DllCanUnloadNow (DINPUT.@)
694 HRESULT WINAPI DINPUT_DllCanUnloadNow(void)
696 FIXME("(void): stub\n");
701 /***********************************************************************
702 * DllGetClassObject (DINPUT.@)
704 HRESULT WINAPI DINPUT_DllGetClassObject(REFCLSID rclsid, REFIID riid,
707 TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
708 if ( IsEqualCLSID( &IID_IClassFactory, riid ) ) {
709 *ppv = (LPVOID)&DINPUT_CF;
710 IClassFactory_AddRef((IClassFactory*)*ppv);
714 FIXME("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
715 return CLASS_E_CLASSNOTAVAILABLE;