@ -205,6 +205,25 @@ namespace AzFramework
class InputDeviceImplementationRequest : public AZ : : EBusTraits
{
public :
////////////////////////////////////////////////////////////////////////////////////////////
//! EBus Trait: requests can be addressed to a specific InputDeviceId so that they are only
//! handled by one input device that has connected to the bus using that unique id, or they
//! can be broadcast to all input devices that have connected to the bus, regardless of id.
//! Connected input devices are ordered by their local player index from lowest to highest.
static const AZ : : EBusAddressPolicy AddressPolicy = AZ : : EBusAddressPolicy : : ByIdAndOrdered ;
////////////////////////////////////////////////////////////////////////////////////////////
//! EBus Trait: requests should be handled by only one input device connected to each id
static const AZ : : EBusHandlerPolicy HandlerPolicy = AZ : : EBusHandlerPolicy : : Single ;
////////////////////////////////////////////////////////////////////////////////////////////
//! EBus Trait: requests can be addressed to a specific InputDeviceId
using BusIdType = InputDeviceId ;
////////////////////////////////////////////////////////////////////////////////////////////
//! EBus Trait: requests are handled by connected devices in the order of local player index
using BusIdOrderCompare = AZStd : : less < BusIdType > ;
////////////////////////////////////////////////////////////////////////////////////////////
//! Alias for the EBus implementation of this interface
using Bus = AZ : : EBus < InputDeviceImplementationRequest < InputDeviceType > > ;
@ -214,11 +233,12 @@ namespace AzFramework
using CreateFunctionType = typename InputDeviceType : : Implementation * ( * ) ( InputDeviceType & ) ;
////////////////////////////////////////////////////////////////////////////////////////////
//! Create a custom implementation for all the existing instances of this input device type.
//! Set a custom implementation for this input device type, either for a specific instance
//! by addressing the call to an InputDeviceId, or for all existing instances by broadcast.
//! Passing InputDeviceType::Implementation::Create as the argument will create the default
//! device implementation, while passing nullptr will delete any existing implementation.
//! \param[in] createFunction Pointer to the function that will create the implementation.
virtual void Create CustomImplementation( CreateFunctionType createFunction ) = 0 ;
virtual void Set CustomImplementation( CreateFunctionType createFunction ) = 0 ;
} ;
////////////////////////////////////////////////////////////////////////////////////////////////
@ -238,7 +258,7 @@ namespace AzFramework
AZ_INLINE InputDeviceImplementationRequestHandler ( InputDeviceType & inputDevice )
: m_inputDevice ( inputDevice )
{
InputDeviceImplementationRequest < InputDeviceType > : : Bus : : Handler : : BusConnect ( ) ;
InputDeviceImplementationRequest < InputDeviceType > : : Bus : : Handler : : BusConnect ( m_inputDevice . GetInputDeviceId ( ) ) ;
}
////////////////////////////////////////////////////////////////////////////////////////////
@ -251,8 +271,8 @@ namespace AzFramework
using CreateFunctionType = typename InputDeviceType : : Implementation * ( * ) ( InputDeviceType & ) ;
////////////////////////////////////////////////////////////////////////////////////////////
//! \ref InputDeviceImplementationRequest<InputDeviceType>:: Create CustomImplementation
AZ_INLINE void Create CustomImplementation( CreateFunctionType createFunction ) override
//! \ref InputDeviceImplementationRequest<InputDeviceType>:: Set CustomImplementation
AZ_INLINE void Set CustomImplementation( CreateFunctionType createFunction ) override
{
AZStd : : unique_ptr < typename InputDeviceType : : Implementation > newImplementation ;
if ( createFunction )