Touch Interface Designer 2025.2
Create touch interface with a visual editor and manage all mobile inputs like gestures
Loading...
Searching...
No Matches
GestureBase.h
Go to the documentation of this file.
1// Copyright 2024 Lost in Game Studio. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "UObject/Object.h"
7#include "GestureBase.generated.h"
8
9USTRUCT(BlueprintType)
11{
12 GENERATED_BODY()
13
15
17 uint8 bIsActive:1;
18
23
24 FVector2D BeginPosition;
25 FVector2D CurrentPosition;
26 FVector2D LastPosition;
27 FVector2D OffsetFromBegin;
28
29 bool AcceptPointerIndex(const uint32 InPointerIndex) const
30 {
31 return PointerIndex == InPointerIndex;
32 }
33
35 : PointerIndex(-1)
36 , bIsActive(false)
37 , PressDuration(0.0f)
38 , TouchStartTime(0.0f)
39 , TouchEndTime(0.0f)
40 , AccumulatedTime(0.0f)
41 , BeginPosition(ForceInitToZero)
42 , LastPosition(ForceInitToZero)
43 , OffsetFromBegin(ForceInitToZero)
44 , bDetected(false)
45 , bFirstTouchDetected(false)
46 , bLongPressDetected(false)
47 , bDragDetected(false)
48 , bBlockDrag(false)
49 {
50 FMemory::Memzero(this, sizeof(*this));
51 }
52
53 FGestureData(const int32 PointerIndex, const FVector2D Location)
55 , bIsActive(true)
56 , PressDuration(0.0f)
57 , TouchStartTime(0.0f)
58 , TouchEndTime(0.0f)
59 , AccumulatedTime(0.0f)
60 , BeginPosition(Location)
61 , LastPosition(Location)
62 , OffsetFromBegin(ForceInitToZero)
63 , bDetected(false)
64 , bFirstTouchDetected(true)
65 , bLongPressDetected(false)
66 , bDragDetected(false)
67 , bBlockDrag(false)
68 {
69
70 }
71
72 FGestureData(const int32 PointerIndex, const FVector2D Location, const double Time)
74 , bIsActive(true)
75 , PressDuration(0.0f)
76 , TouchStartTime(Time)
77 , TouchEndTime(Time)
78 , AccumulatedTime(0.0f)
79 , BeginPosition(Location)
80 , LastPosition(Location)
81 , OffsetFromBegin(ForceInitToZero)
82 , bDetected(false)
83 , bFirstTouchDetected(true)
84 , bLongPressDetected(false)
85 , bDragDetected(false)
86 , bBlockDrag(false)
87 {
88
89 }
90
91 void Update(const FVector2D Location)
92 {
93 OffsetFromBegin = Location - BeginPosition;
94 CurrentPosition = Location;
95 }
96
97 void End(const FVector2D Location)
98 {
99 LastPosition = Location;
100 bIsActive = false;
102 }
103
104private:
105 friend class UGestureBase;
106 friend class UMultitouchLogic;
107
108 uint8 bDetected:1;
109 uint8 bFirstTouchDetected:1;
110 uint8 bLongPressDetected:1;
111 uint8 bDragDetected:1;
112 uint8 bBlockDrag:1;
113
115 void Reset()
116 {
117 PointerIndex = -1;
118 PressDuration = 0.0f;
119 TouchStartTime = 0.0f;
120 AccumulatedTime = 0.0f;
121 BeginPosition = FVector2D::ZeroVector;
122 LastPosition = FVector2D::ZeroVector;
123 OffsetFromBegin = FVector2D::ZeroVector;
124 bDetected = false;
125 bFirstTouchDetected = false;
126 bLongPressDetected = false;
127 bDragDetected = false;
128 bIsActive = false;
129 }
130};
131
133class TOUCHINTERFACE_API UGestureBase : public UObject
134{
135 GENERATED_BODY()
136
137public:
138 UGestureBase();
139
140 //TODO: Block other gesture if needed
141 // Make function ShouldBlock()
142
143 UFUNCTION(Category="Gesture", BlueprintNativeEvent)
145
146 UFUNCTION(Category="Gesture", BlueprintNativeEvent)
147 void OnGestureStarted(const TArray<FGestureData>& GestureData);
148
149 UFUNCTION(Category="Gesture", BlueprintNativeEvent)
150 void OnGestureUpdated(const TArray<FGestureData>& GestureData);
151
152 UFUNCTION(Category="Gesture", BlueprintNativeEvent)
153 void OnGestureEnded(const TArray<FGestureData>& GestureData);
154};
EditInlineNew
Definition ComponentDecorator_Animation.h:40
Abstract
Definition ComponentDecorator_Animation.h:40
BlueprintType
Definition ComponentDecorator_Animation.h:40
BlueprintNativeEvent void OnGestureEnded(const TArray< FGestureData > &GestureData)
BlueprintNativeEvent void OnGestureStarted(const TArray< FGestureData > &GestureData)
BlueprintNativeEvent void OnGestureUpdated(const TArray< FGestureData > &GestureData)
Category
Definition GestureBase.h:143
BlueprintNativeEvent void Initialization()
UGestureBase()
Definition GestureBase.cpp:7
Definition GestureBase.h:11
friend class UMultitouchLogic
Definition GestureBase.h:106
FGestureData()
Definition GestureBase.h:34
uint32 PointerIndex
Definition GestureBase.h:14
double TouchStartTime
Definition GestureBase.h:20
float PressDuration
Definition GestureBase.h:19
bool AcceptPointerIndex(const uint32 InPointerIndex) const
Definition GestureBase.h:29
FVector2D BeginPosition
Definition GestureBase.h:24
friend class UGestureBase
Definition GestureBase.h:105
FGestureData(const int32 PointerIndex, const FVector2D Location, const double Time)
Definition GestureBase.h:72
void Update(const FVector2D Location)
Definition GestureBase.h:91
FVector2D OffsetFromBegin
Definition GestureBase.h:27
uint8 bIsActive
Definition GestureBase.h:17
FGestureData(const int32 PointerIndex, const FVector2D Location)
Definition GestureBase.h:53
double AccumulatedTime
Definition GestureBase.h:22
double TouchEndTime
Definition GestureBase.h:21
void End(const FVector2D Location)
Definition GestureBase.h:97
FVector2D CurrentPosition
Definition GestureBase.h:25
FVector2D LastPosition
Definition GestureBase.h:26