PERFORCE change 214614 for review

Brooks Davis brooks at FreeBSD.org
Thu Jul 19 18:03:01 UTC 2012


http://p4web.freebsd.org/@@214614?ac=10

Change 214614 by brooks at brooks_ecr_current on 2012/07/19 18:02:40

	Improve the quality of touch screen events by ignoring
	release events which are not followed by invalid (no-contact)
	readings on the next cycle.  Also manufacture release events
	in the event that we start a ts_poll, get a no-contact reading
	the first time, and the previous event returned was a contact
	event.
	
	Convert pictview_pan() to use ts_poll..

Affected files ...

.. //depot/projects/ctsrd/beribsd/src/ctsrd-lib/libde4tc/de4tc.c#11 edit

Differences ...

==== //depot/projects/ctsrd/beribsd/src/ctsrd-lib/libde4tc/de4tc.c#11 (text+ko) ====

@@ -153,9 +153,10 @@
 ts_poll(void)
 {
         struct timespec stime = {0, 1000000};
-        static struct tsstate *sp;
-        int init = 0;
-        struct tsstate tmp_s;
+        static struct tsstate *sp = NULL;
+        int init = 0, first_pass = 1;
+        int check_release = 0;
+        struct tsstate tmp_s, rel_s;
 
         if (sp == NULL) {
                 sp = malloc(sizeof(struct tsstate));
@@ -171,6 +172,22 @@
                 tmp_s.ts_y2 = le32toh(mtlctrl[6]);
                 tmp_s.ts_gesture = le32toh(mtlctrl[7]);
                 if (tmp_s.ts_gesture < 0) {
+			if (check_release) {
+				check_release = 0;
+				*sp = rel_s;
+				return (sp);
+			}
+			if (first_pass && !init && sp->ts_count > 0) {
+				/*
+				 * If we returned a touch last time around
+				 * then fake up a release now.
+				 * XXX: we should probably have a timelimit
+				 */
+				sp->ts_count = 0;
+				sp->ts_gesture = 0;
+				return(sp);
+			}
+			first_pass = 0;
                         nanosleep(&stime, NULL);
                         continue;
                 }
@@ -182,9 +199,19 @@
                     tmp_s.ts_x2 != sp->ts_x2 || tmp_s.ts_y2 != sp->ts_y2 ||
                     tmp_s.ts_count != sp->ts_count ||
                     tmp_s.ts_gesture != sp->ts_gesture) {
-                        *sp = tmp_s;
-                        return (sp);
+			/*
+			 * If we get an release event, differ returning
+			 * it until we sleep and get a non-event.
+			 */
+			if (tmp_s.ts_count == 0) {
+				check_release = 1;
+				rel_s = tmp_s;
+			} else {
+				*sp = tmp_s;
+				return (sp);
+			}
                 }
+		first_pass = 0;
                 nanosleep(&stime, NULL);
         }
 }


More information about the p4-projects mailing list