[PATCH 3/6] dinput: SetActionMap setting the device buffer.
Lucas Fialho Zawacki
lfzawacki at gmail.com
Mon Jun 20 17:06:33 CDT 2011
---
dlls/dinput/device.c | 40 +++++++++++++++++++++++++++----
dlls/dinput/dinput_main.c | 54 ++++++++++++++++++++++++++++++++++++++++++
dlls/dinput/dinput_private.h | 2 +
3 files changed, 91 insertions(+), 5 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index 397e70e..ef02f3d 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -1391,9 +1391,24 @@ 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(), HEAP_ZERO_MEMORY,
+ sizeof(DIACTIONW)*lpdiaf->dwNumActions);
+ _copy_diactionformatAtoW( &diafW, lpdiaf);
+
+ hr = IDirectInputDevice8_SetActionMap( &This->IDirectInputDevice8W_iface,
+ &diafW, NULL, dwFlags);
+
+ _copy_diactionformatWtoA( lpdiaf, &diafW);
+
+ HeapFree( GetProcessHeap(), 0, diafW.rgoAction);
+
+ return hr;
}
HRESULT WINAPI IDirectInputDevice8WImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface,
@@ -1401,8 +1416,23 @@ 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)
+ {
+ memset(&dp,0,sizeof(dp));
+ 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 d08eb04..28af929 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..e076370 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)
--
1.7.0.4
More information about the wine-patches
mailing list