Open 3D Engine AzFramework API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AzFramework::InputChannel Class Reference

#include <InputChannel.h>

Inherits InputChannelRequestBus::Handler.

Inherited by AzFramework::InputChannelAnalog, AzFramework::InputChannelAxis2D, AzFramework::InputChannelAxis3D, AzFramework::InputChannelDelta, AzFramework::InputChannelDigital, AzFramework::InputChannelQuaternion, and AzFramework::InputMapping.

Classes

struct  CustomData
 Base struct from which to derive all custom input data. More...
 
struct  PositionData2D
 Custom data struct for input channels associated with a 2D position. More...
 
struct  Snapshot
 Snapshot of an input channel that can be constructed, copied, and stored independently. More...
 

Public Types

enum class  State { Idle , Began , Updated , Ended }
 State of the input channel (not all channels will go through all states) More...
 
using SharedPositionData2D = AZStd::shared_ptr< InputChannel::PositionData2D >
 Alias for verbose shared_ptr class.
 

Public Member Functions

 AZ_CLASS_ALLOCATOR (InputChannel, AZ::SystemAllocator)
 
 AZ_RTTI (InputChannel, "{1C88625D-D297-4A1C-AE07-E17F88D138F3}")
 
 InputChannel (const InputChannelId &inputChannelId, const InputDevice &inputDevice)
 
 AZ_DISABLE_COPY_MOVE (InputChannel)
 
 ~InputChannel () override
 Destructor.
 
const InputChannelGetInputChannel () const final
 AzFramework::InputChannelRequests::GetInputChannel
 
const InputChannelIdGetInputChannelId () const
 
const InputDeviceGetInputDevice () const
 
State GetState () const
 
bool IsActive () const
 
virtual float GetValue () const
 
virtual float GetDelta () const
 
virtual const CustomDataGetCustomData () const
 
template<class CustomDataType >
const CustomDataType * GetCustomData () const
 
bool UpdateState (bool isChannelActive)
 
void ResetState () override
 AzFramework::InputChannelRequests::ResetState
 
bool IsStateIdle () const
 
bool IsStateBegan () const
 
bool IsStateUpdated () const
 
bool IsStateEnded () const
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 

Detailed Description

Base class for all input channels that represent the current state of a single input source. Derived classes should provide additional functions that allow their parent input devices to update the state and value(s) of the input channel as raw input is received from the system, and they can (optionally) override the virtual GetCustomData function to return custom data.

Member Enumeration Documentation

◆ State

State of the input channel (not all channels will go through all states)

Enumerator
Idle 

Examples: inactive or idle, not currently emitting input events.

Began 

Examples: button pressed, trigger engaged, thumb-stick exits deadzone.

Updated 

Examples: button held, trigger changed, thumb-stick is outside deadzone.

Ended 

Examples: button released, trigger released, thumb-stick enters deadzone.

Constructor & Destructor Documentation

◆ InputChannel()

AzFramework::InputChannel::InputChannel ( const InputChannelId inputChannelId,
const InputDevice inputDevice 
)

Constructor

Parameters
[in]inputChannelIdId of the input channel
[in]inputDeviceInput device that owns the input channel

Member Function Documentation

◆ GetCustomData() [1/2]

◆ GetCustomData() [2/2]

template<class CustomDataType >
const CustomDataType * AzFramework::InputChannel::GetCustomData
inline

Access to any custom data of a specific type provided by the input channel

Template Parameters
CustomDataTypeThe specific type of custom data to be returned if it exists
Returns
Pointer to the data if it exists and is of type CustomDataType, nullptr othewise

◆ GetDelta()

virtual float AzFramework::InputChannel::GetDelta ( ) const
virtual

Access to the one dimensional float delta of the input channel

Returns
The current one dimensional float delta of the input channel

Reimplemented in AzFramework::InputChannelAnalog, AzFramework::InputChannelAxis2D, AzFramework::InputChannelAxis3D, AzFramework::InputChannelDelta, AzFramework::InputChannelDigital, AzFramework::InputChannelQuaternion, AzFramework::InputMappingAnd, and AzFramework::InputMappingOr.

◆ GetInputChannelId()

const InputChannelId & AzFramework::InputChannel::GetInputChannelId ( ) const

Access to the input channel's id

Returns
Id of the input channel

◆ GetInputDevice()

const InputDevice & AzFramework::InputChannel::GetInputDevice ( ) const

Access to the input channel's device

Returns
Input device that owns the input channel

◆ GetState()

State AzFramework::InputChannel::GetState ( ) const

Direct access to the input channel's current state

Returns
The current state of the input channel

◆ GetValue()

virtual float AzFramework::InputChannel::GetValue ( ) const
virtual

Access to the one dimensional float value of the input channel

Returns
The current one dimensional float value of the input channel

Reimplemented in AzFramework::InputChannelAnalog, AzFramework::InputChannelAxis2D, AzFramework::InputChannelAxis3D, AzFramework::InputChannelDelta, AzFramework::InputChannelDigital, AzFramework::InputChannelQuaternion, AzFramework::InputMappingAnd, and AzFramework::InputMappingOr.

◆ IsActive()

bool AzFramework::InputChannel::IsActive ( ) const

Indirect access to the input channel's current state

Returns
True if the channel is in the 'Began' or 'Updated' states, false otherwise

◆ IsStateIdle()

bool AzFramework::InputChannel::IsStateIdle ( ) const

Indirect access to the input channel's current state

Returns
True if the input channel is currently in the specified state, false otherwise

◆ UpdateState()

bool AzFramework::InputChannel::UpdateState ( bool  isChannelActive)

Update the channel's state based on whether it is active/engaged or inactive/idle, which will broadcast an input event if the channel is left in a non-idle state. Should only be called a maximum of once per channel per frame from InputDeviceRequests::TickInputDevice to ensure input channels broadcast no more than one event each frame (at the same time).

Parameters
[in]isChannelActiveWhether the input channel is currently active/engaged
Returns
Whether the update resulted in a state transition (was m_state changed)

The documentation for this class was generated from the following file: