Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/force_feedback.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c index a4588f7022d..42f3bdc84c7 100644 --- a/dlls/dinput/tests/force_feedback.c +++ b/dlls/dinput/tests/force_feedback.c @@ -5395,8 +5395,7 @@ static void test_windows_gaming_input(void) check_bool_async( bool_async, 1, 4, S_OK, FALSE ); IAsyncInfo_Release( async_info );
- ref = IAsyncOperation_boolean_Release( bool_async ); - ok( ref == 0, "Release returned %lu\n", ref ); + IAsyncOperation_boolean_Release( bool_async );
set_hid_expect( file, &expect_enable_fail, sizeof(expect_enable_fail) ); @@ -5423,8 +5422,7 @@ static void test_windows_gaming_input(void) check_bool_async( bool_async, 1, 4, 0x8685400d, FALSE ); IAsyncInfo_Release( async_info );
- ref = IAsyncOperation_boolean_Release( bool_async ); - ok( ref == 0, "Release returned %lu\n", ref ); + IAsyncOperation_boolean_Release( bool_async );
/* canceling the async op is just ignored */ @@ -5468,8 +5466,7 @@ static void test_windows_gaming_input(void) ok( hr == S_OK, "get_Completed returned %#lx\n", hr ); ok( tmp_handler == NULL, "got handler %p\n", tmp_handler );
- ref = IAsyncOperation_boolean_Release( bool_async ); - ok( ref == 0, "Release returned %lu\n", ref ); + IAsyncOperation_boolean_Release( bool_async );
/* canceling then closing it calls the handler with closed state */ @@ -5514,8 +5511,7 @@ static void test_windows_gaming_input(void) hr = IAsyncOperation_boolean_get_Completed( bool_async, &tmp_handler ); ok( hr == E_ILLEGAL_METHOD_CALL, "get_Completed returned %#lx\n", hr );
- ref = IAsyncOperation_boolean_Release( bool_async ); - ok( ref == 0, "Release returned %lu\n", ref ); + IAsyncOperation_boolean_Release( bool_async );
set_hid_expect( file, &expect_enable, sizeof(expect_enable) ); @@ -5523,9 +5519,7 @@ static void test_windows_gaming_input(void) todo_wine ok( hr == S_OK, "TryEnableAsync returned %#lx\n", hr ); wait_hid_expect_( __FILE__, __LINE__, file, 100, TRUE ); - check_bool_async( bool_async, 1, Completed, S_OK, TRUE ); - ref = IAsyncOperation_boolean_Release( bool_async ); - ok( ref == 0, "Release returned %lu\n", ref ); + IAsyncOperation_boolean_Release( bool_async );
set_hid_expect( file, expect_reset, sizeof(expect_reset) ); @@ -5533,9 +5527,7 @@ static void test_windows_gaming_input(void) todo_wine ok( hr == S_OK, "TryResetAsync returned %#lx\n", hr ); wait_hid_expect_( __FILE__, __LINE__, file, 100, TRUE ); - check_bool_async( bool_async, 1, Completed, S_OK, TRUE ); - ref = IAsyncOperation_boolean_Release( bool_async ); - ok( ref == 0, "Release returned %lu\n", ref ); + IAsyncOperation_boolean_Release( bool_async );
IForceFeedbackMotor_Release( motor );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/force_feedback.c | 3 +-- dlls/windows.gaming.input/controller.c | 19 +++++++++++++++++-- .../windows.gaming.input.forcefeedback.idl | 3 +++ 3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c index 42f3bdc84c7..9880b65aca2 100644 --- a/dlls/dinput/tests/force_feedback.c +++ b/dlls/dinput/tests/force_feedback.c @@ -5284,10 +5284,8 @@ static void test_windows_gaming_input(void)
set_hid_expect( file, expect_acquire, sizeof(expect_acquire) ); hr = IRawGameController_get_ForceFeedbackMotors( raw_controller, &motors_view ); - todo_wine ok( hr == S_OK, "get_ForceFeedbackMotors returned %#lx\n", hr ); wait_hid_expect_( __FILE__, __LINE__, file, 100, TRUE ); /* device gain reports are written asynchronously */ - if (!motors_view) goto skip_tests;
hr = IVectorView_ForceFeedbackMotor_get_Size( motors_view, &size ); ok( hr == S_OK, "get_Size returned %#lx\n", hr ); @@ -5297,6 +5295,7 @@ static void test_windows_gaming_input(void) todo_wine ok( hr == S_OK, "GetAt returned %#lx\n", hr ); IVectorView_ForceFeedbackMotor_Release( motors_view ); + if (hr != S_OK) goto skip_tests;
check_interface( motor, &IID_IUnknown, TRUE ); check_interface( motor, &IID_IInspectable, TRUE ); diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index 03a3ae398cf..d68da6b3142 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -229,8 +229,23 @@ static HRESULT WINAPI raw_controller_get_ButtonCount( IRawGameController *iface,
static HRESULT WINAPI raw_controller_get_ForceFeedbackMotors( IRawGameController *iface, IVectorView_ForceFeedbackMotor **value ) { - FIXME( "iface %p, value %p stub!\n", iface, value ); - return E_NOTIMPL; + static const struct vector_iids iids = + { + .vector = &IID_IVector_ForceFeedbackMotor, + .view = &IID_IVectorView_ForceFeedbackMotor, + .iterable = &IID_IIterable_ForceFeedbackMotor, + .iterator = &IID_IIterator_ForceFeedbackMotor, + }; + IVector_ForceFeedbackMotor *vector; + HRESULT hr; + + TRACE( "iface %p, value %p\n", iface, value ); + + if (FAILED(hr = vector_create( &iids, (void **)&vector ))) return hr; + hr = IVector_ForceFeedbackMotor_GetView( vector, value ); + IVector_ForceFeedbackMotor_Release( vector ); + + return hr; }
static HRESULT WINAPI raw_controller_get_HardwareProductId( IRawGameController *iface, UINT16 *value ) diff --git a/include/windows.gaming.input.forcefeedback.idl b/include/windows.gaming.input.forcefeedback.idl index 432b60a5592..639e0c5cd57 100644 --- a/include/windows.gaming.input.forcefeedback.idl +++ b/include/windows.gaming.input.forcefeedback.idl @@ -36,7 +36,10 @@ namespace Windows.Gaming.Input.ForceFeedback { declare { interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Gaming.Input.ForceFeedback.ForceFeedbackLoadEffectResult>; interface Windows.Foundation.IAsyncOperation<Windows.Gaming.Input.ForceFeedback.ForceFeedbackLoadEffectResult>; + interface Windows.Foundation.Collections.IIterator<Windows.Gaming.Input.ForceFeedback.ForceFeedbackMotor *>; + interface Windows.Foundation.Collections.IIterable<Windows.Gaming.Input.ForceFeedback.ForceFeedbackMotor *>; interface Windows.Foundation.Collections.IVectorView<Windows.Gaming.Input.ForceFeedback.ForceFeedbackMotor *>; + interface Windows.Foundation.Collections.IVector<Windows.Gaming.Input.ForceFeedback.ForceFeedbackMotor *>; }
[
And create it for RawGameController and RacingWheel motors.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/force_feedback.c | 6 +- dlls/windows.gaming.input/Makefile.in | 1 + dlls/windows.gaming.input/controller.c | 11 +- dlls/windows.gaming.input/force_feedback.c | 227 +++++++++++++++++++++ dlls/windows.gaming.input/private.h | 3 + dlls/windows.gaming.input/provider.c | 16 ++ dlls/windows.gaming.input/provider.idl | 3 + dlls/windows.gaming.input/racing_wheel.c | 7 +- 8 files changed, 267 insertions(+), 7 deletions(-) create mode 100644 dlls/windows.gaming.input/force_feedback.c
diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c index 9880b65aca2..a11bd3420e9 100644 --- a/dlls/dinput/tests/force_feedback.c +++ b/dlls/dinput/tests/force_feedback.c @@ -5289,13 +5289,10 @@ static void test_windows_gaming_input(void)
hr = IVectorView_ForceFeedbackMotor_get_Size( motors_view, &size ); ok( hr == S_OK, "get_Size returned %#lx\n", hr ); - todo_wine ok( size == 1, "got size %u\n", size ); hr = IVectorView_ForceFeedbackMotor_GetAt( motors_view, 0, &motor ); - todo_wine ok( hr == S_OK, "GetAt returned %#lx\n", hr ); IVectorView_ForceFeedbackMotor_Release( motors_view ); - if (hr != S_OK) goto skip_tests;
check_interface( motor, &IID_IUnknown, TRUE ); check_interface( motor, &IID_IInspectable, TRUE ); @@ -5356,6 +5353,7 @@ static void test_windows_gaming_input(void) todo_wine ok( hr == S_OK, "TryDisableAsync returned %#lx\n", hr ); wait_hid_expect_( __FILE__, __LINE__, file, 100, TRUE ); + if (hr != S_OK) goto skip_tests; check_bool_async( bool_async, 1, Completed, S_OK, TRUE );
check_interface( bool_async, &IID_IUnknown, TRUE ); @@ -5529,9 +5527,9 @@ static void test_windows_gaming_input(void) IAsyncOperation_boolean_Release( bool_async );
+skip_tests: IForceFeedbackMotor_Release( motor );
-skip_tests: IRawGameController_Release( raw_controller );
CloseHandle( file ); diff --git a/dlls/windows.gaming.input/Makefile.in b/dlls/windows.gaming.input/Makefile.in index 1e0ce5c360c..b9a56992142 100644 --- a/dlls/windows.gaming.input/Makefile.in +++ b/dlls/windows.gaming.input/Makefile.in @@ -4,6 +4,7 @@ IMPORTS = combase uuid user32 dinput8 setupapi hid C_SRCS = \ controller.c \ event_handlers.c \ + force_feedback.c \ gamepad.c \ main.c \ manager.c \ diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c index d68da6b3142..e372ea6c9bf 100644 --- a/dlls/windows.gaming.input/controller.c +++ b/dlls/windows.gaming.input/controller.c @@ -236,13 +236,22 @@ static HRESULT WINAPI raw_controller_get_ForceFeedbackMotors( IRawGameController .iterable = &IID_IIterable_ForceFeedbackMotor, .iterator = &IID_IIterator_ForceFeedbackMotor, }; + struct controller *impl = impl_from_IRawGameController( iface ); IVector_ForceFeedbackMotor *vector; + IForceFeedbackMotor *motor; HRESULT hr;
TRACE( "iface %p, value %p\n", iface, value );
if (FAILED(hr = vector_create( &iids, (void **)&vector ))) return hr; - hr = IVector_ForceFeedbackMotor_GetView( vector, value ); + + if (SUCCEEDED(IWineGameControllerProvider_get_ForceFeedbackMotor( impl->wine_provider, &motor )) && motor) + { + hr = IVector_ForceFeedbackMotor_Append( vector, motor ); + IForceFeedbackMotor_Release( motor ); + } + + if (SUCCEEDED(hr)) hr = IVector_ForceFeedbackMotor_GetView( vector, value ); IVector_ForceFeedbackMotor_Release( vector );
return hr; diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c new file mode 100644 index 00000000000..24617d16733 --- /dev/null +++ b/dlls/windows.gaming.input/force_feedback.c @@ -0,0 +1,227 @@ +/* WinRT Windows.Gaming.Input implementation + * + * Copyright 2022 Rémi Bernon for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "private.h" + +#include "ddk/hidsdi.h" +#include "dinput.h" +#include "hidusage.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(input); + +struct motor +{ + IForceFeedbackMotor IForceFeedbackMotor_iface; + LONG ref; + + IDirectInputDevice8W *device; +}; + +static inline struct motor *impl_from_IForceFeedbackMotor( IForceFeedbackMotor *iface ) +{ + return CONTAINING_RECORD( iface, struct motor, IForceFeedbackMotor_iface ); +} + +static HRESULT WINAPI motor_QueryInterface( IForceFeedbackMotor *iface, REFIID iid, void **out ) +{ + struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); + + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IForceFeedbackMotor )) + { + IInspectable_AddRef( (*out = &impl->IForceFeedbackMotor_iface) ); + return S_OK; + } + + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI motor_AddRef( IForceFeedbackMotor *iface ) +{ + struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI motor_Release( IForceFeedbackMotor *iface ) +{ + struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + + TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); + + if (!ref) + { + IDirectInputDevice8_Release( impl->device ); + free( impl ); + } + + return ref; +} + +static HRESULT WINAPI motor_GetIids( IForceFeedbackMotor *iface, ULONG *iid_count, IID **iids ) +{ + FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_GetRuntimeClassName( IForceFeedbackMotor *iface, HSTRING *class_name ) +{ + return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_ForceFeedbackMotor, + ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_ForceFeedbackMotor), + class_name ); +} + +static HRESULT WINAPI motor_GetTrustLevel( IForceFeedbackMotor *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_get_AreEffectsPaused( IForceFeedbackMotor *iface, BOOLEAN *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_get_MasterGain( IForceFeedbackMotor *iface, double *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_put_MasterGain( IForceFeedbackMotor *iface, double value ) +{ + FIXME( "iface %p, value %#I64x stub!\n", iface, *(UINT64 *)&value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_get_IsEnabled( IForceFeedbackMotor *iface, BOOLEAN *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_get_SupportedAxes( IForceFeedbackMotor *iface, enum ForceFeedbackEffectAxes *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_LoadEffectAsync( IForceFeedbackMotor *iface, IForceFeedbackEffect *effect, + IAsyncOperation_ForceFeedbackLoadEffectResult **async_op ) +{ + FIXME( "iface %p, effect %p, async_op %p stub!\n", iface, effect, async_op ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_PauseAllEffects( IForceFeedbackMotor *iface ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_ResumeAllEffects( IForceFeedbackMotor *iface ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_StopAllEffects( IForceFeedbackMotor *iface ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_TryDisableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op ) +{ + FIXME( "iface %p, async_op %p stub!\n", iface, async_op ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_TryEnableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op ) +{ + FIXME( "iface %p, async_op %p stub!\n", iface, async_op ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_TryResetAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op ) +{ + FIXME( "iface %p, async_op %p stub!\n", iface, async_op ); + return E_NOTIMPL; +} + +static HRESULT WINAPI motor_TryUnloadEffectAsync( IForceFeedbackMotor *iface, IForceFeedbackEffect *effect, + IAsyncOperation_boolean **async_op ) +{ + FIXME( "iface %p, effect %p, async_op %p stub!\n", iface, effect, async_op ); + return E_NOTIMPL; +} + +static const struct IForceFeedbackMotorVtbl motor_vtbl = +{ + motor_QueryInterface, + motor_AddRef, + motor_Release, + /* IInspectable methods */ + motor_GetIids, + motor_GetRuntimeClassName, + motor_GetTrustLevel, + /* IForceFeedbackMotor methods */ + motor_get_AreEffectsPaused, + motor_get_MasterGain, + motor_put_MasterGain, + motor_get_IsEnabled, + motor_get_SupportedAxes, + motor_LoadEffectAsync, + motor_PauseAllEffects, + motor_ResumeAllEffects, + motor_StopAllEffects, + motor_TryDisableAsync, + motor_TryEnableAsync, + motor_TryResetAsync, + motor_TryUnloadEffectAsync, +}; + +HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out ) +{ + struct motor *impl; + + TRACE( "device %p, out %p\n", device, out ); + + if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; + impl->IForceFeedbackMotor_iface.lpVtbl = &motor_vtbl; + impl->ref = 1; + + IDirectInputDevice_AddRef( device ); + impl->device = device; + + *out = &impl->IForceFeedbackMotor_iface; + TRACE( "created ForceFeedbackMotor %p\n", *out ); + return S_OK; +} diff --git a/dlls/windows.gaming.input/private.h b/dlls/windows.gaming.input/private.h index 58b2040d3de..562a84d49ed 100644 --- a/dlls/windows.gaming.input/private.h +++ b/dlls/windows.gaming.input/private.h @@ -25,6 +25,7 @@ #include "winbase.h" #include "winstring.h" #include "objbase.h" +#include "dinput.h"
#include "activation.h"
@@ -64,6 +65,8 @@ extern HRESULT event_handlers_append( struct list *list, IEventHandler_IInspecta extern HRESULT event_handlers_remove( struct list *list, EventRegistrationToken *token ); extern void event_handlers_notify( struct list *list, IInspectable *element );
+extern HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out ); + #define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ static inline impl_type *impl_from( iface_type *iface ) \ { \ diff --git a/dlls/windows.gaming.input/provider.c b/dlls/windows.gaming.input/provider.c index 69098e8abb6..70900000eef 100644 --- a/dlls/windows.gaming.input/provider.c +++ b/dlls/windows.gaming.input/provider.c @@ -315,6 +315,21 @@ static HRESULT WINAPI wine_provider_put_Vibration( IWineGameControllerProvider * return S_OK; }
+static HRESULT WINAPI wine_provider_get_ForceFeedbackMotor( IWineGameControllerProvider *iface, IForceFeedbackMotor **value ) +{ + struct provider *impl = impl_from_IWineGameControllerProvider( iface ); + DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; + HRESULT hr; + + TRACE( "iface %p, value %p.\n", iface, value ); + + if (SUCCEEDED(hr = IDirectInputDevice8_GetCapabilities( impl->dinput_device, &caps )) && (caps.dwFlags & DIDC_FORCEFEEDBACK)) + return force_feedback_motor_create( impl->dinput_device, value ); + + *value = NULL; + return S_OK; +} + static const struct IWineGameControllerProviderVtbl wine_provider_vtbl = { wine_provider_QueryInterface, @@ -332,6 +347,7 @@ static const struct IWineGameControllerProviderVtbl wine_provider_vtbl = wine_provider_get_State, wine_provider_get_Vibration, wine_provider_put_Vibration, + wine_provider_get_ForceFeedbackMotor, };
DEFINE_IINSPECTABLE( game_provider, IGameControllerProvider, struct provider, IWineGameControllerProvider_iface ) diff --git a/dlls/windows.gaming.input/provider.idl b/dlls/windows.gaming.input/provider.idl index 865a149eaa5..60eaab34506 100644 --- a/dlls/windows.gaming.input/provider.idl +++ b/dlls/windows.gaming.input/provider.idl @@ -29,6 +29,7 @@ import "windowscontracts.idl"; import "windows.foundation.idl"; import "windows.gaming.input.idl"; import "windows.gaming.input.custom.idl"; +import "windows.gaming.input.forcefeedback.idl";
namespace Windows.Gaming.Input.Custom { typedef enum WineGameControllerType WineGameControllerType; @@ -85,6 +86,8 @@ namespace Windows.Gaming.Input.Custom { [propget] HRESULT State([out, retval] WineGameControllerState *state); [propget] HRESULT Vibration([out, retval] WineGameControllerVibration *vibration); [propput] HRESULT Vibration([in] WineGameControllerVibration vibration); + + [propget] HRESULT ForceFeedbackMotor([out, retval] Windows.Gaming.Input.ForceFeedback.ForceFeedbackMotor **motor); }
[ diff --git a/dlls/windows.gaming.input/racing_wheel.c b/dlls/windows.gaming.input/racing_wheel.c index b4635d03153..4a494775dc2 100644 --- a/dlls/windows.gaming.input/racing_wheel.c +++ b/dlls/windows.gaming.input/racing_wheel.c @@ -245,8 +245,11 @@ static HRESULT WINAPI racing_wheel_get_MaxWheelAngle( IRacingWheel *iface, DOUBL
static HRESULT WINAPI racing_wheel_get_WheelMotor( IRacingWheel *iface, IForceFeedbackMotor **value ) { - FIXME( "iface %p, value %p stub!\n", iface, value ); - return E_NOTIMPL; + struct racing_wheel *impl = impl_from_IRacingWheel( iface ); + + TRACE( "iface %p, value %p\n", iface, value ); + + return IWineGameControllerProvider_get_ForceFeedbackMotor( impl->wine_provider, value ); }
static HRESULT WINAPI racing_wheel_GetButtonLabel( IRacingWheel *iface, enum RacingWheelButtons button,
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/force_feedback.c | 4 +--- dlls/windows.gaming.input/force_feedback.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c index a11bd3420e9..591496ca908 100644 --- a/dlls/dinput/tests/force_feedback.c +++ b/dlls/dinput/tests/force_feedback.c @@ -5048,7 +5048,6 @@ static void test_windows_gaming_input(void) .report_id = 1, .report_len = 2, .report_buf = {1, 0x01}, - .todo = TRUE, }, /* device gain */ { @@ -5056,7 +5055,6 @@ static void test_windows_gaming_input(void) .report_id = 6, .report_len = 2, .report_buf = {6, 0xff}, - .todo = TRUE, }, }; static struct hid_expect expect_set_gain = @@ -5285,7 +5283,7 @@ static void test_windows_gaming_input(void) set_hid_expect( file, expect_acquire, sizeof(expect_acquire) ); hr = IRawGameController_get_ForceFeedbackMotors( raw_controller, &motors_view ); ok( hr == S_OK, "get_ForceFeedbackMotors 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 */
hr = IVectorView_ForceFeedbackMotor_get_Size( motors_view, &size ); ok( hr == S_OK, "get_Size returned %#lx\n", hr ); diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index 24617d16733..54742475e7b 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -211,9 +211,14 @@ static const struct IForceFeedbackMotorVtbl motor_vtbl = HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out ) { struct motor *impl; + HRESULT hr;
TRACE( "device %p, out %p\n", device, out );
+ if (FAILED(hr = IDirectInputDevice8_Unacquire( device ))) goto failed; + if (FAILED(hr = IDirectInputDevice8_SetCooperativeLevel( device, GetDesktopWindow(), DISCL_BACKGROUND | DISCL_EXCLUSIVE ))) goto failed; + if (FAILED(hr = IDirectInputDevice8_Acquire( device ))) goto failed; + if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; impl->IForceFeedbackMotor_iface.lpVtbl = &motor_vtbl; impl->ref = 1; @@ -224,4 +229,10 @@ HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbac *out = &impl->IForceFeedbackMotor_iface; TRACE( "created ForceFeedbackMotor %p\n", *out ); return S_OK; + +failed: + IDirectInputDevice8_SetCooperativeLevel( device, 0, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE ); + IDirectInputDevice8_Acquire( device ); + WARN( "Failed to acquire device exclusively, hr %#lx\n", hr ); + return hr; }
Signed-off-by: Rémi Bernon rbernon@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 )
And IForceFeedbackMotor_get_AreEffectsPaused.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/force_feedback.c | 8 ----- dlls/windows.gaming.input/force_feedback.c | 34 +++++++++++++++++----- 2 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c index 5b4bfade9bc..51a6df7222d 100644 --- a/dlls/dinput/tests/force_feedback.c +++ b/dlls/dinput/tests/force_feedback.c @@ -5070,7 +5070,6 @@ static void test_windows_gaming_input(void) .report_id = 1, .report_len = 2, .report_buf = {1, 0x02}, - .todo = TRUE, }; static struct hid_expect expect_resume = { @@ -5078,7 +5077,6 @@ static void test_windows_gaming_input(void) .report_id = 1, .report_len = 2, .report_buf = {1, 0x03}, - .todo = TRUE, }; static struct hid_expect expect_stop = { @@ -5086,7 +5084,6 @@ static void test_windows_gaming_input(void) .report_id = 1, .report_len = 2, .report_buf = {1, 0x06}, - .todo = TRUE, }; static struct hid_expect expect_disable = { @@ -5299,9 +5296,7 @@ static void test_windows_gaming_input(void)
paused = TRUE; hr = IForceFeedbackMotor_get_AreEffectsPaused( motor, &paused ); - todo_wine ok( hr == S_OK, "get_AreEffectsPaused returned %#lx\n", hr ); - todo_wine ok( paused == FALSE, "got paused %u\n", paused );
gain = 12345.6; @@ -5329,15 +5324,12 @@ static void test_windows_gaming_input(void)
set_hid_expect( file, &expect_pause, sizeof(expect_pause) ); hr = IForceFeedbackMotor_PauseAllEffects( motor ); - todo_wine ok( hr == S_OK, "PauseAllEffects returned %#lx\n", hr ); set_hid_expect( file, &expect_resume, sizeof(expect_resume) ); hr = IForceFeedbackMotor_ResumeAllEffects( motor ); - todo_wine ok( hr == S_OK, "ResumeAllEffects returned %#lx\n", hr ); set_hid_expect( file, &expect_stop, sizeof(expect_stop) ); hr = IForceFeedbackMotor_StopAllEffects( motor ); - todo_wine ok( hr == S_OK, "StopAllEffects returned %#lx\n", hr ); set_hid_expect( file, NULL, 0 );
diff --git a/dlls/windows.gaming.input/force_feedback.c b/dlls/windows.gaming.input/force_feedback.c index 6d4e533bc77..fad5ade402c 100644 --- a/dlls/windows.gaming.input/force_feedback.c +++ b/dlls/windows.gaming.input/force_feedback.c @@ -105,8 +105,17 @@ static HRESULT WINAPI motor_GetTrustLevel( IForceFeedbackMotor *iface, TrustLeve
static HRESULT WINAPI motor_get_AreEffectsPaused( IForceFeedbackMotor *iface, BOOLEAN *value ) { - FIXME( "iface %p, value %p stub!\n", iface, value ); - return E_NOTIMPL; + struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + DWORD state; + HRESULT hr; + + TRACE( "iface %p, value %p.\n", iface, value ); + + if (FAILED(hr = IDirectInputDevice8_GetForceFeedbackState( impl->device, &state ))) + return hr; + + *value = (state & DIGFFS_PAUSED); + return S_OK; }
static HRESULT WINAPI motor_get_MasterGain( IForceFeedbackMotor *iface, double *value ) @@ -171,20 +180,29 @@ static HRESULT WINAPI motor_LoadEffectAsync( IForceFeedbackMotor *iface, IForceF
static HRESULT WINAPI motor_PauseAllEffects( IForceFeedbackMotor *iface ) { - FIXME( "iface %p stub!\n", iface ); - return E_NOTIMPL; + struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + + TRACE( "iface %p.\n", iface ); + + return IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_PAUSE ); }
static HRESULT WINAPI motor_ResumeAllEffects( IForceFeedbackMotor *iface ) { - FIXME( "iface %p stub!\n", iface ); - return E_NOTIMPL; + struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + + TRACE( "iface %p.\n", iface ); + + return IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_CONTINUE ); }
static HRESULT WINAPI motor_StopAllEffects( IForceFeedbackMotor *iface ) { - FIXME( "iface %p stub!\n", iface ); - return E_NOTIMPL; + struct motor *impl = impl_from_IForceFeedbackMotor( iface ); + + TRACE( "iface %p.\n", iface ); + + return IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_STOPALL ); }
static HRESULT WINAPI motor_TryDisableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op )