OSDN Git Service

Port Android-x86 changes to newer tslib.
authorBryan Hundven <bryanhundven@gmail.com>
Mon, 4 Jul 2011 08:49:35 +0000 (01:49 -0700)
committerBryan Hundven <bryanhundven@gmail.com>
Mon, 4 Jul 2011 08:49:35 +0000 (01:49 -0700)
22 files changed:
Android.mk [new file with mode: 0644]
README
etc/README [new file with mode: 0644]
plugins/Android.mk [new file with mode: 0644]
plugins/input-raw.c
plugins/linear.c
src/Android.mk [new file with mode: 0644]
src/ts_config.c
src/ts_load_module.c
src/ts_open.c
src/ts_settings.c [new file with mode: 0644]
src/tslib-private.h
src/tslib.h
tests/Android.mk [new file with mode: 0644]
tests/fbutils.c
tests/fbutils.h
tests/ts_calibrate.c
tests/ts_harvest.c
tests/ts_print.c
tests/ts_print_raw.c
tests/ts_test.c
tslib.mk [new file with mode: 0644]

diff --git a/Android.mk b/Android.mk
new file mode 100644 (file)
index 0000000..df7c0ef
--- /dev/null
@@ -0,0 +1,3 @@
+ifeq ($(BOARD_USES_TSLIB),true)
+include $(call all-subdir-makefiles)
+endif
diff --git a/README b/README
index 237db42..d16c80c 100644 (file)
--- a/README
+++ b/README
@@ -54,6 +54,19 @@ TSLIB_CONSOLEDEVICE          Console device.
 TSLIB_FBDEVICE                 Framebuffer device.
                                Default: /dev/fb0
 
+Alternatively, use ${sysconfdir}/ts.env to store these configuration
+parameters. Some java terminals do not inherit environment variables, and
+having to type the environment variables everytime can be a pain. The format of
+ts.env should be the same as entering the environment variables into a flat 
+file:
+
+TSLIB_TSDEVICE=/dev/input/event2
+TSLIB_CALIBFILE=/etc/pointercal
+<key>=<value>
+
+Empty lines, lines starting with '#', lines longer then 512 bytes, and lines
+that don't follow the previous three lines will be ignored.
+
 
 Module Creation Notes
 =====================
diff --git a/etc/README b/etc/README
new file mode 100644 (file)
index 0000000..c805499
--- /dev/null
@@ -0,0 +1,4 @@
+Don't have android install ts.conf.
+This should be done by the Target Product.
+Copy the ts.conf to vendor/<company>/<product> and install it from there.
+Also include a premade pointercal if you wish.
diff --git a/plugins/Android.mk b/plugins/Android.mk
new file mode 100644 (file)
index 0000000..922e745
--- /dev/null
@@ -0,0 +1,166 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+C_INCLUDES += \
+       external/tslib \
+       external/tslib/src \
+       external/tslib/plugins
+
+CFLAGS += -DTS_POINTERCAL=\"/data/system/tslib/pointercal\" \
+         -DTS_ENV=\"/system/etc/ts.env\" \
+         -DTSLIB_INTERNAL \
+         -DGCC_HASCLASSVISIBILITY
+
+LOCAL_MODULE:= linear
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = linear.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= dejitter
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = dejitter.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= variance
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = variance.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= pthres
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = pthres.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= input-raw
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = input-raw.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= arctic2
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = arctic2-raw.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= corgi
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = corgi-raw.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= collie
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = collie-raw.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= h3600
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = h3600-raw.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= linear-h2200
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = linear-h2200.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= mk712
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = mk712-raw.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= tatung
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = tatung-raw.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= touchkit
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = touchkit-raw.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE:= ucb1x00
+LOCAL_MODULE_TAGS := optional
+LOCAL_PRELINK_MODULE := false
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_C_INCLUDES = $(C_INCLUDES)
+LOCAL_SRC_FILES = ucb1x00-raw.c
+LOCAL_SHARED_LIBRARIES += libts
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/ts
+include $(BUILD_SHARED_LIBRARY)
+
index 4396eab..0c71f5e 100644 (file)
@@ -102,7 +102,7 @@ static int check_fd(struct tslib_input *i)
        we set it to constant 255. It's still controlled by BTN_TOUCH - when not
        touched, the pressure is forced to 0. */
 
