Recognizing gestures
In this recipe, we implement a function which detects pinch-zoom-rotate and fling/swipe gestures. It can serve as a starting point for recognition of your own custom gestures.
Getting ready
This recipe relies on the recipe Processing multi-touch events on Android from this chapter to handle multi-touch input.
How to do it...
We split the task of motion decoding into individual layers. The low-level code handles the OS-generated touch events. Collected touch point data is processed using a set of routines in the mid-level code, which we present in this recipe. Finally, all the decoded gestures are reported to the user's high-level code using the simple
iGestureResponder
interface:class iGestureResponder { public:
The
Event_UpdateGesture()
method is provided for direct access to the current state of contact points. ThesMotionData
structure is presented right after theiGestureResponder
discussion. The1_MultitouchInput
example overrides this method to render the touch points...