Add Site or Add Page to Favorites
>

 Finger Gestures 

Preview DRM-free music
Play clips of the most popular DRM-Free music in MP3 format
Legal Music .com

Get information on your favorite TV Shows at TV Series .com

Clarify the meaning of the acronyms on your web site.

Acronym Dictionary

Acronym Finder

Social Networking Web Sites

Register your own domain name at A to Z Domains.

or buy domains at Domain Names For Sale .net


Printer-friendly PDF* format:

Finger Gestures

What are Finger Gestures?

Finger Gestures are continuous sequences of finger motions on a touch-screen device. Some touch-sensitive handheld devices include:

  • Android phones such as the T-Mobile HTC myTouch 3G
  • Other Android-based devices such as the Archos 5 Internet Tablet
  • Apple iPhone
  • Apple iPod Touch

This site provides a catalog of Finger Gestures which makes to detecting and recognizing specific gestures much easier. Follow these steps to make use of Finger Gestures:

  1. Encode each segment of the user's gestures
  2. Build up a gesture from consecutive segments
  3. Find desired gestures in gesture catalog
  4. Provide for recognition of different gestures
  5. Program the desired action(s) for each gesture

Encoding Segments of a Gesture

While handling motion events on a touch device (in a GestureDetector in the Android SDK, for example), each segment of the gesture is encoded as an XY pair of base 3 digits with 0 indicating no motion, 1 indicating motion in the negative direction and 2 indicating motion in the positive direction. Note that no negative numbers are used - there are only positive values since two negatives (-X,-Y) don't make a positive when dealing with directions.

Encoding logic can take advantage of program constants such as:

                        static final int RIGHT     = 0x06; // positive X direction (XY = 20)
                        
static final int LEFT = 0x03; // negative X direction (XY = 10)
static final int DOWN = 0x02; // positive Y direction (XY = 02)
static final int UP = 0x01; // negative Y direction (XY = 01)

Motion in a diagonal direction is encoded by adding the constants for the two component directions, for example RIGHT + UP would be 0x06 + 0x01 = 0x07 // (XY = 21 base 3). Another way to look at segment encoding is using compass directions, which could be programmed using decimal constants such as:

                        static final int NO_MOTION = 0;
                        
static final int NORTH = 1;
static final int SOUTH = 2;
static final int WEST = 3;
static final int NORTHWEST = 4; // NORTH + WEST
static final int SOUTHWEST = 5; // SOUTH + WEST
static final int EAST = 6;
static final int NORTHEAST = 7; // NORTH + EAST
static final int SOUTHEAST = 8; // SOUTH + EAST

Segment encoding summary

CodeMotionCompass direction
0stationary NO_MOTION
1upward motion NORTH
2downward motion SOUTH
3leftward motion WEST
41 + 3 NORTHWEST
52 + 3 SOUTHWEST
6rightward motionEAST
71 + 6 NORTHEAST
82 + 6 SOUTHEAST

Encoding Gestures

Build up a gesture from individual segments by multiplying the gesture for all previous segments by 9, then adding the code for the new segment. In other words, create a base 9 number with all of the segment codes placing the starting segment code in the high order position and the last segment code in the low order position. For example, a G-shaped gesture starting in the upper right and ending in the middle would be coded as 32613 (left, down, right, up, left).

Convert to a decimal number if necessary. This allows the gesture to be specified as a constant value in a program, possibly as a case in a switch statement. For that G-shaped gesture mentioned above, the decimal value would be 21639, so that particular gesture could be recognized in a program as follows:

                        void onGestureDetected(long gesture) {
                        
if (gesture > (long) Integer.MAX_VALUE) { // or 387420489l to exclude all 10-segment gestures
... too many segments, or use nested switch statements ...
}
else switch ((int) gesture) {
case 21639:
... actions for G-shaped gesture ...
break;
}
}

Gesture Catalog

For direct access to specific gestures in the gesture catalog, the web pages are named as follows (gn = gesture number):

Finger Gestures with ten segments or more are encoded with numbers that are usually larger than Integer.MAX_VALUE = 2147483647 and can be recognized in the same manner, but require nested switch (int) statements due to the size of the integers.

Lists of Gestures

Gesture Recognition

One way to recognize different gestures is include a switch statement in your program with one case ...: for each gesture and one break; for each set of actions to be performed. More than one gesture (multiple case ...:s) can be associated with any given set of actions (down to the next break;). A default: case can be included for unrecognized gestures. For example:

                        void onGestureDetected(long gesture) {
                        
if (gesture > (long) Integer.MAX_VALUE) { // or 387420489l to exclude all 10-segment gestures
... too many segments, or use nested switch statements ...
}
else switch ((int) gesture) {
case 1423:
case 1432:
... actions for gesture #1423 or #1432 ...
break;
case 1523:
case 1532:
... actions for gesture #1523 or #1532 ...
break;
... etc. ...
default:
... gesture not recognized ...
break;
}
}

Program Actions for Specific Gestures

Between the case ...:s and break; for each set of gestures, include the program code for whatever actions are to be performed when that gesture is detected.

Last updated Sunday November 1, 2009

You are currently viewing this page in HTML 4* format (* see Clicklets for more infomation). This document is also available in XHTML 1 Style Sheet*XHTML 1* XML*HTML 5 Style Sheet*HTML 5 XML*HTML 5 non-XML* XHTML 2* XHTML Mobile* WML Mobile* and printer-friendly PDF* formats. This is accomplished with Single Source Publishing, a content management system that uses templates in XSLT style sheets provided by XML Styles .com to transform the source content for various content delivery channels. There is also RDF* metadata that describes the content of this document.


Copyright © 2009 Accilent® Corp. Alteration of content, including addition of any function such as hypertext links or pop-up advertising, or interference with the hypertext links or other functions of this site is expressly prohibited.

DISCLAIMER: All information, links, forms, applications and other items on this site or obtained from it are provided AS IS, WITHOUT WARRANTY OF ANY KIND EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.