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"
38 #include "device_private.h"
39 #include "dinput_private.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
43 /******************************************************************************
44 * Various debugging tools
46 void _dump_cooperativelevel_DI(DWORD dwFlags) {
47 if (TRACE_ON(dinput)) {
53 #define FE(x) { x, #x}
57 FE(DISCL_NONEXCLUSIVE)
60 for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++)
61 if (flags[i].mask & dwFlags)
62 DPRINTF("%s ",flags[i].name);
67 void _dump_EnumObjects_flags(DWORD dwFlags) {
68 if (TRACE_ON(dinput)) {
75 #define FE(x) { x, #x}
84 FE(DIDFT_FFEFFECTTRIGGER),
86 FE(DIDFT_VENDORDEFINED),
91 type = (dwFlags & 0xFF0000FF);
92 instance = ((dwFlags >> 8) & 0xFFFF);
94 if (type == DIDFT_ALL) {
95 DPRINTF(" DIDFT_ALL");
97 for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++) {
98 if (flags[i].mask & type) {
99 type &= ~flags[i].mask;
100 DPRINTF(" %s",flags[i].name);
104 DPRINTF(" (unhandled: %08lx)", type);
107 DPRINTF(" / Instance: ");
108 if (instance == ((DIDFT_ANYINSTANCE >> 8) & 0xFFFF)) {
109 DPRINTF("DIDFT_ANYINSTANCE");
111 DPRINTF("%3ld", instance);
116 void _dump_DIPROPHEADER(LPCDIPROPHEADER diph) {
117 if (TRACE_ON(dinput)) {
118 DPRINTF(" - dwObj = 0x%08lx\n", diph->dwObj);
119 DPRINTF(" - dwHow = %s\n",
120 ((diph->dwHow == DIPH_DEVICE) ? "DIPH_DEVICE" :
121 ((diph->dwHow == DIPH_BYOFFSET) ? "DIPH_BYOFFSET" :
122 ((diph->dwHow == DIPH_BYID)) ? "DIPH_BYID" : "unknown")));
126 void _dump_OBJECTINSTANCEA(DIDEVICEOBJECTINSTANCEA *ddoi) {
127 if (TRACE_ON(dinput)) {
128 DPRINTF(" - enumerating : %s ('%s') - %2ld - 0x%08lx - %s\n",
129 debugstr_guid(&ddoi->guidType), _dump_dinput_GUID(&ddoi->guidType), ddoi->dwOfs, ddoi->dwType, ddoi->tszName);
133 void _dump_OBJECTINSTANCEW(DIDEVICEOBJECTINSTANCEW *ddoi) {
134 if (TRACE_ON(dinput)) {
135 DPRINTF(" - enumerating : %s ('%s'), - %2ld - 0x%08lx - %s\n",
136 debugstr_guid(&ddoi->guidType), _dump_dinput_GUID(&ddoi->guidType), ddoi->dwOfs, ddoi->dwType, debugstr_w(ddoi->tszName));
140 /* This function is a helper to convert a GUID into any possible DInput GUID out there */
141 const char *_dump_dinput_GUID(const GUID *guid) {
143 static const struct {
147 #define FE(x) { &x, #x}
160 FE(GUID_SysKeyboard),
162 FE(GUID_ConstantForce),
168 FE(GUID_SawtoothDown),
178 for (i = 0; i < (sizeof(guids) / sizeof(guids[0])); i++) {
179 if (IsEqualGUID(guids[i].guid, guid)) {
180 return guids[i].name;
183 return "Unknown GUID";
186 void _dump_DIDATAFORMAT(const DIDATAFORMAT *df) {
189 TRACE("Dumping DIDATAFORMAT structure:\n");
190 TRACE(" - dwSize: %ld\n", df->dwSize);
191 if (df->dwSize != sizeof(DIDATAFORMAT)) {
192 WARN("Non-standard DIDATAFORMAT structure size %ld\n", df->dwSize);
194 TRACE(" - dwObjsize: %ld\n", df->dwObjSize);
195 if (df->dwObjSize != sizeof(DIOBJECTDATAFORMAT)) {
196 WARN("Non-standard DIOBJECTDATAFORMAT structure size %ld\n", df->dwObjSize);
198 TRACE(" - dwFlags: 0x%08lx (", df->dwFlags);
199 switch (df->dwFlags) {
200 case DIDF_ABSAXIS: TRACE("DIDF_ABSAXIS"); break;
201 case DIDF_RELAXIS: TRACE("DIDF_RELAXIS"); break;
202 default: TRACE("unknown"); break;
205 TRACE(" - dwDataSize: %ld\n", df->dwDataSize);
206 TRACE(" - dwNumObjs: %ld\n", df->dwNumObjs);
208 for (i = 0; i < df->dwNumObjs; i++) {
209 TRACE(" - Object %d:\n", i);
210 TRACE(" * GUID: %s ('%s')\n", debugstr_guid(df->rgodf[i].pguid), _dump_dinput_GUID(df->rgodf[i].pguid));
211 TRACE(" * dwOfs: %ld\n", df->rgodf[i].dwOfs);
212 TRACE(" * dwType: 0x%08lx\n", df->rgodf[i].dwType);
213 TRACE(" "); _dump_EnumObjects_flags(df->rgodf[i].dwType); TRACE("\n");
214 TRACE(" * dwFlags: 0x%08lx\n", df->rgodf[i].dwFlags);
218 /* Conversion between internal data buffer and external data buffer */
219 void fill_DataFormat(void *out, const void *in, DataFormat *df) {
221 char *in_c = (char *) in;
222 char *out_c = (char *) out;
224 if (df->dt == NULL) {
225 /* This means that the app uses Wine's internal data format */
226 memcpy(out, in, df->internal_format_size);
228 for (i = 0; i < df->size; i++) {
229 if (df->dt[i].offset_in >= 0) {
230 switch (df->dt[i].size) {
232 TRACE("Copying (c) to %d from %d (value %d)\n",
233 df->dt[i].offset_out, df->dt[i].offset_in, *((char *) (in_c + df->dt[i].offset_in)));
234 *((char *) (out_c + df->dt[i].offset_out)) = *((char *) (in_c + df->dt[i].offset_in));
238 TRACE("Copying (s) to %d from %d (value %d)\n",
239 df->dt[i].offset_out, df->dt[i].offset_in, *((short *) (in_c + df->dt[i].offset_in)));
240 *((short *) (out_c + df->dt[i].offset_out)) = *((short *) (in_c + df->dt[i].offset_in));
244 TRACE("Copying (i) to %d from %d (value %d)\n",
245 df->dt[i].offset_out, df->dt[i].offset_in, *((int *) (in_c + df->dt[i].offset_in)));
246 *((int *) (out_c + df->dt[i].offset_out)) = *((int *) (in_c + df->dt[i].offset_in));
250 memcpy((out_c + df->dt[i].offset_out), (in_c + df->dt[i].offset_in), df->dt[i].size);
254 switch (df->dt[i].size) {
256 TRACE("Copying (c) to %d default value %d\n",
257 df->dt[i].offset_out, df->dt[i].value);
258 *((char *) (out_c + df->dt[i].offset_out)) = (char) df->dt[i].value;
262 TRACE("Copying (s) to %d default value %d\n",
263 df->dt[i].offset_out, df->dt[i].value);
264 *((short *) (out_c + df->dt[i].offset_out)) = (short) df->dt[i].value;
268 TRACE("Copying (i) to %d default value %d\n",
269 df->dt[i].offset_out, df->dt[i].value);
270 *((int *) (out_c + df->dt[i].offset_out)) = (int) df->dt[i].value;
274 memset((out_c + df->dt[i].offset_out), df->dt[i].size, 0);
282 void release_DataFormat(DataFormat * format)
284 TRACE("Deleting DataTransform :\n");
286 HeapFree(GetProcessHeap(), 0, format->dt);
289 DataFormat *create_DataFormat(const DIDATAFORMAT *wine_format, LPCDIDATAFORMAT asked_format, int *offset) {
298 ret = HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
300 done = HeapAlloc(GetProcessHeap(), 0, sizeof(int) * asked_format->dwNumObjs);
301 memset(done, 0, sizeof(int) * asked_format->dwNumObjs);
303 dt = HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform));
305 TRACE("Creating DataTransform :\n");
307 for (i = 0; i < wine_format->dwNumObjs; i++) {
310 for (j = 0; j < asked_format->dwNumObjs; j++) {
314 if (/* Check if the application either requests any GUID and if not, it if matches
315 * the GUID of the Wine object.
317 ((asked_format->rgodf[j].pguid == NULL) ||
318 (wine_format->rgodf[i].pguid == NULL) ||
319 (IsEqualGUID(wine_format->rgodf[i].pguid, asked_format->rgodf[j].pguid)))
321 (/* Then check if it accepts any instance id, and if not, if it matches Wine's
324 (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0xFFFF) ||
325 (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0x00FF) || /* This is mentionned in no DX docs, but it works fine - tested on WinXP */
326 (DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == DIDFT_GETINSTANCE(wine_format->rgodf[i].dwType)))
328 ( /* Then if the asked type matches the one Wine provides */
329 wine_format->rgodf[i].dwType & asked_format->rgodf[j].dwType)) {
333 TRACE("Matching :\n");
334 TRACE(" - Asked (%d) :\n", j);
335 TRACE(" * GUID: %s ('%s')\n",
336 debugstr_guid(asked_format->rgodf[j].pguid),
337 _dump_dinput_GUID(asked_format->rgodf[j].pguid));
338 TRACE(" * Offset: %3ld\n", asked_format->rgodf[j].dwOfs);
339 TRACE(" * dwType: %08lx\n", asked_format->rgodf[j].dwType);
340 TRACE(" "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
342 TRACE(" - Wine (%d) :\n", i);
343 TRACE(" * GUID: %s ('%s')\n",
344 debugstr_guid(wine_format->rgodf[i].pguid),
345 _dump_dinput_GUID(wine_format->rgodf[i].pguid));
346 TRACE(" * Offset: %3ld\n", wine_format->rgodf[i].dwOfs);
347 TRACE(" * dwType: %08lx\n", wine_format->rgodf[i].dwType);
348 TRACE(" "); _dump_EnumObjects_flags(wine_format->rgodf[i].dwType); TRACE("\n");
350 if (wine_format->rgodf[i].dwType & DIDFT_BUTTON)
351 dt[index].size = sizeof(BYTE);
353 dt[index].size = sizeof(DWORD);
354 dt[index].offset_in = wine_format->rgodf[i].dwOfs;
355 if (asked_format->rgodf[j].dwOfs < next) {
356 WARN("bad format: dwOfs=%ld, changing to %ld\n", asked_format->rgodf[j].dwOfs, next);
357 dt[index].offset_out = next;
360 dt[index].offset_out = asked_format->rgodf[j].dwOfs;
361 offset[i] = asked_format->rgodf[j].dwOfs;
364 next = next + dt[index].size;
366 if (wine_format->rgodf[i].dwOfs != dt[index].offset_out)
374 if (j == asked_format->dwNumObjs)
378 TRACE("Setting to default value :\n");
379 for (j = 0; j < asked_format->dwNumObjs; j++) {
381 TRACE(" - Asked (%d) :\n", j);
382 TRACE(" * GUID: %s ('%s')\n",
383 debugstr_guid(asked_format->rgodf[j].pguid),
384 _dump_dinput_GUID(asked_format->rgodf[j].pguid));
385 TRACE(" * Offset: %3ld\n", asked_format->rgodf[j].dwOfs);
386 TRACE(" * dwType: %08lx\n", asked_format->rgodf[j].dwType);
387 TRACE(" "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
389 if (asked_format->rgodf[j].dwType & DIDFT_BUTTON)
390 dt[index].size = sizeof(BYTE);
392 dt[index].size = sizeof(DWORD);
393 dt[index].offset_in = -1;
394 dt[index].offset_out = asked_format->rgodf[j].dwOfs;
402 ret->internal_format_size = wine_format->dwDataSize;
406 HeapFree(GetProcessHeap(), 0, dt);
411 HeapFree(GetProcessHeap(), 0, done);
416 BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA lpddi, LPVOID lpvRef) {
417 DIDEVICEOBJECTINSTANCEW ddtmp;
418 device_enumobjects_AtoWcb_data* data;
420 data = (device_enumobjects_AtoWcb_data*) lpvRef;
422 memset(&ddtmp, 0, sizeof(ddtmp));
424 ddtmp.dwSize = sizeof(DIDEVICEINSTANCEW);
425 ddtmp.guidType = lpddi->guidType;
426 ddtmp.dwOfs = lpddi->dwOfs;
427 ddtmp.dwType = lpddi->dwType;
428 ddtmp.dwFlags = lpddi->dwFlags;
429 MultiByteToWideChar(CP_ACP, 0, lpddi->tszName, -1, ddtmp.tszName, MAX_PATH);
431 if (lpddi->dwSize == sizeof(DIDEVICEINSTANCEA)) {
433 * if dwSize < sizeof(DIDEVICEINSTANCEA of DInput version >= 5)
434 * force feedback and other newer datas aren't available
436 ddtmp.dwFFMaxForce = lpddi->dwFFMaxForce;
437 ddtmp.dwFFForceResolution = lpddi->dwFFForceResolution;
438 ddtmp.wCollectionNumber = lpddi->wCollectionNumber;
439 ddtmp.wDesignatorIndex = lpddi->wDesignatorIndex;
440 ddtmp.wUsagePage = lpddi->wUsagePage;
441 ddtmp.wUsage = lpddi->wUsage;
442 ddtmp.dwDimension = lpddi->dwDimension;
443 ddtmp.wExponent = lpddi->wExponent;
444 ddtmp.wReserved = lpddi->wReserved;
446 return data->lpCallBack(&ddtmp, data->lpvRef);
449 /******************************************************************************
450 * IDirectInputDeviceA
453 HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
454 LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
456 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
458 TRACE("(this=%p,%p)\n",This,df);
460 _dump_DIDATAFORMAT(df);
465 HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
466 LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags
468 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
469 TRACE("(this=%p,%p,0x%08lx)\n",This,hwnd,dwflags);
470 if (TRACE_ON(dinput)) {
471 TRACE(" cooperative level : ");
472 _dump_cooperativelevel_DI(dwflags);
477 HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
478 LPDIRECTINPUTDEVICE8A iface,HANDLE hnd
480 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
481 FIXME("(this=%p,%p): stub\n",This,hnd);
485 ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE8A iface)
487 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
489 ref = InterlockedDecrement(&(This->ref));
491 HeapFree(GetProcessHeap(),0,This);
495 HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(
496 LPDIRECTINPUTDEVICE8A iface,REFIID riid,LPVOID *ppobj
499 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
501 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
502 if (IsEqualGUID(&IID_IUnknown,riid)) {
503 IDirectInputDevice2_AddRef(iface);
507 if (IsEqualGUID(&IID_IDirectInputDeviceA,riid)) {
508 IDirectInputDevice2_AddRef(iface);
512 if (IsEqualGUID(&IID_IDirectInputDevice2A,riid)) {
513 IDirectInputDevice2_AddRef(iface);
517 if (IsEqualGUID(&IID_IDirectInputDevice7A,riid)) {
518 IDirectInputDevice7_AddRef(iface);
522 if (IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
523 IDirectInputDevice8_AddRef(iface);
527 TRACE("Unsupported interface !\n");
531 HRESULT WINAPI IDirectInputDevice2WImpl_QueryInterface(
532 LPDIRECTINPUTDEVICE8W iface,REFIID riid,LPVOID *ppobj
535 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
537 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(riid),ppobj);
538 if (IsEqualGUID(&IID_IUnknown,riid)) {
539 IDirectInputDevice2_AddRef(iface);
543 if (IsEqualGUID(&IID_IDirectInputDeviceW,riid)) {
544 IDirectInputDevice2_AddRef(iface);
548 if (IsEqualGUID(&IID_IDirectInputDevice2W,riid)) {
549 IDirectInputDevice2_AddRef(iface);
553 if (IsEqualGUID(&IID_IDirectInputDevice7W,riid)) {
554 IDirectInputDevice7_AddRef(iface);
558 if (IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
559 IDirectInputDevice8_AddRef(iface);
563 TRACE("Unsupported interface !\n");
567 ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
568 LPDIRECTINPUTDEVICE8A iface)
570 IDirectInputDevice2AImpl *This = (IDirectInputDevice2AImpl *)iface;
571 return InterlockedIncrement(&(This->ref));
574 HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
575 LPDIRECTINPUTDEVICE8A iface,
576 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
580 FIXME("(this=%p,%p,%p,%08lx): stub!\n", iface, lpCallback, lpvRef, dwFlags);
581 if (TRACE_ON(dinput)) {
582 DPRINTF(" - flags = ");
583 _dump_EnumObjects_flags(dwFlags);
590 HRESULT WINAPI IDirectInputDevice2WImpl_EnumObjects(
591 LPDIRECTINPUTDEVICE8W iface,
592 LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
596 FIXME("(this=%p,%p,%p,%08lx): stub!\n", iface, lpCallback, lpvRef, dwFlags);
597 if (TRACE_ON(dinput)) {
598 DPRINTF(" - flags = ");
599 _dump_EnumObjects_flags(dwFlags);
606 HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
607 LPDIRECTINPUTDEVICE8A iface,
609 LPDIPROPHEADER pdiph)
611 FIXME("(this=%p,%s,%p): stub!\n",
612 iface, debugstr_guid(rguid), pdiph);
614 if (TRACE_ON(dinput))
615 _dump_DIPROPHEADER(pdiph);
620 HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
621 LPDIRECTINPUTDEVICE8A iface,
622 LPDIDEVICEOBJECTINSTANCEA pdidoi,
626 FIXME("(this=%p,%p,%ld,0x%08lx): stub!\n",
627 iface, pdidoi, dwObj, dwHow);
632 HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(
633 LPDIRECTINPUTDEVICE8W iface,
634 LPDIDEVICEOBJECTINSTANCEW pdidoi,
638 FIXME("(this=%p,%p,%ld,0x%08lx): stub!\n",
639 iface, pdidoi, dwObj, dwHow);
644 HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
645 LPDIRECTINPUTDEVICE8A iface,
646 LPDIDEVICEINSTANCEA pdidi)
648 FIXME("(this=%p,%p): stub!\n",
654 HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceInfo(
655 LPDIRECTINPUTDEVICE8W iface,
656 LPDIDEVICEINSTANCEW pdidi)
658 FIXME("(this=%p,%p): stub!\n",
664 HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
665 LPDIRECTINPUTDEVICE8A iface,
669 FIXME("(this=%p,%p,0x%08lx): stub!\n",
670 iface, hwndOwner, dwFlags);
675 HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
676 LPDIRECTINPUTDEVICE8A iface,
681 FIXME("(this=%p,%p,%ld,%s): stub!\n",
682 iface, hinst, dwVersion, debugstr_guid(rguid));
686 /******************************************************************************
687 * IDirectInputDevice2A
690 HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
691 LPDIRECTINPUTDEVICE8A iface,
694 LPDIRECTINPUTEFFECT *ppdef,
697 FIXME("(this=%p,%s,%p,%p,%p): stub!\n",
698 iface, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter);
702 HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
703 LPDIRECTINPUTDEVICE8A iface,
704 LPDIENUMEFFECTSCALLBACKA lpCallback,
708 FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
709 iface, lpCallback, lpvRef, dwFlags);
714 HRESULT WINAPI IDirectInputDevice2WImpl_EnumEffects(
715 LPDIRECTINPUTDEVICE8W iface,
716 LPDIENUMEFFECTSCALLBACKW lpCallback,
720 FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
721 iface, lpCallback, lpvRef, dwFlags);
726 HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
727 LPDIRECTINPUTDEVICE8A iface,
728 LPDIEFFECTINFOA lpdei,
731 FIXME("(this=%p,%p,%s): stub!\n",
732 iface, lpdei, debugstr_guid(rguid));
736 HRESULT WINAPI IDirectInputDevice2WImpl_GetEffectInfo(
737 LPDIRECTINPUTDEVICE8W iface,
738 LPDIEFFECTINFOW lpdei,
741 FIXME("(this=%p,%p,%s): stub!\n",
742 iface, lpdei, debugstr_guid(rguid));
746 HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
747 LPDIRECTINPUTDEVICE8A iface,
750 FIXME("(this=%p,%p): stub!\n",
755 HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
756 LPDIRECTINPUTDEVICE8A iface,
759 FIXME("(this=%p,0x%08lx): stub!\n",
764 HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
765 LPDIRECTINPUTDEVICE8A iface,
766 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
770 FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
771 iface, lpCallback, lpvRef, dwFlags);
775 HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
776 LPDIRECTINPUTDEVICE8A iface,
777 LPDIEFFESCAPE lpDIEEsc)
779 FIXME("(this=%p,%p): stub!\n",
784 HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
785 LPDIRECTINPUTDEVICE8A iface)
787 /* Because wine devices do not need to be polled, just return DI_NOEFFECT */
791 HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
792 LPDIRECTINPUTDEVICE8A iface,
794 LPCDIDEVICEOBJECTDATA rgdod,
798 FIXME("(this=%p,0x%08lx,%p,%p,0x%08lx): stub!\n",
799 iface, cbObjectData, rgdod, pdwInOut, dwFlags);
804 HRESULT WINAPI IDirectInputDevice7AImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8A iface,
806 LPDIENUMEFFECTSINFILECALLBACK pec,
810 FIXME("(%p)->(%s,%p,%p,%08lx): stub !\n", iface, lpszFileName, pec, pvRef, dwFlags);
815 HRESULT WINAPI IDirectInputDevice7WImpl_EnumEffectsInFile(LPDIRECTINPUTDEVICE8W iface,
816 LPCWSTR lpszFileName,
817 LPDIENUMEFFECTSINFILECALLBACK pec,
821 FIXME("(%p)->(%s,%p,%p,%08lx): stub !\n", iface, debugstr_w(lpszFileName), pec, pvRef, dwFlags);
826 HRESULT WINAPI IDirectInputDevice7AImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8A iface,
829 LPDIFILEEFFECT rgDiFileEft,
832 FIXME("(%p)->(%s,%08lx,%p,%08lx): stub !\n", iface, lpszFileName, dwEntries, rgDiFileEft, dwFlags);
837 HRESULT WINAPI IDirectInputDevice7WImpl_WriteEffectToFile(LPDIRECTINPUTDEVICE8W iface,
838 LPCWSTR lpszFileName,
840 LPDIFILEEFFECT rgDiFileEft,
843 FIXME("(%p)->(%s,%08lx,%p,%08lx): stub !\n", iface, debugstr_w(lpszFileName), dwEntries, rgDiFileEft, dwFlags);
848 HRESULT WINAPI IDirectInputDevice8AImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface,
849 LPDIACTIONFORMATA lpdiaf,
853 FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
858 HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface,
859 LPDIACTIONFORMATW lpdiaf,
860 LPCWSTR lpszUserName,
863 FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
868 HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface,
869 LPDIACTIONFORMATA lpdiaf,
873 FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
878 HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
879 LPDIACTIONFORMATW lpdiaf,
880 LPCWSTR lpszUserName,
883 FIXME("(%p)->(%p,%s,%08lx): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
888 HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
889 LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader)
891 FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
896 HRESULT WINAPI IDirectInputDevice8WImpl_GetImageInfo(LPDIRECTINPUTDEVICE8W iface,
897 LPDIDEVICEIMAGEINFOHEADERW lpdiDevImageInfoHeader)
899 FIXME("(%p)->(%p): stub !\n", iface, lpdiDevImageInfoHeader);
904 /******************************************************************************
908 static LRESULT CALLBACK dinput_hook_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
910 static HHOOK kbd_hook, mouse_hook;
913 TRACE("got message %x %p %p\n", message, (LPVOID)wParam, (LPVOID)lParam);
917 if (wParam == WH_KEYBOARD_LL)
921 if (kbd_hook) return 0;
922 kbd_hook = SetWindowsHookExW(WH_KEYBOARD_LL, (LPVOID)lParam, DINPUT_instance, 0);
923 return (LRESULT)kbd_hook;
927 if (!kbd_hook) return 0;
928 res = UnhookWindowsHookEx(kbd_hook);
933 else if (wParam == WH_MOUSE_LL)
937 if (mouse_hook) return 0;
938 mouse_hook = SetWindowsHookExW(WH_MOUSE_LL, (LPVOID)lParam, DINPUT_instance, 0);
939 return (LRESULT)mouse_hook;
943 if (!mouse_hook) return 0;
944 res = UnhookWindowsHookEx(mouse_hook);
954 return DefWindowProcW(hWnd, message, wParam, lParam);
957 static HANDLE signal_event;
959 static DWORD WINAPI hook_thread_proc(void *param)
961 static const WCHAR classW[]={'H','o','o','k','_','L','L','_','C','L',0};
966 memset(&wcex, 0, sizeof(wcex));
967 wcex.cbSize = sizeof(wcex);
968 wcex.lpfnWndProc = dinput_hook_WndProc;
969 wcex.lpszClassName = classW;
970 wcex.hInstance = GetModuleHandleW(0);
972 if (!RegisterClassExW(&wcex)) ERR("Error registering window class\n");
973 hwnd = CreateWindowExW(0, classW, NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, 0);
974 *(HWND*)param = hwnd;
976 SetEvent(signal_event);
979 while (GetMessageW(&msg, 0, 0, 0))
981 TranslateMessage(&msg);
982 DispatchMessageW(&msg);
985 else ERR("Error creating message window\n");
988 UnregisterClassW(wcex.lpszClassName, wcex.hInstance);
992 static CRITICAL_SECTION dinput_hook_crit;
993 static CRITICAL_SECTION_DEBUG dinput_critsect_debug =
995 0, 0, &dinput_hook_crit,
996 { &dinput_critsect_debug.ProcessLocksList, &dinput_critsect_debug.ProcessLocksList },
997 0, 0, { (DWORD_PTR)(__FILE__ ": dinput_hook_crit") }
999 static CRITICAL_SECTION dinput_hook_crit = { &dinput_critsect_debug, -1, 0, 0, 0, 0 };
1001 static HWND get_thread_hwnd(void)
1003 static HANDLE hook_thread;
1004 static HWND hook_thread_hwnd;
1006 EnterCriticalSection(&dinput_hook_crit);
1012 signal_event = CreateEventW(NULL, FALSE, FALSE, NULL);
1013 hook_thread = CreateThread(NULL, 0, hook_thread_proc, &hwnd, 0, &tid);
1014 if (signal_event && hook_thread)
1017 handles[0] = signal_event;
1018 handles[1] = hook_thread;
1019 WaitForMultipleObjects(2, handles, FALSE, INFINITE);
1021 CloseHandle(signal_event);
1023 if (!(hook_thread_hwnd = hwnd))
1025 /* Thread failed to create window - reset things so we could try again later */
1026 CloseHandle(hook_thread);
1030 LeaveCriticalSection(&dinput_hook_crit);
1032 return hook_thread_hwnd;
1035 HHOOK set_dinput_hook(int hook_id, LPVOID proc)
1037 return (HHOOK)SendMessageW(get_thread_hwnd(), WM_USER+0x10, (WPARAM)hook_id, (LPARAM)proc);