LeapScreenTapGestureΒΆ
Properties:
The LeapScreenTapGesture class represents a tapping gesture by a finger or tool.
A screen tap gesture is recognized when the tip of a finger pokes forward and then springs back to approximately the original postion, as if tapping a vertical screen. The tapping finger must pause briefly before beginning the tap.
Important: To use screen tap gestures in your application, you must enable recognition of the screen tap gesture. You can enable recognition with:
[controller enableGesture:LEAP_GESTURE_TYPE_SCREEN_TAP enable:YES];LeapScreenTap gestures are discrete. The LeapScreenTapGesture object representing a tap always has the state, LEAP_GESTURE_STATE_STOP. Only one LeapScreenTapGesture object is created for each screen tap gesture recognized.
You can set the minimum finger movement and velocity required for a movement to be recognized as a screen tap as well as adjust the detection window for evaluating the movement using the config attribute of a connected LeapController object. Use the following keys to configure screen tap recognition:
Key string Value type Default value Units Gesture.ScreenTap.MinForwardVelocity float 50 mm/s Gesture.ScreenTap.HistorySeconds float 0.1 s Gesture.ScreenTap.MinDistance float 5.0 mm The following example demonstrates how to set the screen tap configuration parameters:
[controller.config setFloat:@"Gesture.ScreenTap.MinForwardVelocity" value:30.0]; [controller.config setFloat:@"Gesture.ScreenTap.HistorySeconds" value:.5]; [controller.config setFloat:@"Gesture.ScreenTap.MinDistance" value:1.0]; [controller.config save];The LeapController object must be connected to the Leap Motion service/daemon before setting the configuration parameters.
Public Functions
- Since 1.0
Property- (BOOL) equals:(const LeapGesture *) otherCompare LeapGesture object equality.
Two LeapGestures are equal if they represent the same snapshot of the same recognized movement.
[thisGesture equals:thatGesture];
- Since 1.0
- Parameters
- other -
The LeapGesture object to compare.
Public Static Functionsdirection- (LeapVector *) directionThe direction of finger tip motion.
LeapVector *tapDirection = screenTap.direction;
- Return
- LeapVector A unit direction vector.
- Since 1.0
duration- (int64_t) durationThe elapsed duration of the recognized movement up to the frame containing this LeapGesture object, in microseconds.
int64_t microseconds = gesture.duration;The duration reported for the first LeapGesture in the sequence (with the LEAP_GESTURE_STATE_START state) will typically be a small positive number since the movement must progress far enough for the Leap to recognize it as an intentional gesture.
- Return
- int64_t the elapsed duration in microseconds.
- Since 1.0
durationSeconds- (float) durationSecondsThe elapsed duration in seconds.
float seconds = gesture.duration;
- See
- duration
- Return
- float the elapsed duration in seconds.
- Since 1.0
frame- (LeapFrame *) frameThe LeapFrame containing this LeapGesture instance.
LeapFrame *owningFrame = gesture.frame;
- Return
- The parent LeapFrame object.
- Since 1.0
hands- (NSArray *) handsThe list of hands associated with this LeapGesture, if any.
NSArray *handList = gesture.hands; //Only one hand for current gestures LeapHand *gesturingHand = [handList objectAtIndex:0];If no hands are related to this gesture, the list is empty.
- Return
- NSArray the list of related LeapHand objects.
- Since 1.0
id- (int32_t) idThe gesture ID.
All LeapGesture objects belonging to the same recognized movement share the same ID value. Use the ID value with the [LeapFrame gesture:] method to find updates related to this LeapGesture object in subsequent frames.
int gestureID = gesture.id;
- Return
- int32_t the ID of this LeapGesture.
- Since 1.0
isValid- (BOOL) isValidReports whether this LeapGesture instance represents a valid gesture.
An invalid LeapGesture object does not represent a snapshot of a recognized movement. Invalid LeapGesture objects are returned when a valid object cannot be provided. For example, when you get an gesture by ID using [LeapFrame gesture:], and there is no gesture with that ID in the current frame, then gesture: returns an Invalid LeapGesture object (rather than a null value). Always check object validity in situations where an gesture might be invalid.
LeapFrame *frame = [controller frame:0]; LeapGesture *trackedGesture = [frame gesture:trackedGestureID]; if(trackedGesture.isValid) { //Use the data... }
- Return
- bool Yes, if this is a valid LeapGesture instance; NO, otherwise.
- Since 1.0
pointable- (LeapPointable *) pointableThe finger performing the screen tap gesture.
LeapPointable * tapper = screenTap.pointable;
- Return
- A LeapPointable object representing the tapping finger.
- Since 1.0
pointables- (NSArray *) pointablesThe list of fingers and tools associated with this LeapGesture, if any.
NSArray *pointableList = gesture.pointables; //Only one pointable for current gestures LeapHand *gesturingPointable = [pointableList objectAtIndex:0];If no LeapPointable objects are related to this gesture, the list is empty.
- Return
- NSArray the list of related LeapPointable objects.
- Since 1.0
position- (LeapVector *) positionThe position where the screen tap is registered.
LeapVector *tapPosition = screenTap.position;
- Return
- A LeapVector containing the coordinates of screen tap location.
- Since 1.0
progress- (float) progressThe progess value is always 1.0 for a screen tap gesture.
- Return
- float The value 1.0.
- Since 1.0
state- (LeapGestureState) stateThe gesture state.
Recognized movements occur over time and have a beginning, a middle, and an end. The ‘state’ attribute reports where in that sequence this LeapGesture object falls.
LeapGestureState state = gesture.state;The possible gesture states are defined by the LeapGestureState enumeration:
LEAP_GESTURE_STATE_INVALID An invalid state.
LEAP_GESTURE_STATE_START The gesture is starting. Just enough has happened to recognize it.
LEAP_GESTURE_STATE_UPDATE The gesture is in progress. (Note: not all gestures have updates).
LEAP_GESTURE_STATE_STOP The gesture has completed or stopped.
- Return
- LeapGestureState A value from the LeapGestureState enumeration.
- Since 1.0
type- (LeapGestureType) typeThe gesture type.
LeapGestureType type = gesture.type;The supported types of gestures are defined by the LeapGestureType enumeration:
LEAP_GESTURE_TYPE_INVALID An invalid type.
LEAP_GESTURE_TYPE_SWIPE A straight line movement by the hand with fingers extended.
LEAP_GESTURE_TYPE_CIRCLE A circular movement by a finger.
LEAP_GESTURE_TYPE_SCREEN_TAP A forward tapping movement by a finger.
LEAP_GESTURE_TYPE_KEY_TAP A downward tapping movement by a finger.
- Return
- LeapGestureType A value from the LeapGestureType enumeration.
- Since 1.0
+ (LeapGesture *) invalidReturns an invalid LeapGesture object.
LeapGesture *wrongGesture = LeapGesture.invalid;
- Return
- The invalid LeapGesture instance.
- Since 1.0
