3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998,1999 Lionel Ulmer
8 /* This file contains all the Device specific functions that can be used as stubs
9 by real device implementations.
11 It also contains all the helper functions.
16 #include "debugtools.h"
21 #include "device_private.h"
23 DEFAULT_DEBUG_CHANNEL(dinput);
25 /******************************************************************************
26 * Various debugging tools
28 void _dump_cooperativelevel_DI(DWORD dwFlags) {
34 #define FE(x) { x, #x},
38 FE(DISCL_NONEXCLUSIVE)
41 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
42 if (flags[i].mask & dwFlags)
43 DPRINTF("%s ",flags[i].name);
47 void _dump_EnumObjects_flags(DWORD dwFlags) {
53 #define FE(x) { x, #x},
60 FE(DIDFT_FFEFFECTTRIGGER)
61 FE(DIDFT_NOCOLLECTION)
70 if (dwFlags == DIDFT_ALL) {
74 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
75 if (flags[i].mask & dwFlags)
76 DPRINTF("%s ",flags[i].name);
77 if (dwFlags & DIDFT_INSTANCEMASK)
78 DPRINTF("Instance(%04lx) ", dwFlags >> 8);
81 void _dump_DIPROPHEADER(DIPROPHEADER *diph) {
82 DPRINTF(" - dwObj = 0x%08lx\n", diph->dwObj);
83 DPRINTF(" - dwHow = %s\n",
84 ((diph->dwHow == DIPH_DEVICE) ? "DIPH_DEVICE" :
85 ((diph->dwHow == DIPH_BYOFFSET) ? "DIPH_BYOFFSET" :
86 ((diph->dwHow == DIPH_BYID)) ? "DIPH_BYID" : "unknown")));
89 void _dump_OBJECTINSTANCEA(DIDEVICEOBJECTINSTANCEA *ddoi) {
90 if (TRACE_ON(dinput)) {
91 DPRINTF(" - enumerating : 0x%08lx - %2ld - 0x%08lx - %s\n",
92 ddoi->guidType.Data1, ddoi->dwOfs, ddoi->dwType, ddoi->tszName);
96 /* Conversion between internal data buffer and external data buffer */
97 void fill_DataFormat(void *out, void *in, DataFormat *df) {
99 char *in_c = (char *) in;
100 char *out_c = (char *) out;
102 if (df->dt == NULL) {
103 /* This means that the app uses Wine's internal data format */
104 memcpy(out, in, df->internal_format_size);
106 for (i = 0; i < df->size; i++) {
107 if (df->dt[i].offset_in >= 0) {
108 switch (df->dt[i].size) {
110 TRACE("Copying (c) to %d from %d (value %d)\n",
111 df->dt[i].offset_out, df->dt[i].offset_in, *((char *) (in_c + df->dt[i].offset_in)));
112 *((char *) (out_c + df->dt[i].offset_out)) = *((char *) (in_c + df->dt[i].offset_in));
116 TRACE("Copying (s) to %d from %d (value %d)\n",
117 df->dt[i].offset_out, df->dt[i].offset_in, *((short *) (in_c + df->dt[i].offset_in)));
118 *((short *) (out_c + df->dt[i].offset_out)) = *((short *) (in_c + df->dt[i].offset_in));
122 TRACE("Copying (i) to %d from %d (value %d)\n",
123 df->dt[i].offset_out, df->dt[i].offset_in, *((int *) (in_c + df->dt[i].offset_in)));
124 *((int *) (out_c + df->dt[i].offset_out)) = *((int *) (in_c + df->dt[i].offset_in));
128 memcpy((out_c + df->dt[i].offset_out), (in_c + df->dt[i].offset_in), df->dt[i].size);
131 switch (df->dt[i].size) {
133 TRACE("Copying (c) to %d default value %d\n",
134 df->dt[i].offset_out, df->dt[i].value);
135 *((char *) (out_c + df->dt[i].offset_out)) = (char) df->dt[i].value;
139 TRACE("Copying (s) to %d default value %d\n",
140 df->dt[i].offset_out, df->dt[i].value);
141 *((short *) (out_c + df->dt[i].offset_out)) = (short) df->dt[i].value;
145 TRACE("Copying (i) to %d default value %d\n",
146 df->dt[i].offset_out, df->dt[i].value);
147 *((int *) (out_c + df->dt[i].offset_out)) = (int) df->dt[i].value;
151 memset((out_c + df->dt[i].offset_out), df->dt[i].size, 0);
158 DataFormat *create_DataFormat(DIDATAFORMAT *wine_format, LPCDIDATAFORMAT asked_format, int *offset) {
166 ret = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
168 done = (int *) HeapAlloc(GetProcessHeap(), 0, sizeof(int) * asked_format->dwNumObjs);
169 memset(done, 0, sizeof(int) * asked_format->dwNumObjs);
171 dt = (DataTransform *) HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform));
173 TRACE("Creating DataTransorm : \n");
175 for (i = 0; i < wine_format->dwNumObjs; i++) {
178 for (j = 0; j < asked_format->dwNumObjs; j++) {
182 if (((asked_format->rgodf[j].pguid == NULL) || (IsEqualGUID(wine_format->rgodf[i].pguid, asked_format->rgodf[j].pguid)))
184 (wine_format->rgodf[i].dwType & asked_format->rgodf[j].dwType)) {
188 TRACE("Matching : \n");
189 TRACE(" - Asked (%d) : %s - Ofs = %3ld - (Type = 0x%02x | Instance = %04x)\n",
190 j, debugstr_guid(asked_format->rgodf[j].pguid),
191 asked_format->rgodf[j].dwOfs,
192 DIDFT_GETTYPE(asked_format->rgodf[j].dwType), DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType));
194 TRACE(" - Wine (%d) : %s - Ofs = %3ld - (Type = 0x%02x | Instance = %04x)\n",
195 j, debugstr_guid(wine_format->rgodf[i].pguid),
196 wine_format->rgodf[i].dwOfs,
197 DIDFT_GETTYPE(wine_format->rgodf[i].dwType), DIDFT_GETINSTANCE(wine_format->rgodf[i].dwType));
199 if (wine_format->rgodf[i].dwType & DIDFT_BUTTON)
200 dt[index].size = sizeof(BYTE);
202 dt[index].size = sizeof(DWORD);
203 dt[index].offset_in = wine_format ->rgodf[i].dwOfs;
204 dt[index].offset_out = asked_format->rgodf[j].dwOfs;
208 if (wine_format->rgodf[i].dwOfs != asked_format->rgodf[j].dwOfs)
211 offset[i] = asked_format->rgodf[j].dwOfs;
216 if (j == asked_format->dwNumObjs)
220 TRACE("Setting to default value :\n");
221 for (j = 0; j < asked_format->dwNumObjs; j++) {
223 TRACE(" - Asked (%d) : %s - Ofs = %3ld - (Type = 0x%02x | Instance = %04x)\n",
224 j, debugstr_guid(asked_format->rgodf[j].pguid),
225 asked_format->rgodf[j].dwOfs,
226 DIDFT_GETTYPE(asked_format->rgodf[j].dwType), DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType));
229 if (asked_format->rgodf[j].dwType & DIDFT_BUTTON)
230 dt[index].size = sizeof(BYTE);
232 dt[index].size = sizeof(DWORD);
233 dt[index].offset_in = -1;
234 dt[index].offset_out = asked_format->rgodf[j].dwOfs;
242 ret->internal_format_size = wine_format->dwDataSize;
246 HeapFree(GetProcessHeap(), 0, dt);
251 HeapFree(GetProcessHeap(), 0, done);
256 /******************************************************************************
257 * IDirectInputDeviceA
260 HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
261 LPDIRECTINPUTDEVICE2A iface,LPCDIDATAFORMAT df
264 ICOM_THIS(IDirectInputDevice2AImpl,iface);
266 TRACE("(this=%p,%p)\n",This,df);
268 TRACE("df.dwSize=%ld\n",df->dwSize);
269 TRACE("(df.dwObjsize=%ld)\n",df->dwObjSize);
270 TRACE("(df.dwFlags=0x%08lx)\n",df->dwFlags);
271 TRACE("(df.dwDataSize=%ld)\n",df->dwDataSize);
272 TRACE("(df.dwNumObjs=%ld)\n",df->dwNumObjs);
274 for (i=0;i<df->dwNumObjs;i++) {
275 TRACE("df.rgodf[%d].guid %s\n",i,debugstr_guid(df->rgodf[i].pguid));
276 TRACE("df.rgodf[%d].dwOfs %ld\n",i,df->rgodf[i].dwOfs);
277 TRACE("dwType 0x%02x,dwInstance %d\n",DIDFT_GETTYPE(df->rgodf[i].dwType),DIDFT_GETINSTANCE(df->rgodf[i].dwType));
278 TRACE("df.rgodf[%d].dwFlags 0x%08lx\n",i,df->rgodf[i].dwFlags);
283 HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
284 LPDIRECTINPUTDEVICE2A iface,HWND hwnd,DWORD dwflags
286 ICOM_THIS(IDirectInputDevice2AImpl,iface);
287 TRACE("(this=%p,0x%08lx,0x%08lx)\n",This,(DWORD)hwnd,dwflags);
288 if (TRACE_ON(dinput))
289 _dump_cooperativelevel_DI(dwflags);
293 HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
294 LPDIRECTINPUTDEVICE2A iface,HANDLE hnd
296 ICOM_THIS(IDirectInputDevice2AImpl,iface);
297 FIXME("(this=%p,0x%08lx): stub\n",This,(DWORD)hnd);
301 ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE2A iface)
303 ICOM_THIS(IDirectInputDevice2AImpl,iface);
307 HeapFree(GetProcessHeap(),0,This);
311 HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(
312 LPDIRECTINPUTDEVICE2A iface,REFIID riid,LPVOID *ppobj
315 ICOM_THIS(IDirectInputDevice2AImpl,iface);
317 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
318 if (IsEqualGUID(&IID_IUnknown,riid)) {
319 IDirectInputDevice2_AddRef(iface);
323 if (IsEqualGUID(&IID_IDirectInputDeviceA,riid)) {
324 IDirectInputDevice2_AddRef(iface);
328 if (IsEqualGUID(&IID_IDirectInputDevice2A,riid)) {
329 IDirectInputDevice2_AddRef(iface);
333 TRACE("Unsupported interface !\n");
337 ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
338 LPDIRECTINPUTDEVICE2A iface)
340 ICOM_THIS(IDirectInputDevice2AImpl,iface);
344 HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
345 LPDIRECTINPUTDEVICE2A iface,
346 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
350 FIXME("(this=%p,%p,%p,%08lx): stub!\n", iface, lpCallback, lpvRef, dwFlags);
351 if (TRACE_ON(dinput)) {
352 DPRINTF(" - flags = ");
353 _dump_EnumObjects_flags(dwFlags);
360 HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
361 LPDIRECTINPUTDEVICE2A iface,
363 LPDIPROPHEADER pdiph)
365 FIXME("(this=%p,%s,%p): stub!\n",
366 iface, debugstr_guid(rguid), pdiph);
368 if (TRACE_ON(dinput))
369 _dump_DIPROPHEADER(pdiph);
374 HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
375 LPDIRECTINPUTDEVICE2A iface,
376 LPDIDEVICEOBJECTINSTANCEA pdidoi,
380 FIXME("(this=%p,%p,%ld,0x%08lx): stub!\n",
381 iface, pdidoi, dwObj, dwHow);
386 HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
387 LPDIRECTINPUTDEVICE2A iface,
388 LPDIDEVICEINSTANCEA pdidi)
390 FIXME("(this=%p,%p): stub!\n",
396 HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
397 LPDIRECTINPUTDEVICE2A iface,
401 FIXME("(this=%p,0x%08x,0x%08lx): stub!\n",
402 iface, hwndOwner, dwFlags);
407 HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
408 LPDIRECTINPUTDEVICE2A iface,
413 FIXME("(this=%p,%d,%ld,%s): stub!\n",
414 iface, hinst, dwVersion, debugstr_guid(rguid));
418 /******************************************************************************
419 * IDirectInputDevice2A
422 HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
423 LPDIRECTINPUTDEVICE2A iface,
426 LPDIRECTINPUTEFFECT *ppdef,
429 FIXME("(this=%p,%s,%p,%p,%p): stub!\n",
430 iface, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter);
434 HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
435 LPDIRECTINPUTDEVICE2A iface,
436 LPDIENUMEFFECTSCALLBACKA lpCallback,
440 FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
441 iface, lpCallback, lpvRef, dwFlags);
444 lpCallback(NULL, lpvRef);
448 HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
449 LPDIRECTINPUTDEVICE2A iface,
450 LPDIEFFECTINFOA lpdei,
453 FIXME("(this=%p,%p,%s): stub!\n",
454 iface, lpdei, debugstr_guid(rguid));
458 HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
459 LPDIRECTINPUTDEVICE2A iface,
462 FIXME("(this=%p,%p): stub!\n",
467 HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
468 LPDIRECTINPUTDEVICE2A iface,
471 FIXME("(this=%p,0x%08lx): stub!\n",
476 HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
477 LPDIRECTINPUTDEVICE2A iface,
478 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
482 FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
483 iface, lpCallback, lpvRef, dwFlags);
485 lpCallback(NULL, lpvRef);
489 HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
490 LPDIRECTINPUTDEVICE2A iface,
491 LPDIEFFESCAPE lpDIEEsc)
493 FIXME("(this=%p,%p): stub!\n",
498 HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
499 LPDIRECTINPUTDEVICE2A iface)
501 FIXME("(this=%p): stub!\n",
506 HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
507 LPDIRECTINPUTDEVICE2A iface,
509 LPDIDEVICEOBJECTDATA rgdod,
513 FIXME("(this=%p,0x%08lx,%p,%p,0x%08lx): stub!\n",
514 iface, cbObjectData, rgdod, pdwInOut, dwFlags);
519 HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE7A iface,
521 LPDIENUMEFFECTSINFILECALLBACK pec,
525 FIXME("(%p)->(%s,%p,%p,%08lx): stub !\n", iface, lpszFileName, pec, pvRef, dwFlags);
530 HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE7A iface,
533 LPDIFILEEFFECT rgDiFileEft,
536 FIXME("(%p)->(%s,%08lx,%p,%08lx): stub !\n", iface, lpszFileName, dwEntries, rgDiFileEft, dwFlags);