5#include <unordered_map>
87 enum struct Kind : uint32_t
130 bool hoverEnable =
true;
131 bool wheelEnable =
true;
132 bool tapEnable =
true;
133 bool doubleTapEnable =
true;
134 bool pressEnable =
true;
135 bool dragEnable =
true;
136 bool swipeEnable =
true;
137 bool panEnable =
true;
138 bool rotateEnable =
true;
139 bool pinchEnable =
true;
142 uint32_t tapMaxDuration = 250;
143 uint32_t doubleTapTreshold = 300;
144 uint32_t swipeMaxDuration = 200;
145 float mouseMoveThreshold = 1.f;
146 float touchMoveThreshold = 16.f;
147 float touchVelocityThreshold = 500.f;
148 float mouseVelocityThreshold = 100.f;
149 float rotateThreshold = 0.05f;
150 float pinchThreshold = 0.1f;
158 void pointerMove(
PointerType pointerType,
PointerId pointerId, glm::ivec2 position,
double timestamp_ms);
159 void mouseWheelMove(int32_t delta);
166 const std::vector<Gesture>&
getGestures()
const {
return presentedGestures; }
169 float displayScale = 1.0f;
177 double lastTapTimestamp = 0;
179 std::optional<Gesture> currPress = std::nullopt;
180 std::optional<Gesture> currDrag = std::nullopt;
181 std::optional<Gesture> currPan = std::nullopt;
182 std::optional<Gesture> currRotate = std::nullopt;
183 std::optional<Gesture> currPinch = std::nullopt;
197 double timestamp_ms = 0.0;
211 uint32_t idCounter = 0;
215 void endUpdatingGesture(std::optional<Gesture>& gesture,
Gesture::State state);
#define COGSFOUNDATION_API
Definition: FoundationBase.h:31
Definition: Gestures.h:127
std::vector< Gesture > presentedGestures
Definition: Gestures.h:173
std::vector< Gesture > currentGestures
Definition: Gestures.h:174
uint32_t nextGestureId()
Definition: Gestures.h:212
const std::vector< Gesture > & getGestures() const
Return all gestures recognised in the previous frame. Use id to differentiate between gestures.
Definition: Gestures.h:166
std::unordered_map< PointerId, PointerState > currentPointers
Set of currently active pointers.
Definition: Gestures.h:209
void setDisplayScale(float scale)
Definition: Gestures.h:154
Main Cogs namespace.
Definition: MortonCode.h:5
PointerType
Definition: Gestures.h:12
size_t PointerId
Definition: Gestures.h:9
MouseButton
Definition: Mouse.h:15
@ Count
Definition: Mouse.h:20
Definition: Gestures.h:22
int32_t x
Definition: Gestures.h:23
int32_t y
Definition: Gestures.h:24
Definition: Gestures.h:42
MouseButton button
Button that was tapped.
Definition: Gestures.h:43
Coord coord
Pointer position when the event was triggered.
Definition: Gestures.h:44
Definition: Gestures.h:52
Coord currCoord
Pointer position when the event was triggered.
Definition: Gestures.h:55
MouseButton button
Button that was tapped.
Definition: Gestures.h:53
Coord startCoord
Pointer position when the gesture has started.
Definition: Gestures.h:54
Definition: Gestures.h:28
Coord coord
Pointer position when the event was triggered.
Definition: Gestures.h:29
Definition: Gestures.h:72
Coord midStartCoord
Mid position between the two pointer positions when the gesture has started.
Definition: Gestures.h:73
Coord midCurrCoord
Mid position between the two pointer positions when the event was triggered.
Definition: Gestures.h:74
Definition: Gestures.h:82
Coord center
Mid position between the two pointer positions when the event was triggered.
Definition: Gestures.h:83
float scale
Scale factor, 1 when the gesture starts.
Definition: Gestures.h:84
Definition: Gestures.h:47
Coord coord
Pointer position when the event was triggered.
Definition: Gestures.h:49
MouseButton button
Button that was tapped.
Definition: Gestures.h:48
Definition: Gestures.h:77
float angle
Rotation angle in radians, 0 when the gesture starts.
Definition: Gestures.h:79
Coord center
Mid position between the two pointer positions when the event was triggered.
Definition: Gestures.h:78
Definition: Gestures.h:58
Direction
Definition: Gestures.h:59
@ Left
Definition: Gestures.h:60
@ Down
Definition: Gestures.h:63
@ Up
Definition: Gestures.h:62
@ Right
Definition: Gestures.h:61
Direction direction
Swipe general direction.
Definition: Gestures.h:67
Coord startCoord
Pointer position when the gesture has started.
Definition: Gestures.h:68
float velocity
Pointer velocity relative to startCoord.
Definition: Gestures.h:69
MouseButton button
Button that was tapped.
Definition: Gestures.h:66
Definition: Gestures.h:37
Coord coord
Pointer position when the event was triggered.
Definition: Gestures.h:39
MouseButton button
Button that was tapped.
Definition: Gestures.h:38
Definition: Gestures.h:32
Coord coord
Pointer position when the event was triggered.
Definition: Gestures.h:33
int32_t delta
Amount by which the mouse wheel was moved.
Definition: Gestures.h:34
Definition: Gestures.h:21
Kind
Definition: Gestures.h:88
Rotate rotate
Definition: Gestures.h:121
Press press
Definition: Gestures.h:117
State
Definition: Gestures.h:102
@ Ended
Gesture ended or single-fire events, used by all gestures.
@ Changed
Gesture changed, used by: Drag, Swipe, Pan, Rotate, Pinch.
@ Started
Gesture started, used by: Press, Drag, Swipe, Pan, Rotate, Pinch.
@ Cancelled
Gesture cancelled, used by: Press, Drag, Swipe, Pan, Rotate, Pinch.
Hover hover
< Specific gesture data.
Definition: Gestures.h:113
Pan pan
Definition: Gestures.h:120
Pinch pinch
Definition: Gestures.h:122
Drag drag
Definition: Gestures.h:118
Swipe swipe
Definition: Gestures.h:119
Kind kind
Gesture type, see Kind.
Definition: Gestures.h:109
State state
Gesture state, see State.
Definition: Gestures.h:111
Tap tap
Definition: Gestures.h:115
Wheel wheel
Definition: Gestures.h:114
DoubleTap doubleTap
Definition: Gestures.h:116
uint32_t id
Unique gesture id.
Definition: Gestures.h:110
Definition: Gestures.h:196
glm::ivec2 position
Pixel x and y position.
Definition: Gestures.h:198
Definition: Gestures.h:186
Data curr
Current pointer data.
Definition: Gestures.h:206
Data init
Pointer data when pointer was pressed.
Definition: Gestures.h:204
Data prev
Pointer data before previous update.
Definition: Gestures.h:205
State
Definition: Gestures.h:188
@ Moving
Definition: Gestures.h:191
@ Pressed
Definition: Gestures.h:190
@ None
Definition: Gestures.h:189