Merge lp:~chasedouglas/grail/remove-v2 into lp:grail

Proposed by Chase Douglas
Status: Merged
Merged at revision: 229
Proposed branch: lp:~chasedouglas/grail/remove-v2
Merge into: lp:grail
Diff against target: 5315 lines (+81/-4735)
54 files modified
configure.ac (+2/-5)
include/grail-bits.h (+0/-95)
include/grail-types.h (+0/-195)
include/grail.h (+0/-480)
src/Makefile.am (+23/-60)
src/atomic-recognizer.cpp (+5/-5)
src/atomic-recognizer.h (+1/-1)
src/event.cpp (+2/-2)
src/event.h (+1/-1)
src/gesture.cpp (+7/-7)
src/gesture.h (+1/-1)
src/handle.cpp (+6/-6)
src/handle.h (+1/-1)
src/libutouch-grail.ver (+4/-28)
src/log.cpp (+1/-1)
src/recognizer.cpp (+5/-5)
src/recognizer.h (+2/-2)
src/regular-recognizer.cpp (+5/-5)
src/regular-recognizer.h (+1/-1)
src/slice.cpp (+6/-6)
src/slice.h (+1/-1)
src/subscription.cpp (+1/-1)
src/subscription.h (+1/-1)
src/touch.cpp (+2/-2)
src/v2/evbuf.h (+0/-56)
src/v2/gebuf.h (+0/-67)
src/v2/gestures-drag.c (+0/-134)
src/v2/gestures-pinch.c (+0/-130)
src/v2/gestures-rotate.c (+0/-129)
src/v2/gestures-tapping.c (+0/-99)
src/v2/gestures-touch.c (+0/-97)
src/v2/grail-api.c (+0/-327)
src/v2/grail-bits.c (+0/-92)
src/v2/grail-event.c (+0/-117)
src/v2/grail-frame.c (+0/-409)
src/v2/grail-gestures.c (+0/-222)
src/v2/grail-gestures.h (+0/-114)
src/v2/grail-impl.h (+0/-87)
src/v2/grail-init.c (+0/-235)
src/v2/grail-inserter.c (+0/-303)
src/v2/grail-inserter.h (+0/-92)
src/v2/grail-legacy.c (+0/-63)
src/v2/grail-recognizer.c (+0/-57)
src/v2/grail-recognizer.h (+0/-43)
src/v2/grailbuf.h (+0/-58)
test/Makefile.am (+2/-11)
test/check-mapping.cpp (+0/-100)
test/check-transform.cpp (+0/-116)
tools/Makefile.am (+1/-9)
tools/grail-eventprinter.c (+0/-239)
tools/grail-gesture.1 (+0/-17)
tools/grail-gesture.c (+0/-131)
tools/grail-test-mtdev.1 (+0/-16)
tools/grail-test-mtdev.c (+0/-253)
To merge this branch: bzr merge lp:~chasedouglas/grail/remove-v2
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
Review via email: mp+105238@code.launchpad.net

Description of the change

Remove v2 implementation.

To post a comment you must log in.
lp:~chasedouglas/grail/remove-v2 updated
230. By Chase Douglas

Update library and symbol versioning

Revision history for this message
Stephen M. Webb (bregma) wrote :

OK by me.

