3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998,1999 Lionel Ulmer
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.
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.
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
22 /* This file contains all the Device specific functions that can be used as stubs
23 by real device implementations.
25 It also contains all the helper functions.
30 #include "wine/debug.h"
35 #include "device_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dinput
);
39 /******************************************************************************
40 * Various debugging tools
42 void _dump_cooperativelevel_DI(DWORD dwFlags
) {
48 #define FE(x) { x, #x},
52 FE(DISCL_NONEXCLUSIVE
)
55 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
56 if (flags
[i
].mask
& dwFlags
)
57 DPRINTF("%s ",flags
[i
].name
);
61 void _dump_EnumObjects_flags(DWORD dwFlags
) {
67 #define FE(x) { x, #x},
74 FE(DIDFT_FFEFFECTTRIGGER
)
75 FE(DIDFT_NOCOLLECTION
)
84 if (dwFlags
== DIDFT_ALL
) {
88 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
89 if (flags
[i
].mask
& dwFlags
)
90 DPRINTF("%s ",flags
[i
].name
);
91 if (dwFlags
& DIDFT_INSTANCEMASK
)
92 DPRINTF("Instance(%04lx) ", dwFlags
>> 8);
95 void _dump_DIPROPHEADER(DIPROPHEADER
*diph
) {
96 DPRINTF(" - dwObj = 0x%08lx\n", diph
->dwObj
);
97 DPRINTF(" - dwHow = %s\n",
98 ((diph
->dwHow
== DIPH_DEVICE
) ? "DIPH_DEVICE" :
99 ((diph
->dwHow
== DIPH_BYOFFSET
) ? "DIPH_BYOFFSET" :
100 ((diph
->dwHow
== DIPH_BYID
)) ? "DIPH_BYID" : "unknown")));
103 void _dump_OBJECTINSTANCEA(DIDEVICEOBJECTINSTANCEA
*ddoi
) {
104 if (TRACE_ON(dinput
)) {
105 DPRINTF(" - enumerating : %s - %2ld - 0x%08lx - %s\n",
106 debugstr_guid(&ddoi
->guidType
), ddoi
->dwOfs
, ddoi
->dwType
, ddoi
->tszName
);
110 /* Conversion between internal data buffer and external data buffer */
111 void fill_DataFormat(void *out
, void *in
, DataFormat
*df
) {
113 char *in_c
= (char *) in
;
114 char *out_c
= (char *) out
;
116 if (df
->dt
== NULL
) {
117 /* This means that the app uses Wine's internal data format */
118 memcpy(out
, in
, df
->internal_format_size
);
120 for (i
= 0; i
< df
->size
; i
++) {
121 if (df
->dt
[i
].offset_in
>= 0) {
122 switch (df
->dt
[i
].size
) {
124 TRACE("Copying (c) to %d from %d (value %d)\n",
125 df
->dt
[i
].offset_out
, df
->dt
[i
].offset_in
, *((char *) (in_c
+ df
->dt
[i
].offset_in
)));
126 *((char *) (out_c
+ df
->dt
[i
].offset_out
)) = *((char *) (in_c
+ df
->dt
[i
].offset_in
));
130 TRACE("Copying (s) to %d from %d (value %d)\n",
131 df
->dt
[i
].offset_out
, df
->dt
[i
].offset_in
, *((short *) (in_c
+ df
->dt
[i
].offset_in
)));
132 *((short *) (out_c
+ df
->dt
[i
].offset_out
)) = *((short *) (in_c
+ df
->dt
[i
].offset_in
));
136 TRACE("Copying (i) to %d from %d (value %d)\n",
137 df
->dt
[i
].offset_out
, df
->dt
[i
].offset_in
, *((int *) (in_c
+ df
->dt
[i
].offset_in
)));
138 *((int *) (out_c
+ df
->dt
[i
].offset_out
)) = *((int *) (in_c
+ df
->dt
[i
].offset_in
));
142 memcpy((out_c
+ df
->dt
[i
].offset_out
), (in_c
+ df
->dt
[i
].offset_in
), df
->dt
[i
].size
);
145 switch (df
->dt
[i
].size
) {
147 TRACE("Copying (c) to %d default value %d\n",
148 df
->dt
[i
].offset_out
, df
->dt
[i
].value
);
149 *((char *) (out_c
+ df
->dt
[i
].offset_out
)) = (char) df
->dt
[i
].value
;
153 TRACE("Copying (s) to %d default value %d\n",
154 df
->dt
[i
].offset_out
, df
->dt
[i
].value
);
155 *((short *) (out_c
+ df
->dt
[i
].offset_out
)) = (short) df
->dt
[i
].value
;
159 TRACE("Copying (i) to %d default value %d\n",
160 df
->dt
[i
].offset_out
, df
->dt
[i
].value
);
161 *((int *) (out_c
+ df
->dt
[i
].offset_out
)) = (int) df
->dt
[i
].value
;
165 memset((out_c
+ df
->dt
[i
].offset_out
), df
->dt
[i
].size
, 0);
172 DataFormat
*create_DataFormat(DIDATAFORMAT
*wine_format
, LPCDIDATAFORMAT asked_format
, int *offset
) {
180 ret
= (DataFormat
*) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat
));
182 done
= (int *) HeapAlloc(GetProcessHeap(), 0, sizeof(int) * asked_format
->dwNumObjs
);
183 memset(done
, 0, sizeof(int) * asked_format
->dwNumObjs
);
185 dt
= (DataTransform
*) HeapAlloc(GetProcessHeap(), 0, asked_format
->dwNumObjs
* sizeof(DataTransform
));
187 TRACE("Creating DataTransform : \n");
189 for (i
= 0; i
< wine_format
->dwNumObjs
; i
++) {
192 for (j
= 0; j
< asked_format
->dwNumObjs
; j
++) {
196 if (((asked_format
->rgodf
[j
].pguid
== NULL
) || (IsEqualGUID(wine_format
->rgodf
[i
].pguid
, asked_format
->rgodf
[j
].pguid
)))
198 (wine_format
->rgodf
[i
].dwType
& asked_format
->rgodf
[j
].dwType
)) {
202 TRACE("Matching : \n");
203 TRACE(" - Asked (%d) : %s - Ofs = %3ld - (Type = 0x%02x | Instance = %04x)\n",
204 j
, debugstr_guid(asked_format
->rgodf
[j
].pguid
),
205 asked_format
->rgodf
[j
].dwOfs
,
206 DIDFT_GETTYPE(asked_format
->rgodf
[j
].dwType
), DIDFT_GETINSTANCE(asked_format
->rgodf
[j
].dwType
));
208 TRACE(" - Wine (%d) : %s - Ofs = %3ld - (Type = 0x%02x | Instance = %04x)\n",
209 j
, debugstr_guid(wine_format
->rgodf
[i
].pguid
),
210 wine_format
->rgodf
[i
].dwOfs
,
211 DIDFT_GETTYPE(wine_format
->rgodf
[i
].dwType
), DIDFT_GETINSTANCE(wine_format
->rgodf
[i
].dwType
));
213 if (wine_format
->rgodf
[i
].dwType
& DIDFT_BUTTON
)
214 dt
[index
].size
= sizeof(BYTE
);
216 dt
[index
].size
= sizeof(DWORD
);
217 dt
[index
].offset_in
= wine_format
->rgodf
[i
].dwOfs
;
218 dt
[index
].offset_out
= asked_format
->rgodf
[j
].dwOfs
;
222 if (wine_format
->rgodf
[i
].dwOfs
!= asked_format
->rgodf
[j
].dwOfs
)
225 offset
[i
] = asked_format
->rgodf
[j
].dwOfs
;
230 if (j
== asked_format
->dwNumObjs
)
234 TRACE("Setting to default value :\n");
235 for (j
= 0; j
< asked_format
->dwNumObjs
; j
++) {
237 TRACE(" - Asked (%d) : %s - Ofs = %3ld - (Type = 0x%02x | Instance = %04x)\n",
238 j
, debugstr_guid(asked_format
->rgodf
[j
].pguid
),
239 asked_format
->rgodf
[j
].dwOfs
,
240 DIDFT_GETTYPE(asked_format
->rgodf
[j
].dwType
), DIDFT_GETINSTANCE(asked_format
->rgodf
[j
].dwType
));
243 if (asked_format
->rgodf
[j
].dwType
& DIDFT_BUTTON
)
244 dt
[index
].size
= sizeof(BYTE
);
246 dt
[index
].size
= sizeof(DWORD
);
247 dt
[index
].offset_in
= -1;
248 dt
[index
].offset_out
= asked_format
->rgodf
[j
].dwOfs
;
256 ret
->internal_format_size
= wine_format
->dwDataSize
;
260 HeapFree(GetProcessHeap(), 0, dt
);
265 HeapFree(GetProcessHeap(), 0, done
);
270 /******************************************************************************
271 * IDirectInputDeviceA
274 HRESULT WINAPI
IDirectInputDevice2AImpl_SetDataFormat(
275 LPDIRECTINPUTDEVICE8A iface
,LPCDIDATAFORMAT df
278 ICOM_THIS(IDirectInputDevice2AImpl
,iface
);
280 TRACE("(this=%p,%p)\n",This
,df
);
282 TRACE("df.dwSize=%ld\n",df
->dwSize
);
283 TRACE("(df.dwObjsize=%ld)\n",df
->dwObjSize
);
284 TRACE("(df.dwFlags=0x%08lx)\n",df
->dwFlags
);
285 TRACE("(df.dwDataSize=%ld)\n",df
->dwDataSize
);
286 TRACE("(df.dwNumObjs=%ld)\n",df
->dwNumObjs
);
288 for (i
=0;i
<df
->dwNumObjs
;i
++) {
289 TRACE("df.rgodf[%d].guid %s\n",i
,debugstr_guid(df
->rgodf
[i
].pguid
));
290 TRACE("df.rgodf[%d].dwOfs %ld\n",i
,df
->rgodf
[i
].dwOfs
);
291 TRACE("dwType 0x%02x,dwInstance %d\n",DIDFT_GETTYPE(df
->rgodf
[i
].dwType
),DIDFT_GETINSTANCE(df
->rgodf
[i
].dwType
));
292 TRACE("df.rgodf[%d].dwFlags 0x%08lx\n",i
,df
->rgodf
[i
].dwFlags
);
297 HRESULT WINAPI
IDirectInputDevice2AImpl_SetCooperativeLevel(
298 LPDIRECTINPUTDEVICE8A iface
,HWND hwnd
,DWORD dwflags
300 ICOM_THIS(IDirectInputDevice2AImpl
,iface
);
301 TRACE("(this=%p,0x%08lx,0x%08lx)\n",This
,(DWORD
)hwnd
,dwflags
);
302 if (TRACE_ON(dinput
)) {
303 TRACE(" cooperative level : ");
304 _dump_cooperativelevel_DI(dwflags
);
309 HRESULT WINAPI
IDirectInputDevice2AImpl_SetEventNotification(
310 LPDIRECTINPUTDEVICE8A iface
,HANDLE hnd
312 ICOM_THIS(IDirectInputDevice2AImpl
,iface
);
313 FIXME("(this=%p,0x%08lx): stub\n",This
,(DWORD
)hnd
);
317 ULONG WINAPI
IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface
)
319 ICOM_THIS(IDirectInputDevice2AImpl
,iface
);
323 HeapFree(GetProcessHeap(),0,This
);
327 HRESULT WINAPI
IDirectInputDevice2AImpl_QueryInterface(
328 LPDIRECTINPUTDEVICE8A iface
,REFIID riid
,LPVOID
*ppobj
331 ICOM_THIS(IDirectInputDevice2AImpl
,iface
);
333 TRACE("(this=%p,%s,%p)\n",This
,debugstr_guid(riid
),ppobj
);
334 if (IsEqualGUID(&IID_IUnknown
,riid
)) {
335 IDirectInputDevice2_AddRef(iface
);
339 if (IsEqualGUID(&IID_IDirectInputDeviceA
,riid
)) {
340 IDirectInputDevice2_AddRef(iface
);
344 if (IsEqualGUID(&IID_IDirectInputDevice7A
,riid
)) {
345 IDirectInputDevice7_AddRef(iface
);
349 TRACE("Unsupported interface !\n");
353 ULONG WINAPI
IDirectInputDevice2AImpl_AddRef(
354 LPDIRECTINPUTDEVICE8A iface
)
356 ICOM_THIS(IDirectInputDevice2AImpl
,iface
);
360 HRESULT WINAPI
IDirectInputDevice2AImpl_EnumObjects(
361 LPDIRECTINPUTDEVICE8A iface
,
362 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback
,
366 FIXME("(this=%p,%p,%p,%08lx): stub!\n", iface
, lpCallback
, lpvRef
, dwFlags
);
367 if (TRACE_ON(dinput
)) {
368 DPRINTF(" - flags = ");
369 _dump_EnumObjects_flags(dwFlags
);
376 HRESULT WINAPI
IDirectInputDevice2AImpl_GetProperty(
377 LPDIRECTINPUTDEVICE8A iface
,
379 LPDIPROPHEADER pdiph
)
381 FIXME("(this=%p,%s,%p): stub!\n",
382 iface
, debugstr_guid(rguid
), pdiph
);
384 if (TRACE_ON(dinput
))
385 _dump_DIPROPHEADER(pdiph
);
390 HRESULT WINAPI
IDirectInputDevice2AImpl_GetObjectInfo(
391 LPDIRECTINPUTDEVICE8A iface
,
392 LPDIDEVICEOBJECTINSTANCEA pdidoi
,
396 FIXME("(this=%p,%p,%ld,0x%08lx): stub!\n",
397 iface
, pdidoi
, dwObj
, dwHow
);
402 HRESULT WINAPI
IDirectInputDevice2AImpl_GetDeviceInfo(
403 LPDIRECTINPUTDEVICE8A iface
,
404 LPDIDEVICEINSTANCEA pdidi
)
406 FIXME("(this=%p,%p): stub!\n",
412 HRESULT WINAPI
IDirectInputDevice2AImpl_RunControlPanel(
413 LPDIRECTINPUTDEVICE8A iface
,
417 FIXME("(this=%p,%p,0x%08lx): stub!\n",
418 iface
, hwndOwner
, dwFlags
);
423 HRESULT WINAPI
IDirectInputDevice2AImpl_Initialize(
424 LPDIRECTINPUTDEVICE8A iface
,
429 FIXME("(this=%p,%p,%ld,%s): stub!\n",
430 iface
, hinst
, dwVersion
, debugstr_guid(rguid
));
434 /******************************************************************************
435 * IDirectInputDevice2A
438 HRESULT WINAPI
IDirectInputDevice2AImpl_CreateEffect(
439 LPDIRECTINPUTDEVICE8A iface
,
442 LPDIRECTINPUTEFFECT
*ppdef
,
445 FIXME("(this=%p,%s,%p,%p,%p): stub!\n",
446 iface
, debugstr_guid(rguid
), lpeff
, ppdef
, pUnkOuter
);
450 HRESULT WINAPI
IDirectInputDevice2AImpl_EnumEffects(
451 LPDIRECTINPUTDEVICE8A iface
,
452 LPDIENUMEFFECTSCALLBACKA lpCallback
,
456 FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
457 iface
, lpCallback
, lpvRef
, dwFlags
);
460 lpCallback(NULL
, lpvRef
);
464 HRESULT WINAPI
IDirectInputDevice2AImpl_GetEffectInfo(
465 LPDIRECTINPUTDEVICE8A iface
,
466 LPDIEFFECTINFOA lpdei
,
469 FIXME("(this=%p,%p,%s): stub!\n",
470 iface
, lpdei
, debugstr_guid(rguid
));
474 HRESULT WINAPI
IDirectInputDevice2AImpl_GetForceFeedbackState(
475 LPDIRECTINPUTDEVICE8A iface
,
478 FIXME("(this=%p,%p): stub!\n",
483 HRESULT WINAPI
IDirectInputDevice2AImpl_SendForceFeedbackCommand(
484 LPDIRECTINPUTDEVICE8A iface
,
487 FIXME("(this=%p,0x%08lx): stub!\n",
492 HRESULT WINAPI
IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
493 LPDIRECTINPUTDEVICE8A iface
,
494 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback
,
498 FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
499 iface
, lpCallback
, lpvRef
, dwFlags
);
501 lpCallback(NULL
, lpvRef
);
505 HRESULT WINAPI
IDirectInputDevice2AImpl_Escape(
506 LPDIRECTINPUTDEVICE8A iface
,
507 LPDIEFFESCAPE lpDIEEsc
)
509 FIXME("(this=%p,%p): stub!\n",
514 HRESULT WINAPI
IDirectInputDevice2AImpl_Poll(
515 LPDIRECTINPUTDEVICE8A iface
)
517 /* Because wine devices do not need to be polled, just return DI_NOEFFECT */
521 HRESULT WINAPI
IDirectInputDevice2AImpl_SendDeviceData(
522 LPDIRECTINPUTDEVICE8A iface
,
524 LPCDIDEVICEOBJECTDATA rgdod
,
528 FIXME("(this=%p,0x%08lx,%p,%p,0x%08lx): stub!\n",
529 iface
, cbObjectData
, rgdod
, pdwInOut
, dwFlags
);
534 HRESULT WINAPI
IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface
,
536 LPDIENUMEFFECTSINFILECALLBACK pec
,
540 FIXME("(%p)->(%s,%p,%p,%08lx): stub !\n", iface
, lpszFileName
, pec
, pvRef
, dwFlags
);
545 HRESULT WINAPI
IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface
,
548 LPDIFILEEFFECT rgDiFileEft
,
551 FIXME("(%p)->(%s,%08lx,%p,%08lx): stub !\n", iface
, lpszFileName
, dwEntries
, rgDiFileEft
, dwFlags
);
556 HRESULT WINAPI
IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface
,
557 LPDIACTIONFORMATA lpdiaf
,
561 FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface
, lpdiaf
, lpszUserName
, dwFlags
);
566 HRESULT WINAPI
IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface
,
567 LPDIACTIONFORMATA lpdiaf
,
571 FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface
, lpdiaf
, lpszUserName
, dwFlags
);
576 HRESULT WINAPI
IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface
,
577 LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader
)
579 FIXME("(%p)->(%p): stub !\n", iface
, lpdiDevImageInfoHeader
);