Commit 7b3a669e authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

windows.gaming.input: Use IUnknown invoker instead of IInspectable and add a parameter.

parent c30c0abd
...@@ -37,7 +37,8 @@ struct async_info ...@@ -37,7 +37,8 @@ struct async_info
async_operation_callback callback; async_operation_callback callback;
TP_WORK *async_run_work; TP_WORK *async_run_work;
IInspectable *invoker; IUnknown *invoker;
IUnknown *param;
CRITICAL_SECTION cs; CRITICAL_SECTION cs;
IWineAsyncOperationCompletedHandler *handler; IWineAsyncOperationCompletedHandler *handler;
...@@ -95,7 +96,8 @@ static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface ) ...@@ -95,7 +96,8 @@ static ULONG WINAPI async_impl_Release( IWineAsyncInfoImpl *iface )
{ {
if (impl->handler && impl->handler != HANDLER_NOT_SET) IWineAsyncOperationCompletedHandler_Release( impl->handler ); if (impl->handler && impl->handler != HANDLER_NOT_SET) IWineAsyncOperationCompletedHandler_Release( impl->handler );
IAsyncInfo_Close( &impl->IAsyncInfo_iface ); IAsyncInfo_Close( &impl->IAsyncInfo_iface );
IInspectable_Release( impl->invoker ); if (impl->param) IUnknown_Release( impl->param );
if (impl->invoker) IUnknown_Release( impl->invoker );
DeleteCriticalSection( &impl->cs ); DeleteCriticalSection( &impl->cs );
free( impl ); free( impl );
} }
...@@ -302,7 +304,7 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void * ...@@ -302,7 +304,7 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *
PROPVARIANT result; PROPVARIANT result;
HRESULT hr; HRESULT hr;
hr = impl->callback( impl->invoker, &result ); hr = impl->callback( impl->invoker, impl->param, &result );
EnterCriticalSection( &impl->cs ); EnterCriticalSection( &impl->cs );
if (impl->status != Closed) impl->status = FAILED(hr) ? Error : Completed; if (impl->status != Closed) impl->status = FAILED(hr) ? Error : Completed;
...@@ -327,7 +329,7 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void * ...@@ -327,7 +329,7 @@ static void CALLBACK async_info_callback( TP_CALLBACK_INSTANCE *instance, void *
PropVariantClear( &result ); PropVariantClear( &result );
} }
static HRESULT async_info_create( IInspectable *invoker, async_operation_callback callback, static HRESULT async_info_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback,
IInspectable *outer, IWineAsyncInfoImpl **out ) IInspectable *outer, IWineAsyncInfoImpl **out )
{ {
struct async_info *impl; struct async_info *impl;
...@@ -344,7 +346,9 @@ static HRESULT async_info_create( IInspectable *invoker, async_operation_callbac ...@@ -344,7 +346,9 @@ static HRESULT async_info_create( IInspectable *invoker, async_operation_callbac
if (!(impl->async_run_work = CreateThreadpoolWork( async_info_callback, &impl->IWineAsyncInfoImpl_iface, NULL ))) if (!(impl->async_run_work = CreateThreadpoolWork( async_info_callback, &impl->IWineAsyncInfoImpl_iface, NULL )))
return HRESULT_FROM_WIN32( GetLastError() ); return HRESULT_FROM_WIN32( GetLastError() );
IInspectable_AddRef( (impl->invoker = invoker) ); if ((impl->invoker = invoker)) IUnknown_AddRef( impl->invoker );
if ((impl->param = param)) IUnknown_AddRef( impl->param );
InitializeCriticalSection( &impl->cs ); InitializeCriticalSection( &impl->cs );
impl->cs.DebugInfo->Spare[0] = (DWORD_PTR)( __FILE__ ": async_info.cs" ); impl->cs.DebugInfo->Spare[0] = (DWORD_PTR)( __FILE__ ": async_info.cs" );
...@@ -473,7 +477,7 @@ static const struct IAsyncOperation_booleanVtbl async_bool_vtbl = ...@@ -473,7 +477,7 @@ static const struct IAsyncOperation_booleanVtbl async_bool_vtbl =
async_bool_GetResults, async_bool_GetResults,
}; };
HRESULT async_operation_boolean_create( IInspectable *invoker, async_operation_callback callback, HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback,
IAsyncOperation_boolean **out ) IAsyncOperation_boolean **out )
{ {
struct async_bool *impl; struct async_bool *impl;
...@@ -484,7 +488,7 @@ HRESULT async_operation_boolean_create( IInspectable *invoker, async_operation_c ...@@ -484,7 +488,7 @@ HRESULT async_operation_boolean_create( IInspectable *invoker, async_operation_c
impl->IAsyncOperation_boolean_iface.lpVtbl = &async_bool_vtbl; impl->IAsyncOperation_boolean_iface.lpVtbl = &async_bool_vtbl;
impl->ref = 1; impl->ref = 1;
if (FAILED(hr = async_info_create( invoker, callback, (IInspectable *)&impl->IAsyncOperation_boolean_iface, &impl->IWineAsyncInfoImpl_inner )) || if (FAILED(hr = async_info_create( invoker, param, callback, (IInspectable *)&impl->IAsyncOperation_boolean_iface, &impl->IWineAsyncInfoImpl_inner )) ||
FAILED(hr = IWineAsyncInfoImpl_Start( impl->IWineAsyncInfoImpl_inner ))) FAILED(hr = IWineAsyncInfoImpl_Start( impl->IWineAsyncInfoImpl_inner )))
{ {
if (impl->IWineAsyncInfoImpl_inner) IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner ); if (impl->IWineAsyncInfoImpl_inner) IWineAsyncInfoImpl_Release( impl->IWineAsyncInfoImpl_inner );
......
...@@ -212,9 +212,9 @@ static HRESULT WINAPI motor_StopAllEffects( IForceFeedbackMotor *iface ) ...@@ -212,9 +212,9 @@ static HRESULT WINAPI motor_StopAllEffects( IForceFeedbackMotor *iface )
return IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_STOPALL ); return IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_STOPALL );
} }
static HRESULT WINAPI motor_try_disable_async( IInspectable *iface, PROPVARIANT *result ) static HRESULT WINAPI motor_try_disable_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result )
{ {
struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)iface ); struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker );
HRESULT hr; HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_SETACTUATORSOFF ); hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_SETACTUATORSOFF );
...@@ -227,12 +227,12 @@ static HRESULT WINAPI motor_try_disable_async( IInspectable *iface, PROPVARIANT ...@@ -227,12 +227,12 @@ static HRESULT WINAPI motor_try_disable_async( IInspectable *iface, PROPVARIANT
static HRESULT WINAPI motor_TryDisableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op ) static HRESULT WINAPI motor_TryDisableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op )
{ {
TRACE( "iface %p, async_op %p.\n", iface, async_op ); TRACE( "iface %p, async_op %p.\n", iface, async_op );
return async_operation_boolean_create( (IInspectable *)iface, motor_try_disable_async, async_op ); return async_operation_boolean_create( (IUnknown *)iface, NULL, motor_try_disable_async, async_op );
} }
static HRESULT WINAPI motor_try_enable_async( IInspectable *iface, PROPVARIANT *result ) static HRESULT WINAPI motor_try_enable_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result )
{ {
struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)iface ); struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker );
HRESULT hr; HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_SETACTUATORSON ); hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_SETACTUATORSON );
...@@ -245,12 +245,12 @@ static HRESULT WINAPI motor_try_enable_async( IInspectable *iface, PROPVARIANT * ...@@ -245,12 +245,12 @@ static HRESULT WINAPI motor_try_enable_async( IInspectable *iface, PROPVARIANT *
static HRESULT WINAPI motor_TryEnableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op ) static HRESULT WINAPI motor_TryEnableAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op )
{ {
TRACE( "iface %p, async_op %p.\n", iface, async_op ); TRACE( "iface %p, async_op %p.\n", iface, async_op );
return async_operation_boolean_create( (IInspectable *)iface, motor_try_enable_async, async_op ); return async_operation_boolean_create( (IUnknown *)iface, NULL, motor_try_enable_async, async_op );
} }
static HRESULT WINAPI motor_try_reset_async( IInspectable *iface, PROPVARIANT *result ) static HRESULT WINAPI motor_try_reset_async( IUnknown *invoker, IUnknown *param, PROPVARIANT *result )
{ {
struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)iface ); struct motor *impl = impl_from_IForceFeedbackMotor( (IForceFeedbackMotor *)invoker );
HRESULT hr; HRESULT hr;
hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_RESET ); hr = IDirectInputDevice8_SendForceFeedbackCommand( impl->device, DISFFC_RESET );
...@@ -263,7 +263,7 @@ static HRESULT WINAPI motor_try_reset_async( IInspectable *iface, PROPVARIANT *r ...@@ -263,7 +263,7 @@ static HRESULT WINAPI motor_try_reset_async( IInspectable *iface, PROPVARIANT *r
static HRESULT WINAPI motor_TryResetAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op ) static HRESULT WINAPI motor_TryResetAsync( IForceFeedbackMotor *iface, IAsyncOperation_boolean **async_op )
{ {
TRACE( "iface %p, async_op %p.\n", iface, async_op ); TRACE( "iface %p, async_op %p.\n", iface, async_op );
return async_operation_boolean_create( (IInspectable *)iface, motor_try_reset_async, async_op ); return async_operation_boolean_create( (IUnknown *)iface, NULL, motor_try_reset_async, async_op );
} }
static HRESULT WINAPI motor_TryUnloadEffectAsync( IForceFeedbackMotor *iface, IForceFeedbackEffect *effect, static HRESULT WINAPI motor_TryUnloadEffectAsync( IForceFeedbackMotor *iface, IForceFeedbackEffect *effect,
......
...@@ -67,8 +67,8 @@ extern void event_handlers_notify( struct list *list, IInspectable *element ); ...@@ -67,8 +67,8 @@ extern void event_handlers_notify( struct list *list, IInspectable *element );
extern HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out ); extern HRESULT force_feedback_motor_create( IDirectInputDevice8W *device, IForceFeedbackMotor **out );
typedef HRESULT (WINAPI *async_operation_callback)( IInspectable *invoker, PROPVARIANT *result ); typedef HRESULT (WINAPI *async_operation_callback)( IUnknown *invoker, IUnknown *param, PROPVARIANT *result );
extern HRESULT async_operation_boolean_create( IInspectable *invoker, async_operation_callback callback, extern HRESULT async_operation_boolean_create( IUnknown *invoker, IUnknown *param, async_operation_callback callback,
IAsyncOperation_boolean **out ); IAsyncOperation_boolean **out );
#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ #define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \
......
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