UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FGenericPlatformInputDeviceMapper Class Reference

#include <GenericPlatformInputDeviceMapper.h>

+ Inheritance diagram for FGenericPlatformInputDeviceMapper:

Public Member Functions

APPLICATIONCORE_API FGenericPlatformInputDeviceMapper (const bool InbUsingControllerIdAsUserId, const bool InbShouldBroadcastLegacyDelegates)
 
virtual APPLICATIONCORE_API FPlatformUserId GetUserForUnpairedInputDevices () const override
 
virtual APPLICATIONCORE_API FPlatformUserId GetPrimaryPlatformUser () const override
 
virtual APPLICATIONCORE_API FInputDeviceId GetDefaultInputDevice () const override
 
virtual APPLICATIONCORE_API bool RemapControllerIdToPlatformUserAndDevice (int32 ControllerId, FPlatformUserId &InOutUserId, FInputDeviceId &OutInputDeviceId) override
 
virtual APPLICATIONCORE_API FPlatformUserId GetPlatformUserForUserIndex (int32 LocalUserIndex) override
 
virtual APPLICATIONCORE_API bool RemapUserAndDeviceToControllerId (FPlatformUserId UserId, int32 &OutControllerId, FInputDeviceId OptionalDeviceId=INPUTDEVICEID_NONE) override
 
virtual APPLICATIONCORE_API int32 GetUserIndexForPlatformUser (FPlatformUserId UserId) override
 
virtual APPLICATIONCORE_API bool IsUsingControllerIdAsUserId () const override
 
virtual APPLICATIONCORE_API bool ShouldBroadcastLegacyDelegates () const override
 
virtual APPLICATIONCORE_API FPlatformUserId AllocateNewUserId () override
 
virtual APPLICATIONCORE_API FInputDeviceId AllocateNewInputDeviceId () override
 
- Public Member Functions inherited from IPlatformInputDeviceMapper
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 APPLICATIONCORE_API bool IsUnpairedUserId (const FPlatformUserId PlatformId) const
 
virtual APPLICATIONCORE_API bool IsInputDeviceMappedToUnpairedUser (const FInputDeviceId InputDevice) const
 
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 APPLICATIONCORE_API const EInputDeviceMappingPolicy GetCurrentDeviceMappingPolicy () const
 

Protected Member Functions

virtual APPLICATIONCORE_API void OnUserLoginChangedEvent (bool bLoggedIn, int32 RawPlatformUserId, int32 UserIndex) override
 
- Protected Member Functions inherited from IPlatformInputDeviceMapper
virtual APPLICATIONCORE_API void BindCoreDelegates ()
 
virtual APPLICATIONCORE_API void UnbindCoreDelegates ()
 
virtual APPLICATIONCORE_API bool ShouldCreateUniqueUserForEachDevice () const
 

Protected Attributes

const bool bUsingControllerIdAsUserId = true
 
const bool bShouldBroadcastLegacyDelegates = true
 
bool bUnpairInputDevicesWhenLoggingOut = false
 
- Protected Attributes inherited from IPlatformInputDeviceMapper
TMap< FInputDeviceId, FPlatformInputDeviceStateMappedInputDevices
 
FPlatformUserId LastPlatformUserId = PLATFORMUSERID_NONE
 
FInputDeviceId LastInputDeviceId = INPUTDEVICEID_NONE
 
TArray< FPlatformUserIdAllocatedPlatformUserIds
 

Additional Inherited Members

- Static Public Member Functions inherited from IPlatformInputDeviceMapper
static APPLICATIONCORE_API IPlatformInputDeviceMapperGet ()
 
- Static Protected Attributes inherited from IPlatformInputDeviceMapper
static APPLICATIONCORE_API FOnUserInputDeviceConnectionChange OnInputDeviceConnectionChange
 
static APPLICATIONCORE_API FOnUserInputDevicePairingChange OnInputDevicePairingChange
 

Detailed Description

Generic implementation of the IPlatformInputDeviceMapper. This provides the base functionality that can be used on most platforms.

Constructor & Destructor Documentation

◆ FGenericPlatformInputDeviceMapper()

