[PATCH 06/10] dinput: Send DISFFC_RESET command on HID joystick (Un)Acquire.

Rémi Bernon rbernon at codeweavers.com
Fri Oct 1 02:31:04 CDT 2021


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/dinput/joystick_hid.c |  4 ++++
 dlls/dinput8/tests/hid.c   | 12 ++----------
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c
index b6c4c960521..ac67625cddc 100644
--- a/dlls/dinput/joystick_hid.c
+++ b/dlls/dinput/joystick_hid.c
@@ -707,6 +707,8 @@ static HRESULT WINAPI hid_joystick_Acquire( IDirectInputDevice8W *iface )
         impl->read_ovl.hEvent = impl->base.read_event;
         if (ReadFile( impl->device, impl->input_report_buf, report_len, NULL, &impl->read_ovl ))
             impl->base.read_callback( iface );
+
+        IDirectInputDevice8_SendForceFeedbackCommand( iface, DISFFC_RESET );
     }
     LeaveCriticalSection( &impl->base.crit );
 
@@ -726,6 +728,8 @@ static HRESULT WINAPI hid_joystick_Unacquire( IDirectInputDevice8W *iface )
     {
         ret = CancelIoEx( impl->device, &impl->read_ovl );
         if (!ret) WARN( "CancelIoEx failed, last error %u\n", GetLastError() );
+
+        IDirectInputDevice8_SendForceFeedbackCommand( iface, DISFFC_RESET );
     }
     hr = IDirectInputDevice2WImpl_Unacquire( iface );
     LeaveCriticalSection( &impl->base.crit );
diff --git a/dlls/dinput8/tests/hid.c b/dlls/dinput8/tests/hid.c
index 618fb4e4c7c..7c46f19cc40 100644
--- a/dlls/dinput8/tests/hid.c
+++ b/dlls/dinput8/tests/hid.c
@@ -5259,14 +5259,6 @@ static void test_force_feedback_joystick( void )
         .report_len = 2,
         .report_buf = {1, 0x01},
     };
-    struct hid_expect expect_dc_reset_todo =
-    {
-        .code = IOCTL_HID_WRITE_REPORT,
-        .todo = TRUE,
-        .report_id = 1,
-        .report_len = 2,
-        .report_buf = {1, 0x01},
-    };
 
     const DIDEVICEINSTANCEW expect_devinst =
     {
@@ -5775,7 +5767,7 @@ static void test_force_feedback_joystick( void )
     hr = IDirectInputDevice8_SetCooperativeLevel( device, hwnd, DISCL_BACKGROUND | DISCL_EXCLUSIVE );
     ok( hr == DI_OK, "IDirectInputDevice8_SetCooperativeLevel returned: %#x\n", hr );
 
-    set_hid_expect( file, &expect_dc_reset_todo, sizeof(expect_dc_reset_todo) );
+    set_hid_expect( file, &expect_dc_reset, sizeof(expect_dc_reset) );
     hr = IDirectInputDevice8_Acquire( device );
     ok( hr == DI_OK, "IDirectInputDevice8_Acquire returned: %#x\n", hr );
     set_hid_expect( file, NULL, 0 );
@@ -5821,7 +5813,7 @@ static void test_force_feedback_joystick( void )
 
     test_periodic_effect( device, file );
 
-    set_hid_expect( file, &expect_dc_reset_todo, sizeof(expect_dc_reset_todo) );
+    set_hid_expect( file, &expect_dc_reset, sizeof(expect_dc_reset) );
     hr = IDirectInputDevice8_Unacquire( device );
     ok( hr == DI_OK, "IDirectInputDevice8_Unacquire returned: %#x\n", hr );
     set_hid_expect( file, NULL, 0 );
-- 
2.33.0




More information about the wine-devel mailing list