~ubuntu-branches/ubuntu/trusty/geis/trusty

« back to all changes in this revision

Viewing changes to doc/geisspec-1.0.asc

  • Committer: Package Import Robot
  • Author(s): Chase Douglas
  • Date: 2012-07-30 08:51:42 UTC
  • Revision ID: package-import@ubuntu.com-20120730085142-jrc33ygjvt0ob1wl
Tags: upstream-2.2.11
ImportĀ upstreamĀ versionĀ 2.2.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
ļ»æGesture Engine Interface Support
 
2
================================
 
3
Stephen M. Webb  <stephen.webb@bregmasoft.ca>
 
4
:Author Initials: SMW
 
5
v1.0, 12 August 2010
 
6
 
 
7
Overview
 
8
--------
 
9
 
 
10
This document describes GEIS, an interface between an application and an
 
11
underlying gesture recognition system.
 
12
 
 
13
A GEIS implementation provides a mechanism for recognizing user interface
 
14
gestures on various configurable devices and for propagating those recognized
 
15
gestures to subscribed applications.
 
16
 
 
17
Gestures
 
18
~~~~~~~~
 
19
 
 
20
A _gesture_ is a defined set of particular movements of pointing devices.  GEIS
 
21
provides no interpretation of gestures, only recognition and propagation.
 
22
 
 
23
Because gestures can be defined to have global meaning as well as local meaning,
 
24
it makes sense that gesture recognition be provided by the system rather than be
 
25
included as a library by a particular application or toolkit.  This allows, for
 
26
example, a set of gestures to be defined for the window manager in use on a
 
27
display to receive gesture events even when another application is in the
 
28
foreground and receiving the input.
 
29
 
 
30
GEIS Operation
 
31
--------------
 
32
 
 
33
The purpose of GEIS is intended to provide a consistent and stable application
 
34
programming interface for gesture recognition and propagation on multiple target
 
35
platforms (for example, Linux, Unix, and Windows), multiple target input
 
36
devices (for example mice, touch pads, mutitouch touchscreens, tables, nunchuks),
 
37
and multiple gesture recognition engines.  Different gesture engines may be
 
38
available on the same platform.
 
39
 
 
40
A number of basic types are defined for portability between various underlying
 
41
display, input, and operating systems.
 
42
 
 
43
GEIS Basic Types
 
44
~~~~~~~~~~~~~~~~~
 
45
 
 
46
+GeisBoolean+ is an integral type representing a boolean value and should only
 
47
hold the values +GEIS_TRUE+ (1) and +GEIS_FALSE+ (0).
 
48
 
 
49
+GeisInt+ is an integral type large enough to hold any integral gesture attribute
 
50
value which may be represented on the native platform.  This may includes
 
51
bitmasks, enumerants, integers, handles, and so forth.
 
52
 
 
53
+GeisFloat+ is a floating-point type which can represent floating-point valued
 
54
gesture attributes,
 
55
 
 
56
+GeisString+ is a C-style zero-terminated string of characters in some character
 
57
set.  A +GeisString+ is a read-only string and does not have to be freed or
 
58
disposed of by the caller.
 
59
 
 
60
GEIS Instances
 
61
~~~~~~~~~~~~~~
 
62
 
 
63
An application may need to support different sets of gestures from different
 
64
input devices or associated with different regions of the same device.  For this
 
65
reason, GEIS provides for one or more distinct connections to the underlying
 
66
gesture engine.  The instances are distinguished by a GeisInstance object.  All
 
67
gesture types and gesture instances IDs are in a namespace associated with the
 
68
GeisInstance and are not guaranteed to be system wide unique.
 
69
 
 
70
Threading and Concurrency
 
71
^^^^^^^^^^^^^^^^^^^^^^^^^
 
72
 
 
73
The GEIS API does not specify threading, reentrancy, or concurrency attributes.
 
74
The implementation must supply detailed documentation on these aspects.
 
75
 
 
76
Input Devices
 
77
^^^^^^^^^^^^^
 
78
 
 
79
The API provides a method to enumerate the available gesture-capable input
 
