UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IPlatformInputDeviceMapper Class Referenceabstract

#include <GenericPlatformInputDeviceMapper.h>

+ Inheritance diagram for IPlatformInputDeviceMapper:

Public Member Functions

APPLICATIONCORE_API IPlatformInputDeviceMapper ()
 
virtual APPLICATIONCORE_API ~IPlatformInputDeviceMapper ()
 
virtual APPLICATIONCORE_API int32 GetAllInputDevicesForUser (const FPlatformUserId UserId, TArray< FInputDeviceId > &OutInputDevices) const
 
virtual APPLICATIONCORE_API int32 GetAllInputDevices (TArray< FInputDeviceId > &OutInputDevices) const
 
virtual APPLICATIONCORE_API int32 GetAllConnectedInputDevices (TArray< FInputDeviceId > &OutInputDevices) const
 
virtual APPLICATIONCORE_API int32 GetAllConnectedInputDevicesForUser (const FPlatformUserId UserId, TArray< FInputDeviceId > &OutInputDevices) const
 
virtual APPLICATIONCORE_API int32 GetAllActiveUsers (TArray< FPlatformUserId > &OutUsers) const
 
virtual APPLICATIONCORE_API FPlatformUserId GetFirstPlatformUserWithNoInputDevice () const
 
virtual FPlatformUserId GetUserForUnpairedInputDevices () const =0
 
virtual APPLICATIONCORE_API bool IsUnpairedUserId (const FPlatformUserId PlatformId) const
 
virtual APPLICATIONCORE_API bool IsInputDeviceMappedToUnpairedUser (const FInputDeviceId InputDevice) const
 
virtual FPlatformUserId GetPrimaryPlatformUser () const =0
 
virtual FInputDeviceId GetDefaultInputDevice () const =0
 
virtual APPLICATIONCORE_API FPlatformUserId GetPlatformUserForNewlyConnectedDevice (const int32 InUserId=-1)
 
virtual APPLICATIONCORE_API FPlatformUserId GetUserForInputDevice (FInputDeviceId DeviceId) const
 
virtual APPLICATIONCORE_API FInputDeviceId GetPrimaryInputDeviceForUser (FPlatformUserId UserId) const
 
virtual APPLICATIONCORE_API bool Internal_SetInputDeviceConnectionState (FInputDeviceId DeviceId, EInputDeviceConnectionState NewState)
 
virtual APPLICATIONCORE_API EInputDeviceConnectionState GetInputDeviceConnectionState (const FInputDeviceId DeviceId) const
 
virtual APPLICATIONCORE_API bool Internal_MapInputDeviceToUser (FInputDeviceId DeviceId, FPlatformUserId UserId, EInputDeviceConnectionState ConnectionState)
 
virtual APPLICATIONCORE_API bool Internal_ChangeInputDeviceUserMapping (FInputDeviceId DeviceId, FPlatformUserId NewUserId, FPlatformUserId OldUserId)
 
virtual APPLICATIONCORE_API int32 GetMaxPlatformUserCount () const
 
 DECLARE_MULTICAST_DELEGATE_ThreeParams (FOnUserInputDeviceConnectionChange, EInputDeviceConnectionState, FPlatformUserId, FInputDeviceId)
 
 DECLARE_MULTICAST_DELEGATE_ThreeParams (FOnUserInputDevicePairingChange, FInputDeviceId, FPlatformUserId, FPlatformUserId)
 
FOnUserInputDeviceConnectionChangeGetOnInputDeviceConnectionChange () const
 
FOnUserInputDevicePairingChangeGetOnInputDevicePairingChange () const
 
virtual bool RemapUserAndDeviceToControllerId (FPlatformUserId UserId, int32 &OutControllerId, FInputDeviceId OptionalDeviceId=INPUTDEVICEID_NONE)=0
 
virtual int32 GetUserIndexForPlatformUser (FPlatformUserId UserId)=0
 
virtual bool RemapControllerIdToPlatformUserAndDevice (int32 ControllerId, FPlatformUserId &InOutUserId, FInputDeviceId &OutInputDeviceId)=0
 
virtual FPlatformUserId GetPlatformUserForUserIndex (int32 LocalUserIndex)=0
 
virtual FPlatformUserId AllocateNewUserId ()=0
 
virtual FInputDeviceId AllocateNewInputDeviceId ()=0
 
virtual APPLICATIONCORE_API const EInputDeviceMappingPolicy GetCurrentDeviceMappingPolicy () const
 

