Rémi Bernon : dinput: Send DISFFC_RESET command on HID joystick (Un)Acquire.

Alexandre Julliard julliard at winehq.org
Fri Oct 1 18:02:22 CDT 2021


Module: wine
Branch: master
Commit: 84e586124c92d00335433e75b9c95ca89a6b9150
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=84e586124c92d00335433e75b9c95ca89a6b9150

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Fri Oct  1 09:31:04 2021 +0200

dinput: Send DISFFC_RESET command on HID joystick (Un)Acquire.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 );




More information about the wine-cvs mailing list