[PATCH 5/6] windows.gaming.input: Implement IForceFeedbackMotor_(get|put)_MasterGain.

Rémi Bernon rbernon at codeweavers.com
Mon Apr 25 07:56:19 CDT 2022


Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/dinput/tests/force_feedback.c         |  6 +---
 dlls/windows.gaming.input/force_feedback.c | 37 +++++++++++++++++++---
 2 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c
index 591496ca908..5b4bfade9bc 100644
--- a/dlls/dinput/tests/force_feedback.c
+++ b/dlls/dinput/tests/force_feedback.c
@@ -5063,7 +5063,6 @@ static void test_windows_gaming_input(void)
         .report_id = 6,
         .report_len = 2,
         .report_buf = {6, 0x7f},
-        .todo = TRUE,
     };
     static struct hid_expect expect_pause =
     {
@@ -5307,15 +5306,12 @@ static void test_windows_gaming_input(void)
 
     gain = 12345.6;
     hr = IForceFeedbackMotor_get_MasterGain( motor, &gain );
-    todo_wine
     ok( hr == S_OK, "get_MasterGain returned %#lx\n", hr );
-    todo_wine
     ok( gain == 1.0, "got gain %f\n", gain );
     set_hid_expect( file, &expect_set_gain, sizeof(expect_set_gain) );
     hr = IForceFeedbackMotor_put_MasterGain( motor, 0.5 );
-    todo_wine
     ok( hr == S_OK, "put_MasterGain 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 */
 
     enabled = FALSE;
     hr = IForceFeedbackMotor_get_IsEnabled( motor, &enabled );
diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c
index 54742475e7b..6d4e533bc77 100644
--- a/dlls/windows.gaming.input/force_feedback.c
+++ b/dlls/windows.gaming.input/force_feedback.c
@@ -111,14 +111,43 @@ static HRESULT WINAPI motor_get_AreEffectsPaused( IForceFeedbackMotor *iface, BO
 
 static HRESULT WINAPI motor_get_MasterGain( IForceFeedbackMotor *iface, double *value )
 {
-    FIXME( "iface %p, value %p stub!\n", iface, value );
-    return E_NOTIMPL;
+    struct motor *impl = impl_from_IForceFeedbackMotor( iface );
+    DIPROPDWORD gain =
+    {
+        .diph =
+        {
+            .dwSize = sizeof(DIPROPDWORD),
+            .dwHeaderSize = sizeof(DIPROPHEADER),
+            .dwHow = DIPH_DEVICE,
+        },
+    };
+    HRESULT hr;
+
+    TRACE( "iface %p, value %p.\n", iface, value );
+
+    if (FAILED(hr = IDirectInputDevice8_GetProperty( impl->device, DIPROP_FFGAIN, &gain.diph ))) *value = 1.;
+    else *value = gain.dwData / 10000.;
+
+    return hr;
 }
 
 static HRESULT WINAPI motor_put_MasterGain( IForceFeedbackMotor *iface, double value )
 {
-    FIXME( "iface %p, value %#I64x stub!\n", iface, *(UINT64 *)&value );
-    return E_NOTIMPL;
+    struct motor *impl = impl_from_IForceFeedbackMotor( iface );
+    DIPROPDWORD gain =
+    {
+        .diph =
+        {
+            .dwSize = sizeof(DIPROPDWORD),
+            .dwHeaderSize = sizeof(DIPROPHEADER),
+            .dwHow = DIPH_DEVICE,
+        },
+    };
+
+    TRACE( "iface %p, value %f.\n", iface, value );
+
+    gain.dwData = 10000 * value;
+    return IDirectInputDevice8_SetProperty( impl->device, DIPROP_FFGAIN, &gain.diph );
 }
 
 static HRESULT WINAPI motor_get_IsEnabled( IForceFeedbackMotor *iface, BOOLEAN *value )
-- 
2.35.1




More information about the wine-devel mailing list