Merge lp:~chasedouglas/geis/fix-deltas into lp:geis

Proposed by Chase Douglas
Status: Merged
Merged at revision: 255
Proposed branch: lp:~chasedouglas/geis/fix-deltas
Merge into: lp:geis
Prerequisite: lp:~chasedouglas/geis/delta-test
Diff against target: 109 lines (+43/-5)
1 file modified
libutouch-geis/backend/grail/geis_grail_backend.c (+43/-5)
To merge this branch: bzr merge lp:~chasedouglas/geis/fix-deltas
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
Chase Douglas (community) Needs Resubmitting
Review via email: mp+102776@code.launchpad.net

Description of the change

Fix delta calculation when synchronous events are not enabled.

To post a comment you must log in.
Revision history for this message
Stephen M. Webb (bregma) wrote :

Should the radius and angle really be reset to zero when the number of touches change? That doesn't make a lot of sense to me from a functional point of view.

Revision history for this message
Chase Douglas (chasedouglas) wrote :

I merely copied and pasted the radius and angle bits. After thinking some more, the angle should be reset to 0 (it's inherently a relative value), and the radius should be reset to 1 as it represents the ratio of the current radius to the original radius.

I'll fix this up.

lp:~chasedouglas/geis/fix-deltas updated
256. By Chase Douglas

Calculate radius deltas as a ratio from previous geis event

The radius values are scale factors from the geis begin event, so the
deltas should be scale factors from the previous geis event too.

257. By Chase Douglas

Merged delta-test into fix-deltas.

Revision history for this message
Chase Douglas (chasedouglas) wrote :

I have fixed the radius deltas now. Please review.

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

OK.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libutouch-geis/backend/grail/geis_grail_backend.c'
--- libutouch-geis/backend/grail/geis_grail_backend.c 2012-04-18 16:39:21 +0000
+++ libutouch-geis/backend/grail/geis_grail_backend.c 2012-04-20 15:45:25 +0000
@@ -65,7 +65,10 @@
65 unsigned int slice_id;65 unsigned int slice_id;
66 uint64_t timestamp;66 uint64_t timestamp;
67 GeisFloat angle;67 GeisFloat angle;
68 GeisFloat position_x;
69 GeisFloat position_y;
68 GeisFloat radius;70 GeisFloat radius;
71 unsigned int num_touches;
69};72};
7073
7174
@@ -195,7 +198,6 @@
195 GeisFrame frame)198 GeisFrame frame)
196{199{
197 UGGestureTypeMask ugmask = grail_slice_get_recognized(slice);200 UGGestureTypeMask ugmask = grail_slice_get_recognized(slice);
198 const UGTransform *T = grail_slice_get_transform(slice);
199 const UGTransform *C = grail_slice_get_cumulative_transform(slice);201 const UGTransform *C = grail_slice_get_cumulative_transform(slice);
200202
201 geis_frame_add_attr(frame, geis_attr_new(GEIS_GESTURE_ATTRIBUTE_GESTURE_NAME,203 geis_frame_add_attr(frame, geis_attr_new(GEIS_GESTURE_ATTRIBUTE_GESTURE_NAME,
@@ -217,14 +219,18 @@
217 GEIS_ATTR_TYPE_FLOAT,219 GEIS_ATTR_TYPE_FLOAT,
218 &position_y));220 &position_y));
219221
220 GeisFloat delta_x = (*T)[0][2];222 GeisFloat delta_x = position_x - slice_state->position_x;
221 geis_frame_add_attr(frame, geis_attr_new(GEIS_GESTURE_ATTRIBUTE_DELTA_X,223 geis_frame_add_attr(frame, geis_attr_new(GEIS_GESTURE_ATTRIBUTE_DELTA_X,
222 GEIS_ATTR_TYPE_FLOAT,224 GEIS_ATTR_TYPE_FLOAT,
223 &delta_x));225 &delta_x));
224 GeisFloat delta_y = (*T)[1][2];226 slice_state->position_x = position_x;
227
228 GeisFloat delta_y = position_y - slice_state->position_y;
225 geis_frame_add_attr(frame, geis_attr_new(GEIS_GESTURE_ATTRIBUTE_DELTA_Y,229 geis_frame_add_attr(frame, geis_attr_new(GEIS_GESTURE_ATTRIBUTE_DELTA_Y,
226 GEIS_ATTR_TYPE_FLOAT,230 GEIS_ATTR_TYPE_FLOAT,
227 &delta_y));231 &delta_y));
232 slice_state->position_y = position_y;
233
228 if (delta_t > 0.0f)234 if (delta_t > 0.0f)
229 {235 {
230 GeisFloat x_velocity = delta_x / delta_t;236 GeisFloat x_velocity = delta_x / delta_t;
@@ -249,7 +255,7 @@
249 GEIS_ATTR_TYPE_FLOAT,255 GEIS_ATTR_TYPE_FLOAT,
250 &r));256 &r));
251257
252 GeisFloat dr = r - slice_state->radius;258 GeisFloat dr = r / slice_state->radius;
253 geis_frame_add_attr(frame, geis_attr_new(GEIS_GESTURE_ATTRIBUTE_RADIUS_DELTA,259 geis_frame_add_attr(frame, geis_attr_new(GEIS_GESTURE_ATTRIBUTE_RADIUS_DELTA,
254 GEIS_ATTR_TYPE_FLOAT,260 GEIS_ATTR_TYPE_FLOAT,
255 &dr));261 &dr));
@@ -345,16 +351,46 @@
345_grail_be_slice_state_new(GeisGrailBackend gbe,351_grail_be_slice_state_new(GeisGrailBackend gbe,
346 UGSlice slice)352 UGSlice slice)
347{353{
354 const UGTransform *C = grail_slice_get_cumulative_transform(slice);
348 struct _GeisSliceState new_slice_state = {355 struct _GeisSliceState new_slice_state = {
349 .slice_id = grail_slice_get_id(slice),356 .slice_id = grail_slice_get_id(slice),
350 .timestamp = 0, 357 .timestamp = 0,
351 .angle = 0.0f,358 .angle = 0.0f,
352 .radius = 0.0f359 .position_x = grail_slice_get_original_center_x(slice) + (*C)[0][2],
360 .position_y = grail_slice_get_original_center_y(slice) + (*C)[1][2],
361 .radius = 1.0f,
362 .num_touches = grail_slice_get_num_touches(slice)
353 };363 };
354 geis_bag_append(gbe->slice_states, &new_slice_state);364 geis_bag_append(gbe->slice_states, &new_slice_state);
355 return _grail_be_slice_state_from_ugslice(gbe, slice);365 return _grail_be_slice_state_from_ugslice(gbe, slice);
356}366}
357367
368/**
369 * Update a slice state for a grail slice.
370 *
371 * @param[in] slice_state the geis slice state
372 * @param[in] slice a grail slice
373 *
374 * This function resets the slice state if the number of touches has changed.
375 */
376static void
377_grail_be_slice_state_update(struct _GeisSliceState *slice_state, UGSlice slice)
378{
379
380 if (slice_state->num_touches != grail_slice_get_num_touches(slice))
381 {
382 const UGTransform *C = grail_slice_get_cumulative_transform(slice);
383
384 slice_state->angle = 0.0f;
385 slice_state->position_x = grail_slice_get_original_center_x(slice) +
386 (*C)[0][2];
387 slice_state->position_x = grail_slice_get_original_center_x(slice) +
388 (*C)[1][2];
389 slice_state->radius = 1.0f;
390 slice_state->num_touches = grail_slice_get_num_touches(slice);
391 }
392}
393
358394
359/**395/**
360 * Creates a geis event from a grail slice.396 * Creates a geis event from a grail slice.
@@ -493,6 +529,8 @@
493 slice_state->timestamp = timestamp;529 slice_state->timestamp = timestamp;
494 }530 }
495531
532 _grail_be_slice_state_update(slice_state, slice);
533
496 GeisGroupSet groupset = geis_groupset_new();534 GeisGroupSet groupset = geis_groupset_new();
497 GeisAttr group_attr = geis_attr_new(GEIS_EVENT_ATTRIBUTE_GROUPSET,535 GeisAttr group_attr = geis_attr_new(GEIS_EVENT_ATTRIBUTE_GROUPSET,
498 GEIS_ATTR_TYPE_POINTER,536 GEIS_ATTR_TYPE_POINTER,

Subscribers

People subscribed via source and target branches