windows.gaming.input: Implement Windows.Gaming.Input.RampForceEffect runtimeclass.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2022-05-12 11:58:17 +02:00 committed by Alexandre Julliard
parent ea71b9f81b
commit 569036b1f0
7 changed files with 253 additions and 3 deletions

View File

@ -6407,10 +6407,8 @@ skip_condition:
hr = pWindowsCreateString( ramp_effect_class_name, wcslen( ramp_effect_class_name ), &str );
ok( hr == S_OK, "WindowsCreateString returned %#lx\n", hr );
hr = pRoGetActivationFactory( str, &IID_IActivationFactory, (void **)&activation_factory );
todo_wine
ok( hr == S_OK, "RoGetActivationFactory returned %#lx\n", hr );
pWindowsDeleteString( str );
if (hr != S_OK) goto skip_ramp;
hr = IActivationFactory_ActivateInstance( activation_factory, &tmp_inspectable );
ok( hr == S_OK, "ActivateInstance returned %#lx\n", hr );
@ -6488,7 +6486,6 @@ skip_condition:
ok( ref == 0, "Release returned %lu\n", ref );
skip_ramp:
IForceFeedbackMotor_Release( motor );
IRawGameController_Release( raw_controller );

View File

@ -12,6 +12,7 @@ C_SRCS = \
manager.c \
provider.c \
racing_wheel.c \
ramp_effect.c \
vector.c
IDL_SRCS = \

View File

@ -22,6 +22,7 @@
#include "ddk/hidsdi.h"
#include "dinput.h"
#include "hidusage.h"
#include "provider.h"
#include "wine/debug.h"
@ -41,6 +42,7 @@ struct effect
DWORD axes[3];
LONG directions[3];
DICONSTANTFORCE constant_force;
DIRAMPFORCE ramp_force;
DIEFFECT params;
};
@ -177,6 +179,12 @@ HRESULT force_feedback_effect_create( enum WineForceFeedbackEffectType type, IIn
impl->params.lpvTypeSpecificParams = &impl->constant_force;
impl->params.cbTypeSpecificParams = sizeof(impl->constant_force);
break;
case WineForceFeedbackEffectType_Ramp:
impl->type = GUID_RampForce;
impl->params.lpvTypeSpecificParams = &impl->ramp_force;
impl->params.cbTypeSpecificParams = sizeof(impl->ramp_force);
break;
}
impl->params.dwSize = sizeof(DIEFFECT);

View File

