From owner-p4-projects@FreeBSD.ORG Sun Jul 8 22:35:15 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8498E1065673; Sun, 8 Jul 2012 22:35:14 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2F0F2106564A for ; Sun, 8 Jul 2012 22:35:14 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 187078FC16 for ; Sun, 8 Jul 2012 22:35:14 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id q68MZDh1003469 for ; Sun, 8 Jul 2012 22:35:13 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q68MZDRT003466 for perforce@freebsd.org; Sun, 8 Jul 2012 22:35:13 GMT (envelope-from brooks@freebsd.org) Date: Sun, 8 Jul 2012 22:35:13 GMT Message-Id: <201207082235.q68MZDRT003466@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 214095 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jul 2012 22:35:15 -0000 http://p4web.freebsd.org/@@214095?ac=10 Change 214095 by brooks@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 +#include #include #include #include @@ -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);