From 5829aa82100eebeefc23b8c2bc81417b877a200e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Wed, 2 Jul 2008 13:44:53 +0000 Subject: [PATCH] * clutter/fruity/clutter-fruity.c: made the multi touch code more robust. There are situations though where the device seems to stop generating any touch events until all fingers have been lifted and a new interaction session is started. --- ChangeLog | 7 +++++++ clutter/fruity/clutter-fruity.c | 35 ++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5e9cc02c0..26834f2ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-07-02 Øyvind Kolås + + * clutter/fruity/clutter-fruity.c: made the multi touch code more + robust. There are situations though where the device seems to stop + generating any touch events until all fingers have been lifted and + a new interaction session is started. + 2008-07-02 Neil Roberts * clutter/eglx/clutter-stage-egl.c (clutter_stage_egl_realize): diff --git a/clutter/fruity/clutter-fruity.c b/clutter/fruity/clutter-fruity.c index a510cc354..1198c5903 100644 --- a/clutter/fruity/clutter-fruity.c +++ b/clutter/fruity/clutter-fruity.c @@ -78,11 +78,17 @@ typedef struct { bool mapped[MAX_FINGERS] = {false, false, false, false, false}; /* an event has been mapped to this device */ int evs[MAX_FINGERS] = {0,0,0,0,0}; - - for (i = 0; i < event->fingerCount; i++) + + /* using numPoints (with the points[i].status check) seems to + * be no different from using numFingers :/ */ + + for (i = 0; i < event->numPoints; i++) { bool found = false; + if (event->points[i].status != 3) /* skip if finger not down */ + continue; + /* NSLog(@"IncomingEvent: %d, pos: %f, %f", i, event->points[i].x, event->points[i].y);*/ /* check if this finger maps to one of the existing devices */ @@ -98,13 +104,14 @@ typedef struct { if (!dev->is_down) continue; /* device isn't down we cannot really match against it */ - int dist = ABS(event->points[i].x - dev->x) + - ABS(event->points[i].y - dev->y); - if (dist < 20) + int dist = (event->points[i].x - dev->x) * (event->points[i].x - dev->x) + + (event->points[i].y - dev->y) * (event->points[i].y - dev->y); + if (dist < 20 * 20) { found = true; mapped[j] = true; + /* only generate motion events if we've changed position */ if (dist >= 1) { dev->x = event->points[i].x; @@ -130,6 +137,7 @@ typedef struct { dev->x = event->points[i].x; dev->y = event->points[i].y; + g_assert (dev->is_down == FALSE); dev->is_down = TRUE; mapped[j] = true; @@ -140,7 +148,7 @@ typedef struct { } } - for (j = 0; j < MAX_FINGERS; j++) + for (j = 0; j < MAX_FINGERS; j++) { ClutterFruityFingerDevice *dev; @@ -213,7 +221,7 @@ typedef struct { } } -#if 0 // old stylie +#if 0 // old style - (void) mouseDown:(GSEvent*)event { CGPoint location= GSEventGetLocationInWindow(event); @@ -274,13 +282,14 @@ typedef struct { /* New... */ +#if 0 - (void)gestureChanged:(GSEvent*)event { - /*NSLog(@"gestureChanged:");*/ + NSLog(@"gestureChanged:"); [self doEvent: event]; } - (void)gestureEnded:(GSEvent*)event { - /*NSLog(@"gestureEnded:");*/ + NSLog(@"gestureEnded:"); [self doEvent: event]; } @@ -288,6 +297,7 @@ typedef struct { /*NSLog(@"gestureStarted:");*/ [self doEvent: event]; } +#endif - (void)mouseDown:(GSEvent*)event { /*NSLog(@"mouseDown:");*/ @@ -407,6 +417,13 @@ typedef struct { g_main_context_iteration (NULL, FALSE); } +- (id)initWithFrame:(struct CGRect)frame { + [super initWithFrame: frame]; + [super setTapDelegate: self]; + [super setGestureDelegate: self]; + return self; +} + @end void clutter_fruity_main (void)