Static Public Member Functions

static APPLICATIONCORE_API IPlatformInputDeviceMapperGet ()
 

Protected Member Functions

virtual APPLICATIONCORE_API void BindCoreDelegates ()
 
virtual APPLICATIONCORE_API void UnbindCoreDelegates ()
 
virtual void OnUserLoginChangedEvent (bool bLoggedIn, int32 UserId, int32 UserIndex)=0
 
virtual bool IsUsingControllerIdAsUserId () const =0
 
virtual APPLICATIONCORE_API bool ShouldCreateUniqueUserForEachDevice () const
 
virtual bool ShouldBroadcastLegacyDelegates () const =0
 

Protected Attributes

TMap< FInputDeviceId, FPlatformInputDeviceStateMappedInputDevices
 
FPlatformUserId LastPlatformUserId = PLATFORMUSERID_NONE
 
FInputDeviceId LastInputDeviceId = INPUTDEVICEID_NONE
 
TArray< FPlatformUserIdAllocatedPlatformUserIds
 

Static Protected Attributes

static APPLICATIONCORE_API FOnUserInputDeviceConnectionChange OnInputDeviceConnectionChange
 
static APPLICATIONCORE_API FOnUserInputDevicePairingChange OnInputDevicePairingChange
 

Detailed Description

Base class to private a mapping of Platform Users (FPlatformUserID) to their associated available input devices (FInputDeviceID).

This will handle the allocation of the globally unique identifier of the FInputDeviceID, and allow overrides of how each platform maps input devices to their users. Some platforms may desire to have each new input device assigned to a different user, while others may want multiple input devices associated with a single user.

Note
Keep any function comments up to date with those in PlatformInputDeviceMapperLibrary.h!

Constructor & Destructor Documentation

◆ IPlatformInputDeviceMapper()

IPlatformInputDeviceMapper::IPlatformInputDeviceMapper ( )

◆ ~IPlatformInputDeviceMapper()

IPlatformInputDeviceMapper::~IPlatformInputDeviceMapper ( )
virtual

Virtual destructor

Member Function Documentation

◆ AllocateNewInputDeviceId()

virtual FInputDeviceId IPlatformInputDeviceMapper::AllocateNewInputDeviceId ( )
pure virtual

Returns the next available input device id. This ID should be globally unique!

Implemented in FGenericPlatformInputDeviceMapper.

◆ AllocateNewUserId()

virtual FPlatformUserId IPlatformInputDeviceMapper::AllocateNewUserId ( )
pure virtual

Allocates a new user id when a user becomes active, will return none if no more can be created

Implemented in FGenericPlatformInputDeviceMapper.

◆ BindCoreDelegates()

void IPlatformInputDeviceMapper::BindCoreDelegates ( )
protectedvirtual

Binds to any core delegates that the platform may broadcast. By default it is only the OnUserLoginChangedEvent delegate. Called during the constructor of this device mapper.

◆ DECLARE_MULTICAST_DELEGATE_ThreeParams() [1/2]

IPlatformInputDeviceMapper::DECLARE_MULTICAST_DELEGATE_ThreeParams ( FOnUserInputDeviceConnectionChange  ,
EInputDeviceConnectionState  ,
FPlatformUserId  ,
FInputDeviceId   
)

Callback for handling an Input Device's connection state change.

Parameters
NewConnectionStateThe new connection state of this device
FPlatformUserIdThe User ID whose input device has changed
FInputDeviceIdThe Input Device ID that has changed connection

◆ DECLARE_MULTICAST_DELEGATE_ThreeParams() [2/2]

IPlatformInputDeviceMapper::DECLARE_MULTICAST_DELEGATE_ThreeParams ( FOnUserInputDevicePairingChange  ,
FInputDeviceId  ,
FPlatformUserId  ,
FPlatformUserId   
)

Callback for handling an Input Device pairing change.

Parameters
FInputDeviceIdInput device ID
FPlatformUserIdThe NewUserPlatformId
FPlatformUserIdThe OldUserPlatformId

◆ Get()

IPlatformInputDeviceMapper & IPlatformInputDeviceMapper::Get ( )
static

Get the platform input device mapper

◆ GetAllActiveUsers()

int32 IPlatformInputDeviceMapper::GetAllActiveUsers ( TArray< FPlatformUserId > &  OutUsers) const
virtual

Get all currently active platform ids, anyone who has a mapped input device

Parameters
OutUsersArray that will be populated with the platform users.
Returns
The number of active platform users

