TinyGPU
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
GestureDetector Class Reference

Recognizes touch gestures from a stream of single-point touch samples, and reports them through a single callback. More...

#include <GestureDetector.h>

Public Member Functions

void update (TouchDriver &driver)
 

Public Attributes

void(* onGesture )(GestureEvent &) = nullptr
 
bool(* isDraggable )(int16_t x, int16_t y) = nullptr
 
uint16_t tapMaxDurationMs = 300
 
uint16_t tapMaxMovePx = 12
 
uint16_t doubleTapMaxGapMs = 350
 
uint16_t longPressMinDurationMs = 600
 
uint16_t swipeMinDistancePx = 40
 
uint16_t swipeMaxDurationMs = 500
 
uint16_t dragStartThresholdPx = 8
 

Detailed Description

Recognizes touch gestures from a stream of single-point touch samples, and reports them through a single callback.

This does not replace TouchDriver - feed it the same driver you'd otherwise poll directly, once per loop():

GestureDetector gestures; gestures.onGesture = handleGesture; gestures.isDraggable = [](int16_t x, int16_t y) { ... }; // optional void loop() { gestures.update(touchDriver); }

isDraggable, if set, is checked against the position where a touch started; if it returns true the resulting continuous-move gesture is reported as kDrag, otherwise as kPan/kScroll. Without it, continuous moves are always reported as kPan/kScroll (never kDrag).

pinch/rotate require TouchDriver::getSecondPoint() to return a genuine second simultaneous touch; none of the drivers built into this library can supply one (see TouchDriver::getSecondPoint), so those two gesture types will not fire against them.

Member Function Documentation

◆ update()

void update ( TouchDriver &  driver)
inline

Call once per loop() with the same driver you'd otherwise poll directly via isTouched()/getPoint().

Member Data Documentation

◆ doubleTapMaxGapMs

uint16_t doubleTapMaxGapMs = 350

◆ dragStartThresholdPx

uint16_t dragStartThresholdPx = 8

◆ isDraggable

bool(* isDraggable) (int16_t x, int16_t y) = nullptr

◆ longPressMinDurationMs

uint16_t longPressMinDurationMs = 600

◆ onGesture

void(* onGesture) (GestureEvent &) = nullptr

◆ swipeMaxDurationMs

uint16_t swipeMaxDurationMs = 500

◆ swipeMinDistancePx

uint16_t swipeMinDistancePx = 40

◆ tapMaxDurationMs

uint16_t tapMaxDurationMs = 300

◆ tapMaxMovePx

uint16_t tapMaxMovePx = 12

The documentation for this class was generated from the following file: