Touch Interface Designer 2025.2
Create touch interface with a visual editor and manage all mobile inputs like gestures
Loading...
Searching...
No Matches
TouchInterfaceSettings.h
Go to the documentation of this file.
1// Copyright Lost in Game Studio. All Rights Reserved.
2
3#pragma once
4
5//#include "CoreMinimal.h"
6#include "Engine/DeveloperSettings.h"
7#include "Runtime/Launch/Resources/Version.h"
8#include "TouchInterfaceSettings.generated.h"
9
12class UVirtualShape;
13
14/*UENUM()
15enum class EInputMode
16{
17 //Only gamepad respond to input. Touch Interface and other widget do not respond to input
18 GameOnly,
19
20 //Only UI respond to input. Gamepad, keyboard or mouse do not respond to input.
21 UIOnly,
22
23 //UI respond first to input. If UI do not intercept input, gamepad, keyboard or mouse has a chance.
24 GameAndUI
25};*/
26
27USTRUCT(BlueprintType)
29{
30 GENERATED_BODY()
31
32
38 UPROPERTY(Category="Tap", EditDefaultsOnly)
39 float TapTime;
40
42 UPROPERTY(Category="Long Press", EditDefaultsOnly)
44
48 UPROPERTY(Category="Long Press", EditDefaultsOnly)
50
53 UPROPERTY(Category="Drag", EditDefaultsOnly)
55
58 UPROPERTY(Category="Drag", EditDefaultsOnly)
60
64 UPROPERTY(Category="Swipe", EditDefaultsOnly, meta=(ClampMin=0.8f, ClampMax=1.0f))
65 float DirectionThreshold;
66
68 UPROPERTY(Category="Swipe", EditDefaultsOnly)
70
73 UPROPERTY(Category="Swipe", EditDefaultsOnly)
75
76 //TODO: Block Swipe if long press is detected
77
81 UPROPERTY(Category="Two Finger Swipe", EditDefaultsOnly)
83
86 UPROPERTY(Category="Zoom", EditDefaultsOnly)
88
91 UPROPERTY(Category="Zoom", EditDefaultsOnly)
93
95 : TapTime(0.18f)
96 , LongPressDuration(0.8f)
97 , MovementThreshold(10.0f)
100 , DirectionThreshold(0.98f)
101 , SwipeThreshold(500.0f)
102 , SwipeVelocityThreshold(3000.0f)
106 {
107
108 }
109};
110
111UENUM(BlueprintType, meta=(Bitflags, UseEnumValuesAsMaskValuesInEditor="true"))
112enum class EDebugType : uint8
113{
114 None = 0x0 UMETA(Hidden), // 0
115 Outline = 0x01, // 1
116 HitBox = 0x02, // 2
117 ComponentName = 0x04, // 4
118 ComponentSize = 0x08, // 8
119 ComponentCenter = 0x10, // 16
120 Pivot = 0x20, // 32
121 FingerLocation = 0x40 // 64
122};
123ENUM_CLASS_FLAGS(EDebugType)
124
125UENUM()
126enum class EScalingMode
127{
128 // No scaling
129 NONE UMETA(DisplayName="Disabled"),
130
131 // Use desktop DPI Curve based on geometry size
132 DPI UMETA(DisplayName="Desktop DPI Curve"),
133
134 // Scaling the touch interface based on the reference design size (DesiredWidth)
136
137 // Use your own scaling algorithm
139
140 //Mobile DPI Curve based on viewport size
141};
142
143/*UENUM()
144enum class EScaleSide
145{
146 // Use the shortest side for DPI Curve or Design Size based scaling
147 ShortestSide,
148
149 // Use the longest side for DPI Curve or Design Size based scaling
150 LargestSide,
151
152 // Use the X-axis of geometry (viewport) for DPI Curve or Design Size based scaling
153 Horizontal,
154
155 // Use the Y-axis of geometry (viewport) for DPI Curve or Design Size based scaling
156 Vertical
157};*/
158
162UCLASS(Config=Engine, defaultConfig, meta=(DisplayName="Touch Interface"))
163class TOUCHINTERFACE_API UTouchInterfaceSettings : public UDeveloperSettings
164{
165 GENERATED_BODY()
166
167public:
168 UTouchInterfaceSettings();
169
170#if WITH_EDITOR
171 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
172#endif
173
174 float GetScaleFactor(const FVector2D Size, const float LayoutScale = 1.0f, const bool InEditorMode = true) const;
175
176 bool CustomScalingClassIsValid() const { return CustomTouchInterfaceScalingInstance != nullptr; }
177
178 // Get the resolution size associated with a key whose value is equal to scale
179 bool GetResolutionSizeFromDpiCurveScale(const float Scale, float& ResolutionSize) const;
180
181 bool UseEnhancedInput() const;
182
183
184 //Todo: Use SoftObjectPtr with no empty feature and make a basic interface by default
185 // In case you forget to fill in an interface in the TouchDesignerController, it will use this one by default
186 UPROPERTY(Category="General", Config, EditAnywhere, meta=(AllowedClasses="/Script/TouchInterface.VirtualControlSetup"))
187 FSoftObjectPath DefaultVirtualControlSetup;
188
189 // Should touch interface be shown in desktop platform
190 UPROPERTY(Category="General", Config, EditAnywhere)
191 bool bShowInDesktopPlatform;
192
193 //If enabled, the subsystem remove touch interface from player screen automatically on level load
194 UPROPERTY(Category="General", EditAnywhere, Config)
195 bool bAutomaticallyRemoveOnLevelLoad;
196
200 UPROPERTY(Category="General", Config, EditAnywhere)
201 int32 ZOrder;
202
203
204 // Max layer to draw for one virtual input
205 UPROPERTY(Category="Visual Layer", Config, EditAnywhere)
206 int32 MaxLayer;
207
208
209 // Max layer to draw per component decorator (Aka per component)
210 UPROPERTY(Category="Decorator", EditAnywhere, Config)
211 int32 MaxLayerPerComponentDecorator;
212
213
214 // Scaling Mode
215 UPROPERTY(Category="Scaling", Config, EditAnywhere)
216 EScalingMode ScalingMode;
217
218 // The design width of Touch interface used as reference for scaling calculation in DesignSize mode
219 UPROPERTY(Category="Scaling", Config, EditAnywhere, meta=(EditCondition="ScalingMode == EScalingMode::DesignSize", EditConditionHides))
220 float DesignWidth;
221
223 //UPROPERTY(Config, EditAnywhere, Category="Scaling", meta=(EditCondition="ScalingMode == EScalingMode::DesignSize", EditConditionHides))
224 //EScaleSide ScaleSideRule;
225
226 //UPROPERTY(Config, EditAnywhere, Category="Scaling", meta=(EditCondition="ScalingMode == EScalingMode::DPI", EditConditionHides))
227 //FRuntimeFloatCurve TouchInterfaceScaleCurve;
228
229 //Todo: Use TSoftClassPtr with NoClear meta
230 // This class will be used for touch interface scaling.
231 UPROPERTY(Category="Scaling", config, EditAnywhere, meta=(MetaClass="/Script/TouchInterface.CustomTouchInterfaceScaling", EditCondition="ScalingMode == EScalingMode::Custom", EditConditionHides))
232 FSoftClassPath CustomTouchInterfaceScalingClass;
233
238 UPROPERTY(Category="Scaling", Config, EditAnywhere)
239 float ScaleMultiplier;
240
243 UPROPERTY(Category="Input", Config, EditAnywhere)
244 bool bBlockTouchEvent;
245
248 UPROPERTY(Category="Input", Config, EditAnywhere)
249 bool bCaptureMouse;
250
254 UPROPERTY(Category="Touch Interface Listener", EditAnywhere, Config)
255 bool bSendInputEvenIfTouchInputIsHit;
256
257 //TODO: Remove this
258 // Enable the recognition of gestures
259 UPROPERTY(Category="Gestures Recognizer", Config, EditAnywhere)
260 bool bEnableGestureRecognizer;
261
262 // This is the default gestures config used in Gesture Manager Component
263 UPROPERTY(Category="Gestures Recognizer", Config, EditAnywhere, meta=(EditCondition="bEnableGestureRecognizer", EditConditionHides))
264 FGesturesConfig DefaultGesturesConfig;
265
266 //TODO: Remove this
267 // EXPERIMENTAL! Enable detection of user-drawn shapes
268 UPROPERTY(Category="Shape Recognizer", Config, EditAnywhere)
269 bool bEnableShapeRecognizer;
270
271 UPROPERTY(Category="Shape Recognizer", Config, EditAnywhere, meta=(EditCondition="bEnableShapeRecognizer", EditConditionHides, ClampMin=0.1f, ClampMax=1.0f))
272 float CornerDetectionThreshold;
273
274 float ShapeDotDistance;
275
276 UPROPERTY(Category="Shape Recognizer", Config, EditAnywhere, meta=(EditCondition="bEnableShapeRecognizer", EditConditionHides, ClampMin=0.1f, ClampMax=1.0f))
277 int32 MaxPoint;
278
279 //TODO: Implement
280 // Default shape recognized by all shape recognizer components
281 //UPROPERTY(Category="Shape Recognizer", Config, EditAnywhere, meta=(AllowedClasses="/Script/TouchInterface.VirtualShape", EditCondition="bEnableShapeRecognizer", EditConditionHides))
282 //TArray<FSoftObjectPath> DefaultVirtualShapes;
283
290 UPROPERTY(Category="Shape Recognizer", Config, EditAnywhere, meta=(EditCondition="bEnableShapeRecognizer", EditConditionHides))
291 uint8 bUseTimer:1;
292
293 UPROPERTY(Category="Shape Recognizer", Config, EditAnywhere, meta=(AllowedClasses="/Script/TouchInterface.VirtualShape", EditCondition="bEnableShapeRecognizer", EditConditionHides))
294 float DelayBetweenEndDrawAndComputation;
295
296 UPROPERTY(Category="Shape Recognizer", Config, EditAnywhere, meta=(EditCondition="bEnableShapeRecognizer", EditConditionHides))
297 float MinMatchingScoreToTriggerEvent;
298
299
300 // EXPERIMENTAL! Enable detection of device movements based on gyroscope data
301 UPROPERTY(Category="Motion Recognizer", Config, EditAnywhere)
302 uint8 bEnableMotionRecognizer:1;
303
304
310 UPROPERTY( Category="Gamepad", Config, EditAnywhere)
311 bool bHideTouchInterfaceWhenGamepadIsConnected;
312
315 /*UPROPERTY( Category="Gamepad", Config, EditAnywhere)
316 bool bOverrideInputMode;*/
317
318 // Base input mode when gamepad is disconnected
319 /*UPROPERTY( Category="Gamepad", Config, EditAnywhere, meta=(EditCondition="bOverrideInputMode==true"))
320 EInputMode BaseInputMode;*/
321
322 // Input mode set when gamepad is connected to device
323 /*UPROPERTY( Category="Gamepad", Config, EditAnywhere, meta=(EditCondition="bOverrideInputMode==true"))
324 EInputMode GamepadInputMode;*/
325
326
327 // Slot name for saved configuration of Touch Interface at runtime
328 UPROPERTY(Category="Build-in Save System", Config, EditAnywhere, BlueprintReadOnly)
329 FString SaveSlotName;
330
331
332
336 UPROPERTY( Category="Debugging", Config, EditAnywhere)
337 bool bDrawDebug;
338
339 // Show some information for debugging like Fingers position, component name, hit box, size, etc.
340 UPROPERTY(Category="Debugging", Config, EditAnywhere, BlueprintReadOnly, meta=(Bitmask, BitmaskEnum="/Script/TouchInterface.EDebugType"), meta=(EditCondition="bDrawDebug", EditConditionHides))
341 int32 DebugType;
342
343 // Opacity of debug information
344 UPROPERTY(Category="Debugging", Config, EditAnywhere, meta=(ClampMin=0.0f, UIMin=0.0f, ClampMax=1.0f, UIMax=1.0f), meta=(EditCondition="bDrawDebug", EditConditionHides))
345 float DebugOpacity;
346
347
348private:
349 TObjectPtr<class UCustomTouchInterfaceScaling> CustomTouchInterfaceScalingInstance;
350};
BlueprintType
Definition ComponentDecorator_Animation.h:40
DisplayName
Definition DecoratorRotationAnim.h:15
meta
Definition GestureRecognizerComp.h:274
@ Scale
Definition ProgressBarLayer.h:33
Config
Definition TouchInterfaceSettings.h:162
EScalingMode
Definition TouchInterfaceSettings.h:127
@ DesignSize
Definition TouchInterfaceSettings.h:135
@ Custom
Definition TouchInterfaceSettings.h:138
@ UMETA
Definition TouchInterfaceSettings.h:129
defaultConfig
Definition TouchInterfaceSettings.h:162
Definition VirtualControlSetup.h:465
Definition VirtualShapeDrawer.h:22
Definition VirtualShape.h:233
EditAnywhere
Definition VirtualShape.h:271
BlueprintReadOnly
Definition VirtualShape.h:281
Category
Definition VirtualShape.h:244
Definition TouchInterfaceSettings.h:29
EditDefaultsOnly uint8 bBlockDragIfSlideIsDetected
Definition TouchInterfaceSettings.h:59
EditDefaultsOnly
Definition TouchInterfaceSettings.h:64
EditDefaultsOnly uint8 bSendDragAfterLongPress
Definition TouchInterfaceSettings.h:54
EditDefaultsOnly uint8 bSendDragEventWhenZoomOrRotateGestureDetected
Definition TouchInterfaceSettings.h:92
meta
Definition TouchInterfaceSettings.h:64
Category
Definition TouchInterfaceSettings.h:38
EditDefaultsOnly float LongPressDuration
Definition TouchInterfaceSettings.h:43
EditDefaultsOnly float MinimumDeltaToSendEvent
Definition TouchInterfaceSettings.h:87
EditDefaultsOnly float SwipeVelocityThreshold
Definition TouchInterfaceSettings.h:74
EditDefaultsOnly float MovementThreshold
Definition TouchInterfaceSettings.h:49
FGesturesConfig()
Definition TouchInterfaceSettings.h:94
EditDefaultsOnly float TwoFingerSwipeClosenessThreshold
Definition TouchInterfaceSettings.h:82
EditDefaultsOnly float SwipeThreshold
Definition TouchInterfaceSettings.h:69
EditDefaultsOnly float TapTime
Definition TouchInterfaceSettings.h:39