It also contains all the helper functions.
*/
-#include <config.h>
-
-//#include <stdarg.h>
-//#include <string.h>
-#include <wine/debug.h>
-#include <wine/unicode.h>
-//#include "windef.h"
-//#include "winbase.h"
-#include <winreg.h>
-#include <winuser.h>
-//#include "winerror.h"
-//#include "dinput.h"
-#include "device_private.h"
-//#include "dinput_private.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(dinput);
+
+#include "dinput_private.h"
static inline IDirectInputDeviceImpl *impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
{
}
}
+static void _dump_ObjectDataFormat_flags(DWORD dwFlags) {
+ unsigned int i;
+ static const struct {
+ DWORD mask;
+ const char *name;
+ } flags[] = {
+#define FE(x) { x, #x}
+ FE(DIDOI_FFACTUATOR),
+ FE(DIDOI_FFEFFECTTRIGGER),
+ FE(DIDOI_POLLED),
+ FE(DIDOI_GUIDISUSAGE)
+#undef FE
+ };
+
+ if (!dwFlags) return;
+
+ TRACE("Flags:");
+
+ /* First the flags */
+ for (i = 0; i < (sizeof(flags) / sizeof(flags[0])); i++) {
+ if (flags[i].mask & dwFlags)
+ TRACE(" %s",flags[i].name);
+ }
+
+ /* Now specific values */
+#define FE(x) case x: TRACE(" "#x); break
+ switch (dwFlags & DIDOI_ASPECTMASK) {
+ FE(DIDOI_ASPECTACCEL);
+ FE(DIDOI_ASPECTFORCE);
+ FE(DIDOI_ASPECTPOSITION);
+ FE(DIDOI_ASPECTVELOCITY);
+ }
+#undef FE
+
+}
+
static void _dump_EnumObjects_flags(DWORD dwFlags) {
if (TRACE_ON(dinput)) {
unsigned int i;
TRACE(" * dwType: 0x%08x\n", df->rgodf[i].dwType);
TRACE(" "); _dump_EnumObjects_flags(df->rgodf[i].dwType); TRACE("\n");
TRACE(" * dwFlags: 0x%08x\n", df->rgodf[i].dwFlags);
+ TRACE(" "); _dump_ObjectDataFormat_flags(df->rgodf[i].dwFlags); TRACE("\n");
}
}
debugstr_guid(asked_format->rgodf[j].pguid),
_dump_dinput_GUID(asked_format->rgodf[j].pguid));
TRACE(" * Offset: %3d\n", asked_format->rgodf[j].dwOfs);
- TRACE(" * dwType: %08x\n", asked_format->rgodf[j].dwType);
+ TRACE(" * dwType: 0x%08x\n", asked_format->rgodf[j].dwType);
TRACE(" "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
+ TRACE(" * dwFlags: 0x%08x\n", asked_format->rgodf[j].dwFlags);
+ TRACE(" "); _dump_ObjectDataFormat_flags(asked_format->rgodf[j].dwFlags); TRACE("\n");
TRACE(" - Wine (%d) :\n", i);
TRACE(" * GUID: %s ('%s')\n",
debugstr_guid(format->wine_df->rgodf[i].pguid),
_dump_dinput_GUID(format->wine_df->rgodf[i].pguid));
TRACE(" * Offset: %3d\n", format->wine_df->rgodf[i].dwOfs);
- TRACE(" * dwType: %08x\n", format->wine_df->rgodf[i].dwType);
+ TRACE(" * dwType: 0x%08x\n", format->wine_df->rgodf[i].dwType);
TRACE(" "); _dump_EnumObjects_flags(format->wine_df->rgodf[i].dwType); TRACE("\n");
+ TRACE(" * dwFlags: 0x%08x\n", format->wine_df->rgodf[i].dwFlags);
+ TRACE(" "); _dump_ObjectDataFormat_flags(format->wine_df->rgodf[i].dwFlags); TRACE("\n");
if (format->wine_df->rgodf[i].dwType & DIDFT_BUTTON)
dt[index].size = sizeof(BYTE);
debugstr_guid(asked_format->rgodf[j].pguid),
_dump_dinput_GUID(asked_format->rgodf[j].pguid));
TRACE(" * Offset: %3d\n", asked_format->rgodf[j].dwOfs);
- TRACE(" * dwType: %08x\n", asked_format->rgodf[j].dwType);
+ TRACE(" * dwType: 0x%08x\n", asked_format->rgodf[j].dwType);
TRACE(" "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
+ TRACE(" * dwFlags: 0x%08x\n", asked_format->rgodf[j].dwFlags);
+ TRACE(" "); _dump_ObjectDataFormat_flags(asked_format->rgodf[j].dwFlags); TRACE("\n");
if (asked_format->rgodf[j].dwType & DIDFT_BUTTON)
dt[index].size = sizeof(BYTE);
return DIERR_OUTOFMEMORY;
}
-/* find an object by it's offset in a data format */
+/* find an object by its offset in a data format */
static int offset_to_object(const DataFormat *df, int offset)
{
int i;
DWORD type = (0x0000ff00 & dwSemantic) >> 8;
DWORD offset = 0x000000ff & dwSemantic;
DWORD obj_instance = 0;
- DWORD found = 0;
+ BOOL found = FALSE;
int i;
for (i = 0; i < This->data_format.wine_df->dwNumObjs; i++)
if (odf->dwOfs == offset)
{
obj_instance = DIDFT_GETINSTANCE(odf->dwType);
- found = 1;
+ found = TRUE;
break;
}
}
IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
WCHAR username[MAX_PATH];
DWORD username_size = MAX_PATH;
- int i, has_actions = 0;
- BOOL load_success = FALSE;
+ int i;
+ BOOL load_success = FALSE, has_actions = FALSE;
/* Unless asked the contrary by these flags, try to load a previous mapping */
if (!(dwFlags & DIDBAM_HWDEFAULTS))
lpdiaf->rgoAction[i].dwObjID = obj_id;
lpdiaf->rgoAction[i].guidInstance = This->guid;
lpdiaf->rgoAction[i].dwHow = DIAH_DEFAULT;
- has_actions = 1;
+ has_actions = TRUE;
}
}
else if (!(dwFlags & DIDBAM_PRESERVE))
DIOBJECTDATAFORMAT *obj_df = NULL;
DIPROPDWORD dp;
DIPROPRANGE dpr;
+ DIPROPSTRING dps;
WCHAR username[MAX_PATH];
DWORD username_size = MAX_PATH;
int i, action = 0, num_actions = 0;
else
lstrcpynW(username, lpszUserName, MAX_PATH);
+ dps.diph.dwSize = sizeof(dps);
+ dps.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+ dps.diph.dwObj = 0;
+ dps.diph.dwHow = DIPH_DEVICE;
+ if (dwFlags & DIDSAM_NOUSER)
+ dps.wsz[0] = '\0';
+ else
+ lstrcpynW(dps.wsz, username, sizeof(dps.wsz)/sizeof(WCHAR));
+ IDirectInputDevice8_SetProperty(iface, DIPROP_USERNAME, &dps.diph);
+
/* Save the settings to disk */
save_mapping_settings(iface, lpdiaf, username);
- return IDirectInputDevice8WImpl_SetActionMap(iface, lpdiaf, lpszUserName, dwFlags);
+ return DI_OK;
}
/******************************************************************************
EnterCriticalSection(&This->crit);
res = This->acquired ? S_FALSE : DI_OK;
This->acquired = 1;
- if (res == DI_OK)
- check_dinput_hooks(iface);
LeaveCriticalSection(&This->crit);
+ if (res == DI_OK)
+ check_dinput_hooks(iface, TRUE);
return res;
}
EnterCriticalSection(&This->crit);
res = !This->acquired ? DI_NOEFFECT : DI_OK;
This->acquired = 0;
- if (res == DI_OK)
- check_dinput_hooks(iface);
LeaveCriticalSection(&This->crit);
+ if (res == DI_OK)
+ check_dinput_hooks(iface, FALSE);
return res;
}
if (hwnd && GetWindowLongW(hwnd, GWL_STYLE) & WS_CHILD) return E_HANDLE;
- if (dwflags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))
+ if (!hwnd && dwflags == (DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))
hwnd = GetDesktopWindow();
- if (!hwnd) return E_HANDLE;
+ if (!IsWindow(hwnd)) return E_HANDLE;
/* For security reasons native does not allow exclusive background level
for mouse and keyboard only */
TRACE("buffersize = %d\n", pd->dwData);
break;
}
+ case (DWORD_PTR) DIPROP_USERNAME:
+ {
+ LPDIPROPSTRING ps = (LPDIPROPSTRING)pdiph;
+ struct DevicePlayer *device_player;
+
+ if (pdiph->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM;
+
+ LIST_FOR_EACH_ENTRY(device_player, &This->dinput->device_players,
+ struct DevicePlayer, entry)
+ {
+ if (IsEqualGUID(&device_player->instance_guid, &This->guid))
+ {
+ if (*device_player->username)
+ {
+ lstrcpynW(ps->wsz, device_player->username, sizeof(ps->wsz)/sizeof(WCHAR));
+ return DI_OK;
+ }
+ else break;
+ }
+ }
+ return S_FALSE;
+ }
case (DWORD_PTR) DIPROP_VIDPID:
FIXME("DIPROP_VIDPID not implemented\n");
return DIERR_UNSUPPORTED;
LeaveCriticalSection(&This->crit);
break;
}
+ case (DWORD_PTR) DIPROP_USERNAME:
+ {
+ LPCDIPROPSTRING ps = (LPCDIPROPSTRING)pdiph;
+ struct DevicePlayer *device_player;
+ BOOL found = FALSE;
+
+ if (pdiph->dwSize != sizeof(DIPROPSTRING)) return DIERR_INVALIDPARAM;
+
+ LIST_FOR_EACH_ENTRY(device_player, &This->dinput->device_players,
+ struct DevicePlayer, entry)
+ {
+ if (IsEqualGUID(&device_player->instance_guid, &This->guid))
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ if (!found && (device_player =
+ HeapAlloc(GetProcessHeap(), 0, sizeof(struct DevicePlayer))))
+ {
+ list_add_tail(&This->dinput->device_players, &device_player->entry);
+ device_player->instance_guid = This->guid;
+ }
+ if (device_player)
+ lstrcpynW(device_player->username, ps->wsz,
+ sizeof(device_player->username)/sizeof(WCHAR));
+ break;
+ }
default:
WARN("Unknown property %s\n", debugstr_guid(rguid));
return DIERR_UNSUPPORTED;
LPDIRECTINPUTEFFECT *ppdef, LPUNKNOWN pUnkOuter)
{
FIXME("(this=%p,%s,%p,%p,%p): stub!\n", iface, debugstr_guid(rguid), lpeff, ppdef, pUnkOuter);
- return DI_OK;
+
+ FIXME("not available in the generic implementation\n");
+ *ppdef = NULL;
+ return DIERR_UNSUPPORTED;
}
HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPCDIEFFECT lpeff,
IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
if (!This->acquired) return DIERR_NOTACQUIRED;
- /* Because wine devices do not need to be polled, just return DI_NOEFFECT */
- return DI_NOEFFECT;
+
+ check_dinput_events();
+ return DI_OK;
}
HRESULT WINAPI IDirectInputDevice2AImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
return DI_OK;
}
-HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
- LPDIACTIONFORMATW lpdiaf,
- LPCWSTR lpszUserName,
- DWORD dwFlags)
-{
- FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
-
- return DI_OK;
-}
-
HRESULT WINAPI IDirectInputDevice8AImpl_GetImageInfo(LPDIRECTINPUTDEVICE8A iface,
LPDIDEVICEIMAGEINFOHEADERA lpdiDevImageInfoHeader)
{