FGenericPlatformInputDeviceMapper::FGenericPlatformInputDeviceMapper ( const bool  InbUsingControllerIdAsUserId,
const bool  InbShouldBroadcastLegacyDelegates 
)

Member Function Documentation

◆ AllocateNewInputDeviceId()

FInputDeviceId FGenericPlatformInputDeviceMapper::AllocateNewInputDeviceId ( )
overridevirtual

Returns the next available input device id

Implements IPlatformInputDeviceMapper.

◆ AllocateNewUserId()

FPlatformUserId FGenericPlatformInputDeviceMapper::AllocateNewUserId ( )
overridevirtual

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

Implements IPlatformInputDeviceMapper.

◆ GetDefaultInputDevice()

FInputDeviceId FGenericPlatformInputDeviceMapper::GetDefaultInputDevice ( ) const
overridevirtual

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

Implements IPlatformInputDeviceMapper.

◆ GetPlatformUserForUserIndex()

FPlatformUserId FGenericPlatformInputDeviceMapper::GetPlatformUserForUserIndex ( int32  LocalUserIndex)
overridevirtual

◆ GetPrimaryPlatformUser()

FPlatformUserId FGenericPlatformInputDeviceMapper::GetPrimaryPlatformUser ( ) const
overridevirtual

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.

Implements IPlatformInputDeviceMapper.

◆ GetUserForUnpairedInputDevices()

FPlatformUserId FGenericPlatformInputDeviceMapper::GetUserForUnpairedInputDevices ( ) const
overridevirtual

This is unsupported by default and will return PLATFORMUSERID_NONE on the generic platform

Implements IPlatformInputDeviceMapper.

◆ GetUserIndexForPlatformUser()

int32 FGenericPlatformInputDeviceMapper::GetUserIndexForPlatformUser ( FPlatformUserId  UserId)
overridevirtual

◆ IsUsingControllerIdAsUserId()

bool FGenericPlatformInputDeviceMapper::IsUsingControllerIdAsUserId ( ) const
overridevirtual

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

Implements IPlatformInputDeviceMapper.

◆ OnUserLoginChangedEvent()

void FGenericPlatformInputDeviceMapper::OnUserLoginChangedEvent ( bool  bLoggedIn,
int32  RawPlatformUserId,
int32  UserIndex 
)
overrideprotectedvirtual

Callback for when FCoreDelegates::OnUserLoginChangedEvent is broadcasted. If the user has logged out, then remap any input devices that the user had to the "Unpaired" user on this platform (if bUnpairInputDevicesWhenLoggingOut is true)

Implements IPlatformInputDeviceMapper.

◆ RemapControllerIdToPlatformUserAndDevice()

bool FGenericPlatformInputDeviceMapper::RemapControllerIdToPlatformUserAndDevice ( int32  ControllerId,
FPlatformUserId InOutUserId,
FInputDeviceId OutInputDeviceId 
)
overridevirtual

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

Implements IPlatformInputDeviceMapper.

◆ RemapUserAndDeviceToControllerId()

bool FGenericPlatformInputDeviceMapper::RemapUserAndDeviceToControllerId ( FPlatformUserId  UserId,
int32 OutControllerId,
FInputDeviceId  OptionalDeviceId = INPUTDEVICEID_NONE 
)
overridevirtual

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

Implements IPlatformInputDeviceMapper.

◆ ShouldBroadcastLegacyDelegates()

bool FGenericPlatformInputDeviceMapper::ShouldBroadcastLegacyDelegates ( ) const
overridevirtual

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

Implements IPlatformInputDeviceMapper.

Member Data Documentation

◆ bShouldBroadcastLegacyDelegates

const bool FGenericPlatformInputDeviceMapper::bShouldBroadcastLegacyDelegates = true
protected

◆ bUnpairInputDevicesWhenLoggingOut

bool FGenericPlatformInputDeviceMapper::bUnpairInputDevicesWhenLoggingOut = false
protected

Additional functionality that specializations can customize

◆ bUsingControllerIdAsUserId

const bool FGenericPlatformInputDeviceMapper::bUsingControllerIdAsUserId = true
protected

Flags for backwards compatibility with the older "int32 ControllerId" implementation


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