diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/frame-mtdev.c | 2 | ||||
| -rw-r--r-- | src/frame-xi2.c | 2 | ||||
| -rw-r--r-- | src/frame.c | 33 |
3 files changed, 31 insertions, 6 deletions
diff --git a/src/frame-mtdev.c b/src/frame-mtdev.c index caf90ae..1d9976d 100644 --- a/src/frame-mtdev.c +++ b/src/frame-mtdev.c | |||
| @@ -154,9 +154,11 @@ static int handle_abs_event(utouch_frame_handle fh, | |||
| 154 | return 1; | 154 | return 1; |
| 155 | case ABS_MT_POSITION_X: | 155 | case ABS_MT_POSITION_X: |
| 156 | t->x = ev->value; | 156 | t->x = ev->value; |
| 157 | t->vx = 0; | ||
| 157 | return 1; | 158 | return 1; |
| 158 | case ABS_MT_POSITION_Y: | 159 | case ABS_MT_POSITION_Y: |
| 159 | t->y = ev->value; | 160 | t->y = ev->value; |
| 161 | t->vy = 0; | ||
| 160 | return 1; | 162 | return 1; |
| 161 | case ABS_MT_TOUCH_MAJOR: | 163 | case ABS_MT_TOUCH_MAJOR: |
| 162 | t->touch_major = ev->value; | 164 | t->touch_major = ev->value; |
diff --git a/src/frame-xi2.c b/src/frame-xi2.c index a78d9bf..bead751 100644 --- a/src/frame-xi2.c +++ b/src/frame-xi2.c | |||
| @@ -217,9 +217,11 @@ static int handle_event(utouch_frame_handle fh, | |||
| 217 | switch (fh->evmap[ix]) { | 217 | switch (fh->evmap[ix]) { |
| 218 | case ABS_MT_POSITION_X: | 218 | case ABS_MT_POSITION_X: |
| 219 | slot->x = value; | 219 | slot->x = value; |
| 220 | slot->vx = 0; | ||
| 220 | return 1; | 221 | return 1; |
| 221 | case ABS_MT_POSITION_Y: | 222 | case ABS_MT_POSITION_Y: |
| 222 | slot->y = value; | 223 | slot->y = value; |
| 224 | slot->vy = 0; | ||
| 223 | return 1; | 225 | return 1; |
| 224 | case ABS_MT_TOUCH_MAJOR: | 226 | case ABS_MT_TOUCH_MAJOR: |
| 225 | slot->touch_major = value; | 227 | slot->touch_major = value; |
diff --git a/src/frame.c b/src/frame.c index 32bd2cd..f1c8aa4 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -245,11 +245,14 @@ static void transform_slot(struct utouch_contact *slot, | |||
| 245 | slot->distance *= f; | 245 | slot->distance *= f; |
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | static void copy_contact(utouch_frame_handle fh, | 248 | static void set_contact(utouch_frame_handle fh, |
| 249 | struct utouch_contact *a, | 249 | struct utouch_contact *a, |
| 250 | const struct utouch_contact *b) | 250 | struct utouch_contact *b, |
| 251 | utouch_frame_time_t dt) | ||
| 251 | { | 252 | { |
| 253 | static const float D = 0.333; | ||
| 252 | struct utouch_surface *s = fh->surface; | 254 | struct utouch_surface *s = fh->surface; |
| 255 | const struct utouch_contact *ap = a->prev; | ||
| 253 | 256 | ||
| 254 | a->active = b->id != -1; | 257 | a->active = b->id != -1; |
| 255 | a->id = b->id; | 258 | a->id = b->id; |
| @@ -267,6 +270,21 @@ static void copy_contact(utouch_frame_handle fh, | |||
| 267 | a->distance = b->distance; | 270 | a->distance = b->distance; |
| 268 | 271 | ||
| 269 | transform_slot(a, s); | 272 | transform_slot(a, s); |
| 273 | |||
| 274 | if (a->active && ap->active && a->id == ap->id) { | ||
| 275 | a->x += b->vx * dt; | ||
| 276 | a->y += b->vy * dt; | ||
| 277 | if (dt > 0) { | ||
| 278 | a->vx = (1 - D) * ap->vx + D * (a->x - ap->x) / dt; | ||
| 279 | a->vy = (1 - D) * ap->vy + D * (a->y - ap->y) / dt; | ||
| 280 | } | ||
| 281 | } else { | ||
| 282 | a->vx = 0; | ||
| 283 | a->vy = 0; | ||
| 284 | } | ||
| 285 | |||
| 286 | b->vx = a->vx; | ||
| 287 | b->vy = a->vy; | ||
| 270 | } | 288 | } |
| 271 | 289 | ||
| 272 | static int detect_addrem(const struct utouch_contact *a, | 290 | static int detect_addrem(const struct utouch_contact *a, |
| @@ -303,14 +321,18 @@ const struct utouch_frame *utouch_frame_sync(utouch_frame_handle fh, | |||
| 303 | const struct utouch_frame *prev = frame->prev; | 321 | const struct utouch_frame *prev = frame->prev; |
| 304 | struct utouch_frame *next = fh->next; | 322 | struct utouch_frame *next = fh->next; |
| 305 | int naddrem = 0, nmod = 0; | 323 | int naddrem = 0, nmod = 0; |
| 324 | utouch_frame_time_t dt; | ||
| 306 | int i; | 325 | int i; |
| 307 | 326 | ||
| 327 | frame->time = time ? time : get_time_ms(); | ||
| 308 | frame->num_active = 0; | 328 | frame->num_active = 0; |
| 329 | dt = frame->time - prev->time; | ||
| 330 | |||
| 309 | for (i = 0; i < fh->num_slots; i++) { | 331 | for (i = 0; i < fh->num_slots; i++) { |
| 310 | struct utouch_contact *p = frame->slots[i]; | 332 | struct utouch_contact *p = frame->slots[i]; |
| 311 | const struct utouch_contact *q = next->slots[i]; | 333 | struct utouch_contact *q = next->slots[i]; |
| 312 | 334 | ||
| 313 | copy_contact(fh, p, q); | 335 | set_contact(fh, p, q, dt); |
| 314 | if (p->active) | 336 | if (p->active) |
| 315 | frame->active[frame->num_active++] = p; | 337 | frame->active[frame->num_active++] = p; |
| 316 | 338 | ||
| @@ -320,7 +342,6 @@ const struct utouch_frame *utouch_frame_sync(utouch_frame_handle fh, | |||
| 320 | if (naddrem + nmod == 0) | 342 | if (naddrem + nmod == 0) |
| 321 | return 0; | 343 | return 0; |
| 322 | 344 | ||
| 323 | frame->time = time ? time : get_time_ms(); | ||
| 324 | if (naddrem == 0 && frame->time < prev->time + fh->hold_ms) | 345 | if (naddrem == 0 && frame->time < prev->time + fh->hold_ms) |
| 325 | return 0; | 346 | return 0; |
| 326 | 347 | ||
