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::InputDeviceMouse Class Reference

#include <InputDeviceMouse.h>

Inherits AzFramework::InputDevice, and InputSystemCursorRequestBus::Handler.

Classes

struct  Button
 
class  Implementation
 Base class for platform specific implementations of mouse input devices. More...
 
struct  Movement
 

Public Types

using ImplementationFactory = Implementation *(InputDeviceMouse &)
 Alias for the function type used to create a custom implementation for this input device.
 

Public Member Functions

 AZ_CLASS_ALLOCATOR (InputDeviceMouse, AZ::SystemAllocator)
 
 AZ_RTTI (InputDeviceMouse, "{A509CA9D-BEAA-4124-9AAD-7381E46EBDD4}", InputDevice)
 
 InputDeviceMouse (const InputDeviceId &inputDeviceId=Id, ImplementationFactory implementationFactory=&Implementation::Create)
 
 AZ_DISABLE_COPY_MOVE (InputDeviceMouse)
 
 ~InputDeviceMouse () override
 Destructor.
 
const InputChannelByIdMap & GetInputChannelsById () const override
 AzFramework::InputDevice::GetInputChannelsById
 
bool IsSupported () const override
 AzFramework::InputDevice::IsSupported
 
bool IsConnected () const override
 AzFramework::InputDevice::IsConnected
 
void TickInputDevice () override
 AzFramework::InputDeviceRequests::TickInputDevice
 
void SetSystemCursorState (SystemCursorState systemCursorState) override
 AzFramework::InputSystemCursorRequests::SetSystemCursorState
 
SystemCursorState GetSystemCursorState () const override
 AzFramework::InputSystemCursorRequests::GetSystemCursorState
 
void SetSystemCursorPositionNormalized (AZ::Vector2 positionNormalized) override
 AzFramework::InputSystemCursorRequests::SetSystemCursorPositionNormalized
 
AZ::Vector2 GetSystemCursorPositionNormalized () const override
 AzFramework::InputSystemCursorRequests::GetSystemCursorPositionNormalized
 
void SetRawMovementSampleRate (AZ::u32 sampleRateHertz)
 
void SetImplementation (AZStd::unique_ptr< Implementation > impl)
 
- Public Member Functions inherited from AzFramework::InputDevice
 AZ_CLASS_ALLOCATOR (InputDevice, AZ::SystemAllocator)
 
 AZ_RTTI (InputDevice, "{29F9FB6B-15CB-4DB4-9F36-DE7396B82F3D}")
 
 InputDevice (const InputDeviceId &inputDeviceId)
 
 AZ_DISABLE_COPY_MOVE (InputDevice)
 
 ~InputDevice () override
 Destructor.
 
const InputDeviceGetInputDevice () const final
 AzFramework::InputDeviceRequests::GetInputDevice
 
const InputDeviceIdGetInputDeviceId () const
 
virtual LocalUserId GetAssignedLocalUserId () const
 
virtual void PromptLocalUserSignIn () const
 
virtual const InputChannelByIdMap & GetInputChannelsById () const =0
 
virtual bool IsSupported () const =0
 
virtual bool IsConnected () const =0
 

Static Public Member Functions

static bool IsMouseDevice (const InputDeviceId &inputDeviceId)
 
static void Reflect (AZ::ReflectContext *context)
 
- Static Public Member Functions inherited from AzFramework::InputDevice
static void Reflect (AZ::ReflectContext *context)
 

Static Public Attributes

static constexpr AZ::u32 MovementSampleRateDefault {60}
 
static constexpr AZ::u32 MovementSampleRateQueueAll {std::numeric_limits<AZ::u32>::max()}
 
static constexpr AZ::u32 MovementSampleRateAccumulateAll {0}
 
static constexpr InputDeviceId Id {"mouse"}
 The id used to identify the primary mouse input device.
 
static constexpr InputChannelId SystemCursorPosition {"mouse_system_cursor_position"}
 

Protected Types

using ButtonChannelByIdMap = AZStd::unordered_map< InputChannelId, InputChannelDigitalWithSharedPosition2D * >
 
using MovementChannelByIdMap = AZStd::unordered_map< InputChannelId, InputChannelDeltaWithSharedPosition2D * >
 

Protected Attributes

InputChannelByIdMap m_allChannelsById
 All mouse channels.
 
ButtonChannelByIdMap m_buttonChannelsById
 Mouse button channels.
 
MovementChannelByIdMap m_movementChannelsById
 Mouse movement channels.
 