◆ GetAllConnectedInputDevices()

int32 IPlatformInputDeviceMapper::GetAllConnectedInputDevices ( TArray< FInputDeviceId > &  OutInputDevices) const
virtual

Gather all currently connected input devices

Parameters
OutInputDevicesArray of input devices to populate
Returns
The number of connected input devices

◆ GetAllConnectedInputDevicesForUser()

int32 IPlatformInputDeviceMapper::GetAllConnectedInputDevicesForUser ( const FPlatformUserId  UserId,
TArray< FInputDeviceId > &  OutInputDevices 
) const
virtual

Gather all currently connected input devices for specific user

Parameters
UserIdThe Platform User to gather the input devices of.
OutInputDevicesArray of input device ID's that will be populated with the mapped devices.
Returns
The number of mapped devices, INDEX_NONE if the user was not found.

◆ GetAllInputDevices()

int32 IPlatformInputDeviceMapper::GetAllInputDevices ( TArray< FInputDeviceId > &  OutInputDevices) const
virtual

Get all mapped input devices on this platform regardless of their connection state.

Parameters
OutInputDevicesArray of input devices to populate
Returns
The number of connected input devices

◆ GetAllInputDevicesForUser()

int32 IPlatformInputDeviceMapper::GetAllInputDevicesForUser ( const FPlatformUserId  UserId,
TArray< FInputDeviceId > &  OutInputDevices 
) const
virtual

Populates the OutInputDevices array with any InputDeviceID's that are mapped to the given platform user

Parameters
UserIdThe Platform User to gather the input devices of.
OutInputDevicesArray of input device ID's that will be populated with the mapped devices.
Returns
The number of mapped devices, INDEX_NONE if the user was not found.

◆ GetCurrentDeviceMappingPolicy()

const EInputDeviceMappingPolicy IPlatformInputDeviceMapper::GetCurrentDeviceMappingPolicy ( ) const
virtual

◆ GetDefaultInputDevice()

virtual FInputDeviceId IPlatformInputDeviceMapper::GetDefaultInputDevice ( ) const
pure virtual

Returns the default device id used for things like keyboard/mouse input

Implemented in FGenericPlatformInputDeviceMapper.

◆ GetFirstPlatformUserWithNoInputDevice()

FPlatformUserId IPlatformInputDeviceMapper::GetFirstPlatformUserWithNoInputDevice ( ) const
virtual

Finds the first FPlatformUserId which was already allocated with no input devices.

Returns PLATFORMUSERID_NONE if every current platform user has a valid input device mapped to it.

Will not return the Unpaired platform user.

◆ GetInputDeviceConnectionState()

EInputDeviceConnectionState IPlatformInputDeviceMapper::GetInputDeviceConnectionState ( const FInputDeviceId  DeviceId) const
virtual

Gets the connection state of the given input device.

Parameters
DeviceIdThe device to get the connection state of
Returns
The connection state of the given device. EInputDeviceConnectionState::Unknown if the device is not mapped

◆ GetMaxPlatformUserCount()

int32 IPlatformInputDeviceMapper::GetMaxPlatformUserCount ( ) const
virtual

Returns the max allowed number of platform users this platform can have.

By default, this will return the value specified in the input settings ini file

◆ GetOnInputDeviceConnectionChange()

FOnUserInputDeviceConnectionChange & IPlatformInputDeviceMapper::GetOnInputDeviceConnectionChange ( ) const
inline

◆ GetOnInputDevicePairingChange()

FOnUserInputDevicePairingChange & IPlatformInputDeviceMapper::GetOnInputDevicePairingChange ( ) const
inline

◆ GetPlatformUserForNewlyConnectedDevice()

FPlatformUserId IPlatformInputDeviceMapper::GetPlatformUserForNewlyConnectedDevice ( const int32  InUserId = -1)
virtual

Returns the platform user id that a newly connected device should be mapped to.

If "ShouldCreateUniqueUserForEachDevice" is true, then a new platform user id will be allocated for this device. Otherwise, this will return the primary platform user.

Parameters
InUserIdAn optional user index which can be passed in. If this is not -1, and IsUsingControllerIdAsUserId is true, then the platform user id for that user will be returned.

◆ GetPlatformUserForUserIndex()

virtual FPlatformUserId IPlatformInputDeviceMapper::GetPlatformUserForUserIndex ( int32  LocalUserIndex)
pure virtual

◆ GetPrimaryInputDeviceForUser()

