OSDN Git Service

Add tatung webpad raw module, courtesy Nicolas FR.
authorChris Larson <clarson@kergoth.com>
Wed, 11 Jul 2007 19:32:58 +0000 (19:32 +0000)
committerChris Larson <clarson@kergoth.com>
Wed, 11 Jul 2007 19:32:58 +0000 (19:32 +0000)
configure.ac
plugins/Makefile.am
plugins/tatung-raw.c [new file with mode: 0644]

index de38caf..402c74b 100644 (file)
@@ -154,6 +154,15 @@ AC_ARG_ENABLE(arctic2,
 AC_MSG_RESULT($arctic2_module)
 AM_CONDITIONAL(ENABLE_ARCTIC2_MODULE, test "$arctic2_module" = "yes")
 
+AC_MSG_CHECKING([whether tatung module is requested])
+AC_ARG_ENABLE(tatung,
+        AS_HELP_STRING([--enable-tatung],
+                [Enable building of tatung raw module (Tatung Webpad support) (default=yes)]),
+        [tatung_module=$enableval],
+        [tatung_module=yes])
+AC_MSG_RESULT($tatung_module)
+AM_CONDITIONAL(ENABLE_TATUNG_MODULE, test "$tatung_module" = "yes")
+
 AC_MSG_CHECKING([whether input module is requested])
 AC_ARG_ENABLE(input,
         AS_HELP_STRING([--enable-input],
index c54a690..3b902c2 100644 (file)
@@ -79,6 +79,12 @@ else
 ARCTIC2_MODULE =
 endif
 
+if ENABLE_TATUNG_MODULE
+TATUNG_MODULE = tatung.la
+else
+TATUNG_MODULE =
+endif
+
 if ENABLE_INPUT_MODULE
 INPUT_MODULE = input.la
 else
@@ -102,6 +108,7 @@ pluginexec_LTLIBRARIES = \
        $(H3600_MODULE) \
        $(MK712_MODULE) \
        $(ARCTIC2_MODULE) \
+       $(TATUNG_MODULE) \
        $(H2200_LINEAR_MODULE) \
        $(INPUT_MODULE)
   
@@ -136,6 +143,9 @@ mk712_la_LDFLAGS    = -module $(LTVSN)
 arctic2_la_SOURCES     = arctic2-raw.c
 arctic2_la_LDFLAGS     = -module $(LTVSN)
 
+tatung_la_SOURCES      = tatung-raw.c
+tatung_la_LDFLAGS      = -module $(LTVSN)
+
 input_la_SOURCES       = input-raw.c
 input_la_LDFLAGS       = -module $(LTVSN)
 
diff --git a/plugins/tatung-raw.c b/plugins/tatung-raw.c
new file mode 100644 (file)
index 0000000..26fae27
--- /dev/null
@@ -0,0 +1,70 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "tslib-private.h"
+
+struct tatung_ts_event { /* Tatung touchscreen 4bytes protocol */
+       unsigned char x1;
+       unsigned char x2;
+       unsigned char y1;
+       unsigned char y2;
+};
+
+static int tatung_read(struct tslib_module_info *inf, struct ts_sample *samp, int nr)
+{
+       struct tsdev *ts = inf->dev;
+       struct tatung_ts_event *tatung_evt;
+       int ret;
+       int total = 0;
+       tatung_evt = alloca(sizeof(*tatung_evt) * nr);
+       ret = read(ts->fd, tatung_evt, sizeof(*tatung_evt) * nr);
+       if(ret > 0) {
+               int nr = ret / sizeof(*tatung_evt);
+               while(ret >= (int)sizeof(*tatung_evt)) {
+
+                       if (tatung_evt->x1==240 || tatung_evt->x2==240 || tatung_evt->y1==240 || tatung_evt->y2==240)
+                       {
+                               ret = nr;
+                               return ret;
+                       }
+
+                       samp->x = (tatung_evt->x1)*31 + (tatung_evt->x2)-64;
+                       samp->y = (tatung_evt->y1)*31 + (tatung_evt->y2)-192;
+                       samp->pressure=1;
+                       //samp->pressure = tatung_evt->pressure;
+
+#ifdef DEBUG
+        fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
+#endif /*DEBUG*/
+                       gettimeofday(&samp->tv,NULL);
+                       samp++;
+                       tatung_evt++;
+                       ret -= sizeof(*tatung_evt);
+               }
+       } else {
+               return -1;
+       }
+
+       samp->pressure=0;
+       ret = nr;
+       return ret;
+}
+
+static const struct tslib_ops tatung_ops =
+{
+       .read   = tatung_read,
+};
+
+TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
+{
+       struct tslib_module_info *m;
+
+       m = malloc(sizeof(struct tslib_module_info));
+       if (m == NULL)
+               return NULL;
+
+       m->ops = &tatung_ops;
+       return m;
+}