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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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.
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
39 #include "device_private.h"
40 #include "dinput_private.h"
42 #define WM_WINE_NOTIFY_ACTIVITY WM_USER
44 WINE_DEFAULT_DEBUG_CHANNEL(dinput
);
46 static inline IDirectInputDeviceImpl
*impl_from_IDirectInputDevice8A(IDirectInputDevice8A
*iface
)
48 return CONTAINING_RECORD(iface
, IDirectInputDeviceImpl
, IDirectInputDevice8A_iface
);
50 static inline IDirectInputDeviceImpl
*impl_from_IDirectInputDevice8W(IDirectInputDevice8W
*iface
)
52 return CONTAINING_RECORD(iface
, IDirectInputDeviceImpl
, IDirectInputDevice8W_iface
);
55 static inline IDirectInputDevice8A
*IDirectInputDevice8A_from_impl(IDirectInputDeviceImpl
*This
)
57 return &This
->IDirectInputDevice8A_iface
;
59 static inline IDirectInputDevice8W
*IDirectInputDevice8W_from_impl(IDirectInputDeviceImpl
*This
)
61 return &This
->IDirectInputDevice8W_iface
;
64 /******************************************************************************
65 * Various debugging tools
67 static void _dump_cooperativelevel_DI(DWORD dwFlags
) {
68 if (TRACE_ON(dinput
)) {
74 #define FE(x) { x, #x}
78 FE(DISCL_NONEXCLUSIVE
),
82 TRACE(" cooperative level : ");
83 for (i
= 0; i
< ARRAY_SIZE(flags
); i
++)
84 if (flags
[i
].mask
& dwFlags
)
85 TRACE("%s ",flags
[i
].name
);
90 static void _dump_ObjectDataFormat_flags(DWORD dwFlags
) {
96 #define FE(x) { x, #x}
98 FE(DIDOI_FFEFFECTTRIGGER
),
100 FE(DIDOI_GUIDISUSAGE
)
104 if (!dwFlags
) return;
108 /* First the flags */
109 for (i
= 0; i
< ARRAY_SIZE(flags
); i
++) {
110 if (flags
[i
].mask
& dwFlags
)
111 TRACE(" %s",flags
[i
].name
);
114 /* Now specific values */
115 #define FE(x) case x: TRACE(" "#x); break
116 switch (dwFlags
& DIDOI_ASPECTMASK
) {
117 FE(DIDOI_ASPECTACCEL
);
118 FE(DIDOI_ASPECTFORCE
);
119 FE(DIDOI_ASPECTPOSITION
);
120 FE(DIDOI_ASPECTVELOCITY
);
126 static void _dump_EnumObjects_flags(DWORD dwFlags
) {
127 if (TRACE_ON(dinput
)) {
129 DWORD type
, instance
;
130 static const struct {
134 #define FE(x) { x, #x}
140 FE(DIDFT_COLLECTION
),
142 FE(DIDFT_FFACTUATOR
),
143 FE(DIDFT_FFEFFECTTRIGGER
),
145 FE(DIDFT_VENDORDEFINED
),
150 type
= (dwFlags
& 0xFF0000FF);
151 instance
= ((dwFlags
>> 8) & 0xFFFF);
153 if (type
== DIDFT_ALL
) {
156 for (i
= 0; i
< ARRAY_SIZE(flags
); i
++) {
157 if (flags
[i
].mask
& type
) {
158 type
&= ~flags
[i
].mask
;
159 TRACE(" %s",flags
[i
].name
);
163 TRACE(" (unhandled: %08x)", type
);
166 TRACE(" / Instance: ");
167 if (instance
== ((DIDFT_ANYINSTANCE
>> 8) & 0xFFFF)) {
168 TRACE("DIDFT_ANYINSTANCE");
170 TRACE("%3d", instance
);
175 void _dump_DIPROPHEADER(LPCDIPROPHEADER diph
) {
176 if (TRACE_ON(dinput
)) {
177 TRACE(" - dwObj = 0x%08x\n", diph
->dwObj
);
178 TRACE(" - dwHow = %s\n",
179 ((diph
->dwHow
== DIPH_DEVICE
) ? "DIPH_DEVICE" :
180 ((diph
->dwHow
== DIPH_BYOFFSET
) ? "DIPH_BYOFFSET" :
181 ((diph
->dwHow
== DIPH_BYID
)) ? "DIPH_BYID" : "unknown")));
185 void _dump_OBJECTINSTANCEA(const DIDEVICEOBJECTINSTANCEA
*ddoi
) {
186 TRACE(" - enumerating : %s ('%s') - %2d - 0x%08x - %s - 0x%x\n",
187 debugstr_guid(&ddoi
->guidType
), _dump_dinput_GUID(&ddoi
->guidType
), ddoi
->dwOfs
, ddoi
->dwType
, ddoi
->tszName
, ddoi
->dwFlags
);
190 void _dump_OBJECTINSTANCEW(const DIDEVICEOBJECTINSTANCEW
*ddoi
) {
191 TRACE(" - enumerating : %s ('%s'), - %2d - 0x%08x - %s - 0x%x\n",
192 debugstr_guid(&ddoi
->guidType
), _dump_dinput_GUID(&ddoi
->guidType
), ddoi
->dwOfs
, ddoi
->dwType
, debugstr_w(ddoi
->tszName
), ddoi
->dwFlags
);
195 /* This function is a helper to convert a GUID into any possible DInput GUID out there */
196 const char *_dump_dinput_GUID(const GUID
*guid
) {
198 static const struct {
202 #define FE(x) { &x, #x}
215 FE(GUID_SysKeyboard
),
217 FE(GUID_ConstantForce
),
223 FE(GUID_SawtoothDown
),
233 for (i
= 0; i
< ARRAY_SIZE(guids
); i
++) {
234 if (IsEqualGUID(guids
[i
].guid
, guid
)) {
235 return guids
[i
].name
;
238 return debugstr_guid(guid
);
241 void _dump_DIDATAFORMAT(const DIDATAFORMAT
*df
) {
244 TRACE("Dumping DIDATAFORMAT structure:\n");
245 TRACE(" - dwSize: %d\n", df
->dwSize
);
246 if (df
->dwSize
!= sizeof(DIDATAFORMAT
)) {
247 WARN("Non-standard DIDATAFORMAT structure size %d\n", df
->dwSize
);
249 TRACE(" - dwObjsize: %d\n", df
->dwObjSize
);
250 if (df
->dwObjSize
!= sizeof(DIOBJECTDATAFORMAT
)) {
251 WARN("Non-standard DIOBJECTDATAFORMAT structure size %d\n", df
->dwObjSize
);
253 TRACE(" - dwFlags: 0x%08x (", df
->dwFlags
);
254 switch (df
->dwFlags
) {
255 case DIDF_ABSAXIS
: TRACE("DIDF_ABSAXIS"); break;
256 case DIDF_RELAXIS
: TRACE("DIDF_RELAXIS"); break;
257 default: TRACE("unknown"); break;
260 TRACE(" - dwDataSize: %d\n", df
->dwDataSize
);
261 TRACE(" - dwNumObjs: %d\n", df
->dwNumObjs
);
263 for (i
= 0; i
< df
->dwNumObjs
; i
++) {
264 TRACE(" - Object %d:\n", i
);
265 TRACE(" * GUID: %s ('%s')\n", debugstr_guid(df
->rgodf
[i
].pguid
), _dump_dinput_GUID(df
->rgodf
[i
].pguid
));
266 TRACE(" * dwOfs: %d\n", df
->rgodf
[i
].dwOfs
);
267 TRACE(" * dwType: 0x%08x\n", df
->rgodf
[i
].dwType
);
268 TRACE(" "); _dump_EnumObjects_flags(df
->rgodf
[i
].dwType
); TRACE("\n");
269 TRACE(" * dwFlags: 0x%08x\n", df
->rgodf
[i
].dwFlags
);
270 TRACE(" "); _dump_ObjectDataFormat_flags(df
->rgodf
[i
].dwFlags
); TRACE("\n");
274 /******************************************************************************
275 * Get the default and the app-specific config keys.
277 BOOL
get_app_key(HKEY
*defkey
, HKEY
*appkey
)
279 char buffer
[MAX_PATH
+16];
284 /* @@ Wine registry key: HKCU\Software\Wine\DirectInput */
285 if (RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\DirectInput", defkey
))
288 len
= GetModuleFileNameA(0, buffer
, MAX_PATH
);
289 if (len
&& len
< MAX_PATH
)
293 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectInput */
294 if (!RegOpenKeyA(HKEY_CURRENT_USER
, "Software\\Wine\\AppDefaults", &tmpkey
))
296 char *p
, *appname
= buffer
;
297 if ((p
= strrchr(appname
, '/'))) appname
= p
+ 1;
298 if ((p
= strrchr(appname
, '\\'))) appname
= p
+ 1;
299 strcat(appname
, "\\DirectInput");
301 if (RegOpenKeyA(tmpkey
, appname
, appkey
)) *appkey
= 0;
306 return *defkey
|| *appkey
;
309 /******************************************************************************
310 * Get a config key from either the app-specific or the default config
312 DWORD
get_config_key( HKEY defkey
, HKEY appkey
, const char *name
,
313 char *buffer
, DWORD size
)
315 if (appkey
&& !RegQueryValueExA( appkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
))
318 if (defkey
&& !RegQueryValueExA( defkey
, name
, 0, NULL
, (LPBYTE
)buffer
, &size
))
321 return ERROR_FILE_NOT_FOUND
;
324 /* Conversion between internal data buffer and external data buffer */
325 void fill_DataFormat(void *out
, DWORD size
, const void *in
, const DataFormat
*df
)
328 const char *in_c
= in
;
331 memset(out
, 0, size
);
332 if (df
->dt
== NULL
) {
333 /* This means that the app uses Wine's internal data format */
334 memcpy(out
, in
, min(size
, df
->internal_format_size
));
336 for (i
= 0; i
< df
->size
; i
++) {
337 if (df
->dt
[i
].offset_in
>= 0) {
338 switch (df
->dt
[i
].size
) {
340 TRACE("Copying (c) to %d from %d (value %d)\n",
341 df
->dt
[i
].offset_out
, df
->dt
[i
].offset_in
, *(in_c
+ df
->dt
[i
].offset_in
));
342 *(out_c
+ df
->dt
[i
].offset_out
) = *(in_c
+ df
->dt
[i
].offset_in
);
346 TRACE("Copying (s) to %d from %d (value %d)\n",
347 df
->dt
[i
].offset_out
, df
->dt
[i
].offset_in
, *((const short *)(in_c
+ df
->dt
[i
].offset_in
)));
348 *((short *)(out_c
+ df
->dt
[i
].offset_out
)) = *((const short *)(in_c
+ df
->dt
[i
].offset_in
));
352 TRACE("Copying (i) to %d from %d (value %d)\n",
353 df
->dt
[i
].offset_out
, df
->dt
[i
].offset_in
, *((const int *)(in_c
+ df
->dt
[i
].offset_in
)));
354 *((int *)(out_c
+ df
->dt
[i
].offset_out
)) = *((const int *)(in_c
+ df
->dt
[i
].offset_in
));
358 memcpy((out_c
+ df
->dt
[i
].offset_out
), (in_c
+ df
->dt
[i
].offset_in
), df
->dt
[i
].size
);
362 switch (df
->dt
[i
].size
) {
364 TRACE("Copying (c) to %d default value %d\n",
365 df
->dt
[i
].offset_out
, df
->dt
[i
].value
);
366 *(out_c
+ df
->dt
[i
].offset_out
) = (char) df
->dt
[i
].value
;
370 TRACE("Copying (s) to %d default value %d\n",
371 df
->dt
[i
].offset_out
, df
->dt
[i
].value
);
372 *((short *) (out_c
+ df
->dt
[i
].offset_out
)) = (short) df
->dt
[i
].value
;
376 TRACE("Copying (i) to %d default value %d\n",
377 df
->dt
[i
].offset_out
, df
->dt
[i
].value
);
378 *((int *) (out_c
+ df
->dt
[i
].offset_out
)) = df
->dt
[i
].value
;
382 memset((out_c
+ df
->dt
[i
].offset_out
), 0, df
->dt
[i
].size
);
390 void release_DataFormat(DataFormat
* format
)
392 TRACE("Deleting DataFormat: %p\n", format
);
394 HeapFree(GetProcessHeap(), 0, format
->dt
);
396 HeapFree(GetProcessHeap(), 0, format
->offsets
);
397 format
->offsets
= NULL
;
398 HeapFree(GetProcessHeap(), 0, format
->user_df
);
399 format
->user_df
= NULL
;
402 static inline LPDIOBJECTDATAFORMAT
dataformat_to_odf(LPCDIDATAFORMAT df
, int idx
)
404 if (idx
< 0 || idx
>= df
->dwNumObjs
) return NULL
;
405 return (LPDIOBJECTDATAFORMAT
)((LPBYTE
)df
->rgodf
+ idx
* df
->dwObjSize
);
408 /* dataformat_to_odf_by_type
409 * Find the Nth object of the selected type in the DataFormat
411 LPDIOBJECTDATAFORMAT
dataformat_to_odf_by_type(LPCDIDATAFORMAT df
, int n
, DWORD type
)
415 for (i
=0; i
< df
->dwNumObjs
; i
++)
417 LPDIOBJECTDATAFORMAT odf
= dataformat_to_odf(df
, i
);
419 if (odf
->dwType
& type
)
431 static HRESULT
create_DataFormat(LPCDIDATAFORMAT asked_format
, DataFormat
*format
)
440 if (!format
->wine_df
) return DIERR_INVALIDPARAM
;
441 done
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, asked_format
->dwNumObjs
* sizeof(int));
442 dt
= HeapAlloc(GetProcessHeap(), 0, asked_format
->dwNumObjs
* sizeof(DataTransform
));
443 if (!dt
|| !done
) goto failed
;
445 if (!(format
->offsets
= HeapAlloc(GetProcessHeap(), 0, format
->wine_df
->dwNumObjs
* sizeof(int))))
448 if (!(format
->user_df
= HeapAlloc(GetProcessHeap(), 0, asked_format
->dwSize
)))
450 memcpy(format
->user_df
, asked_format
, asked_format
->dwSize
);
452 TRACE("Creating DataTransform :\n");
454 for (i
= 0; i
< format
->wine_df
->dwNumObjs
; i
++)
456 format
->offsets
[i
] = -1;
458 for (j
= 0; j
< asked_format
->dwNumObjs
; j
++) {
462 if (/* Check if the application either requests any GUID and if not, it if matches
463 * the GUID of the Wine object.
465 ((asked_format
->rgodf
[j
].pguid
== NULL
) ||
466 (format
->wine_df
->rgodf
[i
].pguid
== NULL
) ||
467 (IsEqualGUID(format
->wine_df
->rgodf
[i
].pguid
, asked_format
->rgodf
[j
].pguid
)))
469 (/* Then check if it accepts any instance id, and if not, if it matches Wine's
472 ((asked_format
->rgodf
[j
].dwType
& DIDFT_INSTANCEMASK
) == DIDFT_ANYINSTANCE
) ||
473 (DIDFT_GETINSTANCE(asked_format
->rgodf
[j
].dwType
) == 0x00FF) || /* This is mentioned in no DX docs, but it works fine - tested on WinXP */
474 (DIDFT_GETINSTANCE(asked_format
->rgodf
[j
].dwType
) == DIDFT_GETINSTANCE(format
->wine_df
->rgodf
[i
].dwType
)))
476 ( /* Then if the asked type matches the one Wine provides */
477 DIDFT_GETTYPE(asked_format
->rgodf
[j
].dwType
) & format
->wine_df
->rgodf
[i
].dwType
))
481 TRACE("Matching :\n");
482 TRACE(" - Asked (%d) :\n", j
);
483 TRACE(" * GUID: %s ('%s')\n",
484 debugstr_guid(asked_format
->rgodf
[j
].pguid
),
485 _dump_dinput_GUID(asked_format
->rgodf
[j
].pguid
));
486 TRACE(" * Offset: %3d\n", asked_format
->rgodf
[j
].dwOfs
);
487 TRACE(" * dwType: 0x%08x\n", asked_format
->rgodf
[j
].dwType
);
488 TRACE(" "); _dump_EnumObjects_flags(asked_format
->rgodf
[j
].dwType
); TRACE("\n");
489 TRACE(" * dwFlags: 0x%08x\n", asked_format
->rgodf
[j
].dwFlags
);
490 TRACE(" "); _dump_ObjectDataFormat_flags(asked_format
->rgodf
[j
].dwFlags
); TRACE("\n");
492 TRACE(" - Wine (%d) :\n", i
);
493 TRACE(" * GUID: %s ('%s')\n",
494 debugstr_guid(format
->wine_df
->rgodf
[i
].pguid
),
495 _dump_dinput_GUID(format
->wine_df
->rgodf
[i
].pguid
));
496 TRACE(" * Offset: %3d\n", format
->wine_df
->rgodf
[i
].dwOfs
);
497 TRACE(" * dwType: 0x%08x\n", format
->wine_df
->rgodf
[i
].dwType
);
498 TRACE(" "); _dump_EnumObjects_flags(format
->wine_df
->rgodf
[i
].dwType
); TRACE("\n");
499 TRACE(" * dwFlags: 0x%08x\n", format
->wine_df
->rgodf
[i
].dwFlags
);
500 TRACE(" "); _dump_ObjectDataFormat_flags(format
->wine_df
->rgodf
[i
].dwFlags
); TRACE("\n");
502 if (format
->wine_df
->rgodf
[i
].dwType
& DIDFT_BUTTON
)
503 dt
[index
].size
= sizeof(BYTE
);
505 dt
[index
].size
= sizeof(DWORD
);
506 dt
[index
].offset_in
= format
->wine_df
->rgodf
[i
].dwOfs
;
507 dt
[index
].offset_out
= asked_format
->rgodf
[j
].dwOfs
;
508 format
->offsets
[i
] = asked_format
->rgodf
[j
].dwOfs
;
510 next
= next
+ dt
[index
].size
;
512 if (format
->wine_df
->rgodf
[i
].dwOfs
!= dt
[index
].offset_out
)
521 TRACE("Setting to default value :\n");
522 for (j
= 0; j
< asked_format
->dwNumObjs
; j
++) {
524 TRACE(" - Asked (%d) :\n", j
);
525 TRACE(" * GUID: %s ('%s')\n",
526 debugstr_guid(asked_format
->rgodf
[j
].pguid
),
527 _dump_dinput_GUID(asked_format
->rgodf
[j
].pguid
));
528 TRACE(" * Offset: %3d\n", asked_format
->rgodf
[j
].dwOfs
);
529 TRACE(" * dwType: 0x%08x\n", asked_format
->rgodf
[j
].dwType
);
530 TRACE(" "); _dump_EnumObjects_flags(asked_format
->rgodf
[j
].dwType
); TRACE("\n");
531 TRACE(" * dwFlags: 0x%08x\n", asked_format
->rgodf
[j
].dwFlags
);
532 TRACE(" "); _dump_ObjectDataFormat_flags(asked_format
->rgodf
[j
].dwFlags
); TRACE("\n");
534 if (asked_format
->rgodf
[j
].dwType
& DIDFT_BUTTON
)
535 dt
[index
].size
= sizeof(BYTE
);
537 dt
[index
].size
= sizeof(DWORD
);
538 dt
[index
].offset_in
= -1;
539 dt
[index
].offset_out
= asked_format
->rgodf
[j
].dwOfs
;
540 if (asked_format
->rgodf
[j
].dwType
& DIDFT_POV
)
541 dt
[index
].value
= -1;
550 format
->internal_format_size
= format
->wine_df
->dwDataSize
;
551 format
->size
= index
;
553 HeapFree(GetProcessHeap(), 0, dt
);
558 HeapFree(GetProcessHeap(), 0, done
);
563 HeapFree(GetProcessHeap(), 0, done
);
564 HeapFree(GetProcessHeap(), 0, dt
);
566 HeapFree(GetProcessHeap(), 0, format
->offsets
);
567 format
->offsets
= NULL
;
568 HeapFree(GetProcessHeap(), 0, format
->user_df
);
569 format
->user_df
= NULL
;
571 return DIERR_OUTOFMEMORY
;
574 /* find an object by its offset in a data format */
575 static int offset_to_object(const DataFormat
*df
, int offset
)
579 if (!df
->offsets
) return -1;
581 for (i
= 0; i
< df
->wine_df
->dwNumObjs
; i
++)
582 if (df
->offsets
[i
] == offset
) return i
;
587 int id_to_object(LPCDIDATAFORMAT df
, int id
)
592 for (i
= 0; i
< df
->dwNumObjs
; i
++)
593 if ((dataformat_to_odf(df
, i
)->dwType
& 0x00ffffff) == id
)
599 static int id_to_offset(const DataFormat
*df
, int id
)
601 int obj
= id_to_object(df
->wine_df
, id
);
603 return obj
>= 0 && df
->offsets
? df
->offsets
[obj
] : -1;
606 int find_property(const DataFormat
*df
, LPCDIPROPHEADER ph
)
610 case DIPH_BYID
: return id_to_object(df
->wine_df
, ph
->dwObj
);
611 case DIPH_BYOFFSET
: return offset_to_object(df
, ph
->dwObj
);
613 FIXME("Unhandled ph->dwHow=='%04X'\n", (unsigned int)ph
->dwHow
);
618 static DWORD
semantic_to_obj_id(IDirectInputDeviceImpl
* This
, DWORD dwSemantic
)
620 DWORD type
= (0x0000ff00 & dwSemantic
) >> 8;
621 DWORD offset
= 0x000000ff & dwSemantic
;
622 DWORD obj_instance
= 0;
626 for (i
= 0; i
< This
->data_format
.wine_df
->dwNumObjs
; i
++)
628 LPDIOBJECTDATAFORMAT odf
= dataformat_to_odf(This
->data_format
.wine_df
, i
);
630 if (odf
->dwOfs
== offset
)
632 obj_instance
= DIDFT_GETINSTANCE(odf
->dwType
);
638 if (!found
) return 0;
640 if (type
& DIDFT_AXIS
) type
= DIDFT_RELAXIS
;
641 if (type
& DIDFT_BUTTON
) type
= DIDFT_PSHBUTTON
;
643 return type
| (0x0000ff00 & (obj_instance
<< 8));
648 * Retrieves an open registry key to save the mapping, parametrized for an username,
649 * specific device and specific action mapping guid.
651 static HKEY
get_mapping_key(const WCHAR
*device
, const WCHAR
*username
, const WCHAR
*guid
)
653 static const WCHAR subkey
[] = {
654 'S','o','f','t','w','a','r','e','\\',
655 'W','i','n','e','\\',
656 'D','i','r','e','c','t','I','n','p','u','t','\\',
657 'M','a','p','p','i','n','g','s','\\','%','s','\\','%','s','\\','%','s','\0'};
661 keyname
= HeapAlloc(GetProcessHeap(), 0,
662 sizeof(WCHAR
) * (lstrlenW(subkey
) + strlenW(username
) + strlenW(device
) + strlenW(guid
)));
663 sprintfW(keyname
, subkey
, username
, device
, guid
);
665 /* The key used is HKCU\Software\Wine\DirectInput\Mappings\[username]\[device]\[mapping_guid] */
666 if (RegCreateKeyW(HKEY_CURRENT_USER
, keyname
, &hkey
))
669 HeapFree(GetProcessHeap(), 0, keyname
);
674 static HRESULT
save_mapping_settings(IDirectInputDevice8W
*iface
, LPDIACTIONFORMATW lpdiaf
, LPCWSTR lpszUsername
)
676 WCHAR
*guid_str
= NULL
;
677 DIDEVICEINSTANCEW didev
;
681 didev
.dwSize
= sizeof(didev
);
682 IDirectInputDevice8_GetDeviceInfo(iface
, &didev
);
684 if (StringFromCLSID(&lpdiaf
->guidActionMap
, &guid_str
) != S_OK
)
685 return DI_SETTINGSNOTSAVED
;
687 hkey
= get_mapping_key(didev
.tszInstanceName
, lpszUsername
, guid_str
);
691 CoTaskMemFree(guid_str
);
692 return DI_SETTINGSNOTSAVED
;
695 /* Write each of the actions mapped for this device.
696 Format is "dwSemantic"="dwObjID" and key is of type REG_DWORD
698 for (i
= 0; i
< lpdiaf
->dwNumActions
; i
++)
700 static const WCHAR format
[] = {'%','x','\0'};
703 if (IsEqualGUID(&didev
.guidInstance
, &lpdiaf
->rgoAction
[i
].guidInstance
) &&
704 lpdiaf
->rgoAction
[i
].dwHow
!= DIAH_UNMAPPED
)
706 sprintfW(label
, format
, lpdiaf
->rgoAction
[i
].dwSemantic
);
707 RegSetValueExW(hkey
, label
, 0, REG_DWORD
, (const BYTE
*) &lpdiaf
->rgoAction
[i
].dwObjID
, sizeof(DWORD
));
712 CoTaskMemFree(guid_str
);
717 static BOOL
load_mapping_settings(IDirectInputDeviceImpl
*This
, LPDIACTIONFORMATW lpdiaf
, const WCHAR
*username
)
721 DIDEVICEINSTANCEW didev
;
724 didev
.dwSize
= sizeof(didev
);
725 IDirectInputDevice8_GetDeviceInfo(&This
->IDirectInputDevice8W_iface
, &didev
);
727 if (StringFromCLSID(&lpdiaf
->guidActionMap
, &guid_str
) != S_OK
)
730 hkey
= get_mapping_key(didev
.tszInstanceName
, username
, guid_str
);
734 CoTaskMemFree(guid_str
);
738 /* Try to read each action in the DIACTIONFORMAT from registry */
739 for (i
= 0; i
< lpdiaf
->dwNumActions
; i
++)
741 static const WCHAR format
[] = {'%','x','\0'};
742 DWORD id
, size
= sizeof(DWORD
);
745 sprintfW(label
, format
, lpdiaf
->rgoAction
[i
].dwSemantic
);
747 if (!RegQueryValueExW(hkey
, label
, 0, NULL
, (LPBYTE
) &id
, &size
))
749 lpdiaf
->rgoAction
[i
].dwObjID
= id
;
750 lpdiaf
->rgoAction
[i
].guidInstance
= didev
.guidInstance
;
751 lpdiaf
->rgoAction
[i
].dwHow
= DIAH_DEFAULT
;
757 CoTaskMemFree(guid_str
);
762 HRESULT
_build_action_map(LPDIRECTINPUTDEVICE8W iface
, LPDIACTIONFORMATW lpdiaf
, LPCWSTR lpszUserName
, DWORD dwFlags
, DWORD devMask
, LPCDIDATAFORMAT df
)
764 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
765 WCHAR username
[MAX_PATH
];
766 DWORD username_size
= MAX_PATH
;
768 BOOL load_success
= FALSE
, has_actions
= FALSE
;
770 /* Unless asked the contrary by these flags, try to load a previous mapping */
771 if (!(dwFlags
& DIDBAM_HWDEFAULTS
))
773 /* Retrieve logged user name if necessary */
774 if (lpszUserName
== NULL
)
775 GetUserNameW(username
, &username_size
);
777 lstrcpynW(username
, lpszUserName
, MAX_PATH
);
779 load_success
= load_mapping_settings(This
, lpdiaf
, username
);
782 if (load_success
) return DI_OK
;
784 for (i
=0; i
< lpdiaf
->dwNumActions
; i
++)
786 /* Don't touch a user configured action */
787 if (lpdiaf
->rgoAction
[i
].dwHow
== DIAH_USERCONFIG
) continue;
789 if ((lpdiaf
->rgoAction
[i
].dwSemantic
& devMask
) == devMask
)
791 DWORD obj_id
= semantic_to_obj_id(This
, lpdiaf
->rgoAction
[i
].dwSemantic
);
792 DWORD type
= DIDFT_GETTYPE(obj_id
);
793 DWORD inst
= DIDFT_GETINSTANCE(obj_id
);
795 LPDIOBJECTDATAFORMAT odf
;
797 if (type
== DIDFT_PSHBUTTON
) type
= DIDFT_BUTTON
;
798 if (type
== DIDFT_RELAXIS
) type
= DIDFT_AXIS
;
800 /* Make sure the object exists */
801 odf
= dataformat_to_odf_by_type(df
, inst
, type
);
805 lpdiaf
->rgoAction
[i
].dwObjID
= obj_id
;
806 lpdiaf
->rgoAction
[i
].guidInstance
= This
->guid
;
807 lpdiaf
->rgoAction
[i
].dwHow
= DIAH_DEFAULT
;
811 else if (!(dwFlags
& DIDBAM_PRESERVE
))
813 /* We must clear action data belonging to other devices */
814 memset(&lpdiaf
->rgoAction
[i
].guidInstance
, 0, sizeof(GUID
));
815 lpdiaf
->rgoAction
[i
].dwHow
= DIAH_UNMAPPED
;
819 if (!has_actions
) return DI_NOEFFECT
;
821 return IDirectInputDevice8WImpl_BuildActionMap(iface
, lpdiaf
, lpszUserName
, dwFlags
);
824 HRESULT
_set_action_map(LPDIRECTINPUTDEVICE8W iface
, LPDIACTIONFORMATW lpdiaf
, LPCWSTR lpszUserName
, DWORD dwFlags
, LPCDIDATAFORMAT df
)
826 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
827 DIDATAFORMAT data_format
;
828 DIOBJECTDATAFORMAT
*obj_df
= NULL
;
832 WCHAR username
[MAX_PATH
];
833 DWORD username_size
= MAX_PATH
;
834 int i
, action
= 0, num_actions
= 0;
835 unsigned int offset
= 0;
837 if (This
->acquired
) return DIERR_ACQUIRED
;
839 data_format
.dwSize
= sizeof(data_format
);
840 data_format
.dwObjSize
= sizeof(DIOBJECTDATAFORMAT
);
841 data_format
.dwFlags
= DIDF_RELAXIS
;
842 data_format
.dwDataSize
= lpdiaf
->dwDataSize
;
844 /* Count the actions */
845 for (i
=0; i
< lpdiaf
->dwNumActions
; i
++)
846 if (IsEqualGUID(&This
->guid
, &lpdiaf
->rgoAction
[i
].guidInstance
))
849 if (num_actions
== 0) return DI_NOEFFECT
;
851 This
->num_actions
= num_actions
;
853 /* Construct the dataformat and actionmap */
854 obj_df
= HeapAlloc(GetProcessHeap(), 0, sizeof(DIOBJECTDATAFORMAT
)*num_actions
);
855 data_format
.rgodf
= (LPDIOBJECTDATAFORMAT
)obj_df
;
856 data_format
.dwNumObjs
= num_actions
;
858 HeapFree(GetProcessHeap(), 0, This
->action_map
);
859 This
->action_map
= HeapAlloc(GetProcessHeap(), 0, sizeof(ActionMap
)*num_actions
);
861 for (i
= 0; i
< lpdiaf
->dwNumActions
; i
++)
863 if (IsEqualGUID(&This
->guid
, &lpdiaf
->rgoAction
[i
].guidInstance
))
865 DWORD inst
= DIDFT_GETINSTANCE(lpdiaf
->rgoAction
[i
].dwObjID
);
866 DWORD type
= DIDFT_GETTYPE(lpdiaf
->rgoAction
[i
].dwObjID
);
867 LPDIOBJECTDATAFORMAT obj
;
869 if (type
== DIDFT_PSHBUTTON
) type
= DIDFT_BUTTON
;
870 if (type
== DIDFT_RELAXIS
) type
= DIDFT_AXIS
;
872 obj
= dataformat_to_odf_by_type(df
, inst
, type
);
874 memcpy(&obj_df
[action
], obj
, df
->dwObjSize
);
876 This
->action_map
[action
].uAppData
= lpdiaf
->rgoAction
[i
].uAppData
;
877 This
->action_map
[action
].offset
= offset
;
878 obj_df
[action
].dwOfs
= offset
;
879 offset
+= (type
& DIDFT_BUTTON
) ? 1 : 4;
885 IDirectInputDevice8_SetDataFormat(iface
, &data_format
);
887 HeapFree(GetProcessHeap(), 0, obj_df
);
889 /* Set the device properties according to the action format */
890 dpr
.diph
.dwSize
= sizeof(DIPROPRANGE
);
891 dpr
.lMin
= lpdiaf
->lAxisMin
;
892 dpr
.lMax
= lpdiaf
->lAxisMax
;
893 dpr
.diph
.dwHeaderSize
= sizeof(DIPROPHEADER
);
894 dpr
.diph
.dwHow
= DIPH_DEVICE
;
895 IDirectInputDevice8_SetProperty(iface
, DIPROP_RANGE
, &dpr
.diph
);
897 if (lpdiaf
->dwBufferSize
> 0)
899 dp
.diph
.dwSize
= sizeof(DIPROPDWORD
);
900 dp
.dwData
= lpdiaf
->dwBufferSize
;
901 dp
.diph
.dwHeaderSize
= sizeof(DIPROPHEADER
);
902 dp
.diph
.dwHow
= DIPH_DEVICE
;
903 IDirectInputDevice8_SetProperty(iface
, DIPROP_BUFFERSIZE
, &dp
.diph
);
906 /* Retrieve logged user name if necessary */
907 if (lpszUserName
== NULL
)
908 GetUserNameW(username
, &username_size
);
910 lstrcpynW(username
, lpszUserName
, MAX_PATH
);
912 dps
.diph
.dwSize
= sizeof(dps
);
913 dps
.diph
.dwHeaderSize
= sizeof(DIPROPHEADER
);
915 dps
.diph
.dwHow
= DIPH_DEVICE
;
916 if (dwFlags
& DIDSAM_NOUSER
)
919 lstrcpynW(dps
.wsz
, username
, ARRAY_SIZE(dps
.wsz
));
920 IDirectInputDevice8_SetProperty(iface
, DIPROP_USERNAME
, &dps
.diph
);
922 /* Save the settings to disk */
923 save_mapping_settings(iface
, lpdiaf
, username
);
928 /******************************************************************************
929 * queue_event - add new event to the ring queue
932 void queue_event(LPDIRECTINPUTDEVICE8A iface
, int inst_id
, DWORD data
, DWORD time
, DWORD seq
)
934 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
935 int next_pos
, ofs
= id_to_offset(&This
->data_format
, inst_id
);
937 /* Event is being set regardless of the queue state */
938 if (This
->hEvent
) SetEvent(This
->hEvent
);
940 PostMessageW(GetDesktopWindow(), WM_WINE_NOTIFY_ACTIVITY
, 0, 0);
942 if (!This
->queue_len
|| This
->overflow
|| ofs
< 0) return;
944 next_pos
= (This
->queue_head
+ 1) % This
->queue_len
;
945 if (next_pos
== This
->queue_tail
)
947 TRACE(" queue overflowed\n");
948 This
->overflow
= TRUE
;
952 TRACE(" queueing %d at offset %d (queue head %d / size %d)\n",
953 data
, ofs
, This
->queue_head
, This
->queue_len
);
955 This
->data_queue
[This
->queue_head
].dwOfs
= ofs
;
956 This
->data_queue
[This
->queue_head
].dwData
= data
;
957 This
->data_queue
[This
->queue_head
].dwTimeStamp
= time
;
958 This
->data_queue
[This
->queue_head
].dwSequence
= seq
;
960 /* Set uAppData by means of action mapping */
961 if (This
->num_actions
> 0)
964 for (i
=0; i
< This
->num_actions
; i
++)
966 if (This
->action_map
[i
].offset
== ofs
)
968 TRACE("Offset %d mapped to uAppData %lu\n", ofs
, This
->action_map
[i
].uAppData
);
969 This
->data_queue
[This
->queue_head
].uAppData
= This
->action_map
[i
].uAppData
;
975 This
->queue_head
= next_pos
;
976 /* Send event if asked */
979 /******************************************************************************
983 HRESULT WINAPI
IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface
)
985 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
988 TRACE("(%p)\n", This
);
990 if (!This
->data_format
.user_df
) return DIERR_INVALIDPARAM
;
991 if (This
->dwCoopLevel
& DISCL_FOREGROUND
&& This
->win
!= GetForegroundWindow())
992 return DIERR_OTHERAPPHASPRIO
;
994 EnterCriticalSection(&This
->crit
);
995 res
= This
->acquired
? S_FALSE
: DI_OK
;
997 LeaveCriticalSection(&This
->crit
);
999 check_dinput_hooks(iface
, TRUE
);
1004 HRESULT WINAPI
IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface
)
1006 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1007 return IDirectInputDevice2WImpl_Acquire(IDirectInputDevice8W_from_impl(This
));
1011 /******************************************************************************
1015 HRESULT WINAPI
IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface
)
1017 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1020 TRACE("(%p)\n", This
);
1022 EnterCriticalSection(&This
->crit
);
1023 res
= !This
->acquired
? DI_NOEFFECT
: DI_OK
;
1025 LeaveCriticalSection(&This
->crit
);
1027 check_dinput_hooks(iface
, FALSE
);
1032 HRESULT WINAPI
IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface
)
1034 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1035 return IDirectInputDevice2WImpl_Unacquire(IDirectInputDevice8W_from_impl(This
));
1038 /******************************************************************************
1039 * IDirectInputDeviceA
1042 HRESULT WINAPI
IDirectInputDevice2WImpl_SetDataFormat(LPDIRECTINPUTDEVICE8W iface
, LPCDIDATAFORMAT df
)
1044 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1045 HRESULT res
= DI_OK
;
1047 if (!df
) return E_POINTER
;
1048 TRACE("(%p) %p\n", This
, df
);
1049 _dump_DIDATAFORMAT(df
);
1051 if (df
->dwSize
!= sizeof(DIDATAFORMAT
)) return DIERR_INVALIDPARAM
;
1052 if (This
->acquired
) return DIERR_ACQUIRED
;
1054 EnterCriticalSection(&This
->crit
);
1056 release_DataFormat(&This
->data_format
);
1057 res
= create_DataFormat(df
, &This
->data_format
);
1059 LeaveCriticalSection(&This
->crit
);
1063 HRESULT WINAPI
IDirectInputDevice2AImpl_SetDataFormat(LPDIRECTINPUTDEVICE8A iface
, LPCDIDATAFORMAT df
)
1065 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1066 return IDirectInputDevice2WImpl_SetDataFormat(IDirectInputDevice8W_from_impl(This
), df
);
1069 /******************************************************************************
1070 * SetCooperativeLevel
1072 * Set cooperative level and the source window for the events.
1074 HRESULT WINAPI
IDirectInputDevice2WImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8W iface
, HWND hwnd
, DWORD dwflags
)
1076 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1078 TRACE("(%p) %p,0x%08x\n", This
, hwnd
, dwflags
);
1079 _dump_cooperativelevel_DI(dwflags
);
1081 if ((dwflags
& (DISCL_EXCLUSIVE
| DISCL_NONEXCLUSIVE
)) == 0 ||
1082 (dwflags
& (DISCL_EXCLUSIVE
| DISCL_NONEXCLUSIVE
)) == (DISCL_EXCLUSIVE
| DISCL_NONEXCLUSIVE
) ||
1083 (dwflags
& (DISCL_FOREGROUND
| DISCL_BACKGROUND
)) == 0 ||
1084 (dwflags
& (DISCL_FOREGROUND
| DISCL_BACKGROUND
)) == (DISCL_FOREGROUND
| DISCL_BACKGROUND
))
1085 return DIERR_INVALIDPARAM
;
1087 if (hwnd
&& GetWindowLongW(hwnd
, GWL_STYLE
) & WS_CHILD
) return E_HANDLE
;
1089 if (!hwnd
&& dwflags
== (DISCL_NONEXCLUSIVE
| DISCL_BACKGROUND
))
1090 hwnd
= GetDesktopWindow();
1092 if (!IsWindow(hwnd
)) return E_HANDLE
;
1094 /* For security reasons native does not allow exclusive background level
1095 for mouse and keyboard only */
1096 if (dwflags
& DISCL_EXCLUSIVE
&& dwflags
& DISCL_BACKGROUND
&&
1097 (IsEqualGUID(&This
->guid
, &GUID_SysMouse
) ||
1098 IsEqualGUID(&This
->guid
, &GUID_SysKeyboard
)))
1099 return DIERR_UNSUPPORTED
;
1101 /* Store the window which asks for the mouse */
1102 EnterCriticalSection(&This
->crit
);
1104 This
->dwCoopLevel
= dwflags
;
1105 LeaveCriticalSection(&This
->crit
);
1110 HRESULT WINAPI
IDirectInputDevice2AImpl_SetCooperativeLevel(LPDIRECTINPUTDEVICE8A iface
, HWND hwnd
, DWORD dwflags
)
1112 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1113 return IDirectInputDevice2WImpl_SetCooperativeLevel(IDirectInputDevice8W_from_impl(This
), hwnd
, dwflags
);
1116 /******************************************************************************
1117 * SetEventNotification : specifies event to be sent on state change
1119 HRESULT WINAPI
IDirectInputDevice2WImpl_SetEventNotification(LPDIRECTINPUTDEVICE8W iface
, HANDLE event
)
1121 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1123 TRACE("(%p) %p\n", This
, event
);
1125 EnterCriticalSection(&This
->crit
);
1126 This
->hEvent
= event
;
1127 LeaveCriticalSection(&This
->crit
);
1131 HRESULT WINAPI
IDirectInputDevice2AImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface
, HANDLE event
)
1133 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1134 return IDirectInputDevice2WImpl_SetEventNotification(IDirectInputDevice8W_from_impl(This
), event
);
1138 ULONG WINAPI
IDirectInputDevice2WImpl_Release(LPDIRECTINPUTDEVICE8W iface
)
1140 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1141 ULONG ref
= InterlockedDecrement(&(This
->ref
));
1143 TRACE("(%p) ref %d\n", This
, ref
);
1145 if (ref
) return ref
;
1147 IDirectInputDevice_Unacquire(iface
);
1148 /* Reset the FF state, free all effects, etc */
1149 IDirectInputDevice8_SendForceFeedbackCommand(iface
, DISFFC_RESET
);
1151 HeapFree(GetProcessHeap(), 0, This
->data_queue
);
1153 /* Free data format */
1154 HeapFree(GetProcessHeap(), 0, This
->data_format
.wine_df
->rgodf
);
1155 HeapFree(GetProcessHeap(), 0, This
->data_format
.wine_df
);
1156 release_DataFormat(&This
->data_format
);
1158 /* Free action mapping */
1159 HeapFree(GetProcessHeap(), 0, This
->action_map
);
1161 EnterCriticalSection( &This
->dinput
->crit
);
1162 list_remove( &This
->entry
);
1163 LeaveCriticalSection( &This
->dinput
->crit
);
1165 IDirectInput_Release(&This
->dinput
->IDirectInput7A_iface
);
1166 This
->crit
.DebugInfo
->Spare
[0] = 0;
1167 DeleteCriticalSection(&This
->crit
);
1169 HeapFree(GetProcessHeap(), 0, This
);
1174 ULONG WINAPI
IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface
)
1176 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1177 return IDirectInputDevice2WImpl_Release(IDirectInputDevice8W_from_impl(This
));
1180 HRESULT WINAPI
IDirectInputDevice2WImpl_QueryInterface(LPDIRECTINPUTDEVICE8W iface
, REFIID riid
, LPVOID
*ppobj
)
1182 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1184 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(riid
), ppobj
);
1185 if (IsEqualGUID(&IID_IUnknown
, riid
) ||
1186 IsEqualGUID(&IID_IDirectInputDeviceA
, riid
) ||
1187 IsEqualGUID(&IID_IDirectInputDevice2A
, riid
) ||
1188 IsEqualGUID(&IID_IDirectInputDevice7A
, riid
) ||
1189 IsEqualGUID(&IID_IDirectInputDevice8A
, riid
))
1191 IDirectInputDevice2_AddRef(iface
);
1192 *ppobj
= IDirectInputDevice8A_from_impl(This
);
1195 if (IsEqualGUID(&IID_IDirectInputDeviceW
, riid
) ||
1196 IsEqualGUID(&IID_IDirectInputDevice2W
, riid
) ||
1197 IsEqualGUID(&IID_IDirectInputDevice7W
, riid
) ||
1198 IsEqualGUID(&IID_IDirectInputDevice8W
, riid
))
1200 IDirectInputDevice2_AddRef(iface
);
1201 *ppobj
= IDirectInputDevice8W_from_impl(This
);
1205 WARN("Unsupported interface!\n");
1206 return E_NOINTERFACE
;
1209 HRESULT WINAPI
IDirectInputDevice2AImpl_QueryInterface(LPDIRECTINPUTDEVICE8A iface
, REFIID riid
, LPVOID
*ppobj
)
1211 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1212 return IDirectInputDevice2WImpl_QueryInterface(IDirectInputDevice8W_from_impl(This
), riid
, ppobj
);
1215 ULONG WINAPI
IDirectInputDevice2WImpl_AddRef(LPDIRECTINPUTDEVICE8W iface
)
1217 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1218 ULONG ref
= InterlockedIncrement(&This
->ref
);
1219 TRACE( "(%p) ref %d\n", This
, ref
);
1223 ULONG WINAPI
IDirectInputDevice2AImpl_AddRef(LPDIRECTINPUTDEVICE8A iface
)
1225 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1226 return IDirectInputDevice2WImpl_AddRef(IDirectInputDevice8W_from_impl(This
));
1229 HRESULT WINAPI
IDirectInputDevice2AImpl_EnumObjects(LPDIRECTINPUTDEVICE8A iface
,
1230 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback
, LPVOID lpvRef
, DWORD dwFlags
)
1232 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1233 DIDEVICEOBJECTINSTANCEA ddoi
;
1236 TRACE("(%p)->(%p,%p flags:%08x)\n", This
, lpCallback
, lpvRef
, dwFlags
);
1237 TRACE(" - flags = ");
1238 _dump_EnumObjects_flags(dwFlags
);
1241 /* Only the fields till dwFFMaxForce are relevant */
1242 memset(&ddoi
, 0, sizeof(ddoi
));
1243 ddoi
.dwSize
= FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA
, dwFFMaxForce
);
1245 for (i
= 0; i
< This
->data_format
.wine_df
->dwNumObjs
; i
++)
1247 LPDIOBJECTDATAFORMAT odf
= dataformat_to_odf(This
->data_format
.wine_df
, i
);
1249 if (dwFlags
!= DIDFT_ALL
&& !(dwFlags
& DIDFT_GETTYPE(odf
->dwType
))) continue;
1250 if (IDirectInputDevice_GetObjectInfo(iface
, &ddoi
, odf
->dwType
, DIPH_BYID
) != DI_OK
)
1253 if (lpCallback(&ddoi
, lpvRef
) != DIENUM_CONTINUE
) break;
1259 HRESULT WINAPI
IDirectInputDevice2WImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface
,
1260 LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback
, LPVOID lpvRef
, DWORD dwFlags
)
1262 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1263 DIDEVICEOBJECTINSTANCEW ddoi
;
1266 TRACE("(%p)->(%p,%p flags:%08x)\n", This
, lpCallback
, lpvRef
, dwFlags
);
1267 TRACE(" - flags = ");
1268 _dump_EnumObjects_flags(dwFlags
);
1271 /* Only the fields till dwFFMaxForce are relevant */
1272 memset(&ddoi
, 0, sizeof(ddoi
));
1273 ddoi
.dwSize
= FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW
, dwFFMaxForce
);
1275 for (i
= 0; i
< This
->data_format
.wine_df
->dwNumObjs
; i
++)
1277 LPDIOBJECTDATAFORMAT odf
= dataformat_to_odf(This
->data_format
.wine_df
, i
);
1279 if (dwFlags
!= DIDFT_ALL
&& !(dwFlags
& DIDFT_GETTYPE(odf
->dwType
))) continue;
1280 if (IDirectInputDevice_GetObjectInfo(iface
, &ddoi
, odf
->dwType
, DIPH_BYID
) != DI_OK
)
1283 if (lpCallback(&ddoi
, lpvRef
) != DIENUM_CONTINUE
) break;
1289 /******************************************************************************
1293 HRESULT WINAPI
IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface
, REFGUID rguid
, LPDIPROPHEADER pdiph
)
1295 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1297 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(rguid
), pdiph
);
1298 _dump_DIPROPHEADER(pdiph
);
1300 if (!IS_DIPROP(rguid
)) return DI_OK
;
1302 switch (LOWORD(rguid
))
1304 case (DWORD_PTR
) DIPROP_BUFFERSIZE
:
1306 LPDIPROPDWORD pd
= (LPDIPROPDWORD
)pdiph
;
1308 if (pdiph
->dwSize
!= sizeof(DIPROPDWORD
)) return DIERR_INVALIDPARAM
;
1310 pd
->dwData
= This
->queue_len
;
1311 TRACE("buffersize = %d\n", pd
->dwData
);
1314 case (DWORD_PTR
) DIPROP_USERNAME
:
1316 LPDIPROPSTRING ps
= (LPDIPROPSTRING
)pdiph
;
1317 struct DevicePlayer
*device_player
;
1319 if (pdiph
->dwSize
!= sizeof(DIPROPSTRING
)) return DIERR_INVALIDPARAM
;
1321 LIST_FOR_EACH_ENTRY(device_player
, &This
->dinput
->device_players
,
1322 struct DevicePlayer
, entry
)
1324 if (IsEqualGUID(&device_player
->instance_guid
, &This
->guid
))
1326 if (*device_player
->username
)
1328 lstrcpynW(ps
->wsz
, device_player
->username
, ARRAY_SIZE(ps
->wsz
));
1336 case (DWORD_PTR
) DIPROP_VIDPID
:
1337 FIXME("DIPROP_VIDPID not implemented\n");
1338 return DIERR_UNSUPPORTED
;
1340 FIXME("Unknown property %s\n", debugstr_guid(rguid
));
1341 return DIERR_INVALIDPARAM
;
1347 HRESULT WINAPI
IDirectInputDevice2AImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface
, REFGUID rguid
, LPDIPROPHEADER pdiph
)
1349 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1350 return IDirectInputDevice2WImpl_GetProperty(IDirectInputDevice8W_from_impl(This
), rguid
, pdiph
);
1353 /******************************************************************************
1357 HRESULT WINAPI
IDirectInputDevice2WImpl_SetProperty(
1358 LPDIRECTINPUTDEVICE8W iface
, REFGUID rguid
, LPCDIPROPHEADER pdiph
)
1360 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1362 TRACE("(%p)->(%s,%p)\n", This
, debugstr_guid(rguid
), pdiph
);
1363 _dump_DIPROPHEADER(pdiph
);
1365 if (!IS_DIPROP(rguid
)) return DI_OK
;
1367 switch (LOWORD(rguid
))
1369 case (DWORD_PTR
) DIPROP_AXISMODE
:
1371 LPCDIPROPDWORD pd
= (LPCDIPROPDWORD
)pdiph
;
1373 if (pdiph
->dwSize
!= sizeof(DIPROPDWORD
)) return DIERR_INVALIDPARAM
;
1374 if (pdiph
->dwHow
== DIPH_DEVICE
&& pdiph
->dwObj
) return DIERR_INVALIDPARAM
;
1375 if (This
->acquired
) return DIERR_ACQUIRED
;
1376 if (pdiph
->dwHow
!= DIPH_DEVICE
) return DIERR_UNSUPPORTED
;
1377 if (!This
->data_format
.user_df
) return DI_OK
;
1379 TRACE("Axis mode: %s\n", pd
->dwData
== DIPROPAXISMODE_ABS
? "absolute" :
1382 EnterCriticalSection(&This
->crit
);
1383 This
->data_format
.user_df
->dwFlags
&= ~DIDFT_AXIS
;
1384 This
->data_format
.user_df
->dwFlags
|= pd
->dwData
== DIPROPAXISMODE_ABS
?
1385 DIDF_ABSAXIS
: DIDF_RELAXIS
;
1386 LeaveCriticalSection(&This
->crit
);
1389 case (DWORD_PTR
) DIPROP_BUFFERSIZE
:
1391 LPCDIPROPDWORD pd
= (LPCDIPROPDWORD
)pdiph
;
1393 if (pdiph
->dwSize
!= sizeof(DIPROPDWORD
)) return DIERR_INVALIDPARAM
;
1394 if (This
->acquired
) return DIERR_ACQUIRED
;
1396 TRACE("buffersize = %d\n", pd
->dwData
);
1398 EnterCriticalSection(&This
->crit
);
1399 HeapFree(GetProcessHeap(), 0, This
->data_queue
);
1401 This
->data_queue
= !pd
->dwData
? NULL
: HeapAlloc(GetProcessHeap(), 0,
1402 pd
->dwData
* sizeof(DIDEVICEOBJECTDATA
));
1403 This
->queue_head
= This
->queue_tail
= This
->overflow
= 0;
1404 This
->queue_len
= pd
->dwData
;
1406 LeaveCriticalSection(&This
->crit
);
1409 case (DWORD_PTR
) DIPROP_USERNAME
:
1411 LPCDIPROPSTRING ps
= (LPCDIPROPSTRING
)pdiph
;
1412 struct DevicePlayer
*device_player
;
1415 if (pdiph
->dwSize
!= sizeof(DIPROPSTRING
)) return DIERR_INVALIDPARAM
;
1417 LIST_FOR_EACH_ENTRY(device_player
, &This
->dinput
->device_players
,
1418 struct DevicePlayer
, entry
)
1420 if (IsEqualGUID(&device_player
->instance_guid
, &This
->guid
))
1426 if (!found
&& (device_player
=
1427 HeapAlloc(GetProcessHeap(), 0, sizeof(struct DevicePlayer
))))
1429 list_add_tail(&This
->dinput
->device_players
, &device_player
->entry
);
1430 device_player
->instance_guid
= This
->guid
;
1433 lstrcpynW(device_player
->username
, ps
->wsz
, ARRAY_SIZE(device_player
->username
));
1437 WARN("Unknown property %s\n", debugstr_guid(rguid
));
1438 return DIERR_UNSUPPORTED
;
1444 HRESULT WINAPI
IDirectInputDevice2AImpl_SetProperty(
1445 LPDIRECTINPUTDEVICE8A iface
, REFGUID rguid
, LPCDIPROPHEADER pdiph
)
1447 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1448 return IDirectInputDevice2WImpl_SetProperty(IDirectInputDevice8W_from_impl(This
), rguid
, pdiph
);
1451 HRESULT WINAPI
IDirectInputDevice2AImpl_GetObjectInfo(
1452 LPDIRECTINPUTDEVICE8A iface
,
1453 LPDIDEVICEOBJECTINSTANCEA pdidoi
,
1457 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1458 DIDEVICEOBJECTINSTANCEW didoiW
;
1462 (pdidoi
->dwSize
!= sizeof(DIDEVICEOBJECTINSTANCEA
) &&
1463 pdidoi
->dwSize
!= sizeof(DIDEVICEOBJECTINSTANCE_DX3A
)))
1464 return DIERR_INVALIDPARAM
;
1466 didoiW
.dwSize
= sizeof(didoiW
);
1467 res
= IDirectInputDevice2WImpl_GetObjectInfo(IDirectInputDevice8W_from_impl(This
), &didoiW
, dwObj
, dwHow
);
1470 DWORD dwSize
= pdidoi
->dwSize
;
1472 memset(pdidoi
, 0, pdidoi
->dwSize
);
1473 pdidoi
->dwSize
= dwSize
;
1474 pdidoi
->guidType
= didoiW
.guidType
;
1475 pdidoi
->dwOfs
= didoiW
.dwOfs
;
1476 pdidoi
->dwType
= didoiW
.dwType
;
1477 pdidoi
->dwFlags
= didoiW
.dwFlags
;
1483 HRESULT WINAPI
IDirectInputDevice2WImpl_GetObjectInfo(
1484 LPDIRECTINPUTDEVICE8W iface
,
1485 LPDIDEVICEOBJECTINSTANCEW pdidoi
,
1489 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1491 LPDIOBJECTDATAFORMAT odf
;
1494 TRACE("(%p) %d(0x%08x) -> %p\n", This
, dwHow
, dwObj
, pdidoi
);
1497 (pdidoi
->dwSize
!= sizeof(DIDEVICEOBJECTINSTANCEW
) &&
1498 pdidoi
->dwSize
!= sizeof(DIDEVICEOBJECTINSTANCE_DX3W
)))
1499 return DIERR_INVALIDPARAM
;
1504 if (!This
->data_format
.offsets
) break;
1505 for (idx
= This
->data_format
.wine_df
->dwNumObjs
- 1; idx
>= 0; idx
--)
1506 if (This
->data_format
.offsets
[idx
] == dwObj
) break;
1509 dwObj
&= 0x00ffffff;
1510 for (idx
= This
->data_format
.wine_df
->dwNumObjs
- 1; idx
>= 0; idx
--)
1511 if ((dataformat_to_odf(This
->data_format
.wine_df
, idx
)->dwType
& 0x00ffffff) == dwObj
)
1516 FIXME("dwHow = DIPH_BYUSAGE not implemented\n");
1519 WARN("invalid parameter: dwHow = %08x\n", dwHow
);
1520 return DIERR_INVALIDPARAM
;
1522 if (idx
< 0) return DIERR_OBJECTNOTFOUND
;
1524 odf
= dataformat_to_odf(This
->data_format
.wine_df
, idx
);
1525 dwSize
= pdidoi
->dwSize
; /* save due to memset below */
1526 memset(pdidoi
, 0, pdidoi
->dwSize
);
1527 pdidoi
->dwSize
= dwSize
;
1528 if (odf
->pguid
) pdidoi
->guidType
= *odf
->pguid
;
1529 pdidoi
->dwOfs
= This
->data_format
.offsets
? This
->data_format
.offsets
[idx
] : odf
->dwOfs
;
1530 pdidoi
->dwType
= odf
->dwType
;
1531 pdidoi
->dwFlags
= odf
->dwFlags
;
1536 HRESULT WINAPI
IDirectInputDevice2WImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W iface
, DWORD dodsize
,
1537 LPDIDEVICEOBJECTDATA dod
, LPDWORD entries
, DWORD flags
)
1539 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1540 HRESULT ret
= DI_OK
;
1543 TRACE("(%p) %p -> %p(%d) x%d, 0x%08x\n",
1544 This
, dod
, entries
, entries
? *entries
: 0, dodsize
, flags
);
1546 if (This
->dinput
->dwVersion
== 0x0800 || dodsize
== sizeof(DIDEVICEOBJECTDATA_DX3
))
1548 if (!This
->queue_len
) return DIERR_NOTBUFFERED
;
1549 if (!This
->acquired
) return DIERR_NOTACQUIRED
;
1552 if (!This
->queue_len
)
1554 if (dodsize
< sizeof(DIDEVICEOBJECTDATA_DX3
))
1555 return DIERR_INVALIDPARAM
;
1557 IDirectInputDevice2_Poll(iface
);
1558 EnterCriticalSection(&This
->crit
);
1560 len
= This
->queue_head
- This
->queue_tail
;
1561 if (len
< 0) len
+= This
->queue_len
;
1563 if ((*entries
!= INFINITE
) && (len
> *entries
)) len
= *entries
;
1568 for (i
= 0; i
< len
; i
++)
1570 int n
= (This
->queue_tail
+ i
) % This
->queue_len
;
1571 memcpy((char *)dod
+ dodsize
* i
, This
->data_queue
+ n
, dodsize
);
1576 if (This
->overflow
&& This
->dinput
->dwVersion
== 0x0800)
1577 ret
= DI_BUFFEROVERFLOW
;
1579 if (!(flags
& DIGDD_PEEK
))
1581 /* Advance reading position */
1582 This
->queue_tail
= (This
->queue_tail
+ len
) % This
->queue_len
;
1583 This
->overflow
= FALSE
;
1586 LeaveCriticalSection(&This
->crit
);
1588 TRACE("Returning %d events queued\n", *entries
);
1592 HRESULT WINAPI
IDirectInputDevice2AImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface
, DWORD dodsize
,
1593 LPDIDEVICEOBJECTDATA dod
, LPDWORD entries
, DWORD flags
)
1595 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1596 return IDirectInputDevice2WImpl_GetDeviceData(IDirectInputDevice8W_from_impl(This
), dodsize
, dod
, entries
, flags
);
1599 HRESULT WINAPI
IDirectInputDevice2WImpl_RunControlPanel(LPDIRECTINPUTDEVICE8W iface
, HWND hwndOwner
, DWORD dwFlags
)
1601 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1602 FIXME("%p)->(%p,0x%08x): stub!\n", This
, hwndOwner
, dwFlags
);
1607 HRESULT WINAPI
IDirectInputDevice2AImpl_RunControlPanel(LPDIRECTINPUTDEVICE8A iface
, HWND hwndOwner
, DWORD dwFlags
)
1609 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1610 return IDirectInputDevice2WImpl_RunControlPanel(IDirectInputDevice8W_from_impl(This
), hwndOwner
, dwFlags
);
1613 HRESULT WINAPI
IDirectInputDevice2WImpl_Initialize(LPDIRECTINPUTDEVICE8W iface
, HINSTANCE hinst
, DWORD dwVersion
,
1616 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1617 FIXME("(%p)->(%p,%d,%s): stub!\n", This
, hinst
, dwVersion
, debugstr_guid(rguid
));
1621 HRESULT WINAPI
IDirectInputDevice2AImpl_Initialize(LPDIRECTINPUTDEVICE8A iface
, HINSTANCE hinst
, DWORD dwVersion
,
1624 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1625 return IDirectInputDevice2WImpl_Initialize(IDirectInputDevice8W_from_impl(This
), hinst
, dwVersion
, rguid
);
1628 /******************************************************************************
1629 * IDirectInputDevice2A
1632 HRESULT WINAPI
IDirectInputDevice2WImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface
, REFGUID rguid
, LPCDIEFFECT lpeff
,
1633 LPDIRECTINPUTEFFECT
*ppdef
, LPUNKNOWN pUnkOuter
)
1635 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1636 FIXME("(%p)->(%s,%p,%p,%p): stub!\n", This
, debugstr_guid(rguid
), lpeff
, ppdef
, pUnkOuter
);
1638 FIXME("not available in the generic implementation\n");
1640 return DIERR_UNSUPPORTED
;
1643 HRESULT WINAPI
IDirectInputDevice2AImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface
, REFGUID rguid
, LPCDIEFFECT lpeff
,
1644 LPDIRECTINPUTEFFECT
*ppdef
, LPUNKNOWN pUnkOuter
)
1646 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1647 return IDirectInputDevice2WImpl_CreateEffect(IDirectInputDevice8W_from_impl(This
), rguid
, lpeff
, ppdef
, pUnkOuter
);
1650 HRESULT WINAPI
IDirectInputDevice2AImpl_EnumEffects(
1651 LPDIRECTINPUTDEVICE8A iface
,
1652 LPDIENUMEFFECTSCALLBACKA lpCallback
,
1656 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1657 FIXME("%p)->(%p,%p,0x%08x): stub!\n", This
, lpCallback
, lpvRef
, dwFlags
);
1662 HRESULT WINAPI
IDirectInputDevice2WImpl_EnumEffects(
1663 LPDIRECTINPUTDEVICE8W iface
,
1664 LPDIENUMEFFECTSCALLBACKW lpCallback
,
1668 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1669 FIXME("(%p)->(%p,%p,0x%08x): stub!\n", This
, lpCallback
, lpvRef
, dwFlags
);
1674 HRESULT WINAPI
IDirectInputDevice2AImpl_GetEffectInfo(
1675 LPDIRECTINPUTDEVICE8A iface
,
1676 LPDIEFFECTINFOA lpdei
,
1679 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1680 FIXME("(%p)->(%p,%s): stub!\n", This
, lpdei
, debugstr_guid(rguid
));
1684 HRESULT WINAPI
IDirectInputDevice2WImpl_GetEffectInfo(
1685 LPDIRECTINPUTDEVICE8W iface
,
1686 LPDIEFFECTINFOW lpdei
,
1689 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1690 FIXME("(%p)->(%p,%s): stub!\n", This
, lpdei
, debugstr_guid(rguid
));
1694 HRESULT WINAPI
IDirectInputDevice2WImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8W iface
, LPDWORD pdwOut
)
1696 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1697 FIXME("(%p)->(%p): stub!\n", This
, pdwOut
);
1701 HRESULT WINAPI
IDirectInputDevice2AImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8A iface
, LPDWORD pdwOut
)
1703 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1704 return IDirectInputDevice2WImpl_GetForceFeedbackState(IDirectInputDevice8W_from_impl(This
), pdwOut
);
1707 HRESULT WINAPI
IDirectInputDevice2WImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface
, DWORD dwFlags
)
1709 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1710 TRACE("(%p)->(0x%08x)\n", This
, dwFlags
);
1714 HRESULT WINAPI
IDirectInputDevice2AImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8A iface
, DWORD dwFlags
)
1716 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1717 return IDirectInputDevice2WImpl_SendForceFeedbackCommand(IDirectInputDevice8W_from_impl(This
), dwFlags
);
1720 HRESULT WINAPI
IDirectInputDevice2WImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8W iface
,
1721 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback
, LPVOID lpvRef
, DWORD dwFlags
)
1723 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1724 FIXME("(%p)0>(%p,%p,0x%08x): stub!\n", This
, lpCallback
, lpvRef
, dwFlags
);
1728 HRESULT WINAPI
IDirectInputDevice2AImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8A iface
,
1729 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback
, LPVOID lpvRef
, DWORD dwFlags
)
1731 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1732 return IDirectInputDevice2WImpl_EnumCreatedEffectObjects(IDirectInputDevice8W_from_impl(This
), lpCallback
, lpvRef
, dwFlags
);
1735 HRESULT WINAPI
IDirectInputDevice2WImpl_Escape(LPDIRECTINPUTDEVICE8W iface
, LPDIEFFESCAPE lpDIEEsc
)
1737 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1738 FIXME("(%p)->(%p): stub!\n", This
, lpDIEEsc
);
1742 HRESULT WINAPI
IDirectInputDevice2AImpl_Escape(LPDIRECTINPUTDEVICE8A iface
, LPDIEFFESCAPE lpDIEEsc
)
1744 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1745 return IDirectInputDevice2WImpl_Escape(IDirectInputDevice8W_from_impl(This
), lpDIEEsc
);
1748 HRESULT WINAPI
IDirectInputDevice2WImpl_Poll(LPDIRECTINPUTDEVICE8W iface
)
1750 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1752 if (!This
->acquired
) return DIERR_NOTACQUIRED
;
1754 check_dinput_events();
1758 HRESULT WINAPI
IDirectInputDevice2AImpl_Poll(LPDIRECTINPUTDEVICE8A iface
)
1760 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1761 return IDirectInputDevice2WImpl_Poll(IDirectInputDevice8W_from_impl(This
));
1764 HRESULT WINAPI
IDirectInputDevice2WImpl_SendDeviceData(LPDIRECTINPUTDEVICE8W iface
, DWORD cbObjectData
,
1765 LPCDIDEVICEOBJECTDATA rgdod
, LPDWORD pdwInOut
,
1768 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1769 FIXME("(%p)->(0x%08x,%p,%p,0x%08x): stub!\n", This
, cbObjectData
, rgdod
, pdwInOut
, dwFlags
);
1774 HRESULT WINAPI
IDirectInputDevice2AImpl_SendDeviceData(LPDIRECTINPUTDEVICE8A iface
, DWORD cbObjectData
,
1775 LPCDIDEVICEOBJECTDATA rgdod
, LPDWORD pdwInOut
,
1778 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1779 return IDirectInputDevice2WImpl_SendDeviceData(IDirectInputDevice8W_from_impl(This
), cbObjectData
, rgdod
,
1783 HRESULT WINAPI
IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface
,
1784 LPCSTR lpszFileName
,
1785 LPDIENUMEFFECTSINFILECALLBACK pec
,
1789 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1790 FIXME("(%p)->(%s,%p,%p,%08x): stub !\n", This
, lpszFileName
, pec
, pvRef
, dwFlags
);
1795 HRESULT WINAPI
IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface
,
1796 LPCWSTR lpszFileName
,
1797 LPDIENUMEFFECTSINFILECALLBACK pec
,
1801 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1802 FIXME("(%p)->(%s,%p,%p,%08x): stub !\n", This
, debugstr_w(lpszFileName
), pec
, pvRef
, dwFlags
);
1807 HRESULT WINAPI
IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface
,
1808 LPCSTR lpszFileName
,
1810 LPDIFILEEFFECT rgDiFileEft
,
1813 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1814 FIXME("(%p)->(%s,%08x,%p,%08x): stub !\n", This
, lpszFileName
, dwEntries
, rgDiFileEft
, dwFlags
);
1819 HRESULT WINAPI
IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface
,
1820 LPCWSTR lpszFileName
,
1822 LPDIFILEEFFECT rgDiFileEft
,
1825 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1826 FIXME("(%p)->(%s,%08x,%p,%08x): stub !\n", This
, debugstr_w(lpszFileName
), dwEntries
, rgDiFileEft
, dwFlags
);
1831 HRESULT WINAPI
IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface
,
1832 LPDIACTIONFORMATW lpdiaf
,
1833 LPCWSTR lpszUserName
,
1836 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1837 FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", This
, lpdiaf
, debugstr_w(lpszUserName
), dwFlags
);
1838 #define X(x) if (dwFlags & x) FIXME("\tdwFlags =|"#x"\n");
1841 X(DIDBAM_INITIALIZE
)
1842 X(DIDBAM_HWDEFAULTS
)
1848 HRESULT WINAPI
IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface
,
1849 LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader
)
1851 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8A(iface
);
1852 FIXME("(%p)->(%p): stub !\n", This
, lpdiDevImageInfoHeader
);
1857 HRESULT WINAPI
IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface
,
1858 LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader
)
1860 IDirectInputDeviceImpl
*This
= impl_from_IDirectInputDevice8W(iface
);
1861 FIXME("(%p)->(%p): stub !\n", This
, lpdiDevImageInfoHeader
);