Leap C++ API Reference  0.7.9
Leap::SwipeGesture Class Reference

The SwipeGesture class represents a swiping motion of a finger or tool. More...

Inherits Leap::Gesture.

Public Member Functions

Vector direction () const
 The unit direction vector parallel to the swipe motion.
 
Pointable pointable () const
 The finger performing the swipe gesture.
 
Vector position () const
 The current position of the swipe.
 
float speed () const
 The swipe speed in mm/second.
 
Vector startPosition () const
 The position where the swipe began.
 
 SwipeGesture (const Gesture &rhs)
 Constructs a SwipeGesture object from an instance of the Gesture class.
 
- Public Member Functions inherited from Leap::Gesture
int64_t duration () const
 The elapsed duration of the recognized movement up to the frame containing this Gesture object, in microseconds.
 
float durationSeconds () const
 The elapsed duration in seconds.
 
Frame frame () const
 The Frame containing this Gesture instance.
 
 Gesture ()
 Constructs a new Gesture object.
 
 Gesture (const Gesture &rhs)
 Constructs a new copy of an Gesture object.
 
HandList hands () const
 The list of hands associated with this Gesture, if any.
 
int32_t id () const
 The gesture ID.
 
bool isValid () const
 Reports whether this Gesture instance represents a valid Gesture.
 
bool operator!= (const Gesture &rhs) const
 Compare Gesture object inequality.
 
bool operator== (const Gesture &rhs) const
 Compare Gesture object equality.
 
PointableList pointables () const
 The list of fingers and tools associated with this Gesture, if any.
 
State state () const
 The gesture state.
 
std::string toString () const
 A string containing a brief, human-readable description of this Gesture.
 
Type type () const
 The gesture type.
 

Static Public Member Functions

static Type classType ()
 The swipe gesture type.
 
- Static Public Member Functions inherited from Leap::Gesture
static const Gestureinvalid ()
 Returns an invalid Gesture object.
 

Additional Inherited Members

- Public Types inherited from Leap::Gesture
enum  State { STATE_INVALID = -1, STATE_START = 1, STATE_UPDATE = 2, STATE_STOP = 3 }
 The possible gesture states. More...
 
enum  Type {
  TYPE_INVALID = -1, TYPE_SWIPE = 1, TYPE_CIRCLE = 4, TYPE_SCREEN_TAP = 5,
  TYPE_KEY_TAP = 6
}
 The supported types of gestures. More...
 

Detailed Description

The SwipeGesture class represents a swiping motion of a finger or tool.

Leap_Gesture_Swipe.png

Important: To use swipe gestures in your application, you must enable recognition of the swipe gesture. You can enable recognition with:

controller.enableGesture(Gesture::TYPE_SWIPE);

Swipe gestures are continuous.

You can set the minimum length and velocity required for a movement to be recognized as a swipe using the config attribute of a connected Controller object. Use the following keys to configure swipe recognition:

Key string Value type Default value Units
Gesture.Swipe.MinLength float 150 mm
Gesture.Swipe.MinVelocity float 1000 mm/s

The following example demonstrates how to set the swipe configuration parameters:

if(controller.config().setFloat("Gesture.Swipe.MinLength", 200.0) &&
controller.config().setFloat("Gesture.Swipe.MinVelocity", 750))
controller.config().save();

Constructor & Destructor Documentation

Leap::SwipeGesture::SwipeGesture ( const Gesture rhs)

Constructs a SwipeGesture object from an instance of the Gesture class.

Parameters
rhsThe Gesture instance to specialize. This Gesture instance must be a SwipeGesture object.

Member Function Documentation

static Type Leap::SwipeGesture::classType ( )
inlinestatic

The swipe gesture type.

Returns
Type The type value designating a swipe gesture.
Vector Leap::SwipeGesture::direction ( ) const

The unit direction vector parallel to the swipe motion.

You can compare the components of the vector to classify the swipe as appropriate for your application. For example, if you are using swipes for two dimensional scrolling, you can compare the x and y values to determine if the swipe is primarily horizontal or vertical.

Returns
Vector The unit direction vector representing the swipe motion.
Pointable Leap::SwipeGesture::pointable ( ) const

The finger performing the swipe gesture.

Returns
Pointable A Pointable object representing the swiping finger.
Vector Leap::SwipeGesture::position ( ) const

The current position of the swipe.

Returns
Vector The current swipe position within the Leap frame of reference, in mm.
float Leap::SwipeGesture::speed ( ) const

The swipe speed in mm/second.

Returns
float The speed of the finger performing the swipe gesture in millimeters per second.
Vector Leap::SwipeGesture::startPosition ( ) const

The position where the swipe began.

Returns
Vector The starting position within the Leap frame of reference, in mm.