FInputDeviceId IPlatformInputDeviceMapper::GetPrimaryInputDeviceForUser ( FPlatformUserId  UserId) const
virtual

Returns the primary input device used by a specific player, or INPUTDEVICEID_NONE if invalid

◆ GetPrimaryPlatformUser()

virtual FPlatformUserId IPlatformInputDeviceMapper::GetPrimaryPlatformUser ( ) const
pure virtual

Returns the 'Primary' Platform user for this platform. This typically has an internal ID of '0' and is used as the default platform user to map devices such as the keyboard and mouse that don't get assigned unique ID's from their owning platform code.

Implemented in FGenericPlatformInputDeviceMapper.

◆ GetUserForInputDevice()

FPlatformUserId IPlatformInputDeviceMapper::GetUserForInputDevice ( FInputDeviceId  DeviceId) const
virtual

Returns the platform user attached to this input device, or PLATFORMUSERID_NONE if invalid

◆ GetUserForUnpairedInputDevices()

virtual FPlatformUserId IPlatformInputDeviceMapper::GetUserForUnpairedInputDevices ( ) const
pure virtual

Returns the platform user id that is being used for unmapped input devices. Will be PLATFORMUSERID_NONE if platform does not support this (this is the default behavior)

Implemented in FGenericPlatformInputDeviceMapper.

◆ GetUserIndexForPlatformUser()

virtual int32 IPlatformInputDeviceMapper::GetUserIndexForPlatformUser ( FPlatformUserId  UserId)
pure virtual

◆ Internal_ChangeInputDeviceUserMapping()

bool IPlatformInputDeviceMapper::Internal_ChangeInputDeviceUserMapping ( FInputDeviceId  DeviceId,
FPlatformUserId  NewUserId,
FPlatformUserId  OldUserId 
)
virtual

Change the user mapping of the given input device from an old user to a new one. This will broadcast the OnInputDevicePairingChange delegate. Use this when you know that an input device is already mapped, but it has changed platform users This should be called by the platform's implementation.

Parameters
DeviceIdThe input device to change the owner on
NewUserIdThe new platform user that this input device should be mapped to
OldUserIdThe old platform user that this input device is currently mapped to
Returns
True if the device was successfully remapped

◆ Internal_MapInputDeviceToUser()

bool IPlatformInputDeviceMapper::Internal_MapInputDeviceToUser ( FInputDeviceId  DeviceId,
FPlatformUserId  UserId,
EInputDeviceConnectionState  ConnectionState 
)
virtual

Maps the given Input Device to the given userID. This will broadcast the OnInputDeviceConnectionChange delegate. This should be called by the platform's implementation.

Parameters
DeviceIdThe device id to map
UserIdThe Platform User that owns the given device
ConnectionStateThe connection state of the device
Returns
True if the input device was successfully mapped

◆ Internal_SetInputDeviceConnectionState()

bool IPlatformInputDeviceMapper::Internal_SetInputDeviceConnectionState ( FInputDeviceId  DeviceId,
EInputDeviceConnectionState  NewState 
)
virtual

Set the connection state of a given Input Device to something new. This will broadcast the OnInputDeviceConnectionChange delegate. This should be called by the platform's implementation.

Parameters
DeviceIdThe device id that has had a connection change
NewStateThe new connection state of the given device
Returns
True if the connection state was set successfully

◆ IsInputDeviceMappedToUnpairedUser()

bool IPlatformInputDeviceMapper::IsInputDeviceMappedToUnpairedUser ( const FInputDeviceId  InputDevice) const
virtual

Returns true if the given input device is mapped to the unpaired platform user id.

◆ IsUnpairedUserId()

bool IPlatformInputDeviceMapper::IsUnpairedUserId ( const FPlatformUserId  PlatformId) const
virtual

Returns true if the given Platform User Id is the user for unpaired input devices on this platform.

◆ IsUsingControllerIdAsUserId()

virtual bool IPlatformInputDeviceMapper::IsUsingControllerIdAsUserId ( ) const
protectedpure virtual

If true, this device mapper is operating in a backward compatible mode where there is a 1:1 mapping between controller id and user id

Implemented in FGenericPlatformInputDeviceMapper.

◆ OnUserLoginChangedEvent()

virtual void IPlatformInputDeviceMapper::OnUserLoginChangedEvent ( bool  bLoggedIn,
int32  UserId,
int32  UserIndex 
)
protectedpure virtual

Callback for when FCoreDelegates::OnUserLoginChangedEvent is broadcasted

