Commit 69745cc1 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

windows.gaming.input: Implement ForceFeedbackMotor stub runtimeclass.

And create it for RawGameController and RacingWheel motors. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 5c88fea5
......@@ -5288,13 +5288,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 );
......@@ -5355,6 +5352,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 );
......@@ -5528,9 +5526,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 );
......
......@@ -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 \
......
......@@ -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;
......
/* 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;
}
......@@ -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 ) \
{ \
......
......@@ -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 )
......
......@@ -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);
}
[
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment