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
1=== modified file 'libutouch-geis/backend/grail/geis_grail_backend.c'
2--- libutouch-geis/backend/grail/geis_grail_backend.c 2012-04-18 16:39:21 +0000
3+++ libutouch-geis/backend/grail/geis_grail_backend.c 2012-04-20 15:45:25 +0000
4@@ -65,7 +65,10 @@
5 unsigned int slice_id;
6 uint64_t timestamp;
7 GeisFloat angle;
8+ GeisFloat position_x;
9+ GeisFloat position_y;
10 GeisFloat radius;
11+ unsigned int num_touches;
12 };
13
14
15@@ -195,7 +198,6 @@
16 GeisFrame frame)
17 {
18 UGGestureTypeMask ugmask = grail_slice_get_recognized(slice);
19- const UGTransform *T = grail_slice_get_transform(slice);
20 const UGTransform *C = grail_slice_get_cumulative_transform(slice);
21
22 geis_frame_add_attr(frame, geis_attr_new(GEIS_GESTURE_ATTRIBUTE_GESTURE_NAME,
23@@ -217,14 +219,18 @@
24 GEIS_ATTR_TYPE_FLOAT,
25 &position_y));
26
27- GeisFloat delta_x = (*T)[0][2];
28+ GeisFloat delta_x = position_x - slice_state->position_x;
29 geis_frame_add_attr(frame, geis_attr_new(GEIS_GESTURE_ATTRIBUTE_DELTA_X,
30 GEIS_ATTR_TYPE_FLOAT,
31 &delta_x));
32- GeisFloat delta_y = (*T)[1][2];
33+ slice_state->position_x = position_x;
34+
35+ GeisFloat delta_y = position_y - slice_state->position_y;
36 geis_frame_add_attr(frame, geis_attr_new(GEIS_GESTURE_ATTRIBUTE_DELTA_Y,
37 GEIS_ATTR_TYPE_FLOAT,
38 &delta_y));
39+ slice_state->position_y = position_y;
40+
41 if (delta_t > 0.0f)
42 {
43 GeisFloat x_velocity = delta_x / delta_t;
44@@ -249,7 +255,7 @@
45 GEIS_ATTR_TYPE_FLOAT,
46 &r));
47
48- GeisFloat dr = r - slice_state->radius;
49+ GeisFloat dr = r / slice_state->radius;
50 geis_frame_add_attr(frame, geis_attr_new(GEIS_GESTURE_ATTRIBUTE_RADIUS_DELTA,
51 GEIS_ATTR_TYPE_FLOAT,
52 &dr));
53@@ -345,16 +351,46 @@
54 _grail_be_slice_state_new(GeisGrailBackend gbe,
55 UGSlice slice)
56 {
57+ const UGTransform *C = grail_slice_get_cumulative_transform(slice);
58 struct _GeisSliceState new_slice_state = {
59 .slice_id = grail_slice_get_id(slice),
60 .timestamp = 0,
61 .angle = 0.0f,
62- .radius = 0.0f
63+ .position_x = grail_slice_get_original_center_x(slice) + (*C)[0][2],
64+ .position_y = grail_slice_get_original_center_y(slice) + (*C)[1][2],
65+ .radius = 1.0f,
66+ .num_touches = grail_slice_get_num_touches(slice)
67 };
68 geis_bag_append(gbe->slice_states, &new_slice_state);
69 return _grail_be_slice_state_from_ugslice(gbe, slice);
70 }
71
72+/**
73+ * Update a slice state for a grail slice.
74+ *
75+ * @param[in] slice_state the geis slice state
76+ * @param[in] slice a grail slice
77+ *
78+ * This function resets the slice state if the number of touches has changed.
79+ */
80+static void
81+_grail_be_slice_state_update(struct _GeisSliceState *slice_state, UGSlice slice)
82+{
83+
84+ if (slice_state->num_touches != grail_slice_get_num_touches(slice))
85+ {
86+ const UGTransform *C = grail_slice_get_cumulative_transform(slice);
87+
88+ slice_state->angle = 0.0f;
89+ slice_state->position_x = grail_slice_get_original_center_x(slice) +
90+ (*C)[0][2];
91+ slice_state->position_x = grail_slice_get_original_center_x(slice) +
92+ (*C)[1][2];
93+ slice_state->radius = 1.0f;
94+ slice_state->num_touches = grail_slice_get_num_touches(slice);
95+ }
96+}
97+
98
99 /**
100 * Creates a geis event from a grail slice.
101@@ -493,6 +529,8 @@
102 slice_state->timestamp = timestamp;
103 }
104
105+ _grail_be_slice_state_update(slice_state, slice);
106+
107 GeisGroupSet groupset = geis_groupset_new();
108 GeisAttr group_attr = geis_attr_new(GEIS_EVENT_ATTRIBUTE_GROUPSET,
109 GEIS_ATTR_TYPE_POINTER,

Subscribers

People subscribed via source and target branches