dinput: Move get_config_key to a common place.
[wine/wine-jacek.git] / dlls / dinput / device.c
blobd1c94fc6de115b6d03c7019f57d74b0b92c45872
1 /* DirectInput Device
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.
27 #include "config.h"
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 "winreg.h"
36 #include "winuser.h"
37 #include "winerror.h"
38 #include "dinput.h"
39 #include "device_private.h"
40 #include "dinput_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
44 /******************************************************************************
45 * Various debugging tools
47 void _dump_cooperativelevel_DI(DWORD dwFlags) {
48 if (TRACE_ON(dinput)) {
49 unsigned int i;
50 static const struct {
51 DWORD mask;
52 const char *name;
53 } flags[] = {
54 #define FE(x) { x, #x}
55 FE(DISCL_BACKGROUND),
56 FE(DISCL_EXCLUSIVE),
57 FE(DISCL_FOREGROUND),
58 FE(DISCL_NONEXCLUSIVE),
59 FE(DISCL_NOWINKEY)
60 #undef FE
62 for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
63 if (flags[i].mask & dwFlags)
64 DPRINTF("%s ",flags[i].name);
65 DPRINTF("\n");
69 void _dump_EnumObjects_flags(DWORD dwFlags) {
70 if (TRACE_ON(dinput)) {
71 unsigned int i;
72 DWORD type, instance;
73 static const struct {
74 DWORD mask;
75 const char *name;
76 } flags[] = {
77 #define FE(x) { x, #x}
78 FE(DIDFT_RELAXIS),
79 FE(DIDFT_ABSAXIS),
80 FE(DIDFT_PSHBUTTON),
81 FE(DIDFT_TGLBUTTON),
82 FE(DIDFT_POV),
83 FE(DIDFT_COLLECTION),
84 FE(DIDFT_NODATA),
85 FE(DIDFT_FFACTUATOR),
86 FE(DIDFT_FFEFFECTTRIGGER),
87 FE(DIDFT_OUTPUT),
88 FE(DIDFT_VENDORDEFINED),
89 FE(DIDFT_ALIAS),
90 FE(DIDFT_OPTIONAL)
91 #undef FE
93 type = (dwFlags & 0xFF0000FF);
94 instance = ((dwFlags >> 8) & 0xFFFF);
95 DPRINTF("Type:");
96 if (type == DIDFT_ALL) {
97 DPRINTF(" DIDFT_ALL");
98 } else {
99 for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++) {
100 if (flags[i].mask & type) {
101 type &= ~flags[i].mask;
102 DPRINTF(" %s",flags[i].name);
105 if (type) {
106 DPRINTF(" (unhandled: %08x)", type);
109 DPRINTF(" / Instance: ");
110 if (instance == ((DIDFT_ANYINSTANCE >> 8) & 0xFFFF)) {
111 DPRINTF("DIDFT_ANYINSTANCE");
112 } else {
113 DPRINTF("%3d", instance);
118 void _dump_DIPROPHEADER(LPCDIPROPHEADER diph) {
119 if (TRACE_ON(dinput)) {
120 DPRINTF(" - dwObj = 0x%08x\n", diph->dwObj);
121 DPRINTF(" - dwHow = %s\n",
122 ((diph->dwHow == DIPH_DEVICE) ? "DIPH_DEVICE" :
123 ((diph->dwHow == DIPH_BYOFFSET) ? "DIPH_BYOFFSET" :
124 ((diph->dwHow == DIPH_BYID)) ? "DIPH_BYID" : "unknown")));
128 void _dump_OBJECTINSTANCEA(const DIDEVICEOBJECTINSTANCEA *ddoi) {
129 if (TRACE_ON(dinput)) {
130 DPRINTF(" - enumerating : %s ('%s') - %2d - 0x%08x - %s\n",
131 debugstr_guid(&ddoi->guidType), _dump_dinput_GUID(&ddoi->guidType), ddoi->dwOfs, ddoi->dwType, ddoi->tszName);
135 void _dump_OBJECTINSTANCEW(const DIDEVICEOBJECTINSTANCEW *ddoi) {
136 if (TRACE_ON(dinput)) {
137 DPRINTF(" - enumerating : %s ('%s'), - %2d - 0x%08x - %s\n",
138 debugstr_guid(&ddoi->guidType), _dump_dinput_GUID(&ddoi->guidType), ddoi->dwOfs, ddoi->dwType, debugstr_w(ddoi->tszName));
142 /* This function is a helper to convert a GUID into any possible DInput GUID out there */
143 const char *_dump_dinput_GUID(const GUID *guid) {
144 unsigned int i;
145 static const struct {
146 const GUID *guid;
147 const char *name;
148 } guids[] = {
149 #define FE(x) { &x, #x}
150 FE(GUID_XAxis),
151 FE(GUID_YAxis),
152 FE(GUID_ZAxis),
153 FE(GUID_RxAxis),
154 FE(GUID_RyAxis),
155 FE(GUID_RzAxis),
156 FE(GUID_Slider),
157 FE(GUID_Button),
158 FE(GUID_Key),
159 FE(GUID_POV),
160 FE(GUID_Unknown),
161 FE(GUID_SysMouse),
162 FE(GUID_SysKeyboard),
163 FE(GUID_Joystick),
164 FE(GUID_ConstantForce),
165 FE(GUID_RampForce),
166 FE(GUID_Square),
167 FE(GUID_Sine),
168 FE(GUID_Triangle),
169 FE(GUID_SawtoothUp),
170 FE(GUID_SawtoothDown),
171 FE(GUID_Spring),
172 FE(GUID_Damper),
173 FE(GUID_Inertia),
174 FE(GUID_Friction),
175 FE(GUID_CustomForce)
176 #undef FE
178 if (guid == NULL)
179 return "null GUID";
180 for (i = 0; i < (sizeof(guids) / sizeof(guids[0])); i++) {
181 if (IsEqualGUID(guids[i].guid, guid)) {
182 return guids[i].name;
185 return "Unknown GUID";
188 void _dump_DIDATAFORMAT(const DIDATAFORMAT *df) {
189 unsigned int i;
191 TRACE("Dumping DIDATAFORMAT structure:\n");
192 TRACE(" - dwSize: %d\n", df->dwSize);
193 if (df->dwSize != sizeof(DIDATAFORMAT)) {
194 WARN("Non-standard DIDATAFORMAT structure size %d\n", df->dwSize);
196 TRACE(" - dwObjsize: %d\n", df->dwObjSize);
197 if (df->dwObjSize != sizeof(DIOBJECTDATAFORMAT)) {
198 WARN("Non-standard DIOBJECTDATAFORMAT structure size %d\n", df->dwObjSize);
200 TRACE(" - dwFlags: 0x%08x (", df->dwFlags);
201 switch (df->dwFlags) {
202 case DIDF_ABSAXIS: TRACE("DIDF_ABSAXIS"); break;
203 case DIDF_RELAXIS: TRACE("DIDF_RELAXIS"); break;
204 default: TRACE("unknown"); break;
206 TRACE(")\n");
207 TRACE(" - dwDataSize: %d\n", df->dwDataSize);
208 TRACE(" - dwNumObjs: %d\n", df->dwNumObjs);
210 for (i = 0; i < df->dwNumObjs; i++) {
211 TRACE(" - Object %d:\n", i);
212 TRACE(" * GUID: %s ('%s')\n", debugstr_guid(df->rgodf[i].pguid), _dump_dinput_GUID(df->rgodf[i].pguid));
213 TRACE(" * dwOfs: %d\n", df->rgodf[i].dwOfs);
214 TRACE(" * dwType: 0x%08x\n", df->rgodf[i].dwType);
215 TRACE(" "); _dump_EnumObjects_flags(df->rgodf[i].dwType); TRACE("\n");
216 TRACE(" * dwFlags: 0x%08x\n", df->rgodf[i].dwFlags);
220 /******************************************************************************
221 * Get a config key from either the app-specific or the default config
223 DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name,
224 char *buffer, DWORD size )
226 if (appkey && !RegQueryValueExA( appkey, name, 0, NULL, (LPBYTE)buffer, &size ))
227 return 0;
229 if (defkey && !RegQueryValueExA( defkey, name, 0, NULL, (LPBYTE)buffer, &size ))
230 return 0;
232 return ERROR_FILE_NOT_FOUND;
235 /* Conversion between internal data buffer and external data buffer */
236 void fill_DataFormat(void *out, const void *in, const DataFormat *df) {
237 int i;
238 const char *in_c = in;
239 char *out_c = (char *) out;
241 if (df->dt == NULL) {
242 /* This means that the app uses Wine's internal data format */
243 memcpy(out, in, df->internal_format_size);
244 } else {
245 for (i = 0; i < df->size; i++) {
246 if (df->dt[i].offset_in >= 0) {
247 switch (df->dt[i].size) {
248 case 1:
249 TRACE("Copying (c) to %d from %d (value %d)\n",
250 df->dt[i].offset_out, df->dt[i].offset_in, *(in_c + df->dt[i].offset_in));
251 *(out_c + df->dt[i].offset_out) = *(in_c + df->dt[i].offset_in);
252 break;
254 case 2:
255 TRACE("Copying (s) to %d from %d (value %d)\n",
256 df->dt[i].offset_out, df->dt[i].offset_in, *((const short *)(in_c + df->dt[i].offset_in)));
257 *((short *)(out_c + df->dt[i].offset_out)) = *((const short *)(in_c + df->dt[i].offset_in));
258 break;
260 case 4:
261 TRACE("Copying (i) to %d from %d (value %d)\n",
262 df->dt[i].offset_out, df->dt[i].offset_in, *((const int *)(in_c + df->dt[i].offset_in)));
263 *((int *)(out_c + df->dt[i].offset_out)) = *((const int *)(in_c + df->dt[i].offset_in));
264 break;
266 default:
267 memcpy((out_c + df->dt[i].offset_out), (in_c + df->dt[i].offset_in), df->dt[i].size);
268 break;
270 } else {
271 switch (df->dt[i].size) {
272 case 1:
273 TRACE("Copying (c) to %d default value %d\n",
274 df->dt[i].offset_out, df->dt[i].value);
275 *(out_c + df->dt[i].offset_out) = (char) df->dt[i].value;
276 break;
278 case 2:
279 TRACE("Copying (s) to %d default value %d\n",
280 df->dt[i].offset_out, df->dt[i].value);
281 *((short *) (out_c + df->dt[i].offset_out)) = (short) df->dt[i].value;
282 break;
284 case 4:
285 TRACE("Copying (i) to %d default value %d\n",
286 df->dt[i].offset_out, df->dt[i].value);
287 *((int *) (out_c + df->dt[i].offset_out)) = (int) df->dt[i].value;
288 break;
290 default:
291 memset((out_c + df->dt[i].offset_out), 0, df->dt[i].size);
292 break;
299 void release_DataFormat(DataFormat * format)
301 TRACE("Deleting DataFormat: %p\n", format);
303 HeapFree(GetProcessHeap(), 0, format->dt);
304 format->dt = NULL;
305 HeapFree(GetProcessHeap(), 0, format->offsets);
306 format->offsets = NULL;
307 HeapFree(GetProcessHeap(), 0, format->user_df);
308 format->user_df = NULL;
311 inline LPDIOBJECTDATAFORMAT dataformat_to_odf(LPCDIDATAFORMAT df, int idx)
313 if (idx < 0 || idx >= df->dwNumObjs) return NULL;
314 return (LPDIOBJECTDATAFORMAT)((LPBYTE)df->rgodf + idx * df->dwObjSize);
317 HRESULT create_DataFormat(LPCDIDATAFORMAT asked_format, DataFormat *format)
319 DataTransform *dt;
320 unsigned int i, j;
321 int same = 1;
322 int *done;
323 int index = 0;
324 DWORD next = 0;
326 if (!format->wine_df) return DIERR_INVALIDPARAM;
327 done = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, asked_format->dwNumObjs * sizeof(int));
328 dt = HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform));
329 if (!dt || !done) goto failed;
331 if (!(format->offsets = HeapAlloc(GetProcessHeap(), 0, format->wine_df->dwNumObjs * sizeof(int))))
332 goto failed;
334 if (!(format->user_df = HeapAlloc(GetProcessHeap(), 0, asked_format->dwSize)))
335 goto failed;
336 memcpy(format->user_df, asked_format, asked_format->dwSize);
338 TRACE("Creating DataTransform :\n");
340 for (i = 0; i < format->wine_df->dwNumObjs; i++)
342 format->offsets[i] = -1;
344 for (j = 0; j < asked_format->dwNumObjs; j++) {
345 if (done[j] == 1)
346 continue;
348 if (/* Check if the application either requests any GUID and if not, it if matches
349 * the GUID of the Wine object.
351 ((asked_format->rgodf[j].pguid == NULL) ||
352 (format->wine_df->rgodf[i].pguid == NULL) ||
353 (IsEqualGUID(format->wine_df->rgodf[i].pguid, asked_format->rgodf[j].pguid)))
355 (/* Then check if it accepts any instance id, and if not, if it matches Wine's
356 * instance id.
358 ((asked_format->rgodf[j].dwType & DIDFT_INSTANCEMASK) == DIDFT_ANYINSTANCE) ||
359 (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0x00FF) || /* This is mentionned in no DX docs, but it works fine - tested on WinXP */
360 (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == DIDFT_GETINSTANCE(format->wine_df->rgodf[i].dwType)))
362 ( /* Then if the asked type matches the one Wine provides */
363 DIDFT_GETTYPE(asked_format->rgodf[j].dwType) & format->wine_df->rgodf[i].dwType))
365 done[j] = 1;
367 TRACE("Matching :\n");
368 TRACE(" - Asked (%d) :\n", j);
369 TRACE(" * GUID: %s ('%s')\n",
370 debugstr_guid(asked_format->rgodf[j].pguid),
371 _dump_dinput_GUID(asked_format->rgodf[j].pguid));
372 TRACE(" * Offset: %3d\n", asked_format->rgodf[j].dwOfs);
373 TRACE(" * dwType: %08x\n", asked_format->rgodf[j].dwType);
374 TRACE(" "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
376 TRACE(" - Wine (%d) :\n", i);
377 TRACE(" * GUID: %s ('%s')\n",
378 debugstr_guid(format->wine_df->rgodf[i].pguid),
379 _dump_dinput_GUID(format->wine_df->rgodf[i].pguid));
380 TRACE(" * Offset: %3d\n", format->wine_df->rgodf[i].dwOfs);
381 TRACE(" * dwType: %08x\n", format->wine_df->rgodf[i].dwType);
382 TRACE(" "); _dump_EnumObjects_flags(format->wine_df->rgodf[i].dwType); TRACE("\n");
384 if (format->wine_df->rgodf[i].dwType & DIDFT_BUTTON)
385 dt[index].size = sizeof(BYTE);
386 else
387 dt[index].size = sizeof(DWORD);
388 dt[index].offset_in = format->wine_df->rgodf[i].dwOfs;
389 dt[index].offset_out = asked_format->rgodf[j].dwOfs;
390 format->offsets[i] = asked_format->rgodf[j].dwOfs;
391 dt[index].value = 0;
392 next = next + dt[index].size;
394 if (format->wine_df->rgodf[i].dwOfs != dt[index].offset_out)
395 same = 0;
397 index++;
398 break;
402 if (j == asked_format->dwNumObjs)
403 same = 0;
406 TRACE("Setting to default value :\n");
407 for (j = 0; j < asked_format->dwNumObjs; j++) {
408 if (done[j] == 0) {
409 TRACE(" - Asked (%d) :\n", j);
410 TRACE(" * GUID: %s ('%s')\n",
411 debugstr_guid(asked_format->rgodf[j].pguid),
412 _dump_dinput_GUID(asked_format->rgodf[j].pguid));
413 TRACE(" * Offset: %3d\n", asked_format->rgodf[j].dwOfs);
414 TRACE(" * dwType: %08x\n", asked_format->rgodf[j].dwType);
415 TRACE(" "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
417 if (asked_format->rgodf[j].dwType & DIDFT_BUTTON)
418 dt[index].size = sizeof(BYTE);
419 else
420 dt[index].size = sizeof(DWORD);
421 dt[index].offset_in = -1;
422 dt[index].offset_out = asked_format->rgodf[j].dwOfs;
423 dt[index].value = 0;
424 index++;
426 same = 0;
430 format->internal_format_size = format->wine_df->dwDataSize;
431 format->size = index;
432 if (same) {
433 HeapFree(GetProcessHeap(), 0, dt);
434 dt = NULL;
436 format->dt = dt;
438 HeapFree(GetProcessHeap(), 0, done);
440 return DI_OK;
442 failed:
443 HeapFree(GetProcessHeap(), 0, done);
444 HeapFree(GetProcessHeap(), 0, dt);
445 format->dt = NULL;
446 HeapFree(GetProcessHeap(), 0, format->offsets);
447 format->offsets = NULL;
448 HeapFree(GetProcessHeap(), 0, format->user_df);
449 format->user_df = NULL;
451 return DIERR_OUTOFMEMORY;
454 /* find an object by it's offset in a data format */
455 static int offset_to_object(const DataFormat *df, int offset)
457 int i;
459 if (!df->offsets) return -1;
461 for (i = 0; i < df->wine_df->dwNumObjs; i++)
462 if (df->offsets[i] == offset) return i;
464 return -1;
467 int id_to_object(LPCDIDATAFORMAT df, int id)
469 int i;
471 id &= 0x00ffffff;
472 for (i = 0; i < df->dwNumObjs; i++)
473 if ((dataformat_to_odf(df, i)->dwType & 0x00ffffff) == id)
474 return i;
476 return -1;
479 int id_to_offset(const DataFormat *df, int id)
481 int obj = id_to_object(df->wine_df, id);
483 return obj >= 0 && df->offsets ? df->offsets[obj] : -1;
486 int find_property(const DataFormat *df, LPCDIPROPHEADER ph)
488 switch (ph->dwHow)
490 case DIPH_BYID: return id_to_object(df->wine_df, ph->dwObj);
491 case DIPH_BYOFFSET: return offset_to_object(df, ph->dwObj);
493 FIXME("Unhandled ph->dwHow=='%04X'\n", (unsigned int)ph->dwHow);
495 return -1;
499 BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA lpddi, LPVOID lpvRef) {
500 DIDEVICEOBJECTINSTANCEW ddtmp;
501 device_enumobjects_AtoWcb_data* data;
503 data = (device_enumobjects_AtoWcb_data*) lpvRef;
505 memset(&ddtmp, 0, sizeof(ddtmp));
507 ddtmp.dwSize = sizeof(DIDEVICEINSTANCEW);
508 ddtmp.guidType = lpddi->guidType;
509 ddtmp.dwOfs = lpddi->dwOfs;
510 ddtmp.dwType = lpddi->dwType;
511 ddtmp.dwFlags = lpddi->dwFlags;
512 MultiByteToWideChar(CP_ACP, 0, lpddi->tszName, -1, ddtmp.tszName, MAX_PATH);
514 if (lpddi->dwSize == sizeof(DIDEVICEINSTANCEA)) {
516 * if dwSize < sizeof(DIDEVICEINSTANCEA of DInput version >= 5)
517 * force feedback and other newer datas aren't available
519 ddtmp.dwFFMaxForce = lpddi->dwFFMaxForce;
520 ddtmp.dwFFForceResolution = lpddi->dwFFForceResolution;
521 ddtmp.wCollectionNumber = lpddi->wCollectionNumber;
522 ddtmp.wDesignatorIndex = lpddi->wDesignatorIndex;
523 ddtmp.wUsagePage = lpddi->wUsagePage;
524 ddtmp.wUsage = lpddi->wUsage;
525 ddtmp.dwDimension = lpddi->dwDimension;
526 ddtmp.wExponent = lpddi->wExponent;
527 ddtmp.wReserved = lpddi->wReserved;
529 return data->lpCallBack(&ddtmp, data->lpvRef);
532 /******************************************************************************
533 * queue_event - add new event to the ring queue
536 void queue_event(LPDIRECTINPUTDEVICE8A iface, int ofs, DWORD data, DWORD time, DWORD seq)
538 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
539 int next_pos;
541 /* Event is being set regardless of the queue state */
542 if (This->hEvent) SetEvent(This->hEvent);
544 if (!This->queue_len || This->overflow || ofs < 0) return;
546 next_pos = (This->queue_head + 1) % This->queue_len;
547 if (next_pos == This->queue_tail)
549 TRACE(" queue overflowed\n");
550 This->overflow = TRUE;
551 return;
554 TRACE(" queueing %d at offset %d (queue head %d / size %d)\n",
555 data, ofs, This->queue_head, This->queue_len);
557 This->data_queue[This->queue_head].dwOfs = ofs;
558 This->data_queue[This->queue_head].dwData = data;
559 This->data_queue[This->queue_head].dwTimeStamp = time;
560 This->data_queue[This->queue_head].dwSequence = seq;
561 This->queue_head = next_pos;
562 /* Send event if asked */
565 /******************************************************************************
566 * Acquire
569 HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
571 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
572 HRESULT res;
574 if (!This->data_format.user_df) return DIERR_INVALIDPARAM;
575 if (This->dwCoopLevel & DISCL_FOREGROUND && This->win != GetForegroundWindow())
576 return DIERR_OTHERAPPHASPRIO;
578 EnterCriticalSection(&This->crit);
579 res = This->acquired ? S_FALSE : DI_OK;
580 This->acquired = 1;
581 if (res == DI_OK)
583 This->queue_head = This->queue_tail = This->overflow = 0;
584 check_dinput_hooks(iface);
586 LeaveCriticalSection(&This->crit);
588 return res;
591 /******************************************************************************
592 * Unacquire
595 HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
597 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
598 HRESULT res;
600 EnterCriticalSection(&This->crit);
601 res = !This->acquired ? DI_NOEFFECT : DI_OK;
602 This->acquired = 0;
603 if (res == DI_OK)
604 check_dinput_hooks(iface);
605 LeaveCriticalSection(&This->crit);
607 return res;
610 /******************************************************************************
611 * IDirectInputDeviceA
614 HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
615 LPDIRECTINPUTDEVICE8A iface, LPCDIDATAFORMAT df)
617 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
618 HRESULT res = DI_OK;
620 if (!df) return E_POINTER;
621 TRACE("(%p) %p\n", This, df);
622 _dump_DIDATAFORMAT(df);
624 if (df->dwSize != sizeof(DIDATAFORMAT)) return DIERR_INVALIDPARAM;
625 if (This->acquired) return DIERR_ACQUIRED;
627 EnterCriticalSection(&This->crit);
629 release_DataFormat(&This->data_format);
630 res = create_DataFormat(df, &This->data_format);
632 LeaveCriticalSection(&This->crit);
633 return res;
636 /******************************************************************************
637 * SetCooperativeLevel
639 * Set cooperative level and the source window for the events.
641 HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
642 LPDIRECTINPUTDEVICE8A iface, HWND hwnd, DWORD dwflags)
644 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
646 TRACE("(%p) %p,0x%08x\n", This, hwnd, dwflags);
647 TRACE(" cooperative level : ");
648 _dump_cooperativelevel_DI(dwflags);
650 if ((dwflags & (DISCL_EXCLUSIVE | DISCL_NONEXCLUSIVE)) == 0 ||
651 (dwflags & (DISCL_EXCLUSIVE | DISCL_NONEXCLUSIVE)) == (DISCL_EXCLUSIVE | DISCL_NONEXCLUSIVE) ||
652 (dwflags & (DISCL_FOREGROUND | DISCL_BACKGROUND)) == 0 ||
653 (dwflags & (DISCL_FOREGROUND | DISCL_BACKGROUND)) == (DISCL_FOREGROUND | DISCL_BACKGROUND))
654 return DIERR_INVALIDPARAM;
656 if (dwflags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))
657 hwnd = GetDesktopWindow();
659 if (!hwnd) return E_HANDLE;
661 /* For security reasons native does not allow exclusive background level
662 for mouse and keyboard only */
663 if (dwflags & DISCL_EXCLUSIVE && dwflags & DISCL_BACKGROUND &&
664 (IsEqualGUID(&This->guid, &GUID_SysMouse) ||
665 IsEqualGUID(&This->guid, &GUID_SysKeyboard)))
666 return DIERR_UNSUPPORTED;
668 /* Store the window which asks for the mouse */
669 EnterCriticalSection(&This->crit);
670 This->win = hwnd;
671 This->dwCoopLevel = dwflags;
672 LeaveCriticalSection(&This->crit);
674 return DI_OK;
677 /******************************************************************************
678 * SetEventNotification : specifies event to be sent on state change
680 HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
681 LPDIRECTINPUTDEVICE8A iface, HANDLE event)
683 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
685 TRACE("(%p) %p\n", This, event);
687 EnterCriticalSection(&This->crit);
688 This->hEvent = event;
689 LeaveCriticalSection(&This->crit);
690 return DI_OK;
693 ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface)
695 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
696 ULONG ref;
698 ref = InterlockedDecrement(&(This->ref));
699 if (ref) return ref;
701 IDirectInputDevice_Unacquire(iface);
702 /* Reset the FF state, free all effects, etc */
703 IDirectInputDevice8_SendForceFeedbackCommand(iface, DISFFC_RESET);
705 HeapFree(GetProcessHeap(), 0, This->data_queue);
707 /* Free data format */
708 HeapFree(GetProcessHeap(), 0, This->data_format.wine_df->rgodf);
709 HeapFree(GetProcessHeap(), 0, This->data_format.wine_df);
710 release_DataFormat(&This->data_format);
712 EnterCriticalSection( &This->dinput->crit );
713 list_remove( &This->entry );
714 LeaveCriticalSection( &This->dinput->crit );
716 IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
717 This->crit.DebugInfo->Spare[0] = 0;
718 DeleteCriticalSection(&This->crit);
720 HeapFree(GetProcessHeap(), 0, This);
722 return DI_OK;
725 HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(
726 LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj
729 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
731 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
732 if (IsEqualGUID(&IID_IUnknown,riid)) {
733 IDirectInputDevice2_AddRef(iface);
734 *ppobj = This;
735 return DI_OK;
737 if (IsEqualGUID(&IID_IDirectInputDeviceA,riid)) {
738 IDirectInputDevice2_AddRef(iface);
739 *ppobj = This;
740 return DI_OK;
742 if (IsEqualGUID(&IID_IDirectInputDevice2A,riid)) {
743 IDirectInputDevice2_AddRef(iface);
744 *ppobj = This;
745 return DI_OK;
747 if (IsEqualGUID(&IID_IDirectInputDevice7A,riid)) {
748 IDirectInputDevice7_AddRef(iface);
749 *ppobj = This;
750 return DI_OK;
752 if (IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
753 IDirectInputDevice8_AddRef(iface);
754 *ppobj = This;
755 return DI_OK;
757 TRACE("Unsupported interface !\n");
758 return E_FAIL;
761 HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(
762 LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj
765 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
767 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
768 if (IsEqualGUID(&IID_IUnknown,riid)) {
769 IDirectInputDevice2_AddRef(iface);
770 *ppobj = This;
771 return DI_OK;
773 if (IsEqualGUID(&IID_IDirectInputDeviceW,riid)) {
774 IDirectInputDevice2_AddRef(iface);
775 *ppobj = This;
776 return DI_OK;
778 if (IsEqualGUID(&IID_IDirectInputDevice2W,riid)) {
779 IDirectInputDevice2_AddRef(iface);
780 *ppobj = This;
781 return DI_OK;
783 if (IsEqualGUID(&IID_IDirectInputDevice7W,riid)) {
784 IDirectInputDevice7_AddRef(iface);
785 *ppobj = This;
786 return DI_OK;
788 if (IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
789 IDirectInputDevice8_AddRef(iface);
790 *ppobj = This;
791 return DI_OK;
793 TRACE("Unsupported interface !\n");
794 return E_FAIL;
797 ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
798 LPDIRECTINPUTDEVICE8A iface)
800 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
801 return InterlockedIncrement(&(This->ref));
804 HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(LPDIRECTINPUTDEVICE8A iface,
805 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID lpvRef, DWORD dwFlags)
807 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
808 DIDEVICEOBJECTINSTANCEA ddoi;
809 int i;
811 TRACE("(%p) %p,%p flags:%08x)\n", iface, lpCallback, lpvRef, dwFlags);
812 TRACE(" - flags = ");
813 _dump_EnumObjects_flags(dwFlags);
814 TRACE("\n");
816 /* Only the fields till dwFFMaxForce are relevant */
817 memset(&ddoi, 0, sizeof(ddoi));
818 ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce);
820 for (i = 0; i < This->data_format.wine_df->dwNumObjs; i++)
822 LPDIOBJECTDATAFORMAT odf = dataformat_to_odf(This->data_format.wine_df, i);
824 if (dwFlags != DIDFT_ALL && !(dwFlags & DIEFT_GETTYPE(odf->dwType))) continue;
825 if (IDirectInputDevice_GetObjectInfo(iface, &ddoi, odf->dwType, DIPH_BYID) != DI_OK)
826 continue;
828 if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) break;
831 return DI_OK;
834 HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
835 LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID lpvRef, DWORD dwFlags)
837 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
838 DIDEVICEOBJECTINSTANCEW ddoi;
839 int i;
841 TRACE("(%p) %p,%p flags:%08x)\n", iface, lpCallback, lpvRef, dwFlags);
842 TRACE(" - flags = ");
843 _dump_EnumObjects_flags(dwFlags);
844 TRACE("\n");
846 /* Only the fields till dwFFMaxForce are relevant */
847 memset(&ddoi, 0, sizeof(ddoi));
848 ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, dwFFMaxForce);
850 for (i = 0; i < This->data_format.wine_df->dwNumObjs; i++)
852 LPDIOBJECTDATAFORMAT odf = dataformat_to_odf(This->data_format.wine_df, i);
854 if (dwFlags != DIDFT_ALL && !(dwFlags & DIEFT_GETTYPE(odf->dwType))) continue;
855 if (IDirectInputDevice_GetObjectInfo(iface, &ddoi, odf->dwType, DIPH_BYID) != DI_OK)
856 continue;
858 if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) break;
861 return DI_OK;
864 /******************************************************************************
865 * GetProperty
868 HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
869 LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
871 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
873 TRACE("(%p) %s,%p\n", iface, debugstr_guid(rguid), pdiph);
874 _dump_DIPROPHEADER(pdiph);
876 if (HIWORD(rguid)) return DI_OK;
878 switch (LOWORD(rguid))
880 case (DWORD) DIPROP_BUFFERSIZE:
882 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
884 if (pdiph->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
886 pd->dwData = This->queue_len;
887 TRACE("buffersize = %d\n", pd->dwData);
888 break;
890 default:
891 WARN("Unknown property %s\n", debugstr_guid(rguid));
892 break;
895 return DI_OK;
898 /******************************************************************************
899 * SetProperty
902 HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty(
903 LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER pdiph)
905 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
907 TRACE("(%p) %s,%p\n", iface, debugstr_guid(rguid), pdiph);
908 _dump_DIPROPHEADER(pdiph);
910 if (HIWORD(rguid)) return DI_OK;
912 switch (LOWORD(rguid))
914 case (DWORD) DIPROP_AXISMODE:
916 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)pdiph;
918 if (pdiph->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
919 if (pdiph->dwHow == DIPH_DEVICE && pdiph->dwObj) return DIERR_INVALIDPARAM;
920 if (This->acquired) return DIERR_ACQUIRED;
921 if (pdiph->dwHow != DIPH_DEVICE) return DIERR_UNSUPPORTED;
922 if (!This->data_format.user_df) return DI_OK;
924 TRACE("Axis mode: %s\n", pd->dwData == DIPROPAXISMODE_ABS ? "absolute" :
925 "relative");
927 EnterCriticalSection(&This->crit);
928 This->data_format.user_df->dwFlags &= ~DIDFT_AXIS;
929 This->data_format.user_df->dwFlags |= pd->dwData == DIPROPAXISMODE_ABS ?
930 DIDF_ABSAXIS : DIDF_RELAXIS;
931 LeaveCriticalSection(&This->crit);
932 break;
934 case (DWORD) DIPROP_BUFFERSIZE:
936 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)pdiph;
938 if (pdiph->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
939 if (This->acquired) return DIERR_ACQUIRED;
941 TRACE("buffersize = %d\n", pd->dwData);
943 EnterCriticalSection(&This->crit);
944 HeapFree(GetProcessHeap(), 0, This->data_queue);
946 This->data_queue = !pd->dwData ? NULL : HeapAlloc(GetProcessHeap(), 0,
947 pd->dwData * sizeof(DIDEVICEOBJECTDATA));
948 This->queue_head = This->queue_tail = This->overflow = 0;
949 This->queue_len = pd->dwData;
951 LeaveCriticalSection(&This->crit);
952 break;
954 default:
955 WARN("Unknown property %s\n", debugstr_guid(rguid));
956 return DIERR_UNSUPPORTED;
959 return DI_OK;
962 HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
963 LPDIRECTINPUTDEVICE8A iface,
964 LPDIDEVICEOBJECTINSTANCEA pdidoi,
965 DWORD dwObj,
966 DWORD dwHow)
968 DIDEVICEOBJECTINSTANCEW didoiW;
969 HRESULT res;
971 if (!pdidoi ||
972 (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) &&
973 pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A)))
974 return DIERR_INVALIDPARAM;
976 didoiW.dwSize = sizeof(didoiW);
977 res = IDirectInputDevice2WImpl_GetObjectInfo((LPDIRECTINPUTDEVICE8W)iface, &didoiW, dwObj, dwHow);
978 if (res == DI_OK)
980 DWORD dwSize = pdidoi->dwSize;
982 memset(pdidoi, 0, pdidoi->dwSize);
983 pdidoi->dwSize = dwSize;
984 pdidoi->guidType = didoiW.guidType;
985 pdidoi->dwOfs = didoiW.dwOfs;
986 pdidoi->dwType = didoiW.dwType;
987 pdidoi->dwFlags = didoiW.dwFlags;
990 return res;
993 HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(
994 LPDIRECTINPUTDEVICE8W iface,
995 LPDIDEVICEOBJECTINSTANCEW pdidoi,
996 DWORD dwObj,
997 DWORD dwHow)
999 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
1000 DWORD dwSize;
1001 LPDIOBJECTDATAFORMAT odf;
1002 int idx = -1;
1004 TRACE("(%p) %d(0x%08x) -> %p\n", This, dwHow, dwObj, pdidoi);
1006 if (!pdidoi ||
1007 (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEW) &&
1008 pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3W)))
1009 return DIERR_INVALIDPARAM;
1011 switch (dwHow)
1013 case DIPH_BYOFFSET:
1014 if (!This->data_format.offsets) break;
1015 for (idx = This->data_format.wine_df->dwNumObjs - 1; idx >= 0; idx--)
1016 if (This->data_format.offsets[idx] == dwObj) break;
1017 break;
1018 case DIPH_BYID:
1019 dwObj &= 0x00ffffff;
1020 for (idx = This->data_format.wine_df->dwNumObjs - 1; idx >= 0; idx--)
1021 if ((dataformat_to_odf(This->data_format.wine_df, idx)->dwType & 0x00ffffff) == dwObj)
1022 break;
1023 break;
1025 case DIPH_BYUSAGE:
1026 FIXME("dwHow = DIPH_BYUSAGE not implemented\n");
1027 break;
1028 default:
1029 WARN("invalid parameter: dwHow = %08x\n", dwHow);
1030 return DIERR_INVALIDPARAM;
1032 if (idx < 0) return DIERR_OBJECTNOTFOUND;
1034 odf = dataformat_to_odf(This->data_format.wine_df, idx);
1035 dwSize = pdidoi->dwSize; /* save due to memset below */
1036 memset(pdidoi, 0, pdidoi->dwSize);
1037 pdidoi->dwSize = dwSize;
1038 if (odf->pguid) pdidoi->guidType = *odf->pguid;
1039 pdidoi->dwOfs = This->data_format.offsets ? This->data_format.offsets[idx] : odf->dwOfs;
1040 pdidoi->dwType = odf->dwType;
1041 pdidoi->dwFlags = odf->dwFlags;
1043 return DI_OK;
1046 HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData(
1047 LPDIRECTINPUTDEVICE8A iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod,
1048 LPDWORD entries, DWORD flags)
1050 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
1051 HRESULT ret = DI_OK;
1052 int len;
1054 TRACE("(%p) %p -> %p(%d) x%d, 0x%08x\n",
1055 This, dod, entries, entries ? *entries : 0, dodsize, flags);
1057 if (!This->acquired)
1058 return DIERR_NOTACQUIRED;
1059 if (!This->queue_len)
1060 return DIERR_NOTBUFFERED;
1061 if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3))
1062 return DIERR_INVALIDPARAM;
1064 IDirectInputDevice2_Poll(iface);
1065 EnterCriticalSection(&This->crit);
1067 len = This->queue_head - This->queue_tail;
1068 if (len < 0) len += This->queue_len;
1070 if ((*entries != INFINITE) && (len > *entries)) len = *entries;
1072 if (dod)
1074 int i;
1075 for (i = 0; i < len; i++)
1077 int n = (This->queue_tail + i) % This->queue_len;
1078 memcpy((char *)dod + dodsize * i, This->data_queue + n, dodsize);
1081 *entries = len;
1083 if (This->overflow)
1084 ret = DI_BUFFEROVERFLOW;
1086 if (!(flags & DIGDD_PEEK))
1088 /* Advance reading position */
1089 This->queue_tail = (This->queue_tail + len) % This->queue_len;
1090 This->overflow = FALSE;
1093 LeaveCriticalSection(&This->crit);
1095 TRACE("Returning %d events queued\n", *entries);
1096 return ret;
1099 HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
1100 LPDIRECTINPUTDEVICE8A iface,
1101 LPDIDEVICEINSTANCEA pdidi)
1103 FIXME("(this=%p,%p): stub!\n",
1104 iface, pdidi);
1106 return DI_OK;
1109 HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo(
1110 LPDIRECTINPUTDEVICE8W iface,
1111 LPDIDEVICEINSTANCEW pdidi)
1113 FIXME("(this=%p,%p): stub!\n",
1114 iface, pdidi);
1116 return DI_OK;
1119 HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
1120 LPDIRECTINPUTDEVICE8A iface,
1121 HWND hwndOwner,
1122 DWORD dwFlags)
1124 FIXME("(this=%p,%p,0x%08x): stub!\n",
1125 iface, hwndOwner, dwFlags);
1127 return DI_OK;
1130 HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
1131 LPDIRECTINPUTDEVICE8A iface,
1132 HINSTANCE hinst,
1133 DWORD dwVersion,
1134 REFGUID rguid)
1136 FIXME("(this=%p,%p,%d,%s): stub!\n",
1137 iface, hinst, dwVersion, debugstr_guid(rguid));
1138 return DI_OK;
1141 /******************************************************************************
1142 * IDirectInputDevice2A
1145 HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
1146 LPDIRECTINPUTDEVICE8A iface,
1147 REFGUID rguid,
1148 LPCDIEFFECT lpeff,
1149 LPDIRECTINPUTEFFECT *ppdef,
1150 LPUNKNOWN pUnkOuter)
1152 FIXME("(this=%p,%s,%p,%p,%p): stub!\n",
1153 iface, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter);
1154 return DI_OK;
1157 HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
1158 LPDIRECTINPUTDEVICE8A iface,
1159 LPDIENUMEFFECTSCALLBACKA lpCallback,
1160 LPVOID lpvRef,
1161 DWORD dwFlags)
1163 FIXME("(this=%p,%p,%p,0x%08x): stub!\n",
1164 iface, lpCallback, lpvRef, dwFlags);
1166 return DI_OK;
1169 HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
1170 LPDIRECTINPUTDEVICE8W iface,
1171 LPDIENUMEFFECTSCALLBACKW lpCallback,
1172 LPVOID lpvRef,
1173 DWORD dwFlags)
1175 FIXME("(this=%p,%p,%p,0x%08x): stub!\n",
1176 iface, lpCallback, lpvRef, dwFlags);
1178 return DI_OK;
1181 HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
1182 LPDIRECTINPUTDEVICE8A iface,
1183 LPDIEFFECTINFOA lpdei,
1184 REFGUID rguid)
1186 FIXME("(this=%p,%p,%s): stub!\n",
1187 iface, lpdei, debugstr_guid(rguid));
1188 return DI_OK;
1191 HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
1192 LPDIRECTINPUTDEVICE8W iface,
1193 LPDIEFFECTINFOW lpdei,
1194 REFGUID rguid)
1196 FIXME("(this=%p,%p,%s): stub!\n",
1197 iface, lpdei, debugstr_guid(rguid));
1198 return DI_OK;
1201 HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
1202 LPDIRECTINPUTDEVICE8A iface,
1203 LPDWORD pdwOut)
1205 FIXME("(this=%p,%p): stub!\n",
1206 iface, pdwOut);
1207 return DI_OK;
1210 HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
1211 LPDIRECTINPUTDEVICE8A iface,
1212 DWORD dwFlags)
1214 TRACE("(%p) 0x%08x:\n", iface, dwFlags);
1215 return DI_NOEFFECT;
1218 HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
1219 LPDIRECTINPUTDEVICE8A iface,
1220 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
1221 LPVOID lpvRef,
1222 DWORD dwFlags)
1224 FIXME("(this=%p,%p,%p,0x%08x): stub!\n",
1225 iface, lpCallback, lpvRef, dwFlags);
1226 return DI_OK;
1229 HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
1230 LPDIRECTINPUTDEVICE8A iface,
1231 LPDIEFFESCAPE lpDIEEsc)
1233 FIXME("(this=%p,%p): stub!\n",
1234 iface, lpDIEEsc);
1235 return DI_OK;
1238 HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
1239 LPDIRECTINPUTDEVICE8A iface)
1241 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
1243 if (!This->acquired) return DIERR_NOTACQUIRED;
1244 /* Because wine devices do not need to be polled, just return DI_NOEFFECT */
1245 return DI_NOEFFECT;
1248 HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
1249 LPDIRECTINPUTDEVICE8A iface,
1250 DWORD cbObjectData,
1251 LPCDIDEVICEOBJECTDATA rgdod,
1252 LPDWORD pdwInOut,
1253 DWORD dwFlags)
1255 FIXME("(this=%p,0x%08x,%p,%p,0x%08x): stub!\n",
1256 iface, cbObjectData, rgdod, pdwInOut, dwFlags);
1258 return DI_OK;
1261 HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface,
1262 LPCSTR lpszFileName,
1263 LPDIENUMEFFECTSINFILECALLBACK pec,
1264 LPVOID pvRef,
1265 DWORD dwFlags)
1267 FIXME("(%p)->(%s,%p,%p,%08x): stub !\n", iface, lpszFileName, pec, pvRef, dwFlags);
1269 return DI_OK;
1272 HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
1273 LPCWSTR lpszFileName,
1274 LPDIENUMEFFECTSINFILECALLBACK pec,
1275 LPVOID pvRef,
1276 DWORD dwFlags)
1278 FIXME("(%p)->(%s,%p,%p,%08x): stub !\n", iface, debugstr_w(lpszFileName), pec, pvRef, dwFlags);
1280 return DI_OK;
1283 HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
1284 LPCSTR lpszFileName,
1285 DWORD dwEntries,
1286 LPDIFILEEFFECT rgDiFileEft,
1287 DWORD dwFlags)
1289 FIXME("(%p)->(%s,%08x,%p,%08x): stub !\n", iface, lpszFileName, dwEntries, rgDiFileEft, dwFlags);
1291 return DI_OK;
1294 HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
1295 LPCWSTR lpszFileName,
1296 DWORD dwEntries,
1297 LPDIFILEEFFECT rgDiFileEft,
1298 DWORD dwFlags)
1300 FIXME("(%p)->(%s,%08x,%p,%08x): stub !\n", iface, debugstr_w(lpszFileName), dwEntries, rgDiFileEft, dwFlags);
1302 return DI_OK;
1305 HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
1306 LPDIACTIONFORMATA lpdiaf,
1307 LPCSTR lpszUserName,
1308 DWORD dwFlags)
1310 FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
1312 return DI_OK;
1315 HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
1316 LPDIACTIONFORMATW lpdiaf,
1317 LPCWSTR lpszUserName,
1318 DWORD dwFlags)
1320 FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
1322 return DI_OK;
1325 HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
1326 LPDIACTIONFORMATA lpdiaf,
1327 LPCSTR lpszUserName,
1328 DWORD dwFlags)
1330 FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
1332 return DI_OK;
1335 HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
1336 LPDIACTIONFORMATW lpdiaf,
1337 LPCWSTR lpszUserName,
1338 DWORD dwFlags)
1340 FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
1342 return DI_OK;
1345 HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
1346 LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader)
1348 FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
1350 return DI_OK;
1353 HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
1354 LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader)
1356 FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
1358 return DI_OK;