1 /* WinRT Windows.Gaming.Input implementation
3 * Copyright 2022 RĂ©mi Bernon for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "winstring.h"
30 #include "activation.h"
32 #define WIDL_using_Windows_Foundation
33 #define WIDL_using_Windows_Foundation_Collections
34 #define WIDL_using_Windows_Foundation_Numerics
35 #include "windows.foundation.h"
36 #define WIDL_using_Windows_Devices_Power
37 #define WIDL_using_Windows_Gaming_Input
38 #define WIDL_using_Windows_Gaming_Input_Custom
39 #define WIDL_using_Windows_Gaming_Input_ForceFeedback
40 #include "windows.gaming.input.custom.h"
42 #include "wine/debug.h"
43 #include "wine/list.h"
47 extern HINSTANCE windows_gaming_input
;
48 extern ICustomGameControllerFactory
*controller_factory
;
49 extern ICustomGameControllerFactory
*gamepad_factory
;
50 extern ICustomGameControllerFactory
*racing_wheel_factory
;
51 extern IGameControllerFactoryManagerStatics2
*manager_factory
;
52 extern IInspectable
*constant_effect_factory
;
53 extern IInspectable
*ramp_effect_factory
;
54 extern IInspectable
*periodic_effect_factory
;
55 extern IInspectable
*condition_effect_factory
;
64 extern HRESULT
vector_create( const struct vector_iids
*iids
, void **out
);
66 extern void provider_create( const WCHAR
*device_path
);
67 extern void provider_remove( const WCHAR
*device_path
);
69 extern void manager_on_provider_created( IGameControllerProvider
*provider
);
70 extern void manager_on_provider_removed( IGameControllerProvider
*provider
);
72 extern HRESULT
event_handlers_append( struct list
*list
, IEventHandler_IInspectable
*handler
, EventRegistrationToken
*token
);
73 extern HRESULT
event_handlers_remove( struct list
*list
, EventRegistrationToken
*token
);
74 extern void event_handlers_notify( struct list
*list
, IInspectable
*element
);
76 extern HRESULT
force_feedback_motor_create( IDirectInputDevice8W
*device
, IForceFeedbackMotor
**out
);
77 extern HRESULT
force_feedback_effect_create( enum WineForceFeedbackEffectType type
, IInspectable
*outer
, IWineForceFeedbackEffectImpl
**out
);
79 typedef HRESULT (WINAPI
*async_operation_callback
)( IUnknown
*invoker
, IUnknown
*param
, PROPVARIANT
*result
);
80 extern HRESULT
async_operation_boolean_create( IUnknown
*invoker
, IUnknown
*param
, async_operation_callback callback
,
81 IAsyncOperation_boolean
**out
);
82 extern HRESULT
async_operation_effect_result_create( IUnknown
*invoker
, IUnknown
*param
, async_operation_callback callback
,
83 IAsyncOperation_ForceFeedbackLoadEffectResult
**out
);
85 #define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \
86 static inline impl_type *impl_from( iface_type *iface ) \
88 return CONTAINING_RECORD( iface, impl_type, iface_mem ); \
90 static HRESULT WINAPI pfx##_QueryInterface( iface_type *iface, REFIID iid, void **out ) \
92 impl_type *impl = impl_from( iface ); \
93 return IInspectable_QueryInterface( (IInspectable *)(expr), iid, out ); \
95 static ULONG WINAPI pfx##_AddRef( iface_type *iface ) \
97 impl_type *impl = impl_from( iface ); \
98 return IInspectable_AddRef( (IInspectable *)(expr) ); \
100 static ULONG WINAPI pfx##_Release( iface_type *iface ) \
102 impl_type *impl = impl_from( iface ); \
103 return IInspectable_Release( (IInspectable *)(expr) ); \
105 static HRESULT WINAPI pfx##_GetIids( iface_type *iface, ULONG *iid_count, IID **iids ) \
107 impl_type *impl = impl_from( iface ); \
108 return IInspectable_GetIids( (IInspectable *)(expr), iid_count, iids ); \
110 static HRESULT WINAPI pfx##_GetRuntimeClassName( iface_type *iface, HSTRING *class_name ) \
112 impl_type *impl = impl_from( iface ); \
113 return IInspectable_GetRuntimeClassName( (IInspectable *)(expr), class_name ); \
115 static HRESULT WINAPI pfx##_GetTrustLevel( iface_type *iface, TrustLevel *trust_level ) \
117 impl_type *impl = impl_from( iface ); \
118 return IInspectable_GetTrustLevel( (IInspectable *)(expr), trust_level ); \
120 #define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \
121 DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, &impl->base_iface )
122 #define DEFINE_IINSPECTABLE_OUTER( pfx, iface_type, impl_type, outer_iface ) \
123 DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, impl->outer_iface )
125 static inline const char *debugstr_vector3( const Vector3
*vector
)
127 if (!vector
) return "(null)";
128 return wine_dbg_sprintf( "[%f, %f, %f]", vector
->X
, vector
->Y
, vector
->Z
);