80
devices (including the dynamic appearance and disappearance of such devices) and
 
81
a way to specify a subset of these devices for use in a particular gesture
 
82
detection instance.  A client application might typically respond to gestures
 
83
from any input device, but others, such as a drawing application, may wish to
 
84
bypass gesture detection on, for example, a drawing tablet while accepting them
 
85
from a touchscreen for other functions such as zoom and rotate.
 
86
 
 
87
GEIS uses a set of client-supplied callbacks to report the availability of input
 
88
devices so that devices that dynamically appear or disappear can be reported
 
89
through a consistent interface.
 
90
 
 
91
GEIS Functions and Errors
 
92
-------------------------
 
93
 
 
94
Errors
 
95
~~~~~~
 
96
 
 
97
NOTE: This section is not complete.
 
98
 
 
99
GEIS functions usually return a status code indicating success or failure.  The
 
100
status codes that may be returned, and their meanings, are as follows.
 
101
 
 
102
+GEIS_SUCCESS+::
 
103
  Normal, successful completion of the function.
 
104
 
 
105
+GEIS_BAD_ARGUMENT+::
 
106
  One or more argument values are invalid.  Any command taking parameters may
 
107
  generate this error.
 
108
 
 
109
+GEIS_STATUS_NOT_SUPPORTED+::
 
110
  An operation or configuration item is not supported by the implementation.
 
111
 
 
112
+GEIS_UNKNOWN_ERROR+::
 
113
  A general catchall error:  an error occurred that is not covered by any other
 
114
  defined status code.
 
115
 
 
116
Initialization
 
117
~~~~~~~~~~~~~~
 
118
 
 
119
NOTE: This section is not complete.
 
120
 
 
121
A GEIS instance may be initialized by calling
 
122
[source, C]
 
123
-----------
 
124
GeisStatus geis_init(GeisWinInfo *win_info, GeisInstance *geis_instance);
 
125
-----------
 
126
 
 
127
+GEIS_SUCCESS+ is returned on success and _geis_instance_ is updated with an
 
128
instance value to be used in subsequent GEIS calls.
 
129
 
 
130
The definition of the +GeisWinInfo+ fields is entirely dependant on the
 
131
implementation.  For example, an X11-based gesture recognizer may specify the
 
132
_window_id_ as the _win_info_ argument.
 
133
 
 
134
Configuration and Control
 
135
~~~~~~~~~~~~~~~~~~~~~~~~~
 
136
 
 
137
A particular GEIS implementation may support a subset of standard configuarable
 
138
items and, in addition, zero or more implementation-specific configuration
 
139
items.  The implementation-specific configuration items will be documented by
 
140
the implementation.
 
141
 
 
142
To determine of a confiuration item is supported, use the following call.
 
143
 
 
144
[source, C]
 
145
-----------
 
146
GeisStatus geis_configuration_supported(GeisInstance instance,
 
147
                                        int          configuration_item);
 
148
-----------
 
149
 
 
150
This function will return +GEIS_STATUS_SUCCESS+ if the _configuration_item_ is
 
151
supported by the implementation, +GEIS_STATUS_NOT_SUPPORTED+ otherwise.
 
152
 
 
153
The following standard configuration items must be available.
 
154
.Input Standard Configuration Items
 
155
[width="60%",cols="<,3d",frame="topbot",options="header"]
 
156
|===================
 
157
|+configuration item+ | description
 
158
|GEIS_CONFIG_UNIX_FD  | A posix descriptor for event loop synchronization is available.
 
159
|===================
 
160
 
 
161
Configuration-specifc values may be set and retrieved using the following calls.
 
162
 
 
163
[source,C]
 
164
----------
 
165
GeisStatus geis_configuration_get_value(GeisInstance instance,
 
166
                                        int          configuration_item,
 
167
                                        void*        value);
 
168
 
 
169
GeisStatus geis_configuration_set_value(GeisInstance instance,
 
170
                                        int          configuration_item,
 
171
                                        void*        value);
 
172
----------
 
173
 
 
174
The actual type and meaning of the _value_ argument depends on the
 
