Rémi Bernon : windows.gaming.input: Implement IForceFeedbackEffect_(get|put)_Gain.
Alexandre Julliard
julliard at winehq.org
Wed May 18 15:38:31 CDT 2022
Module: wine
Branch: master
Commit: bc6df7ca5707d8509efb8fae1629300b7f50bf17
URL: https://source.winehq.org/git/wine.git/?a=commit;h=bc6df7ca5707d8509efb8fae1629300b7f50bf17
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Thu May 12 15:58:05 2022 +0200
windows.gaming.input: Implement IForceFeedbackEffect_(get|put)_Gain.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dinput/tests/force_feedback.c | 8 +-------
dlls/windows.gaming.input/force_feedback.c | 27 +++++++++++++++++++++++----
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c
index da01ce63a96..7755cca1927 100644
--- a/dlls/dinput/tests/force_feedback.c
+++ b/dlls/dinput/tests/force_feedback.c
@@ -5572,7 +5572,7 @@ static void test_windows_gaming_input(void)
.code = IOCTL_HID_WRITE_REPORT,
.report_id = 3,
.report_len = 18,
- .report_buf = {3,0x01,0x04,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x5a,0x00,0x00,0x00},
+ .report_buf = {3,0x01,0x04,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x7f,0x5a,0x00,0x00,0x00},
.wine_only = TRUE,
.todo = TRUE,
},
@@ -6061,12 +6061,9 @@ static void test_windows_gaming_input(void)
gain = 12345.6;
hr = IForceFeedbackEffect_get_Gain( effect, &gain );
- todo_wine
ok( hr == S_OK, "get_Gain returned %#lx\n", hr );
- todo_wine
ok( gain == 1.0, "got gain %f\n", gain );
hr = IForceFeedbackEffect_put_Gain( effect, 0.5 );
- todo_wine
ok( hr == S_FALSE, "put_Gain returned %#lx\n", hr );
state = 0xdeadbeef;
hr = IForceFeedbackEffect_get_State( effect, &state );
@@ -6317,12 +6314,9 @@ static void test_windows_gaming_input(void)
gain = 12345.6;
hr = IForceFeedbackEffect_get_Gain( effect, &gain );
- todo_wine
ok( hr == S_OK, "get_Gain returned %#lx\n", hr );
- todo_wine
ok( gain == 1.0, "get_MasterGain returned %f\n", gain );
hr = IForceFeedbackEffect_put_Gain( effect, 0.5 );
- todo_wine
ok( hr == S_FALSE, "put_Gain returned %#lx\n", hr );
state = 0xdeadbeef;
hr = IForceFeedbackEffect_get_State( effect, &state );
diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c
index 9f24fa8a748..667174829f5 100644
--- a/dlls/windows.gaming.input/force_feedback.c
+++ b/dlls/windows.gaming.input/force_feedback.c
@@ -19,6 +19,8 @@
#include "private.h"
+#include "math.h"
+
#include "ddk/hidsdi.h"
#include "dinput.h"
#include "hidusage.h"
@@ -117,14 +119,31 @@ DEFINE_IINSPECTABLE_OUTER( effect, IForceFeedbackEffect, struct effect, IInspect
static HRESULT WINAPI effect_get_Gain( IForceFeedbackEffect *iface, DOUBLE *value )
{
- FIXME( "iface %p, value %p stub!\n", iface, value );
- return E_NOTIMPL;
+ struct effect *impl = impl_from_IForceFeedbackEffect( iface );
+
+ TRACE( "iface %p, value %p.\n", iface, value );
+
+ EnterCriticalSection( &impl->cs );
+ *value = impl->params.dwGain / 10000.;
+ LeaveCriticalSection( &impl->cs );
+
+ return S_OK;
}
static HRESULT WINAPI effect_put_Gain( IForceFeedbackEffect *iface, DOUBLE value )
{
- FIXME( "iface %p, value %f stub!\n", iface, value );
- return E_NOTIMPL;
+ struct effect *impl = impl_from_IForceFeedbackEffect( iface );
+ HRESULT hr;
+
+ TRACE( "iface %p, value %f.\n", iface, value );
+
+ EnterCriticalSection( &impl->cs );
+ impl->params.dwGain = round( value * 10000 );
+ if (!impl->effect) hr = S_FALSE;
+ else hr = IDirectInputEffect_SetParameters( impl->effect, &impl->params, DIEP_GAIN );
+ LeaveCriticalSection( &impl->cs );
+
+ return hr;
}
static HRESULT WINAPI effect_get_State( IForceFeedbackEffect *iface, ForceFeedbackEffectState *value )
More information about the wine-cvs
mailing list