Change the InputDeviceImplementationRequest to be addressable by an InputDevcieId to account for the situation where someone may want to swap out the implementation for a single instance of a devcie type rather than all instances of that device type (the latter can still be achieved using Broadcast instead of Event when calling the EBus method). (#2180)
Signed-off-by: bosnichd <bosnichd@amazon.com>
This commit is contained in:
+25
-5
@@ -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 CreateCustomImplementation(CreateFunctionType createFunction) = 0;
|
||||
virtual void SetCustomImplementation(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>::CreateCustomImplementation
|
||||
AZ_INLINE void CreateCustomImplementation(CreateFunctionType createFunction) override
|
||||
//! \ref InputDeviceImplementationRequest<InputDeviceType>::SetCustomImplementation
|
||||
AZ_INLINE void SetCustomImplementation(CreateFunctionType createFunction) override
|
||||
{
|
||||
AZStd::unique_ptr<typename InputDeviceType::Implementation> newImplementation;
|
||||
if (createFunction)
|
||||
|
||||
Reference in New Issue
Block a user