@ -187,6 +187,8 @@ HRESULT WINAPI DllGetActivationFactory( HSTRING class_str, IActivationFactory **
if (!wcscmp( buffer, RuntimeClass_Windows_Gaming_Input_ForceFeedback_ConstantForceEffect ))
IInspectable_QueryInterface( constant_effect_factory, &IID_IActivationFactory, (void **)factory );
if (!wcscmp( buffer, RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect ))
IInspectable_QueryInterface( ramp_effect_factory, &IID_IActivationFactory, (void **)factory );
if (*factory) return S_OK;
return CLASS_E_CLASSNOTAVAILABLE;

View File

@ -50,6 +50,7 @@ extern ICustomGameControllerFactory *gamepad_factory;
extern ICustomGameControllerFactory *racing_wheel_factory;
extern IGameControllerFactoryManagerStatics2 *manager_factory;
extern IInspectable *constant_effect_factory;
extern IInspectable *ramp_effect_factory;
struct vector_iids
{

View File

@ -53,6 +53,7 @@ namespace Windows.Gaming.Input.Custom {
enum WineForceFeedbackEffectType
{
Constant = 1,
Ramp = 2,
};
struct WineGameControllerState

View File

@ -0,0 +1,240 @@
/* 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 "provider.h"
WINE_DEFAULT_DEBUG_CHANNEL(input);
struct ramp_effect
{
IRampForceEffect IRampForceEffect_iface;
IWineForceFeedbackEffectImpl *IWineForceFeedbackEffectImpl_inner;
LONG ref;
};
static inline struct ramp_effect *impl_from_IRampForceEffect( IRampForceEffect *iface )
{
return CONTAINING_RECORD( iface, struct ramp_effect, IRampForceEffect_iface );
}
static HRESULT WINAPI effect_QueryInterface( IRampForceEffect *iface, REFIID iid, void **out )
{
struct ramp_effect *impl = impl_from_IRampForceEffect( 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_IRampForceEffect ))
{
IInspectable_AddRef( (*out = &impl->IRampForceEffect_iface) );
return S_OK;
}
return IWineForceFeedbackEffectImpl_QueryInterface( impl->IWineForceFeedbackEffectImpl_inner, iid, out );
}
static ULONG WINAPI effect_AddRef( IRampForceEffect *iface )
{
struct ramp_effect *impl = impl_from_IRampForceEffect( iface );
ULONG ref = InterlockedIncrement( &impl->ref );
TRACE( "iface %p increasing refcount to %lu.\n", iface, ref );
return ref;
}
static ULONG WINAPI effect_Release( IRampForceEffect *iface )
{
struct ramp_effect *impl = impl_from_IRampForceEffect( iface );
ULONG ref = InterlockedDecrement( &impl->ref );
TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref );
if (!ref)
{
/* guard against re-entry if inner releases an outer iface */
InterlockedIncrement( &impl->ref );
IWineForceFeedbackEffectImpl_Release( impl->IWineForceFeedbackEffectImpl_inner );
free( impl );
}
return ref;
}
static HRESULT WINAPI effect_GetIids( IRampForceEffect *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 effect_GetRuntimeClassName( IRampForceEffect *iface, HSTRING *class_name )
{
return WindowsCreateString( RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect,
ARRAY_SIZE(RuntimeClass_Windows_Gaming_Input_ForceFeedback_RampForceEffect),
class_name );
}
static HRESULT WINAPI effect_GetTrustLevel( IRampForceEffect *iface, TrustLevel *trust_level )
{
FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level );
return E_NOTIMPL;
}
static HRESULT WINAPI effect_SetParameters( IRampForceEffect *iface, Vector3 start_vector, Vector3 end_vector, TimeSpan duration )
{
FIXME( "iface %p, start_vector %s, end_vector %s, duration %I64u stub!\n", iface,
debugstr_vector3( &start_vector ), debugstr_vector3( &end_vector ), duration.Duration );
return E_NOTIMPL;
}
static HRESULT WINAPI effect_SetParametersWithEnvelope( IRampForceEffect *iface, Vector3 start_vector, Vector3 end_vector, FLOAT attack_gain,
FLOAT sustain_gain, FLOAT release_gain, TimeSpan start_delay,
TimeSpan attack_duration, TimeSpan sustain_duration,
TimeSpan release_duration, UINT32 repeat_count )
{
FIXME( "iface %p, start_vector %s, end_vector %s, attack_gain %f, sustain_gain %f, release_gain %f, start_delay %I64u, attack_duration %I64u, "
"sustain_duration %I64u, release_duration %I64u, repeat_count %u stub!\n", iface, debugstr_vector3( &start_vector ), debugstr_vector3( &end_vector ),
attack_gain, sustain_gain, release_gain, start_delay.Duration, attack_duration.Duration, sustain_duration.Duration,
release_duration.Duration, repeat_count );
return E_NOTIMPL;
}
static const struct IRampForceEffectVtbl effect_vtbl =
{
effect_QueryInterface,
effect_AddRef,
effect_Release,
/* IInspectable methods */
effect_GetIids,
effect_GetRuntimeClassName,
effect_GetTrustLevel,
/* IRampForceEffect methods */
effect_SetParameters,
effect_SetParametersWithEnvelope,
};
struct ramp_factory
{
IActivationFactory IActivationFactory_iface;
LONG ref;
};
static inline struct ramp_factory *impl_from_IActivationFactory( IActivationFactory *iface )
{
return CONTAINING_RECORD( iface, struct ramp_factory, IActivationFactory_iface );
}
static HRESULT WINAPI activation_QueryInterface( IActivationFactory *iface, REFIID iid, void **out )
{
struct ramp_factory *impl = impl_from_IActivationFactory( 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_IActivationFactory ))
{
IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) );
return S_OK;
}
FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) );
*out = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI activation_AddRef( IActivationFactory *iface )
{
struct ramp_factory *impl = impl_from_IActivationFactory( iface );
ULONG ref = InterlockedIncrement( &impl->ref );
TRACE( "iface %p increasing refcount to %lu.\n", iface, ref );
return ref;
}
static ULONG WINAPI activation_Release( IActivationFactory *iface )
{
struct ramp_factory *impl = impl_from_IActivationFactory( iface );
ULONG ref = InterlockedDecrement( &impl->ref );
TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref );
return ref;
}
static HRESULT WINAPI activation_GetIids( IActivationFactory *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 activation_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name )
{
FIXME( "iface %p, class_name %p stub!\n", iface, class_name );
return E_NOTIMPL;
}
static HRESULT WINAPI activation_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level )
{
FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level );
return E_NOTIMPL;
}
static HRESULT WINAPI activation_ActivateInstance( IActivationFactory *iface, IInspectable **instance )
{
struct ramp_effect *impl;
HRESULT hr;
TRACE( "iface %p, instance %p.\n", iface, instance );
if (!(impl = calloc( 1, sizeof(struct ramp_effect) ))) return E_OUTOFMEMORY;
impl->IRampForceEffect_iface.lpVtbl = &effect_vtbl;
impl->ref = 1;
if (FAILED(hr = force_feedback_effect_create( WineForceFeedbackEffectType_Ramp, (IInspectable *)&impl->IRampForceEffect_iface,
&impl->IWineForceFeedbackEffectImpl_inner )))
{
free( impl );
return hr;
}
*instance = (IInspectable *)&impl->IRampForceEffect_iface;
TRACE( "created RampForceEffect %p\n", *instance );
return S_OK;
}
static const struct IActivationFactoryVtbl activation_vtbl =
{
activation_QueryInterface,
activation_AddRef,
activation_Release,
/* IInspectable methods */
activation_GetIids,
activation_GetRuntimeClassName,
activation_GetTrustLevel,
/* IActivationFactory methods */
activation_ActivateInstance,
};
static struct ramp_factory ramp_statics =
{
{&activation_vtbl},
1,
};
IInspectable *ramp_effect_factory = (IInspectable *)&ramp_statics.IActivationFactory_iface;