Module: wine Branch: master Commit: 5f8f6c34526a406a72516b1c3e3bd53623f2260b URL: https://gitlab.winehq.org/wine/wine/-/commit/5f8f6c34526a406a72516b1c3e3bd53...
Author: Ivo Ivanov logos128@gmail.com Date: Sat Jul 23 16:48:37 2022 +0300
windows.gaming.input: Implement IForceFeedbackMotor_get_SupportedAxes.
---
dlls/dinput/tests/force_feedback.c | 13 +++++++++---- dlls/windows.gaming.input/force_feedback.c | 26 ++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c index de7d5990f34..d743f959f55 100644 --- a/dlls/dinput/tests/force_feedback.c +++ b/dlls/dinput/tests/force_feedback.c @@ -5735,10 +5735,10 @@ static void test_windows_gaming_input(void) EventRegistrationToken controller_added_token; IPeriodicForceEffectFactory *periodic_factory; struct bool_async_handler bool_async_handler; + ForceFeedbackEffectAxes supported_axes, axes; IVectorView_ForceFeedbackMotor *motors_view; IConditionForceEffect *condition_effect; ConditionForceEffectKind condition_kind; - ForceFeedbackEffectAxes supported_axes; IActivationFactory *activation_factory; IPeriodicForceEffect *periodic_effect; IConstantForceEffect *constant_effect; @@ -5856,12 +5856,17 @@ static void test_windows_gaming_input(void) ok( hr == S_OK, "get_IsEnabled returned %#lx\n", hr ); ok( enabled == TRUE, "got enabled %u\n", enabled );
+ /* SupportedAxes always returns ForceFeedbackEffectAxes_X on Windows, + * no matter which axis is available for FFB in the Set Effects report, + * or whether a X axis is declared at all. + */ + supported_axes = 0xdeadbeef; hr = IForceFeedbackMotor_get_SupportedAxes( motor, &supported_axes ); - todo_wine ok( hr == S_OK, "get_SupportedAxes returned %#lx\n", hr ); - todo_wine - ok( supported_axes == ForceFeedbackEffectAxes_X, "got axes %#x\n", supported_axes ); + axes = ForceFeedbackEffectAxes_X | ForceFeedbackEffectAxes_Y | ForceFeedbackEffectAxes_Z; + ok( supported_axes == axes || broken( supported_axes == ForceFeedbackEffectAxes_X ), + "got axes %#x\n", supported_axes );
set_hid_expect( file, &expect_pause, sizeof(expect_pause) ); hr = IForceFeedbackMotor_PauseAllEffects( motor ); diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index 198268eac24..e32e6fea9b4 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -532,10 +532,32 @@ static HRESULT WINAPI motor_get_IsEnabled( IForceFeedbackMotor *iface, BOOLEAN * return hr; }
+static BOOL CALLBACK check_ffb_axes( const DIDEVICEOBJECTINSTANCEW *obj, void *args ) +{ + ForceFeedbackEffectAxes *value = args; + + if (obj->dwType & DIDFT_FFACTUATOR) + { + if (IsEqualIID( &obj->guidType, &GUID_XAxis )) *value |= ForceFeedbackEffectAxes_X; + else if (IsEqualIID( &obj->guidType, &GUID_YAxis )) *value |= ForceFeedbackEffectAxes_Y; + else if (IsEqualIID( &obj->guidType, &GUID_ZAxis )) *value |= ForceFeedbackEffectAxes_Z; + } + + return DIENUM_CONTINUE; +} + static HRESULT WINAPI motor_get_SupportedAxes( IForceFeedbackMotor *iface, enum ForceFeedbackEffectAxes *value ) { - FIXME( "iface %p, value %p stub!\n", iface, value ); - return E_NOTIMPL; + struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + HRESULT hr; + + TRACE( "iface %p, value %p.\n", iface, value ); + + *value = ForceFeedbackEffectAxes_None; + if (FAILED(hr = IDirectInputDevice8_EnumObjects( impl->device, check_ffb_axes, value, DIDFT_AXIS ))) + *value = ForceFeedbackEffectAxes_None; + + return hr; }
static HRESULT WINAPI motor_load_effect_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result )