diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 397e70ec074..5a03a27730a 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 c032642e9c5..1329ec6994b 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 33cc8230fd8..a6ce4d6d516 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 af14d608b82..4841a1f59b2 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);