175
_configuration_item_.  Standard configuration item types are described in the
 
176
following table.
 
177
 
 
178
.Input Standard Configuration Item Types
 
179
[width="60%",cols="<,<,2d",frame="topbot",options="header"]
 
180
|===================
 
181
|+configuration item+ | type | description
 
182
|GEIS_CONFIG_UNIX_FD  | int  | A posix file descriptor
 
183
|===================
 
184
 
 
185
 
 
186
Integration with the native event loop is through an implementation-specific
 
187
mechanism (likely obtained through the configuration calls above, but documented
 
188
more thoroughly in the implementation documentation) combined with a call to the
 
189
GEIS dispatch mechanism.
 
190
[source,C]
 
191
----------
 
192
GeisStatus geis_event_dispatch(geisInstance instance);
 
193
----------
 
194
 
 
195
Input Devices
 
196
~~~~~~~~~~~~~
 
197
 
 
198
Gestures are associated with input devices (a gesture must be input on a
 
199
device).  Client software may subscribe to gestures that occur on all input
 
200
devices or on only a subset of input devices.  For that to be possible, the
 
201
client needs to enumerate all available input devices.  In addition, many input
 
202
devices have a dynamic lifetime -- they may be added or removed asynchronously.
 
203
the client software needs to be made aware that new input devices have become
 
204
available or existing devices have become unavailable.
 
205
 
 
206
GEIS input device enumeration and availability notification is performed through
 
207
the following interface.
 
208
 
 
209
[source, C]
 
210
-----------
 
211
typedef unsigned int GeisInputDeviceId;
 
212
 
 
213
#define GEIS_ALL_INPUT_DEVICES ((GeisInputDeviceId)0)
 
214
 
 
215
typedef void (*GeisInputCallback)(void             *cookie,
 
216
                                  GeisInputDeviceId device_id,
 
217
                                  void             *attrs);
 
218
 
 
219
typedef struct GeisInputFuncs
 
220
{
 
221
  GeisInputCallback  added;   /**< Receives new input device notices */
 
222
  GeisInputCallback  changed; /**< Receives modified input device notices */
 
223
  GeisInputCallback  removed; /**< Receives removes input device notices */
 
224
 
 
225
} GeisInputFuncs;
 
226
 
 
227
GeisStatus geis_input_devices(GeisInstance    geis_instance,
 
228
                              GeisInputFuncs  funcs,
 
229
                              void           *cookie);
 
230
-----------
 
231
 
 
232
The API provides a list of available input devices one at a time through the
 
233
client-supplied _added_ callback function.
 
234
 
 
235
The _changed_ callback function or the _removed_ callback function may be
 
236
invoked at any time after *geis_input_devices* is called and before
 
237
*geis_finish* is called to tear down the +GeisInstance+ or *geis_input_devices*
 
238
is called again to replace the callback function.  This can occur when input
 
239
devices are, for example, physically connected to or disconnected from the
 
240
system.
 
241
 
 
242
The _cookie_ value passed to *geis_input_devices* is passed unmodified to
 
243
callback function.  Client programs may use this for passing context-specific
 
244
information into the callback.
 
245
 
 
246
The suggested behaviour of an implementation is to invoke the _callback_ for
 
247
each input device known at call time _before_ returning from the
 
248
*geis_input_devices* call.
 
249
 
 
250
Subscribing to Gestures
 
251
~~~~~~~~~~~~~~~~~~~~~~~
 
252
 
 
253
Gestures are specific to a +GeisInstance+ and set of input devices.  The
 
254
+GeisInstance+ must be informed of the set of gestures (and input devices) of
 
255
interest.
 
256
 
 
257
[source, C]
 
258
-----------
 
259
typedef unsigned int GeisGestureType;
 
260
typedef unsigned int GeisGestureId;
 
261
 
 
262
#define GEIS_ALL_GESTURES ((GeisGestureType)0)
 
263
#define GEIS_NO_GESTURE_ID ((GeisGestureId)0)
 