This requires some changes to the utouch-grail packaging (mostly due to the bumped SONAME) and a small change to utouch-geis, but in and of itself looks correct and builds cleanly.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2012-04-03 19:47:33 +0000
3+++ configure.ac 2012-05-09 17:32:19 +0000
4@@ -14,7 +14,7 @@
5 AM_SILENT_RULES([yes])
6 AM_MAINTAINER_MODE([enable])
7
8-LIB_VERSION=4:0:3
9+LIB_VERSION=5:0:0
10 AC_SUBST([LIB_VERSION])
11
12 # Initialize libtool
13@@ -30,10 +30,7 @@
14 PKG_CHECK_MODULES([FRAME], [utouch-frame >= 2.2.0])
15
16 PKG_CHECK_MODULES([XINPUT],
17- [x11] [xext] [xi >= 1.5.99.1] [inputproto >= 2.1.99.6],
18- [have_xi22="yes"],
19- [have_xi22="no"]);
20-AM_CONDITIONAL([HAVE_XI22], [test "x$have_xi22" = xyes])
21+ [x11] [xext] [xi >= 1.5.99.1] [inputproto >= 2.1.99.6])
22
23 # Check for TDD tools
24 AC_ARG_ENABLE([integration-tests],
25
26=== removed file 'include/grail-bits.h'
27--- include/grail-bits.h 2011-05-27 09:22:36 +0000
28+++ include/grail-bits.h 1970-01-01 00:00:00 +0000
29@@ -1,95 +0,0 @@
30-/*****************************************************************************
31- *
32- * grail - Gesture Recognition And Instantiation Library
33- *
34- * Copyright (C) 2010-2011 Canonical Ltd.
35- *
36- * This program is free software: you can redistribute it and/or modify it
37- * under the terms of the GNU General Public License as published by the
38- * Free Software Foundation, either version 3 of the License, or (at your
39- * option) any later version.
40- *
41- * This program is distributed in the hope that it will be useful, but
42- * WITHOUT ANY WARRANTY; without even the implied warranty of
43- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
44- * General Public License for more details.
45- *
46- * You should have received a copy of the GNU General Public License along
47- * with this program. If not, see <http://www.gnu.org/licenses/>.
48- *
49- ****************************************************************************/
50-
51-#ifndef GRAIL_BITS_H
52-#define GRAIL_BITS_H
53-
54-#ifdef __cplusplus
55-extern "C" {
56-#endif
57-
58-/* Macros that set symbol visibilities in shared libraries properly.
59- * Adapted from http://gcc.gnu.org/wiki/Visibility
60- */
61-
62-#if defined _WIN32 || defined __CYGWIN__
63- #ifdef BUILDING_GRAIL
64- #define GRAIL_PUBLIC __declspec(dllexport)
65- #else
66- #define GRAIL_PUBLIC __declspec(dllimport)
67- #endif
68- #define GRAIL_PRIVATE
69-#else
70- #if defined __GNUC__
71- #define GRAIL_PUBLIC __attribute__ ((visibility("default")))
72- #define GRAIL_PRIVATE __attribute__ ((visibility("hidden")))
73- #else
74- #pragma message ("Compiler does not support symbol visibility.")
75- #define GRAIL_PUBLIC
76- #define GRAIL_PRIVATE
77- #endif
78-#endif
79-
80-typedef unsigned char grail_mask_t;
81-
82-static inline void grail_mask_set(grail_mask_t *mask, int i)
83-{
84- mask[i >> 3] |= (1 << (i & 7));
85-}
86-
87-static inline void grail_mask_clear(grail_mask_t *mask, int i)
88-{
89- mask[i >> 3] &= ~(1 << (i & 7));
90-}
91-
92-static inline void grail_mask_modify(grail_mask_t *mask, int i, int v)
93-{
94- if (v)
95- grail_mask_set(mask, i);
96- else
97- grail_mask_clear(mask, i);
98-}
99-
100-static inline int grail_mask_get(const grail_mask_t *mask, int i)
101-{
102- return (mask[i >> 3] >> (i & 7)) & 1;
103-}
104-
105-void GRAIL_PUBLIC grail_mask_set_mask(grail_mask_t *a, const grail_mask_t *b,
106- int bytes);
107-void GRAIL_PUBLIC grail_mask_clear_mask(grail_mask_t *a, const grail_mask_t *b,
108- int bytes);
109-
110-int GRAIL_PUBLIC grail_mask_count(const grail_mask_t *mask, int bytes);
111-int GRAIL_PUBLIC grail_mask_get_first(const grail_mask_t *mask, int bytes);
112-int GRAIL_PUBLIC grail_mask_get_next(int i, const grail_mask_t *mask,
113- int bytes);
114-
115-#define grail_mask_foreach(i, mask, bytes) \
116- for (i = grail_mask_get_first(mask, bytes); \
117- i >= 0; \
118- i = grail_mask_get_next(i, mask, bytes))
119-
120-#ifdef __cplusplus
121-}
122-#endif
123-
124-#endif
125
126=== removed file 'include/grail-types.h'
127--- include/grail-types.h 2011-06-06 14:42:39 +0000
128+++ include/grail-types.h 1970-01-01 00:00:00 +0000
129@@ -1,195 +0,0 @@
130-/*****************************************************************************
131- *
132- * grail - Gesture Recognition And Instantiation Library
133- *
134- * Copyright (C) 2010-2011 Canonical Ltd.
135- *
136- * This program is free software: you can redistribute it and/or modify it
137- * under the terms of the GNU General Public License as published by the
138- * Free Software Foundation, either version 3 of the License, or (at your
139- * option) any later version.
140- *
141- * This program is distributed in the hope that it will be useful, but
142- * WITHOUT ANY WARRANTY; without even the implied warranty of
143- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
144- * General Public License for more details.
145- *
146- * You should have received a copy of the GNU General Public License along
147- * with this program. If not, see <http://www.gnu.org/licenses/>.
148- *
149- ****************************************************************************/
150-
151-#ifndef GRAIL_TYPES_H
152-#define GRAIL_TYPES_H
153-
154-#define GRAIL_TYPE_DRAG1 0 /* one-finger drag/pan/scroll */
155-#define GRAIL_TYPE_PINCH1 1 /* one-finger pinch-to-zoom */
156-#define GRAIL_TYPE_ROTATE1 2 /* one-finger rotation */
157-
158-#define GRAIL_TYPE_DRAG2 3 /* two-finger drag/pan/scroll */
159-#define GRAIL_TYPE_PINCH2 4 /* two-finger pinch-to-zoom */
160-#define GRAIL_TYPE_ROTATE2 5 /* two-finger rotation */
161-
162-#define GRAIL_TYPE_DRAG3 6 /* three-finger drag/pan */
163-#define GRAIL_TYPE_PINCH3 7 /* three-finger pinch */
164-#define GRAIL_TYPE_ROTATE3 8 /* three-finger rotate */
165-
166-#define GRAIL_TYPE_DRAG4 9 /* four-finger drag/pan */
167-#define GRAIL_TYPE_PINCH4 10 /* four-finger pinch */
168-#define GRAIL_TYPE_ROTATE4 11 /* four-finger rotate */
169-
170-#define GRAIL_TYPE_DRAG5 12 /* five-finger drag/pan */
171-#define GRAIL_TYPE_PINCH5 13 /* five-finger pinch */
172-#define GRAIL_TYPE_ROTATE5 14 /* five-finger rotate */
173-
174-#define GRAIL_TYPE_TAP1 15 /* one-finger single tap */
175-#define GRAIL_TYPE_TAP2 16 /* two-finger single tap */
176-#define GRAIL_TYPE_TAP3 17 /* three-finger single tap */
177-#define GRAIL_TYPE_TAP4 18 /* four-finger single tap */
178-#define GRAIL_TYPE_TAP5 19 /* five-finger single tap */
179-
180-#define GRAIL_TYPE_EDRAG 20 /* three-finger environment drag */
181-#define GRAIL_TYPE_EPINCH 21 /* three-finger environment drag */
182-#define GRAIL_TYPE_EROTATE 22 /* three-finger environment drag */
183-
184-#define GRAIL_TYPE_MDRAG 23 /* four-finger meta drag */
185-#define GRAIL_TYPE_MPINCH 24 /* four-finger meta drag */
186-#define GRAIL_TYPE_MROTATE 25 /* four-finger meta drag */
187-
188-#define GRAIL_TYPE_SYSFLAG1 26 /* reserved system flag */
189-
190-#define GRAIL_TYPE_TOUCH1 32 /* one-finger touch */
191-#define GRAIL_TYPE_TOUCH2 33 /* two-finger touch */
192-#define GRAIL_TYPE_TOUCH3 34 /* three-finger touch */
193-#define GRAIL_TYPE_TOUCH4 35 /* four-finger touch */
194-#define GRAIL_TYPE_TOUCH5 36 /* five-finger touch */
195-#define GRAIL_TYPE_ETOUCH 37 /* three-finger environment touch */
196-#define GRAIL_TYPE_MTOUCH 38 /* four-finger meta touch */
197-
198-#define GRAIL_MAIN_DRAG 0
199-#define GRAIL_MAIN_PINCH 1
200-#define GRAIL_MAIN_ROTATE 2
201-#define GRAIL_MAIN_TAP 3
202-#define GRAIL_MAIN_SYSFLAG 4
203-#define GRAIL_MAIN_TOUCH 5
204-
205-#define GRAIL_PROP_DRAG_DX 0 /* horizontal position delta */
206-#define GRAIL_PROP_DRAG_DY 1 /* vertical position delta */
207-#define GRAIL_PROP_DRAG_VX 2 /* horizontal velocity */
208-#define GRAIL_PROP_DRAG_VY 3 /* vertical velocity */
209-#define GRAIL_PROP_DRAG_X 4 /* horizontal position */
210-#define GRAIL_PROP_DRAG_Y 5 /* vertical position */
211-#define GRAIL_PROP_DRAG_X1 6 /* bounding box x1 */
212-#define GRAIL_PROP_DRAG_Y1 7 /* bounding box y1 */
213-#define GRAIL_PROP_DRAG_X2 8 /* bounding box x2 */
214-#define GRAIL_PROP_DRAG_Y2 9 /* bounding box y2 */
215-#define GRAIL_PROP_DRAG_ID_T0 10 /* first touch id */
216-#define GRAIL_PROP_DRAG_X_T0 11 /* first touch horizontal position */
217-#define GRAIL_PROP_DRAG_Y_T0 12 /* first touch vertical position */
218-#define GRAIL_PROP_DRAG_ID_T1 13
219-#define GRAIL_PROP_DRAG_X_T1 14
220-#define GRAIL_PROP_DRAG_Y_T1 15
221-#define GRAIL_PROP_DRAG_ID_T2 16
222-#define GRAIL_PROP_DRAG_X_T2 17
223-#define GRAIL_PROP_DRAG_Y_T2 18
224-#define GRAIL_PROP_DRAG_ID_T3 19
225-#define GRAIL_PROP_DRAG_X_T3 20
226-#define GRAIL_PROP_DRAG_Y_T3 21
227-#define GRAIL_PROP_DRAG_ID_T4 22
228-#define GRAIL_PROP_DRAG_X_T4 23
229-#define GRAIL_PROP_DRAG_Y_T4 24
230-
231-#define GRAIL_PROP_PINCH_DR 0 /* radius delta */
232-#define GRAIL_PROP_PINCH_VR 1 /* radial velocity */
233-#define GRAIL_PROP_PINCH_R 2 /* radius */
234-#define GRAIL_PROP_PINCH_X 3 /* centroid x */
235-#define GRAIL_PROP_PINCH_Y 4 /* centroid y */
236-#define GRAIL_PROP_PINCH_X1 5 /* bounding box x1 */
237-#define GRAIL_PROP_PINCH_Y1 6 /* bounding box y1 */
238-#define GRAIL_PROP_PINCH_X2 7 /* bounding box x2 */
239-#define GRAIL_PROP_PINCH_Y2 8 /* bounding box y2 */
240-#define GRAIL_PROP_PINCH_ID_T0 9 /* first touch id */
241-#define GRAIL_PROP_PINCH_X_T0 10 /* first touch horizontal position */
242-#define GRAIL_PROP_PINCH_Y_T0 11 /* first touch vertical position */
243-#define GRAIL_PROP_PINCH_ID_T1 12
244-#define GRAIL_PROP_PINCH_X_T1 13
245-#define GRAIL_PROP_PINCH_Y_T1 14
246-#define GRAIL_PROP_PINCH_ID_T2 15
247-#define GRAIL_PROP_PINCH_X_T2 16
248-#define GRAIL_PROP_PINCH_Y_T2 17
249-#define GRAIL_PROP_PINCH_ID_T3 18
250-#define GRAIL_PROP_PINCH_X_T3 19
251-#define GRAIL_PROP_PINCH_Y_T3 20
252-#define GRAIL_PROP_PINCH_ID_T4 21
253-#define GRAIL_PROP_PINCH_X_T4 22
254-#define GRAIL_PROP_PINCH_Y_T4 23
255-
256-#define GRAIL_PROP_ROTATE_DA 0 /* angle delta */
257-#define GRAIL_PROP_ROTATE_VA 1 /* angular velocity */
258-#define GRAIL_PROP_ROTATE_A 2 /* angle */
259-#define GRAIL_PROP_ROTATE_X 3 /* centroid x coordinate */
260-#define GRAIL_PROP_ROTATE_Y 4 /* centroid y coordinate */
261-#define GRAIL_PROP_ROTATE_X1 5 /* bounding box x1 */
262-#define GRAIL_PROP_ROTATE_Y1 6 /* bounding box y1 */
263-#define GRAIL_PROP_ROTATE_X2 7 /* bounding box x2 */
264-#define GRAIL_PROP_ROTATE_Y2 8 /* bounding box y2 */
265-#define GRAIL_PROP_ROTATE_ID_T0 9 /* first touch id */
266-#define GRAIL_PROP_ROTATE_X_T0 10 /* first touch horizontal position */
267-#define GRAIL_PROP_ROTATE_Y_T0 11 /* first touch vertical position */
268-#define GRAIL_PROP_ROTATE_ID_T1 12
269-#define GRAIL_PROP_ROTATE_X_T1 13
270-#define GRAIL_PROP_ROTATE_Y_T1 14
271-#define GRAIL_PROP_ROTATE_ID_T2 15
272-#define GRAIL_PROP_ROTATE_X_T2 16
273-#define GRAIL_PROP_ROTATE_Y_T2 17
274-#define GRAIL_PROP_ROTATE_ID_T3 18
275-#define GRAIL_PROP_ROTATE_X_T3 19
276-#define GRAIL_PROP_ROTATE_Y_T3 20
277-#define GRAIL_PROP_ROTATE_ID_T4 21
278-#define GRAIL_PROP_ROTATE_X_T4 22
279-#define GRAIL_PROP_ROTATE_Y_T4 23
280-
281-#define GRAIL_PROP_TAP_DT 0 /* tap time (ms) */
282-#define GRAIL_PROP_TAP_X 1 /* horizontal position */
283-#define GRAIL_PROP_TAP_Y 2 /* vertical position */
284-#define GRAIL_PROP_TAP_X1 3 /* bounding box x1 */
285-#define GRAIL_PROP_TAP_Y1 4 /* bounding box y1 */
286-#define GRAIL_PROP_TAP_X2 5 /* bounding box x2 */
287-#define GRAIL_PROP_TAP_Y2 6 /* bounding box y2 */
288-#define GRAIL_PROP_TAP_ID_T0 7 /* first touch id */
289-#define GRAIL_PROP_TAP_X_T0 8 /* first touch horizontal position */
290-#define GRAIL_PROP_TAP_Y_T0 9 /* first touch vertical position */
291-#define GRAIL_PROP_TAP_ID_T1 10
292-#define GRAIL_PROP_TAP_X_T1 11
293-#define GRAIL_PROP_TAP_Y_T1 12
294-#define GRAIL_PROP_TAP_ID_T2 13
295-#define GRAIL_PROP_TAP_X_T2 14
296-#define GRAIL_PROP_TAP_Y_T2 15
297-#define GRAIL_PROP_TAP_ID_T3 16
298-#define GRAIL_PROP_TAP_X_T3 17
299-#define GRAIL_PROP_TAP_Y_T3 18
300-#define GRAIL_PROP_TAP_ID_T4 19
301-#define GRAIL_PROP_TAP_X_T4 20
302-#define GRAIL_PROP_TAP_Y_T4 21
303-
304-#define GRAIL_PROP_TOUCH_X1 0 /* bounding box x1 */
305-#define GRAIL_PROP_TOUCH_Y1 1 /* bounding box y1 */
306-#define GRAIL_PROP_TOUCH_X2 2 /* bounding box x2 */
307-#define GRAIL_PROP_TOUCH_Y2 3 /* bounding box y2 */
308-#define GRAIL_PROP_TOUCH_ID_T0 4 /* first touch id */
309-#define GRAIL_PROP_TOUCH_X_T0 5 /* first touch horizontal position */
310-#define GRAIL_PROP_TOUCH_Y_T0 6 /* first touch vertical position */
311-#define GRAIL_PROP_TOUCH_ID_T1 7
312-#define GRAIL_PROP_TOUCH_X_T1 8
313-#define GRAIL_PROP_TOUCH_Y_T1 9
314-#define GRAIL_PROP_TOUCH_ID_T2 10
315-#define GRAIL_PROP_TOUCH_X_T2 11
316-#define GRAIL_PROP_TOUCH_Y_T2 12
317-#define GRAIL_PROP_TOUCH_ID_T3 13
318-#define GRAIL_PROP_TOUCH_X_T3 14
319-#define GRAIL_PROP_TOUCH_Y_T3 15
320-#define GRAIL_PROP_TOUCH_ID_T4 16
321-#define GRAIL_PROP_TOUCH_X_T4 17
322-#define GRAIL_PROP_TOUCH_Y_T4 18
323-
324-#endif
325
326=== removed file 'include/grail.h'
327--- include/grail.h 2011-08-30 15:10:16 +0000
328+++ include/grail.h 1970-01-01 00:00:00 +0000
329@@ -1,480 +0,0 @@
330-/*****************************************************************************
331- *
332- * grail - Gesture Recognition And Instantiation Library
333- *
334- * Copyright (C) 2010-2011 Canonical Ltd.
335- *
336- * This program is free software: you can redistribute it and/or modify it
337- * under the terms of the GNU General Public License as published by the
338- * Free Software Foundation, either version 3 of the License, or (at your
339- * option) any later version.
340- *
341- * This program is distributed in the hope that it will be useful, but
342- * WITHOUT ANY WARRANTY; without even the implied warranty of
343- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
344- * General Public License for more details.
345- *
346- * You should have received a copy of the GNU General Public License along
347- * with this program. If not, see <http://www.gnu.org/licenses/>.
348- *
349- ****************************************************************************/
350-
351-#ifndef GRAIL_H
352-#define GRAIL_H
353-
354-#include <linux/input.h>
355-#include <grail-bits.h>
356-#include <grail-types.h>
357-#include <utouch/frame.h>
358-
359-#ifdef __cplusplus
360-extern "C" {
361-#endif
362-
363-#define GRAIL_VERSION 0x00011000
364-
365-#define DIM_GRAIL_TYPE 64
366-#define DIM_GRAIL_TYPE_BYTES ((DIM_GRAIL_TYPE + 7) >> 3)
367-
368-#define DIM_GRAIL_PROP 32
369-#define DIM_GRAIL_PROP_BYTES ((DIM_GRAIL_PROP + 7) >> 3)
370-
371-#define GRAIL_STATUS_BEGIN 0
372-#define GRAIL_STATUS_UPDATE 1
373-#define GRAIL_STATUS_END 2
374-
375-#define GRAIL_EXPECT_DRAG_X 0x0001
376-#define GRAIL_EXPECT_DRAG_Y 0x0002
377-#define GRAIL_EXPECT_SCALE 0x0004
378-#define GRAIL_EXPECT_ANGLE 0x0008
379-#define GRAIL_EXPECT_MASK 0x000f
380-
381-typedef float grail_prop_t; /* gesture properties */
382-typedef utouch_frame_time_t grail_time_t; /* time in milliseconds */
383-typedef struct grail *grail_handle; /* the grail instance handle */
384-
385-/**
386- * struct grail_get_version - get grail library version
387- *
388- * Report the version of the grail library, which can be different from
389- * the value of GRAIL_VERSION in this header file.
390- *
391- * This function allows for fallback options from major interface
392- * extensions within the same ABI version. For the normal cases of ABI
393- * agnostic or backwards incompatible changes, this function is not
394- * needed.
395- */
396-unsigned int GRAIL_PUBLIC grail_get_version(void);
397-
398-/**
399- * struct grail_coord - coordinate in bounding box units
400- * @x: the horizontal position (bbox units)
401- * @y: the vertical position (bbox units)
402- */
403-struct grail_coord {
404- float x, y;
405-};
406-
407-grail_handle GRAIL_PUBLIC grail_new_raw(utouch_frame_handle fh,
408- unsigned int num_frames,
409- void *select,
410- unsigned int version,
411- unsigned int control_size,
412- unsigned int frame_size,
413- unsigned int slot_size);
414-
415-/**
416- * grail_new - allocate and initialize a new grail instance
417- * @fh: utouch frame handle to use
418- * @num_frames: number of frames in cyclic buffer
419- * @select: client selection callback
420- *
421- * Initialize the internal grail structures.
422- *
423- * Returns zero in case of failure.
424- */
425-#define grail_new(fh, num_frames, select) \
426- grail_new_raw(fh, num_frames, select, \
427- GRAIL_VERSION, \
428- sizeof(struct grail_control), \
429- sizeof(struct grail_frame), \
430- sizeof(struct grail_element))
431-
432-/**
433- * grail_delete - destroy and delete grail instance
434- * @ge: grail instance in use
435- *
436- * Deallocates all internal memory structures.
437- */
438-void GRAIL_PUBLIC grail_delete(grail_handle ge);
439-
440-/**
441- * grail_get_control - get mutable control structure
442- * @ge: the grail device in use
443- *
444- * Return the control struct of the grail instance.
445- *
446- * The control pointer is ABI agnostic, owned by the grail instance, and
447- * has grail scope.
448- */
449-struct grail_control GRAIL_PUBLIC *grail_get_control(grail_handle ge);
450-
451-/**
452- * grail_pump_frame - insert touch frames into grail
453- * @ge: the grail device in use
454- * @frame: the touch frame to insert
455- *
456- * Insert a new touch frame into the grail engine. If the frame induces a
457- * new gesture frame, a pointer to the frame is returned.
458- *
459- * The grail frame pointer is ABI agnostic, owned by the grail instance, and
460- * has grail scope.
461- */
462-const struct grail_frame GRAIL_PUBLIC *
463-grail_pump_frame(grail_handle ge, const struct utouch_frame *frame);
464-
465-/**
466- * struct grail_client_id - Gesture client information
467- * @client: Client id
468- * @root: Root window
469- * @event: Window to route events to
470- * @child: Window the event occured in
471- *
472- * This struct is treated opaquely, and only has meaning to the gesture
473- * client. Details are subject to change.
474- */
475-struct grail_client_id {
476- int client;
477- int root, event, child;
478-};
479-
480-/**
481- * struct grail_client_info - Gesture request information
482- * @id: Gesture client id
483- * @mask: Gestures the client is listening to
484- */
485-struct grail_client_info {
486- struct grail_client_id id;
487- grail_mask_t mask[DIM_GRAIL_TYPE_BYTES];
488-};
489-
490-/**
491- * struct grail_control - control parameters of grail
492- * @glue_ms: minimum time to hold activation (ms)
493- * @bar_drag_x: horizontal distance to activate (surface width fraction)
494- * @bar_drag_y: vertical distance to activate (surface height fraction)
495- * @bar_scale: minimum scaling to activate (fraction)
496- * @bar_angle: minimum angle to activate (radians)
497- * @drop_x_ms: horizontal expect timeout (ms)
498- * @drop_y_ms: vertical expect timeout (ms)
499- * @drop_scale_ms: scaling expect timeout (ms)
500- * @drop_angle_ms: rotation expect timeout (ms)
501- *
502- * The parameters are used to tune the behavior of the gesture recognition.
503- *
504- * The moveness is a number between zero and one denoting the
505- * character of the current transform. Zero means pure rotate and
506- * scale, one means pure drag.
507- *
508- * Later versions of this struct may grow in size, but will remain
509- * binary compatible with older versions.
510- */
511-struct grail_control {
512- float glue_ms;
513- float bar_drag_x;
514- float bar_drag_y;
515- float bar_scale;
516- float bar_angle;
517- float drop_x_ms;
518- float drop_y_ms;
519- float drop_scale_ms;
520- float drop_angle_ms;
521-};
522-
523-/**
524- * struct grail_frame - frame of ongoing elementary transformations
525- * @prev: pointer to the previous gesture frame
526- * @touch: pointer to the touch frame triggering this gesture frame
527- * @num_ongoing: number of elements in the ongoing array
528- * @ongoing: array of ongoing transformation elements
529- * @slots: array of all transformation slots
530- *
531- * A gesture frame consists of one or several touch frames glued
532- * together into a stable transition, combined with information on
533- * ongoing elementary gestural transformations. The array of ongoing
534- * elements contains all elements with a nonzero expect mask.
535- *
536- * Later versions of this struct may grow in size, but will remain
537- * binary compatible with older versions.
538- */
539-struct grail_frame {
540- const struct grail_frame *prev;
541- const struct utouch_frame *touch;
542- unsigned int num_ongoing;
543- struct grail_element **ongoing;
544- struct grail_element **slots;
545-};
546-
547-/**
548- * struct grail_element - elementary gesture transformation
549- * @prev: respective element of previous frame
550- * @slot: the transformation slot occupied by this element
551- * @id: unique identifier of the ongoing transformation
552- * @num_touches: number of contacts of this element
553- * @touches: array of contacts of this element
554- * @start_time: start time of this element
555- * @expect_mask: bitmask of expected gestures (grail main types)
556- * @active_mask: bitmask of activated gestures (grail main types)
557- * @center: gesture center position (surface units)
558- * @velocity: current center velocity (surface units per second)
559- * @radius: gesture radius from center (surface units)
560- * @transform: the transformation matrix of the gesture
561- * @rotation_center: current instant center of rotation (surface units)
562- * @drag: accumulated transformation displacement (surface units)
563- * @scale: accumulated scale (dimensionless)
564- * @angle: accumulated rotation angle (radians)
565- *
566- * The grail element describes the ongoing gestural transformation of
567- * a particular set of contacts. The expect mask describes which
568- * gestural transformations may become active during the course of
569- * events, and the active mask describes which have passed their
570- * respective activation threshold. The set of expected gestures can
571- * change over time, for instance by exclusion or timeout.
572- *
573- * Applications handling rotation, either by transformation matrix or
574- * angle, should use the drag displacement. For other applications,
575- * the center displacement may be used instead, as to not lose
576- * movement accuracy.
577- *
578- * Later versions of this struct may grow in size, but will remain
579- * binary compatible with older versions.
580- */
581-struct grail_element {
582- const struct grail_element *prev;
583- int slot;
584- int id;
585- int num_touches;
586- const struct utouch_contact **touches;
587- grail_time_t start_time;
588- unsigned int expect_mask;
589- unsigned int active_mask;
590- struct grail_coord center;
591- struct grail_coord velocity;
592- float radius2;
593- float transform[6];
594- struct grail_coord rotation_center;
595- struct grail_coord drag;
596- float scale2;
597- float angle;
598-};
599-
600-/**
601- * grail_element_transform - transform coordinates using element
602- * @slot: the transformation element to use
603- * @q: the grail coordinate to fill
604- * @x: the grail coordinate to transform
605- *
606- * Performs the 3x3 transform *q = T *p, where T is the element
607- * transform.
608- */
609-static inline void grail_element_transform(const struct grail_element *slot,
610- struct grail_coord *q,
611- const struct grail_coord *p)
612-{
613- const float *T = slot->transform;
614- q->x = T[0] * (p->x - slot->center.x) +
615- T[1] * (p->y - slot->center.y) +
616- T[2] + slot->center.x;
617- q->y = T[3] * (p->x - slot->center.x) +
618- T[4] * (p->y - slot->center.y) +
619- T[5] + slot->center.y;
620-}
621-
622-/**
623- * struct grail_event - Gesture event
624- * @type: The gesture type
625- * @id: Unique identifier foof the gesture instance
626- * @status: Gesture status (begin, update, end)
627- * @ntouch: Number of current touches
628- * @nprop: Number of properties in the gesture
629- * @pos: Focus point of the gesture (bbox coordinates)
630- * @touch: Array of individual touch information
631- * @client_id: The gesture client to route the gesture to
632- * @time: Time of event (milliseconds)
633- * @prop: Array of properties of the event
634- *
635- * Gesture events are passed to the client via the gesture() callback.
636- */
637-struct grail_event {
638- int type;
639- int id;
640- int status;
641- int ntouch;
642- int nprop;
643- struct grail_coord pos;
644- struct grail_client_id client_id;
645- grail_time_t time;
646- grail_prop_t prop[DIM_GRAIL_PROP];
647-};
648-
649-/**
650- * struct grail - Main grail device
651- * @get_clients: Called at the onset of new gestures to retrieve the list
652- * of listening clients.
653- * @event: Callback for kernel events passing through grail.
654- * @gesture: Main gesture callback.
655- * @impl: Grail implementation details.
656- * @gin: Gesture instatiation details.
657- * @gru: Gesture recognition details.
658- * @priv: Generic pointer to user-defined content.
659- *
660- * The grail device pulls events from the underlying device, detects
661- * gestures, and passes them on to the client via the gesture()
662- * callback. Events that are not gesture or for other reasons held back are
663- * passed on via the event() callback. The user provides information about
664- * windows and listening clients via the get_clients callback, which is
665- * called during gesture instantiation.
666- *
667- */
668-struct grail {
669- int (*get_clients)(struct grail *ge,
670- struct grail_client_info *client, int max_clients,
671- const struct grail_coord *coords, int num_coords,
672- const grail_mask_t *types, int type_bytes);
673- void (*event)(struct grail *ge,
674- const struct input_event *ev);
675- void (*gesture)(struct grail *ge,
676- const struct grail_event *ev);
677- struct grail_impl *impl;
678- struct gesture_inserter *gin;
679- struct gesture_recognizer *gru;
680- void *priv;
681-};
682-
683-/**
684- * grail_open - open a grail device
685- * @ge: the grail device to open
686- * @fd: file descriptor of the kernel device
687- *
688- * Initialize the internal grail structures and configure it by reading the
689- * protocol capabilities through the file descriptor.
690- *
691- * The callbacks, parameters and priv pointer should be set prior to this
692- * call.
693- *
694- * Returns zero on success, negative error number otherwise.
695- */
696-int GRAIL_PUBLIC grail_open(struct grail *ge, int fd);
697-
698-/**
699- * grail_idle - check state of kernel device
700- * @ge: the grail device in use
701- * @fd: file descriptor of the kernel device
702- * @ms: number of milliseconds to wait for activity
703- *
704- * Returns true if the device is idle, i.e., there are no fetched
705- * events in the pipe and there is nothing to fetch from the device.
706- */
707-int GRAIL_PUBLIC grail_idle(struct grail *ge, int fd, int ms);
708-
709-/**
710- * grail_pull - pull and process available events from the kernel device
711- * @ge: the grail device in use
712- * @fd: file descriptor of the kernel device
713- *
714- * Pull all available events and process them. The grail callbacks are
715- * invoked during this call.
716- *
717- * The underlying file descriptor must have O_NONBLOCK set, or this method
718- * will not return until the file is closed.
719- *
720- * On success, returns the number of events read. Otherwise,
721- * a standard negative error number is returned.
722- */
723-int GRAIL_PUBLIC grail_pull(struct grail *ge, int fd);
724-
725-/**
726- * grail_close - close the grail device
727- * @ge: the grail device to close
728- * @fd: file descriptor of the kernel device
729- *
730- * Deallocates all memory associated with grail, and clears the grail
731- * structure.
732- */
733-void GRAIL_PUBLIC grail_close(struct grail *ge, int fd);
734-
735-/**
736- * grail_set_bbox - set the grail unit bounding box
737- * @ge: the grail device in use
738- * @min: the minimum (lower-left) corner of the bounding box
739- * @max: the maximum (upper-right) corner of the bounding box
740- *
741- * Sets the box within which the device coordinates should be presented.
742- */
743-void GRAIL_PUBLIC grail_set_bbox(struct grail *ge,
744- const struct grail_coord *min,
745- const struct grail_coord *max);
746-
747-/**
748- * grail_get_units - get device coordinate ranges
749- * @ge: the grail device in use
750- * @min: minimum x and y coordinates
751- * @max: maximum x and y coordinates
752- *
753- * The grail event attributes pos, touch_major, touch_minor,
754- * width_major, and width_minor are all given in device coordinate
755- * units, unless specified otherwise using the grail_set_bbox()
756- * function. This function reports the device coordinate ranges.
757- *
758- */
759-void GRAIL_PUBLIC grail_get_units(const struct grail *ge,
760- struct grail_coord *min, struct grail_coord *max);
761-
762-/**
763- * grail_get_contact_frame - get current contact frame
764- * @ge: the grail device in use
765- *
766- * Return the contact frame current being processed. If called from
767- * within a gesture callback, it is guaranteed to return the frame
768- * corresponding to the gesture.
769- *
770- * The returned pointer can be NULL if no input has yet been extracted
771- * through the grail instance.
772- *
773- * The frame pointer is ABI agnostic, owned by the grail instance, and
774- * has grail scope.
775- */
776-const struct utouch_frame GRAIL_PUBLIC *
777-grail_get_contact_frame(const struct grail *ge);
778-
779-#ifndef GRAIL_NO_LEGACY_API
780-
781-struct grail_contact {
782- int id;
783- int tool_type;
784- struct grail_coord pos;
785- float touch_major;
786- float touch_minor;
787- float width_major;
788- float width_minor;
789- float angle;
790- float pressure;
791-};
792-
793-void GRAIL_PUBLIC grail_filter_abs_events(struct grail *ge, int usage);
794-
795-int GRAIL_PUBLIC grail_get_contacts(const struct grail *ge,
796- struct grail_contact *touch, int max_touch);
797-
798-#endif
799-
800-void GRAIL_PUBLIC grail_set_coordinate_transform_callback(struct grail *ge,
801- utouch_coordinate_transform_cb callback,
802- void *user_data);
803-
804-
805-#ifdef __cplusplus
806-}
807-#endif
808-
809-#endif
810
811=== modified file 'src/Makefile.am'
812--- src/Makefile.am 2012-03-29 18:02:09 +0000
813+++ src/Makefile.am 2012-05-09 17:32:19 +0000
814@@ -1,5 +1,3 @@
815-AUTOMAKE_OPTIONS = subdir-objects
816-
817 lib_LTLIBRARIES = libutouch-grail.la
818 version_script = $(srcdir)/libutouch-grail.ver
819
820@@ -20,69 +18,34 @@
821 $(COVERAGE_LIBS) \
822 -lm
823
824-v2dir = v2
825 libutouch_grail_la_SOURCES = \
826- v2/evbuf.h \
827- v2/gebuf.h \
828- v2/grailbuf.h \
829- v2/grail-bits.c \
830- v2/grail-inserter.c \
831- v2/grail-inserter.h \
832- v2/grail-gestures.c \
833- v2/grail-gestures.h \
834- v2/gestures-touch.c \
835- v2/gestures-drag.c \
836- v2/gestures-pinch.c \
837- v2/gestures-rotate.c \
838- v2/gestures-tapping.c \
839- v2/grail-recognizer.c \
840- v2/grail-recognizer.h \
841- v2/grail-event.c \
842- v2/grail-impl.h \
843- v2/grail-api.c \
844- v2/grail-legacy.c \
845- v2/grail-init.c \
846- v2/grail-frame.c
847-
848-if HAVE_XI22
849-v3dir = v3
850-libutouch_grail_la_SOURCES += \
851- v3/atomic-recognizer.cpp \
852- v3/atomic-recognizer.h \
853- v3/event.cpp \
854- v3/event.h \
855- v3/forward.h \
856- v3/gesture.cpp \
857- v3/gesture.h \
858- v3/handle.cpp \
859- v3/handle.h \
860- v3/log.cpp \
861- v3/log.h \
862- v3/recognizer.cpp \
863- v3/recognizer.h \
864- v3/regular-recognizer.cpp \
865- v3/regular-recognizer.h \
866- v3/slice.cpp \
867- v3/slice.h \
868- v3/subscription.cpp \
869- v3/subscription.h \
870- v3/touch.cpp \
871- v3/touch.h
872-endif
873+ atomic-recognizer.cpp \
874+ atomic-recognizer.h \
875+ event.cpp \
876+ event.h \
877+ forward.h \
878+ gesture.cpp \
879+ gesture.h \
880+ handle.cpp \
881+ handle.h \
882+ log.cpp \
883+ log.h \
884+ recognizer.cpp \
885+ recognizer.h \
886+ regular-recognizer.cpp \
887+ regular-recognizer.h \
888+ slice.cpp \
889+ slice.h \
890+ subscription.cpp \
891+ subscription.h \
892+ touch.cpp \
893+ touch.h
894
895 INCLUDES = -I$(top_srcdir)/include/ $(FRAME_CFLAGS)
896
897-libutouch_grailincludedir = $(includedir)
898-libutouch_grailinclude_HEADERS = \
899- $(top_srcdir)/include/grail-bits.h \
900- $(top_srcdir)/include/grail-types.h \
901- $(top_srcdir)/include/grail.h
902-
903-if HAVE_XI22
904-libutouch_grail_v3includedir = $(includedir)/utouch
905-libutouch_grail_v3include_HEADERS = \
906+libutouch_grail_includedir = $(includedir)/utouch
907+libutouch_grail_include_HEADERS = \
908 $(top_srcdir)/include/utouch/grail.h
909-endif
910
911 EXTRA_DIST = $(version_script)
912
913
914=== renamed file 'src/v3/atomic-recognizer.cpp' => 'src/atomic-recognizer.cpp'
915--- src/v3/atomic-recognizer.cpp 2012-04-03 14:24:54 +0000
916+++ src/atomic-recognizer.cpp 2012-05-09 17:32:19 +0000
917@@ -18,7 +18,7 @@
918 *
919 ****************************************************************************/
920
921-#include "v3/atomic-recognizer.h"
922+#include "atomic-recognizer.h"
923
924 #include <algorithm>
925 #include <cassert>
926@@ -29,10 +29,10 @@
927 #include <utouch/frame.h>
928 #include <utouch/frame_x11.h>
929
930-#include "v3/handle.h"
931-#include "v3/gesture.h"
932-#include "v3/log.h"
933-#include "v3/touch.h"
934+#include "handle.h"
935+#include "gesture.h"
936+#include "log.h"
937+#include "touch.h"
938
939 namespace {
940 const uint64_t MAX_TOUCHES_FOR_GESTURES = 5;
941
942=== renamed file 'src/v3/atomic-recognizer.h' => 'src/atomic-recognizer.h'
943--- src/v3/atomic-recognizer.h 2012-04-03 14:24:54 +0000
944+++ src/atomic-recognizer.h 2012-05-09 17:32:19 +0000
945@@ -21,7 +21,7 @@
946 #ifndef UTOUCH_GRAIL_ATOMIC_RECOGNIZER_H_
947 #define UTOUCH_GRAIL_ATOMIC_RECOGNIZER_H_
948
949-#include "v3/recognizer.h"
950+#include "recognizer.h"
951
952 namespace utouch {
953 namespace grail {
954
955=== renamed file 'src/v3/event.cpp' => 'src/event.cpp'
956--- src/v3/event.cpp 2012-03-26 12:57:55 +0000
957+++ src/event.cpp 2012-05-09 17:32:19 +0000
958@@ -18,11 +18,11 @@
959 *
960 ****************************************************************************/
961
962-#include "v3/event.h"
963+#include "event.h"
964
965 #include <cassert>
966
967-#include "v3/slice.h"
968+#include "slice.h"
969
970 namespace utouch {
971 namespace grail {
972
973=== renamed file 'src/v3/event.h' => 'src/event.h'
974--- src/v3/event.h 2012-03-26 12:57:55 +0000
975+++ src/event.h 2012-05-09 17:32:19 +0000
976@@ -25,7 +25,7 @@
977 #include <memory>
978
979 #include "utouch/grail.h"
980-#include "v3/forward.h"
981+#include "forward.h"
982
983 struct UGEvent_ {};
984
985
986=== renamed file 'src/v3/forward.h' => 'src/forward.h'
987=== renamed file 'src/v3/gesture.cpp' => 'src/gesture.cpp'
988--- src/v3/gesture.cpp 2012-03-26 19:29:08 +0000
989+++ src/gesture.cpp 2012-05-09 17:32:19 +0000
990@@ -18,19 +18,19 @@
991 *
992 ****************************************************************************/
993
994-#include "v3/gesture.h"
995+#include "gesture.h"
996
997 #include <cstdio>
998 #include <stdexcept>
999
1000 #include "utouch/grail.h"
1001
1002-#include "v3/event.h"
1003-#include "v3/handle.h"
1004-#include "v3/log.h"
1005-#include "v3/recognizer.h"
1006-#include "v3/slice.h"
1007-#include "v3/touch.h"
1008+#include "event.h"
1009+#include "handle.h"
1010+#include "log.h"
1011+#include "recognizer.h"
1012+#include "slice.h"
1013+#include "touch.h"
1014
1015 namespace utouch {
1016 namespace grail {
1017
1018=== renamed file 'src/v3/gesture.h' => 'src/gesture.h'
1019--- src/v3/gesture.h 2012-03-27 15:52:30 +0000
1020+++ src/gesture.h 2012-05-09 17:32:19 +0000
1021@@ -29,7 +29,7 @@
1022 #include <utouch/frame.h>
1023
1024 #include "utouch/grail.h"
1025-#include "v3/forward.h"
1026+#include "forward.h"
1027
1028 namespace utouch {
1029 namespace grail {
1030
1031=== renamed file 'src/v3/handle.cpp' => 'src/handle.cpp'
1032--- src/v3/handle.cpp 2012-03-26 12:57:55 +0000
1033+++ src/handle.cpp 2012-05-09 17:32:19 +0000
1034@@ -18,7 +18,7 @@
1035 *
1036 ****************************************************************************/
1037
1038-#include "v3/handle.h"
1039+#include "handle.h"
1040
1041 #include <sys/eventfd.h>
1042 #include <unistd.h>
1043@@ -31,11 +31,11 @@
1044
1045 #include <utouch/frame_x11.h>
1046
1047-#include "v3/atomic-recognizer.h"
1048-#include "v3/event.h"
1049-#include "v3/log.h"
1050-#include "v3/regular-recognizer.h"
1051-#include "v3/subscription.h"
1052+#include "atomic-recognizer.h"
1053+#include "event.h"
1054+#include "log.h"
1055+#include "regular-recognizer.h"
1056+#include "subscription.h"
1057
1058 namespace utouch {
1059 namespace grail {
1060
1061=== renamed file 'src/v3/handle.h' => 'src/handle.h'
1062--- src/v3/handle.h 2012-03-26 12:57:55 +0000
1063+++ src/handle.h 2012-05-09 17:32:19 +0000
1064@@ -29,7 +29,7 @@
1065 #include <X11/X.h>
1066
1067 #include "utouch/grail.h"
1068-#include "v3/forward.h"
1069+#include "forward.h"
1070
1071 struct UGHandle_ {};
1072
1073
1074=== modified file 'src/libutouch-grail.ver'
1075--- src/libutouch-grail.ver 2012-01-25 17:49:58 +0000
1076+++ src/libutouch-grail.ver 2012-05-09 17:32:19 +0000
1077@@ -1,30 +1,3 @@
1078-UTOUCH_GRAIL_2.0 {
1079- global:
1080- grail_close;
1081- grail_delete;
1082- grail_filter_abs_events;
1083- grail_get_contact_frame;
1084- grail_get_contacts;
1085- grail_get_control;
1086- grail_get_units;
1087- grail_get_version;
1088- grail_idle;
1089- grail_mask_clear_mask;
1090- grail_mask_count;
1091- grail_mask_get_first;
1092- grail_mask_get_next;
1093- grail_mask_set_mask;
1094- grail_new_raw;
1095- grail_open;
1096- grail_pull;
1097- grail_pump_frame;
1098- grail_set_bbox;
1099- grail_set_coordinate_transform_callback;
1100-
1101- local:
1102- *;
1103-};
1104-
1105 UTOUCH_GRAIL_3.0 {
1106 global:
1107 grail_accept_gesture;
1108@@ -63,4 +36,7 @@
1109 grail_subscription_new;
1110 grail_subscription_set_property;
1111 grail_update_time;
1112-} UTOUCH_GRAIL_2.0;
1113+
1114+ local:
1115+ *;
1116+};
1117
1118=== renamed file 'src/v3/log.cpp' => 'src/log.cpp'
1119--- src/v3/log.cpp 2012-03-26 12:57:55 +0000
1120+++ src/log.cpp 2012-05-09 17:32:19 +0000
1121@@ -18,7 +18,7 @@
1122 *
1123 ****************************************************************************/
1124
1125-#include "v3/log.h"
1126+#include "log.h"
1127
1128 #include <cstdlib>
1129
1130
1131=== renamed file 'src/v3/log.h' => 'src/log.h'
1132=== renamed file 'src/v3/recognizer.cpp' => 'src/recognizer.cpp'
1133--- src/v3/recognizer.cpp 2012-04-03 14:22:54 +0000
1134+++ src/recognizer.cpp 2012-05-09 17:32:19 +0000
1135@@ -18,7 +18,7 @@
1136 *
1137 ****************************************************************************/
1138
1139-#include "v3/recognizer.h"
1140+#include "recognizer.h"
1141
1142 #include <algorithm>
1143 #include <cassert>
1144@@ -29,10 +29,10 @@
1145 #include <utouch/frame.h>
1146 #include <utouch/frame_x11.h>
1147
1148-#include "v3/handle.h"
1149-#include "v3/gesture.h"
1150-#include "v3/log.h"
1151-#include "v3/touch.h"
1152+#include "handle.h"
1153+#include "gesture.h"
1154+#include "log.h"
1155+#include "touch.h"
1156
1157 namespace utouch {
1158 namespace grail {
1159
1160=== renamed file 'src/v3/recognizer.h' => 'src/recognizer.h'
1161--- src/v3/recognizer.h 2012-04-03 14:24:54 +0000
1162+++ src/recognizer.h 2012-05-09 17:32:19 +0000
1163@@ -29,8 +29,8 @@
1164 #include <utouch/frame.h>
1165
1166 #include "utouch/grail.h"
1167-#include "v3/forward.h"
1168-#include "v3/subscription.h"
1169+#include "forward.h"
1170+#include "subscription.h"
1171
1172 #define INSERT_TOUCH(touch, map) \
1173 { \
1174
1175=== renamed file 'src/v3/regular-recognizer.cpp' => 'src/regular-recognizer.cpp'
1176--- src/v3/regular-recognizer.cpp 2012-04-03 14:24:54 +0000
1177+++ src/regular-recognizer.cpp 2012-05-09 17:32:19 +0000
1178@@ -18,7 +18,7 @@
1179 *
1180 ****************************************************************************/
1181
1182-#include "v3/regular-recognizer.h"
1183+#include "regular-recognizer.h"
1184
1185 #include <algorithm>
1186 #include <cassert>
1187@@ -29,10 +29,10 @@
1188 #include <utouch/frame.h>
1189 #include <utouch/frame_x11.h>
1190
1191-#include "v3/handle.h"
1192-#include "v3/gesture.h"
1193-#include "v3/log.h"
1194-#include "v3/touch.h"
1195+#include "handle.h"
1196+#include "gesture.h"
1197+#include "log.h"
1198+#include "touch.h"
1199
1200 namespace utouch {
1201 namespace grail {
1202
1203=== renamed file 'src/v3/regular-recognizer.h' => 'src/regular-recognizer.h'
1204--- src/v3/regular-recognizer.h 2012-04-03 14:24:54 +0000
1205+++ src/regular-recognizer.h 2012-05-09 17:32:19 +0000
1206@@ -21,7 +21,7 @@
1207 #ifndef UTOUCH_GRAIL_REGULAR_RECOGNIZER_H_
1208 #define UTOUCH_GRAIL_REGULAR_RECOGNIZER_H_
1209
1210-#include "v3/recognizer.h"
1211+#include "recognizer.h"
1212
1213 namespace utouch {
1214 namespace grail {
1215
1216=== renamed file 'src/v3/slice.cpp' => 'src/slice.cpp'
1217--- src/v3/slice.cpp 2012-03-26 19:29:08 +0000
1218+++ src/slice.cpp 2012-05-09 17:32:19 +0000
1219@@ -18,7 +18,7 @@
1220 *
1221 ****************************************************************************/
1222
1223-#include "v3/slice.h"
1224+#include "slice.h"
1225
1226 #include <cassert>
1227 #include <cmath>
1228@@ -28,11 +28,11 @@
1229
1230 #include <utouch/frame.h>
1231
1232-#include "v3/gesture.h"
1233-#include "v3/log.h"
1234-#include "v3/recognizer.h"
1235-#include "v3/subscription.h"
1236-#include "v3/touch.h"
1237+#include "gesture.h"
1238+#include "log.h"
1239+#include "recognizer.h"
1240+#include "subscription.h"
1241+#include "touch.h"
1242
1243 namespace {
1244
1245
1246=== renamed file 'src/v3/slice.h' => 'src/slice.h'
1247--- src/v3/slice.h 2012-03-26 19:29:08 +0000
1248+++ src/slice.h 2012-05-09 17:32:19 +0000
1249@@ -25,7 +25,7 @@
1250 #include <set>
1251
1252 #include "utouch/grail.h"
1253-#include "v3/forward.h"
1254+#include "forward.h"
1255
1256 struct UGSlice_ {};
1257
1258
1259=== renamed file 'src/v3/subscription.cpp' => 'src/subscription.cpp'
1260--- src/v3/subscription.cpp 2012-03-26 12:57:55 +0000
1261+++ src/subscription.cpp 2012-05-09 17:32:19 +0000
1262@@ -18,7 +18,7 @@
1263 *
1264 ****************************************************************************/
1265
1266-#include "v3/subscription.h"
1267+#include "subscription.h"
1268
1269 #include <cmath>
1270
1271
1272=== renamed file 'src/v3/subscription.h' => 'src/subscription.h'
1273--- src/v3/subscription.h 2012-03-26 12:57:55 +0000
1274+++ src/subscription.h 2012-05-09 17:32:19 +0000
1275@@ -24,7 +24,7 @@
1276 #include <X11/X.h>
1277
1278 #include "utouch/grail.h"
1279-#include "v3/forward.h"
1280+#include "forward.h"
1281
1282 struct UGSubscription_ {};
1283
1284
1285=== renamed file 'src/v3/touch.cpp' => 'src/touch.cpp'
1286--- src/v3/touch.cpp 2012-03-27 15:52:30 +0000
1287+++ src/touch.cpp 2012-05-09 17:32:19 +0000
1288@@ -18,11 +18,11 @@
1289 *
1290 ****************************************************************************/
1291
1292-#include "v3/touch.h"
1293+#include "touch.h"
1294
1295 #include <utouch/frame_x11.h>
1296
1297-#include "v3/log.h"
1298+#include "log.h"
1299
1300 namespace utouch {
1301 namespace grail {
1302
1303=== renamed file 'src/v3/touch.h' => 'src/touch.h'
1304=== removed directory 'src/v2'
1305=== removed file 'src/v2/evbuf.h'
1306--- src/v2/evbuf.h 2012-03-26 12:57:55 +0000
1307+++ src/v2/evbuf.h 1970-01-01 00:00:00 +0000
1308@@ -1,56 +0,0 @@
1309-/*****************************************************************************
1310- *
1311- * grail - Gesture Recognition And Instantiation Library
1312- *
1313- * Copyright (C) 2010-2012 Canonical Ltd.
1314- *
1315- * This library is free software: you can redistribute it and/or modify it
1316- * under the terms of the GNU Lesser General Public License version 3
1317- * as published by the Free Software Foundation.
1318- *
1319- * This library is distributed in the hope that it will be useful, but
1320- * WITHOUT ANY WARRANTY; without even the implied warranties of
1321- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1322- * PURPOSE. See the GNU Lesser General Public License for more details.
1323- *
1324- * You should have received a copy of the GNU Lesser General Public License
1325- * along with this library. If not, see <http://www.gnu.org/licenses/>.
1326- *
1327- ****************************************************************************/
1328-
1329-#ifndef GRAIL_EVBUF_H
1330-#define GRAIL_EVBUF_H
1331-
1332-#define DIM_EVENTS 4096
1333-
1334-struct evbuf {
1335- int head;
1336- int tail;
1337- struct input_event buffer[DIM_EVENTS];
1338-};
1339-
1340-static inline void evbuf_clear(struct evbuf *evbuf)
1341-{
1342- evbuf->head = evbuf->tail = 0;
1343-}
1344-
1345-static inline int evbuf_empty(const struct evbuf *evbuf)
1346-{
1347- return evbuf->head == evbuf->tail;
1348-}
1349-
1350-static inline void evbuf_put(struct evbuf *evbuf,
1351- const struct input_event *ev)
1352-{
1353- evbuf->buffer[evbuf->head++] = *ev;
1354- evbuf->head &= DIM_EVENTS - 1;
1355-}
1356-
1357-static inline void evbuf_get(struct evbuf *evbuf,
1358- struct input_event *ev)
1359-{
1360- *ev = evbuf->buffer[evbuf->tail++];
1361- evbuf->tail &= DIM_EVENTS - 1;
1362-}
1363-
1364-#endif
1365
1366=== removed file 'src/v2/gebuf.h'
1367--- src/v2/gebuf.h 2012-03-26 12:57:55 +0000
1368+++ src/v2/gebuf.h 1970-01-01 00:00:00 +0000
1369@@ -1,67 +0,0 @@
1370-/*****************************************************************************
1371- *
1372- * grail - Gesture Recognition And Instantiation Library
1373- *
1374- * Copyright (C) 2010-2012 Canonical Ltd.
1375- *
1376- * This library is free software: you can redistribute it and/or modify it
1377- * under the terms of the GNU Lesser General Public License version 3
1378- * as published by the Free Software Foundation.
1379- *
1380- * This library is distributed in the hope that it will be useful, but
1381- * WITHOUT ANY WARRANTY; without even the implied warranties of
1382- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1383- * PURPOSE. See the GNU Lesser General Public License for more details.
1384- *
1385- * You should have received a copy of the GNU Lesser General Public License
1386- * along with this library. If not, see <http://www.gnu.org/licenses/>.
1387- *
1388- ****************************************************************************/
1389-
1390-#ifndef GRAIL_GESTURE_BUFFER_H
1391-#define GRAIL_GESTURE_BUFFER_H
1392-
1393-#include "grail-impl.h"
1394-
1395-#define DIM_GESTURE_EVENTS 512
1396-
1397-struct gesture_event {
1398- int status;
1399- int ntouch;
1400- int nprop;
1401- utouch_frame_time_t time;
1402- struct grail_coord pos;
1403- grail_prop_t prop[DIM_GRAIL_PROP];
1404-};
1405-
1406-struct gebuf {
1407- int head;
1408- int tail;
1409- struct gesture_event buffer[DIM_GESTURE_EVENTS];
1410-};
1411-
1412-static inline void gebuf_clear(struct gebuf *gebuf)
1413-{
1414- gebuf->head = gebuf->tail = 0;
1415-}
1416-
1417-static inline int gebuf_empty(const struct gebuf *gebuf)
1418-{
1419- return gebuf->head == gebuf->tail;
1420-}
1421-
1422-static inline void gebuf_put(struct gebuf *gebuf,
1423- const struct gesture_event *ev)
1424-{
1425- gebuf->buffer[gebuf->head++] = *ev;
1426- gebuf->head &= DIM_GESTURE_EVENTS - 1;
1427-}
1428-
1429-static inline void gebuf_get(struct gebuf *gebuf,
1430- struct gesture_event *ev)
1431-{
1432- *ev = gebuf->buffer[gebuf->tail++];
1433- gebuf->tail &= DIM_GESTURE_EVENTS - 1;
1434-}
1435-
1436-#endif
1437
1438=== removed file 'src/v2/gestures-drag.c'
1439--- src/v2/gestures-drag.c 2012-03-26 12:57:55 +0000
1440+++ src/v2/gestures-drag.c 1970-01-01 00:00:00 +0000
1441@@ -1,134 +0,0 @@
1442-/*****************************************************************************
1443- *
1444- * grail - Gesture Recognition And Instantiation Library
1445- *
1446- * Copyright (C) 2010-2013 Canonical Ltd.
1447- *
1448- * This library is free software: you can redistribute it and/or modify it
1449- * under the terms of the GNU Lesser General Public License version 3
1450- * as published by the Free Software Foundation.
1451- *
1452- * This library is distributed in the hope that it will be useful, but
1453- * WITHOUT ANY WARRANTY; without even the implied warranties of
1454- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1455- * PURPOSE. See the GNU Lesser General Public License for more details.
1456- *
1457- * You should have received a copy of the GNU Lesser General Public License
1458- * along with this library. If not, see <http://www.gnu.org/licenses/>.
1459- *
1460- ****************************************************************************/
1461-
1462-#include "grail-recognizer.h"
1463-#include <math.h>
1464-#include <stdio.h>
1465-
1466-static const int getype[DIM_TOUCH + 1] = {
1467- -1,
1468- GRAIL_TYPE_DRAG1,
1469- GRAIL_TYPE_DRAG2,
1470- GRAIL_TYPE_DRAG3,
1471- GRAIL_TYPE_DRAG4,
1472- GRAIL_TYPE_DRAG5,
1473-};
1474-
1475-static void set_props(const struct gesture_inserter *gin,
1476- struct combo_model *s, const struct move_model *m,
1477- const struct utouch_frame *frame)
1478-{
1479- if (m->single) {
1480- s->prop[GRAIL_PROP_DRAG_DX] = m->fm[FM_X].raw_delta;
1481- s->prop[GRAIL_PROP_DRAG_DY] = m->fm[FM_Y].raw_delta;
1482- } else {
1483- s->prop[GRAIL_PROP_DRAG_DX] = m->fm[FM_X].action_delta;
1484- s->prop[GRAIL_PROP_DRAG_DY] = m->fm[FM_Y].action_delta;
1485- }
1486- s->prop[GRAIL_PROP_DRAG_VX] = m->fm[FM_X].velocity;
1487- s->prop[GRAIL_PROP_DRAG_VY] = m->fm[FM_Y].velocity;
1488- s->prop[GRAIL_PROP_DRAG_X] = m->fm[FM_X].value;
1489- s->prop[GRAIL_PROP_DRAG_Y] = m->fm[FM_Y].value;
1490- s->nprop = 6;
1491- s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame);
1492-}
1493-
1494-static const int fm_mask = 0x03;
1495-
1496-int gru_drag(struct grail *ge,
1497- const struct utouch_frame *frame)
1498-{
1499- struct gesture_recognizer *gru = ge->gru;
1500- struct combo_model *state = &gru->drag;
1501- struct move_model *move = &gru->move;
1502- int mask = state->active ? (move->active & fm_mask) : fm_mask;
1503- if (!move->multi && !move->single) {
1504- if (state->active) {
1505- gru_end(ge, state->gid, move,
1506- state->prop, state->nprop);
1507- state->active = 0;
1508- }
1509- }
1510- if ((move->timeout & fm_mask) == fm_mask) {
1511- if (state->active) {
1512- gin_gid_timeout(ge, state->gid);
1513- }
1514- }
1515- if (!state->active) {
1516- int type = getype[move->ntouch];
1517- if (type < 0)
1518- return 0;
1519- state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame);
1520- state->active = 1;
1521- }
1522- if (!(move->tickle & mask))
1523- return 0;
1524- if (!(move->active & fm_mask))
1525- return 0;
1526- set_props(ge->gin, state, move, frame);
1527- gru_event(ge, state->gid, move, state->prop, state->nprop);
1528- return 1;
1529-}
1530-
1531-int gru_windrag(struct grail *ge,
1532- const struct utouch_frame *frame)
1533-{
1534- struct gesture_recognizer *gru = ge->gru;
1535- struct combo_model *state = &gru->windrag;
1536- struct move_model *move = &gru->move;
1537- int mask = state->active ? (move->active & fm_mask) : fm_mask;
1538- if (!move->multi && !move->single) {
1539- if (state->active && out_of_bounds(state, move)) {
1540- gru_end(ge, state->gid, move,
1541- state->prop, state->nprop);
1542- state->active = 0;
1543- }
1544- }
1545- if ((move->timeout & fm_mask) == fm_mask) {
1546- if (state->active) {
1547- gin_gid_timeout(ge, state->gid);
1548- }
1549- }
1550- if (!state->active) {
1551- if (move->ntouch == 4) {
1552- state->gid = gin_gid_begin(ge, GRAIL_TYPE_MDRAG,
1553- PRIO_META, frame);
1554- state->mintouch = 1;
1555- state->maxtouch = 4;
1556- state->active = 1;
1557- } else if (move->ntouch == 3) {
1558- state->gid = gin_gid_begin(ge, GRAIL_TYPE_EDRAG,
1559- PRIO_ENV, frame);
1560- state->mintouch = 1;
1561- state->maxtouch = 3;
1562- state->active = 1;
1563- } else {
1564- return 0;
1565- }
1566- }
1567- if (!(move->tickle & mask))
1568- return 0;
1569- if (!(move->active & fm_mask))
1570- return 0;
1571- set_props(ge->gin, state, move, frame);
1572- gru_event(ge, state->gid, move, state->prop, state->nprop);
1573- return 1;
1574-}
1575-
1576
1577=== removed file 'src/v2/gestures-pinch.c'
1578--- src/v2/gestures-pinch.c 2012-03-26 12:57:55 +0000
1579+++ src/v2/gestures-pinch.c 1970-01-01 00:00:00 +0000
1580@@ -1,130 +0,0 @@
1581-/*****************************************************************************
1582- *
1583- * grail - Gesture Recognition And Instantiation Library
1584- *
1585- * Copyright (C) 2010-2012 Canonical Ltd.
1586- *
1587- * This library is free software: you can redistribute it and/or modify it
1588- * under the terms of the GNU Lesser General Public License version 3
1589- * as published by the Free Software Foundation.
1590- *
1591- * This library is distributed in the hope that it will be useful, but
1592- * WITHOUT ANY WARRANTY; without even the implied warranties of
1593- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1594- * PURPOSE. See the GNU Lesser General Public License for more details.
1595- *
1596- * You should have received a copy of the GNU Lesser General Public License
1597- * along with this library. If not, see <http://www.gnu.org/licenses/>.
1598- *
1599- ****************************************************************************/
1600-
1601-#include "grail-recognizer.h"
1602-#include <math.h>
1603-#include <stdio.h>
1604-
1605-static const int getype[DIM_TOUCH + 1] = {
1606- 0,
1607- 0,
1608- GRAIL_TYPE_PINCH2,
1609- GRAIL_TYPE_PINCH3,
1610- GRAIL_TYPE_PINCH4,
1611- GRAIL_TYPE_PINCH5,
1612-};
1613-
1614-static const int fm_mask = 0x04;
1615-
1616-static void set_props(const struct gesture_inserter *gin,
1617- struct combo_model *s,
1618- const struct move_model *m,
1619- const struct utouch_frame *frame)
1620-{
1621- s->prop[GRAIL_PROP_PINCH_DR] = m->fm[FM_R].action_delta;
1622- s->prop[GRAIL_PROP_PINCH_VR] = m->fm[FM_R].velocity;
1623- s->prop[GRAIL_PROP_PINCH_R] = m->fm[FM_R].value;
1624- s->prop[GRAIL_PROP_PINCH_X] = m->fm[FM_X].value;
1625- s->prop[GRAIL_PROP_PINCH_Y] = m->fm[FM_Y].value;
1626- s->nprop = 5;
1627- s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame);
1628-}
1629-
1630-int gru_pinch(struct grail *ge,
1631- const struct utouch_frame *frame)
1632-{
1633- struct gesture_recognizer *gru = ge->gru;
1634- struct combo_model *state = &gru->pinch;
1635- struct move_model *move = &gru->move;
1636- int mask = state->active ? (move->active & fm_mask) : fm_mask;
1637- if (!move->multi && !move->single) {
1638- if (state->active) {
1639- gru_end(ge, state->gid, move,
1640- state->prop, state->nprop);
1641- state->active = 0;
1642- }
1643- return 0;
1644- }
1645- if ((move->timeout & fm_mask) == fm_mask) {
1646- if (state->active) {
1647- gin_gid_timeout(ge, state->gid);
1648- }
1649- }
1650- if (!(move->tickle & mask))
1651- return 0;
1652- if (!state->active) {
1653- int type = getype[move->ntouch];
1654- if (!type)
1655- return 0;
1656- state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame);
1657- state->active = 1;
1658- }
1659- if (!(move->active & fm_mask))
1660- return 0;
1661- set_props(ge->gin, state, move, frame);
1662- gru_event(ge, state->gid, move, state->prop, state->nprop);
1663- return 1;
1664-}
1665-
1666-int gru_winpinch(struct grail *ge,
1667- const struct utouch_frame *frame)
1668-{
1669- struct gesture_recognizer *gru = ge->gru;
1670- struct combo_model *state = &gru->winpinch;
1671- struct move_model *move = &gru->move;
1672- int mask = state->active ? (move->active & fm_mask) : fm_mask;
1673- if (!move->multi) {
1674- if (state->active && out_of_bounds(state, move)) {
1675- gru_end(ge, state->gid, move,
1676- state->prop, state->nprop);
1677- state->active = 0;
1678- }
1679- return 0;
1680- }
1681- if ((move->timeout & fm_mask) == fm_mask) {
1682- if (state->active) {
1683- gin_gid_timeout(ge, state->gid);
1684- }
1685- }
1686- if (!(move->tickle & mask))
1687- return 0;
1688- if (!state->active) {
1689- if (move->ntouch == 4) {
1690- state->gid = gin_gid_begin(ge, GRAIL_TYPE_MPINCH,
1691- PRIO_META, frame);
1692- state->mintouch = 2;
1693- state->maxtouch = 4;
1694- state->active = 1;
1695- } else if (move->ntouch == 3) {
1696- state->gid = gin_gid_begin(ge, GRAIL_TYPE_EPINCH,
1697- PRIO_ENV, frame);
1698- state->mintouch = 2;
1699- state->maxtouch = 3;
1700- state->active = 1;
1701- } else {
1702- return 0;
1703- }
1704- }
1705- if (!(move->active & fm_mask))
1706- return 0;
1707- set_props(ge->gin, state, move, frame);
1708- gru_event(ge, state->gid, move, state->prop, state->nprop);
1709- return 1;
1710-}
1711
1712=== removed file 'src/v2/gestures-rotate.c'
1713--- src/v2/gestures-rotate.c 2012-03-26 12:57:55 +0000
1714+++ src/v2/gestures-rotate.c 1970-01-01 00:00:00 +0000
1715@@ -1,129 +0,0 @@
1716-/*****************************************************************************
1717- *
1718- * grail - Gesture Recognition And Instantiation Library
1719- *
1720- * Copyright (C) 2010-2012 Canonical Ltd.
1721- *
1722- * This library is free software: you can redistribute it and/or modify it
1723- * under the terms of the GNU Lesser General Public License version 3
1724- * as published by the Free Software Foundation.
1725- *
1726- * This library is distributed in the hope that it will be useful, but
1727- * WITHOUT ANY WARRANTY; without even the implied warranties of
1728- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1729- * PURPOSE. See the GNU Lesser General Public License for more details.
1730- *
1731- * You should have received a copy of the GNU Lesser General Public License
1732- * along with this library. If not, see <http://www.gnu.org/licenses/>.
1733- *
1734- ****************************************************************************/
1735-
1736-#include "grail-recognizer.h"
1737-#include <math.h>
1738-#include <stdio.h>
1739-
1740-static const int getype[DIM_TOUCH + 1] = {
1741- 0,
1742- 0,
1743- GRAIL_TYPE_ROTATE2,
1744- GRAIL_TYPE_ROTATE3,
1745- GRAIL_TYPE_ROTATE4,
1746- GRAIL_TYPE_ROTATE5,
1747-};
1748-
1749-static const int fm_mask = 0x08;
1750-
1751-static void set_props(const struct gesture_inserter *gin,
1752- struct combo_model *s, const struct move_model *m,
1753- const struct utouch_frame *frame)
1754-{
1755- s->prop[GRAIL_PROP_ROTATE_DA] = m->fm[FM_A].action_delta;
1756- s->prop[GRAIL_PROP_ROTATE_VA] = m->fm[FM_A].velocity;
1757- s->prop[GRAIL_PROP_ROTATE_A] = m->fm[FM_A].value;
1758- s->prop[GRAIL_PROP_ROTATE_X] = m->fm[FM_X].value;
1759- s->prop[GRAIL_PROP_ROTATE_Y] = m->fm[FM_Y].value;
1760- s->nprop = 5;
1761- s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame);
1762-}
1763-
1764-int gru_rotate(struct grail *ge,
1765- const struct utouch_frame *frame)
1766-{
1767- struct gesture_recognizer *gru = ge->gru;
1768- struct combo_model *state = &gru->rotate;
1769- struct move_model *move = &gru->move;
1770- int mask = state->active ? (move->active & fm_mask) : fm_mask;
1771- if (!move->multi && !move->single) {
1772- if (state->active) {
1773- gru_end(ge, state->gid, move,
1774- state->prop, state->nprop);
1775- state->active = 0;
1776- }
1777- return 0;
1778- }
1779- if ((move->timeout & fm_mask) == fm_mask) {
1780- if (state->active) {
1781- gin_gid_timeout(ge, state->gid);
1782- }
1783- }
1784- if (!(move->tickle & mask))
1785- return 0;
1786- if (!state->active) {
1787- int type = getype[move->ntouch];
1788- if (!type)
1789- return 0;
1790- state->gid = gin_gid_begin(ge, type, PRIO_GESTURE, frame);
1791- state->active = 1;
1792- }
1793- if (!(move->active & fm_mask))
1794- return 0;
1795- set_props(ge->gin, state, move, frame);
1796- gru_event(ge, state->gid, move, state->prop, state->nprop);
1797- return 1;
1798-}
1799-
1800-int gru_winrotate(struct grail *ge,
1801- const struct utouch_frame *frame)
1802-{
1803- struct gesture_recognizer *gru = ge->gru;
1804- struct combo_model *state = &gru->winrotate;
1805- struct move_model *move = &gru->move;
1806- int mask = state->active ? (move->active & fm_mask) : fm_mask;
1807- if (!move->multi) {
1808- if (state->active && out_of_bounds(state, move)) {
1809- gru_end(ge, state->gid, move,
1810- state->prop, state->nprop);
1811- state->active = 0;
1812- }
1813- return 0;
1814- }
1815- if ((move->timeout & fm_mask) == fm_mask) {
1816- if (state->active) {
1817- gin_gid_timeout(ge, state->gid);
1818- }
1819- }
1820- if (!(move->tickle & mask))
1821- return 0;
1822- if (!state->active) {
1823- if (move->ntouch == 4) {
1824- state->gid = gin_gid_begin(ge, GRAIL_TYPE_MROTATE,
1825- PRIO_META, frame);
1826- state->mintouch = 2;
1827- state->maxtouch = 4;
1828- state->active = 1;
1829- } else if (move->ntouch == 3) {
1830- state->gid = gin_gid_begin(ge, GRAIL_TYPE_EROTATE,
1831- PRIO_ENV, frame);
1832- state->mintouch = 2;
1833- state->maxtouch = 3;
1834- state->active = 1;
1835- } else {
1836- return 0;
1837- }
1838- }
1839- if (!(move->active & fm_mask))
1840- return 0;
1841- set_props(ge->gin, state, move, frame);
1842- gru_event(ge, state->gid, move, state->prop, state->nprop);
1843- return 1;
1844-}
1845
1846=== removed file 'src/v2/gestures-tapping.c'
1847--- src/v2/gestures-tapping.c 2012-03-26 12:57:55 +0000
1848+++ src/v2/gestures-tapping.c 1970-01-01 00:00:00 +0000
1849@@ -1,99 +0,0 @@
1850-/*****************************************************************************
1851- *
1852- * grail - Gesture Recognition And Instantiation Library
1853- *
1854- * Copyright (C) 2010-2012 Canonical Ltd.
1855- *
1856- * This library is free software: you can redistribute it and/or modify it
1857- * under the terms of the GNU Lesser General Public License version 3
1858- * as published by the Free Software Foundation.
1859- *
1860- * This library is distributed in the hope that it will be useful, but
1861- * WITHOUT ANY WARRANTY; without even the implied warranties of
1862- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1863- * PURPOSE. See the GNU Lesser General Public License for more details.
1864- *
1865- * You should have received a copy of the GNU Lesser General Public License
1866- * along with this library. If not, see <http://www.gnu.org/licenses/>.
1867- *
1868- ****************************************************************************/
1869-
1870-#include "grail-recognizer.h"
1871-#include <math.h>
1872-
1873-static const int fm_mask = 0x07;
1874-
1875-static void set_props(const struct gesture_inserter *gin,
1876- struct tapping_model *s, const struct move_model *m,
1877- const struct utouch_frame *frame)
1878-{
1879- s->prop[GRAIL_PROP_TAP_DT] = m->time - s->start;
1880- s->prop[GRAIL_PROP_TAP_X] = m->fm[FM_X].value;
1881- s->prop[GRAIL_PROP_TAP_Y] = m->fm[FM_Y].value;
1882- s->nprop = 3;
1883- s->nprop += gin_add_contact_props(gin, s->prop + s->nprop, frame);
1884-}
1885-
1886-int gru_tapping(struct grail *ge,
1887- const struct utouch_frame *frame)
1888-{
1889- struct gesture_recognizer *gru = ge->gru;
1890- struct tapping_model *state = &gru->tapping;
1891- struct move_model *move = &gru->move;
1892- state->tap = 0;
1893- if (frame->num_active && !frame->prev->num_active) {
1894- state->mintouch = 0;
1895- state->maxtouch = 0;
1896- }
1897- if (move->ntouch > state->maxtouch) {
1898- if (state->active) {
1899- gin_gid_discard(ge, state->gid);
1900- state->active = 0;
1901- }
1902- state->start = move->time;
1903- state->maxtouch = move->ntouch;
1904- set_props(ge->gin, state, move, frame);
1905- if (state->maxtouch <= 5) {
1906- int type = GRAIL_TYPE_TAP1 + state->maxtouch - 1;
1907- state->gid = gin_gid_begin(ge, type, PRIO_TAP, frame);
1908- state->active = 1;
1909- }
1910- return 0;
1911- }
1912- if (!state->active) {
1913- state->mintouch = move->ntouch;
1914- state->maxtouch = move->ntouch;
1915- return 0;
1916- }
1917- if (move->ntouch <= state->mintouch) {
1918- int x = state->prop[GRAIL_PROP_TAP_X];
1919- int y = state->prop[GRAIL_PROP_TAP_Y];
1920- int t = move->time - state->start;
1921- if (t > move->fm[FM_X].bar_ms) {
1922- gin_gid_discard(ge, state->gid);
1923- state->mintouch = move->ntouch;
1924- state->maxtouch = move->ntouch;
1925- state->active = 0;
1926- return 0;
1927- }
1928- state->tap = state->maxtouch;
1929- state->prop[GRAIL_PROP_TAP_DT] = t;
1930- gin_gid_event(ge, state->gid, x, y, state->maxtouch,
1931- state->prop, state->nprop, 1);
1932- state->mintouch = move->ntouch;
1933- state->maxtouch = move->ntouch;
1934- state->active = 0;
1935- return 1;
1936- }
1937- if (!move->ntouch)
1938- return 0;
1939- state->prop[GRAIL_PROP_TAP_DT] = move->time - state->start;
1940- if ((move->active & fm_mask) ||
1941- move->time - state->start > move->fm[FM_X].bar_ms) {
1942- gin_gid_discard(ge, state->gid);
1943- state->mintouch = move->ntouch;
1944- state->maxtouch = move->ntouch;
1945- state->active = 0;
1946- }
1947- return 0;
1948-}
1949
1950=== removed file 'src/v2/gestures-touch.c'
1951--- src/v2/gestures-touch.c 2012-03-26 12:57:55 +0000
1952+++ src/v2/gestures-touch.c 1970-01-01 00:00:00 +0000
1953@@ -1,97 +0,0 @@
1954-/*****************************************************************************
1955- *
1956- * grail - Gesture Recognition And Instantiation Library
1957- *
1958- * Copyright (C) 2010-2012 Canonical Ltd.
1959- * Copyright (C) 2010 Henrik Rydberg <rydberg@bitmath.org>
1960- *
1961- * This library is free software: you can redistribute it and/or modify it
1962- * under the terms of the GNU Lesser General Public License version 3
1963- * as published by the Free Software Foundation.
1964- *
1965- * This library is distributed in the hope that it will be useful, but
1966- * WITHOUT ANY WARRANTY; without even the implied warranties of
1967- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
1968- * PURPOSE. See the GNU Lesser General Public License for more details.
1969- *
1970- * You should have received a copy of the GNU Lesser General Public License
1971- * along with this library. If not, see <http://www.gnu.org/licenses/>.
1972- *
1973- ****************************************************************************/
1974-
1975-#include "grail-recognizer.h"
1976-#include <math.h>
1977-#include <stdio.h>
1978-
1979-static const int getype[DIM_TOUCH + 1] = {
1980- -1,
1981- GRAIL_TYPE_TOUCH1,
1982- GRAIL_TYPE_TOUCH2,
1983- GRAIL_TYPE_TOUCH3,
1984- GRAIL_TYPE_TOUCH4,
1985- GRAIL_TYPE_TOUCH5,
1986-};
1987-
1988-int gru_touch(struct grail *ge,
1989- const struct utouch_frame *frame)
1990-{
1991- struct gesture_recognizer *gru = ge->gru;
1992- struct combo_model *state = &gru->touch;
1993- struct move_model *move = &gru->move;
1994- if (frame->slot_revision != frame->prev->slot_revision) {
1995- if (state->active) {
1996- gru_end(ge, state->gid, move,
1997- state->prop, state->nprop);
1998- state->active = 0;
1999- }
2000- }
2001- if (!state->active) {
2002- int type = getype[move->ntouch];
2003- if (type <= 0)
2004- return 0;
2005- state->gid = gin_gid_begin(ge, type, -PRIO_GESTURE, frame);
2006- state->active = 1;
2007- }
2008- if (move->time - move->fm[FM_X].original_ms <= move->fm[FM_X].hold_ms)
2009- return 0;
2010- state->nprop = gin_add_contact_props(ge->gin, state->prop, frame);
2011- gru_event(ge, state->gid, move, state->prop, state->nprop);
2012- return 1;
2013-}
2014-
2015-int gru_wintouch(struct grail *ge,
2016- const struct utouch_frame *frame)
2017-{
2018- struct gesture_recognizer *gru = ge->gru;
2019- struct combo_model *state = &gru->wintouch;
2020- struct move_model *move = &gru->move;
2021- if (frame->slot_revision != frame->prev->slot_revision) {
2022- if (state->active && out_of_bounds(state, move)) {
2023- gru_end(ge, state->gid, move,
2024- state->prop, state->nprop);
2025- state->active = 0;
2026- }
2027- }
2028- if (!state->active) {
2029- if (move->ntouch == 4) {
2030- state->gid = gin_gid_begin(ge, GRAIL_TYPE_MTOUCH,
2031- -PRIO_META, frame);
2032- state->mintouch = 1;
2033- state->maxtouch = 4;
2034- state->active = 1;
2035- } else if (move->ntouch == 3) {
2036- state->gid = gin_gid_begin(ge, GRAIL_TYPE_ETOUCH,
2037- -PRIO_ENV, frame);
2038- state->mintouch = 1;
2039- state->maxtouch = 3;
2040- state->active = 1;
2041- } else {
2042- return 0;
2043- }
2044- }
2045- if (move->time - move->fm[FM_X].original_ms <= move->fm[FM_X].hold_ms)
2046- return 0;
2047- state->nprop = gin_add_contact_props(ge->gin, state->prop, frame);
2048- gru_event(ge, state->gid, move, state->prop, state->nprop);
2049- return 1;
2050-}
2051
2052=== removed file 'src/v2/grail-api.c'
2053--- src/v2/grail-api.c 2012-03-26 12:57:55 +0000
2054+++ src/v2/grail-api.c 1970-01-01 00:00:00 +0000
2055@@ -1,327 +0,0 @@
2056-/*****************************************************************************
2057- *
2058- * grail - Gesture Recognition And Instantiation Library
2059- *
2060- * Copyright (C) 2010-2012 Canonical Ltd.
2061- *
2062- * This library is free software: you can redistribute it and/or modify it
2063- * under the terms of the GNU Lesser General Public License version 3
2064- * as published by the Free Software Foundation.
2065- *
2066- * This library is distributed in the hope that it will be useful, but
2067- * WITHOUT ANY WARRANTY; without even the implied warranties of
2068- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2069- * PURPOSE. See the GNU Lesser General Public License for more details.
2070- *
2071- * You should have received a copy of the GNU Lesser General Public License
2072- * along with this library. If not, see <http://www.gnu.org/licenses/>.
2073- *
2074- ****************************************************************************/
2075-
2076-#include "grail-impl.h"
2077-#include "grail-inserter.h"
2078-#include "grail-recognizer.h"
2079-#include <string.h>
2080-#include <stdio.h>
2081-#include <unistd.h>
2082-#include <fcntl.h>
2083-#include <malloc.h>
2084-#include <errno.h>
2085-#include <stdlib.h>
2086-#include <sys/stat.h>
2087-
2088-#define DIM_FRAMES 100
2089-#define FRAME_RATE 100
2090-
2091-unsigned int GRAIL_PUBLIC grail_get_version(void)
2092-{
2093- return GRAIL_VERSION;
2094-}
2095-
2096-int GRAIL_PUBLIC grail_open(struct grail *ge, int fd)
2097-{
2098- struct grail_impl *x;
2099- struct stat fs;
2100- int ret;
2101-
2102- ret = fstat(fd, &fs);
2103- if (ret)
2104- return ret;
2105-
2106- x = calloc(1, sizeof(*x));
2107- if (!x)
2108- return -ENOMEM;
2109-
2110- if (!fs.st_rdev)
2111- x->fptest = fdopen(fd, "r");
2112-
2113- x->evemu = evemu_new(x->fptest ? "fptest" : 0);
2114- if (!x->evemu) {
2115- ret = -ENOMEM;
2116- goto freemem;
2117- }
2118- if (x->fptest)
2119- ret = evemu_read(x->evemu, x->fptest) <= 0;
2120- else
2121- ret = evemu_extract(x->evemu, fd);
2122- if (ret)
2123- goto freemem;
2124- if (!utouch_frame_is_supported_mtdev(x->evemu)) {
2125- ret = -ENODEV;
2126- goto freemem;
2127- }
2128-
2129- if (!x->fptest) {
2130- x->mtdev = mtdev_new_open(fd);
2131- if (!x->mtdev) {
2132- ret = -ENOMEM;
2133- goto freemem;
2134- }
2135- }
2136- x->fh = utouch_frame_new_engine(DIM_FRAMES, DIM_TOUCH, FRAME_RATE);
2137- if (!x->fh) {
2138- ret = -ENOMEM;
2139- goto freedev;
2140- }
2141- ret = utouch_frame_init_mtdev(x->fh, x->evemu);
2142- if (ret)
2143- goto freeframe;
2144-
2145- ge->impl = x;
2146-
2147- ret = gin_init(ge);
2148- if (ret)
2149- goto freeframe;
2150-
2151- ret = gru_init(ge);
2152- if (ret)
2153- goto freegin;
2154-
2155- return 0;
2156- freegin:
2157- gin_destroy(ge);
2158- freeframe:
2159- utouch_frame_delete_engine(x->fh);
2160- freedev:
2161- if (x->mtdev)
2162- mtdev_close_delete(x->mtdev);
2163- freemem:
2164- evemu_delete(x->evemu);
2165- if (x->fptest)
2166- fclose(x->fptest);
2167- free(x);
2168- ge->impl = 0;
2169- return ret;
2170-}
2171-
2172-void GRAIL_PUBLIC grail_close(struct grail *ge, int fd)
2173-{
2174- struct grail_impl *x = ge->impl;
2175- gru_destroy(ge);
2176- gin_destroy(ge);
2177- utouch_frame_delete_engine(x->fh);
2178- if (x->mtdev)
2179- mtdev_close_delete(x->mtdev);
2180- evemu_delete(x->evemu);
2181- if (x->fptest)
2182- fclose(x->fptest);
2183- free(x);
2184- ge->impl = 0;
2185-}
2186-
2187-int GRAIL_PUBLIC grail_idle(struct grail *ge, int fd, int ms)
2188-{
2189- struct grail_impl *x = ge->impl;
2190- if (x->fptest)
2191- return 0;
2192- if (x->mtdev)
2193- return mtdev_idle(x->mtdev, fd, ms);
2194- return 1;
2195-}
2196-
2197-void GRAIL_PUBLIC grail_get_units(const struct grail *ge,
2198- struct grail_coord *min, struct grail_coord *max)
2199-{
2200- struct utouch_surface *s = utouch_frame_get_surface(ge->impl->fh);
2201- min->x = s->min_x;
2202- min->y = s->min_y;
2203- max->x = s->max_x;
2204- max->y = s->max_y;
2205-}
2206-
2207-const struct utouch_frame GRAIL_PUBLIC *
2208-grail_get_contact_frame(const struct grail *ge)
2209-{
2210- return ge->impl->touch;
2211-}
2212-
2213-static void flush_events(struct grail *ge)
2214-{
2215- struct grail_impl *impl = ge->impl;
2216- struct input_event iev;
2217-
2218- grailbuf_clear(&impl->gbuf);
2219- while (!evbuf_empty(&impl->evbuf)) {
2220- evbuf_get(&impl->evbuf, &iev);
2221- if (ge->event)
2222- ge->event(ge, &iev);
2223- }
2224-}
2225-
2226-static int skip_event(const struct input_event *ev, int count)
2227-{
2228- switch (ev->type) {
2229- case EV_ABS:
2230- return 1;
2231- case EV_KEY:
2232- return ev->code >= BTN_DIGI && ev->code < BTN_WHEEL;
2233- case EV_SYN:
2234- switch (ev->code) {
2235- case SYN_MT_REPORT:
2236- return 1;
2237- case SYN_REPORT:
2238- return count == 0;
2239- default:
2240- return 0;
2241- }
2242- default:
2243- return 0;
2244- }
2245-}
2246-
2247-static void flush_gestures(struct grail *ge)
2248-{
2249- struct grail_impl *impl = ge->impl;
2250- struct input_event iev;
2251- struct grail_event gev;
2252- int count = 0;
2253-
2254- while (!evbuf_empty(&impl->evbuf)) {
2255- evbuf_get(&impl->evbuf, &iev);
2256- if (skip_event(&iev, count))
2257- continue;
2258- if (ge->event)
2259- ge->event(ge, &iev);
2260- if (iev.type == EV_SYN && iev.code == SYN_REPORT)
2261- count = 0;
2262- else
2263- count++;
2264- }
2265- while (!grailbuf_empty(&impl->gbuf)) {
2266- grailbuf_get(&impl->gbuf, &gev);
2267- if (ge->gesture)
2268- ge->gesture(ge, &gev);
2269- }
2270-}
2271-
2272-static int gesture_timeout(struct grail *ge, const struct utouch_frame *frame)
2273-{
2274- struct gesture_recognizer *gru = ge->gru;
2275- struct gesture_inserter *gin = ge->gin;
2276-
2277- return grail_mask_count(gin->used, sizeof(gin->used)) == 0 &&
2278- frame->time - frame->mod_time > gru->move.fm[FM_X].hold_ms;
2279-}
2280-
2281-static void report_frame(struct grail *ge,
2282- const struct utouch_frame *touch,
2283- const struct input_event *syn)
2284-{
2285- struct grail_impl *impl = ge->impl;
2286-
2287- impl->touch = touch;
2288-
2289- if (touch->num_active && !touch->prev->num_active) {
2290- impl->ongoing = 1;
2291- impl->gesture = 0;
2292- }
2293-
2294- if (!impl->ongoing)
2295- return;
2296-
2297- gin_frame_begin(ge, touch);
2298- gru_recognize(ge, touch);
2299- gin_frame_end(ge, touch);
2300-
2301- if (!grailbuf_empty(&impl->gbuf))
2302- impl->gesture = 1;
2303-
2304- if (touch->num_active == 0 || gesture_timeout(ge, touch))
2305- impl->ongoing &= impl->gesture;
2306-}
2307-
2308-static void grail_pump_mtdev(struct grail *ge, const struct input_event *ev)
2309-{
2310- struct grail_impl *impl = ge->impl;
2311- const struct utouch_frame *frame;
2312-
2313- evbuf_put(&impl->evbuf, ev);
2314-
2315- if (ev->type == EV_SYN || ev->type == EV_ABS || ev->type == EV_KEY) {
2316- frame = utouch_frame_pump_mtdev(impl->fh, ev);
2317- if (frame)
2318- report_frame(ge, frame, ev);
2319- }
2320-
2321- if (ev->type == EV_SYN) {
2322- if (!impl->ongoing)
2323- flush_events(ge);
2324- if (impl->gesture)
2325- flush_gestures(ge);
2326- }
2327-}
2328-
2329-/**
2330- * Read an event from the given file. If fast_fileread is true,
2331- * return immediately. If it is false, delay between events
2332- * so it looks like they are coming in real time.
2333- */
2334-static int grail_read_evemu_event(FILE *fp, struct input_event *ev,
2335- struct timeval *evtime, int fast_fileread) {
2336- if (fast_fileread)
2337- return evemu_read_event(fp, ev);
2338- return evemu_read_event_realtime(fp, ev, evtime);
2339-}
2340-
2341-
2342-static int grail_pull_fstest(struct grail *ge, int fd)
2343-{
2344- struct grail_impl *impl = ge->impl;
2345- struct input_event ev;
2346- struct timeval evtime;
2347- int count = 0;
2348-
2349- memset(&evtime, 0, sizeof(evtime));
2350- while (grail_read_evemu_event(impl->fptest, &ev, &evtime, impl->fast_fileread) > 0) {
2351- grail_pump_mtdev(ge, &ev);
2352- count++;
2353- }
2354-
2355- fclose(impl->fptest);
2356- impl->fptest = 0;
2357-
2358- return count > 0 ? count : -1;
2359-}
2360-
2361-int GRAIL_PUBLIC grail_pull(struct grail *ge, int fd)
2362-{
2363- struct grail_impl *impl = ge->impl;
2364- struct input_event ev;
2365- int ret, count = 0;
2366-
2367- if (impl->fptest)
2368- return grail_pull_fstest(ge, fd);
2369-
2370- while ((ret = mtdev_get(impl->mtdev, fd, &ev, 1)) > 0) {
2371- grail_pump_mtdev(ge, &ev);
2372- count++;
2373- }
2374-
2375- return count > 0 ? count : ret;
2376-}
2377-
2378-void GRAIL_PUBLIC grail_set_coordinate_transform_callback(struct grail *ge,
2379- utouch_coordinate_transform_cb callback,
2380- void *user_data) {
2381- utouch_frame_set_coordinate_transform_callback(ge->impl->fh, callback, user_data);
2382-}
2383
2384=== removed file 'src/v2/grail-bits.c'
2385--- src/v2/grail-bits.c 2012-03-26 12:57:55 +0000
2386+++ src/v2/grail-bits.c 1970-01-01 00:00:00 +0000
2387@@ -1,92 +0,0 @@
2388-/*****************************************************************************
2389- *
2390- * grail - Gesture Recognition And Instantiation Library
2391- *
2392- * Copyright (C) 2010-2012 Canonical Ltd.
2393- *
2394- * This library is free software: you can redistribute it and/or modify it
2395- * under the terms of the GNU Lesser General Public License version 3
2396- * as published by the Free Software Foundation.
2397- *
2398- * This library is distributed in the hope that it will be useful, but
2399- * WITHOUT ANY WARRANTY; without even the implied warranties of
2400- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2401- * PURPOSE. See the GNU Lesser General Public License for more details.
2402- *
2403- * You should have received a copy of the GNU Lesser General Public License
2404- * along with this library. If not, see <http://www.gnu.org/licenses/>.
2405- *
2406- ****************************************************************************/
2407-
2408-#include "grail-bits.h"
2409-
2410-static const int grail_bits_in_byte[256] =
2411-{
2412- 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
2413- 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
2414- 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
2415- 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
2416- 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
2417- 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
2418- 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
2419- 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8,
2420-};
2421-
2422-static const int grail_first_set_bit[256] =
2423-{
2424- -1,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
2425- 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
2426- 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
2427- 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
2428- 7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
2429- 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
2430- 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
2431- 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
2432-};
2433-
2434-void GRAIL_PUBLIC grail_mask_set_mask(grail_mask_t *a, const grail_mask_t *b,
2435- int bytes)
2436-{
2437- while (bytes--)
2438- *a++ |= *b++;
2439-}
2440-
2441-void GRAIL_PUBLIC grail_mask_clear_mask(grail_mask_t *a, const grail_mask_t *b,
2442- int bytes)
2443-{
2444- while (bytes--)
2445- *a++ &= ~*b++;
2446-}
2447-
2448-int GRAIL_PUBLIC grail_mask_count(const grail_mask_t *mask, int bytes)
2449-{
2450- int count = 0;
2451- while (bytes--)
2452- count += grail_bits_in_byte[*mask++];
2453- return count;
2454-}
2455-
2456-int GRAIL_PUBLIC grail_mask_get_first(const grail_mask_t *mask, int bytes)
2457-{
2458- int k;
2459- for (k = 0; k < bytes; k++)
2460- if (mask[k])
2461- return (k << 3) | grail_first_set_bit[mask[k]];
2462- return -1;
2463-}
2464-
2465-int GRAIL_PUBLIC grail_mask_get_next(int i, const grail_mask_t *mask, int bytes)
2466-{
2467- int k = ++i >> 3;
2468- if (k < bytes) {
2469- i = grail_first_set_bit[mask[k] & (~0 << (i & 7))];
2470- if (i >= 0)
2471- return (k << 3) | i;
2472- while (++k < bytes) {
2473- i = grail_first_set_bit[mask[k]];
2474- if (i >= 0)
2475- return (k << 3) | i;
2476- }
2477- }
2478- return -1;
2479-}
2480
2481=== removed file 'src/v2/grail-event.c'
2482--- src/v2/grail-event.c 2012-03-26 12:57:55 +0000
2483+++ src/v2/grail-event.c 1970-01-01 00:00:00 +0000
2484@@ -1,117 +0,0 @@
2485-/*****************************************************************************
2486- *
2487- * grail - Gesture Recognition And Instantiation Library
2488- *
2489- * Copyright (C) 2010-2012 Canonical Ltd.
2490- *
2491- * This library is free software: you can redistribute it and/or modify it
2492- * under the terms of the GNU Lesser General Public License version 3
2493- * as published by the Free Software Foundation.
2494- *
2495- * This library is distributed in the hope that it will be useful, but
2496- * WITHOUT ANY WARRANTY; without even the implied warranties of
2497- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2498- * PURPOSE. See the GNU Lesser General Public License for more details.
2499- *
2500- * You should have received a copy of the GNU Lesser General Public License
2501- * along with this library. If not, see <http://www.gnu.org/licenses/>.
2502- *
2503- ****************************************************************************/
2504-
2505-#include "grail-inserter.h"
2506-#include "grail-impl.h"
2507-#include <malloc.h>
2508-#include <string.h>
2509-#include <errno.h>
2510-#include <math.h>
2511-
2512-static void compute_bbox(struct grail_coord *min, struct grail_coord *max,
2513- const struct utouch_frame *frame)
2514-{
2515- float x, y;
2516- int i;
2517- if (frame->num_active < 1)
2518- return;
2519- x = frame->active[0]->x;
2520- y = frame->active[0]->y;
2521- min->x = max->x = x;
2522- min->y = max->y = y;
2523- for (i = 1; i < frame->num_active; i++) {
2524- x = frame->active[i]->x;
2525- y = frame->active[i]->y;
2526- if (x < min->x)
2527- min->x = x;
2528- if (y < min->y)
2529- min->y = y;
2530- if (x > max->x)
2531- max->x = x;
2532- if (y > max->y)
2533- max->y = y;
2534- }
2535-}
2536-
2537-int gin_add_contact_props(const struct gesture_inserter *gin,
2538- grail_prop_t *prop, const struct utouch_frame *frame)
2539-{
2540- struct grail_coord min = { 0, 0 };
2541- struct grail_coord max = { 0, 0 };
2542- int i, n = 0, ntouch = frame->num_active;
2543- if (!ntouch)
2544- return n;
2545- if (ntouch > 5)
2546- ntouch = 5;
2547- compute_bbox(&min, &max, frame);
2548- prop[n++] = min.x;
2549- prop[n++] = min.y;
2550- prop[n++] = max.x;
2551- prop[n++] = max.y;
2552- for (i = 0; i < ntouch; i++) {
2553- const struct utouch_contact *ct = frame->active[i];
2554- prop[n++] = ct->id;
2555- prop[n++] = ct->x;
2556- prop[n++] = ct->y;
2557- }
2558- return n;
2559-}
2560-
2561-int gin_get_clients(struct grail *ge,
2562- struct grail_client_info *info, int maxinfo,
2563- const grail_mask_t* types, int btypes,
2564- const grail_mask_t* span, int bspan,
2565- const struct utouch_frame *frame)
2566-{
2567- struct grail_coord pos[DIM_TOUCH];
2568- int i, npos = 0;
2569- if (!ge->get_clients)
2570- return 0;
2571- grail_mask_foreach(i, span, bspan) {
2572- pos[npos].x = frame->slots[i]->x;
2573- pos[npos].y = frame->slots[i]->y;
2574- npos++;
2575- }
2576- return ge->get_clients(ge, info, maxinfo, pos, npos, types, btypes);
2577-}
2578-
2579-void gin_send_event(struct grail *ge, struct slot_state *s,
2580- const struct gesture_event *ev,
2581- const struct utouch_frame *frame)
2582-{
2583- struct grail_impl *impl = ge->impl;
2584- struct grail_event gev;
2585- int i;
2586- if (!ge->gesture)
2587- return;
2588- gev.type = s->type;
2589- gev.id = s->id;
2590- gev.status = ev->status;
2591- gev.ntouch = ev->ntouch;
2592- gev.nprop = ev->nprop;
2593- gev.time = ev->time;
2594- gev.pos.x = ev->pos.x;
2595- gev.pos.y = ev->pos.y;
2596- memcpy(gev.prop, ev->prop, ev->nprop * sizeof(grail_prop_t));
2597- for (i = 0; i < s->nclient; i++) {
2598- gev.client_id = s->client_id[i];
2599- grailbuf_put(&impl->gbuf, &gev);
2600- }
2601-}
2602
2603=== removed file 'src/v2/grail-frame.c'
2604--- src/v2/grail-frame.c 2012-03-26 12:57:55 +0000
2605+++ src/v2/grail-frame.c 1970-01-01 00:00:00 +0000
2606@@ -1,409 +0,0 @@
2607-/*****************************************************************************
2608- *
2609- * grail - Gesture Recognition And Instantiation Library
2610- *
2611- * Copyright (C) 2010-2012 Canonical Ltd.
2612- *
2613- * This library is free software: you can redistribute it and/or modify it
2614- * under the terms of the GNU Lesser General Public License version 3
2615- * as published by the Free Software Foundation.
2616- *
2617- * This library is distributed in the hope that it will be useful, but
2618- * WITHOUT ANY WARRANTY; without even the implied warranties of
2619- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
2620- * PURPOSE. See the GNU Lesser General Public License for more details.
2621- *
2622- * You should have received a copy of the GNU Lesser General Public License
2623- * along with this library. If not, see <http://www.gnu.org/licenses/>.
2624- *
2625- ****************************************************************************/
2626-
2627-#include "grail-impl.h"
2628-#include <stdlib.h>
2629-#include <string.h>
2630-#include <math.h>
2631-
2632-static void set_center_velocity_and_radius(struct grail_impl *impl,
2633- struct grail_element *slot)
2634-{
2635- const struct utouch_contact **tc = slot->touches;
2636- double x, y, vx, vy, r2, dx, dy;
2637- int i;
2638-
2639- switch (slot->num_touches) {
2640- case 1:
2641- x = tc[0]->x;
2642- y = tc[0]->y;
2643- vx = tc[0]->vx;
2644- vy = tc[0]->vy;
2645- r2 = 0;
2646- break;
2647- case 2:
2648- dx = 0.5 * (tc[1]->x - tc[0]->x);
2649- dy = 0.5 * (tc[1]->y - tc[0]->y);
2650- x = tc[0]->x + dx;
2651- y = tc[0]->y + dy;
2652- vx = 0.5 * (tc[0]->vx + tc[1]->vx);
2653- vy = 0.5 * (tc[0]->vy + tc[1]->vy);
2654- r2 = dx * dx + dy * dy;
2655- break;
2656- default:
2657- x = y = vx = vy = r2 = 0;
2658- for (i = 0; i < slot->num_touches; i++) {
2659- x += tc[i]->x;
2660- y += tc[i]->y;
2661- vx += tc[i]->vx;
2662- vy += tc[i]->vy;
2663- }
2664- x /= slot->num_touches;
2665- y /= slot->num_touches;
2666- vx /= slot->num_touches;
2667- vy /= slot->num_touches;
2668- for (i = 0; i < slot->num_touches; i++) {
2669- dx = tc[i]->x - x;
2670- dy = tc[i]->y - y;
2671- r2 += dx * dx + dy * dy;
2672- }
2673- r2 /= slot->num_touches;
2674- break;
2675- }
2676-
2677- slot->center.x = x;
2678- slot->center.y = y;
2679- slot->velocity.x = 1000 * vx;
2680- slot->velocity.y = 1000 * vy;
2681- slot->radius2 = r2;
2682-}
2683-
2684-static void set_transform(struct grail_impl *impl, struct grail_element *slot,
2685- double ds, double dc)
2686-{
2687- const struct grail_element *pslot = slot->prev;
2688- double dx = slot->center.x - pslot->center.x;
2689- double dy = slot->center.y - pslot->center.y;
2690- float *T = slot->transform;
2691-
2692- T[0] = dc;
2693- T[1] = ds;
2694- T[2] = dx;
2695- T[3] = -ds;
2696- T[4] = dc;
2697- T[5] = dy;
2698-
2699- slot->drag.x = pslot->drag.x + dx;
2700- slot->drag.y = pslot->drag.y + dy;
2701-}
2702-
2703-static void start_slot(struct grail_impl *impl,
2704- struct grail_element *slot,
2705- const struct utouch_frame *touch)
2706-{
2707- float *T = slot->transform;
2708-
2709- slot->id = impl->seqid++ & GRAIL_ID_MAX;
2710- slot->expect_mask = GRAIL_EXPECT_MASK;
2711- slot->active_mask = 0;
2712- slot->start_time = touch->time;
2713- set_center_velocity_and_radius(impl, slot);
2714- T[0] = T[4] = 1;
2715- T[1] = T[2] = T[3] = T[5] = 0;
2716- slot->drag.x = 0;
2717- slot->drag.y = 0;
2718- slot->scale2 = 1;
2719- slot->angle = 0;
2720-}
2721-
2722-static void update_slot(struct grail_impl *impl,
2723- struct grail_element *slot,
2724- double ds, double dc)
2725-{
2726- const struct grail_element *pslot = slot->prev;
2727-
2728- slot->id = pslot->id;
2729- slot->start_time = pslot->start_time;
2730- slot->expect_mask = pslot->expect_mask;
2731- slot->active_mask = pslot->active_mask;
2732-
2733- set_center_velocity_and_radius(impl, slot);
2734- set_transform(impl, slot, ds, dc);
2735-
2736- slot->scale2 = pslot->scale2 * (ds * ds + dc * dc);
2737- slot->angle = pslot->angle + ds / dc; /* atan2(ds, dc) */
2738-}
2739-
2740-static void stop_slot(struct grail_impl *impl,
2741- struct grail_element *slot)
2742-{
2743- const struct grail_element *pslot = slot->prev;
2744- float *T = slot->transform;
2745-
2746- slot->id = -1;
2747- slot->num_touches = 0;
2748- slot->start_time = pslot->start_time;
2749- slot->expect_mask = 0;
2750- slot->active_mask = pslot->active_mask;
2751- slot->center = pslot->center;
2752- slot->velocity = pslot->velocity;
2753- slot->radius2 = pslot->radius2;
2754- T[0] = T[4] = 1;
2755- T[1] = T[2] = T[3] = T[5] = 0;
2756- slot->drag = pslot->drag;
2757- slot->scale2 = pslot->scale2;
2758- slot->angle = pslot->angle;
2759-}
2760-
2761-static void set_slot_one(struct grail_impl *impl,
2762- struct grail_element *slot,
2763- const struct utouch_frame *touch,
2764- const struct utouch_contact *t1)
2765-{
2766- const struct grail_element *pslot = slot->prev;
2767- const struct utouch_contact *p1 = pslot->touches[0];
2768-
2769- if (!t1->active) {
2770- stop_slot(impl, slot);
2771- return;
2772- }
2773-
2774- slot->touches[0] = t1;
2775- slot->num_touches = 1;
2776-
2777- if (pslot->num_touches != slot->num_touches || t1->id != p1->id) {
2778- start_slot(impl, slot, touch);
2779- return;
2780- }
2781-
2782- update_slot(impl, slot, 0, 1);
2783-}
2784-
2785-static void set_slot_two(struct grail_impl *impl,
2786- struct grail_element *slot,
2787- const struct utouch_frame *touch,
2788- const struct utouch_contact *t1,
2789- const struct utouch_contact *t2)
2790-{
2791- const struct grail_element *pslot = slot->prev;
2792- const struct utouch_contact *p1 = pslot->touches[0];
2793- const struct utouch_contact *p2 = pslot->touches[1];
2794- double tx, ty, px, py, d2;
2795-
2796- if (!t1->active || !t2->active) {
2797- stop_slot(impl, slot);
2798- return;
2799- }
2800-
2801- slot->touches[0] = t1;
2802- slot->touches[1] = t2;
2803- slot->num_touches = 2;
2804-
2805- if (pslot->num_touches != slot->num_touches ||
2806- t1->id != p1->id || t2->id != p2->id) {
2807- start_slot(impl, slot, touch);
2808- return;
2809- }
2810-
2811- tx = t2->x - t1->x;
2812- ty = t2->y - t1->y;
2813- px = p2->x - p1->x;
2814- py = p2->y - p1->y;
2815-
2816- d2 = px * px + py * py;
2817- if (d2 > 0) {
2818- px /= d2;
2819- py /= d2;
2820- }
2821-
2822- update_slot(impl, slot, tx * py - ty * px, tx * px + ty * py);
2823-}
2824-
2825-static void set_slot_multi(struct grail_impl *impl,
2826- struct grail_element *slot,
2827- struct grail_frame *frame,
2828- const struct utouch_frame *touch)
2829-{
2830- const struct grail_element *pslot = slot->prev;
2831- struct grail_element **slots = frame->slots;
2832- int i, j, n = impl->num_touches;
2833- struct grail_element *best = 0;
2834-
2835- if (touch->num_active < 3) {
2836- stop_slot(impl, slot);
2837- return;
2838- }
2839-
2840- memcpy(slot->touches, touch->active,
2841- touch->num_active * sizeof(slot->touches[0]));
2842- slot->num_touches = touch->num_active;
2843-
2844- if (pslot->num_touches != slot->num_touches) {
2845- start_slot(impl, slot, touch);
2846- return;
2847- }
2848-
2849- for (i = 0; i < slot->num_touches; i++) {
2850- if (slot->touches[i]->id != pslot->touches[i]->id) {
2851- start_slot(impl, slot, touch);
2852- return;
2853- }
2854- }
2855-
2856- for (i = 0; i < impl->num_touches; i++) {
2857- for (j = i + 1; j < impl->num_touches; j++) {
2858- struct grail_element *s = slots[n++];
2859- if (!s->num_touches)
2860- continue;
2861- if (!best || s->radius2 > best->radius2)
2862- best = s;
2863- }
2864- }
2865-
2866- update_slot(impl, slot, best->transform[1], best->transform[0]);
2867-}
2868-
2869-/**
2870- * Determine the center of rotation point.
2871- *
2872- * For any given point q that is transformed by a 2D affine transformation
2873- * matrix T about anchor point P the new point q' may be determined by the
2874- * following equation:
2875- *
2876- * q' = T * (q - P) + P
2877- *
2878- * T and P are dependent, so we can modify one and find a new value for the
2879- * other. We will label the original T and P as T0 and P0, and the new values
2880- * will be labeled T1 and P1. We can find new values by solving the following
2881- * equation:
2882- *
2883- * q' = T0 * (q - P0) + P0 = T1 * (q - P1) + P1
2884- *
2885- * In the calculations below, we use variables for the scalar values
2886- * that make up T0, P0, T1, and P1:
2887- *
2888- * T0: [ a -b c ] P0: [ x0 ] T1: [ a -b 0 ] P1: [ x1 ]
2889- * [ b a d ] [ y0 ] [ b a 0 ] [ y1 ]
2890- * [ 0 0 1 ] [ 0 ] [ 0 0 1 ] [ 0 ]
2891- *
2892- * Note that rotation and scaling are independent of the anchor point, so a and
2893- * b are equivalent between the transformation matrices.
2894- *
2895- * Since we know all the values of T0, P0, and T1, we can calculate the values
2896- * x1 and y1 in P1.
2897- */
2898-static inline int set_center_of_rotation(struct grail_element *e)
2899-{
2900- float a = e->transform[0];
2901- float b = e->transform[3];
2902- float c = e->transform[2];
2903- float d = e->transform[5];
2904- float x0 = e->center.x;
2905- float y0 = e->center.y;
2906- float x1;
2907- float y1;
2908-
2909- float div = a*a - 2*a + b*b + 1;
2910-
2911- if (fabsf(div) < 1e-5)
2912- return 0;
2913-
2914- x1 = (a*a*x0 - a*(2*x0+c) + b*b*x0 - b*d + c + x0) / div;
2915- y1 = (a*a*y0 - a*(2*y0+d) + b*b*y0 + b*c + d + y0) / div;
2916-
2917- e->rotation_center.x = x1;
2918- e->rotation_center.y = y1;
2919-
2920- return 1;
2921-}
2922-
2923-static void set_slots(struct grail_impl *impl,
2924- struct grail_frame *frame,
2925- const struct utouch_frame *touch)
2926-{
2927- struct grail_element **slots = frame->slots;
2928- struct utouch_contact *const *tc = touch->slots;
2929- int i, j, n = 0;
2930-
2931- for (i = 0; i < impl->num_touches; i++)
2932- set_slot_one(impl, slots[n++], touch, tc[i]);
2933-
2934- for (i = 0; i < impl->num_touches; i++)
2935- for (j = i + 1; j < impl->num_touches; j++)
2936- set_slot_two(impl, slots[n++], touch, tc[i], tc[j]);
2937-
2938- set_slot_multi(impl, slots[n++], frame, touch);
2939-}
2940-
2941-static void collect_transforms(struct grail_impl *impl,
2942- struct grail_frame *frame,
2943- const struct utouch_frame *touch)
2944-{
2945- const struct utouch_surface *s = utouch_frame_get_surface(impl->fh);
2946- const struct grail_control *ctl = impl->ctl;
2947- float d_x = ctl->bar_drag_x * (s->mapped_max_x - s->mapped_min_x);
2948- float d_y = ctl->bar_drag_y * (s->mapped_max_y - s->mapped_min_y);
2949- float ds2 = ctl->bar_scale * ctl->bar_scale;
2950- float dt;
2951- int i;
2952-
2953- for (i = 0; i < impl->num_slots; i++) {
2954- struct grail_element *s = frame->slots[i];
2955-
2956- if (!s->num_touches)
2957- continue;
2958-
2959- set_center_of_rotation(s);
2960-
2961- dt = touch->time - s->start_time;
2962- if (dt > ctl->glue_ms) {
2963- unsigned int mask = s->active_mask;
2964-
2965- if (fabs(s->drag.x) > d_x)
2966- mask |= GRAIL_EXPECT_DRAG_X;
2967- if (fabs(s->drag.y) > d_y)
2968- mask |= GRAIL_EXPECT_DRAG_Y;
2969- if (fabs(s->scale2 - 1) > ds2)
2970- mask |= GRAIL_EXPECT_SCALE;
2971- if (fabs(s->angle) > ctl->bar_angle)
2972- mask |= GRAIL_EXPECT_ANGLE;
2973-
2974- s->active_mask = mask;
2975-
2976- if (dt < ctl->drop_x_ms)
2977- mask |= GRAIL_EXPECT_DRAG_X;
2978- if (dt < ctl->drop_y_ms)
2979- mask |= GRAIL_EXPECT_DRAG_Y;
2980- if (dt < ctl->drop_scale_ms)
2981- mask |= GRAIL_EXPECT_SCALE;
2982- if (dt < ctl->drop_angle_ms)
2983- mask |= GRAIL_EXPECT_ANGLE;
2984-
2985- s->expect_mask &= mask;
2986- }
2987-
2988- frame->ongoing[frame->num_ongoing++] = s;
2989- }
2990-}
2991-
2992-const struct grail_frame GRAIL_PUBLIC *
2993-grail_pump_frame(grail_handle ge, const struct utouch_frame *touch)
2994-{
2995- struct grail_impl *impl = ge->impl;
2996- struct grail_frame *frame = impl->frames[impl->nextframe];
2997- const struct grail_frame *prev = frame->prev;
2998- int i;
2999-
3000- if (touch->slot_revision == touch->prev->slot_revision &&
3001- !prev->num_ongoing)
3002- return 0;
3003-
3004- frame->touch = touch;
3005- frame->num_ongoing = 0;
3006- for (i = 0; i < impl->num_slots; i++)
3007- frame->slots[i]->prev = prev->slots[i];
3008-
3009- set_slots(impl, frame, touch);
3010- collect_transforms(impl, frame, touch);
3011-
3012- impl->nextframe = (impl->nextframe + 1) % impl->num_frames;
3013-
3014- return frame;
3015-}
3016
3017=== removed file 'src/v2/grail-gestures.c'
3018--- src/v2/grail-gestures.c 2012-03-26 12:57:55 +0000
3019+++ src/v2/grail-gestures.c 1970-01-01 00:00:00 +0000
3020@@ -1,222 +0,0 @@
3021-/*****************************************************************************
3022- *
3023- * grail - Gesture Recognition And Instantiation Library
3024- *
3025- * Copyright (C) 2010-2012 Canonical Ltd.
3026- *
3027- * This library is free software: you can redistribute it and/or modify it
3028- * under the terms of the GNU Lesser General Public License version 3
3029- * as published by the Free Software Foundation.
3030- *
3031- * This library is distributed in the hope that it will be useful, but
3032- * WITHOUT ANY WARRANTY; without even the implied warranties of
3033- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3034- * PURPOSE. See the GNU Lesser General Public License for more details.
3035- *
3036- * You should have received a copy of the GNU Lesser General Public License
3037- * along with this library. If not, see <http://www.gnu.org/licenses/>.
3038- *
3039- ****************************************************************************/
3040-
3041-#include "grail-recognizer.h"
3042-#include "grail-impl.h"
3043-#include <math.h>
3044-
3045-/* Units of mm or radians */
3046-static const float FM_SN[DIM_FM] = { 0.13, 0.13, 0.26, 2 * M_PI / 1000 };
3047-static const float FM_BAR[DIM_FM] = { 2.6, 2.6, 5.2, 2 * M_PI / 50 };
3048-
3049-/* Units of ms */
3050-static const grail_time_t FM_HOLD_MS[DIM_FM] = { 60, 60, 60, 60 };
3051-static const grail_time_t FM_BAR_MS[DIM_FM] = { 300, 300, 500, 500 };
3052-static const grail_time_t SAMPLE_MS = 10;
3053-
3054-static const float EPS = 1e-3;
3055-
3056-static void compute_position(float *x, float *y,
3057- const struct utouch_frame *frame)
3058-{
3059- int i, n = frame->num_active;
3060- *x = 0;
3061- *y = 0;
3062- if (n < 1)
3063- return;
3064- for (i = 0; i < n; i++) {
3065- const struct utouch_contact *t = frame->active[i];
3066- *x += t->x;
3067- *y += t->y;
3068- }
3069- *x /= n;
3070- *y /= n;
3071-}
3072-
3073-static float compute_radius(float x, float y,
3074- const struct utouch_frame *frame)
3075-{
3076- int i, n = frame->num_active;
3077- float r = 0, r2 = 0;
3078- if (n < 2)
3079- return r;
3080- for (i = 0; i < n; i++) {
3081- const struct utouch_contact *t = frame->active[i];
3082- float dx = t->x - x;
3083- float dy = t->y - y;
3084- r2 += dx * dx + dy * dy;
3085- }
3086- r2 /= n;
3087- r = sqrt(r2);
3088- return r;
3089-}
3090-
3091-static float compute_rotation(float x, float y, float r,
3092- const struct utouch_frame *frame)
3093-{
3094- int i, n = frame->num_active;
3095- float da = 0, darc2 = 0;
3096- if (n < 2)
3097- return da;
3098- for (i = 0; i < n; i++) {
3099- const struct utouch_contact *t = frame->active[i];
3100- const struct utouch_contact *ot = t->prev;
3101- float dx = t->x - x;
3102- float dy = t->y - y;
3103- float mx = t->x - ot->x;
3104- float my = t->y - ot->y;
3105- darc2 += dx * my - dy * mx;
3106- }
3107- darc2 /= n;
3108- da = darc2 / (r * r);
3109- return da;
3110-}
3111-
3112-static void move_reset(struct move_model *m, int i, float x, grail_time_t t)
3113-{
3114- struct filter_model *fm = &m->fm[i];
3115- fm->raw_delta = 0;
3116- fm->action_delta = 0;
3117- fm->velocity = 0;
3118- fm->value = x;
3119- fm->original = x;
3120- fm->original_ms = t;
3121- fm->sample = x;
3122- fm->sample_ms = t;
3123- m->tickle &= ~(1 << i);
3124- m->active &= ~(1 << i);
3125- m->timeout &= ~(1 << i);
3126-}
3127-
3128-static void move_update(struct move_model *m, int i, float x, grail_time_t t)
3129-{
3130- struct filter_model *fm = &m->fm[i];
3131- float dt = t - fm->sample_ms;
3132-
3133- if (fabs(x - fm->value) < fm->fuzz)
3134- return;
3135-
3136- fm->raw_delta = x - fm->value;
3137- fm->action_delta = fm->raw_delta;
3138- fm->value = x;
3139- if (dt > SAMPLE_MS) {
3140- fm->velocity = (x - fm->sample) / dt;
3141- fm->sample = x;
3142- fm->sample_ms = t;
3143- }
3144- if (fabs(fm->raw_delta) > EPS)
3145- m->tickle |= (1 << i);
3146- else
3147- m->tickle &= ~(1 << i);
3148- if (m->active & (1 << i))
3149- return;
3150- fm->action_delta = 0;
3151- if (fabs(x - fm->original) > fm->bar) {
3152- if (t - fm->original_ms > fm->hold_ms) {
3153- m->active |= (1 << i);
3154- fm->action_delta = x - fm->original;
3155- }
3156- } else if (t - fm->original_ms > fm->bar_ms) {
3157- m->timeout |= (1 << i);
3158- }
3159-}
3160-
3161-void gru_init_motion(struct grail *ge)
3162-{
3163- struct utouch_surface *s = utouch_frame_get_surface(ge->impl->fh);
3164- struct gesture_recognizer *gru = ge->gru;
3165- struct move_model *m = &gru->move;
3166- float U[DIM_FM]; /* Device unit dimensions */
3167- float P[DIM_FM]; /* Device physical dimensions */
3168- int i;
3169- U[FM_X] = s->mapped_max_x - s->mapped_min_x;
3170- U[FM_Y] = s->mapped_max_y - s->mapped_min_y;
3171- U[FM_R] = sqrt(U[FM_X] * U[FM_X] + U[FM_Y] * U[FM_Y]);
3172- U[FM_A] = 2 * M_PI;
3173- P[FM_X] = s->phys_width;
3174- P[FM_Y] = s->phys_height;
3175- P[FM_R] = sqrt(P[FM_X] * P[FM_X] + P[FM_Y] * P[FM_Y]);
3176- P[FM_A] = 2 * M_PI;
3177- for (i = 0; i < DIM_FM; i++) {
3178- m->fm[i].fuzz = U[i] * FM_SN[i] / P[i];
3179- m->fm[i].bar = U[i] * FM_BAR[i] / P[i];
3180- m->fm[i].hold_ms = FM_HOLD_MS[i];
3181- m->fm[i].bar_ms = FM_BAR_MS[i];
3182- }
3183-}
3184-
3185-void gru_motion(struct grail *ge,
3186- const struct utouch_frame *frame)
3187-{
3188- const struct utouch_surface *s = utouch_frame_get_surface(ge->impl->fh);
3189- struct gesture_recognizer *gru = ge->gru;
3190- struct move_model *m = &gru->move;
3191- grail_time_t t = frame->time;
3192- float x, y, r, a;
3193-
3194- compute_position(&x, &y, frame);
3195- if (frame->prev->revision != frame->revision) {
3196- r = compute_radius(x, y, frame);
3197- a = 0;
3198- move_reset(m, FM_X, x, t);
3199- move_reset(m, FM_Y, y, t);
3200- move_reset(m, FM_R, r, t);
3201- move_reset(m, FM_A, a, t);
3202- m->single = 0;
3203- m->multi = 0;
3204- } else if (frame->num_active < 2) {
3205- r = 0;
3206- a = 0;
3207- move_update(m, FM_X, x, t);
3208- move_update(m, FM_Y, y, t);
3209- move_reset(m, FM_R, r, t);
3210- move_reset(m, FM_A, a, t);
3211- m->single = 1;
3212- m->multi = 0;
3213- } else {
3214- r = compute_radius(x, y, frame);
3215- a = m->fm[FM_A].value;
3216- if (!s->is_semi_mt)
3217- a += compute_rotation(x, y, r, frame);
3218- move_update(m, FM_X, x, t);
3219- move_update(m, FM_Y, y, t);
3220- move_update(m, FM_R, r, t);
3221- move_update(m, FM_A, a, t);
3222- m->single = 0;
3223- m->multi = 1;
3224- }
3225- m->ntouch = frame->num_active;
3226- m->time = t;
3227-}
3228-
3229-void gru_event(struct grail *ge, int gid,
3230- const struct move_model *m,
3231- const grail_prop_t *prop, int nprop)
3232-{
3233- gin_gid_event(ge, gid, m->fm[FM_X].value, m->fm[FM_Y].value, m->ntouch,
3234- prop, nprop, 0);
3235-}
3236-
3237-void gru_end(struct grail *ge, int gid, const struct move_model *m,
3238- const grail_prop_t *prop, int nprop)
3239-{
3240- gin_gid_end(ge, gid, m->fm[FM_X].value, m->fm[FM_Y].value, m->ntouch,
3241- prop, nprop);
3242-}
3243
3244=== removed file 'src/v2/grail-gestures.h'
3245--- src/v2/grail-gestures.h 2012-03-26 12:57:55 +0000
3246+++ src/v2/grail-gestures.h 1970-01-01 00:00:00 +0000
3247@@ -1,114 +0,0 @@
3248-/*****************************************************************************
3249- *
3250- * grail - Gesture Recognition And Instantiation Library
3251- *
3252- * Copyright (C) 2010-2012 Canonical Ltd.
3253- *
3254- * This library is free software: you can redistribute it and/or modify it
3255- * under the terms of the GNU Lesser General Public License version 3
3256- * as published by the Free Software Foundation.
3257- *
3258- * This library is distributed in the hope that it will be useful, but
3259- * WITHOUT ANY WARRANTY; without even the implied warranties of
3260- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3261- * PURPOSE. See the GNU Lesser General Public License for more details.
3262- *
3263- * You should have received a copy of the GNU Lesser General Public License
3264- * along with this library. If not, see <http://www.gnu.org/licenses/>.
3265- *
3266- ****************************************************************************/
3267-
3268-#ifndef GRAIL_GESTURES_H
3269-#define GRAIL_GESTURES_H
3270-
3271-#include "grail-inserter.h"
3272-
3273-#define PRIO_POINTER 1
3274-#define PRIO_GESTURE 2
3275-#define PRIO_ENV 3
3276-#define PRIO_META 4
3277-#define PRIO_TAP 5
3278-
3279-#define DIM_FM 4
3280-
3281-#define FM_X 0
3282-#define FM_Y 1
3283-#define FM_R 2
3284-#define FM_A 3
3285-
3286-struct filter_model {
3287- float raw_delta;
3288- float action_delta;
3289- float velocity;
3290- float value;
3291- float original;
3292- float sample;
3293- float fuzz;
3294- float bar;
3295- grail_time_t original_ms;
3296- grail_time_t sample_ms;
3297- grail_time_t hold_ms;
3298- grail_time_t bar_ms;
3299-};
3300-
3301-struct move_model {
3302- struct filter_model fm[DIM_FM];
3303- int tickle, active, timeout;
3304- int single, multi, ntouch;
3305- grail_time_t time;
3306-};
3307-
3308-void gru_init_motion(struct grail *ge);
3309-void gru_motion(struct grail *ge,
3310- const struct utouch_frame *frame);
3311-void gru_event(struct grail *ge, int gid,
3312- const struct move_model *move,
3313- const grail_prop_t *prop, int nprop);
3314-void gru_end(struct grail *ge, int gid,
3315- const struct move_model *move,
3316- const grail_prop_t *prop, int nprop);
3317-
3318-struct combo_model {
3319- int active, gid;
3320- int mintouch, maxtouch;
3321- int nprop;
3322- grail_prop_t prop[DIM_GRAIL_PROP];
3323-};
3324-
3325-int gru_touch(struct grail *ge,
3326- const struct utouch_frame *frame);
3327-int gru_drag(struct grail *ge,
3328- const struct utouch_frame *frame);
3329-int gru_pinch(struct grail *ge,
3330- const struct utouch_frame *frame);
3331-int gru_rotate(struct grail *ge,
3332- const struct utouch_frame *frame);
3333-
3334-static inline int out_of_bounds(const struct combo_model *s,
3335- const struct move_model *m)
3336-{
3337- return m->ntouch < s->mintouch || m->ntouch > s->maxtouch;
3338-}
3339-
3340-int gru_wintouch(struct grail *ge,
3341- const struct utouch_frame *frame);
3342-int gru_windrag(struct grail *ge,
3343- const struct utouch_frame *frame);
3344-int gru_winpinch(struct grail *ge,
3345- const struct utouch_frame *frame);
3346-int gru_winrotate(struct grail *ge,
3347- const struct utouch_frame *frame);
3348-
3349-struct tapping_model {
3350- grail_time_t start;
3351- int mintouch, maxtouch;
3352- int active, gid, tap;
3353- int nprop;
3354- grail_prop_t prop[DIM_GRAIL_PROP];
3355-};
3356-
3357-int gru_tapping(struct grail *ge,
3358- const struct utouch_frame *frame);
3359-
3360-#endif
3361-
3362
3363=== removed file 'src/v2/grail-impl.h'
3364--- src/v2/grail-impl.h 2012-03-26 12:57:55 +0000
3365+++ src/v2/grail-impl.h 1970-01-01 00:00:00 +0000
3366@@ -1,87 +0,0 @@
3367-/*****************************************************************************
3368- *
3369- * grail - Gesture Recognition And Instantiation Library
3370- *
3371- * Copyright (C) 2010-2012 Canonical Ltd.
3372- *
3373- * This library is free software: you can redistribute it and/or modify it
3374- * under the terms of the GNU Lesser General Public License version 3
3375- * as published by the Free Software Foundation.
3376- *
3377- * This library is distributed in the hope that it will be useful, but
3378- * WITHOUT ANY WARRANTY; without even the implied warranties of
3379- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3380- * PURPOSE. See the GNU Lesser General Public License for more details.
3381- *
3382- * You should have received a copy of the GNU Lesser General Public License
3383- * along with this library. If not, see <http://www.gnu.org/licenses/>.
3384- *
3385- ****************************************************************************/
3386-
3387-#ifndef GRAIL_IMPL_H
3388-#define GRAIL_IMPL_H
3389-
3390-#define MTDEV_NO_LEGACY_API
3391-#define GRAIL_NO_LEGACY_API
3392-
3393-#include <grail.h>
3394-#include <utouch/frame-mtdev.h>
3395-#include "evbuf.h"
3396-#include "grailbuf.h"
3397-
3398-#define DIM_TOUCH 32
3399-#define DIM_TOUCH_BYTES ((DIM_TOUCH + 7) >> 3)
3400-#define GRAIL_ID_MAX 0xffff
3401-
3402-#define MIN(a, b) ((a) < (b) ? (a) : (b))
3403-#define MAX(a, b) ((a) > (b) ? (a) : (b))
3404-
3405-typedef void *grail_select_callback;
3406-
3407-/*
3408- * In this implementation, there can be N one-gestures, N (N - 1) / 2
3409- * two-gestures, and one global gesture.
3410- */
3411-static inline int get_slot_count(int n)
3412-{
3413- return n + n * (n - 1) / 2 + 1;
3414-}
3415-
3416-int create_grail2(struct grail_impl *x,
3417- utouch_frame_handle fh,
3418- unsigned int num_frames,
3419- void *select,
3420- unsigned int version,
3421- unsigned int control_size,
3422- unsigned int frame_size,
3423- unsigned int slot_size);
3424-
3425-void destroy_grail2(struct grail_impl *x);
3426-
3427-struct grail_impl {
3428- struct evemu_device *evemu;
3429- struct mtdev *mtdev;
3430- utouch_frame_handle fh;
3431- const struct utouch_frame *touch;
3432- struct evbuf evbuf;
3433- struct grailbuf gbuf;
3434- int filter_abs;
3435- int ongoing;
3436- int gesture;
3437- FILE *fptest;
3438- int fast_fileread;
3439- /* new stuff below */
3440- struct grail_control *ctl;
3441- grail_select_callback select;
3442- int num_frames;
3443- int num_slots;
3444- int num_touches;
3445- int nextframe;
3446- int seqid;
3447- unsigned int control_size;
3448- unsigned int frame_size;
3449- unsigned int slot_size;
3450- struct grail_frame **frames;
3451-};
3452-
3453-#endif
3454
3455=== removed file 'src/v2/grail-init.c'
3456--- src/v2/grail-init.c 2012-03-26 12:57:55 +0000
3457+++ src/v2/grail-init.c 1970-01-01 00:00:00 +0000
3458@@ -1,235 +0,0 @@
3459-/*****************************************************************************
3460- *
3461- * grail - Gesture Recognition And Instantiation Library
3462- *
3463- * Copyright (C) 2010-2012 Canonical Ltd.
3464- *
3465- * This library is free software: you can redistribute it and/or modify it
3466- * under the terms of the GNU Lesser General Public License version 3
3467- * as published by the Free Software Foundation.
3468- *
3469- * This library is distributed in the hope that it will be useful, but
3470- * WITHOUT ANY WARRANTY; without even the implied warranties of
3471- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3472- * PURPOSE. See the GNU Lesser General Public License for more details.
3473- *
3474- * You should have received a copy of the GNU Lesser General Public License
3475- * along with this library. If not, see <http://www.gnu.org/licenses/>.
3476- *
3477- ****************************************************************************/
3478-
3479-#include "grail-impl.h"
3480-#include <stdlib.h>
3481-#include <string.h>
3482-#include <math.h>
3483-
3484-static struct grail_control *create_control(int size)
3485-{
3486- struct grail_control *c = calloc(1, size);
3487-
3488- if (!c)
3489- return 0;
3490-
3491- c->glue_ms = 60;
3492- c->bar_drag_x = 0.03;
3493- c->bar_drag_y = 0.03;
3494- c->bar_scale = 0.3;
3495- c->bar_angle = 0.1;
3496- c->drop_x_ms = 300;
3497- c->drop_y_ms = 300;
3498- c->drop_scale_ms = 300;
3499- c->drop_angle_ms = 300;
3500-
3501- return c;
3502-}
3503-
3504-static void destroy_slots(struct grail_element **slots, int nslot)
3505-{
3506- int i;
3507-
3508- if (slots) {
3509- for (i = nslot - 1; i >= 0; i--)
3510- free(slots[i]);
3511- free(slots);
3512- }
3513-}
3514-
3515-static void destroy_frame(struct grail_frame *frame, int nslot)
3516-{
3517- if (frame) {
3518- destroy_slots(frame->slots, nslot);
3519- free(frame->ongoing);
3520- free(frame);
3521- }
3522-}
3523-
3524-static void destroy_frames(struct grail_frame **frames, int nframe, int nslot)
3525-{
3526- int i;
3527-
3528- if (frames) {
3529- for (i = nframe - 1; i >= 0; i--)
3530- destroy_frame(frames[i], nslot);
3531- free(frames);
3532- }
3533-}
3534-
3535-static struct grail_element **create_slots(int nslot, int ntouch, int size)
3536-{
3537- struct grail_element **slots;
3538- struct grail_element *s;
3539- int i;
3540-
3541- slots = calloc(nslot, sizeof(slots[0]));
3542- if (!slots)
3543- return 0;
3544-
3545- for (i = 0; i < nslot; i++) {
3546- s = calloc(1, size + ntouch * sizeof(void *));
3547- if (!s)
3548- goto out;
3549- s->slot = i;
3550- s->id = -1;
3551- s->touches = (void *)((char *)s + size);
3552- slots[i] = s;
3553- }
3554-
3555- return slots;
3556- out:
3557- destroy_slots(slots, nslot);
3558- return 0;
3559-}
3560-
3561-static struct grail_frame *create_frame(int nslot, int ntouch,
3562- int frame_size, int slot_size)
3563-{
3564- struct grail_frame *frame;
3565-
3566- frame = calloc(1, frame_size);
3567- if (!frame)
3568- return 0;
3569-
3570- frame->ongoing = calloc(nslot, sizeof(frame->ongoing[0]));
3571- frame->slots = create_slots(nslot, ntouch, slot_size);
3572- if (!frame->ongoing || !frame->slots)
3573- goto out;
3574-
3575- return frame;
3576- out:
3577- destroy_frame(frame, nslot);
3578- return 0;
3579-}
3580-
3581-static struct grail_frame **create_frames(int nframe, int nslot, int ntouch,
3582- int frame_size, int slot_size)
3583-{
3584- struct grail_frame **frames;
3585- struct grail_frame *f;
3586- int i;
3587-
3588- frames = calloc(nframe, sizeof(frames[0]));
3589- if (!frames)
3590- return 0;
3591-
3592- for (i = 0; i < nframe; i++) {
3593- f = create_frame(nslot, ntouch, frame_size, slot_size);
3594- if (!f)
3595- goto out;
3596- frames[i] = f;
3597- }
3598-
3599- return frames;
3600- out:
3601- destroy_frames(frames, nframe, nslot);
3602- return 0;
3603-}
3604-
3605-int create_grail2(struct grail_impl *x,
3606- utouch_frame_handle fh,
3607- unsigned int num_frames,
3608- grail_select_callback select,
3609- unsigned int version,
3610- unsigned int control_size,
3611- unsigned int frame_size,
3612- unsigned int slot_size)
3613-{
3614- unsigned int ntouch = utouch_frame_get_num_slots(fh);
3615- unsigned int nslot = get_slot_count(ntouch);
3616- int i;
3617-
3618- x->select = select;
3619- x->control_size = MAX(control_size, sizeof(struct grail_control));
3620- x->frame_size = MAX(frame_size, sizeof(struct grail_frame));
3621- x->slot_size = MAX(slot_size, sizeof(struct grail_element));
3622-
3623- x->num_frames = num_frames;
3624- x->num_slots = nslot;
3625- x->num_touches = ntouch;
3626-
3627- x->ctl = create_control(x->control_size);
3628- if (!x->ctl)
3629- goto freemem;
3630-
3631- x->frames = create_frames(num_frames, nslot, ntouch,
3632- x->frame_size, x->slot_size);
3633- if (!x->frames)
3634- goto freemem;
3635-
3636- for (i = 0; i < num_frames; i++)
3637- x->frames[(i + 1) % num_frames]->prev = x->frames[i];
3638-
3639- return 0;
3640-
3641- freemem:
3642- destroy_grail2(x);
3643- return -ENOMEM;
3644-}
3645-
3646-void destroy_grail2(struct grail_impl *x)
3647-{
3648- destroy_frames(x->frames, x->num_frames, x->num_slots);
3649- free(x->ctl);
3650-}
3651-
3652-grail_handle GRAIL_PUBLIC grail_new_raw(utouch_frame_handle fh,
3653- unsigned int num_frames,
3654- grail_select_callback select,
3655- unsigned int version,
3656- unsigned int control_size,
3657- unsigned int frame_size,
3658- unsigned int slot_size)
3659-{
3660- struct grail *ge;
3661- struct grail_impl *x;
3662-
3663- ge = calloc(1, sizeof(*ge));
3664- if (!ge)
3665- return 0;
3666- x = calloc(1, sizeof(*x));
3667- if (!x)
3668- goto out;
3669- x->fh = fh;
3670- if (create_grail2(x, fh, num_frames, select,
3671- version, control_size, frame_size, slot_size))
3672- goto out;
3673-
3674- ge->impl = x;
3675- return ge;
3676-
3677- out:
3678- free(x);
3679- free(ge);
3680- return 0;
3681-}
3682-
3683-void GRAIL_PUBLIC grail_delete(grail_handle ge)
3684-{
3685- destroy_grail2(ge->impl);
3686- free(ge->impl);
3687- free(ge);
3688-}
3689-
3690-struct grail_control GRAIL_PUBLIC *grail_get_control(grail_handle ge)
3691-{
3692- return ge->impl->ctl;
3693-}
3694
3695=== removed file 'src/v2/grail-inserter.c'
3696--- src/v2/grail-inserter.c 2012-03-26 12:57:55 +0000
3697+++ src/v2/grail-inserter.c 1970-01-01 00:00:00 +0000
3698@@ -1,303 +0,0 @@
3699-/*****************************************************************************
3700- *
3701- * grail - Gesture Recognition And Instantiation Library
3702- *
3703- * Copyright (C) 2010-2012 Canonical Ltd.
3704- *
3705- * This library is free software: you can redistribute it and/or modify it
3706- * under the terms of the GNU Lesser General Public License version 3
3707- * as published by the Free Software Foundation.
3708- *
3709- * This library is distributed in the hope that it will be useful, but
3710- * WITHOUT ANY WARRANTY; without even the implied warranties of
3711- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
3712- * PURPOSE. See the GNU Lesser General Public License for more details.
3713- *
3714- * You should have received a copy of the GNU Lesser General Public License
3715- * along with this library. If not, see <http://www.gnu.org/licenses/>.
3716- *
3717- ****************************************************************************/
3718-
3719-#include "grail-gestures.h"
3720-#include "grail-inserter.h"
3721-#include "grail-impl.h"
3722-#include <malloc.h>
3723-#include <string.h>
3724-#include <errno.h>
3725-#include <math.h>
3726-
3727-static const int MAX_GESTURE_ID = 0xfff;
3728-
3729-static int find_gslot(const struct gesture_inserter *gin, int gid)
3730-{
3731- int i;
3732- grail_mask_foreach(i, gin->used, sizeof(gin->used))
3733- if (gin->state[i].id == gid)
3734- return i;
3735- return -1;
3736-}
3737-
3738-static int mask_overlap(const grail_mask_t *a, const grail_mask_t *b,
3739- int bytes)
3740-{
3741- int i;
3742-
3743- for (i = 0; i < bytes; i++)
3744- if (a[i] & b[i])
3745- return 1;
3746-
3747- return 0;
3748-}
3749-
3750-// todo: spanning tree for multi-user case
3751-static void setup_new_gestures(struct grail *ge,
3752- const struct utouch_frame *frame)
3753-{
3754- struct gesture_inserter *gin = ge->gin;
3755- grail_mask_t types[DIM_GRAIL_TYPE_BYTES];
3756- grail_mask_t span[DIM_TOUCH_BYTES];
3757- struct grail_client_info info[DIM_CLIENT];
3758- int i, j, nclient = 0;
3759- int nfresh = grail_mask_count(gin->fresh, sizeof(gin->fresh));
3760- if (!nfresh)
3761- return;
3762-
3763- memset(types, 0, sizeof(types));
3764- memset(span, 0, sizeof(span));
3765-
3766- grail_mask_foreach(i, gin->fresh, sizeof(gin->fresh)) {
3767- struct slot_state *s = &gin->state[i];
3768- grail_mask_set(types, s->type);
3769- grail_mask_set_mask(span, s->span, sizeof(span));
3770- }
3771-
3772- nclient = gin_get_clients(ge, info, DIM_CLIENT, types, sizeof(types),
3773- span, sizeof(span), frame);
3774-
3775- grail_mask_foreach(i, gin->fresh, sizeof(gin->fresh)) {
3776- struct slot_state *s = &gin->state[i];
3777- s->nclient = 0;
3778- for (j = 0; j < nclient; j++) {
3779- if (!grail_mask_get(info[j].mask, s->type))
3780- continue;
3781- if (gin->grab_active &&
3782- info[j].id.client != gin->grab_client)
3783- continue;
3784- if (grail_mask_get(info[j].mask, GRAIL_TYPE_SYSFLAG1)) {
3785- gin->grab_active = 1;
3786- gin->grab_client = info[j].id.client;
3787- }
3788- s->client_id[s->nclient++] = info[j].id;
3789- }
3790- }
3791-
3792- memset(gin->fresh, 0, sizeof(gin->fresh));
3793-}
3794-
3795-int gin_init(struct grail *ge)
3796-{
3797- struct gesture_inserter *gin;
3798- int i;
3799- gin = calloc(1, sizeof(*gin));
3800- if (!gin)
3801- return -ENOMEM;
3802- for (i = 0; i < DIM_INSTANCE; i++)
3803- grail_mask_set(gin->unused, i);
3804- ge->gin = gin;
3805- return 0;
3806-}
3807-
3808-void gin_destroy(struct grail *ge)
3809-{
3810- free(ge->gin);
3811- ge->gin = NULL;
3812-}
3813-
3814-void gin_frame_begin(struct grail *ge, const struct utouch_frame *frame)
3815-{
3816- struct gesture_inserter *gin = ge->gin;
3817- memset(gin->types, 0, sizeof(gin->types));
3818- gin->time = frame->time;
3819- if (frame->num_active && !frame->prev->num_active)
3820- gin->grab_active = 0;
3821-}
3822-
3823-void gin_frame_end(struct grail *ge, const struct utouch_frame *frame)
3824-{
3825- struct gesture_inserter *gin = ge->gin;
3826- grail_mask_t keep[DIM_TOUCH_BYTES];
3827- int i, hold[2] = { 0, 0 }, discard[2] = { 0, 0 };
3828-
3829- memset(keep, 0, sizeof(keep));
3830- setup_new_gestures(ge, frame);
3831-
3832- grail_mask_foreach(i, gin->used, sizeof(gin->used)) {
3833- struct slot_state *s = &gin->state[i];
3834- if (!s->nclient)
3835- continue;
3836- if (s->priority > hold[s->slice])
3837- hold[s->slice] = s->priority;
3838- if (s->status != GRAIL_STATUS_UPDATE)
3839- continue;
3840- if (s->priority > discard[s->slice])
3841- discard[s->slice] = s->priority;
3842- }
3843-
3844- grail_mask_foreach(i, gin->used, sizeof(gin->used)) {
3845- struct slot_state *s = &gin->state[i];
3846- if (!s->nclient || (s->priority < discard[s->slice] && !s->sent))
3847- gin_gid_discard(ge, s->id);
3848- }
3849-
3850- grail_mask_foreach(i, gin->used, sizeof(gin->used)) {
3851- struct slot_state *s = &gin->state[i];
3852- if (s->slice == 1)
3853- grail_mask_set_mask(keep, s->span, sizeof(keep));
3854- }
3855-
3856- grail_mask_foreach(i, gin->used, sizeof(gin->used)) {
3857- struct slot_state *s = &gin->state[i];
3858- if (!s->timeout)
3859- continue;
3860- if (mask_overlap(keep, s->span, sizeof(keep)))
3861- continue;
3862- gin_gid_discard(ge, s->id);
3863- }
3864-
3865- grail_mask_foreach(i, gin->used, sizeof(gin->used)) {
3866- struct slot_state *s = &gin->state[i];
3867- struct gesture_event ev;
3868- grail_mask_set(gin->types, s->type);
3869- if (s->priority < hold[s->slice] && !s->sent)
3870- continue;
3871- while (!gebuf_empty(&s->buf)) {
3872- gebuf_get(&s->buf, &ev);
3873- gin_send_event(ge, s, &ev, frame);
3874- }
3875- s->sent = 1;
3876- }
3877-
3878- grail_mask_foreach(i, gin->used, sizeof(gin->used)) {
3879- struct slot_state *s = &gin->state[i];
3880- if (s->status == GRAIL_STATUS_END)
3881- gin_gid_discard(ge, s->id);
3882- }
3883-}
3884-
3885-int gin_gid_begin(struct grail *ge, int type, int priority,
3886- const struct utouch_frame *frame)
3887-{
3888- struct gesture_inserter *gin = ge->gin;
3889- struct slot_state *s;
3890- int slot;
3891- int i = grail_mask_get_first(gin->unused, sizeof(gin->unused));
3892- if (i < 0)
3893- return -1;
3894- s = &gin->state[i];
3895- s->type = type;
3896- if (priority < 0) {
3897- s->priority = -priority;
3898- s->slice = 1;
3899- } else {
3900- s->priority = priority;
3901- s->slice = 0;
3902- }
3903- s->timeout = 0;
3904- s->sent = 0;
3905- s->id = gin->gestureid++ & MAX_GESTURE_ID;
3906- s->status = GRAIL_STATUS_BEGIN;
3907- s->nclient = 0;
3908- for (slot = 0; slot < DIM_TOUCH; slot++)
3909- grail_mask_modify(s->span, slot, frame->slots[slot]->active);
3910- gebuf_clear(&s->buf);
3911- grail_mask_clear(gin->unused, i);
3912- grail_mask_set(gin->fresh, i);
3913- grail_mask_set(gin->used, i);
3914- return s->id;
3915-}
3916-
3917-void gin_gid_discard(struct grail *ge, int gid)
3918-{
3919- struct gesture_inserter *gin = ge->gin;
3920- struct slot_state *s;
3921- int i = find_gslot(gin, gid);
3922- if (i < 0)
3923- return;
3924- s = &gin->state[i];
3925- gebuf_clear(&s->buf);
3926- s->status = GRAIL_STATUS_END;
3927- grail_mask_clear(gin->used, i);
3928- grail_mask_set(gin->unused, i);
3929-}
3930-
3931-void gin_gid_timeout(struct grail *ge, int gid)
3932-{
3933- int i = find_gslot(ge->gin, gid);
3934- if (i >= 0)
3935- ge->gin->state[i].timeout = 1;
3936-}
3937-
3938-void gin_gid_event(struct grail *ge, int gid,
3939- float x, float y, int ntouch,
3940- const grail_prop_t *prop, int nprop,
3941- int transient)
3942-{
3943- struct gesture_inserter *gin = ge->gin;
3944- struct gesture_event ev;
3945- struct slot_state *s;
3946- int i = find_gslot(gin, gid);
3947- if (i < 0)
3948- return;
3949- s = &gin->state[i];
3950- ev.status = transient ? GRAIL_STATUS_UPDATE : s->status;
3951- ev.ntouch = ntouch;
3952- ev.nprop = nprop;
3953- ev.time = gin->time;
3954- ev.pos.x = x;
3955- ev.pos.y = y;
3956- memcpy(ev.prop, prop, nprop * sizeof(grail_prop_t));
3957- gebuf_put(&s->buf, &ev);
3958- if (transient)
3959- s->status = GRAIL_STATUS_END;
3960- else if (s->status == GRAIL_STATUS_BEGIN)
3961- s->status = GRAIL_STATUS_UPDATE;
3962-}
3963-
3964-void gin_gid_end(struct grail *ge, int gid,
3965- float x, float y, int ntouch,
3966- const grail_prop_t *prop, int nprop)
3967-{
3968- struct gesture_inserter *gin = ge->gin;
3969- struct gesture_event ev;
3970- struct slot_state *s;
3971- int i = find_gslot(gin, gid);
3972- if (i < 0)
3973- return;
3974- s = &gin->state[i];
3975- if (s->status != GRAIL_STATUS_BEGIN) {
3976- ev.status = GRAIL_STATUS_END;
3977- ev.ntouch = ntouch;
3978- ev.nprop = nprop;
3979- ev.time = gin->time;
3980- ev.pos.x = x;
3981- ev.pos.y = y;
3982- memcpy(ev.prop, prop, nprop * sizeof(grail_prop_t));
3983- gebuf_put(&s->buf, &ev);
3984- }
3985- s->status = GRAIL_STATUS_END;
3986-}
3987-
3988-void GRAIL_PUBLIC grail_set_bbox(struct grail *ge,
3989- const struct grail_coord *tmin,
3990- const struct grail_coord *tmax)
3991-{
3992- struct utouch_surface *s = utouch_frame_get_surface(ge->impl->fh);
3993-
3994- s->mapped_min_x = tmin->x;
3995- s->mapped_min_y = tmin->y;
3996- s->mapped_max_x = tmax->x;
3997- s->mapped_max_y = tmax->y;
3998-
3999- if (ge->gru)
4000- gru_init_motion(ge);
4001-}
4002
4003=== removed file 'src/v2/grail-inserter.h'
4004--- src/v2/grail-inserter.h 2012-03-26 12:57:55 +0000
4005+++ src/v2/grail-inserter.h 1970-01-01 00:00:00 +0000
4006@@ -1,92 +0,0 @@
4007-/*****************************************************************************
4008- *
4009- * grail - Gesture Recognition And Instantiation Library
4010- *
4011- * Copyright (C) 2010-2012 Canonical Ltd.
4012- *
4013- * This library is free software: you can redistribute it and/or modify it
4014- * under the terms of the GNU Lesser General Public License version 3
4015- * as published by the Free Software Foundation.
4016- *
4017- * This library is distributed in the hope that it will be useful, but
4018- * WITHOUT ANY WARRANTY; without even the implied warranties of
4019- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
4020- * PURPOSE. See the GNU Lesser General Public License for more details.
4021- *
4022- * You should have received a copy of the GNU Lesser General Public License
4023- * along with this library. If not, see <http://www.gnu.org/licenses/>.
4024- *
4025- ****************************************************************************/
4026-
4027-#ifndef GRAIL_INSERTER_H
4028-#define GRAIL_INSERTER_H
4029-
4030-#include "grail-impl.h"
4031-#include "gebuf.h"
4032-
4033-#define DIM_EV_TYPE EV_CNT
4034-#define DIM_EV_TYPE_BYTES ((DIM_EV_TYPE + 7) >> 3)
4035-
4036-#define DIM_INSTANCE 32
4037-#define DIM_INSTANCE_BYTES ((DIM_INSTANCE + 7) >> 3)
4038-
4039-#define DIM_CLIENT 32
4040-
4041-struct slot_state {
4042- int type;
4043- int priority;
4044- int slice;
4045- int timeout;
4046- int sent;
4047- int id;
4048- int status;
4049- int nclient;
4050- struct grail_client_id client_id[DIM_CLIENT];
4051- grail_mask_t span[DIM_TOUCH_BYTES];
4052- struct gebuf buf;
4053-};
4054-
4055-struct gesture_inserter {
4056- struct slot_state state[DIM_INSTANCE];
4057- grail_mask_t types[DIM_GRAIL_TYPE_BYTES];
4058- grail_mask_t unused[DIM_INSTANCE_BYTES];
4059- grail_mask_t fresh[DIM_INSTANCE_BYTES];
4060- grail_mask_t used[DIM_INSTANCE_BYTES];
4061- grail_time_t time;
4062- int gestureid;
4063- int grab_active;
4064- int grab_client;
4065-};
4066-
4067-int gin_add_contact_props(const struct gesture_inserter *gin,
4068- grail_prop_t *prop, const struct utouch_frame *frame);
4069-
4070-int gin_get_clients(struct grail *ge,
4071- struct grail_client_info *info, int maxinfo,
4072- const grail_mask_t* types, int btypes,
4073- const grail_mask_t* span, int bspan,
4074- const struct utouch_frame *frame);
4075-void gin_send_event(struct grail *ge, struct slot_state *s,
4076- const struct gesture_event *ev,
4077- const struct utouch_frame *frame);
4078-
4079-int gin_init(struct grail *ge);
4080-void gin_destroy(struct grail *ge);
4081-
4082-void gin_frame_begin(struct grail *ge, const struct utouch_frame *frame);
4083-void gin_frame_end(struct grail *ge, const struct utouch_frame *frame);
4084-
4085-int gin_gid_begin(struct grail *ge, int type, int priority,
4086- const struct utouch_frame *frame);
4087-void gin_gid_discard(struct grail *ge, int gid);
4088-void gin_gid_timeout(struct grail *ge, int gid);
4089-
4090-void gin_gid_event(struct grail *ge, int gid,
4091- float x, float y, int ntouch,
4092- const grail_prop_t *prop, int nprop,
4093- int transient);
4094-void gin_gid_end(struct grail *ge, int gid,
4095- float x, float y, int ntouch,
4096- const grail_prop_t *prop, int nprop);
4097-
4098-#endif
4099
4100=== removed file 'src/v2/grail-legacy.c'
4101--- src/v2/grail-legacy.c 2012-03-26 12:57:55 +0000
4102+++ src/v2/grail-legacy.c 1970-01-01 00:00:00 +0000
4103@@ -1,63 +0,0 @@
4104-/*****************************************************************************
4105- *
4106- * grail - Gesture Recognition And Instantiation Library
4107- *
4108- * Copyright (C) 2010-2012 Canonical Ltd.
4109- *
4110- * This library is free software: you can redistribute it and/or modify it
4111- * under the terms of the GNU Lesser General Public License version 3
4112- * as published by the Free Software Foundation.
4113- *
4114- * This library is distributed in the hope that it will be useful, but
4115- * WITHOUT ANY WARRANTY; without even the implied warranties of
4116- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
4117- * PURPOSE. See the GNU Lesser General Public License for more details.
4118- *
4119- * You should have received a copy of the GNU Lesser General Public License
4120- * along with this library. If not, see <http://www.gnu.org/licenses/>.
4121- *
4122- ****************************************************************************/
4123-
4124-#include <grail.h>
4125-#include "grail-inserter.h"
4126-#include <string.h>
4127-#include <stdio.h>
4128-#include <unistd.h>
4129-#include <fcntl.h>
4130-#include <malloc.h>
4131-#include <errno.h>
4132-#include <stdlib.h>
4133-
4134-#ifndef GRAIL_NO_LEGACY_ABI
4135-
4136-void GRAIL_PUBLIC grail_filter_abs_events(struct grail *ge, int usage)
4137-{
4138- struct grail_impl *x = ge->impl;
4139- x->filter_abs = usage;
4140-}
4141-
4142-int GRAIL_PUBLIC grail_get_contacts(const struct grail *ge,
4143- struct grail_contact *touch, int max_touch)
4144-{
4145- const struct utouch_frame *frame = ge->impl->touch;
4146- int i;
4147- if (frame->num_active < max_touch)
4148- max_touch = frame->num_active;
4149- for (i = 0; i < max_touch; i++) {
4150- struct grail_contact *t = &touch[i];
4151- const struct utouch_contact *ct = frame->active[i];
4152- t->id = ct->id;
4153- t->tool_type = ct->tool_type;
4154- t->pos.x = ct->x;
4155- t->pos.y = ct->y;
4156- t->touch_major = ct->touch_major;
4157- t->touch_minor = ct->touch_minor;
4158- t->width_major = ct->width_major;
4159- t->width_minor = ct->width_minor;
4160- t->angle = ct->orientation;
4161- t->pressure = ct->pressure;
4162- }
4163- return max_touch;
4164-}
4165-
4166-#endif
4167
4168=== removed file 'src/v2/grail-recognizer.c'
4169--- src/v2/grail-recognizer.c 2012-03-26 12:57:55 +0000
4170+++ src/v2/grail-recognizer.c 1970-01-01 00:00:00 +0000
4171@@ -1,57 +0,0 @@
4172-/*****************************************************************************
4173- *
4174- * grail - Gesture Recognition And Instantiation Library
4175- *
4176- * Copyright (C) 2010-2012 Canonical Ltd.
4177- *
4178- * This library is free software: you can redistribute it and/or modify it
4179- * under the terms of the GNU Lesser General Public License version 3
4180- * as published by the Free Software Foundation.
4181- *
4182- * This library is distributed in the hope that it will be useful, but
4183- * WITHOUT ANY WARRANTY; without even the implied warranties of
4184- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
4185- * PURPOSE. See the GNU Lesser General Public License for more details.
4186- *
4187- * You should have received a copy of the GNU Lesser General Public License
4188- * along with this library. If not, see <http://www.gnu.org/licenses/>.
4189- *
4190- ****************************************************************************/
4191-
4192-#include "grail-recognizer.h"
4193-#include <string.h>
4194-#include <malloc.h>
4195-#include <errno.h>
4196-
4197-int gru_init(struct grail *ge)
4198-{
4199- struct gesture_recognizer *gru;
4200- gru = calloc(1, sizeof(struct gesture_recognizer));
4201- if (!gru)
4202- return -ENOMEM;
4203- ge->gru = gru;
4204- gru_init_motion(ge);
4205- return 0;
4206-}
4207-
4208-void gru_destroy(struct grail *ge)
4209-{
4210- free(ge->gru);
4211- ge->gru = NULL;
4212-}
4213-
4214-void gru_recognize(struct grail *ge, const struct utouch_frame *frame)
4215-{
4216- if (!ge->gin || !ge->gru)
4217- return;
4218- gru_motion(ge, frame);
4219- gru_touch(ge, frame);
4220- gru_drag(ge, frame);
4221- gru_pinch(ge, frame);
4222- gru_rotate(ge, frame);
4223- gru_wintouch(ge, frame);
4224- gru_windrag(ge, frame);
4225- gru_winpinch(ge, frame);
4226- gru_winrotate(ge, frame);
4227- gru_tapping(ge, frame);
4228-}
4229
4230=== removed file 'src/v2/grail-recognizer.h'
4231--- src/v2/grail-recognizer.h 2012-03-26 12:57:55 +0000
4232+++ src/v2/grail-recognizer.h 1970-01-01 00:00:00 +0000
4233@@ -1,43 +0,0 @@
4234-/*****************************************************************************
4235- *
4236- * grail - Gesture Recognition And Instantiation Library
4237- *
4238- * Copyright (C) 2010-2012 Canonical Ltd.
4239- *
4240- * This library is free software: you can redistribute it and/or modify it
4241- * under the terms of the GNU Lesser General Public License version 3
4242- * as published by the Free Software Foundation.
4243- *
4244- * This library is distributed in the hope that it will be useful, but
4245- * WITHOUT ANY WARRANTY; without even the implied warranties of
4246- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
4247- * PURPOSE. See the GNU Lesser General Public License for more details.
4248- *
4249- * You should have received a copy of the GNU Lesser General Public License
4250- * along with this library. If not, see <http://www.gnu.org/licenses/>.
4251- *
4252- ****************************************************************************/
4253-
4254-#ifndef GRAIL_RECOGNIZER_H
4255-#define GRAIL_RECOGNIZER_H
4256-
4257-#include "grail-gestures.h"
4258-
4259-struct gesture_recognizer {
4260- struct move_model move;
4261- struct combo_model touch;
4262- struct combo_model drag;
4263- struct combo_model pinch;
4264- struct combo_model rotate;
4265- struct combo_model wintouch;
4266- struct combo_model windrag;
4267- struct combo_model winpinch;
4268- struct combo_model winrotate;
4269- struct tapping_model tapping;
4270-};
4271-
4272-int gru_init(struct grail *ge);
4273-void gru_recognize(struct grail *ge, const struct utouch_frame *frame);
4274-void gru_destroy(struct grail *ge);
4275-
4276-#endif
4277
4278=== removed file 'src/v2/grailbuf.h'
4279--- src/v2/grailbuf.h 2012-03-26 12:57:55 +0000
4280+++ src/v2/grailbuf.h 1970-01-01 00:00:00 +0000
4281@@ -1,58 +0,0 @@
4282-/*****************************************************************************
4283- *
4284- * grail - Gesture Recognition And Instantiation Library
4285- *
4286- * Copyright (C) 2010-2012 Canonical Ltd.
4287- *
4288- * This library is free software: you can redistribute it and/or modify it
4289- * under the terms of the GNU Lesser General Public License version 3
4290- * as published by the Free Software Foundation.
4291- *
4292- * This library is distributed in the hope that it will be useful, but
4293- * WITHOUT ANY WARRANTY; without even the implied warranties of
4294- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
4295- * PURPOSE. See the GNU Lesser General Public License for more details.
4296- *
4297- * You should have received a copy of the GNU Lesser General Public License
4298- * along with this library. If not, see <http://www.gnu.org/licenses/>.
4299- *
4300- ****************************************************************************/
4301-
4302-#ifndef GRAIL_BUFFER_H
4303-#define GRAIL_BUFFER_H
4304-
4305-#include <grail.h>
4306-
4307-#define DIM_GRAIL_EVENTS 512
4308-
4309-struct grailbuf {
4310- int head;
4311- int tail;
4312- struct grail_event buffer[DIM_GRAIL_EVENTS];
4313-};
4314-
4315-static inline void grailbuf_clear(struct grailbuf *buf)
4316-{
4317- buf->head = buf->tail = 0;
4318-}
4319-
4320-static inline int grailbuf_empty(const struct grailbuf *buf)
4321-{
4322- return buf->head == buf->tail;
4323-}
4324-
4325-static inline void grailbuf_put(struct grailbuf *buf,
4326- const struct grail_event *ev)
4327-{
4328- buf->buffer[buf->head++] = *ev;
4329- buf->head &= DIM_GRAIL_EVENTS - 1;
4330-}
4331-
4332-static inline void grailbuf_get(struct grailbuf *buf,
4333- struct grail_event *ev)
4334-{
4335- *ev = buf->buffer[buf->tail++];
4336- buf->tail &= DIM_GRAIL_EVENTS - 1;
4337-}
4338-
4339-#endif
4340
4341=== removed directory 'src/v3'
4342=== modified file 'test/Makefile.am'
4343--- test/Makefile.am 2012-04-03 01:40:58 +0000
4344+++ test/Makefile.am 2012-05-09 17:32:19 +0000
4345@@ -23,11 +23,6 @@
4346 $(MTDEV_LIBS)
4347
4348 check_grail_SOURCES = \
4349- check-mapping.cpp \
4350- check-transform.cpp
4351-
4352-if HAVE_XI22
4353-check_grail_SOURCES += \
4354 grail.cpp \
4355 subscription.cpp \
4356 device.cpp \
4357@@ -48,7 +43,6 @@
4358 x11/tap-touch-accept.cpp \
4359 x11/parallel-atomic-gestures.cpp \
4360 x11/hold-reject.cpp
4361-endif
4362
4363 AM_CPPFLAGS = \
4364 -I$(top_srcdir) \
4365@@ -82,10 +76,7 @@
4366 $(COVERAGE_LIBS) \
4367 $(XORG_GTEST_LIBS) \
4368 $(XORG_GTEST_MAIN_LIBS)
4369-
4370-if HAVE_XI22
4371-check_grail_LDADD += \
4372- $(XINPUT_LIBS) $(X11_LIBS)
4373-endif
4374+ $(XINPUT_LIBS) \
4375+ $(X11_LIBS)
4376
4377 EXTRA_DIST = io recordings
4378
4379=== removed file 'test/check-mapping.cpp'
4380--- test/check-mapping.cpp 2012-03-23 09:44:52 +0000
4381+++ test/check-mapping.cpp 1970-01-01 00:00:00 +0000
4382@@ -1,100 +0,0 @@
4383-#include <fcntl.h>
4384-#include <unistd.h>
4385-
4386-#include <cmath>
4387-#include <cstdio>
4388-#include <cstdlib>
4389-#include <cstring>
4390-#include <ctime>
4391-#include <stdexcept>
4392-
4393-#include <gtest/gtest.h>
4394-
4395-#include "grail.h"
4396-
4397-/**
4398- * @brief Fixture for check-mapping test suite.
4399- */
4400-class CheckMapping : public testing::Test {
4401- protected:
4402-
4403- grail ge_;
4404- int fd_;
4405- grail_coord pos_;
4406-
4407- CheckMapping()
4408- : fd_(-1) {
4409- std::memset(&ge_, 0, sizeof(ge_));
4410- std::memset(&pos_, 0, sizeof(pos_));
4411- }
4412-
4413- /**
4414- * @brief Setup procedure is called before every test.
4415- */
4416- void SetUp() {
4417- ge_.get_clients = TpGetClients;
4418- ge_.event = TpEvent;
4419- ge_.gesture = TpGesture;
4420- ge_.priv = this;
4421-
4422- fd_ = open(TEST_ROOT_DIR "io/evemu/one-tap.evemu", O_RDONLY | O_NONBLOCK);
4423-
4424- if (0 != grail_open(&ge_, fd_))
4425- throw std::runtime_error(
4426- "Problem initializing grail for test-suite CheckMapping.");
4427- }
4428-
4429- /**
4430- * @brief Cleanup procedure is called before every test.
4431- */
4432- virtual void TearDown() {
4433- grail_close(&ge_, fd_);
4434- close(fd_);
4435- }
4436-
4437- static int TpGetClients(struct grail* ge,
4438- grail_client_info* clients,
4439- int max_clients, const grail_coord* coords,
4440- int num_coords, const grail_mask_t *types,
4441- int type_bytes) {
4442- memset(&clients[0], 0, sizeof(clients[0]));
4443- memset(clients[0].mask, ~0, sizeof(clients[0].mask));
4444- clients[0].id.client = 345;
4445- clients[0].id.root = 1;
4446- clients[0].id.event = 2;
4447- clients[0].id.child = 3;
4448- return 1;
4449- }
4450-
4451- static void TpEvent(grail* ge, const input_event* ev) {
4452- }
4453-
4454- static void TpGesture(grail* ge, const grail_event* ev) {
4455- CheckMapping* data = static_cast<CheckMapping*>(ge->priv);
4456- if (ev->type != GRAIL_TYPE_TAP1)
4457- return;
4458- data->pos_.x = ev->prop[GRAIL_PROP_TAP_X];
4459- data->pos_.y = ev->prop[GRAIL_PROP_TAP_Y];
4460- }
4461-
4462- static float Distance(const grail_coord* p, float x, float y) {
4463- double dx = p->x - x;
4464- double dy = p->y - y;
4465- return std::sqrt(dx * dx + dy * dy);
4466- }
4467-};
4468-
4469-TEST_F(CheckMapping,device_coordinates) {
4470- grail_pull(&ge_, fd_);
4471-
4472- EXPECT_NEAR(0, CheckMapping::Distance(&pos_, 17086, 14789), 1E-8);
4473-}
4474-
4475-TEST_F(CheckMapping,mapped_coordinates) {
4476- static const grail_coord min = { 0, 0 }, max = { 1.6, 1 };
4477- grail_set_bbox(&ge_, &min, &max);
4478-
4479- grail_pull(&ge_, fd_);
4480-
4481- EXPECT_NEAR(0., CheckMapping::Distance(&pos_, 0.834303, 0.451338), 1E-6);
4482-}
4483
4484=== removed file 'test/check-transform.cpp'
4485--- test/check-transform.cpp 2012-03-23 09:44:52 +0000
4486+++ test/check-transform.cpp 1970-01-01 00:00:00 +0000
4487@@ -1,116 +0,0 @@
4488-#include <fcntl.h>
4489-#include <unistd.h>
4490-
4491-#include <cmath>
4492-#include <cstdio>
4493-#include <cstdlib>
4494-#include <cstring>
4495-#include <ctime>
4496-#include <stdexcept>
4497-
4498-#include <gtest/gtest.h>
4499-#include <utouch/frame-mtdev.h>
4500-
4501-#include "grail.h"
4502-
4503-/**
4504- * @brief Fixture for check-transform test suite.
4505- */
4506-class CheckTransform : public testing::Test {
4507- protected:
4508- evemu_device* evemu_;
4509- utouch_frame_handle fh_;
4510- grail_handle ge_;
4511- FILE* fp_;
4512- timeval evtime_;
4513-
4514- static float Distance(const grail_coord * p, float x, float y) {
4515- double dx = p->x - x;
4516- double dy = p->y - y;
4517- return std::sqrt(dx * dx + dy * dy);
4518- }
4519-
4520- CheckTransform()
4521- : evemu_(NULL),
4522- fp_(NULL) {
4523- std::memset(&fh_, 0, sizeof(fh_));
4524- std::memset(&ge_, 0, sizeof(ge_));
4525- std::memset(&evtime_, 0, sizeof(evtime_));
4526- }
4527-
4528- void SetUp() {
4529- fp_ = fopen(TEST_ROOT_DIR "io/evemu/one-tap.evemu", "r");
4530- if (!fp_)
4531- throw std::runtime_error(
4532- "Error opening pre-recorded events file io/evemu/one-tap.evemu.");
4533-
4534- evemu_ = evemu_new(NULL);
4535- if (!evemu_ || evemu_read(evemu_, fp_) <= 0)
4536- throw std::runtime_error("Error reading emulated event.");
4537-
4538- fh_ = utouch_frame_new_engine(100, 32, 100);
4539- if (!fh_ || utouch_frame_init_mtdev(fh_, evemu_))
4540- throw std::runtime_error("Error initializing utouch frame.");
4541-
4542- ge_ = grail_new(fh_, 10, 0);
4543- if (!ge_)
4544- throw std::runtime_error(
4545- "Error allocating and initializing grail context.");
4546- }
4547-
4548- void TearDown(struct test_data *data) {
4549- grail_delete(ge_);
4550- utouch_frame_delete_engine(fh_);
4551- evemu_delete(evemu_);
4552- fclose(fp_);
4553- }
4554-
4555- int GetEvent(input_event* ev) {
4556- return evemu_read_event_realtime(fp_, ev, &evtime_) > 0;
4557- }
4558-
4559- const grail_element* GetElement(const input_event* ev) {
4560- const utouch_frame* touch;
4561- const grail_frame* frame;
4562-
4563- touch = utouch_frame_pump_mtdev(fh_, ev);
4564- if (!touch)
4565- return NULL;
4566- frame = grail_pump_frame(ge_, touch);
4567- if (!frame || !frame->num_ongoing)
4568- return NULL;
4569-
4570- return frame->ongoing[frame->num_ongoing - 1];
4571- }
4572-};
4573-
4574-TEST_F(CheckTransform, device_coordinates) {
4575- struct input_event ev;
4576- const struct grail_element *slot;
4577- struct grail_coord pos = { 0, 0 };
4578-
4579- while (GetEvent(&ev)) {
4580- slot = GetElement(&ev);
4581- if (slot)
4582- pos = slot->center;
4583- }
4584-
4585- EXPECT_NEAR(0., CheckTransform::Distance(&pos, 17086, 14789), 1E-6);
4586-}
4587-
4588-TEST_F(CheckTransform, mapped_coordinates) {
4589- static const struct grail_coord min = { 0, 0 }, max = { 1.6, 1 };
4590- struct input_event ev;
4591- const grail_element* slot;
4592- struct grail_coord pos = { 0, 0 };
4593-
4594- grail_set_bbox(ge_, &min, &max);
4595-
4596- while (GetEvent(&ev)) {
4597- slot = GetElement(&ev);
4598- if (slot)
4599- pos = slot->center;
4600- }
4601-
4602- EXPECT_NEAR(0., CheckTransform::Distance(&pos, 0.834303, 0.451338), 1E-6);
4603-}
4604
4605=== modified file 'tools/Makefile.am'
4606--- tools/Makefile.am 2012-03-29 20:34:51 +0000
4607+++ tools/Makefile.am 2012-05-09 17:32:19 +0000
4608@@ -1,16 +1,10 @@
4609-bin_PROGRAMS = grail-gesture grail-test-mtdev
4610-noinst_PROGRAMS = grail-eventprinter
4611 dist_man_MANS = \
4612- grail-gesture.1 \
4613 grail-test-3-1.1 \
4614 grail-test-atomic.1 \
4615 grail-test-edge.1 \
4616- grail-test-mtdev.1 \
4617 grail-test-propagation.1
4618
4619-if HAVE_XI22
4620-
4621-bin_PROGRAMS += \
4622+bin_PROGRAMS = \
4623 grail-test-propagation \
4624 grail-test-edge \
4625 grail-test-3-1 \
4626@@ -48,8 +42,6 @@
4627 common/slice.c \
4628 common/slice.h
4629
4630-endif
4631-
4632 INCLUDES=-I$(top_srcdir)/include/
4633
4634 AM_CPPFLAGS = $(WARNING_CPPFLAGS)
4635
4636=== removed file 'tools/grail-eventprinter.c'
4637--- tools/grail-eventprinter.c 2011-09-08 16:54:39 +0000
4638+++ tools/grail-eventprinter.c 1970-01-01 00:00:00 +0000
4639@@ -1,239 +0,0 @@
4640-/*****************************************************************************
4641- *
4642- * grail-eventprinter - pretty prints events as produced by Grail
4643- *
4644- * Copyright (C) 2010-2011 Canonical Ltd.
4645- *
4646- * This program is free software: you can redistribute it and/or modify it
4647- * under the terms of the GNU General Public License as published by the
4648- * Free Software Foundation, either version 3 of the License, or (at your
4649- * option) any later version.
4650- *
4651- * This program is distributed in the hope that it will be useful, but
4652- * WITHOUT ANY WARRANTY; without even the implied warranty of
4653- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4654- * General Public License for more details.
4655- *
4656- * You should have received a copy of the GNU General Public License along
4657- * with this program. If not, see <http://www.gnu.org/licenses/>.
4658- *
4659- ****************************************************************************/
4660-
4661-/* Regular applications must include <grail.h>. Since
4662- * this application needs to access Grail's internals
4663- * to access the private fast_fileread struct element,
4664- * it needs this header.
4665- *
4666- * Only Grail's internal tools are allowed to include
4667- * this header.
4668- */
4669-#include "../src/v2/grail-impl.h"
4670-
4671-#include <string.h>
4672-#include <stdio.h>
4673-#include <unistd.h>
4674-#include <fcntl.h>
4675-#include <stdlib.h>
4676-#include <sys/stat.h>
4677-
4678-static grail_mask_t flag_mask[DIM_GRAIL_TYPE_BYTES];
4679-
4680-/* Order is the same as with defines in grail-types.h */
4681-
4682-static const char* const grail_event_names[] = {
4683- "Drag1",
4684- "Pinch1",
4685- "Rotate1",
4686- "Drag2",
4687- "Pinch2",
4688- "Rotate2",
4689- "Drag3",
4690- "Pinch3",
4691- "Rotate3",
4692- "Drag4",
4693- "Pinch4",
4694- "Rotate4",
4695- "Drag5",
4696- "Pinch5",
4697- "Rotate5",
4698- "Tap1",
4699- "Tap2",
4700- "Tap3",
4701- "Tap4",
4702- "Tap5",
4703- "Edrag",
4704- "Epinch",
4705- "Erotate",
4706- "Mdrag",
4707- "Mpinch",
4708- "Mrotate",
4709- "Sysflag1",
4710- "Unknown27",
4711- "Unknown28",
4712- "Unknown29",
4713- "Unknown30",
4714- "Unknown31",
4715- "Touch1",
4716- "Touch2",
4717- "Touch3",
4718- "Touch4",
4719- "Touch5",
4720- "Etouch",
4721- "Mtouch"
4722-};
4723-
4724-static int tp_get_clients(struct grail *ge,
4725- struct grail_client_info *clients, int max_clients,
4726- const struct grail_coord *coords, int num_coords,
4727- const grail_mask_t *types, int type_bytes)
4728-{
4729- printf("Client query.\n");
4730-
4731- memset(&clients[0], 0, sizeof(clients[0]));
4732- clients[0].id.client = 345;
4733- clients[0].id.root = 1;
4734- clients[0].id.event = 2;
4735- clients[0].id.child = 3;
4736- memcpy(clients[0].mask, flag_mask, sizeof(flag_mask));
4737- return 1;
4738-}
4739-
4740-static void tp_event(struct grail *ge, const struct input_event *ev)
4741-{
4742- printf("Input event.\n");
4743-}
4744-
4745-static int is_drag_event(const struct grail_event *ev) {
4746- return ev->type == GRAIL_TYPE_DRAG1 ||
4747- ev->type == GRAIL_TYPE_DRAG2 ||
4748- ev->type == GRAIL_TYPE_DRAG3 ||
4749- ev->type == GRAIL_TYPE_DRAG4 ||
4750- ev->type == GRAIL_TYPE_DRAG5;
4751-}
4752-
4753-static void print_drag_stats(const struct grail_event *ev) {
4754- printf(" c = (%f, %f), delta = (%f, %f)\n",
4755- ev->prop[GRAIL_PROP_DRAG_X],
4756- ev->prop[GRAIL_PROP_DRAG_Y],
4757- ev->prop[GRAIL_PROP_DRAG_VX],
4758- ev->prop[GRAIL_PROP_DRAG_VY]);
4759-}
4760-
4761-static int is_rotate_event(const struct grail_event *ev) {
4762- return ev->type == GRAIL_TYPE_ROTATE1 ||
4763- ev->type == GRAIL_TYPE_ROTATE2 ||
4764- ev->type == GRAIL_TYPE_ROTATE3 ||
4765- ev->type == GRAIL_TYPE_ROTATE4 ||
4766- ev->type == GRAIL_TYPE_ROTATE5;
4767-}
4768-
4769-static void print_rotate_stats(const struct grail_event *ev) {
4770- printf(" a = %f, va = %f\n",
4771- ev->prop[GRAIL_PROP_ROTATE_A],
4772- ev->prop[GRAIL_PROP_ROTATE_VA]);
4773-}
4774-
4775-static int is_pinch_event(const struct grail_event *ev) {
4776- return ev->type == GRAIL_TYPE_PINCH1 ||
4777- ev->type == GRAIL_TYPE_PINCH2 ||
4778- ev->type == GRAIL_TYPE_PINCH3 ||
4779- ev->type == GRAIL_TYPE_PINCH4 ||
4780- ev->type == GRAIL_TYPE_PINCH5;
4781-}
4782-
4783-static void print_pinch_stats(const struct grail_event *ev) {
4784- printf(" radius = %f, delta r = %f\n",
4785- ev->prop[GRAIL_PROP_PINCH_R],
4786- ev->prop[GRAIL_PROP_PINCH_VR]);
4787-}
4788-
4789-const char *event_name(const struct grail_event *ev) {
4790- return grail_event_names[ev->type];
4791-}
4792-
4793-static void tp_gesture(struct grail *ge, const struct grail_event *ev)
4794-{
4795- if (ev->status == GRAIL_STATUS_BEGIN) {
4796- printf("BEGIN gesture %s\n", event_name(ev));
4797- if (is_drag_event(ev)){
4798- print_drag_stats(ev);
4799- }
4800- if (is_rotate_event(ev)) {
4801- print_rotate_stats(ev);
4802- }
4803- if (is_pinch_event(ev)) {
4804- print_pinch_stats(ev);
4805- }
4806- }
4807- if (ev->status == GRAIL_STATUS_UPDATE) {
4808- printf("UPDATE gesture %s.\n", event_name(ev));
4809- }
4810- if (ev->status == GRAIL_STATUS_END) {
4811- printf("END gesture %s.\n", event_name(ev));
4812- if (is_drag_event(ev)){
4813- print_drag_stats(ev);
4814- }
4815- if (is_rotate_event(ev)) {
4816- print_rotate_stats(ev);
4817- }
4818- if (is_pinch_event(ev)) {
4819- print_pinch_stats(ev);
4820- }
4821- }
4822-}
4823-
4824-static void loop_device(struct grail *ge, int fd)
4825-{
4826- while (!grail_idle(ge, fd, 5000))
4827- grail_pull(ge, fd);
4828-}
4829-
4830-int main(int argc, char *argv[])
4831-{
4832- struct grail ge;
4833- struct stat fs;
4834- int i, fd;
4835-
4836- if (argc < 2) {
4837- fprintf(stderr, "Usage: %s <device or trace file>\n", argv[0]);
4838- return -1;
4839- }
4840-
4841- memset(&ge, 0, sizeof(ge));
4842- ge.get_clients = tp_get_clients;
4843- ge.event = tp_event;
4844- ge.gesture = tp_gesture;
4845-
4846- unsigned long mask = 0xffffffff; /* Get every gesture type. */
4847- for (i = 0; i < DIM_GRAIL_TYPE; i++)
4848- if ((mask >> i) & 1)
4849- grail_mask_set(flag_mask, i);
4850-
4851- fd = open(argv[1], O_RDONLY | O_NONBLOCK);
4852- if (fd < 0) {
4853- fprintf(stderr, "error: could not open device\n");
4854- return -1;
4855- }
4856- if (fstat(fd, &fs)) {
4857- fprintf(stderr, "error: could not stat the device\n");
4858- return -1;
4859- }
4860- if (fs.st_rdev && ioctl(fd, EVIOCGRAB, 1)) {
4861- fprintf(stderr, "error: could not grab the device\n");
4862- return -1;
4863- }
4864-
4865- if (grail_open(&ge, fd)) {
4866- fprintf(stderr, "error: could not open touch device\n");
4867- return -1;
4868- }
4869- ge.impl->fast_fileread = 1;
4870-
4871- loop_device(&ge, fd);
4872- grail_close(&ge, fd);
4873-
4874- if (fs.st_rdev)
4875- ioctl(fd, EVIOCGRAB, 0);
4876- close(fd);
4877- return 0;
4878-}
4879
4880=== removed file 'tools/grail-gesture.1'
4881--- tools/grail-gesture.1 2012-03-29 13:21:33 +0000
4882+++ tools/grail-gesture.1 1970-01-01 00:00:00 +0000
4883@@ -1,17 +0,0 @@
4884-.TH GRAIL-GESTURE 1 "March 14, 2012" "grail" "uTouch"
4885-
4886-.SH NAME
4887-grail-gesture \- print grail v2 gesture events
4888-
4889-.SH SYNPOSIS
4890-.B grail-gesture
4891-.I mask
4892-.I devce
4893-.br
4894-
4895-.SH DESCRIPTION
4896-Prints grail v2 gesture events. Works only with the grail v2 gesture
4897-recognition engine, based exclusively on the mtdev library to access kernel
4898-multi-touch input device events.
4899-
4900-This program is deprecated and will be removed in a future release of grail.
4901
4902=== removed file 'tools/grail-gesture.c'
4903--- tools/grail-gesture.c 2011-04-28 16:53:57 +0000
4904+++ tools/grail-gesture.c 1970-01-01 00:00:00 +0000
4905@@ -1,131 +0,0 @@
4906-/*****************************************************************************
4907- *
4908- * grail - Gesture Recognition And Instantiation Library
4909- *
4910- * Copyright (C) 2010-2011 Canonical Ltd.
4911- *
4912- * This program is free software: you can redistribute it and/or modify it
4913- * under the terms of the GNU General Public License as published by the
4914- * Free Software Foundation, either version 3 of the License, or (at your
4915- * option) any later version.
4916- *
4917- * This program is distributed in the hope that it will be useful, but
4918- * WITHOUT ANY WARRANTY; without even the implied warranty of
4919- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4920- * General Public License for more details.
4921- *
4922- * You should have received a copy of the GNU General Public License along
4923- * with this program. If not, see <http://www.gnu.org/licenses/>.
4924- *
4925- ****************************************************************************/
4926-
4927-#include <grail.h>
4928-#include <string.h>
4929-#include <stdio.h>
4930-#include <unistd.h>
4931-#include <fcntl.h>
4932-#include <stdlib.h>
4933-#include <sys/stat.h>
4934-
4935-static grail_mask_t flag_mask[DIM_GRAIL_TYPE_BYTES];
4936-
4937-static int tp_get_clients(struct grail *ge,
4938- struct grail_client_info *clients, int max_clients,
4939- const struct grail_coord *coords, int num_coords,
4940- const grail_mask_t *types, int type_bytes)
4941-{
4942- memset(&clients[0], 0, sizeof(clients[0]));
4943- clients[0].id.client = 345;
4944- clients[0].id.root = 1;
4945- clients[0].id.event = 2;
4946- clients[0].id.child = 3;
4947- memcpy(clients[0].mask, flag_mask, sizeof(flag_mask));
4948- return 1;
4949-}
4950-
4951-static void tp_event(struct grail *ge, const struct input_event *ev)
4952-{
4953- fprintf(stderr, "%lu.%06u %04x %04x %d\n",
4954- ev->time.tv_sec, (unsigned)ev->time.tv_usec,
4955- ev->type, ev->code, ev->value);
4956-}
4957-
4958-static void tp_gesture(struct grail *ge, const struct grail_event *ev)
4959-{
4960- struct grail_contact touch[32];
4961- int i, ntouch;
4962- fprintf(stderr, "gesture %d %d %d %d - %f %f %d - %d\n",
4963- ev->type, ev->id, ev->client_id.client, ev->client_id.event,
4964- ev->pos.x, ev->pos.y, ev->ntouch,
4965- ev->status);
4966- ntouch = grail_get_contacts(ge, touch, 32);
4967- for (i = 0; i < ntouch; i++) {
4968- const struct grail_contact *t = &touch[i];
4969- fprintf(stderr, "\t%d: %d %d\n", i, t->id, t->tool_type);
4970- fprintf(stderr, "\t %f %f\n", t->pos.x, t->pos.y);
4971- fprintf(stderr, "\t %f %f %f %f\n", t->touch_major,
4972- t->touch_minor, t->width_major, t->width_minor);
4973- fprintf(stderr, "\t %f %f\n", t->angle, t->pressure);
4974- }
4975- for (i = 0; i < ev->nprop; i++)
4976- fprintf(stderr, "\t%d: %f\n", i, ev->prop[i]);
4977-}
4978-
4979-static void loop_device(struct grail *ge, int fd)
4980-{
4981- while (!grail_idle(ge, fd, 5000))
4982- grail_pull(ge, fd);
4983-}
4984-
4985-int main(int argc, char *argv[])
4986-{
4987- struct grail ge;
4988- struct stat fs;
4989- int i, fd;
4990-
4991- if (argc < 3) {
4992- fprintf(stderr, "Usage: %s <mask> <device>\n", argv[0]);
4993- return -1;
4994- }
4995-
4996- memset(&ge, 0, sizeof(ge));
4997- ge.get_clients = tp_get_clients;
4998- ge.event = tp_event;
4999- ge.gesture = tp_gesture;
5000-
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches