UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GenericInputDeviceMap.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Map.h"
7#include "Misc/CoreMiscDefines.h" // For FInputDeviceId/FPlatformUserId
8
18template <class TDeviceKeyType>
20{
21public:
22
23 TInputDeviceMap() = default;
24 ~TInputDeviceMap() = default;
25
33 {
35
36 // If we already know about this device, then we can just use that info
38 {
40 }
41 // Otherwise, we have not seen this input device before (its a new connection)
42 // So we need a new FInputDeviceId and a FPlatformUserId to map it to.
43 else
44 {
46
47 // Keep track of both the FInputDeviceId -> DeviceKey
48 // and DeviceKey -> FInputDeviceID for quick lookup
51 }
52
53 return OutDeviceId;
54 }
55
69
76 {
78
79 // If we already know about this device, then we can just use that info
81 {
83 }
84
85 return OutDeviceId;
86 }
87
95
100 {
101 return MappedIdToKey.FindChecked(DeviceId);
102 }
103
107 [[nodiscard]] const TDeviceKeyType* FindDeviceKey(const FInputDeviceId DeviceId) const
108 {
109 return MappedIdToKey.Find(DeviceId);
110 }
111
112protected:
113
118
124};
constexpr FInputDeviceId INPUTDEVICEID_NONE
Definition CoreMiscDefines.h:590
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
virtual FInputDeviceId GetDefaultInputDevice() const =0
static APPLICATIONCORE_API IPlatformInputDeviceMapper & Get()
Definition GenericPlatformInputDeviceMapper.cpp:97
virtual FInputDeviceId AllocateNewInputDeviceId()=0
Definition GenericInputDeviceMap.h:20
TMap< TDeviceKeyType, FInputDeviceId > MappedDeviceIds
Definition GenericInputDeviceMap.h:117
const TDeviceKeyType & GetDeviceKeyChecked(const FInputDeviceId DeviceId) const
Definition GenericInputDeviceMap.h:99
~TInputDeviceMap()=default
FInputDeviceId MapDefaultInputDevice(const TDeviceKeyType &DeviceKey)
Definition GenericInputDeviceMap.h:60
FInputDeviceId FindDeviceId(const TDeviceKeyType &DeviceKey) const
Definition GenericInputDeviceMap.h:75
FInputDeviceId GetOrCreateDeviceId(const TDeviceKeyType &DeviceKey)
Definition GenericInputDeviceMap.h:32
TMap< FInputDeviceId, TDeviceKeyType > MappedIdToKey
Definition GenericInputDeviceMap.h:123
TInputDeviceMap()=default
FInputDeviceId FindDeviceIdChecked(const TDeviceKeyType &DeviceKey) const
Definition GenericInputDeviceMap.h:91
const TDeviceKeyType * FindDeviceKey(const FInputDeviceId DeviceId) const
Definition GenericInputDeviceMap.h:107
Definition UnrealString.h.inl:34
Definition CoreMiscDefines.h:524