Status: | Merged |
---|---|
Merged at revision: | 129 |
Proposed branch: | lp:~bregma/geis/lp-742555 |
Merge into: | lp:geis |
Diff against target: |
499 lines (+229/-56) 9 files modified
ChangeLog (+21/-0) include/geis/geis.h (+10/-0) libutouch-geis/backend/xcb/geis_xcb_backend.c (+10/-7) libutouch-geis/backend/xcb/grail_gestures.c (+102/-49) libutouch-geis/geis_v1.c (+5/-0) testsuite/geis1/Makefile.am (+1/-0) testsuite/geis1/check_geis1_api.c (+2/-0) testsuite/geis1/check_gesture_types.c (+77/-0) testsuite/geistest/geistest.c (+1/-0) |
To merge this branch: | bzr merge lp:~bregma/geis/lp-742555 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chase Douglas (community) | Approve | ||
Review via email: mp+54920@code.launchpad.net |
Commit message
Description of the change
Adds through support for TOUCH gesture types for direct touch begin/end handling.
- 130. By Stephen M. Webb
-
* Replaced alloca() calls with C99 dynamic arrays.
* Used memset instead of a for-loop for array initialization.
* Removed extraneous commas from s_grail_class_map. - 131. By Stephen M. Webb
-
Properly initialized the grail gesture bitmask in all cases.
Stephen M. Webb (bregma) wrote : | # |
New revision pushed up.
(1) alloca() replaced by C99 dynamic arrays.
(b) used memset() instead of a for-loop to initialize the array.
(3) removed extraneous commas.
(5) initialized all instances of mask_len.
grail_mask_setbit() only concerns itself with the lower 2^5 bits of each uint32_t because there are only 2^5 bits in a uint32_t.
- 132. By Stephen M. Webb
-
Cleared touch count mask.
- 133. By Stephen M. Webb
-
Changed the list of properties received from grail for the Touch gesture.
Chase Douglas (chasedouglas) wrote : | # |
The code looks good now, and geistest is behaving as I expect :).
Preview Diff
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2011-03-24 19:38:36 +0000 |
3 | +++ ChangeLog 2011-03-28 12:59:24 +0000 |
4 | @@ -1,3 +1,24 @@ |
5 | +2011-03-28 Stephen M. Webb <stephen.webb@canonical.com> |
6 | + |
7 | + Changes the list of attrs received from grail for the Touch gesture. |
8 | + |
9 | + * libutouch-geis/backend/xcb/grail_gestures.c: change Touch attrs |
10 | + |
11 | +2011-03-25 Stephen M. Webb <stephen.webb@canonical.com> |
12 | + |
13 | + Added new TOUCH gesture types (LP: #742555). |
14 | + |
15 | + * include/geis/geis.h: added new TOUCH gesture types |
16 | + * libutouch-geis/backend/xcb/geis_xcb_backend.c: tweaked gesture mask size |
17 | + * libutouch-geis/backend/xcb/grail_gestures.c: added new TOUCH gesture types |
18 | + added proper handling of a variable-size gesture mask |
19 | + * libutouch-geis/geis_v1.c: mapped new TOUCH gesture types to grail TOUCH |
20 | + gesture types |
21 | + * testsuite/geis1/check_gesture_types.c: new testsuite |
22 | + * testsuite/geis1/Makefile.am: added new testsuite |
23 | + * testsuite/geis1/check_geis1_api.c: invoked new testsuite |
24 | + * testsuite/geistest/geistest.c: added new gesture types |
25 | + |
26 | 2011-03-24 Stephen M. Webb <stephen.webb@canonical.com> |
27 | |
28 | Fixed a bad index when translating grail touches (LP: #742002). |
29 | |
30 | === modified file 'include/geis/geis.h' |
31 | --- include/geis/geis.h 2011-03-17 23:42:48 +0000 |
32 | +++ include/geis/geis.h 2011-03-28 12:59:24 +0000 |
33 | @@ -107,6 +107,7 @@ |
34 | #define GEIS_GESTURE_PINCH "Pinch" |
35 | #define GEIS_GESTURE_ROTATE "Rotate" |
36 | #define GEIS_GESTURE_TAP "Tap" |
37 | +#define GEIS_GESTURE_TOUCH "Touch" |
38 | |
39 | /** |
40 | * @defgroup geis_v1_gesture_types Gesture Types |
41 | @@ -143,11 +144,15 @@ |
42 | * |
43 | * @def GEIS_GESTURE_PRIMITIVE_TAP |
44 | * A tap. Touch down, touch up, one or more touches. |
45 | + * |
46 | + * @def GEIS_GESTURE_PRIMITIVE_TOUCH |
47 | + * A parenthetical gesture event. Touch down (start) and up (finish). |
48 | */ |
49 | #define GEIS_GESTURE_PRIMITIVE_DRAG 0 |
50 | #define GEIS_GESTURE_PRIMITIVE_PINCH 1 |
51 | #define GEIS_GESTURE_PRIMITIVE_ROTATE 2 |
52 | #define GEIS_GESTURE_PRIMITIVE_TAP 15 |
53 | +#define GEIS_GESTURE_PRIMITIVE_TOUCH 32 |
54 | |
55 | /* @} */ |
56 | |
57 | @@ -182,6 +187,11 @@ |
58 | #define GEIS_GESTURE_TYPE_TAP3 "Tap,touch=3" |
59 | #define GEIS_GESTURE_TYPE_TAP4 "Tap,touch=4" |
60 | #define GEIS_GESTURE_TYPE_TAP5 "Tap,touch=5" |
61 | +#define GEIS_GESTURE_TYPE_TOUCH1 "Touch,touch=1" |
62 | +#define GEIS_GESTURE_TYPE_TOUCH2 "Touch,touch=2" |
63 | +#define GEIS_GESTURE_TYPE_TOUCH3 "Touch,touch=3" |
64 | +#define GEIS_GESTURE_TYPE_TOUCH4 "Touch,touch=4" |
65 | +#define GEIS_GESTURE_TYPE_TOUCH5 "Touch,touch=5" |
66 | |
67 | /* @} */ |
68 | |
69 | |
70 | === modified file 'libutouch-geis/backend/xcb/geis_xcb_backend.c' |
71 | --- libutouch-geis/backend/xcb/geis_xcb_backend.c 2011-03-24 19:38:36 +0000 |
72 | +++ libutouch-geis/backend/xcb/geis_xcb_backend.c 2011-03-28 12:59:24 +0000 |
73 | @@ -47,6 +47,8 @@ |
74 | #define MAX_NUM_DEVICES 10 |
75 | #define MAX_NUM_WINDOWS 10 |
76 | |
77 | +#define GRAIL_XCB_BITMASK_LEN 2 |
78 | + |
79 | |
80 | static inline GeisSize |
81 | _min(GeisSize a, GeisSize b) |
82 | @@ -83,7 +85,7 @@ |
83 | uint16_t devices[MAX_NUM_DEVICES]; |
84 | uint16_t device_count; |
85 | int num_class_filters; |
86 | - uint32_t mask[1]; |
87 | + uint32_t mask[GRAIL_XCB_BITMASK_LEN]; |
88 | uint32_t mask_len; |
89 | int num_region_filters; |
90 | xcb_window_t windows[MAX_NUM_WINDOWS]; |
91 | @@ -537,8 +539,8 @@ |
92 | GeisString class_name = NULL; |
93 | GeisSize min_touches = MIN_TOUCHES; |
94 | GeisSize max_touches = MAX_TOUCHES; |
95 | - uint32_t mask_len; |
96 | - uint32_t mask[1]; |
97 | + uint32_t mask_len = GRAIL_XCB_BITMASK_LEN; |
98 | + uint32_t mask[mask_len]; |
99 | |
100 | geis_xcb_backend_gesture_bitmask_init(geis_subscription_flags(sub), |
101 | &mask_len, mask); |
102 | @@ -600,6 +602,7 @@ |
103 | geis_error("error allocating xcb-gesture subscription"); |
104 | goto error_exit; |
105 | } |
106 | + xsub->mask_len = GRAIL_XCB_BITMASK_LEN; |
107 | |
108 | /* Translate the GEIS v2 subscription into an XCB subscription. */ |
109 | for (i = 0; i < filter_count; ++i) |
110 | @@ -652,13 +655,13 @@ |
111 | xcb_generic_error_t *error; |
112 | xcb_void_cookie_t select_cookie; |
113 | |
114 | - geis_debug("window_id=0x%08x device_id=%d mask_len=%d mask[0]=0x%08x", |
115 | + geis_debug("window_id=0x%08x device_id=%d mask_len=%d mask=0x%08x %08x", |
116 | xsub->windows[win], xsub->devices[dev], |
117 | - xsub->mask_len, xsub->mask[0]); |
118 | + xsub->mask_len, xsub->mask[1], xsub->mask[0]); |
119 | select_cookie = xcb_gesture_select_events_checked(xcb->xcb_connection, |
120 | xsub->windows[win], |
121 | - xsub->devices[dev], |
122 | - xsub->mask_len, |
123 | + (uint16_t)xsub->devices[dev], |
124 | + (uint16_t)xsub->mask_len, |
125 | xsub->mask); |
126 | error = xcb_request_check(xcb->xcb_connection, select_cookie); |
127 | if (error) |
128 | |
129 | === modified file 'libutouch-geis/backend/xcb/grail_gestures.c' |
130 | --- libutouch-geis/backend/xcb/grail_gestures.c 2011-03-22 16:14:01 +0000 |
131 | +++ libutouch-geis/backend/xcb/grail_gestures.c 2011-03-28 12:59:24 +0000 |
132 | @@ -38,6 +38,14 @@ |
133 | |
134 | static GeisFloat zero = 0.0f; |
135 | |
136 | +static struct _AttrInitializer s_touch_attrs[] = { |
137 | + { GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X1, GEIS_ATTR_TYPE_FLOAT, &zero }, |
138 | + { GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y1, GEIS_ATTR_TYPE_FLOAT, &zero }, |
139 | + { GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_X2, GEIS_ATTR_TYPE_FLOAT, &zero }, |
140 | + { GEIS_GESTURE_ATTRIBUTE_BOUNDINGBOX_Y2, GEIS_ATTR_TYPE_FLOAT, &zero }, |
141 | + { NULL, 0, &zero } |
142 | +}; |
143 | + |
144 | static struct _AttrInitializer s_drag_attrs[] = { |
145 | { GEIS_GESTURE_ATTRIBUTE_DELTA_X, GEIS_ATTR_TYPE_FLOAT, &zero }, |
146 | { GEIS_GESTURE_ATTRIBUTE_DELTA_Y, GEIS_ATTR_TYPE_FLOAT, &zero }, |
147 | @@ -128,19 +136,54 @@ |
148 | { GRAIL_TYPE_TAP3, GEIS_GESTURE_PRIMITIVE_TAP, GEIS_GESTURE_TYPE_TAP3, GEIS_GESTURE_TAP, s_tap_attrs, 3 }, |
149 | { GRAIL_TYPE_TAP4, GEIS_GESTURE_PRIMITIVE_TAP, GEIS_GESTURE_TYPE_TAP4, GEIS_GESTURE_TAP, s_tap_attrs, 4 }, |
150 | { GRAIL_TYPE_TAP5, GEIS_GESTURE_PRIMITIVE_TAP, GEIS_GESTURE_TYPE_TAP5, GEIS_GESTURE_TAP, s_tap_attrs, 5 }, |
151 | + { GRAIL_TYPE_TOUCH1, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH1, GEIS_GESTURE_TOUCH, s_touch_attrs, 1 }, |
152 | + { GRAIL_TYPE_TOUCH2, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH2, GEIS_GESTURE_TOUCH, s_touch_attrs, 2 }, |
153 | + { GRAIL_TYPE_TOUCH3, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH3, GEIS_GESTURE_TOUCH, s_touch_attrs, 3 }, |
154 | + { GRAIL_TYPE_ETOUCH, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH3, GEIS_GESTURE_TOUCH, s_touch_attrs, 3 }, |
155 | + { GRAIL_TYPE_TOUCH4, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH4, GEIS_GESTURE_TOUCH, s_touch_attrs, 4 }, |
156 | + { GRAIL_TYPE_MTOUCH, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH4, GEIS_GESTURE_TOUCH, s_touch_attrs, 4 }, |
157 | + { GRAIL_TYPE_TOUCH5, GEIS_GESTURE_PRIMITIVE_TOUCH, GEIS_GESTURE_TYPE_TOUCH5, GEIS_GESTURE_TOUCH, s_touch_attrs, 5 }, |
158 | { -1, -1, NULL, NULL, NULL, 0 } /* sentinel */ |
159 | }; |
160 | |
161 | |
162 | /* |
163 | - * Gets the bitmask for an entry in the GrailClassMap. |
164 | - */ |
165 | -static inline GeisInteger |
166 | -_grail_bitmask_for(const GrailClassMap *entry) |
167 | -{ |
168 | - return 1 << entry->grail_type; |
169 | -} |
170 | - |
171 | + * Clears all the bits in a bitmask. |
172 | + */ |
173 | +static inline void |
174 | +_grail_mask_clear(uint32_t mask_len, |
175 | + uint32_t* mask) |
176 | +{ |
177 | + memset(mask, 0, mask_len * sizeof(uint32_t)); |
178 | +} |
179 | + |
180 | +/* |
181 | + * Sets the indicated bit in the bitmask. |
182 | + * |
183 | + * @todo: convert form uint32_t masks to byte masks |
184 | + */ |
185 | +static inline void |
186 | +_grail_mask_set_bit(uint32_t mask_len __attribute__((unused)), |
187 | + uint32_t* mask, |
188 | + int index) |
189 | +{ |
190 | + mask[index >> 5] |= 1 << (index & 0x1f); |
191 | +} |
192 | + |
193 | +/* |
194 | + * Masks the bits in one bitmask by the bots in another. |
195 | + */ |
196 | +static inline void |
197 | +_grail_mask_and(uint32_t mask_len, |
198 | + uint32_t* mask_lhs, |
199 | + uint32_t* mask_rhs) |
200 | +{ |
201 | + uint32_t i; |
202 | + for (i = 0; i < mask_len; ++i) |
203 | + { |
204 | + mask_lhs[i] &= mask_rhs[i]; |
205 | + } |
206 | +} |
207 | |
208 | /* |
209 | * Initializes the XCB gesture bitmap flags. |
210 | @@ -153,40 +196,46 @@ |
211 | uint32_t *mask_len, |
212 | uint32_t *mask) |
213 | { |
214 | - *mask_len = 1; /* always */ |
215 | - *mask = 0; |
216 | - *mask = (1 << GRAIL_TYPE_DRAG1) |
217 | - | (1 << GRAIL_TYPE_PINCH1) |
218 | - | (1 << GRAIL_TYPE_ROTATE1) |
219 | - | (1 << GRAIL_TYPE_TAP1) |
220 | - | (1 << GRAIL_TYPE_DRAG2) |
221 | - | (1 << GRAIL_TYPE_PINCH2) |
222 | - | (1 << GRAIL_TYPE_ROTATE2) |
223 | - | (1 << GRAIL_TYPE_TAP2) |
224 | - | (1 << GRAIL_TYPE_TAP3) |
225 | - | (1 << GRAIL_TYPE_TAP4) |
226 | - | (1 << GRAIL_TYPE_DRAG5) |
227 | - | (1 << GRAIL_TYPE_PINCH5) |
228 | - | (1 << GRAIL_TYPE_ROTATE5) |
229 | - | (1 << GRAIL_TYPE_TAP5); |
230 | + _grail_mask_clear(*mask_len, mask); |
231 | + |
232 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_DRAG1); |
233 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_PINCH1); |
234 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_ROTATE1); |
235 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TAP1); |
236 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TOUCH1); |
237 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_DRAG2); |
238 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_PINCH2); |
239 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_ROTATE2); |
240 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TAP2); |
241 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TOUCH2); |
242 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TAP3); |
243 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TAP4); |
244 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_DRAG5); |
245 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_PINCH5); |
246 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_ROTATE5); |
247 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TAP5); |
248 | |
249 | if (sub_flags & GEIS_SUBSCRIPTION_CONT) |
250 | { |
251 | - *mask |= ( (1 << GRAIL_TYPE_EDRAG) |
252 | - | (1 << GRAIL_TYPE_EPINCH) |
253 | - | (1 << GRAIL_TYPE_EROTATE) |
254 | - | (1 << GRAIL_TYPE_MDRAG) |
255 | - | (1 << GRAIL_TYPE_MPINCH) |
256 | - | (1 << GRAIL_TYPE_MROTATE) ); |
257 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_EDRAG); |
258 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_EPINCH); |
259 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_EROTATE); |
260 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_ETOUCH); |
261 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_MDRAG); |
262 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_MPINCH); |
263 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_MROTATE); |
264 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_MTOUCH); |
265 | } |
266 | else |
267 | { |
268 | - *mask |= ( (1 << GRAIL_TYPE_DRAG3) |
269 | - | (1 << GRAIL_TYPE_PINCH3) |
270 | - | (1 << GRAIL_TYPE_ROTATE3) |
271 | - | (1 << GRAIL_TYPE_DRAG4) |
272 | - | (1 << GRAIL_TYPE_PINCH4) |
273 | - | (1 << GRAIL_TYPE_ROTATE4) ); |
274 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_DRAG3); |
275 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_PINCH3); |
276 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_ROTATE3); |
277 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TOUCH3); |
278 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_DRAG4); |
279 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_PINCH4); |
280 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_ROTATE4); |
281 | + _grail_mask_set_bit(*mask_len, mask, GRAIL_TYPE_TOUCH4); |
282 | } |
283 | |
284 | |
285 | @@ -194,7 +243,7 @@ |
286 | { |
287 | *mask |= (1 << GRAIL_TYPE_SYSFLAG1); |
288 | } |
289 | -geis_debug("initial bitmap is 0x%08x", *mask); |
290 | +geis_debug("initial bitmap is 0x%08x %08x", mask[1], mask[0]); |
291 | } |
292 | |
293 | |
294 | @@ -203,23 +252,25 @@ |
295 | */ |
296 | void |
297 | geis_xcb_backend_gesture_bitmask_filter_class(GeisString class_name, |
298 | - uint32_t *mask_len __attribute__((unused)), |
299 | + uint32_t *mask_len, |
300 | uint32_t *mask) |
301 | { |
302 | - uint32_t class_mask = 0; |
303 | const GrailClassMap *grail_class; |
304 | + uint32_t class_mask[*mask_len]; |
305 | + |
306 | + _grail_mask_clear(*mask_len, class_mask); |
307 | for (grail_class = s_grail_class_map; |
308 | grail_class->geis_class_id >= 0; |
309 | ++grail_class) |
310 | { |
311 | if (0 == strcmp(grail_class->class_name, class_name)) |
312 | { |
313 | - class_mask |= _grail_bitmask_for(grail_class); |
314 | + _grail_mask_set_bit(*mask_len, class_mask, grail_class->grail_type); |
315 | } |
316 | } |
317 | - *mask &= class_mask; |
318 | - geis_debug("class=\"%s\" mask=0x%08x bitmap is now 0x%08x", |
319 | - class_name, class_mask, *mask); |
320 | + _grail_mask_and(*mask_len, mask, class_mask); |
321 | + geis_debug("class=\"%s\" mask is 0x%08x %08x bitmap is now 0x%08x %08x", |
322 | + class_name, class_mask[1], class_mask[0], mask[1], mask[0]); |
323 | } |
324 | |
325 | |
326 | @@ -230,11 +281,13 @@ |
327 | void |
328 | geis_xcb_backend_gesture_bitmask_filter_touches(GeisSize min_touches, |
329 | GeisSize max_touches, |
330 | - uint32_t *mask_len __attribute__((unused)), |
331 | + uint32_t *mask_len, |
332 | uint32_t *mask) |
333 | { |
334 | - uint32_t touch_mask = 0; |
335 | const GrailClassMap *grail_class; |
336 | + uint32_t touch_mask[*mask_len]; |
337 | + |
338 | + _grail_mask_clear(*mask_len, touch_mask); |
339 | for (grail_class = s_grail_class_map; |
340 | grail_class->geis_class_id >= 0; |
341 | ++grail_class) |
342 | @@ -242,12 +295,12 @@ |
343 | if (min_touches <= grail_class->touch_count |
344 | && grail_class->touch_count <= max_touches) |
345 | { |
346 | - touch_mask |= _grail_bitmask_for(grail_class); |
347 | + _grail_mask_set_bit(*mask_len, touch_mask, grail_class->grail_type); |
348 | } |
349 | } |
350 | - *mask &= touch_mask; |
351 | - geis_debug("min_touches=%lu max_touches=%lu mask=0x%08x bitmap is now 0x%08x", |
352 | - min_touches, max_touches, touch_mask, *mask); |
353 | + _grail_mask_and(*mask_len, mask, touch_mask); |
354 | + geis_debug("min_touches=%lu max_touches=%lu mask is 0x%08x %08x bitmap is now 0x%08x %08x", |
355 | + min_touches, max_touches, touch_mask[1], touch_mask[0], mask[1], mask[0]); |
356 | } |
357 | |
358 | |
359 | |
360 | === modified file 'libutouch-geis/geis_v1.c' |
361 | --- libutouch-geis/geis_v1.c 2011-03-13 18:00:45 +0000 |
362 | +++ libutouch-geis/geis_v1.c 2011-03-28 12:59:24 +0000 |
363 | @@ -72,6 +72,11 @@ |
364 | { GEIS_GESTURE_TYPE_TAP3, GEIS_GESTURE_TAP, 3 }, |
365 | { GEIS_GESTURE_TYPE_TAP4, GEIS_GESTURE_TAP, 4 }, |
366 | { GEIS_GESTURE_TYPE_TAP5, GEIS_GESTURE_TAP, 5 }, |
367 | + { GEIS_GESTURE_TYPE_TOUCH1, GEIS_GESTURE_TOUCH, 1 }, |
368 | + { GEIS_GESTURE_TYPE_TOUCH2, GEIS_GESTURE_TOUCH, 2 }, |
369 | + { GEIS_GESTURE_TYPE_TOUCH3, GEIS_GESTURE_TOUCH, 3 }, |
370 | + { GEIS_GESTURE_TYPE_TOUCH4, GEIS_GESTURE_TOUCH, 4 }, |
371 | + { GEIS_GESTURE_TYPE_TOUCH5, GEIS_GESTURE_TOUCH, 5 }, |
372 | { NULL, NULL, 0 } |
373 | }; |
374 | |
375 | |
376 | === modified file 'testsuite/geis1/Makefile.am' |
377 | --- testsuite/geis1/Makefile.am 2011-03-08 14:49:28 +0000 |
378 | +++ testsuite/geis1/Makefile.am 2011-03-28 12:59:24 +0000 |
379 | @@ -15,6 +15,7 @@ |
380 | |
381 | check_geis1_api_SOURCES = \ |
382 | check_instance.c \ |
383 | + check_gesture_types.c \ |
384 | check_gesture_attrs.c \ |
385 | check_geis1_api.c |
386 | |
387 | |
388 | === modified file 'testsuite/geis1/check_geis1_api.c' |
389 | --- testsuite/geis1/check_geis1_api.c 2011-03-08 14:49:28 +0000 |
390 | +++ testsuite/geis1/check_geis1_api.c 2011-03-28 12:59:24 +0000 |
391 | @@ -21,6 +21,7 @@ |
392 | #include <check.h> |
393 | |
394 | extern Suite *geis1_instance_suite_new(); |
395 | +extern Suite *geis1_gesture_types_new(); |
396 | extern Suite *geis1_gesture_attrs_new(); |
397 | |
398 | int |
399 | @@ -31,6 +32,7 @@ |
400 | Suite *s = suite_create("GEIS v1.0 API"); |
401 | SRunner *sr = srunner_create(s); |
402 | srunner_add_suite(sr, geis1_instance_suite_new()); |
403 | + srunner_add_suite(sr, geis1_gesture_types_new()); |
404 | srunner_add_suite(sr, geis1_gesture_attrs_new()); |
405 | |
406 | srunner_set_log(sr, "geis1_api.log"); |
407 | |
408 | === added file 'testsuite/geis1/check_gesture_types.c' |
409 | --- testsuite/geis1/check_gesture_types.c 1970-01-01 00:00:00 +0000 |
410 | +++ testsuite/geis1/check_gesture_types.c 2011-03-28 12:59:24 +0000 |
411 | @@ -0,0 +1,77 @@ |
412 | +/** |
413 | + * @file check_gesture_types.c |
414 | + * @brief Unit tests for GEIS v1 gesture types |
415 | + * |
416 | + * Copyright 2011 Canonical Ltd. |
417 | + * |
418 | + * This library is free software; you can redistribute it and/or modify it under |
419 | + * the terms of the GNU Lesser General Public License as published by the Free |
420 | + * Software Foundation; either version 3 of the License, or (at your option) any |
421 | + * later version. |
422 | + * |
423 | + * This library is distributed in the hope that it will be useful, but WITHOUT |
424 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
425 | + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
426 | + * details. |
427 | + * |
428 | + * You should have received a copy of the GNU Lesser General Public License |
429 | + * along with this program; if not, write to the Free Software Foundation, Inc., |
430 | + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
431 | + */ |
432 | +#include <check.h> |
433 | + |
434 | +#include <geis/geis.h> |
435 | + |
436 | + |
437 | +START_TEST(gesture_types) |
438 | +{ |
439 | + GeisInteger geis_type; |
440 | + GeisString geis_type_name; |
441 | + |
442 | + geis_type = GEIS_GESTURE_PRIMITIVE_DRAG; |
443 | + geis_type = GEIS_GESTURE_PRIMITIVE_PINCH; |
444 | + geis_type = GEIS_GESTURE_PRIMITIVE_ROTATE; |
445 | + geis_type = GEIS_GESTURE_PRIMITIVE_TAP; |
446 | + geis_type = GEIS_GESTURE_PRIMITIVE_TOUCH; |
447 | + |
448 | + geis_type_name = GEIS_GESTURE_TYPE_DRAG1; |
449 | + geis_type_name = GEIS_GESTURE_TYPE_DRAG2; |
450 | + geis_type_name = GEIS_GESTURE_TYPE_DRAG3; |
451 | + geis_type_name = GEIS_GESTURE_TYPE_DRAG4; |
452 | + geis_type_name = GEIS_GESTURE_TYPE_DRAG5; |
453 | + geis_type_name = GEIS_GESTURE_TYPE_PINCH1; |
454 | + geis_type_name = GEIS_GESTURE_TYPE_PINCH2; |
455 | + geis_type_name = GEIS_GESTURE_TYPE_PINCH3; |
456 | + geis_type_name = GEIS_GESTURE_TYPE_PINCH4; |
457 | + geis_type_name = GEIS_GESTURE_TYPE_PINCH5; |
458 | + geis_type_name = GEIS_GESTURE_TYPE_ROTATE1; |
459 | + geis_type_name = GEIS_GESTURE_TYPE_ROTATE2; |
460 | + geis_type_name = GEIS_GESTURE_TYPE_ROTATE3; |
461 | + geis_type_name = GEIS_GESTURE_TYPE_ROTATE4; |
462 | + geis_type_name = GEIS_GESTURE_TYPE_ROTATE5; |
463 | + geis_type_name = GEIS_GESTURE_TYPE_TAP1; |
464 | + geis_type_name = GEIS_GESTURE_TYPE_TAP2; |
465 | + geis_type_name = GEIS_GESTURE_TYPE_TAP3; |
466 | + geis_type_name = GEIS_GESTURE_TYPE_TAP4; |
467 | + geis_type_name = GEIS_GESTURE_TYPE_TAP5; |
468 | + geis_type_name = GEIS_GESTURE_TYPE_TOUCH1; |
469 | + geis_type_name = GEIS_GESTURE_TYPE_TOUCH2; |
470 | + geis_type_name = GEIS_GESTURE_TYPE_TOUCH3; |
471 | + geis_type_name = GEIS_GESTURE_TYPE_TOUCH4; |
472 | + geis_type_name = GEIS_GESTURE_TYPE_TOUCH5; |
473 | +} |
474 | +END_TEST |
475 | + |
476 | +Suite * |
477 | +geis1_gesture_types_new() |
478 | +{ |
479 | + Suite *s = suite_create("geis1_gesture_types"); |
480 | + TCase *test; |
481 | + |
482 | + test = tcase_create("gesture_types"); |
483 | + tcase_add_test(test, gesture_types); |
484 | + suite_add_tcase(s, test); |
485 | + |
486 | + return s; |
487 | +} |
488 | + |
489 | |
490 | === modified file 'testsuite/geistest/geistest.c' |
491 | --- testsuite/geistest/geistest.c 2011-03-22 16:35:35 +0000 |
492 | +++ testsuite/geistest/geistest.c 2011-03-28 12:59:24 +0000 |
493 | @@ -33,6 +33,7 @@ |
494 | GEIS_GESTURE_TYPE_PINCH2, GEIS_GESTURE_TYPE_PINCH3, |
495 | GEIS_GESTURE_TYPE_ROTATE2, GEIS_GESTURE_TYPE_ROTATE3, |
496 | GEIS_GESTURE_TYPE_TAP2, GEIS_GESTURE_TYPE_TAP3, GEIS_GESTURE_TYPE_TAP4, |
497 | + GEIS_GESTURE_TYPE_TOUCH3, GEIS_GESTURE_TYPE_TOUCH4, |
498 | NULL |
499 | }; |
500 |
I'd prefer to move to C99 and use dynamic array sizes than use alloca, just cause it seems more conventional.
The s_grail_class_map array has a bunch of changes to unaffected gesture types. It appears there's a comma added near the end of each line. I think the comma is superfluous and should be removed so there's no change.
grail_mask_clear could just use memset, which would make the code more readable.
Why does grail_mask_setbit only concern itself with the lower 5 bits of each uint32_t?
Although grail exposes velocity attributes for touch gestures, I don't want to expose the attributes through GEIS. I propose masking them out.
Looks good otherwise!