Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/force_feedback.c | 4 +--- dlls/windows.gaming.input/force_feedback.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c index a11bd3420e9..591496ca908 100644 --- a/dlls/dinput/tests/force_feedback.c +++ b/dlls/dinput/tests/force_feedback.c @@ -5048,7 +5048,6 @@ static void test_windows_gaming_input(void) .report_id = 1, .report_len = 2, .report_buf = {1, 0x01}, - .todo = TRUE, }, /* device gain */ { @@ -5056,7 +5055,6 @@ static void test_windows_gaming_input(void) .report_id = 6, .report_len = 2, .report_buf = {6, 0xff}, - .todo = TRUE, }, }; static struct hid_expect expect_set_gain = @@ -5285,7 +5283,7 @@ static void test_windows_gaming_input(void) set_hid_expect( file, expect_acquire, sizeof(expect_acquire) ); hr = IRawGameController_get_ForceFeedbackMotors( raw_controller, &motors_view ); ok( hr == S_OK, "get_ForceFeedbackMotors returned %#lx\n", hr ); - wait_hid_expect_( __FILE__, __LINE__, file, 100, TRUE ); /* device gain reports are written asynchronously */ + wait_hid_expect( file, 100 ); /* device gain reports are written asynchronously */
hr = IVectorView_ForceFeedbackMotor_get_Size( motors_view, &size ); ok( hr == S_OK, "get_Size returned %#lx\n", hr ); diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index 24617d16733..54742475e7b 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -211,9 +211,14 @@ static const struct IForceFeedbackMotorVtbl motor_vtbl = HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out ) { struct motor *impl; + HRESULT hr;
TRACE( "device %p, out %p\n", device, out );
+ if (FAILED(hr = IDirectInputDevice8_Unacquire( device ))) goto failed; + if (FAILED(hr = IDirectInputDevice8_SetCooperativeLevel( device, GetDesktopWindow(), DISCL_BACKGROUND | DISCL_EXCLUSIVE ))) goto failed; + if (FAILED(hr = IDirectInputDevice8_Acquire( device ))) goto failed; + if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IForceFeedbackMotor_iface.lpVtbl = &motor_vtbl; impl->ref = 1; @@ -224,4 +229,10 @@ HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbac *out = &impl->IForceFeedbackMotor_iface; TRACE( "created ForceFeedbackMotor %p\n", *out ); return S_OK; + +failed: + IDirectInputDevice8_SetCooperativeLevel( device, 0, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE ); + IDirectInputDevice8_Acquire( device ); + WARN( "Failed to acquire device exclusively, hr %#lx\n", hr ); + return hr; }