-       if (!(absbit[BIT_WORD(ABS_PRESSURE)] & BIT_MASK(ABS_PRESSURE))) {
+       if (1 || !(absbit[BIT_WORD(ABS_PRESSURE)] & BIT_MASK(ABS_PRESSURE))) {
                i->current_p = 255;
 
                if ((ioctl(ts->fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) ||
@@ -154,6 +154,7 @@ static int ts_input_read(struct tslib_module_info *inf,
                        case EV_KEY:
                                switch (ev.code) {
                                case BTN_TOUCH:
+                               case BTN_MOUSE:
                                        if (ev.value == 0)
                                                pen_up = 1;
                                        break;
@@ -183,9 +184,11 @@ static int ts_input_read(struct tslib_module_info *inf,
                        case EV_ABS:
                                switch (ev.code) {
                                case ABS_X:
+                               case ABS_Z:
                                        i->current_x = ev.value;
                                        break;
                                case ABS_Y:
+                               case ABS_RX:
                                        i->current_y = ev.value;
                                        break;
                                case ABS_PRESSURE:
@@ -222,6 +225,7 @@ static int ts_input_read(struct tslib_module_info *inf,
                        if (ev.type == EV_ABS) {
                                switch (ev.code) {
                                case ABS_X:
+                               case ABS_Z:
                                        if (ev.value != 0) {
                                                samp->x = i->current_x = ev.value;
                                                samp->y = i->current_y;
@@ -232,6 +236,7 @@ static int ts_input_read(struct tslib_module_info *inf,
                                        }
                                        break;
                                case ABS_Y:
+                               case ABS_RX:
                                        if (ev.value != 0) {
                                                samp->x = i->current_x;
                                                samp->y = i->current_y = ev.value;
@@ -257,6 +262,7 @@ static int ts_input_read(struct tslib_module_info *inf,
                        } else if (ev.type == EV_KEY) {
                                switch (ev.code) {
                                case BTN_TOUCH:
+                               case BTN_MOUSE:
                                        if (ev.value == 0) {
                                                /* pen up */
                                                samp->x = 0;
@@ -338,6 +344,7 @@ TSAPI struct tslib_module_info *input_mod_init(struct tsdev *dev, const char *pa
                return NULL;
 
        i->module.ops = &__ts_input_ops;
+       i->module.dev = dev;
        i->current_x = 0;
        i->current_y = 0;
        i->current_p = 0;
@@ -345,7 +352,7 @@ TSAPI struct tslib_module_info *input_mod_init(struct tsdev *dev, const char *pa
        i->using_syn = 0;
        i->grab_events = 0;
 
-       if (tslib_parse_vars(&i->module, raw_vars, NR_VARS, params)) {
+       if (check_fd(i) || tslib_parse_vars(&i->module, raw_vars, NR_VARS, params)) {
                free(i);
                return NULL;
        }
index 822f647..52dbeee 100644 (file)
@@ -159,6 +159,9 @@ TSAPI struct tslib_module_info *linear_mod_init(struct tsdev *dev, const char *p
        int index;
        char *calfile;
 
+       struct tssetting *tset;
+       tset = ts_setting(TS_ENV);
+
        lin = malloc(sizeof(struct tslib_linear));
        if (lin == NULL)
                return NULL;
@@ -181,7 +184,13 @@ TSAPI struct tslib_module_info *linear_mod_init(struct tsdev *dev, const char *p
        /*
         * Check calibration file
         */
-       if( (calfile = getenv("TSLIB_CALIBFILE")) == NULL) calfile = TS_POINTERCAL;
+       if( (calfile = getenv("TSLIB_CALIBFILE")) == NULL) {
+               if (tset != NULL) {
+                       calfile = tset->calfile;
+               } else {
+                       calfile = TS_POINTERCAL;
+               }
+       }
        if (stat(calfile, &sbuf)==0) {
                pcal_fd = fopen(calfile, "r");
                for (index = 0; index < 7; index++)
@@ -204,6 +213,7 @@ TSAPI struct tslib_module_info *linear_mod_init(struct tsdev *dev, const char *p
                return NULL;
        }
 
+       free(tset);
        return &lin->module;
 }
 
diff --git a/src/Android.mk b/src/Android.mk
new file mode 100644 (file)
index 0000000..2892e4c
--- /dev/null
@@ -0,0 +1,32 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+       ts_attach.c \
+       ts_close.c \
+       ts_config.c \
+       ts_setting.c \
+       ts_error.c \
+       ts_fd.c \
+       ts_load_module.c \
+       ts_open.c \
+       ts_parse_vars.c \
+       ts_read.c \
+       ts_read_raw.c
+
+#include $(LOCAL_PATH)/../android-config.mk
+LOCAL_CFLAGS += -DPLUGIN_DIR=\"/system/lib/ts\" \
+               -DTS_CONF=\"/system/etc/ts.conf\" \
+               -DTS_ENV=\"/system/etc/ts.env\" \
+               -DTSLIB_INTERNAL
+LOCAL_C_INCLUDES += \
+       external/tslib \
+       external/tslib/src
+
+LOCAL_SHARED_LIBRARIES += libdl
+LOCAL_PRELINK_MODULE := false
+
+LOCAL_MODULE:= libts
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
index c3cb0f5..df29c6a 100644 (file)
@@ -29,10 +29,17 @@ int ts_config(struct tsdev *ts)
        int line = 0;
        int ret = 0;
 
+       struct tssetting *tset;
+       tset = ts_setting(TS_ENV);
+
        char *conffile;
 
        if( (conffile = getenv("TSLIB_CONFFILE")) == NULL) {
-               conffile = strdup (TS_CONF);
+               if (tset != NULL) {
+                       conffile = tset->conffile;
+               } else {
+                       conffile = strdup (TS_CONF);
+               }
        }
 
        f = fopen(conffile, "r");
@@ -95,5 +102,6 @@ int ts_config(struct tsdev *ts)
 
        fclose(f);
 
+       free(tset);
        return ret;
 }
index 3fab1da..479ec9f 100644 (file)
@@ -104,8 +104,16 @@ static struct tslib_module_info *__ts_load_module_shared(struct tsdev *ts, const
        void *handle;
        char *plugin_directory = getenv("TSLIB_PLUGINDIR");
 
-       if (!plugin_directory)
-               plugin_directory = PLUGIN_DIR;
+       struct tssetting *tset;
+       tset = ts_setting(TS_ENV);
+
+       if (!plugin_directory) {
+               if (tset != NULL && tset->plugdir != NULL) {
+                       plugin_directory = tset->plugdir;
+               } else {
+                       plugin_directory = PLUGIN_DIR;
+               }
+       }
 
        snprintf(fn, sizeof fn, "%s/%s.so", plugin_directory, module);
 
@@ -137,6 +145,7 @@ static struct tslib_module_info *__ts_load_module_shared(struct tsdev *ts, const
 
        info->handle = handle;
 
+       free(tset);
        return info;
 }
 
index d38babf..7f92c1a 100644 (file)
@@ -16,7 +16,7 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-#include <sys/fcntl.h>
+#include <fcntl.h>
 
 #include "tslib-private.h"
 
diff --git a/src/ts_settings.c b/src/ts_settings.c
new file mode 100644 (file)
index 0000000..0dc48f2
--- /dev/null
@@ -0,0 +1,78 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "tslib.h"
+
+#define BUF_SIZE 512
+
+struct tssetting *ts_setting(const char *filename)
+{
+       struct tssetting *tset;
+       char buf[BUF_SIZE], *p;
+       int line = 0;
+
+       /* try to open filename */
+       FILE *file = fopen(filename, "r");
+       if (file == NULL) {
+               perror("Failed to open settings file");
+               return NULL;
+       } else {
+               /* we can open filename, lets allocate tset! */
+               tset = malloc(sizeof(struct tssetting));
+               if (tset)
+               {
+                       memset(tset, 0, sizeof(struct tssetting));
+               } else {
+                       return NULL;
+               }
+       }
+
+       if (file != NULL)
+       {
+               buf[BUF_SIZE - 2] = '\0';
+               while ((p = fgets(buf, BUF_SIZE, file)) != NULL) {
+                       char *e, *tok;
+                       char delim[] = "=";
+                       
+                       line++;
+
+                       /* chomp */
+                       e = strchr(p, '\n');
+                       if (e)
+                               *e = '\0';
+                       
+                       /* ignore lines that are too long for our buffer */
+                       if (buf[BUF_SIZE - 2] != '\0') {
+                               /* printf("%s: line %d too long\n", filename, line); */
+                               break;
+                       }
+
+                       /* get the lhs of delim */
+                       tok = strsep(&p, delim);
+
+                       /* ignore lines starting with '#' and blank lines */
+                       if (p==NULL || *tok == '#')
+                               continue;
+
+                       /* copy the rhs to struct->member */
+                       if (strcasecmp(tok, "TSLIB_TSDEVICE") == 0) {
+                               tset->tsdev = strdup(strsep(&p, delim));
+                       } else if (strcasecmp(tok, "TSLIB_CONSOLEDEVICE") == 0) {
+                               tset->condev = strdup(strsep(&p, delim));
+                       } else if (strcasecmp(tok, "TSLIB_FBDEVICE") == 0) {
+                               tset->fbdev = strdup(strsep(&p, delim));
+                       } else if (strcasecmp(tok, "TSLIB_CALIBFILE") == 0) {
+                               tset->calfile = strdup(strsep(&p, delim));
+                       } else if (strcasecmp(tok, "TSLIB_CONFFILE") == 0) {
+                               tset->conffile = strdup(strsep(&p, delim));
+                       } else if (strcasecmp(tok, "TSLIB_PLUGINDIR") == 0) {
+                               tset->plugdir = strdup(strsep(&p, delim));
+                       } else {
+                               /* unknown line... ignoring */
+                               continue;
+                       }
+               }
+               fclose(file);
+       }
+       return tset;
+}
index bffc62e..0968455 100644 (file)
@@ -28,6 +28,8 @@ struct tsdev {
        int rotation;
 };
 
+struct tssetting;
+
 int __ts_attach(struct tsdev *ts, struct tslib_module_info *info);
 int __ts_attach_raw(struct tsdev *ts, struct tslib_module_info *info);
 int ts_load_module(struct tsdev *dev, const char *module, const char *params);
index df8e284..9903856 100644 (file)
@@ -39,6 +39,16 @@ extern "C" {
 
 struct tsdev;
 
+struct tssetting
+{
+       char *tsdev;
+       char *fbdev;
+       char *calfile;
+       char *conffile;
+       char *condev;
+       char *plugdir;
+};
+
 struct ts_sample {
        int             x;
        int             y;
@@ -52,6 +62,11 @@ enum ts_param {
 };
 
 /*
+ * Get environment variables from settings file rather then environment.
+ */
+TSAPI struct tssetting *ts_setting(const char *filename);
+
+/*
  * Close the touchscreen device, free all resources.
  */
 TSAPI int ts_close(struct tsdev *);
diff --git a/tests/Android.mk b/tests/Android.mk
new file mode 100644 (file)
index 0000000..8f14154
--- /dev/null
@@ -0,0 +1,67 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+INCLUDES += \
+       external/tslib \
+       external/tslib/src \
+       external/tslib/tests
+
+CFLAGS += -DTS_POINTERCAL=\"/data/system/tslib/pointercal\" \
+         -DTS_ENV=\"/system/etc/ts.env\" \
+         -DGCC_HASCLASSVISIBILITY
+
+SRC_FILES += fbutils.c \
+            font_8x8.c \
+            font_8x16.c
+
+SHARED_LIBRARIES = libts
+
+LOCAL_MODULE := ts_test
+LOCAL_MODULE_TAGS := tests
+LOCAL_SRC_FILES = ts_test.c \
+                 $(SRC_FILES)
+LOCAL_C_INCLUDES = $(INCLUDES)
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_SHARED_LIBRARIES = $(SHARED_LIBRARIES)
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := ts_calibrate
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES = ts_calibrate.c \
+                 testutils.c \
+                 $(SRC_FILES)
+LOCAL_C_INCLUDES = $(INCLUDES)
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_SHARED_LIBRARIES = $(SHARED_LIBRARIES)
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := ts_print
+LOCAL_MODULE_TAGS := tests
+LOCAL_SRC_FILES = ts_print.c
+LOCAL_C_INCLUDES = $(INCLUDES)
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_SHARED_LIBRARIES = $(SHARED_LIBRARIES)
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := ts_print_raw
+LOCAL_MODULE_TAGS := tests
+LOCAL_SRC_FILES = ts_print_raw.c
+LOCAL_C_INCLUDES = $(INCLUDES)
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_SHARED_LIBRARIES = $(SHARED_LIBRARIES)
+include $(BUILD_EXECUTABLE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := ts_harvest
+LOCAL_MODULE_TAGS := tests
+LOCAL_SRC_FILES = ts_harvest.c \
+                 testutils.c \
+                 $(SRC_FILES)
+LOCAL_C_INCLUDES = $(INCLUDES)
+LOCAL_CFLAGS = $(CFLAGS)
+LOCAL_SHARED_LIBRARIES = $(SHARED_LIBRARIES)
+include $(BUILD_EXECUTABLE)
+
index ec267f7..515c912 100644 (file)
@@ -16,7 +16,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <sys/time.h>
@@ -25,6 +25,8 @@
 #include <linux/kd.h>
 #include <linux/fb.h>
 
+#include "tslib.h"
+
 #include "font.h"
 #include "fbutils.h"
 
@@ -49,6 +51,20 @@ static char *defaultconsoledevice = "/dev/tty";
 static char *fbdevice = NULL;
 static char *consoledevice = NULL;
 
+struct tsdev *open_touchdev(const char *dev)
+{
+       struct tsdev *ts = ts_open(dev, 0);
+       if (!ts) {
+               perror("ts_open");
+               return NULL;
+       }
+       if (ts_config(ts)) {
+               ts_close(ts);
+               return NULL;
+       }
+       return ts;
+}
+
 int open_framebuffer(void)
 {
        struct vt_stat vts;
@@ -56,11 +72,24 @@ int open_framebuffer(void)
        int fd, nr;
        unsigned y, addr;
 
-       if ((fbdevice = getenv ("TSLIB_FBDEVICE")) == NULL)
-               fbdevice = defaultfbdevice;
+       struct tssetting *tset;
+       tset = ts_setting(TS_ENV);
 
-       if ((consoledevice = getenv ("TSLIB_CONSOLEDEVICE")) == NULL)
-               consoledevice = defaultconsoledevice;
+       if ((fbdevice = getenv ("TSLIB_FBDEVICE")) == NULL) {
+               if (tset != NULL) {
+                       fbdevice = tset->fbdev;
+               } else {
+                       fbdevice = defaultfbdevice;
+               }
+       }
+
+       if ((consoledevice = getenv ("TSLIB_CONSOLEDEVICE")) == NULL) {
+               if (tset != NULL) {
+                       consoledevice = tset->condev;
+               } else {
+                       consoledevice = defaultconsoledevice;
+               }
+       }
 
        if (strcmp (consoledevice, "none") != 0) {
                sprintf (vtname,"%s%d", consoledevice, 1);
@@ -143,6 +172,7 @@ int open_framebuffer(void)
        for (y = 0; y < var.yres_virtual; y++, addr += fix.line_length)
                line_addr [y] = fbuffer + addr;
 
+       free(tset);
        return 0;
 }
 
index 48890f7..3d612c9 100644 (file)
@@ -23,6 +23,7 @@
 
 extern __u32 xres, yres;
 
+struct tsdev *open_touchdev(const char *dev);
 int open_framebuffer(void);
 void close_framebuffer(void);
 void setcolor(unsigned colidx, unsigned value);
index 1bee699..1a2e911 100644 (file)
@@ -16,7 +16,7 @@
 #include <signal.h>
 #include <string.h>
 #include <unistd.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <sys/time.h>
@@ -196,23 +196,43 @@ int main()
        char *tsdevice = NULL;
        char *calfile = NULL;
        unsigned int i, len;
+       pid_t child;
+
+       child = fork();
+       if (child > 0) {
+               getchar();
+               kill(child, SIGKILL);
+               exit(0);
+       } else if (child < 0) {
+               perror("fork");
+               exit(-1);
+       }
+
+       struct tsetting *tset;
+       tset = ts_setting(TS_ENV);
 
        signal(SIGSEGV, sig);
        signal(SIGINT, sig);
        signal(SIGTERM, sig);
 
        if( (tsdevice = getenv("TSLIB_TSDEVICE")) != NULL ) {
-               ts = ts_open(tsdevice,0);
-       } else {
-               if (!(ts = ts_open("/dev/input/event0", 0)))
-                       ts = ts_open("/dev/touchscreen/ucb1x00", 0);
+               ts = ts_touchdev(tsdevice);
+       } else if (tset != NULL) {
+               ts = ts_touchdev(tset->tsdev);
        }
 
        if (!ts) {
-               perror("ts_open");
-               exit(1);
+               char tsdevice[20];
+               /* CW: a lazy way to go through all events.. is 99 enough? */
+               for (i = 0; i <= 99; ++i) {
+                       sprintf(tsdevice, "/dev/input/event%d", i);
+                       if ((ts = open_touchdev(tsdevice)))
+                               break;
+               }
+               if (!ts)
+                       ts = open_touchdev("/dev/touchscreen/ucb1x00");
        }
-       if (ts_config(ts)) {
+       if (!ts) {
                perror("ts_config");
                exit(1);
        }
@@ -229,8 +249,11 @@ int main()
                           "TSLIB calibration utility", 1);
        put_string_center (xres / 2, yres / 4 + 20,
                           "Touch crosshair to calibrate", 2);
+       put_string_center (xres / 2, yres / 4 + 40,
+                          "Press Enter to skip", 2);
 
-       printf("xres = %d, yres = %d\n", xres, yres);
+       sprintf(cal_buffer, "Resolution %d x %d", xres, yres);
+       put_string_center (xres / 2, yres / 4 + 70, cal_buffer, 3);
 
        // Clear the buffer
        clearbuf(ts);
@@ -252,6 +275,9 @@ int main()
                if ((calfile = getenv("TSLIB_CALIBFILE")) != NULL) {
                        cal_fd = open (calfile, O_CREAT | O_RDWR,
                                       S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+               } else if (tset != NULL) {
+                       cal_fd = open (tset->calfile, O_CREAT | O_RDWR,
+                                      S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
                } else {
                        cal_fd = open (TS_POINTERCAL, O_CREAT | O_RDWR,
                                       S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
@@ -268,6 +294,8 @@ int main()
                i = -1;
        }
 
+       free(tset);
        close_framebuffer();
+       kill(getppid(), SIGTERM);
        return i;
 }
index 05b8853..3be5812 100644 (file)
@@ -16,7 +16,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <signal.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <sys/time.h>
@@ -69,12 +69,17 @@ int main()
        char *tsdevice=NULL;
        FILE *output_fid;
 
+       struct tssetting *tset;
+       tset = ts_setting(TS_ENV);
+
        signal(SIGSEGV, sig);
        signal(SIGINT, sig);
        signal(SIGTERM, sig);
 
        if( (tsdevice = getenv("TSLIB_TSDEVICE")) != NULL ) {
                ts = ts_open(tsdevice,0);
+       } else if (tset != NULL) {
+               ts = ts_open(tset->tsdev, 0);
        } else {
                if (!(ts = ts_open("/dev/input/event0", 0)))
                        ts = ts_open("/dev/touchscreen/ucb1x00", 0);
@@ -197,6 +202,7 @@ int main()
        put_string_center (xres/2, yres*0.85, "Touch anywhere to quit", 4);
        getxy (ts, &x_ts, &y_ts); 
        refresh_screen ();
+       free(tset);
        close_framebuffer();
        return 0;
 }
index b2a7b85..2fe5179 100644 (file)
@@ -12,7 +12,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <sys/time.h>
@@ -25,8 +25,13 @@ int main()
        struct tsdev *ts;
        char *tsdevice=NULL;
 
+       struct tssetting *tset;
+       tset = ts_setting(TS_ENV);
+
        if( (tsdevice = getenv("TSLIB_TSDEVICE")) != NULL ) {
                ts = ts_open(tsdevice,0);
+       } else if (tset != NULL) {
+               ts = ts_open(tset->tsdev, 0);
        } else {
                if (!(ts = ts_open("/dev/input/event0", 0)))
                        ts = ts_open("/dev/touchscreen/ucb1x00", 0);
@@ -59,4 +64,6 @@ int main()
                printf("%ld.%06ld: %6d %6d %6d\n", samp.tv.tv_sec, samp.tv.tv_usec, samp.x, samp.y, samp.pressure);
 
        }
+       free(tset);
+       return 0;
 }
index 9c103f2..c302cd2 100644 (file)
@@ -12,7 +12,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <sys/time.h>
@@ -25,8 +25,13 @@ int main()
        struct tsdev *ts;
        char *tsdevice=NULL;
 
+       struct tssetting *tset;
+       tset = ts_setting(TS_ENV);
+
        if( (tsdevice = getenv("TSLIB_TSDEVICE")) != NULL ) {
                ts = ts_open(tsdevice,0);
+       } else if (tset != NULL) {
+               ts = ts_open(tset->tsdev, 0);
        } else {
                if (!(ts = ts_open("/dev/input/event0", 0)))
                        ts = ts_open("/dev/touchscreen/ucb1x00", 0);
@@ -59,4 +64,6 @@ int main()
                printf("%ld.%06ld: %6d %6d %6d\n", samp.tv.tv_sec, samp.tv.tv_usec, samp.x, samp.y, samp.pressure);
 
        }
+       free(tset);
+       return 0;
 }
index 02aa216..6d8f2d3 100644 (file)
@@ -15,7 +15,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <signal.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <sys/time.h>
@@ -115,12 +115,17 @@ int main()
 
        char *tsdevice=NULL;
 
+       struct tssetting *tset;
+       tset = ts_setting(TS_ENV);
+
        signal(SIGSEGV, sig);
        signal(SIGINT, sig);
        signal(SIGTERM, sig);
 
        if( (tsdevice = getenv("TSLIB_TSDEVICE")) != NULL ) {
                ts = ts_open(tsdevice,0);
+       } else if (tset != NULL) {
+               ts = ts_open(tset->tsdev, 0);
        } else {
                if (!(ts = ts_open("/dev/input/event0", 0)))
                        ts = ts_open("/dev/touchscreen/ucb1x00", 0);
@@ -213,5 +218,7 @@ int main()
                if (quit_pressed)
                        break;
        }
+       free(tset);
        close_framebuffer();
+       return 0;
 }
diff --git a/tslib.mk b/tslib.mk
new file mode 100644 (file)
index 0000000..78ac80a
--- /dev/null
+++ b/tslib.mk
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 2011 The Android-x86 Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+
+# for touchscreen calibration
+PRODUCT_PACKAGES := \
+    ts_calibrate \
+
+# plugins
+PRODUCT_PACKAGES += \
+    arctic2 \
+    collie \
+    corgi \
+    dejitter \
+    h3600 \
+    input-raw \
+    linear \
+    linear-h2200 \
+    mk712 \
+    pthres \
+    tatung \
+    touchkit \
+    ucb1x00 \
+    variance