From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dinput/device.c | 14 +++++--------- dlls/dinput/tests/joystick8.c | 4 ---- 2 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 16c4409b9b3..2817ca9839b 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -1964,8 +1964,8 @@ static HRESULT WINAPI dinput_device_SetActionMap( IDirectInputDevice8W *iface, D }; WCHAR username_buf[MAX_PATH]; DWORD username_len = MAX_PATH; - int i, index, num_actions = 0; unsigned int offset = 0; + int i, index; HRESULT hr;
FIXME( "iface %p, format %p, username %s, flags %#lx stub!\n", iface, format, @@ -1973,14 +1973,7 @@ static HRESULT WINAPI dinput_device_SetActionMap( IDirectInputDevice8W *iface, D
if (!format) return DIERR_INVALIDPARAM;
- /* Count the actions */ - for (i = 0; i < format->dwNumActions; i++) - if (IsEqualGUID( &impl->guid, &format->rgoAction[i].guidInstance )) - num_actions++; - - if (num_actions == 0) return DI_NOEFFECT; - - if (!(data_format.rgodf = malloc( sizeof(DIOBJECTDATAFORMAT) * num_actions ))) return DIERR_OUTOFMEMORY; + if (!(data_format.rgodf = malloc( sizeof(DIOBJECTDATAFORMAT) * format->dwNumActions ))) return DIERR_OUTOFMEMORY; data_format.dwDataSize = format->dwDataSize;
for (i = 0; i < format->dwNumActions; i++, offset += sizeof(ULONG)) @@ -2026,6 +2019,9 @@ static HRESULT WINAPI dinput_device_SetActionMap( IDirectInputDevice8W *iface, D LeaveCriticalSection( &impl->crit );
free( data_format.rgodf ); + + if (FAILED(hr)) return hr; + if (!data_format.dwNumObjs) return DI_NOEFFECT; return hr; }
diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c index c3866e4e177..6e8a9292f84 100644 --- a/dlls/dinput/tests/joystick8.c +++ b/dlls/dinput/tests/joystick8.c @@ -824,9 +824,7 @@ static void test_action_map( IDirectInputDevice8W *device, HANDLE file, HANDLE e
memset( prop_username.wsz, 0, sizeof(prop_username.wsz) ); hr = IDirectInputDevice_GetProperty( device, DIPROP_USERNAME, &prop_username.diph ); - todo_wine ok( hr == DI_OK, "GetProperty returned %#lx\n", hr ); - todo_wine ok( !wcscmp( prop_username.wsz, username ), "got username %s\n", debugstr_w(prop_username.wsz) );
hr = IDirectInputDevice8_SetActionMap( device, &voice_action_format, NULL, DIDSAM_DEFAULT ); @@ -837,9 +835,7 @@ static void test_action_map( IDirectInputDevice8W *device, HANDLE file, HANDLE e
memset( prop_username.wsz, 0, sizeof(prop_username.wsz) ); hr = IDirectInputDevice_GetProperty( device, DIPROP_USERNAME, &prop_username.diph ); - todo_wine ok( hr == DI_OK, "GetProperty returned %#lx\n", hr ); - todo_wine ok( !wcscmp( prop_username.wsz, username ), "got username %s\n", debugstr_w(prop_username.wsz) );