summaryrefslogtreecommitdiff
path: root/src/gestures.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gestures.c')
-rw-r--r--src/gestures.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/gestures.c b/src/gestures.c
index 977655c..03ec96d 100644
--- a/src/gestures.c
+++ b/src/gestures.c
@@ -70,22 +70,32 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt)
70 int npoint = bitcount(mt->mem.pointing); 70 int npoint = bitcount(mt->mem.pointing);
71 int nmove = bitcount(mt->mem.moving); 71 int nmove = bitcount(mt->mem.moving);
72 int i; 72 int i;
73 float xp[DIM_FINGER], yp[DIM_FINGER];
73 float xm[DIM_FINGER], ym[DIM_FINGER]; 74 float xm[DIM_FINGER], ym[DIM_FINGER];
74 float xmove = 0, ymove = 0; 75 float xpos = 0, ypos = 0;
76 float move, xmove = 0, ymove = 0;
77 float rad, rad2 = 0, scale = 0;
75 78
76 if (!nmove || nmove != npoint) 79 if (!nmove || nmove != npoint)
77 return; 80 return;
78 81
79 foreach_bit(i, mt->mem.moving) { 82 foreach_bit(i, mt->mem.moving) {
83 xp[i] = mt->state.finger[i].hw.position_x - xpos;
84 yp[i] = mt->state.finger[i].hw.position_y - ypos;
80 xm[i] = mt->mem.dx[i]; 85 xm[i] = mt->mem.dx[i];
81 ym[i] = mt->mem.dy[i]; 86 ym[i] = mt->mem.dy[i];
82 mt->mem.dx[i] = 0; 87 mt->mem.dx[i] = 0;
83 mt->mem.dy[i] = 0; 88 mt->mem.dy[i] = 0;
89 xpos += xp[i];
90 ypos += yp[i];
84 xmove += xm[i]; 91 xmove += xm[i];
85 ymove += ym[i]; 92 ymove += ym[i];
86 } 93 }
94 xpos /= nmove;
95 ypos /= nmove;
87 xmove /= nmove; 96 xmove /= nmove;
88 ymove /= nmove; 97 ymove /= nmove;
98 move = sqrt(xmove * xmove + ymove * ymove);
89 99
90 if (nmove == 1) { 100 if (nmove == 1) {
91 if (mt->mem.moving & mt->mem.thumb) { 101 if (mt->mem.moving & mt->mem.thumb) {
@@ -96,6 +106,28 @@ static void extract_movement(struct Gestures *gs, struct MTouch* mt)
96 gs->dy = ymove; 106 gs->dy = ymove;
97 if (gs->dx || gs->dy) 107 if (gs->dx || gs->dy)
98 SETBIT(gs->type, GS_MOVE); 108 SETBIT(gs->type, GS_MOVE);
109 return;
110 }
111
112 foreach_bit(i, mt->mem.moving) {
113 xp[i] -= xpos;
114 yp[i] -= ypos;
115 rad2 += xp[i] * xp[i];
116 rad2 += yp[i] * yp[i];
117 scale += xp[i] * xm[i];
118 scale += yp[i] * ym[i];
119 }
120 rad2 /= nmove;
121 scale /= nmove;
122 rad = sqrt(rad2);
123 scale /= rad;
124
125 if (abs(scale) > move) {
126 gs->scale = scale;
127 if (gs->scale) {
128 if (nmove == 2)
129 SETBIT(gs->type, GS_SCALE);
130 }
99 } else { 131 } else {
100 if (mt->mem.moving & mt->mem.thumb) { 132 if (mt->mem.moving & mt->mem.thumb) {
101 mt_skip_movement(mt, FINGER_THUMB_MS); 133 mt_skip_movement(mt, FINGER_THUMB_MS);