PERFORCE change 214095 for review

Brooks Davis brooks at FreeBSD.org
Sun Jul 8 22:35:15 UTC 2012


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

Change 214095 by brooks at brooks_ecr_current on 2012/07/08 22:35:11

	Add a new ts_poll() function to get touch screen events.  It sleeps
	10ms between read events and no longer looses click events.

Affected files ...

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

Differences ...

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

@@ -29,6 +29,7 @@
  */
 
 #include <sys/types.h>
+#include <sys/endian.h>
 #include <sys/stat.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -54,7 +55,7 @@
 static int fademode=0;
 volatile u_int32_t *pfbp;
 static volatile u_int16_t *tfbp;
-static volatile u_int32_t *mtlctrl;
+volatile u_int32_t *mtlctrl;
 
 // fade timing (for crude timing loop)
 static const int fb_cross_fade_time = 500;
@@ -144,6 +145,50 @@
   } while(touch_count!=0);
 }
 
+/*****************************************************************************
+ * Revised touch screen polling interface
+ *****************************************************************************/
+
+struct tsstate*
+ts_poll(void)
+{
+        struct timespec stime = {0, 0.01};
+        static struct tsstate *sp;
+        int init = 0;
+        struct tsstate tmp_s;
+
+        if (sp == NULL) {
+                sp = malloc(sizeof(struct tsstate));
+                if (sp == NULL)
+                        err(1, "malloc of tstate");
+                init = 1;
+        }
+
+        for (;;) {
+                tmp_s.ts_x1 = le32toh(mtlctrl[3]);
+                tmp_s.ts_y1 = le32toh(mtlctrl[4]);
+                tmp_s.ts_x2 = le32toh(mtlctrl[5]);
+                tmp_s.ts_y2 = le32toh(mtlctrl[6]);
+                tmp_s.ts_gesture = le32toh(mtlctrl[7]);
+                if (tmp_s.ts_gesture < 0) {
+                        nanosleep(&stime, NULL);
+                        continue;
+                }
+                tmp_s.ts_count = tmp_s.ts_gesture >> 8;
+                tmp_s.ts_gesture &= 0xFF;
+ 
+               if (init ||
+                    tmp_s.ts_x1 != sp->ts_x1 || tmp_s.ts_y1 != sp->ts_y1 ||
+                    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);
+                }
+                nanosleep(&stime, NULL);
+        }
+}
+
 
 /*****************************************************************************
  * frame buffer routines

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

@@ -32,6 +32,40 @@
 #ifndef _DE4TC_H_
 #define _DE4TC_H_
 
+#define	TSG_NONE	0x00
+#define	TSG_NORTH	0x10
+#define	TSG_NORTHEAST	0x12
+#define	TSG_EAST	0x14
+#define	TSG_SOUTHEAST	0x16
+#define	TSG_SOUTH	0x18
+#define	TSG_SOUTHWEST	0x1A
+#define	TSG_WEST	0x1C
+#define	TSG_NORTHWEST	0x1E
+#define	TSG_ROTATE_CW	0x28	/* Clockwise */
+#define	TSG_ROTATE_CCW	0x29	/* Counter Clockwise */
+#define	TSG_CLICK	0x20
+#define	TSG_DCLICK	0x22	/* Double Click */
+#define	TSG2_NORTH	0x30
+#define	TSG2_NORTHEAST	0x32
+#define	TSG2_EAST	0x34
+#define	TSG2_SOUTHEAST	0x36
+#define	TSG2_SOUTH	0x38
+#define	TSG2_SOUTHWEST	0x3A
+#define	TSG2_WEST	0x3C
+#define	TSG2_NORTHWEST	0x3E
+#define	TSG2_CLICK	0x40
+#define	TSG2_ZOOM_IN	0x48
+#define	TSG2_ZOOM_OUT	0x49
+
+struct tsstate {
+	int ts_x1;
+	int ts_y1;
+	int ts_x2;
+	int ts_y2;
+	int ts_count;
+	int ts_gesture;
+};
+
 extern int touch_x0;
 extern int touch_y0;
 extern int touch_x1;
@@ -42,9 +76,12 @@
 extern const int fb_height;
 extern const int fb_width;
 
+extern volatile u_int32_t *mtlctrl;
+
 void multitouch_pole(void);
 void multitouch_filter(void);
 void multitouch_release_event(void);
+struct tsstate* ts_poll(void);
 void fb_init(void);
 void fb_fini(void);
 u_int32_t fb_colour(int r, int g, int b);


More information about the p4-projects mailing list