push 0a6b4a6c9e6bf38a9b3d5ed71f415701d1ca15d1
[wine/hacks.git] / dlls / dinput / device.c
blob170d8fdeee63df4d5d7c8187c8b5b33da206df3f
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 the default and the app-specific config keys.
223 BOOL get_app_key(HKEY *defkey, HKEY *appkey)
225 char buffer[MAX_PATH+16];
226 DWORD len;
228 *appkey = 0;
230 /* @@ Wine registry key: HKCU\Software\Wine\DirectInput */
231 if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\DirectInput", defkey))
232 *defkey = 0;
234 len = GetModuleFileNameA(0, buffer, MAX_PATH);
235 if (len && len < MAX_PATH)
237 HKEY tmpkey;
239 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectInput */
240 if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey))
242 char *p, *appname = buffer;
243 if ((p = strrchr(appname, '/'))) appname = p + 1;
244 if ((p = strrchr(appname, '\\'))) appname = p + 1;
245 strcat(appname, "\\DirectInput");
247 if (RegOpenKeyA(tmpkey, appname, appkey)) appkey = 0;
248 RegCloseKey(tmpkey);
252 return *defkey || *appkey;
255 /******************************************************************************
256 * Get a config key from either the app-specific or the default config
258 DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name,
259 char *buffer, DWORD size )
261 if (appkey && !RegQueryValueExA( appkey, name, 0, NULL, (LPBYTE)buffer, &size ))
262 return 0;
264 if (defkey && !RegQueryValueExA( defkey, name, 0, NULL, (LPBYTE)buffer, &size ))
265 return 0;
267 return ERROR_FILE_NOT_FOUND;
270 /* Conversion between internal data buffer and external data buffer */
271 void fill_DataFormat(void *out, const void *in, const DataFormat *df) {
272 int i;
273 const char *in_c = in;
274 char *out_c = (char *) out;
276 if (df->dt == NULL) {
277 /* This means that the app uses Wine's internal data format */
278 memcpy(out, in, df->internal_format_size);
279 } else {
280 for (i = 0; i < df->size; i++) {
281 if (df->dt[i].offset_in >= 0) {
282 switch (df->dt[i].size) {
283 case 1:
284 TRACE("Copying (c) to %d from %d (value %d)\n",
285 df->dt[i].offset_out, df->dt[i].offset_in, *(in_c + df->dt[i].offset_in));
286 *(out_c + df->dt[i].offset_out) = *(in_c + df->dt[i].offset_in);
287 break;
289 case 2:
290 TRACE("Copying (s) to %d from %d (value %d)\n",
291 df->dt[i].offset_out, df->dt[i].offset_in, *((const short *)(in_c + df->dt[i].offset_in)));
292 *((short *)(out_c + df->dt[i].offset_out)) = *((const short *)(in_c + df->dt[i].offset_in));
293 break;
295 case 4:
296 TRACE("Copying (i) to %d from %d (value %d)\n",
297 df->dt[i].offset_out, df->dt[i].offset_in, *((const int *)(in_c + df->dt[i].offset_in)));
298 *((int *)(out_c + df->dt[i].offset_out)) = *((const int *)(in_c + df->dt[i].offset_in));
299 break;
301 default:
302 memcpy((out_c + df->dt[i].offset_out), (in_c + df->dt[i].offset_in), df->dt[i].size);
303 break;
305 } else {
306 switch (df->dt[i].size) {
307 case 1:
308 TRACE("Copying (c) to %d default value %d\n",
309 df->dt[i].offset_out, df->dt[i].value);
310 *(out_c + df->dt[i].offset_out) = (char) df->dt[i].value;
311 break;
313 case 2:
314 TRACE("Copying (s) to %d default value %d\n",
315 df->dt[i].offset_out, df->dt[i].value);
316 *((short *) (out_c + df->dt[i].offset_out)) = (short) df->dt[i].value;
317 break;
319 case 4:
320 TRACE("Copying (i) to %d default value %d\n",
321 df->dt[i].offset_out, df->dt[i].value);
322 *((int *) (out_c + df->dt[i].offset_out)) = (int) df->dt[i].value;
323 break;
325 default:
326 memset((out_c + df->dt[i].offset_out), 0, df->dt[i].size);
327 break;
334 void release_DataFormat(DataFormat * format)
336 TRACE("Deleting DataFormat: %p\n", format);
338 HeapFree(GetProcessHeap(), 0, format->dt);
339 format->dt = NULL;
340 HeapFree(GetProcessHeap(), 0, format->offsets);
341 format->offsets = NULL;
342 HeapFree(GetProcessHeap(), 0, format->user_df);
343 format->user_df = NULL;
346 inline LPDIOBJECTDATAFORMAT dataformat_to_odf(LPCDIDATAFORMAT df, int idx)
348 if (idx < 0 || idx >= df->dwNumObjs) return NULL;
349 return (LPDIOBJECTDATAFORMAT)((LPBYTE)df->rgodf + idx * df->dwObjSize);
352 HRESULT create_DataFormat(LPCDIDATAFORMAT asked_format, DataFormat *format)
354 DataTransform *dt;
355 unsigned int i, j;
356 int same = 1;
357 int *done;
358 int index = 0;
359 DWORD next = 0;
361 if (!format->wine_df) return DIERR_INVALIDPARAM;
362 done = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, asked_format->dwNumObjs * sizeof(int));
363 dt = HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform));
364 if (!dt || !done) goto failed;
366 if (!(format->offsets = HeapAlloc(GetProcessHeap(), 0, format->wine_df->dwNumObjs * sizeof(int))))
367 goto failed;
369 if (!(format->user_df = HeapAlloc(GetProcessHeap(), 0, asked_format->dwSize)))
370 goto failed;
371 memcpy(format->user_df, asked_format, asked_format->dwSize);
373 TRACE("Creating DataTransform :\n");
375 for (i = 0; i < format->wine_df->dwNumObjs; i++)
377 format->offsets[i] = -1;
379 for (j = 0; j < asked_format->dwNumObjs; j++) {
380 if (done[j] == 1)
381 continue;
383 if (/* Check if the application either requests any GUID and if not, it if matches
384 * the GUID of the Wine object.
386 ((asked_format->rgodf[j].pguid == NULL) ||
387 (format->wine_df->rgodf[i].pguid == NULL) ||
388 (IsEqualGUID(format->wine_df->rgodf[i].pguid, asked_format->rgodf[j].pguid)))
390 (/* Then check if it accepts any instance id, and if not, if it matches Wine's
391 * instance id.
393 ((asked_format->rgodf[j].dwType & DIDFT_INSTANCEMASK) == DIDFT_ANYINSTANCE) ||
394 (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0x00FF) || /* This is mentionned in no DX docs, but it works fine - tested on WinXP */
395 (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == DIDFT_GETINSTANCE(format->wine_df->rgodf[i].dwType)))
397 ( /* Then if the asked type matches the one Wine provides */
398 DIDFT_GETTYPE(asked_format->rgodf[j].dwType) & format->wine_df->rgodf[i].dwType))
400 done[j] = 1;
402 TRACE("Matching :\n");
403 TRACE(" - Asked (%d) :\n", j);
404 TRACE(" * GUID: %s ('%s')\n",
405 debugstr_guid(asked_format->rgodf[j].pguid),
406 _dump_dinput_GUID(asked_format->rgodf[j].pguid));
407 TRACE(" * Offset: %3d\n", asked_format->rgodf[j].dwOfs);
408 TRACE(" * dwType: %08x\n", asked_format->rgodf[j].dwType);
409 TRACE(" "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
411 TRACE(" - Wine (%d) :\n", i);
412 TRACE(" * GUID: %s ('%s')\n",
413 debugstr_guid(format->wine_df->rgodf[i].pguid),
414 _dump_dinput_GUID(format->wine_df->rgodf[i].pguid));
415 TRACE(" * Offset: %3d\n", format->wine_df->rgodf[i].dwOfs);
416 TRACE(" * dwType: %08x\n", format->wine_df->rgodf[i].dwType);
417 TRACE(" "); _dump_EnumObjects_flags(format->wine_df->rgodf[i].dwType); TRACE("\n");
419 if (format->wine_df->rgodf[i].dwType & DIDFT_BUTTON)
420 dt[index].size = sizeof(BYTE);
421 else
422 dt[index].size = sizeof(DWORD);
423 dt[index].offset_in = format->wine_df->rgodf[i].dwOfs;
424 dt[index].offset_out = asked_format->rgodf[j].dwOfs;
425 format->offsets[i] = asked_format->rgodf[j].dwOfs;
426 dt[index].value = 0;
427 next = next + dt[index].size;
429 if (format->wine_df->rgodf[i].dwOfs != dt[index].offset_out)
430 same = 0;
432 index++;
433 break;
437 if (j == asked_format->dwNumObjs)
438 same = 0;
441 TRACE("Setting to default value :\n");
442 for (j = 0; j < asked_format->dwNumObjs; j++) {
443 if (done[j] == 0) {
444 TRACE(" - Asked (%d) :\n", j);
445 TRACE(" * GUID: %s ('%s')\n",
446 debugstr_guid(asked_format->rgodf[j].pguid),
447 _dump_dinput_GUID(asked_format->rgodf[j].pguid));
448 TRACE(" * Offset: %3d\n", asked_format->rgodf[j].dwOfs);
449 TRACE(" * dwType: %08x\n", asked_format->rgodf[j].dwType);
450 TRACE(" "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
452 if (asked_format->rgodf[j].dwType & DIDFT_BUTTON)
453 dt[index].size = sizeof(BYTE);
454 else
455 dt[index].size = sizeof(DWORD);
456 dt[index].offset_in = -1;
457 dt[index].offset_out = asked_format->rgodf[j].dwOfs;
458 dt[index].value = 0;
459 index++;
461 same = 0;
465 format->internal_format_size = format->wine_df->dwDataSize;
466 format->size = index;
467 if (same) {
468 HeapFree(GetProcessHeap(), 0, dt);
469 dt = NULL;
471 format->dt = dt;
473 HeapFree(GetProcessHeap(), 0, done);
475 return DI_OK;
477 failed:
478 HeapFree(GetProcessHeap(), 0, done);
479 HeapFree(GetProcessHeap(), 0, dt);
480 format->dt = NULL;
481 HeapFree(GetProcessHeap(), 0, format->offsets);
482 format->offsets = NULL;
483 HeapFree(GetProcessHeap(), 0, format->user_df);
484 format->user_df = NULL;
486 return DIERR_OUTOFMEMORY;
489 /* find an object by it's offset in a data format */
490 static int offset_to_object(const DataFormat *df, int offset)
492 int i;
494 if (!df->offsets) return -1;
496 for (i = 0; i < df->wine_df->dwNumObjs; i++)
497 if (df->offsets[i] == offset) return i;
499 return -1;
502 int id_to_object(LPCDIDATAFORMAT df, int id)
504 int i;
506 id &= 0x00ffffff;
507 for (i = 0; i < df->dwNumObjs; i++)
508 if ((dataformat_to_odf(df, i)->dwType & 0x00ffffff) == id)
509 return i;
511 return -1;
514 int id_to_offset(const DataFormat *df, int id)
516 int obj = id_to_object(df->wine_df, id);
518 return obj >= 0 && df->offsets ? df->offsets[obj] : -1;
521 int find_property(const DataFormat *df, LPCDIPROPHEADER ph)
523 switch (ph->dwHow)
525 case DIPH_BYID: return id_to_object(df->wine_df, ph->dwObj);
526 case DIPH_BYOFFSET: return offset_to_object(df, ph->dwObj);
528 FIXME("Unhandled ph->dwHow=='%04X'\n", (unsigned int)ph->dwHow);
530 return -1;
534 BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA lpddi, LPVOID lpvRef) {
535 DIDEVICEOBJECTINSTANCEW ddtmp;
536 device_enumobjects_AtoWcb_data* data;
538 data = (device_enumobjects_AtoWcb_data*) lpvRef;
540 memset(&ddtmp, 0, sizeof(ddtmp));
542 ddtmp.dwSize = sizeof(DIDEVICEINSTANCEW);
543 ddtmp.guidType = lpddi->guidType;
544 ddtmp.dwOfs = lpddi->dwOfs;
545 ddtmp.dwType = lpddi->dwType;
546 ddtmp.dwFlags = lpddi->dwFlags;
547 MultiByteToWideChar(CP_ACP, 0, lpddi->tszName, -1, ddtmp.tszName, MAX_PATH);
549 if (lpddi->dwSize == sizeof(DIDEVICEINSTANCEA)) {
551 * if dwSize < sizeof(DIDEVICEINSTANCEA of DInput version >= 5)
552 * force feedback and other newer datas aren't available
554 ddtmp.dwFFMaxForce = lpddi->dwFFMaxForce;
555 ddtmp.dwFFForceResolution = lpddi->dwFFForceResolution;
556 ddtmp.wCollectionNumber = lpddi->wCollectionNumber;
557 ddtmp.wDesignatorIndex = lpddi->wDesignatorIndex;
558 ddtmp.wUsagePage = lpddi->wUsagePage;
559 ddtmp.wUsage = lpddi->wUsage;
560 ddtmp.dwDimension = lpddi->dwDimension;
561 ddtmp.wExponent = lpddi->wExponent;
562 ddtmp.wReserved = lpddi->wReserved;
564 return data->lpCallBack(&ddtmp, data->lpvRef);
567 /******************************************************************************
568 * queue_event - add new event to the ring queue
571 void queue_event(LPDIRECTINPUTDEVICE8A iface, int ofs, DWORD data, DWORD time, DWORD seq)
573 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
574 int next_pos;
576 /* Event is being set regardless of the queue state */
577 if (This->hEvent) SetEvent(This->hEvent);
579 if (!This->queue_len || This->overflow || ofs < 0) return;
581 next_pos = (This->queue_head + 1) % This->queue_len;
582 if (next_pos == This->queue_tail)
584 TRACE(" queue overflowed\n");
585 This->overflow = TRUE;
586 return;
589 TRACE(" queueing %d at offset %d (queue head %d / size %d)\n",
590 data, ofs, This->queue_head, This->queue_len);
592 This->data_queue[This->queue_head].dwOfs = ofs;
593 This->data_queue[This->queue_head].dwData = data;
594 This->data_queue[This->queue_head].dwTimeStamp = time;
595 This->data_queue[This->queue_head].dwSequence = seq;
596 This->queue_head = next_pos;
597 /* Send event if asked */
600 /******************************************************************************
601 * Acquire
604 HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
606 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
607 HRESULT res;
609 if (!This->data_format.user_df) return DIERR_INVALIDPARAM;
610 if (This->dwCoopLevel & DISCL_FOREGROUND && This->win != GetForegroundWindow())
611 return DIERR_OTHERAPPHASPRIO;
613 EnterCriticalSection(&This->crit);
614 res = This->acquired ? S_FALSE : DI_OK;
615 This->acquired = 1;
616 if (res == DI_OK)
618 This->queue_head = This->queue_tail = This->overflow = 0;
619 check_dinput_hooks(iface);
621 LeaveCriticalSection(&This->crit);
623 return res;
626 /******************************************************************************
627 * Unacquire
630 HRESULT WINAPI IDirectInputDevice2AImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
632 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
633 HRESULT res;
635 EnterCriticalSection(&This->crit);
636 res = !This->acquired ? DI_NOEFFECT : DI_OK;
637 This->acquired = 0;
638 if (res == DI_OK)
639 check_dinput_hooks(iface);
640 LeaveCriticalSection(&This->crit);
642 return res;
645 /******************************************************************************
646 * IDirectInputDeviceA
649 HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
650 LPDIRECTINPUTDEVICE8A iface, LPCDIDATAFORMAT df)
652 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
653 HRESULT res = DI_OK;
655 if (!df) return E_POINTER;
656 TRACE("(%p) %p\n", This, df);
657 _dump_DIDATAFORMAT(df);
659 if (df->dwSize != sizeof(DIDATAFORMAT)) return DIERR_INVALIDPARAM;
660 if (This->acquired) return DIERR_ACQUIRED;
662 EnterCriticalSection(&This->crit);
664 release_DataFormat(&This->data_format);
665 res = create_DataFormat(df, &This->data_format);
667 LeaveCriticalSection(&This->crit);
668 return res;
671 /******************************************************************************
672 * SetCooperativeLevel
674 * Set cooperative level and the source window for the events.
676 HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
677 LPDIRECTINPUTDEVICE8A iface, HWND hwnd, DWORD dwflags)
679 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
681 TRACE("(%p) %p,0x%08x\n", This, hwnd, dwflags);
682 TRACE(" cooperative level : ");
683 _dump_cooperativelevel_DI(dwflags);
685 if ((dwflags & (DISCL_EXCLUSIVE | DISCL_NONEXCLUSIVE)) == 0 ||
686 (dwflags & (DISCL_EXCLUSIVE | DISCL_NONEXCLUSIVE)) == (DISCL_EXCLUSIVE | DISCL_NONEXCLUSIVE) ||
687 (dwflags & (DISCL_FOREGROUND | DISCL_BACKGROUND)) == 0 ||
688 (dwflags & (DISCL_FOREGROUND | DISCL_BACKGROUND)) == (DISCL_FOREGROUND | DISCL_BACKGROUND))
689 return DIERR_INVALIDPARAM;
691 if (dwflags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))
692 hwnd = GetDesktopWindow();
694 if (!hwnd) return E_HANDLE;
696 /* For security reasons native does not allow exclusive background level
697 for mouse and keyboard only */
698 if (dwflags & DISCL_EXCLUSIVE && dwflags & DISCL_BACKGROUND &&
699 (IsEqualGUID(&This->guid, &GUID_SysMouse) ||
700 IsEqualGUID(&This->guid, &GUID_SysKeyboard)))
701 return DIERR_UNSUPPORTED;
703 /* Store the window which asks for the mouse */
704 EnterCriticalSection(&This->crit);
705 This->win = hwnd;
706 This->dwCoopLevel = dwflags;
707 LeaveCriticalSection(&This->crit);
709 return DI_OK;
712 /******************************************************************************
713 * SetEventNotification : specifies event to be sent on state change
715 HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
716 LPDIRECTINPUTDEVICE8A iface, HANDLE event)
718 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
720 TRACE("(%p) %p\n", This, event);
722 EnterCriticalSection(&This->crit);
723 This->hEvent = event;
724 LeaveCriticalSection(&This->crit);
725 return DI_OK;
728 ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface)
730 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
731 ULONG ref;
733 ref = InterlockedDecrement(&(This->ref));
734 if (ref) return ref;
736 IDirectInputDevice_Unacquire(iface);
737 /* Reset the FF state, free all effects, etc */
738 IDirectInputDevice8_SendForceFeedbackCommand(iface, DISFFC_RESET);
740 HeapFree(GetProcessHeap(), 0, This->data_queue);
742 /* Free data format */
743 HeapFree(GetProcessHeap(), 0, This->data_format.wine_df->rgodf);
744 HeapFree(GetProcessHeap(), 0, This->data_format.wine_df);
745 release_DataFormat(&This->data_format);
747 EnterCriticalSection( &This->dinput->crit );
748 list_remove( &This->entry );
749 LeaveCriticalSection( &This->dinput->crit );
751 IDirectInput_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
752 This->crit.DebugInfo->Spare[0] = 0;
753 DeleteCriticalSection(&This->crit);
755 HeapFree(GetProcessHeap(), 0, This);
757 return DI_OK;
760 HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(
761 LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj
764 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
766 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
767 if (IsEqualGUID(&IID_IUnknown,riid)) {
768 IDirectInputDevice2_AddRef(iface);
769 *ppobj = This;
770 return DI_OK;
772 if (IsEqualGUID(&IID_IDirectInputDeviceA,riid)) {
773 IDirectInputDevice2_AddRef(iface);
774 *ppobj = This;
775 return DI_OK;
777 if (IsEqualGUID(&IID_IDirectInputDevice2A,riid)) {
778 IDirectInputDevice2_AddRef(iface);
779 *ppobj = This;
780 return DI_OK;
782 if (IsEqualGUID(&IID_IDirectInputDevice7A,riid)) {
783 IDirectInputDevice7_AddRef(iface);
784 *ppobj = This;
785 return DI_OK;
787 if (IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
788 IDirectInputDevice8_AddRef(iface);
789 *ppobj = This;
790 return DI_OK;
792 TRACE("Unsupported interface !\n");
793 return E_FAIL;
796 HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(
797 LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj
800 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
802 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
803 if (IsEqualGUID(&IID_IUnknown,riid)) {
804 IDirectInputDevice2_AddRef(iface);
805 *ppobj = This;
806 return DI_OK;
808 if (IsEqualGUID(&IID_IDirectInputDeviceW,riid)) {
809 IDirectInputDevice2_AddRef(iface);
810 *ppobj = This;
811 return DI_OK;
813 if (IsEqualGUID(&IID_IDirectInputDevice2W,riid)) {
814 IDirectInputDevice2_AddRef(iface);
815 *ppobj = This;
816 return DI_OK;
818 if (IsEqualGUID(&IID_IDirectInputDevice7W,riid)) {
819 IDirectInputDevice7_AddRef(iface);
820 *ppobj = This;
821 return DI_OK;
823 if (IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
824 IDirectInputDevice8_AddRef(iface);
825 *ppobj = This;
826 return DI_OK;
828 TRACE("Unsupported interface !\n");
829 return E_FAIL;
832 ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
833 LPDIRECTINPUTDEVICE8A iface)
835 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
836 return InterlockedIncrement(&(This->ref));
839 HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(LPDIRECTINPUTDEVICE8A iface,
840 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback, LPVOID lpvRef, DWORD dwFlags)
842 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
843 DIDEVICEOBJECTINSTANCEA ddoi;
844 int i;
846 TRACE("(%p) %p,%p flags:%08x)\n", iface, lpCallback, lpvRef, dwFlags);
847 TRACE(" - flags = ");
848 _dump_EnumObjects_flags(dwFlags);
849 TRACE("\n");
851 /* Only the fields till dwFFMaxForce are relevant */
852 memset(&ddoi, 0, sizeof(ddoi));
853 ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce);
855 for (i = 0; i < This->data_format.wine_df->dwNumObjs; i++)
857 LPDIOBJECTDATAFORMAT odf = dataformat_to_odf(This->data_format.wine_df, i);
859 if (dwFlags != DIDFT_ALL && !(dwFlags & DIEFT_GETTYPE(odf->dwType))) continue;
860 if (IDirectInputDevice_GetObjectInfo(iface, &ddoi, odf->dwType, DIPH_BYID) != DI_OK)
861 continue;
863 if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) break;
866 return DI_OK;
869 HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
870 LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID lpvRef, DWORD dwFlags)
872 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
873 DIDEVICEOBJECTINSTANCEW ddoi;
874 int i;
876 TRACE("(%p) %p,%p flags:%08x)\n", iface, lpCallback, lpvRef, dwFlags);
877 TRACE(" - flags = ");
878 _dump_EnumObjects_flags(dwFlags);
879 TRACE("\n");
881 /* Only the fields till dwFFMaxForce are relevant */
882 memset(&ddoi, 0, sizeof(ddoi));
883 ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, dwFFMaxForce);
885 for (i = 0; i < This->data_format.wine_df->dwNumObjs; i++)
887 LPDIOBJECTDATAFORMAT odf = dataformat_to_odf(This->data_format.wine_df, i);
889 if (dwFlags != DIDFT_ALL && !(dwFlags & DIEFT_GETTYPE(odf->dwType))) continue;
890 if (IDirectInputDevice_GetObjectInfo(iface, &ddoi, odf->dwType, DIPH_BYID) != DI_OK)
891 continue;
893 if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) break;
896 return DI_OK;
899 /******************************************************************************
900 * GetProperty
903 HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
904 LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
906 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
908 TRACE("(%p) %s,%p\n", iface, debugstr_guid(rguid), pdiph);
909 _dump_DIPROPHEADER(pdiph);
911 if (HIWORD(rguid)) return DI_OK;
913 switch (LOWORD(rguid))
915 case (DWORD) DIPROP_BUFFERSIZE:
917 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
919 if (pdiph->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
921 pd->dwData = This->queue_len;
922 TRACE("buffersize = %d\n", pd->dwData);
923 break;
925 default:
926 WARN("Unknown property %s\n", debugstr_guid(rguid));
927 break;
930 return DI_OK;
933 /******************************************************************************
934 * SetProperty
937 HRESULT WINAPI IDirectInputDevice2AImpl_SetProperty(
938 LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIPROPHEADER pdiph)
940 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
942 TRACE("(%p) %s,%p\n", iface, debugstr_guid(rguid), pdiph);
943 _dump_DIPROPHEADER(pdiph);
945 if (HIWORD(rguid)) return DI_OK;
947 switch (LOWORD(rguid))
949 case (DWORD) DIPROP_AXISMODE:
951 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)pdiph;
953 if (pdiph->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
954 if (pdiph->dwHow == DIPH_DEVICE && pdiph->dwObj) return DIERR_INVALIDPARAM;
955 if (This->acquired) return DIERR_ACQUIRED;
956 if (pdiph->dwHow != DIPH_DEVICE) return DIERR_UNSUPPORTED;
957 if (!This->data_format.user_df) return DI_OK;
959 TRACE("Axis mode: %s\n", pd->dwData == DIPROPAXISMODE_ABS ? "absolute" :
960 "relative");
962 EnterCriticalSection(&This->crit);
963 This->data_format.user_df->dwFlags &= ~DIDFT_AXIS;
964 This->data_format.user_df->dwFlags |= pd->dwData == DIPROPAXISMODE_ABS ?
965 DIDF_ABSAXIS : DIDF_RELAXIS;
966 LeaveCriticalSection(&This->crit);
967 break;
969 case (DWORD) DIPROP_BUFFERSIZE:
971 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)pdiph;
973 if (pdiph->dwSize != sizeof(DIPROPDWORD)) return DIERR_INVALIDPARAM;
974 if (This->acquired) return DIERR_ACQUIRED;
976 TRACE("buffersize = %d\n", pd->dwData);
978 EnterCriticalSection(&This->crit);
979 HeapFree(GetProcessHeap(), 0, This->data_queue);
981 This->data_queue = !pd->dwData ? NULL : HeapAlloc(GetProcessHeap(), 0,
982 pd->dwData * sizeof(DIDEVICEOBJECTDATA));
983 This->queue_head = This->queue_tail = This->overflow = 0;
984 This->queue_len = pd->dwData;
986 LeaveCriticalSection(&This->crit);
987 break;
989 default:
990 WARN("Unknown property %s\n", debugstr_guid(rguid));
991 return DIERR_UNSUPPORTED;
994 return DI_OK;
997 HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
998 LPDIRECTINPUTDEVICE8A iface,
999 LPDIDEVICEOBJECTINSTANCEA pdidoi,
1000 DWORD dwObj,
1001 DWORD dwHow)
1003 DIDEVICEOBJECTINSTANCEW didoiW;
1004 HRESULT res;
1006 if (!pdidoi ||
1007 (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA) &&
1008 pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A)))
1009 return DIERR_INVALIDPARAM;
1011 didoiW.dwSize = sizeof(didoiW);
1012 res = IDirectInputDevice2WImpl_GetObjectInfo((LPDIRECTINPUTDEVICE8W)iface, &didoiW, dwObj, dwHow);
1013 if (res == DI_OK)
1015 DWORD dwSize = pdidoi->dwSize;
1017 memset(pdidoi, 0, pdidoi->dwSize);
1018 pdidoi->dwSize = dwSize;
1019 pdidoi->guidType = didoiW.guidType;
1020 pdidoi->dwOfs = didoiW.dwOfs;
1021 pdidoi->dwType = didoiW.dwType;
1022 pdidoi->dwFlags = didoiW.dwFlags;
1025 return res;
1028 HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(
1029 LPDIRECTINPUTDEVICE8W iface,
1030 LPDIDEVICEOBJECTINSTANCEW pdidoi,
1031 DWORD dwObj,
1032 DWORD dwHow)
1034 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
1035 DWORD dwSize;
1036 LPDIOBJECTDATAFORMAT odf;
1037 int idx = -1;
1039 TRACE("(%p) %d(0x%08x) -> %p\n", This, dwHow, dwObj, pdidoi);
1041 if (!pdidoi ||
1042 (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEW) &&
1043 pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3W)))
1044 return DIERR_INVALIDPARAM;
1046 switch (dwHow)
1048 case DIPH_BYOFFSET:
1049 if (!This->data_format.offsets) break;
1050 for (idx = This->data_format.wine_df->dwNumObjs - 1; idx >= 0; idx--)
1051 if (This->data_format.offsets[idx] == dwObj) break;
1052 break;
1053 case DIPH_BYID:
1054 dwObj &= 0x00ffffff;
1055 for (idx = This->data_format.wine_df->dwNumObjs - 1; idx >= 0; idx--)
1056 if ((dataformat_to_odf(This->data_format.wine_df, idx)->dwType & 0x00ffffff) == dwObj)
1057 break;
1058 break;
1060 case DIPH_BYUSAGE:
1061 FIXME("dwHow = DIPH_BYUSAGE not implemented\n");
1062 break;
1063 default:
1064 WARN("invalid parameter: dwHow = %08x\n", dwHow);
1065 return DIERR_INVALIDPARAM;
1067 if (idx < 0) return DIERR_OBJECTNOTFOUND;
1069 odf = dataformat_to_odf(This->data_format.wine_df, idx);
1070 dwSize = pdidoi->dwSize; /* save due to memset below */
1071 memset(pdidoi, 0, pdidoi->dwSize);
1072 pdidoi->dwSize = dwSize;
1073 if (odf->pguid) pdidoi->guidType = *odf->pguid;
1074 pdidoi->dwOfs = This->data_format.offsets ? This->data_format.offsets[idx] : odf->dwOfs;
1075 pdidoi->dwType = odf->dwType;
1076 pdidoi->dwFlags = odf->dwFlags;
1078 return DI_OK;
1081 HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceData(
1082 LPDIRECTINPUTDEVICE8A iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod,
1083 LPDWORD entries, DWORD flags)
1085 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
1086 HRESULT ret = DI_OK;
1087 int len;
1089 TRACE("(%p) %p -> %p(%d) x%d, 0x%08x\n",
1090 This, dod, entries, entries ? *entries : 0, dodsize, flags);
1092 if (!This->acquired)
1093 return DIERR_NOTACQUIRED;
1094 if (!This->queue_len)
1095 return DIERR_NOTBUFFERED;
1096 if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3))
1097 return DIERR_INVALIDPARAM;
1099 IDirectInputDevice2_Poll(iface);
1100 EnterCriticalSection(&This->crit);
1102 len = This->queue_head - This->queue_tail;
1103 if (len < 0) len += This->queue_len;
1105 if ((*entries != INFINITE) && (len > *entries)) len = *entries;
1107 if (dod)
1109 int i;
1110 for (i = 0; i < len; i++)
1112 int n = (This->queue_tail + i) % This->queue_len;
1113 memcpy((char *)dod + dodsize * i, This->data_queue + n, dodsize);
1116 *entries = len;
1118 if (This->overflow)
1119 ret = DI_BUFFEROVERFLOW;
1121 if (!(flags & DIGDD_PEEK))
1123 /* Advance reading position */
1124 This->queue_tail = (This->queue_tail + len) % This->queue_len;
1125 This->overflow = FALSE;
1128 LeaveCriticalSection(&This->crit);
1130 TRACE("Returning %d events queued\n", *entries);
1131 return ret;
1134 HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
1135 LPDIRECTINPUTDEVICE8A iface,
1136 LPDIDEVICEINSTANCEA pdidi)
1138 FIXME("(this=%p,%p): stub!\n",
1139 iface, pdidi);
1141 return DI_OK;
1144 HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo(
1145 LPDIRECTINPUTDEVICE8W iface,
1146 LPDIDEVICEINSTANCEW pdidi)
1148 FIXME("(this=%p,%p): stub!\n",
1149 iface, pdidi);
1151 return DI_OK;
1154 HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
1155 LPDIRECTINPUTDEVICE8A iface,
1156 HWND hwndOwner,
1157 DWORD dwFlags)
1159 FIXME("(this=%p,%p,0x%08x): stub!\n",
1160 iface, hwndOwner, dwFlags);
1162 return DI_OK;
1165 HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
1166 LPDIRECTINPUTDEVICE8A iface,
1167 HINSTANCE hinst,
1168 DWORD dwVersion,
1169 REFGUID rguid)
1171 FIXME("(this=%p,%p,%d,%s): stub!\n",
1172 iface, hinst, dwVersion, debugstr_guid(rguid));
1173 return DI_OK;
1176 /******************************************************************************
1177 * IDirectInputDevice2A
1180 HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
1181 LPDIRECTINPUTDEVICE8A iface,
1182 REFGUID rguid,
1183 LPCDIEFFECT lpeff,
1184 LPDIRECTINPUTEFFECT *ppdef,
1185 LPUNKNOWN pUnkOuter)
1187 FIXME("(this=%p,%s,%p,%p,%p): stub!\n",
1188 iface, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter);
1189 return DI_OK;
1192 HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
1193 LPDIRECTINPUTDEVICE8A iface,
1194 LPDIENUMEFFECTSCALLBACKA lpCallback,
1195 LPVOID lpvRef,
1196 DWORD dwFlags)
1198 FIXME("(this=%p,%p,%p,0x%08x): stub!\n",
1199 iface, lpCallback, lpvRef, dwFlags);
1201 return DI_OK;
1204 HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
1205 LPDIRECTINPUTDEVICE8W iface,
1206 LPDIENUMEFFECTSCALLBACKW lpCallback,
1207 LPVOID lpvRef,
1208 DWORD dwFlags)
1210 FIXME("(this=%p,%p,%p,0x%08x): stub!\n",
1211 iface, lpCallback, lpvRef, dwFlags);
1213 return DI_OK;
1216 HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
1217 LPDIRECTINPUTDEVICE8A iface,
1218 LPDIEFFECTINFOA lpdei,
1219 REFGUID rguid)
1221 FIXME("(this=%p,%p,%s): stub!\n",
1222 iface, lpdei, debugstr_guid(rguid));
1223 return DI_OK;
1226 HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
1227 LPDIRECTINPUTDEVICE8W iface,
1228 LPDIEFFECTINFOW lpdei,
1229 REFGUID rguid)
1231 FIXME("(this=%p,%p,%s): stub!\n",
1232 iface, lpdei, debugstr_guid(rguid));
1233 return DI_OK;
1236 HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
1237 LPDIRECTINPUTDEVICE8A iface,
1238 LPDWORD pdwOut)
1240 FIXME("(this=%p,%p): stub!\n",
1241 iface, pdwOut);
1242 return DI_OK;
1245 HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
1246 LPDIRECTINPUTDEVICE8A iface,
1247 DWORD dwFlags)
1249 TRACE("(%p) 0x%08x:\n", iface, dwFlags);
1250 return DI_NOEFFECT;
1253 HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
1254 LPDIRECTINPUTDEVICE8A iface,
1255 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
1256 LPVOID lpvRef,
1257 DWORD dwFlags)
1259 FIXME("(this=%p,%p,%p,0x%08x): stub!\n",
1260 iface, lpCallback, lpvRef, dwFlags);
1261 return DI_OK;
1264 HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
1265 LPDIRECTINPUTDEVICE8A iface,
1266 LPDIEFFESCAPE lpDIEEsc)
1268 FIXME("(this=%p,%p): stub!\n",
1269 iface, lpDIEEsc);
1270 return DI_OK;
1273 HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
1274 LPDIRECTINPUTDEVICE8A iface)
1276 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
1278 if (!This->acquired) return DIERR_NOTACQUIRED;
1279 /* Because wine devices do not need to be polled, just return DI_NOEFFECT */
1280 return DI_NOEFFECT;
1283 HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
1284 LPDIRECTINPUTDEVICE8A iface,
1285 DWORD cbObjectData,
1286 LPCDIDEVICEOBJECTDATA rgdod,
1287 LPDWORD pdwInOut,
1288 DWORD dwFlags)
1290 FIXME("(this=%p,0x%08x,%p,%p,0x%08x): stub!\n",
1291 iface, cbObjectData, rgdod, pdwInOut, dwFlags);
1293 return DI_OK;
1296 HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface,
1297 LPCSTR lpszFileName,
1298 LPDIENUMEFFECTSINFILECALLBACK pec,
1299 LPVOID pvRef,
1300 DWORD dwFlags)
1302 FIXME("(%p)->(%s,%p,%p,%08x): stub !\n", iface, lpszFileName, pec, pvRef, dwFlags);
1304 return DI_OK;
1307 HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
1308 LPCWSTR lpszFileName,
1309 LPDIENUMEFFECTSINFILECALLBACK pec,
1310 LPVOID pvRef,
1311 DWORD dwFlags)
1313 FIXME("(%p)->(%s,%p,%p,%08x): stub !\n", iface, debugstr_w(lpszFileName), pec, pvRef, dwFlags);
1315 return DI_OK;
1318 HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
1319 LPCSTR lpszFileName,
1320 DWORD dwEntries,
1321 LPDIFILEEFFECT rgDiFileEft,
1322 DWORD dwFlags)
1324 FIXME("(%p)->(%s,%08x,%p,%08x): stub !\n", iface, lpszFileName, dwEntries, rgDiFileEft, dwFlags);
1326 return DI_OK;
1329 HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
1330 LPCWSTR lpszFileName,
1331 DWORD dwEntries,
1332 LPDIFILEEFFECT rgDiFileEft,
1333 DWORD dwFlags)
1335 FIXME("(%p)->(%s,%08x,%p,%08x): stub !\n", iface, debugstr_w(lpszFileName), dwEntries, rgDiFileEft, dwFlags);
1337 return DI_OK;
1340 HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
1341 LPDIACTIONFORMATA lpdiaf,
1342 LPCSTR lpszUserName,
1343 DWORD dwFlags)
1345 FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
1347 return DI_OK;
1350 HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
1351 LPDIACTIONFORMATW lpdiaf,
1352 LPCWSTR lpszUserName,
1353 DWORD dwFlags)
1355 FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
1357 return DI_OK;
1360 HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
1361 LPDIACTIONFORMATA lpdiaf,
1362 LPCSTR lpszUserName,
1363 DWORD dwFlags)
1365 FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
1367 return DI_OK;
1370 HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
1371 LPDIACTIONFORMATW lpdiaf,
1372 LPCWSTR lpszUserName,
1373 DWORD dwFlags)
1375 FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
1377 return DI_OK;
1380 HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
1381 LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader)
1383 FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
1385 return DI_OK;
1388 HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
1389 LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader)
1391 FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
1393 return DI_OK;