264
 
 
265
typedef void (*GeisGestureCallback)(void             *cookie,
 
266
                                    GeisGestureType   gesture_type,
 
267
                                    GeisGestureId     gesture_id,
 
268
                                    GeisSize          attr_count,
 
269
                                    GeisGestureAttr  *attrs);
 
270
 
 
271
typedef struct GeisGestureFuncs
 
272
{
 
273
  GeisGestureCallback  added;
 
274
  GeisGestureCallback  removed;
 
275
  GeisGestureCallback  start;
 
276
  GeisGestureCallback  update;
 
277
  GeisGestureCallback  finish;
 
278
} GeisGestureFuncs;
 
279
 
 
280
GeisStatus geis_subscribe(GeisInstance        geis_instance,
 
281
                          GeisInputDeviceId  *input_list,
 
282
                          const char*        *gesture_list,
 
283
                          GeisGestureFuncs    funcs,
 
284
                          void               *cookie);
 
285
 
 
286
GeisStatus geis_unsubscribe(GeisInstance     geis_instance,
 
287
                            GeisGestureType *gesture_list);
 
288
-----------
 
289
 
 
290
The client supplies a list of input devices (or the constant
 
291
+GEIS_ALL_INPUT_DEVICES+) and a +NULL+ terminated list of C-style strings naming
 
292
the gestures to be recognized.  The constant +GEIS_ALL_GESTURES+ indicates all
 
293
available gestures should be detected.
 
294
 
 
295
GEIS provides a list of gestures available in the desired window and input
 
296
device(s) one at a time through the client-supplied _added_ callback function
 
297
with the +GEIS_GESTURE_TYPE_ADDED+ action.  This allows the client to build a
 
298
map of gesture names to +GeisGestureType+.  If the recognition engine does not
 
299
support a named gesture type passed to *geis_subscribe* then no
 
300
+GeisGestureType+ is passed to the callback function for the named gesture.
 
301
 
 
302
The _cookie_ value passed to *geis_subscribe* is passed unmodified to
 
303
_callback_.  Client programs may use this for passing context-specific
 
304
information into the callback.
 
305
 
 
306
Receiving Gestures
 
307
~~~~~~~~~~~~~~~~~~
 
308
 
 
309
One of the gesture event callback functions may be invoked at any time after
 
310
*geis_input_devices* is called and before *geis_finish* is called to tear down
 
311
the +GeisInstance+ or *geis_input_devices* is called again to replace the
 
312
_callback_ function.  This can occur when input devices are, for example,
 
313
physically connected to or disconnected from the system.
 
314
 
 
315
Most gestures will result in a _start_ callback, zero or more _update_
 
316
callbacks, and a _finish_ callback.  Some gestures such as _tap_ gestures may
 
317
result in only a single _update_ callback.  This behaviour is dependent on the
 
318
underlying gesture recognition engine
 
319
 
 
320
Once a gesture is recognized, a +GEIS_GESTURE_STARTED+ action is sent. A set of
 
321
zero or more attributes will be returned.  These attributes are specific to the
 
322
gesture.  Depending on the nature of the gesture, one or more
 
323
+GEIS_GESTURE_UPDATED+ actions may be sent, and finally a
 
324
+GEIS_GESTURE_FINISHED+ action will be sent.  Each of these may or may not have
 
325
a set of attributes associated.
 
326
 
 
327
A gesture or gesture type action is often associated with a set of attributes.
 
328
These attributes are delivered to the callback function as a read-only array of
 
329
_GeisGestureAttr_ type, defined below.
 
330
 
 
331
[source, C]
 
332
-----------
 
333
typedef struct GeisGestureAttr
 
334
{
 
335
  GeisString   name;
 
336
  GeisAttrType type;
 
337
  union
 
338
  {
 
339
    GeisBoolean boolean_val;
 
340
    GeisFloat   float_val;
 
341
    GeisInteger integer_val;
 
342
    GeisString  string_val;
 
343
  };
 
344
} GeisGestureAttr;
 
345
-----------
 
346
 
 
347
Recognizer Teardown
 
348
~~~~~~~~~~~~~~~~~~~
 
