./0000775000175000017500000000000012620061116011430 5ustar nielsenrnielsenr./add-group.patch0000664000175000017500000001345712511411357014352 0ustar nielsenrnielsenr--- /dev/null 2014-10-30 07:36:30.757065999 +0100 +++ b/plugins/group.c 2014-10-29 14:53:41.000000000 +0100 @@ -0,0 +1,268 @@ +/* + * tslib/plugins/group.c + * + * Copyright (C) 2011 Laurent Verstraeten. + * + * This file is placed under the LGPL. Please see the file + * COPYING for more details. + * + * Problem: + * + * Solution: + */ +#include +#include +#include +#include +#include + +#include "tslib.h" +#include "tslib-filter.h" + +#define DEBUG + + +/** + * This filter works as follows: + * + */ + + + + +struct tslib_group { + struct tslib_module_info module; + int radius; + int nbpoints; + int threshold; + //int x; + //int y; + int down; + int nr; + int head; + struct ts_sample last; + struct ts_sample *hist; //[NR_SAMPHISTLEN]; +}; + +static int sqr (int x) +{ + return x * x; +} + +/* return distance between 2 points */ +static int dist(struct ts_sample p1, struct ts_sample p2) +{ + return (sqr(p2.x - p1.x) + sqr(p2.y - p1.y)); +} + + +/* return the number of points from our history contained inside a circle of position c, radius grp->radius) */ +static int nbPointsInCircle(struct tslib_group *grp, struct ts_sample c) +{ + int count = 0; + int i; + + for (i=0; i < grp->nbpoints; i++) { + if (dist(grp->hist[i], c) <= grp->radius) count++; + } + return count; +} + + +static int findBestPoint(struct tslib_group *grp, struct ts_sample *best) +{ + int i; + int m, max; + + for (i=0; i < grp->nbpoints; i++) { + m = nbPointsInCircle(grp, grp->hist[i]); + + if (m > max) { + max = m; + *best = grp->hist[i]; + //best->x = grp->hist[i].x; + //best->y = grp->hist[i].y; + //best->pressure = grp->hist[i].p; + } + } + + //fprintf (stderr, "GROUP: max (%d) at (%d,%d)\n", max, best->x, best->y); + + if (max >= grp->threshold) return 1; else return 0; +} + + + + +static int group_read(struct tslib_module_info *info, struct ts_sample *samp, int nr) +{ + struct tslib_group *grp = (struct tslib_group *)info; + struct ts_sample *s; + struct ts_sample best; + int count = 0, ret; + + ret = info->next->ops->read(info->next, samp, nr); + /* Process each samples received from lower level */ + for (s = samp; ret > 0; s++, ret--) { + if (s->pressure == 0) { + if (grp->down==1) { + /* + * Pen was released. Reset the state and + * forget all history events. + */ + grp->nr = 0; + + /*use the last valid position for this sample */ + samp [count] = grp->last; + samp [count].pressure=0; + samp [count].tv = s->tv; + count++; + grp->down=0; + } + //fprintf(stderr, "GROUP: no pressure\n"); + continue; + } +// +// /* If the pen moves too fast, reset the backlog. */ +// if (grp->nr) { +// int prev = (grp->head - 1) & (NR_SAMPHISTLEN - 1); +// if (sqr (s->x - grp->hist [prev].x) + +// sqr (s->y - grp->hist [prev].y) > grp->delta) { +//#ifdef DEBUG +// fprintf (stderr, "DEJITTER: pen movement exceeds threshold\n"); +//#endif +// grp->nr = 0; +// } +// } + + + + /* add the new sample to our history */ + grp->hist[grp->head] = *s; + //grp->hist[grp->head].x = s->x; + //grp->hist[grp->head].y = s->y; + //grp->hist[grp->head].p = s->pressure; + + /* move history pointer +1 */ + grp->head = (grp->head + 1); + if (grp->head >= grp->nbpoints) grp->head=0; // & (NR_SAMPHISTLEN - 1); + + /* wait till we have enough sample to compute a group circle */ + if (grp->nr < grp->nbpoints) { + grp->nr++; + //fprintf (stderr, "GROUP: not enough sample (%d)\n", grp->nr); + continue; + } + + /* if a best point is found, pass it to upper layer */ + if (findBestPoint(grp, &best)) { + samp[count] = best; + samp[count].tv = s->tv; + grp->last = best; + //fprintf(stderr, " tv : %ld.%06ld \n", s->tv.tv_sec, s->tv.tv_usec); + count++; + grp->down=1; + } else if (grp->down==1) { + samp[count] = grp->last; + samp[count].tv = s->tv; + count++; + } + } + + return count; +} + +static int group_fini(struct tslib_module_info *info) +{ + struct tslib_group *grp = (struct tslib_group *)info; + + if (grp->hist) + free(grp->hist); + free(info); + return 0; +} + +static const struct tslib_ops group_ops = +{ + .read = group_read, + .fini = group_fini, +}; + +static int group_limit(struct tslib_module_info *inf, char *str, void *data) +{ + struct tslib_group *grp = (struct tslib_group *)inf; + unsigned long v; + int err = errno; + + v = strtoul(str, NULL, 0); + + if (v == ULONG_MAX && errno == ERANGE) + return -1; + + errno = err; + switch ((int)data) { + case 1: + printf("radius is now %d\n",v); + grp->radius = v; + break; + case 2: + printf("nbpoints is now %d\n",v); + grp->nbpoints = v; + break; + case 3: + printf("threshold is now %d\n",v); + grp->threshold = v; + break; + + default: + return -1; + } + return 0; +} + +static const struct tslib_vars group_vars[] = +{ + { "radius", (void *)1, group_limit }, + { "nbpoints", (void *)2, group_limit }, + { "threshold", (void *)3, group_limit }, +}; + +#define NR_VARS (sizeof(group_vars) / sizeof(group_vars[0])) + +TSAPI struct tslib_module_info *group_mod_init(struct tsdev *dev, const char *params) +{ + struct tslib_group *grp; + + grp = malloc(sizeof(struct tslib_group)); + if (grp == NULL) + return NULL; + + memset(grp, 0, sizeof(struct tslib_group)); + grp->module.ops = &group_ops; + + grp->radius = 10; + grp->nbpoints = 16; + grp->threshold = 8; + grp->head = 0; + grp->hist=NULL; + grp->down=0; /*pen up at start */ + + if (tslib_parse_vars(&grp->module, group_vars, NR_VARS, params)) { + free(grp); + return NULL; + } + + + if (!(grp->hist = malloc(sizeof(struct ts_sample) * grp->nbpoints))) { + free(grp); + return NULL; + } + + grp->radius = sqr (grp->radius); + + return &grp->module; +} + +#ifndef TSLIB_STATIC_GROUP_MODULE + TSLIB_MODULE_INIT(group_mod_init); +#endif + ./makefile.am-plugins.patch0000664000175000017500000000123012511411357016302 0ustar nielsenrnielsenr--- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -9,7 +9,7 @@ # AM_CFLAGS = -DTS_POINTERCAL=\"@TS_POINTERCAL@\" $(DEBUGFLAGS) $(LIBFLAGS) $(VIS_CFLAGS) -LDADD = -rpath $(PLUGIN_DIR) +LDADD = -rpath $(PLUGIN_DIR) INCLUDES = -I$(top_srcdir)/src #LTVSN = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ @@ -24,7 +24,7 @@ LINEAR_MODULE = endif -if ENABLE_LINEAR_MODULE +if ENABLE_DEJITTER_MODULE DEJITTER_MODULE = dejitter.la else DEJITTER_MODULE = @@ -165,6 +165,7 @@ skip_la_SOURCES = skip.c skip_la_LDFLAGS = -module $(LTVSN) +skip_la_LIBADD = $(top_builddir)/src/libts.la # hw access corgi_la_SOURCES = corgi-raw.c ./makefile.am-src.patch0000664000175000017500000000047112511411357015416 0ustar nielsenrnielsenr--- a/src/Makefile.am +++ b/src/Makefile.am @@ -63,6 +63,10 @@ libts_la_SOURCES += $(top_srcdir)/plugins/arctic2-raw.c endif +if ENABLE_STATIC_SKIP_MODULE +libts_la_SOURCES += $(top_srcdir)/plugins/skip.c +endif + if ENABLE_STATIC_TATUNG_MODULE libts_la_SOURCES += $(top_srcdir)/plugins/tatung-raw.c endif ./tslib.sh0000664000175000017500000000017512511411357013111 0ustar nielsenrnielsenr#!/bin/sh if [ -e /dev/input/touchscreen0 ]; then TSLIB_TSDEVICE=/dev/input/touchscreen0 export TSLIB_TSDEVICE fi ./add-group-to-ts_load_module.patch0000664000175000017500000000045112511411357017750 0ustar nielsenrnielsenr--- a/src/ts_load_module.c +++ b/src/ts_load_module.c @@ -44,6 +44,9 @@ #endif #ifdef TSLIB_STATIC_SKIP_MODULE { "skip", skip_mod_init }, +#endif +#ifdef TSLIB_STATIC_GROUP_MODULE + { "group", group_mod_init }, #endif #ifdef TSLIB_STATIC_DEJITTER_MODULE { "dejitter", dejitter_mod_init }, ./add-skip-to-makefile.patch0000664000175000017500000000130212511411357016341 0ustar nielsenrnielsenr--- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -42,6 +42,12 @@ PTHRES_MODULE = endif +if ENABLE_SKIP_MODULE +SKIP_MODULE = skip.la +else +SKIP_MODULE = +endif + if ENABLE_UCB1X00_MODULE UCB1X00_MODULE = ucb1x00.la else @@ -126,6 +132,7 @@ $(DEJITTER_MODULE) \ $(VARIANCE_MODULE) \ $(PTHRES_MODULE) \ + $(SKIP_MODULE) \ $(UCB1X00_MODULE) \ $(CORGI_MODULE) \ $(COLLIE_MODULE) \ @@ -156,6 +163,9 @@ pthres_la_LDFLAGS = -module $(LTVSN) pthres_la_LIBADD = $(top_builddir)/src/libts.la +skip_la_SOURCES = skip.c +skip_la_LDFLAGS = -module $(LTVSN) +skip_la_LIBADD = $(top_builddir)/src/libts.la # hw access corgi_la_SOURCES = corgi-raw.c corgi_la_LDFLAGS = -module $(LTVSN) ./ts_load_module.patch0000664000175000017500000000073112511411357015451 0ustar nielsenrnielsenr--- a/src/ts_load_module.c +++ b/src/ts_load_module.c @@ -23,6 +23,8 @@ #include "../plugins/plugins.h" +#define DEBUG + static const struct { const char *name; tslib_module_init mod_init; @@ -39,6 +41,9 @@ #endif #ifdef TSLIB_CY8MRLN_PALMPRE_MODULE { "cy8mrln_palmpre", cy8mrln_palmpre_mod_init }, +#endif +#ifdef TSLIB_STATIC_SKIP_MODULE + { "skip", skip_mod_init }, #endif #ifdef TSLIB_STATIC_DEJITTER_MODULE { "dejitter", dejitter_mod_init }, ./skip.patch0000664000175000017500000001010512511411357013421 0ustar nielsenrnielsenr--- /dev/null 2014-10-30 07:36:30.757065999 +0100 +++ b/plugins/skip.c 2014-10-29 14:53:41.000000000 +0100 @@ -0,0 +1,213 @@ +/* + * tslib/plugins/skip.c + * + * (C) 2008 by Openmoko, Inc. + * Author: Nelson Castillo <[hidden email]> + * + * This file is placed under the LGPL. Please see the file + * COPYING for more details. + * + * $Id$ + * + * Skip filter for touchscreen values. + * + * Problem: With some drivers the first and the last sample is unreliable. + * + * Solution: + * + * - Skip N points after pressure != 0 + * - Skip M points before pressure == 0 + * - Ignore a click if it has less than N + M + 1 points + * + * Parameters: + * + * - nhead (means N) + * - ntail (means M) + * + */ + +#include +#include +#include +#include +#include + +#include "config.h" +#include "tslib.h" +#include "tslib-filter.h" + +struct tslib_skip { + struct tslib_module_info module; + + int nhead; + int N; + + int ntail; + int M; + struct ts_sample *buf; + int sent; +}; + +static void reset_skip(struct tslib_skip *s) +{ + s->N = 0; + s->M = 0; + s->sent = 0; +} + +static int skip_read(struct tslib_module_info *info, struct ts_sample *samp, + int nr) +{ + struct tslib_skip *skip = (struct tslib_skip *)info; + int nread = 0; + + while (nread < nr) { + struct ts_sample cur; + + if (info->next->ops->read(info->next, &cur, 1) < 1) + return nread; + + /* skip the first N samples */ + if (skip->N < skip->nhead) { + skip->N++; + if (cur.pressure == 0) + reset_skip(skip); + continue; + } + + /* We didn't send DOWN -- Ignore UP */ + if (cur.pressure == 0 && skip->sent == 0) { + reset_skip(skip); + continue; + } + + /* Just accept the sample if ntail is zero */ + if (skip->ntail == 0) { + samp[nread++] = cur; + skip->sent = 1; + if (cur.pressure == 0) + reset_skip(skip); + continue; + } + + /* ntail > 0, Queue current point if we need to */ + if (skip->sent == 0 && skip->M < skip->ntail) { + skip->buf[skip->M++] = cur; + continue; + } + + /* queue full, accept one, queue one */ + + if (skip->M >= skip->ntail) + skip->M = 0; + + if (cur.pressure == 0) + skip->buf[skip->M].pressure = 0; + + samp[nread++] = skip->buf[skip->M]; + +#ifdef DEBUG + fprintf(stderr, "skip---> (X:%d Y:%d) pressure:%d\n", + skip->buf[skip->M].x, skip->buf[skip->M].y, + skip->buf[skip->M].pressure); +#endif + + if (cur.pressure == 0) { + reset_skip(skip); + } else { + skip->buf[skip->M++] = cur; + skip->sent = 1; + } + } + + return nread; +} + +static int skip_fini(struct tslib_module_info *info) +{ + struct tslib_skip *skip = (struct tslib_skip *)info; + + if (skip->buf) + free(skip->buf); + + free(info); + + return 0; +} + +static const struct tslib_ops skip_ops = +{ + .read = skip_read, + .fini = skip_fini, +}; + +static int skip_opt(struct tslib_module_info *inf, char *str, void *data) +{ + struct tslib_skip *skip = (struct tslib_skip *)inf; + unsigned long v; + int err = errno; + + v = strtoul(str, NULL, 0); + + if (v == ULONG_MAX && errno == ERANGE) + return -1; + + errno = err; + + switch ((int)data) { + case 1: + skip->nhead = v; + break; + + case 2: + skip->ntail = v; + break; + + default: + return -1; + } + return 0; +} + +static const struct tslib_vars skip_vars[] = +{ + { "nhead", (void *)1, skip_opt }, + { "ntail", (void *)2, skip_opt }, +}; + +#define NR_VARS (sizeof(skip_vars) / sizeof(skip_vars[0])) + +TSAPI struct tslib_module_info *skip_mod_init(struct tsdev *dev, const char *params) +{ + struct tslib_skip *skip; + + skip = malloc(sizeof(struct tslib_skip)); + if (skip == NULL) + return NULL; + + memset(skip, 0, sizeof(struct tslib_skip)); + skip->module.ops = &skip_ops; + + skip->nhead = 1; /* by default remove the first */ + skip->ntail = 1; /* by default remove the last */ + skip->buf = NULL; + + reset_skip(skip); + + if (tslib_parse_vars(&skip->module, skip_vars, NR_VARS, params)) { + free(skip); + return NULL; + } + + if (skip->ntail && + !(skip->buf = malloc(sizeof(struct ts_sample) * skip->ntail))) { + free(skip); + return NULL; + } + + return &skip->module; +} + +#ifndef TSLIB_STATIC_SKIP_MODULE + TSLIB_MODULE_INIT(skip_mod_init); +#endif + ./add-skip-to-configfile.patch0000664000175000017500000000076412511411357016704 0ustar nielsenrnielsenr--- a/configure.ac +++ b/configure.ac @@ -55,6 +55,7 @@ TSLIB_CHECK_MODULE([linear-h2200], [yes], [Enable building of linearizing filter for iPAQ h2200]) TSLIB_CHECK_MODULE([variance], [yes], [Enable building of variance filter]) TSLIB_CHECK_MODULE([pthres], [yes], [Enable building of pthres filter]) +TSLIB_CHECK_MODULE([skip], [yes], [Enable building of skip filter]) # hardware access modules TSLIB_CHECK_MODULE([ucb1x00], [yes], [Enable building of ucb1x00 raw module (UCB1x00 support)]) ./add-group-to-configfile.patch0000664000175000017500000000073012511411357017063 0ustar nielsenrnielsenr--- a/configure.ac +++ b/configure.ac @@ -56,6 +56,7 @@ TSLIB_CHECK_MODULE([variance], [yes], [Enable building of variance filter]) TSLIB_CHECK_MODULE([pthres], [yes], [Enable building of pthres filter]) TSLIB_CHECK_MODULE([skip], [yes], [Enable building of skip filter]) +TSLIB_CHECK_MODULE([groug], [yes], [Enable building of group filter]) # hardware access modules TSLIB_CHECK_MODULE([ucb1x00], [yes], [Enable building of ucb1x00 raw module (UCB1x00 support)]) ./add-group-to-makefile.patch0000664000175000017500000000133212511411357016532 0ustar nielsenrnielsenr--- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -46,6 +46,12 @@ SKIP_MODULE = skip.la else SKIP_MODULE = +endif + +if ENABLE_LINEAR_MODULE +GROUP_MODULE = group.la +else +GROUP_MODULE = endif if ENABLE_UCB1X00_MODULE @@ -133,6 +139,7 @@ $(VARIANCE_MODULE) \ $(PTHRES_MODULE) \ $(SKIP_MODULE) \ + $(GROUP_MODULE) \ $(UCB1X00_MODULE) \ $(CORGI_MODULE) \ $(COLLIE_MODULE) \ @@ -166,6 +173,10 @@ skip_la_SOURCES = skip.c skip_la_LDFLAGS = -module $(LTVSN) skip_la_LIBADD = $(top_builddir)/src/libts.la + +group_la_SOURCES = group.c +group_la_LDFLAGS = -module $(LTVSN) +group_la_LIBADD = $(top_builddir)/src/libts.la # hw access corgi_la_SOURCES = corgi-raw.c corgi_la_LDFLAGS = -module $(LTVSN) ./ts.conf0000664000175000017500000000132412620061116012725 0ustar nielsenrnielsenr# Uncomment if you wish to use the linux input layer event interface module_raw input # Uncomment if you're using a Sharp Zaurus SL-5500/SL-5000d # module_raw collie # Uncomment if you're using a Sharp Zaurus SL-C700/C750/C760/C860 # module_raw corgi # Uncomment if you're using a device with a UCB1200/1300/1400 TS interface # module_raw ucb1x00 # Uncomment if you're using an HP iPaq h3600 or similar # module_raw h3600 # Uncomment if you're using a Hitachi Webpad # module_raw mk712 # Uncomment if you're using an IBM Arctic II # module_raw arctic2 module pthres pmin=150 #module group radius=10 nbpoints=16 threshold=12 module skip nhead=2 ntail=2 module variance delta=30 module dejitter delta=100 module linear ./add-group-to-headerfile.patch0000664000175000017500000000037312511411357017051 0ustar nielsenrnielsenr--- a/plugins/plugins.h +++ b/plugins/plugins.h @@ -7,6 +7,7 @@ TSLIB_DECLARE_MODULE(variance); TSLIB_DECLARE_MODULE(pthres); TSLIB_DECLARE_MODULE(skip); +TSLIB_DECLARE_MODULE(group); TSLIB_DECLARE_MODULE(ucb1x00); TSLIB_DECLARE_MODULE(corgi); ./add-skip-to-headerfile.patch0000664000175000017500000000040212511411357016654 0ustar nielsenrnielsenr--- a/plugins/plugins.h +++ b/plugins/plugins.h @@ -6,6 +6,7 @@ TSLIB_DECLARE_MODULE(linear_h2200); TSLIB_DECLARE_MODULE(variance); TSLIB_DECLARE_MODULE(pthres); +TSLIB_DECLARE_MODULE(skip); TSLIB_DECLARE_MODULE(ucb1x00); TSLIB_DECLARE_MODULE(corgi); ./add-group-to-makefile.am-src.patch0000664000175000017500000000046312511411357017717 0ustar nielsenrnielsenr--- a/src/Makefile.am +++ b/src/Makefile.am @@ -67,6 +67,10 @@ libts_la_SOURCES += $(top_srcdir)/plugins/skip.c endif +if ENABLE_STATIC_SKIP_MODULE +libts_la_SOURCES += $(top_srcdir)/plugins/group.c +endif + if ENABLE_STATIC_TATUNG_MODULE libts_la_SOURCES += $(top_srcdir)/plugins/tatung-raw.c endif