LEAP Documentation 40220
Documentation for the LEAP project
InputRemappingNodes.h
Go to the documentation of this file.
1// Copyright Blue Isle Studios Inc 2018. All Rights Reserved.
2
3#pragma once
4#include "Kismet/BlueprintFunctionLibrary.h"
5#include "Engine.h"
6#include "InputRemappingNodes.generated.h"
7
8USTRUCT(Blueprintable)
10{
11 GENERATED_USTRUCT_BODY()
12
13 FInputActionMappingStruct() : MappingName(TEXT("")), Key(FKey()), Shift(false), Ctrl(false), Alt(false), Cmd(false) {}
14 FInputActionMappingStruct(const FName& InMappingName, const FKey& InKey, const bool& InShift, const bool& InCtrl, const bool& InAlt, const bool& InCmd) : MappingName(InMappingName), Key(InKey), Shift(InShift), Ctrl(InCtrl), Alt(InAlt), Cmd(InCmd) {}
15
16 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Mapping Struct")
17 FName MappingName;
18
19 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Mapping Struct")
20 FKey Key;
21
22 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Mapping Struct")
23 bool Shift;
24
25 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Mapping Struct")
26 bool Ctrl;
27
28 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Mapping Struct")
29 bool Alt;
30
31 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Action Mapping Struct")
32 bool Cmd;
33};
34
35inline bool operator==(const FInputActionMappingStruct &A, const FInputActionMappingStruct &B) {
36 return (A.MappingName == B.MappingName) & (A.Key == B.Key) & (A.Shift == B.Shift) & (A.Ctrl == B.Ctrl) & (A.Alt == B.Alt) & (A.Cmd == B.Cmd);
37}
38
40 return !(A.MappingName == B.MappingName) & (A.Key == B.Key) & (A.Shift == B.Shift) & (A.Ctrl == B.Ctrl) & (A.Alt == B.Alt) & (A.Cmd == B.Cmd);
41}
42
43UENUM(BlueprintType)
44enum class EInputCategory : uint8
45{
46 Movement = 0,
47 Combat = 1,
48 Communication = 2,
50};
51// Used for flagging key bindings that shouldn't fire as duplicates
52UENUM(BlueprintType)
53enum class ELinkedInputTag : uint8
54{
55 None = 0,
56 Boosting = 1,
57 QuickChat = 2,
58 EscapeButton = 3,
59};
60
61USTRUCT(BlueprintType)
62struct FInputActionRow : public FTableRowBase
63{
64 GENERATED_USTRUCT_BODY()
65 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Customization)
66 FText DisplayName;
67 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Customization)
68 FKey GamepadInput;
69 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Customization)
70 FKey KeyboardMouseInput;
71 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Customization)
72 EInputCategory DisplayCategory;
73 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Customization)
74 ELinkedInputTag SubCategory;
75};
76
77USTRUCT(BlueprintType)
78struct FInputAxisRow : public FTableRowBase
79{
80 GENERATED_USTRUCT_BODY()
81 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Customization)
82 FName AxisName;
83 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Customization)
84 FText DisplayName;
85 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Customization)
86 FKey GamepadInput;
87 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Customization)
88 FKey KeyboardMouseInput;
89 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Customization)
90 EInputCategory DisplayCategory;
91 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Customization)
92 float Scale;
93 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Customization)
94 bool bShowInSettings;
95};
96
97USTRUCT(Blueprintable)
99{
100 GENERATED_USTRUCT_BODY()
101
102 FInputAxisMappingStruct() : MappingName(TEXT("")), Key(FKey()), Scale(0) {}
103 FInputAxisMappingStruct(const FName& InMappingName, const FKey& InKey, const float& InScale) : MappingName(InMappingName), Key(InKey), Scale(InScale) {}
104
105 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Axis Mapping Struct")
106 FName MappingName;
107
108 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Axis Mapping Struct")
109 FKey Key;
110
111 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Axis Mapping Struct")
112 float Scale;
113};
114
115inline bool operator==(const FInputAxisMappingStruct &A, const FInputAxisMappingStruct &B) {
116 return (A.MappingName == B.MappingName) & (A.Key == B.Key) & (A.Scale == B.Scale);
117}
118
120 return !((A.MappingName == B.MappingName) & (A.Key == B.Key) & (A.Scale == B.Scale));
121}
122
123
124UENUM(BlueprintType)
125enum class EMappingType : uint8
126{
127 Axis UMETA(DisplayName = "Axis Mapping"),
128 Action UMETA(DisplayName = "Action Mapping"),
129 Auto UMETA(DisplayName = "Auto")
130};
131
132UENUM(BlueprintType)
133enum class EActionMappingFilter : uint8
134{
135 Name UMETA(DisplayName = "Name"),
136 Key UMETA(DisplayName = "Key"),
137 Shift UMETA(DisplayName = "Shift"),
138 Ctrl UMETA(DisplayName = "Ctrl"),
139 Alt UMETA(DisplayName = "Alt"),
140 Cmd UMETA(DisplayName = "Cmd"),
141 IsNotGamepad UMETA(DisplayName = "Exclude Gamepad"),
142 IsNotKeyboard UMETA(DisplayName = "Exclude Keyboard"),
143 IsNotMouse UMETA(DisplayName = "Exclude Mouse Button")
144};
145
146UENUM(BlueprintType)
147enum class EAxisMappingFilter : uint8
148{
149 Name UMETA(DisplayName = "Name"),
150 Key UMETA(DisplayName = "Key"),
151 Scale UMETA(DisplayName = "Scale"),
152 IsNotGamepad UMETA(DisplayName = "Exclude Gamepad"),
153 IsNotKeyboard UMETA(DisplayName = "Exclude Keyboard"),
154 IsNotMouse UMETA(DisplayName = "Exclude Mouse Button"),
155 IsNotAxis UMETA(DisplayName = "Exclude Axis Keys")
156};
157
158UCLASS()
159class UInputRebindingNodes : public UBlueprintFunctionLibrary
160{
161 GENERATED_UCLASS_BODY()
162
163 UFUNCTION(BlueprintPure, meta = (DisplayName = "Mouse Button From Pointer Event", Keywords = "Mouse Button From Pointer Event", Tooltip = "Gives a blueprint accesible way to get the ouse button pressed from A point event"), Category = "Easy Input Remapping")
164 static FKey GetMouseButtonPressed(FPointerEvent Event,bool &ValidMouseButton);
165
166 UFUNCTION(BlueprintCallable, meta = (DisplayName = "Reset All Key Mappings To Default", Keywords = "Reset Key Bindings To Default", Tooltip = "Restores stock bindings."), Category = "Easy Input Remapping")
167 static void ResetToDefault(UDataTable* const InActionMapDataTable, UDataTable* const InAxisMapDataTable);
168
169 UFUNCTION(BlueprintCallable, meta = (DisplayName = "Rebind Action Mapping", Keywords = "Map Action Key", Tooltip = "Rebinds the provided action mapping to a new key. Returns false if unsuccessfull."), Category = "Easy Input Remapping")
170 static void RebindActionMapping(FInputActionMappingStruct ActionMapping, FInputActionMappingStruct NewData, bool& ReturnValue);
171
172 UFUNCTION(BlueprintCallable, meta = (DisplayName = "Rebind Axis Mapping", Keywords = "Map Axis Key", Tooltip = "Rebinds the provided axis mapping to a new key. Returns false if unsuccessfull."), Category = "Easy Input Remapping")
173 static void RebindAxisMapping(FInputAxisMappingStruct AxisMapping, FInputAxisMappingStruct NewData, bool& ReturnValue);
174
175 UFUNCTION(BlueprintPure, meta = (DisplayName = "Get All Action Mappings", Tooltip = "This returns action mappings, which can be filtered by the filters you input (Both inputs are optional). To only get action mappings that have a certain property, add a filter, and specify the value of that property in the 'Filter Data' input. As an example, if you add 'Key' as a filter, it will only return action mappings that use the key specified in the 'Filter Data' input. As another example: If you add the filter 'Exclude Keyboard', only non-keyboard keys will be outputted, such as Mouse & Gamepad. Adding more than 1 of the same filter will not do anything.", AutoCreateRefTerm = "Filters"), Category = "Easy Input Remapping")
176 static void GetAllActionMappings(FInputActionMappingStruct FilterData, TArray<EActionMappingFilter> Filters, bool& ReturnValue, TArray<FInputActionMappingStruct>& ActionMappings);
177
178 UFUNCTION(BlueprintPure, meta = (DisplayName = "Get All Axis Mappings", Tooltip = "This returns action mappings, which can be filtered by the filters you input (Both inputs are optional). To only get action mappings that have a certain property, add a filter, and specify the value of that property in the 'Filter Data' input. As an example, if you add 'Key' as a filter, it will only return action mappings that use the key specified in the 'Filter Data' input. As another example: If you add the filter 'Exclude Keyboard', only non-keyboard keys will be outputted, such as Mouse & Gamepad. Adding more than 1 of the same filter will not do anything.", AutoCreateRefTerm = "Filters"), Category = "Easy Input Remapping")
179 static void GetAllAxisMappings(FInputAxisMappingStruct FilterData, TArray<EAxisMappingFilter> Filters, bool& ReturnValue, TArray<FInputAxisMappingStruct>& AxisMappings);
180
181 UFUNCTION(BlueprintCallable, meta = (DisplayName = "Create New Action Mapping", Tooltip = "Creates a new action mapping using the data specified. This can easily clutter your config files if you blindly make new action mappings without ever deleting them, so be aware. Returns false if the specified action mapping already exists."), Category = "Easy Input Remapping")
182 static void CreateNewActionMapping(FInputActionMappingStruct MappingData, bool& ReturnValue);
183
184 UFUNCTION(BlueprintCallable, meta = (DisplayName = "Create New Axis Mapping", Tooltip = "Creates a new axis mapping using the data specified. This can easily clutter your config files if you blindly make new axis mappings without ever deleting them, so be aware. Returns false if the specified axis mapping already exists."), Category = "Easy Input Remapping")
185 static void CreateNewAxisMapping(FInputAxisMappingStruct MappingData, bool& ReturnValue);
186
187 UFUNCTION(BlueprintCallable, meta = (DisplayName = "Remove Action Mapping", Tooltip = "Completely removes/deletes the specified action mapping. Returns false if the specified action mapping is not found."), Category = "Easy Input Remapping")
188 static void RemoveActionMapping(FInputActionMappingStruct MappingData, bool& ReturnValue);
189
190 UFUNCTION(BlueprintCallable, meta = (DisplayName = "Remove Axis Mapping", Tooltip = "Completely removes/deletes the specified axis mapping. Returns false if the specified axis mapping is not found."), Category = "Easy Input Remapping")
191 static void RemoveAxisMapping(FInputAxisMappingStruct MappingData, bool& ReturnValue);
192
193 UFUNCTION(BlueprintPure, meta = (DisplayName = "Equal (ActionMapping)", Tooltip = "Returns true if A is exactly equal to B (A == B)", CompactNodeTitle = "==", AutoCreateRefTerm = "A,B"), Category = "Easy Input Remapping")
194 static bool ActionMappingEqualActionMapping(const FInputActionMappingStruct& A, const FInputActionMappingStruct& B);
195
196 UFUNCTION(BlueprintPure, meta = (DisplayName = "NotEqual (ActionMapping)", Tooltip = "Returns true if A does not equal B (A != B)", CompactNodeTitle = "!=", AutoCreateRefTerm = "A,B"), Category = "Easy Input Remapping")
197 static bool ActionMappingNotEqualActionMapping(const FInputActionMappingStruct& A, const FInputActionMappingStruct& B);
198
199 UFUNCTION(BlueprintPure, meta = (DisplayName = "Equal (AxisMapping)", Tooltip = "Returns true if A is exactly equal to B (A == B)", CompactNodeTitle = "==", AutoCreateRefTerm = "A,B"), Category = "Easy Input Remapping")
200 static bool AxisMappingEqualActionMapping(const FInputAxisMappingStruct& A, const FInputAxisMappingStruct& B);
201
202 UFUNCTION(BlueprintPure, meta = (DisplayName = "NotEqual (AxisMapping)", Tooltip = "Returns true if A does not equal B (A != B)", CompactNodeTitle = "!=", AutoCreateRefTerm = "A,B"), Category = "Easy Input Remapping")
203 static bool AxisMappingNotEqualActionMapping(const FInputAxisMappingStruct& A, const FInputAxisMappingStruct& B);
204};
EMappingType
Definition: InputRemappingNodes.h:126
EInputCategory
Definition: InputRemappingNodes.h:45
EAxisMappingFilter
Definition: InputRemappingNodes.h:148
EActionMappingFilter
Definition: InputRemappingNodes.h:134
bool operator!=(const FInputActionMappingStruct &A, const FInputActionMappingStruct &B)
Definition: InputRemappingNodes.h:39
ELinkedInputTag
Definition: InputRemappingNodes.h:54
Definition: InputRemappingNodes.h:160
Definition: InputRemappingNodes.h:10
FKey Key
Definition: InputRemappingNodes.h:20
bool Ctrl
Definition: InputRemappingNodes.h:26
FInputActionMappingStruct(const FName &InMappingName, const FKey &InKey, const bool &InShift, const bool &InCtrl, const bool &InAlt, const bool &InCmd)
Definition: InputRemappingNodes.h:14
bool Alt
Definition: InputRemappingNodes.h:29
FName MappingName
Definition: InputRemappingNodes.h:17
bool Cmd
Definition: InputRemappingNodes.h:32
bool Shift
Definition: InputRemappingNodes.h:23
Definition: InputRemappingNodes.h:63
Definition: InputRemappingNodes.h:99
FName MappingName
Definition: InputRemappingNodes.h:106
FKey Key
Definition: InputRemappingNodes.h:109
FInputAxisMappingStruct(const FName &InMappingName, const FKey &InKey, const float &InScale)
Definition: InputRemappingNodes.h:103
float Scale
Definition: InputRemappingNodes.h:112
Definition: InputRemappingNodes.h:79