![]() |
GEIS
2.0
Gesture Engine Interface Support
|
The advanced GEIS interface is designed around the idea that you can create filters to limit the kinds of gestures received and combine those filters into subscriptions that interact with the gesture recognizer to deliver gesture events.
The normal flow for using the advanced interface is as follows.
This is an example of using the advanced (GEIS v2) API. The full source code for this example (including details missing here) is included in the source distribution of geis.
Please note that these examples omit all of the error checking for expository purposes only.
First, a function to create the filters for a subscription. the filters can not be created until the gesture recognition engine initialization is complete, since otherwise the expected types of the gesture attributes on which to filter are not known by the interface.
An empty filter is created. An empty filter means all input devices, all gestures, all regions. For the purpose of this example, we want just 2-touch gestures, so we need to add a term to the filter specifying only those gestures with two touches.
In the main fucntion, the API instance is created. We tell it to report input devices and gesture classes.
For the event loop processing, we're going to need the event fd (this is assuming a Unix implementation of GEIS, other platforms may have a different event indicator).
A subscription object is created. We want gesture continuations.
The application's main event loop is run until a read is indicated as available on the event fd, at which point the GEIS event loop is pumped.
Finally, the API objects are cleaned up.