From fec8aae2361bfe3ef934430397b491c8165564f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Mon, 25 Apr 2022 14:56:19 +0200 Subject: [PATCH] windows.gaming.input: Implement IForceFeedbackMotor_(get|put)_MasterGain. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RĂ©mi Bernon Signed-off-by: Alexandre Julliard --- 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 9c9af8b6389..f9538f5f56d 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 = { @@ -5306,15 +5305,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 )