349
 
 
350
Teardown of the gesture recognition session is accomplished by the *geis_finish*
 
351
function.
 
352
 
 
353
[source, C]
 
354
-----------
 
355
GeisStatus geis_finish(GeisInstance *geis_instance);
 
356
----------
 
357
 
 
358
This function frees any allocated resources associated with _geis_instance_.  It
 
359
does not affect other instances.
 
360
 
 
361
All resources are expected to be freed automatically on process termination.
 
362
The *geis_finish* function is not expected to return any status value other than
 
363
+GEIS_SUCCESS+.
 
364
 
 
365
Standard Gestures
 
366
-----------------
 
367
 
 
368
A limited number of fundamental gestures are expected to be supplied with the
 
369
API.  All implementations are expected to support at least this set of
 
370
predefined gestures.  Additional predefined gestures and user- or
 
371
application-defined gestures are beyond the scope of this specification but are
 
372
expected to be made available by the implementation.
 
373
 
 
374
.Predefined Gestures
 
375
[width="60%",cols="<,2d,2d",frame="topbot",options="header"]
 
376
|========================================================
 
377
|gesture name |symbolic name        |description
 
378
| Drag        | GEIS_GESTURE_DRAG   |
 
379
| Pinch       | GEIS_GESTURE_PINCH  |
 
380
| Rotate      | GEIS_GESTURE_ROTATE |
 
381
| Tap         | GEIS_GESTURE_TAP    |
 
382
|=========================================================
 
383
 
 
384
Common Attributes
 
385
~~~~~~~~~~~~~~~~~~~
 
386
 
 
387
All standard gestures provide a common set of attributes.
 
388
 
 
389
.Common Gesture Attributes
 
390
[width="60%",cols="3<,m,d",frame="topbot",options="header"]
 
391
|=========================================================
 
392
|name                                    |type         |description
 
393
| GEIS_GESTURE_ATTRIBUTE_DEVICE_ID       | GeisInteger |
 
394
| GEIS_GESTURE_ATTRIBUTE_TIMESTAMP       | GeisInteger |
 
395
| GEIS_GESTURE_ATTRIBUTE_ROOT_WINDOW_ID  | GeisInteger |
 
396
| GEIS_GESTURE_ATTRIBUTE_EVENT_WINDOW_ID | GeisInteger |
 
397
| GEIS_GESTURE_ATTRIBUTE_CHILD_WINDOW_ID | GeisInteger |
 
398
| GEIS_GESTURE_ATTRIBUTE_FOCUS_X         | GeisFloat   |
 
399
| GEIS_GESTURE_ATTRIBUTE_FOCUS_Y         | GeisFloat   |
 
400
| GEIS_GESTURE_ATTRIBUTE_GESTURE_NAME    | GeisString  |
 
401
| GEIS_GESTURE_ATTRIBUTE_FINGERS         | GeisInteger |
 
402
|=========================================================
 
403
 
 
404
Drag
 
405
~~~~
 
406
 
 
407
NOTE: This section is not complete.
 
408
 
 
409
.Pan Gesture Attributes
 
410
[width="60%",cols="3<,m,d",frame="topbot",options="header"]
 
411
|=========================================================
 
412
|name                               |type       |description
 
413
| GEIS_GESTURE_ATTRIBUTE_DELTA_X    | GeisFloat |
 
414
| GEIS_GESTURE_ATTRIBUTE_DELTA_Y    | GeisFloat |
 
415
| GEIS_GESTURE_ATTRIBUTE_VELOCITY_X | GeisFloat |
 
416
| GEIS_GESTURE_ATTRIBUTE_VELOCITY_Y | GeisFloat |
 
417
| GEIS_GESTURE_ATTRIBUTE_POSITION_X | GeisFloat |
 
418
| GEIS_GESTURE_ATTRIBUTE_POSITION_Y | GeisFloat |
 
419
|=========================================================
 
420
 
 
421
Pinch
 
422
~~~~~
 
423
 
 
424
NOTE: This section is not complete.
 
425
 
 
426
. Pinch Gesture Attributes
 