InputChannelDeltaWithSharedPosition2Dm_cursorPositionChannel
 Cursor position channel.
 
InputChannel::SharedPositionData2D m_cursorPositionData2D
 Shared cursor position.
 

Additional Inherited Members

- Protected Member Functions inherited from AzFramework::InputDevice
void BroadcastInputChannelEvent (const InputChannel &inputChannel) const
 
void BroadcastInputTextEvent (const AZStd::string &textUTF8) const
 
void BroadcastInputDeviceConnectedEvent () const
 Broadcast an event when the input device connects to the system.
 
void BroadcastInputDeviceDisconnectedEvent () const
 Broadcast an event when the input device disconnects from the system.
 
void ResetInputChannelStates ()
 Reset the state of all this input device's associated input channels.
 

Detailed Description

Defines a generic mouse input device, including the ids of all its associated input channels. Platform specific implementations are defined as private implementations so that creating an instance of this generic class will work correctly on any platform that supports mouse input, while providing access to the device name and associated channel ids on any platform through the 'null' implementation (primarily so that the editor can use them to setup input mappings).

Member Typedef Documentation

◆ ButtonChannelByIdMap

Alias for verbose container class

Constructor & Destructor Documentation

◆ InputDeviceMouse()

AzFramework::InputDeviceMouse::InputDeviceMouse ( const InputDeviceId inputDeviceId = Id,
ImplementationFactory  implementationFactory = &Implementation::Create 
)
explicit

Constructor

Parameters
[in]inputDeviceIdOptional override of the default input device id
[in]implementationFactoryOptional override of the default Implementation::Create

Member Function Documentation

◆ GetInputChannelsById()

const InputChannelByIdMap & AzFramework::InputDeviceMouse::GetInputChannelsById ( ) const
overridevirtual

◆ IsConnected()

bool AzFramework::InputDeviceMouse::IsConnected ( ) const
overridevirtual

◆ IsMouseDevice()

static bool AzFramework::InputDeviceMouse::IsMouseDevice ( const InputDeviceId inputDeviceId)
static

Check whether an input device id identifies a mouse (regardless of index)

Parameters
[in]inputDeviceIdThe input device id to check
Returns
True if the input device id identifies a mouse, false otherwise

◆ IsSupported()

bool AzFramework::InputDeviceMouse::IsSupported ( ) const
overridevirtual

◆ SetImplementation()

void AzFramework::InputDeviceMouse::SetImplementation ( AZStd::unique_ptr< Implementation impl)
inline

Set the implementation of this input device

Parameters
[in]implementationThe new implementation

◆ SetRawMovementSampleRate()

void AzFramework::InputDeviceMouse::SetRawMovementSampleRate ( AZ::u32  sampleRateHertz)

Set the sample rate for raw mouse movement events

Parameters
[in]sampleRateHertzThe raw movement sample rate in Hertz (cycles per second)

Member Data Documentation

◆ MovementSampleRateAccumulateAll

constexpr AZ::u32 AzFramework::InputDeviceMouse::MovementSampleRateAccumulateAll {0}
inlinestaticconstexpr

Sample rate for raw mouse movement that will cause all events received in the same frame to be accumulated and dispatched as a single event. Optimal for performance, but results in sluggish/unresponsive mouse movement, especially when running at low frame rates.

◆ MovementSampleRateDefault

constexpr AZ::u32 AzFramework::InputDeviceMouse::MovementSampleRateDefault {60}
inlinestaticconstexpr

Default sample rate for raw mouse movement events that aims to strike a balance between responsiveness and performance.

◆ MovementSampleRateQueueAll

constexpr AZ::u32 AzFramework::InputDeviceMouse::MovementSampleRateQueueAll {std::numeric_limits<AZ::u32>::max()}
inlinestaticconstexpr

Sample rate for raw mouse movement that will cause all events received in the same frame to be queued and dispatched as individual events. This results in maximum responsiveness but may potentially impact performance depending how many events happen over each frame.

◆ SystemCursorPosition

constexpr InputChannelId AzFramework::InputDeviceMouse::SystemCursorPosition {"mouse_system_cursor_position"}
inlinestaticconstexpr

Input channel id of the system cursor position normalized relative to the active window. The position obtained has had os ballistics applied, and is valid regardless of whether the system cursor is hidden or visible. When the system cursor has been constrained to the active window values will be in the [0.0, 1.0] range, but not when unconstrained. See also InputSystemCursorRequests::SetSystemCursorState and GetSystemCursorState.


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