UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GenericPlatformInputDeviceMapper.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
6#include "Containers/Map.h"
7#include "CoreTypes.h"
9#include "Logging/LogMacros.h"
10
12
14
28{
29public:
30
33
35
38
47
55
63
72
80
89
95
98
101
109
112
123
126
129
140
148
159
172
179
181 // Delegates for listening to input device changes
182
191
199 DECLARE_MULTICAST_DELEGATE_ThreeParams(FOnUserInputDevicePairingChange, FInputDeviceId /* InputDeviceId */, FPlatformUserId /* NewUserPlatformId */, FPlatformUserId /* OldUserPlatformId */);
200
203
204#if WITH_EDITOR
210#endif // #if WITH_EDITOR
211
213 // Functions to provide compatibility between the old "int32 ControllerId"
214 // and the new FPlatformUserId and FInputDeviceId structs.
215
226
227 /*
228 * Remap a FPlatformUserId to the legacy platform LocalUserIndex (often the same as ControllerId).
229 * This is useful in cases where the input device id is not needed.
230 *
231 * @param UserId The platform user that should be converted
232 * @returns A valid platform user index, or INDEX_NONE
233 */
235
250
251 /*
252 * Remap the legacy platform LocalUserIndex (often the same as ControllerId) to a FPlatformUserId.
253 * This is useful in cases where the input device id is not needed.
254 *
255 * @param LocalUserIndex A platform user index where 0 should always be a valid user
256 * @returns A platform-allocated user id, or PLATFORMUSERID_NONE
257 */
259
262
265
267protected:
268
274
280
282 virtual void OnUserLoginChangedEvent(bool bLoggedIn, int32 UserId, int32 UserIndex) = 0;
283
288 virtual bool IsUsingControllerIdAsUserId() const = 0;
289
296
303 virtual bool ShouldBroadcastLegacyDelegates() const = 0;
304
307
310
313
316
319
322};
323
329{
330public:
331
333
338
343 APPLICATIONCORE_API virtual bool IsUsingControllerIdAsUserId() const override;
344 APPLICATIONCORE_API virtual bool ShouldBroadcastLegacyDelegates() const override;
345
348
351
352protected:
353
359
361 const bool bUsingControllerIdAsUserId = true;
363
366};
EInputDeviceConnectionState
Definition CoreMiscDefines.h:594
constexpr FPlatformUserId PLATFORMUSERID_NONE
Definition CoreMiscDefines.h:516
constexpr FInputDeviceId INPUTDEVICEID_NONE
Definition CoreMiscDefines.h:590
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EInputDeviceMappingPolicy
Definition InputDeviceMappingPolicy.h:16
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
Definition GenericPlatformInputDeviceMapper.h:329
virtual APPLICATIONCORE_API bool ShouldBroadcastLegacyDelegates() const override
Definition GenericPlatformInputDeviceMapper.cpp:703
virtual APPLICATIONCORE_API FPlatformUserId GetPrimaryPlatformUser() const override
Definition GenericPlatformInputDeviceMapper.cpp:589
virtual APPLICATIONCORE_API FInputDeviceId AllocateNewInputDeviceId() override
Definition GenericPlatformInputDeviceMapper.cpp:754
bool bUnpairInputDevicesWhenLoggingOut
Definition GenericPlatformInputDeviceMapper.h:365
virtual APPLICATIONCORE_API bool IsUsingControllerIdAsUserId() const override
Definition GenericPlatformInputDeviceMapper.cpp:698
const bool bShouldBroadcastLegacyDelegates
Definition GenericPlatformInputDeviceMapper.h:362
virtual APPLICATIONCORE_API bool RemapControllerIdToPlatformUserAndDevice(int32 ControllerId, FPlatformUserId &InOutUserId, FInputDeviceId &OutInputDeviceId) override
Definition GenericPlatformInputDeviceMapper.cpp:602
virtual APPLICATIONCORE_API FPlatformUserId AllocateNewUserId() override
Definition GenericPlatformInputDeviceMapper.cpp:736
const bool bUsingControllerIdAsUserId
Definition GenericPlatformInputDeviceMapper.h:361
virtual APPLICATIONCORE_API void OnUserLoginChangedEvent(bool bLoggedIn, int32 RawPlatformUserId, int32 UserIndex) override
Definition GenericPlatformInputDeviceMapper.cpp:708
virtual APPLICATIONCORE_API FPlatformUserId GetUserForUnpairedInputDevices() const override
Definition GenericPlatformInputDeviceMapper.cpp:581
virtual APPLICATIONCORE_API int32 GetUserIndexForPlatformUser(FPlatformUserId UserId) override
Definition GenericPlatformInputDeviceMapper.cpp:687
virtual APPLICATIONCORE_API FPlatformUserId GetPlatformUserForUserIndex(int32 LocalUserIndex) override
Definition GenericPlatformInputDeviceMapper.cpp:664
virtual APPLICATIONCORE_API FInputDeviceId GetDefaultInputDevice() const override
Definition GenericPlatformInputDeviceMapper.cpp:596
virtual APPLICATIONCORE_API bool RemapUserAndDeviceToControllerId(FPlatformUserId UserId, int32 &OutControllerId, FInputDeviceId OptionalDeviceId=INPUTDEVICEID_NONE) override
Definition GenericPlatformInputDeviceMapper.cpp:676
Definition GenericPlatformInputDeviceMapper.h:28
virtual bool RemapUserAndDeviceToControllerId(FPlatformUserId UserId, int32 &OutControllerId, FInputDeviceId OptionalDeviceId=INPUTDEVICEID_NONE)=0
virtual APPLICATIONCORE_API void BindCoreDelegates()
Definition GenericPlatformInputDeviceMapper.cpp:535
virtual APPLICATIONCORE_API bool ShouldCreateUniqueUserForEachDevice() const
Definition GenericPlatformInputDeviceMapper.cpp:545
FOnUserInputDeviceConnectionChange & GetOnInputDeviceConnectionChange() const
Definition GenericPlatformInputDeviceMapper.h:201
virtual APPLICATIONCORE_API bool Internal_MapInputDeviceToUser(FInputDeviceId DeviceId, FPlatformUserId UserId, EInputDeviceConnectionState ConnectionState)
Definition GenericPlatformInputDeviceMapper.cpp:336
virtual bool ShouldBroadcastLegacyDelegates() const =0
virtual APPLICATIONCORE_API int32 GetMaxPlatformUserCount() const
Definition GenericPlatformInputDeviceMapper.cpp:529
TMap< FInputDeviceId, FPlatformInputDeviceState > MappedInputDevices
Definition GenericPlatformInputDeviceMapper.h:312
virtual FPlatformUserId GetPrimaryPlatformUser() const =0
virtual FInputDeviceId GetDefaultInputDevice() const =0
static APPLICATIONCORE_API FOnUserInputDevicePairingChange OnInputDevicePairingChange
Definition GenericPlatformInputDeviceMapper.h:309
virtual APPLICATIONCORE_API EInputDeviceConnectionState GetInputDeviceConnectionState(const FInputDeviceId DeviceId) const
Definition GenericPlatformInputDeviceMapper.cpp:320
virtual APPLICATIONCORE_API FPlatformUserId GetFirstPlatformUserWithNoInputDevice() const
Definition GenericPlatformInputDeviceMapper.cpp:185
virtual APPLICATIONCORE_API bool Internal_ChangeInputDeviceUserMapping(FInputDeviceId DeviceId, FPlatformUserId NewUserId, FPlatformUserId OldUserId)
Definition GenericPlatformInputDeviceMapper.cpp:368
virtual APPLICATIONCORE_API int32 GetAllInputDevicesForUser(const FPlatformUserId UserId, TArray< FInputDeviceId > &OutInputDevices) const
Definition GenericPlatformInputDeviceMapper.cpp:119
APPLICATIONCORE_API IPlatformInputDeviceMapper()
Definition GenericPlatformInputDeviceMapper.cpp:109
DECLARE_MULTICAST_DELEGATE_ThreeParams(FOnUserInputDevicePairingChange, FInputDeviceId, FPlatformUserId, FPlatformUserId)
virtual APPLICATIONCORE_API int32 GetAllInputDevices(TArray< FInputDeviceId > &OutInputDevices) const
Definition GenericPlatformInputDeviceMapper.cpp:134
virtual FPlatformUserId AllocateNewUserId()=0
virtual void OnUserLoginChangedEvent(bool bLoggedIn, int32 UserId, int32 UserIndex)=0
virtual APPLICATIONCORE_API bool Internal_SetInputDeviceConnectionState(FInputDeviceId DeviceId, EInputDeviceConnectionState NewState)
Definition GenericPlatformInputDeviceMapper.cpp:291
static APPLICATIONCORE_API FOnUserInputDeviceConnectionChange OnInputDeviceConnectionChange
Definition GenericPlatformInputDeviceMapper.h:306
FOnUserInputDevicePairingChange & GetOnInputDevicePairingChange() const
Definition GenericPlatformInputDeviceMapper.h:202
virtual APPLICATIONCORE_API FPlatformUserId GetUserForInputDevice(FInputDeviceId DeviceId) const
Definition GenericPlatformInputDeviceMapper.cpp:263
virtual APPLICATIONCORE_API FPlatformUserId GetPlatformUserForNewlyConnectedDevice(const int32 InUserId=-1)
Definition GenericPlatformInputDeviceMapper.cpp:223
virtual APPLICATIONCORE_API ~IPlatformInputDeviceMapper()
Definition GenericPlatformInputDeviceMapper.cpp:114
virtual APPLICATIONCORE_API const EInputDeviceMappingPolicy GetCurrentDeviceMappingPolicy() const
Definition GenericPlatformInputDeviceMapper.cpp:554
virtual APPLICATIONCORE_API FInputDeviceId GetPrimaryInputDeviceForUser(FPlatformUserId UserId) const
Definition GenericPlatformInputDeviceMapper.cpp:272
FPlatformUserId LastPlatformUserId
Definition GenericPlatformInputDeviceMapper.h:315
static APPLICATIONCORE_API IPlatformInputDeviceMapper & Get()
Definition GenericPlatformInputDeviceMapper.cpp:97
virtual bool RemapControllerIdToPlatformUserAndDevice(int32 ControllerId, FPlatformUserId &InOutUserId, FInputDeviceId &OutInputDeviceId)=0
virtual APPLICATIONCORE_API bool IsUnpairedUserId(const FPlatformUserId PlatformId) const
Definition GenericPlatformInputDeviceMapper.cpp:209
virtual FPlatformUserId GetUserForUnpairedInputDevices() const =0
TArray< FPlatformUserId > AllocatedPlatformUserIds
Definition GenericPlatformInputDeviceMapper.h:321
virtual APPLICATIONCORE_API int32 GetAllConnectedInputDevices(TArray< FInputDeviceId > &OutInputDevices) const
Definition GenericPlatformInputDeviceMapper.cpp:139
virtual APPLICATIONCORE_API void UnbindCoreDelegates()
Definition GenericPlatformInputDeviceMapper.cpp:540
FInputDeviceId LastInputDeviceId
Definition GenericPlatformInputDeviceMapper.h:318
virtual bool IsUsingControllerIdAsUserId() const =0
virtual APPLICATIONCORE_API bool IsInputDeviceMappedToUnpairedUser(const FInputDeviceId InputDevice) const
Definition GenericPlatformInputDeviceMapper.cpp:214
virtual FPlatformUserId GetPlatformUserForUserIndex(int32 LocalUserIndex)=0
DECLARE_MULTICAST_DELEGATE_ThreeParams(FOnUserInputDeviceConnectionChange, EInputDeviceConnectionState, FPlatformUserId, FInputDeviceId)
virtual APPLICATIONCORE_API int32 GetAllActiveUsers(TArray< FPlatformUserId > &OutUsers) const
Definition GenericPlatformInputDeviceMapper.cpp:169
virtual FInputDeviceId AllocateNewInputDeviceId()=0
virtual APPLICATIONCORE_API int32 GetAllConnectedInputDevicesForUser(const FPlatformUserId UserId, TArray< FInputDeviceId > &OutInputDevices) const
Definition GenericPlatformInputDeviceMapper.cpp:154
virtual int32 GetUserIndexForPlatformUser(FPlatformUserId UserId)=0
Definition InputDevice.Build.cs:6
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition CoreMiscDefines.h:524
Definition CoreMiscDefines.h:470