427
[width="60%",cols="3<,m,d",frame="topbot",options="header"]
 
428
|=========================================================
 
429
|name                                    |type        |description
 
430
| GEIS_GESTURE_ATTRIBUTE_RADIUS_DELTA    | GeisFloat  | 
 
431
| GEIS_GESTURE_ATTRIBUTE_RADIAL_VELOCITY | GeisFloat  |
 
432
| GEIS_GESTURE_ATTRIBUTE_RADIUS          | GeisFloat  |
 
433
| GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X1  | GeisFloat  |
 
434
| GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y1  | GeisFloat  |
 
435
| GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X2  | GeisFloat  |
 
436
| GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y2  | GeisFloat  |
 
437
|=========================================================
 
438
 
 
439
Rotate
 
440
~~~~~~
 
441
 
 
442
NOTE: This section is not complete.
 
443
 
 
444
. Swipe Gesture Attributes
 
445
[width="60%",cols="3<,m,d",frame="topbot",options="header"]
 
446
|=========================================================
 
447
|name                                     |type        |description
 
448
| GEIS_GESTURE_ATTRIBUTE_ANGLE_DELTA      | GeisFloat  |
 
449
| GEIS_GESTURE_ATTRIBUTE_ANGULAR_VELOCITY | GeisFloat  |
 
450
| GEIS_GESTURE_ATTRIBUTE_ANGLE            | GeisFloat  |
 
451
|=========================================================
 
452
 
 
453
Tap
 
454
~~~
 
455
 
 
456
NOTE: This section is not complete.
 
457
 
 
458
.Tap Gesture Attributes
 
459
[width="60%",cols="3<,m,d",frame="topbot",options="header"]
 
460
|=========================================================
 
461
|name                               |type       |description
 
462
| GEIS_GESTURE_ATTRIBUTE_POSITION_X | GeisFloat |
 
463
| GEIS_GESTURE_ATTRIBUTE_POSITION_Y | GeisFloat |
 
464
|=========================================================
 
465
 
 
466
 
 
467
GEIS Versioning, Header Files, and Constants
 
468
--------------------------------------------
 
469
 
 
470
Each published version of GEIS supports the specified client API of that
 
471
version and all prior versions of those APIs (backwards compatibility).
 
472
 
 
473
Header Files
 
474
~~~~~~~~~~~~
 
475
 
 
476
The GEIS specification defines an ISO C language binding.  The GEIS header file
 
477
+<geis/geis.h>+ provides prototypes for all GEIS entry points and C preprocessors
 
478
for all GEIS tokens, for use both by client code and implementers.
 
479
 
 
480
Languages other than C and C++ will define GEIS interfaces using other methods
 
481
outside the scope of this specification.
 
482
 
 
483
Compile-time Version Detection
 
484
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
485
 
 
486
To allow code to be written portably against future GEIS versions, the
 
487
compile-time environment must make it possible to determine which GEIS version
 
488
interface are available.  For C and C++ code the +<geis/geis.h>+ header defined C
 
489
preprocessor symbols corresponding to all versions of GEIS supported by the
 
490
implementation.
 
491
 
 
492
[source, C]
 
493
-----------
 
494
#define GEIS_VERSION_1_0  1
 
495
-----------
 
496
Future versions of GEIS will define additional preprocessor symbols
 
497
corresponding to the major and minor numbers of those versions.
 
498
 
 
499
Constants and Implementation-Supplied Values
 
500
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
501
 
 
502
Constants and enumerator values for GEIS tokens defined in this specification are
 
503
required to be common across all implementations.  A reference version of the
 
504
+geis.h+ header file can be downloaded from *to be determined*.
 
505
 
 
506
All implementation-specific types, values, and macros used in +geis.h+ are
 
507
partitioned into an implementation header, +geisimpl.h+, which is automatically6
 
508
included by +geis.h+.  Implementers should need only modify +geisimpl.h+, never
 
509
+geis.h+.
 
510
 
 
511
Conformance Testing for Implementers
 
512
------------------------------------
 
513
 
 
514
NOTE: This section is not complete.
 
515