Do nothing in ShowWindow(SW_SHOW) if a window is already visible.
[wine] / dlls / dinput / device.c
1 /*              DirectInput Device
2  *
3  * Copyright 1998 Marcus Meissner
4  * Copyright 1998,1999 Lionel Ulmer
5  *
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 /* This file contains all the Device specific functions that can be used as stubs
23    by real device implementations.
24
25    It also contains all the helper functions.
26 */
27 #include "config.h"
28
29 #include <stdarg.h>
30 #include <string.h>
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
33 #include "windef.h"
34 #include "winbase.h"
35 #include "winerror.h"
36 #include "dinput.h"
37 #include "device_private.h"
38
39 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
40
41 /******************************************************************************
42  *      Various debugging tools
43  */
44 void _dump_cooperativelevel_DI(DWORD dwFlags) {
45     if (TRACE_ON(dinput)) {
46         int   i;
47         static const struct {
48             DWORD       mask;
49             const char  *name;
50         } flags[] = {
51 #define FE(x) { x, #x}
52             FE(DISCL_BACKGROUND),
53             FE(DISCL_EXCLUSIVE),
54             FE(DISCL_FOREGROUND),
55             FE(DISCL_NONEXCLUSIVE)
56 #undef FE
57         };
58         for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
59             if (flags[i].mask & dwFlags)
60                 DPRINTF("%s ",flags[i].name);
61         DPRINTF("\n");
62     }
63 }
64
65 void _dump_EnumObjects_flags(DWORD dwFlags) {
66     if (TRACE_ON(dinput)) {
67         int   i;
68         DWORD type, instance;
69         static const struct {
70             DWORD       mask;
71             const char  *name;
72         } flags[] = {
73 #define FE(x) { x, #x}
74             FE(DIDFT_RELAXIS),
75             FE(DIDFT_ABSAXIS),
76             FE(DIDFT_PSHBUTTON),
77             FE(DIDFT_TGLBUTTON),
78             FE(DIDFT_POV),
79             FE(DIDFT_COLLECTION),
80             FE(DIDFT_NODATA),       
81             FE(DIDFT_FFACTUATOR),
82             FE(DIDFT_FFEFFECTTRIGGER),
83             FE(DIDFT_OUTPUT)
84 #undef FE
85         };
86         type = (dwFlags & 0xFF0000FF);
87         instance = ((dwFlags >> 8) & 0xFFFF);
88         DPRINTF("Type:");
89         if (type == DIDFT_ALL) {
90             DPRINTF(" DIDFT_ALL");
91         } else {
92             for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++) {
93                 if (flags[i].mask & type) {
94                     type &= ~flags[i].mask;
95                     DPRINTF(" %s",flags[i].name);
96                 }
97             }
98             if (type) {
99                 DPRINTF(" (unhandled: %08lx)", type);
100             }
101         }
102         DPRINTF(" / Instance: ");
103         if (instance == ((DIDFT_ANYINSTANCE >> 8) & 0xFFFF)) {
104             DPRINTF("DIDFT_ANYINSTANCE");
105         } else {
106             DPRINTF("%3ld", instance);
107         }
108     }
109 }
110
111 void _dump_DIPROPHEADER(DIPROPHEADER *diph) {
112     if (TRACE_ON(dinput)) {
113         DPRINTF("  - dwObj = 0x%08lx\n", diph->dwObj);
114         DPRINTF("  - dwHow = %s\n",
115                 ((diph->dwHow == DIPH_DEVICE) ? "DIPH_DEVICE" :
116                  ((diph->dwHow == DIPH_BYOFFSET) ? "DIPH_BYOFFSET" :
117                   ((diph->dwHow == DIPH_BYID)) ? "DIPH_BYID" : "unknown")));
118     }
119 }
120
121 void _dump_OBJECTINSTANCEA(DIDEVICEOBJECTINSTANCEA *ddoi) {
122     if (TRACE_ON(dinput)) {
123         DPRINTF("    - enumerating : %s ('%s') - %2ld - 0x%08lx - %s\n",
124                 debugstr_guid(&ddoi->guidType), _dump_dinput_GUID(&ddoi->guidType), ddoi->dwOfs, ddoi->dwType, ddoi->tszName);
125     }
126 }
127
128 void _dump_OBJECTINSTANCEW(DIDEVICEOBJECTINSTANCEW *ddoi) {
129     if (TRACE_ON(dinput)) {
130         DPRINTF("    - enumerating : %s ('%s'), - %2ld - 0x%08lx - %s\n",
131                 debugstr_guid(&ddoi->guidType), _dump_dinput_GUID(&ddoi->guidType), ddoi->dwOfs, ddoi->dwType, debugstr_w(ddoi->tszName));
132     }
133 }
134
135 /* This function is a helper to convert a GUID into any possible DInput GUID out there */
136 const char *_dump_dinput_GUID(const GUID *guid) {
137     int i;
138     static const struct {
139         const GUID *guid;
140         const char *name;
141     } guids[] = {
142 #define FE(x) { &x, #x}
143         FE(GUID_XAxis),
144         FE(GUID_YAxis),
145         FE(GUID_ZAxis),
146         FE(GUID_RxAxis),
147         FE(GUID_RyAxis),
148         FE(GUID_RzAxis),
149         FE(GUID_Slider),
150         FE(GUID_Button),
151         FE(GUID_Key),
152         FE(GUID_POV),
153         FE(GUID_Unknown),
154         FE(GUID_SysMouse),
155         FE(GUID_SysKeyboard),
156         FE(GUID_Joystick),
157         FE(GUID_ConstantForce),
158         FE(GUID_RampForce),
159         FE(GUID_Square),
160         FE(GUID_Sine),
161         FE(GUID_Triangle),
162         FE(GUID_SawtoothUp),
163         FE(GUID_SawtoothDown),
164         FE(GUID_Spring),
165         FE(GUID_Damper),
166         FE(GUID_Inertia),
167         FE(GUID_Friction),
168         FE(GUID_CustomForce)
169 #undef FE
170     };
171     if (guid == NULL)
172         return "null GUID";
173     for (i = 0; i < (sizeof(guids) / sizeof(guids[0])); i++) {
174         if (IsEqualGUID(guids[i].guid, guid)) {
175             return guids[i].name;
176         }
177     }
178     return "Unknown GUID";
179 }
180
181 void _dump_DIDATAFORMAT(const DIDATAFORMAT *df) {
182     int i;
183
184     TRACE("Dumping DIDATAFORMAT structure:\n");
185     TRACE("  - dwSize: %ld\n", df->dwSize);
186     if (df->dwSize != sizeof(DIDATAFORMAT)) {
187         WARN("Non-standard DIDATAFORMAT structure size (%ld instead of %d).\n", df->dwSize, sizeof(DIDATAFORMAT));
188     }
189     TRACE("  - dwObjsize: %ld\n", df->dwObjSize);
190     if (df->dwObjSize != sizeof(DIOBJECTDATAFORMAT)) {
191         WARN("Non-standard DIOBJECTDATAFORMAT structure size (%ld instead of %d).\n", df->dwObjSize, sizeof(DIOBJECTDATAFORMAT));
192     }
193     TRACE("  - dwFlags: 0x%08lx (", df->dwFlags);
194     switch (df->dwFlags) {
195         case DIDF_ABSAXIS: TRACE("DIDF_ABSAXIS"); break;
196         case DIDF_RELAXIS: TRACE("DIDF_RELAXIS"); break;
197         default: TRACE("unknown"); break;
198     }
199     TRACE(")\n");
200     TRACE("  - dwDataSize: %ld\n", df->dwDataSize);
201     TRACE("  - dwNumObjs: %ld\n", df->dwNumObjs);
202     
203     for (i = 0; i < df->dwNumObjs; i++) {
204         TRACE("  - Object %d:\n", i);
205         TRACE("      * GUID: %s ('%s')\n", debugstr_guid(df->rgodf[i].pguid), _dump_dinput_GUID(df->rgodf[i].pguid));
206         TRACE("      * dwOfs: %ld\n", df->rgodf[i].dwOfs);
207         TRACE("      * dwType: 0x%08lx\n", df->rgodf[i].dwType);
208         TRACE("        "); _dump_EnumObjects_flags(df->rgodf[i].dwType); TRACE("\n");
209         TRACE("      * dwFlags: 0x%08lx\n", df->rgodf[i].dwFlags);
210     }
211 }
212
213 /* Conversion between internal data buffer and external data buffer */
214 void fill_DataFormat(void *out, void *in, DataFormat *df) {
215     int i;
216     char *in_c = (char *) in;
217     char *out_c = (char *) out;
218     
219     if (df->dt == NULL) {
220         /* This means that the app uses Wine's internal data format */
221         memcpy(out, in, df->internal_format_size);
222     } else {
223         for (i = 0; i < df->size; i++) {
224             if (df->dt[i].offset_in >= 0) {
225                 switch (df->dt[i].size) {
226                     case 1:
227                         TRACE("Copying (c) to %d from %d (value %d)\n",
228                               df->dt[i].offset_out, df->dt[i].offset_in, *((char *) (in_c + df->dt[i].offset_in)));
229                         *((char *) (out_c + df->dt[i].offset_out)) = *((char *) (in_c + df->dt[i].offset_in));
230                         break;
231                     
232                     case 2:
233                         TRACE("Copying (s) to %d from %d (value %d)\n",
234                               df->dt[i].offset_out, df->dt[i].offset_in, *((short *) (in_c + df->dt[i].offset_in)));
235                         *((short *) (out_c + df->dt[i].offset_out)) = *((short *) (in_c + df->dt[i].offset_in));
236                         break;
237                     
238                     case 4:
239                         TRACE("Copying (i) to %d from %d (value %d)\n",
240                               df->dt[i].offset_out, df->dt[i].offset_in, *((int *) (in_c + df->dt[i].offset_in)));
241                         *((int *) (out_c + df->dt[i].offset_out)) = *((int *) (in_c + df->dt[i].offset_in));
242                         break;
243                     
244                     default:
245                         memcpy((out_c + df->dt[i].offset_out), (in_c + df->dt[i].offset_in), df->dt[i].size);
246                         break;
247                 }
248             } else {
249                 switch (df->dt[i].size) {
250                     case 1:
251                         TRACE("Copying (c) to %d default value %d\n",
252                               df->dt[i].offset_out, df->dt[i].value);
253                         *((char *) (out_c + df->dt[i].offset_out)) = (char) df->dt[i].value;
254                         break;
255                         
256                     case 2:
257                         TRACE("Copying (s) to %d default value %d\n",
258                               df->dt[i].offset_out, df->dt[i].value);
259                         *((short *) (out_c + df->dt[i].offset_out)) = (short) df->dt[i].value;
260                         break;
261                         
262                     case 4:
263                         TRACE("Copying (i) to %d default value %d\n",
264                               df->dt[i].offset_out, df->dt[i].value);
265                         *((int *) (out_c + df->dt[i].offset_out)) = (int) df->dt[i].value;
266                         break;
267                         
268                     default:
269                         memset((out_c + df->dt[i].offset_out), df->dt[i].size, 0);
270                         break;
271                 }
272             }
273         }
274     }
275 }
276
277 DataFormat *create_DataFormat(const DIDATAFORMAT *wine_format, LPCDIDATAFORMAT asked_format, int *offset) {
278     DataFormat *ret;
279     DataTransform *dt;
280     int i, j;
281     int same = 1;
282     int *done;
283     int index = 0;
284     
285     ret = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
286     
287     done = (int *) HeapAlloc(GetProcessHeap(), 0, sizeof(int) * asked_format->dwNumObjs);
288     memset(done, 0, sizeof(int) * asked_format->dwNumObjs);
289     
290     dt = (DataTransform *) HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform));
291     
292     TRACE("Creating DataTransform : \n");
293     
294     for (i = 0; i < wine_format->dwNumObjs; i++) {
295         offset[i] = -1;
296         
297         for (j = 0; j < asked_format->dwNumObjs; j++) {
298             if (done[j] == 1)
299                 continue;
300             
301             if (/* Check if the application either requests any GUID and if not, it if matches
302                  * the GUID of the Wine object.
303                  */
304                 ((asked_format->rgodf[j].pguid == NULL) ||
305                  (IsEqualGUID(wine_format->rgodf[i].pguid, asked_format->rgodf[j].pguid)))
306                 &&
307                 (/* Then check if it accepts any instance id, and if not, if it matches Wine's
308                   * instance id.
309                   */
310                  ((asked_format->rgodf[j].dwType & 0x00FFFF00) == DIDFT_ANYINSTANCE) ||
311                  (DIDFT_GETINSTANCE(wine_format->rgodf[i].dwType) == DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType)))) {
312                 
313                 done[j] = 1;
314                 
315                 TRACE("Matching : \n");
316                 TRACE("   - Asked (%d) :\n", j);
317                 TRACE("       * GUID: %s ('%s')\n",
318                       debugstr_guid(asked_format->rgodf[j].pguid),
319                       _dump_dinput_GUID(asked_format->rgodf[j].pguid));
320                 TRACE("       * Offset: %3ld\n", asked_format->rgodf[j].dwOfs);
321                 TRACE("       * dwType: %08lx\n", asked_format->rgodf[j].dwType);
322                 TRACE("         "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
323                 
324                 TRACE("   - Wine  (%d) :\n", j);
325                 TRACE("       * GUID: %s ('%s')\n",
326                       debugstr_guid(wine_format->rgodf[j].pguid),
327                       _dump_dinput_GUID(wine_format->rgodf[j].pguid));
328                 TRACE("       * Offset: %3ld\n", wine_format->rgodf[j].dwOfs);
329                 TRACE("       * dwType: %08lx\n", wine_format->rgodf[j].dwType);
330                 TRACE("         "); _dump_EnumObjects_flags(wine_format->rgodf[j].dwType); TRACE("\n");
331                 
332                 if (wine_format->rgodf[i].dwType & DIDFT_BUTTON)
333                     dt[index].size = sizeof(BYTE);
334                 else
335                     dt[index].size = sizeof(DWORD);
336                 dt[index].offset_in  = wine_format ->rgodf[i].dwOfs;
337                 dt[index].offset_out = asked_format->rgodf[j].dwOfs;
338                 dt[index].value = 0;
339                 index++;
340                 
341                 if (wine_format->rgodf[i].dwOfs != asked_format->rgodf[j].dwOfs)
342                     same = 0;
343                 
344                 offset[i] = asked_format->rgodf[j].dwOfs;
345                 break;
346             }
347         }
348         
349         if (j == asked_format->dwNumObjs)
350             same = 0;
351     }
352     
353     TRACE("Setting to default value :\n");
354     for (j = 0; j < asked_format->dwNumObjs; j++) {
355         if (done[j] == 0) {
356             TRACE("   - Asked (%d) :\n", j);
357             TRACE("       * GUID: %s ('%s')\n",
358                   debugstr_guid(asked_format->rgodf[j].pguid),
359                   _dump_dinput_GUID(asked_format->rgodf[j].pguid));
360             TRACE("       * Offset: %3ld\n", asked_format->rgodf[j].dwOfs);
361             TRACE("       * dwType: %08lx\n", asked_format->rgodf[j].dwType);
362             TRACE("         "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
363             
364             if (asked_format->rgodf[j].dwType & DIDFT_BUTTON)
365                 dt[index].size = sizeof(BYTE);
366             else
367                 dt[index].size = sizeof(DWORD);
368             dt[index].offset_in  = -1;
369             dt[index].offset_out = asked_format->rgodf[j].dwOfs;
370             dt[index].value = 0;
371             index++;
372             
373             same = 0;
374         }
375     }
376     
377     ret->internal_format_size = wine_format->dwDataSize;
378     ret->size = index;
379     if (same) {
380         ret->dt = NULL;
381         HeapFree(GetProcessHeap(), 0, dt);
382     } else {
383         ret->dt = dt;
384     }
385     
386     HeapFree(GetProcessHeap(), 0, done);
387     
388     return ret;
389 }
390
391 BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA lpddi, LPVOID lpvRef) {
392     DIDEVICEOBJECTINSTANCEW ddtmp;
393     device_enumobjects_AtoWcb_data* data;
394
395     data = (device_enumobjects_AtoWcb_data*) lpvRef;
396     
397     memset(&ddtmp, 0, sizeof(DIDEVICEINSTANCEW)); 
398     
399     ddtmp.dwSize = sizeof(DIDEVICEINSTANCEW);
400     ddtmp.guidType     = lpddi->guidType;
401     ddtmp.dwOfs        = lpddi->dwOfs;
402     ddtmp.dwType       = lpddi->dwType;
403     ddtmp.dwFlags      = lpddi->dwFlags;
404     MultiByteToWideChar(CP_ACP, 0, lpddi->tszName, -1, ddtmp.tszName, MAX_PATH);
405     
406     if (lpddi->dwSize == sizeof(DIDEVICEINSTANCEA)) {
407         /**
408          * if dwSize < sizeof(DIDEVICEINSTANCEA of DInput version >= 5)
409          *  force feedback and other newer datas aren't available
410          */
411         ddtmp.dwFFMaxForce        = lpddi->dwFFMaxForce;
412         ddtmp.dwFFForceResolution = lpddi->dwFFForceResolution;
413         ddtmp.wCollectionNumber   = lpddi->wCollectionNumber;
414         ddtmp.wDesignatorIndex    = lpddi->wDesignatorIndex;
415         ddtmp.wUsagePage          = lpddi->wUsagePage;
416         ddtmp.wUsage              = lpddi->wUsage;
417         ddtmp.dwDimension         = lpddi->dwDimension;
418         ddtmp.wExponent           = lpddi->wExponent;
419         ddtmp.wReserved           = lpddi->wReserved;
420     }
421     return data->lpCallBack(&ddtmp, data->lpvRef);
422 }
423
424 /******************************************************************************
425  *      IDirectInputDeviceA
426  */
427
428 HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
429         LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
430 ) {
431     ICOM_THIS(IDirectInputDevice2AImpl,iface);
432     
433     TRACE("(this=%p,%p)\n",This,df);
434     
435     _dump_DIDATAFORMAT(df);
436     
437     return DI_OK;
438 }
439
440 HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
441         LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags
442 ) {
443     ICOM_THIS(IDirectInputDevice2AImpl,iface);
444     TRACE("(this=%p,0x%08lx,0x%08lx)\n",This,(DWORD)hwnd,dwflags);
445     if (TRACE_ON(dinput)) {
446         TRACE(" cooperative level : ");
447         _dump_cooperativelevel_DI(dwflags);
448     }
449     return DI_OK;
450 }
451
452 HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
453         LPDIRECTINPUTDEVICE8A iface,HANDLE hnd
454 ) {
455     ICOM_THIS(IDirectInputDevice2AImpl,iface);
456     FIXME("(this=%p,0x%08lx): stub\n",This,(DWORD)hnd);
457     return DI_OK;
458 }
459
460 ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface)
461 {
462     ICOM_THIS(IDirectInputDevice2AImpl,iface);
463     This->ref--;
464     if (This->ref)
465         return This->ref;
466     HeapFree(GetProcessHeap(),0,This);
467     return DI_OK;
468 }
469
470 HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(
471         LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj
472 )
473 {
474     ICOM_THIS(IDirectInputDevice2AImpl,iface);
475     
476     TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
477     if (IsEqualGUID(&IID_IUnknown,riid)) {
478         IDirectInputDevice2_AddRef(iface);
479         *ppobj = This;
480         return DI_OK;
481     }
482     if (IsEqualGUID(&IID_IDirectInputDeviceA,riid)) {
483         IDirectInputDevice2_AddRef(iface);
484         *ppobj = This;
485         return DI_OK;
486     }
487     if (IsEqualGUID(&IID_IDirectInputDevice2A,riid)) {
488         IDirectInputDevice2_AddRef(iface);
489         *ppobj = This;
490         return DI_OK;
491     }
492     if (IsEqualGUID(&IID_IDirectInputDevice7A,riid)) {
493         IDirectInputDevice7_AddRef(iface);
494         *ppobj = This;
495         return DI_OK;
496     }
497     TRACE("Unsupported interface !\n");
498     return E_FAIL;
499 }
500
501 HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(
502         LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj
503 )
504 {
505     ICOM_THIS(IDirectInputDevice2AImpl,iface);
506     
507     TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
508     if (IsEqualGUID(&IID_IUnknown,riid)) {
509         IDirectInputDevice2_AddRef(iface);
510         *ppobj = This;
511         return DI_OK;
512     }
513     if (IsEqualGUID(&IID_IDirectInputDeviceW,riid)) {
514         IDirectInputDevice2_AddRef(iface);
515         *ppobj = This;
516         return DI_OK;
517     }
518     if (IsEqualGUID(&IID_IDirectInputDevice2W,riid)) {
519         IDirectInputDevice2_AddRef(iface);
520         *ppobj = This;
521         return DI_OK;
522     }
523     if (IsEqualGUID(&IID_IDirectInputDevice7W,riid)) {
524         IDirectInputDevice7_AddRef(iface);
525         *ppobj = This;
526         return DI_OK;
527     }
528     TRACE("Unsupported interface !\n");
529     return E_FAIL;
530 }
531
532 ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
533         LPDIRECTINPUTDEVICE8A iface)
534 {
535     ICOM_THIS(IDirectInputDevice2AImpl,iface);
536     return ++This->ref;
537 }
538
539 HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
540         LPDIRECTINPUTDEVICE8A iface,
541         LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
542         LPVOID lpvRef,
543         DWORD dwFlags)
544 {
545     FIXME("(this=%p,%p,%p,%08lx): stub!\n", iface, lpCallback, lpvRef, dwFlags);
546     if (TRACE_ON(dinput)) {
547         DPRINTF("  - flags = ");
548         _dump_EnumObjects_flags(dwFlags);
549         DPRINTF("\n");
550     }
551     
552     return DI_OK;
553 }
554
555 HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
556         LPDIRECTINPUTDEVICE8W iface,
557         LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
558         LPVOID lpvRef,
559         DWORD dwFlags)
560 {
561     FIXME("(this=%p,%p,%p,%08lx): stub!\n", iface, lpCallback, lpvRef, dwFlags);
562     if (TRACE_ON(dinput)) {
563         DPRINTF("  - flags = ");
564         _dump_EnumObjects_flags(dwFlags);
565         DPRINTF("\n");
566     }
567     
568     return DI_OK;
569 }
570
571 HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
572         LPDIRECTINPUTDEVICE8A iface,
573         REFGUID rguid,
574         LPDIPROPHEADER pdiph)
575 {
576     FIXME("(this=%p,%s,%p): stub!\n",
577           iface, debugstr_guid(rguid), pdiph);
578     
579     if (TRACE_ON(dinput))
580         _dump_DIPROPHEADER(pdiph);
581     
582     return DI_OK;
583 }
584
585 HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
586         LPDIRECTINPUTDEVICE8A iface,
587         LPDIDEVICEOBJECTINSTANCEA pdidoi,
588         DWORD dwObj,
589         DWORD dwHow)
590 {
591     FIXME("(this=%p,%p,%ld,0x%08lx): stub!\n",
592           iface, pdidoi, dwObj, dwHow);
593     
594     return DI_OK;
595 }
596
597 HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(
598         LPDIRECTINPUTDEVICE8W iface,
599         LPDIDEVICEOBJECTINSTANCEW pdidoi,
600         DWORD dwObj,
601         DWORD dwHow)
602 {
603     FIXME("(this=%p,%p,%ld,0x%08lx): stub!\n",
604           iface, pdidoi, dwObj, dwHow);
605     
606     return DI_OK;
607 }
608
609 HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
610         LPDIRECTINPUTDEVICE8A iface,
611         LPDIDEVICEINSTANCEA pdidi)
612 {
613     FIXME("(this=%p,%p): stub!\n",
614           iface, pdidi);
615     
616     return DI_OK;
617 }
618
619 HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo(
620         LPDIRECTINPUTDEVICE8W iface,
621         LPDIDEVICEINSTANCEW pdidi)
622 {
623     FIXME("(this=%p,%p): stub!\n",
624           iface, pdidi);
625     
626     return DI_OK;
627 }
628
629 HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
630         LPDIRECTINPUTDEVICE8A iface,
631         HWND hwndOwner,
632         DWORD dwFlags)
633 {
634     FIXME("(this=%p,%p,0x%08lx): stub!\n",
635           iface, hwndOwner, dwFlags);
636
637     return DI_OK;
638 }
639
640 HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
641         LPDIRECTINPUTDEVICE8A iface,
642         HINSTANCE hinst,
643         DWORD dwVersion,
644         REFGUID rguid)
645 {
646     FIXME("(this=%p,%p,%ld,%s): stub!\n",
647           iface, hinst, dwVersion, debugstr_guid(rguid));
648     return DI_OK;
649 }
650
651 /******************************************************************************
652  *      IDirectInputDevice2A
653  */
654
655 HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
656         LPDIRECTINPUTDEVICE8A iface,
657         REFGUID rguid,
658         LPCDIEFFECT lpeff,
659         LPDIRECTINPUTEFFECT *ppdef,
660         LPUNKNOWN pUnkOuter)
661 {
662     FIXME("(this=%p,%s,%p,%p,%p): stub!\n",
663           iface, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter);
664     return DI_OK;
665 }
666
667 HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
668         LPDIRECTINPUTDEVICE8A iface,
669         LPDIENUMEFFECTSCALLBACKA lpCallback,
670         LPVOID lpvRef,
671         DWORD dwFlags)
672 {
673     FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
674           iface, lpCallback, lpvRef, dwFlags);
675     
676     if (lpCallback)
677         lpCallback(NULL, lpvRef);
678     return DI_OK;
679 }
680
681 HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
682         LPDIRECTINPUTDEVICE8W iface,
683         LPDIENUMEFFECTSCALLBACKW lpCallback,
684         LPVOID lpvRef,
685         DWORD dwFlags)
686 {
687     FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
688           iface, lpCallback, lpvRef, dwFlags);
689     
690     if (lpCallback)
691         lpCallback(NULL, lpvRef);
692     return DI_OK;
693 }
694
695 HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
696         LPDIRECTINPUTDEVICE8A iface,
697         LPDIEFFECTINFOA lpdei,
698         REFGUID rguid)
699 {
700     FIXME("(this=%p,%p,%s): stub!\n",
701           iface, lpdei, debugstr_guid(rguid));
702     return DI_OK;
703 }
704
705 HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
706         LPDIRECTINPUTDEVICE8W iface,
707         LPDIEFFECTINFOW lpdei,
708         REFGUID rguid)
709 {
710     FIXME("(this=%p,%p,%s): stub!\n",
711           iface, lpdei, debugstr_guid(rguid));
712     return DI_OK;
713 }
714
715 HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
716         LPDIRECTINPUTDEVICE8A iface,
717         LPDWORD pdwOut)
718 {
719     FIXME("(this=%p,%p): stub!\n",
720           iface, pdwOut);
721     return DI_OK;
722 }
723
724 HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
725         LPDIRECTINPUTDEVICE8A iface,
726         DWORD dwFlags)
727 {
728     FIXME("(this=%p,0x%08lx): stub!\n",
729           iface, dwFlags);
730     return DI_OK;
731 }
732
733 HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
734         LPDIRECTINPUTDEVICE8A iface,
735         LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
736         LPVOID lpvRef,
737         DWORD dwFlags)
738 {
739     FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
740           iface, lpCallback, lpvRef, dwFlags);
741     if (lpCallback)
742         lpCallback(NULL, lpvRef);
743     return DI_OK;
744 }
745
746 HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
747         LPDIRECTINPUTDEVICE8A iface,
748         LPDIEFFESCAPE lpDIEEsc)
749 {
750     FIXME("(this=%p,%p): stub!\n",
751           iface, lpDIEEsc);
752     return DI_OK;
753 }
754
755 HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
756         LPDIRECTINPUTDEVICE8A iface)
757 {
758     /* Because wine devices do not need to be polled, just return DI_NOEFFECT */
759     return DI_NOEFFECT;
760 }
761
762 HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
763         LPDIRECTINPUTDEVICE8A iface,
764         DWORD cbObjectData,
765         LPCDIDEVICEOBJECTDATA rgdod,
766         LPDWORD pdwInOut,
767         DWORD dwFlags)
768 {
769     FIXME("(this=%p,0x%08lx,%p,%p,0x%08lx): stub!\n",
770           iface, cbObjectData, rgdod, pdwInOut, dwFlags);
771     
772     return DI_OK;
773 }
774
775 HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface,
776                                                           LPCSTR lpszFileName,
777                                                           LPDIENUMEFFECTSINFILECALLBACK pec,
778                                                           LPVOID pvRef,
779                                                           DWORD dwFlags)
780 {
781     FIXME("(%p)->(%s,%p,%p,%08lx): stub !\n", iface, lpszFileName, pec, pvRef, dwFlags);
782     
783     return DI_OK;
784 }
785
786 HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
787                                                           LPCWSTR lpszFileName,
788                                                           LPDIENUMEFFECTSINFILECALLBACK pec,
789                                                           LPVOID pvRef,
790                                                           DWORD dwFlags)
791 {
792     FIXME("(%p)->(%s,%p,%p,%08lx): stub !\n", iface, debugstr_w(lpszFileName), pec, pvRef, dwFlags);
793     
794     return DI_OK;
795 }
796
797 HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
798                                                           LPCSTR lpszFileName,
799                                                           DWORD dwEntries,
800                                                           LPDIFILEEFFECT rgDiFileEft,
801                                                           DWORD dwFlags)
802 {
803     FIXME("(%p)->(%s,%08lx,%p,%08lx): stub !\n", iface, lpszFileName, dwEntries, rgDiFileEft, dwFlags);
804     
805     return DI_OK;
806 }
807
808 HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
809                                                           LPCWSTR lpszFileName,
810                                                           DWORD dwEntries,
811                                                           LPDIFILEEFFECT rgDiFileEft,
812                                                           DWORD dwFlags)
813 {
814     FIXME("(%p)->(%s,%08lx,%p,%08lx): stub !\n", iface, debugstr_w(lpszFileName), dwEntries, rgDiFileEft, dwFlags);
815     
816     return DI_OK;
817 }
818
819 HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
820                                                        LPDIACTIONFORMATA lpdiaf,
821                                                        LPCSTR lpszUserName,
822                                                        DWORD dwFlags)
823 {
824     FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
825     
826     return DI_OK;
827 }
828
829 HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
830                                                        LPDIACTIONFORMATW lpdiaf,
831                                                        LPCWSTR lpszUserName,
832                                                        DWORD dwFlags)
833 {
834     FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
835   
836     return DI_OK;
837 }
838
839 HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
840                                                      LPDIACTIONFORMATA lpdiaf,
841                                                      LPCSTR lpszUserName,
842                                                      DWORD dwFlags)
843 {
844     FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
845     
846     return DI_OK;
847 }
848
849 HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
850                                                      LPDIACTIONFORMATW lpdiaf,
851                                                      LPCWSTR lpszUserName,
852                                                      DWORD dwFlags)
853 {
854     FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
855     
856     return DI_OK;
857 }
858
859 HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
860                                                      LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader)
861 {
862     FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
863     
864     return DI_OK;
865 }
866
867 HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
868                                                      LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader)
869 {
870     FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
871     
872     return DI_OK;
873 }