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.
15 #include "debugtools.h"
20 #include "device_private.h"
22 DEFAULT_DEBUG_CHANNEL(dinput);
24 /******************************************************************************
25 * Various debugging tools
27 void _dump_cooperativelevel_DI(DWORD dwFlags) {
33 #define FE(x) { x, #x},
37 FE(DISCL_NONEXCLUSIVE)
40 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
41 if (flags[i].mask & dwFlags)
42 DPRINTF("%s ",flags[i].name);
46 void _dump_EnumObjects_flags(DWORD dwFlags) {
52 #define FE(x) { x, #x},
59 FE(DIDFT_FFEFFECTTRIGGER)
60 FE(DIDFT_NOCOLLECTION)
69 if (dwFlags == DIDFT_ALL) {
73 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
74 if (flags[i].mask & dwFlags)
75 DPRINTF("%s ",flags[i].name);
76 if (dwFlags & DIDFT_INSTANCEMASK)
77 DPRINTF("Instance(%04lx) ", dwFlags >> 8);
80 void _dump_DIPROPHEADER(DIPROPHEADER *diph) {
81 DPRINTF(" - dwObj = 0x%08lx\n", diph->dwObj);
82 DPRINTF(" - dwHow = %s\n",
83 ((diph->dwHow == DIPH_DEVICE) ? "DIPH_DEVICE" :
84 ((diph->dwHow == DIPH_BYOFFSET) ? "DIPH_BYOFFSET" :
85 ((diph->dwHow == DIPH_BYID)) ? "DIPH_BYID" : "unknown")));
88 void _dump_OBJECTINSTANCEA(DIDEVICEOBJECTINSTANCEA *ddoi) {
89 if (TRACE_ON(dinput)) {
90 DPRINTF(" - enumerating : 0x%08lx - %2ld - 0x%08lx - %s\n",
91 ddoi->guidType.Data1, ddoi->dwOfs, ddoi->dwType, ddoi->tszName);
95 /* Conversion between internal data buffer and external data buffer */
96 void fill_DataFormat(void *out, void *in, DataFormat *df) {
98 char *in_c = (char *) in;
99 char *out_c = (char *) out;
101 if (df->dt == NULL) {
102 /* This means that the app uses Wine's internal data format */
103 memcpy(out, in, df->internal_format_size);
105 for (i = 0; i < df->size; i++) {
106 if (df->dt[i].offset_in >= 0) {
107 switch (df->dt[i].size) {
109 TRACE("Copying (c) to %d from %d (value %d)\n",
110 df->dt[i].offset_out, df->dt[i].offset_in, *((char *) (in_c + df->dt[i].offset_in)));
111 *((char *) (out_c + df->dt[i].offset_out)) = *((char *) (in_c + df->dt[i].offset_in));
115 TRACE("Copying (s) to %d from %d (value %d)\n",
116 df->dt[i].offset_out, df->dt[i].offset_in, *((short *) (in_c + df->dt[i].offset_in)));
117 *((short *) (out_c + df->dt[i].offset_out)) = *((short *) (in_c + df->dt[i].offset_in));
121 TRACE("Copying (i) to %d from %d (value %d)\n",
122 df->dt[i].offset_out, df->dt[i].offset_in, *((int *) (in_c + df->dt[i].offset_in)));
123 *((int *) (out_c + df->dt[i].offset_out)) = *((int *) (in_c + df->dt[i].offset_in));
127 memcpy((out_c + df->dt[i].offset_out), (in_c + df->dt[i].offset_in), df->dt[i].size);
130 switch (df->dt[i].size) {
132 TRACE("Copying (c) to %d default value %d\n",
133 df->dt[i].offset_out, df->dt[i].value);
134 *((char *) (out_c + df->dt[i].offset_out)) = (char) df->dt[i].value;
138 TRACE("Copying (s) to %d default value %d\n",
139 df->dt[i].offset_out, df->dt[i].value);
140 *((short *) (out_c + df->dt[i].offset_out)) = (short) df->dt[i].value;
144 TRACE("Copying (i) to %d default value %d\n",
145 df->dt[i].offset_out, df->dt[i].value);
146 *((int *) (out_c + df->dt[i].offset_out)) = (int) df->dt[i].value;
150 memset((out_c + df->dt[i].offset_out), df->dt[i].size, 0);
157 DataFormat *create_DataFormat(DIDATAFORMAT *wine_format, LPCDIDATAFORMAT asked_format, int *offset) {
165 ret = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
167 done = (int *) HeapAlloc(GetProcessHeap(), 0, sizeof(int) * asked_format->dwNumObjs);
168 memset(done, 0, sizeof(int) * asked_format->dwNumObjs);
170 dt = (DataTransform *) HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform));
172 TRACE("Creating DataTransorm : \n");
174 for (i = 0; i < wine_format->dwNumObjs; i++) {
177 for (j = 0; j < asked_format->dwNumObjs; j++) {
181 if (((asked_format->rgodf[j].pguid == NULL) || (IsEqualGUID(wine_format->rgodf[i].pguid, asked_format->rgodf[j].pguid)))
183 (wine_format->rgodf[i].dwType & asked_format->rgodf[j].dwType)) {
187 TRACE("Matching : \n");
188 TRACE(" - Asked (%d) : %s - Ofs = %3ld - (Type = 0x%02x | Instance = %04x)\n",
189 j, debugstr_guid(asked_format->rgodf[j].pguid),
190 asked_format->rgodf[j].dwOfs,
191 DIDFT_GETTYPE(asked_format->rgodf[j].dwType), DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType));
193 TRACE(" - Wine (%d) : %s - Ofs = %3ld - (Type = 0x%02x | Instance = %04x)\n",
194 j, debugstr_guid(wine_format->rgodf[i].pguid),
195 wine_format->rgodf[i].dwOfs,
196 DIDFT_GETTYPE(wine_format->rgodf[i].dwType), DIDFT_GETINSTANCE(wine_format->rgodf[i].dwType));
198 if (wine_format->rgodf[i].dwType & DIDFT_BUTTON)
199 dt[index].size = sizeof(BYTE);
201 dt[index].size = sizeof(DWORD);
202 dt[index].offset_in = wine_format ->rgodf[i].dwOfs;
203 dt[index].offset_out = asked_format->rgodf[j].dwOfs;
207 if (wine_format->rgodf[i].dwOfs != asked_format->rgodf[j].dwOfs)
210 offset[i] = asked_format->rgodf[j].dwOfs;
215 if (j == asked_format->dwNumObjs)
219 TRACE("Setting to default value :\n");
220 for (j = 0; j < asked_format->dwNumObjs; j++) {
222 TRACE(" - Asked (%d) : %s - Ofs = %3ld - (Type = 0x%02x | Instance = %04x)\n",
223 j, debugstr_guid(asked_format->rgodf[j].pguid),
224 asked_format->rgodf[j].dwOfs,
225 DIDFT_GETTYPE(asked_format->rgodf[j].dwType), DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType));
228 if (asked_format->rgodf[j].dwType & DIDFT_BUTTON)
229 dt[index].size = sizeof(BYTE);
231 dt[index].size = sizeof(DWORD);
232 dt[index].offset_in = -1;
233 dt[index].offset_out = asked_format->rgodf[j].dwOfs;
241 ret->internal_format_size = wine_format->dwDataSize;
245 HeapFree(GetProcessHeap(), 0, dt);
250 HeapFree(GetProcessHeap(), 0, done);
255 /******************************************************************************
256 * IDirectInputDeviceA
259 HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
260 LPDIRECTINPUTDEVICE2A iface,LPCDIDATAFORMAT df
263 ICOM_THIS(IDirectInputDevice2AImpl,iface);
265 TRACE("(this=%p,%p)\n",This,df);
267 TRACE("df.dwSize=%ld\n",df->dwSize);
268 TRACE("(df.dwObjsize=%ld)\n",df->dwObjSize);
269 TRACE("(df.dwFlags=0x%08lx)\n",df->dwFlags);
270 TRACE("(df.dwDataSize=%ld)\n",df->dwDataSize);
271 TRACE("(df.dwNumObjs=%ld)\n",df->dwNumObjs);
273 for (i=0;i<df->dwNumObjs;i++) {
274 TRACE("df.rgodf[%d].guid %s\n",i,debugstr_guid(df->rgodf[i].pguid));
275 TRACE("df.rgodf[%d].dwOfs %ld\n",i,df->rgodf[i].dwOfs);
276 TRACE("dwType 0x%02x,dwInstance %d\n",DIDFT_GETTYPE(df->rgodf[i].dwType),DIDFT_GETINSTANCE(df->rgodf[i].dwType));
277 TRACE("df.rgodf[%d].dwFlags 0x%08lx\n",i,df->rgodf[i].dwFlags);
282 HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
283 LPDIRECTINPUTDEVICE2A iface,HWND hwnd,DWORD dwflags
285 ICOM_THIS(IDirectInputDevice2AImpl,iface);
286 TRACE("(this=%p,0x%08lx,0x%08lx)\n",This,(DWORD)hwnd,dwflags);
287 if (TRACE_ON(dinput))
288 _dump_cooperativelevel_DI(dwflags);
292 HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
293 LPDIRECTINPUTDEVICE2A iface,HANDLE hnd
295 ICOM_THIS(IDirectInputDevice2AImpl,iface);
296 FIXME("(this=%p,0x%08lx): stub\n",This,(DWORD)hnd);
300 ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE2A iface)
302 ICOM_THIS(IDirectInputDevice2AImpl,iface);
306 HeapFree(GetProcessHeap(),0,This);
310 HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(
311 LPDIRECTINPUTDEVICE2A iface,REFIID riid,LPVOID *ppobj
314 ICOM_THIS(IDirectInputDevice2AImpl,iface);
316 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
317 if (IsEqualGUID(&IID_IUnknown,riid)) {
318 IDirectInputDevice2_AddRef(iface);
322 if (IsEqualGUID(&IID_IDirectInputDeviceA,riid)) {
323 IDirectInputDevice2_AddRef(iface);
327 if (IsEqualGUID(&IID_IDirectInputDevice2A,riid)) {
328 IDirectInputDevice2_AddRef(iface);
332 TRACE("Unsupported interface !\n");
336 ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
337 LPDIRECTINPUTDEVICE2A iface)
339 ICOM_THIS(IDirectInputDevice2AImpl,iface);
343 HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
344 LPDIRECTINPUTDEVICE2A iface,
345 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
349 FIXME("(this=%p,%p,%p,%08lx): stub!\n", iface, lpCallback, lpvRef, dwFlags);
350 if (TRACE_ON(dinput)) {
351 DPRINTF(" - flags = ");
352 _dump_EnumObjects_flags(dwFlags);
359 HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
360 LPDIRECTINPUTDEVICE2A iface,
362 LPDIPROPHEADER pdiph)
364 FIXME("(this=%p,%s,%p): stub!\n",
365 iface, debugstr_guid(rguid), pdiph);
367 if (TRACE_ON(dinput))
368 _dump_DIPROPHEADER(pdiph);
373 HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
374 LPDIRECTINPUTDEVICE2A iface,
375 LPDIDEVICEOBJECTINSTANCEA pdidoi,
379 FIXME("(this=%p,%p,%ld,0x%08lx): stub!\n",
380 iface, pdidoi, dwObj, dwHow);
385 HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
386 LPDIRECTINPUTDEVICE2A iface,
387 LPDIDEVICEINSTANCEA pdidi)
389 FIXME("(this=%p,%p): stub!\n",
395 HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
396 LPDIRECTINPUTDEVICE2A iface,
400 FIXME("(this=%p,0x%08x,0x%08lx): stub!\n",
401 iface, hwndOwner, dwFlags);
406 HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
407 LPDIRECTINPUTDEVICE2A iface,
412 FIXME("(this=%p,%d,%ld,%s): stub!\n",
413 iface, hinst, dwVersion, debugstr_guid(rguid));
417 /******************************************************************************
418 * IDirectInputDevice2A
421 HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
422 LPDIRECTINPUTDEVICE2A iface,
425 LPDIRECTINPUTEFFECT *ppdef,
428 FIXME("(this=%p,%s,%p,%p,%p): stub!\n",
429 iface, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter);
433 HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
434 LPDIRECTINPUTDEVICE2A iface,
435 LPDIENUMEFFECTSCALLBACKA lpCallback,
439 FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
440 iface, lpCallback, lpvRef, dwFlags);
443 lpCallback(NULL, lpvRef);
447 HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
448 LPDIRECTINPUTDEVICE2A iface,
449 LPDIEFFECTINFOA lpdei,
452 FIXME("(this=%p,%p,%s): stub!\n",
453 iface, lpdei, debugstr_guid(rguid));
457 HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
458 LPDIRECTINPUTDEVICE2A iface,
461 FIXME("(this=%p,%p): stub!\n",
466 HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
467 LPDIRECTINPUTDEVICE2A iface,
470 FIXME("(this=%p,0x%08lx): stub!\n",
475 HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
476 LPDIRECTINPUTDEVICE2A iface,
477 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
481 FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
482 iface, lpCallback, lpvRef, dwFlags);
484 lpCallback(NULL, lpvRef);
488 HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
489 LPDIRECTINPUTDEVICE2A iface,
490 LPDIEFFESCAPE lpDIEEsc)
492 FIXME("(this=%p,%p): stub!\n",
497 HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
498 LPDIRECTINPUTDEVICE2A iface)
500 FIXME("(this=%p): stub!\n",
505 HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
506 LPDIRECTINPUTDEVICE2A iface,
508 LPDIDEVICEOBJECTDATA rgdod,
512 FIXME("(this=%p,0x%08lx,%p,%p,0x%08lx): stub!\n",
513 iface, cbObjectData, rgdod, pdwInOut, dwFlags);
518 HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE7A iface,
520 LPDIENUMEFFECTSINFILECALLBACK pec,
524 FIXME("(%p)->(%s,%p,%p,%08lx): stub !\n", iface, lpszFileName, pec, pvRef, dwFlags);
529 HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE7A iface,
532 LPDIFILEEFFECT rgDiFileEft,
535 FIXME("(%p)->(%s,%08lx,%p,%08lx): stub !\n", iface, lpszFileName, dwEntries, rgDiFileEft, dwFlags);