Implemented in FGenericPlatformInputDeviceMapper.

◆ RemapControllerIdToPlatformUserAndDevice()

virtual bool IPlatformInputDeviceMapper::RemapControllerIdToPlatformUserAndDevice ( int32  ControllerId,
FPlatformUserId InOutUserId,
FInputDeviceId OutInputDeviceId 
)
pure virtual

Remap the legacy "int32 ControllerId" to the updated FPlatformUserId and FInputDeviceId. Use this function to add compatibility to platforms that may not have implemented this device mapper yet.

This is useful for functions such as FGenericApplicationMessageHandler::OnControllerAnalog that used to use the "int32 ControllerId" as a parameter so that you can call the new FGenericApplicationMessageHandler that take in a PlatformUserId and an InputDeviceId.

Parameters
ControllerIdThe old plain "int32" that represented gamepad id or user index depending on the context.
InOutUserIdIf the old function provides a PlatformId then pass it here, otherwise pass PLATFORMUSERID_NONE.
OutInputDeviceIdThe best guess for an InputDeviceId based on the legacy int32 ControllerId. This may be INPUTDEVICEID_NONE.
Returns
True if this maps to a real user

Implemented in FGenericPlatformInputDeviceMapper.

◆ RemapUserAndDeviceToControllerId()

virtual bool IPlatformInputDeviceMapper::RemapUserAndDeviceToControllerId ( FPlatformUserId  UserId,
int32 OutControllerId,
FInputDeviceId  OptionalDeviceId = INPUTDEVICEID_NONE 
)
pure virtual

Remap a FPlatformUserId to a ControllerId that is needed by legacy code. Use this function to add compatibility to platforms that may not have implemented this device mapper yet.

Parameters
UserIdThe platform user that should be converted
OutControllerIdSet to the old plain "int32" that represented gamepad id or user index depending on the context.
OptionalDeviceIdSet this to a specific device id if known
Returns
True if this maps to a real user

Implemented in FGenericPlatformInputDeviceMapper.

◆ ShouldBroadcastLegacyDelegates()

virtual bool IPlatformInputDeviceMapper::ShouldBroadcastLegacyDelegates ( ) const
protectedpure virtual

If true, than this device mapper will broadcast the older CoreDelegates as well as the new delegates. Set this to true if your platform needs calls from OnControllerConnectionChange or OnControllerPairingChange

Implemented in FGenericPlatformInputDeviceMapper.

◆ ShouldCreateUniqueUserForEachDevice()

bool IPlatformInputDeviceMapper::ShouldCreateUniqueUserForEachDevice ( ) const
protectedvirtual

If true, then when we remap the platform's raw int32 ControllerId to its FInputDeviceId and owning FPlatformUserId we should create a new platform user id if this controller id is not already mapped.

◆ UnbindCoreDelegates()

void IPlatformInputDeviceMapper::UnbindCoreDelegates ( )
protectedvirtual

Unbind from any delegates that have been hooked into. Called during the destructor of this device mapper.

Member Data Documentation

◆ AllocatedPlatformUserIds

TArray<FPlatformUserId> IPlatformInputDeviceMapper::AllocatedPlatformUserIds
protected

Keeps track of any allocated platform user ID's by this device mapper.

◆ LastInputDeviceId

FInputDeviceId IPlatformInputDeviceMapper::LastInputDeviceId = INPUTDEVICEID_NONE
protected

Highest used input device id. Incremented in AllocateNewInputDeviceId and Internal_MapInputDeviceToUser by default.

◆ LastPlatformUserId

FPlatformUserId IPlatformInputDeviceMapper::LastPlatformUserId = PLATFORMUSERID_NONE
protected

Highest used platform user id. Incremented in AllocateNewUserId and Internal_MapInputDeviceToUser by default.

◆ MappedInputDevices

TMap<FInputDeviceId, FPlatformInputDeviceState> IPlatformInputDeviceMapper::MappedInputDevices
protected

A map of all input devices to their current state

◆ OnInputDeviceConnectionChange

IPlatformInputDeviceMapper::FOnUserInputDeviceConnectionChange IPlatformInputDeviceMapper::OnInputDeviceConnectionChange
staticprotected

Callback when input devices are disconnected/reconnected

◆ OnInputDevicePairingChange

IPlatformInputDeviceMapper::FOnUserInputDevicePairingChange IPlatformInputDeviceMapper::OnInputDevicePairingChange
staticprotected

Callback when an input device's owning platform user pairing changes


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