Lucas Fialho Zawacki : dinput: SetActionMap setting the device buffer.
Alexandre Julliard
julliard at winehq.org
Tue Jun 28 17:25:18 CDT 2011
Module: wine
Branch: master
Commit: 2fe9f14b294e57bdbb676d452cb63e98d7ecc45b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2fe9f14b294e57bdbb676d452cb63e98d7ecc45b
Author: Lucas Fialho Zawacki <lfzawacki at gmail.com>
Date: Tue Jun 28 13:55:24 2011 -0300
dinput: SetActionMap setting the device buffer.
---
dlls/dinput/device.c | 35 +++++++++++++++++++++++----
dlls/dinput/dinput_main.c | 54 ++++++++++++++++++++++++++++++++++++++++++
dlls/dinput/dinput_private.h | 2 +
dlls/dinput8/tests/device.c | 2 +-
4 files changed, 87 insertions(+), 6 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 397e70e..5a03a27 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -1391,9 +1391,20 @@ HRESULT WINAPI IDirectInputDevice8AImpl_SetActionMap(LPDIRECTINPUTDEVICE8A iface
LPCSTR lpszUserName,
DWORD dwFlags)
{
- FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
-
- return DI_OK;
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8A(iface);
+ DIACTIONFORMATW diafW;
+ HRESULT hr;
+
+ FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, lpszUserName, dwFlags);
+
+ diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
+ _copy_diactionformatAtoW(&diafW, lpdiaf);
+
+ hr = IDirectInputDevice8WImpl_SetActionMap(&This->IDirectInputDevice8W_iface, &diafW, NULL, dwFlags);
+
+ HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
+
+ return hr;
}
HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
@@ -1401,8 +1412,22 @@ HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface
LPCWSTR lpszUserName,
DWORD dwFlags)
{
- FIXME("(%p)->(%p,%s,%08x): stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
-
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface);
+ DIPROPDWORD dp;
+
+ FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
+
+ if (This->acquired) return DIERR_ACQUIRED;
+
+ if (lpdiaf->dwBufferSize > 0)
+ {
+ dp.diph.dwSize = sizeof(DIPROPDWORD);
+ dp.dwData = lpdiaf->dwBufferSize;
+ dp.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+ dp.diph.dwHow = DIPH_DEVICE;
+ IDirectInputDevice8_SetProperty(iface, DIPROP_BUFFERSIZE, &dp.diph);
+ }
+
return DI_OK;
}
diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
index c032642..1329ec6 100644
--- a/dlls/dinput/dinput_main.c
+++ b/dlls/dinput/dinput_main.c
@@ -254,6 +254,60 @@ void _dump_diactionformatA(LPDIACTIONFORMATA lpdiActionFormat) {
}
}
+void _copy_diactionformatAtoW(LPDIACTIONFORMATW to, LPDIACTIONFORMATA from)
+{
+ int i;
+
+ to->dwSize = sizeof(DIACTIONFORMATW);
+ to->dwActionSize = sizeof(DIACTIONW);
+ to->dwDataSize = from->dwDataSize;
+ to->dwNumActions = from->dwNumActions;
+ to->guidActionMap = from->guidActionMap;
+ to->dwGenre = from->dwGenre;
+ to->dwBufferSize = from->dwBufferSize;
+ to->lAxisMin = from->lAxisMin;
+ to->lAxisMax = from->lAxisMax;
+ to->dwCRC = from->dwCRC;
+ to->ftTimeStamp = from->ftTimeStamp;
+
+ for (i=0; i < to->dwNumActions; i++)
+ {
+ to->rgoAction[i].uAppData = from->rgoAction[i].uAppData;
+ to->rgoAction[i].dwSemantic = from->rgoAction[i].dwSemantic;
+ to->rgoAction[i].dwFlags = from->rgoAction[i].dwFlags;
+ to->rgoAction[i].guidInstance = from->rgoAction[i].guidInstance;
+ to->rgoAction[i].dwObjID = from->rgoAction[i].dwObjID;
+ to->rgoAction[i].dwHow = from->rgoAction[i].dwHow;
+ }
+}
+
+void _copy_diactionformatWtoA(LPDIACTIONFORMATA to, LPDIACTIONFORMATW from)
+{
+ int i;
+
+ to->dwSize = sizeof(DIACTIONFORMATA);
+ to->dwActionSize = sizeof(DIACTIONA);
+ to->dwDataSize = from->dwDataSize;
+ to->dwNumActions = from->dwNumActions;
+ to->guidActionMap = from->guidActionMap;
+ to->dwGenre = from->dwGenre;
+ to->dwBufferSize = from->dwBufferSize;
+ to->lAxisMin = from->lAxisMin;
+ to->lAxisMax = from->lAxisMax;
+ to->dwCRC = from->dwCRC;
+ to->ftTimeStamp = from->ftTimeStamp;
+
+ for (i=0; i < to->dwNumActions; i++)
+ {
+ to->rgoAction[i].uAppData = from->rgoAction[i].uAppData;
+ to->rgoAction[i].dwSemantic = from->rgoAction[i].dwSemantic;
+ to->rgoAction[i].dwFlags = from->rgoAction[i].dwFlags;
+ to->rgoAction[i].guidInstance = from->rgoAction[i].guidInstance;
+ to->rgoAction[i].dwObjID = from->rgoAction[i].dwObjID;
+ to->rgoAction[i].dwHow = from->rgoAction[i].dwHow;
+ }
+}
+
/******************************************************************************
* IDirectInputA_EnumDevices
*/
diff --git a/dlls/dinput/dinput_private.h b/dlls/dinput/dinput_private.h
index 33cc823..a6ce4d6 100644
--- a/dlls/dinput/dinput_private.h
+++ b/dlls/dinput/dinput_private.h
@@ -63,6 +63,8 @@ extern void check_dinput_hooks(LPDIRECTINPUTDEVICE8W) DECLSPEC_HIDDEN;
typedef int (*DI_EVENT_PROC)(LPDIRECTINPUTDEVICE8A, WPARAM, LPARAM);
extern void _dump_diactionformatA(LPDIACTIONFORMATA) DECLSPEC_HIDDEN;
+extern void _copy_diactionformatAtoW(LPDIACTIONFORMATW, LPDIACTIONFORMATA) DECLSPEC_HIDDEN;
+extern void _copy_diactionformatWtoA(LPDIACTIONFORMATA, LPDIACTIONFORMATW) DECLSPEC_HIDDEN;
#define IS_DIPROP(x) (((ULONG_PTR)(x) >> 16) == 0)
diff --git a/dlls/dinput8/tests/device.c b/dlls/dinput8/tests/device.c
index af14d60..4841a1f 100644
--- a/dlls/dinput8/tests/device.c
+++ b/dlls/dinput8/tests/device.c
@@ -165,7 +165,7 @@ static BOOL CALLBACK enumeration_callback(
hr = IDirectInputDevice_GetProperty(lpdid, DIPROP_BUFFERSIZE, &dp.diph);
ok (SUCCEEDED(hr), "GetProperty failed hr=%08x\n", hr);
- todo_wine ok (dp.dwData == data->lpdiaf->dwBufferSize, "SetActionMap must set the buffer, buffersize=%d\n", dp.dwData);
+ ok (dp.dwData == data->lpdiaf->dwBufferSize, "SetActionMap must set the buffer, buffersize=%d\n", dp.dwData);
/* SetActionMap has set the data format so now it should work */
hr = IDirectInputDevice8_Acquire(lpdid);
More information about the wine-cvs
mailing list