summaryrefslogtreecommitdiffstats
path: root/meta/recipes-graphics/tslib/tslib/multievent.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-graphics/tslib/tslib/multievent.patch')
-rw-r--r--meta/recipes-graphics/tslib/tslib/multievent.patch845
1 files changed, 0 insertions, 845 deletions
diff --git a/meta/recipes-graphics/tslib/tslib/multievent.patch b/meta/recipes-graphics/tslib/tslib/multievent.patch
deleted file mode 100644
index e6803f5a87..0000000000
--- a/meta/recipes-graphics/tslib/tslib/multievent.patch
+++ /dev/null
@@ -1,845 +0,0 @@
1Upstream-Status: Pending
2
3--- tslib/plugins/linear.c~multievent
4+++ tslib/plugins/linear.c
5@@ -39,14 +39,12 @@
6 linear_read(struct tslib_module_info *info, struct ts_sample *samp, int nr)
7 {
8 struct tslib_linear *lin = (struct tslib_linear *)info;
9- int ret;
10+ int ret, i = 0;
11 int xtemp,ytemp;
12
13 ret = info->next->ops->read(info->next, samp, nr);
14 if (ret >= 0) {
15- int nr;
16-
17- for (nr = 0; nr < ret; nr++, samp++) {
18+ for (i = 0; i < ret; i++, samp++) {
19 #ifdef DEBUG
20 fprintf(stderr,"BEFORE CALIB--------------------> %d %d %d\n",samp->x, samp->y, samp->pressure);
21 #endif /*DEBUG*/
22@@ -66,6 +64,7 @@
23 samp->y = tmp;
24 }
25 }
26+ ret = i;
27 }
28
29 return ret;
30--- tslib/plugins/dejitter.c~multievent
31+++ tslib/plugins/dejitter.c
32@@ -24,7 +24,6 @@
33
34 struct tslib_threshold {
35 struct tslib_module_info module;
36- int pthreshold;
37 int xdelta;
38 int ydelta;
39 int delta2;
40@@ -36,40 +35,28 @@
41 static int threshold_read(struct tslib_module_info *info, struct ts_sample *samp, int nr)
42 {
43 struct tslib_threshold *thr = (struct tslib_threshold *)info;
44- struct ts_sample *s;
45- int ret;
46+ struct ts_sample *src = samp, *dest = samp;
47+ int ret, i = 0;
48
49 ret = info->next->ops->read(info->next, samp, nr);
50 if (ret >= 0) {
51- int nr = 0;
52-
53- for (s = samp; s < samp + ret; s++) {
54+ for (i = 0; i < ret; i++, samp++) {
55 int dr2;
56 #ifdef DEBUG
57- fprintf(stderr,"BEFORE DEJITTER---------------> %d %d %d\n",s->x,s->y,s->pressure);
58+ fprintf(stderr,"BEFORE DEJITTER---------------> %d %d %d\n", samp->x, samp->y, samp->pressure);
59 #endif /*DEBUG*/
60- thr->down = (s->pressure >= thr->pthreshold);
61- if (thr->down) {
62- dr2 = (thr->x - s->x)*(thr->x - s->x)
63- + (thr->y - s->y)*(thr->y - s->y);
64- if(dr2 < thr->delta2) {
65- s->x = thr->x;
66- s->y = thr->y;
67- } else {
68- thr->x = s->x;
69- thr->y = s->y;
70- }
71-
72+ dr2 = (thr->x - samp->x)*(thr->x - samp->x)
73+ + (thr->y - samp->y)*(thr->y - samp->y);
74+ if(dr2 < thr->delta2) {
75+ samp->x = thr->x;
76+ samp->y = thr->y;
77 } else {
78- s->x = thr->x;
79- s->y = thr->y;
80+ thr->x = samp->x;
81+ thr->y = samp->y;
82 }
83-
84-
85- samp[nr++] = *s;
86 }
87
88- ret = nr;
89+ ret = i;
90 }
91 return ret;
92 }
93@@ -106,10 +93,6 @@
94 thr->ydelta = v;
95 break;
96
97- case 3:
98- thr->pthreshold = v;
99- break;
100-
101 default:
102 return -1;
103 }
104@@ -120,7 +103,6 @@
105 {
106 { "xdelta", (void *)1, threshold_limit },
107 { "ydelta", (void *)2, threshold_limit },
108- { "pthreshold", (void *)3, threshold_limit }
109 };
110
111 //#define NR_VARS (sizeof(threshold_vars) / sizeof(threshold_vars[0]))
112@@ -138,7 +120,6 @@
113
114 thr->xdelta = 10;
115 thr->ydelta = 10;
116- thr->pthreshold = 100;
117
118 if (tslib_parse_vars(&thr->module, threshold_vars, NR_VARS, params)) {
119 free(thr);
120--- tslib/plugins/variance.c~multievent
121+++ tslib/plugins/variance.c
122@@ -9,25 +9,36 @@
123 * $Id: variance.c,v 1.3 2002/11/08 23:28:55 dlowder Exp $
124 *
125 * Variance filter for touchscreen values
126+ *
127+ * Policy question (applies to all tslib modules that consume events):
128+ * 1) User requests a read of 5 events using nr.
129+ * 2) Lower layers return us 4 events.
130+ * 3) Perform variance calculation, we now only have _1_ event.
131+ * 4) Do we, a) duplicate this data across the user requested 4 events,
132+ * b) push up the single event
133+ * c) loop on the read from the lower layers to obtain
134+ * the user's requested number of events, unless we hit
135+ * a pen_up.
136 */
137+
138 #include <errno.h>
139 #include <stdlib.h>
140 #include <string.h>
141 #include <limits.h>
142-
143 #include <stdio.h>
144
145 #include "tslib.h"
146 #include "tslib-filter.h"
147
148+#define NR_INIT -1
149 #define NR_LAST 4
150
151 struct tslib_variance {
152 struct tslib_module_info module;
153 int nr;
154- unsigned int pthreshold;
155 unsigned int xlimit;
156 unsigned int ylimit;
157+ unsigned int pthreshold;
158 struct ts_sample last[NR_LAST];
159 };
160
161@@ -37,8 +48,7 @@
162 * least variance, and average them.
163 */
164 static int
165-variance_calculate(struct tslib_variance *var, struct ts_sample *samp,
166- struct ts_sample *s)
167+variance_calculate(struct tslib_variance *var, struct ts_sample *dest, struct ts_sample *src)
168 {
169 int i, j;
170 int diff_x, min_x, i_x, j_x;
171@@ -100,11 +110,11 @@
172 }
173 }
174
175- samp->x = (var->last[i_x].x + var->last[j_x].x) / 2;
176- samp->y = (var->last[i_y].y + var->last[j_y].y) / 2;
177- samp->pressure = (var->last[i_p].pressure + var->last[j_p].pressure) / 2;
178- samp->tv.tv_sec = s->tv.tv_sec;
179- samp->tv.tv_usec = s->tv.tv_usec;
180+ dest->x = (var->last[i_x].x + var->last[j_x].x) / 2;
181+ dest->y = (var->last[i_y].y + var->last[j_y].y) / 2;
182+ dest->pressure = (var->last[i_p].pressure + var->last[j_p].pressure) / 2;
183+ dest->tv.tv_sec = src->tv.tv_sec;
184+ dest->tv.tv_usec = src->tv.tv_usec;
185
186 return 1;
187 }
188@@ -112,55 +122,57 @@
189 static int variance_read(struct tslib_module_info *info, struct ts_sample *samp, int nr)
190 {
191 struct tslib_variance *var = (struct tslib_variance *)info;
192- struct ts_sample *s;
193- int ret;
194-
195- ret = info->next->ops->read(info->next, samp, nr);
196- if (ret >= 0) {
197- int nr = 0;
198-
199- for (s = samp; s < samp + ret; s++) {
200- if (s->pressure < var->pthreshold) {
201- /*
202- * Pen was released. Reset our state and
203- * pass up the release information.
204- */
205-// samp[nr].x = 0;
206-// samp[nr].y = 0;
207- samp[nr].pressure = s->pressure;
208- samp[nr].tv.tv_sec = s->tv.tv_sec;
209- samp[nr].tv.tv_usec = s->tv.tv_usec;
210-
211- nr++;
212-
213- var->nr = 0;
214- continue;
215- } else if (var->nr == -1) {
216- /*
217- * Pen was pressed. Inform upper layers
218- * immediately.
219- */
220- samp[nr] = *s;
221- nr++;
222- }
223-
224- if (var->nr >= 0) {
225- var->last[var->nr].x = s->x;
226- var->last[var->nr].y = s->y;
227- var->last[var->nr].pressure = s->pressure;
228- }
229-
230- var->nr++;
231+ struct ts_sample *src = samp, *dest = samp;
232+ int ret, i = 0;
233
234- if (var->nr == NR_LAST) {
235- if (variance_calculate(var, samp + nr, s))
236- nr++;
237- var->nr = 0;
238+ /*
239+ * NOTES:
240+ *
241+ * Loop on read, collecting events until we hit nr, unless
242+ * we hit a pen up or encounter a failure.
243+ */
244+ while ((i < nr) && (ret != -1)) {
245+ ret = info->next->ops->read(info->next, dest + i, nr - i);
246+ if (ret >= 0) {
247+ for (src = dest + i; src < dest + ret; src++) {
248+ if (src->pressure < var->pthreshold) {
249+ /* pen released, reset var->nr,
250+ * do a calc based on what we have so
251+ * far, and let this event flow up */
252+ if (variance_calculate(var, dest + i, src))
253+ i++;
254+ var->nr = NR_INIT;
255+ ret = -1; /* break outer loop, push up event */
256+ break;
257+ } else if (var->nr == NR_INIT) {
258+ /*
259+ * First pen down event. Inform upper layers
260+ * immediately for responsiveness.
261+ */
262+ var->nr = 0;
263+ i++;
264+ ret = -1; /* break outer loop */
265+ break;
266+ }
267+
268+ if (var->nr >= 0) {
269+ var->last[var->nr].x = src->x;
270+ var->last[var->nr].y = src->y;
271+ var->last[var->nr].pressure = src->pressure;
272+ }
273+
274+ var->nr++;
275+
276+ if (var->nr == NR_LAST) {
277+ if (variance_calculate(var, dest + i, src))
278+ i++;
279+ var->nr = 0;
280+ }
281 }
282 }
283-
284- ret = nr;
285 }
286+ /* if we've collected at least one event, send it up */
287+ if (i != 0) ret = i;
288 return ret;
289 }
290
291@@ -196,10 +208,6 @@
292 var->ylimit = v;
293 break;
294
295- case 3:
296- var->pthreshold = v;
297- break;
298-
299 default:
300 return -1;
301 }
302@@ -210,7 +218,6 @@
303 {
304 { "xlimit", (void *)1, variance_limit },
305 { "ylimit", (void *)2, variance_limit },
306- { "pthreshold", (void *)3, variance_limit }
307 };
308
309 #define NR_VARS (sizeof(variance_vars) / sizeof(variance_vars[0]))
310@@ -218,6 +225,7 @@
311 struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
312 {
313 struct tslib_variance *var;
314+ char *pthresvar;
315
316 var = malloc(sizeof(struct tslib_variance));
317 if (var == NULL)
318@@ -225,10 +233,15 @@
319
320 var->module.ops = &variance_ops;
321
322- var->nr = -1;
323+ var->nr = NR_INIT;
324 var->xlimit = 160;
325 var->ylimit = 160;
326 var->pthreshold = 100;
327+ pthresvar = getenv("TSLIB_PTHRES");
328+ if (pthresvar != NULL) {
329+ int p = strtol(pthresvar, (char **)NULL, 10);
330+ if (p != -1) var->pthreshold = p;
331+ }
332
333 if (tslib_parse_vars(&var->module, variance_vars, NR_VARS, params)) {
334 free(var);
335--- tslib/README~multievent
336+++ tslib/README
337@@ -36,6 +36,19 @@
338 usages. They are by no means exhaustive, nor probably even good examples.
339 They are basically the programs I used to test this library.
340
341+Module Creation Notes
342+=====================
343+
344+For those creating tslib modules, it is important to note a couple things with
345+regard to handling of the ability for a user to request more than one ts event
346+at a time. The first thing to note is that the lower layers may send up less
347+events than the user requested, but only if that was a result of a pen release.
348+Next, your module should send up just as many events as the user requested in
349+nr. If your module is one that consumes events, such as variance, then you
350+loop on the read from the lower layers, and only send the events up when
351+1) you have the number of events requested by the user, or 2) one of the events
352+from the lower layers was a pen release.
353+
354
355 Module Parameters
356 =================
357--- tslib/src/ts_read_raw.c~multievent
358+++ tslib/src/ts_read_raw.c
359@@ -14,10 +14,10 @@
360 *
361 * Read raw pressure, x, y, and timestamp from a touchscreen device.
362 */
363+
364 #include "config.h"
365
366 #include <stdio.h>
367-
368 #include <stdlib.h>
369 #ifdef HAVE_UNISTD_H
370 #include <unistd.h>
371@@ -25,79 +25,27 @@
372 #include <sys/time.h>
373 #include <sys/types.h>
374
375-#ifdef USE_INPUT_API
376-#include <linux/input.h>
377-#else
378-struct ts_event { /* Used in UCB1x00 style touchscreens (the default) */
379- unsigned short pressure;
380- unsigned short x;
381- unsigned short y;
382- unsigned short pad;
383- struct timeval stamp;
384-};
385-struct h3600_ts_event { /* Used in the Compaq IPAQ */
386- unsigned short pressure;
387- unsigned short x;
388- unsigned short y;
389- unsigned short pad;
390-};
391-struct mk712_ts_event { /* Used in the Hitachi Webpad */
392- unsigned int header;
393- unsigned int x;
394- unsigned int y;
395- unsigned int reserved;
396-};
397-struct arctic2_ts_event { /* Used in the IBM Arctic II */
398- signed short pressure;
399- signed int x;
400- signed int y;
401- int millisecs;
402- int flags;
403-};
404-struct collie_ts_event { /* Used in the Sharp Zaurus SL-5000d and SL-5500 */
405- long y;
406- long x;
407- long pressure;
408- long long millisecs;
409-};
410-struct corgi_ts_event { /* Used in the Sharp Zaurus SL-C700 */
411- short pressure;
412- short x;
413- short y;
414- short millisecs;
415-};
416-#endif /* USE_INPUT_API */
417-
418 #include "tslib-private.h"
419
420-int ts_read_raw(struct tsdev *ts, struct ts_sample *samp, int nr)
421-{
422 #ifdef USE_INPUT_API
423+#include <linux/input.h>
424+
425+static inline int get_input_event(struct tsdev *ts, struct ts_sample *samp) {
426 struct input_event ev;
427-#else
428- struct ts_event *evt;
429- struct h3600_ts_event *hevt;
430- struct mk712_ts_event *mevt;
431- struct arctic2_ts_event *aevt;
432- struct collie_ts_event *collie_evt;
433- struct corgi_ts_event *corgi_evt;
434-#endif /* USE_INPUT_API */
435- int ret;
436- int total = 0;
437+ struct timeval tv = {0, 0};
438+ fd_set fdset;
439+ int ret = 0;
440
441- char *tseventtype=NULL;
442- char *defaulttseventtype="UCB1x00";
443+ /* event vars */
444+ static int curr_x = 0, curr_y = 0;
445+ int curr_p = 0, next_x = 0, next_y = 0;
446
447-#ifdef USE_INPUT_API
448- /* warning: maybe those static vars should be part of the tsdev struct? */
449- static int curr_x = 0, curr_y = 0, curr_p = 0;
450- static int got_curr_x = 0, got_curr_y = 0;
451- int got_curr_p = 0;
452- int next_x, next_y;
453+ /* state variables */
454+ int got_curr_x = 0, got_curr_y = 0, got_curr_p = 0;
455 int got_next_x = 0, got_next_y = 0;
456 int got_tstamp = 0;
457
458- while (total < nr) {
459+ while (1) {
460 ret = read(ts->fd, &ev, sizeof(struct input_event));
461 if (ret < sizeof(struct input_event)) break;
462
463@@ -146,177 +94,231 @@
464 samp->tv = ev.time;
465 }
466
467- if ( (!got_curr_x || !got_curr_y) && !got_curr_p &&
468- !got_next_x && !got_next_y ) {
469- /*
470- * The current event is not complete yet.
471- * Give the kernel a chance to feed us more.
472- */
473- struct timeval tv = {0, 0};
474- fd_set fdset;
475- FD_ZERO(&fdset);
476- FD_SET(ts->fd, &fdset);
477- ret = select(ts->fd+1, &fdset, NULL, NULL, &tv);
478- if (ret == 1) continue;
479- if (ret == -1) break;
480+ if (got_curr_x && got_curr_y && got_curr_p) {
481+ /* we have a complete event */
482+ samp->x = curr_x;
483+ samp->y = curr_y;
484+ samp->pressure = curr_p;
485+ ret = 0; /* indicate success */
486+ if (got_next_x) curr_x = next_x;
487+ if (got_next_y) curr_y = next_y;
488+ break;
489 }
490
491- /* We consider having a complete ts event */
492- samp->x = curr_x;
493- samp->y = curr_y;
494- samp->pressure = curr_p;
495-#ifdef DEBUG
496- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
497-#endif /*DEBUG*/
498- samp++;
499- total++;
500-
501- /* get ready for next event */
502- if (got_next_x) curr_x = next_x; else got_curr_x = 0;
503- if (got_next_y) curr_y = next_y; else got_curr_y = 0;
504- got_next_x = got_next_y = got_tstamp = 0;
505+ /*
506+ * The current event is not complete yet.
507+ * Give the kernel a chance to feed us more.
508+ */
509+ FD_ZERO(&fdset);
510+ FD_SET(ts->fd, &fdset);
511+ ret = select(ts->fd+1, &fdset, NULL, NULL, &tv);
512+ if (ret == 1) continue;
513+ if (ret == -1) break;
514 }
515
516- if (ret) ret = -1;
517- if (total) ret = total;
518+// fprintf(stdout, "%s: returning %d\n", __FUNCTION__, ret);
519+ if (ret != 0) ret = -1;
520+ return ret;
521+}
522+
523 #else
524+
525+struct ucb1x00_ts_event { /* Used in UCB1x00 style touchscreens (the default) */
526+ unsigned short pressure;
527+ unsigned short x;
528+ unsigned short y;
529+ unsigned short pad;
530+ struct timeval stamp;
531+};
532+struct h3600_ts_event { /* Used in the Compaq IPAQ */
533+ unsigned short pressure;
534+ unsigned short x;
535+ unsigned short y;
536+ unsigned short pad;
537+};
538+struct mk712_ts_event { /* Used in the Hitachi Webpad */
539+ unsigned int header;
540+ unsigned int x;
541+ unsigned int y;
542+ unsigned int reserved;
543+};
544+struct arctic2_ts_event { /* Used in the IBM Arctic II */
545+ signed short pressure;
546+ signed int x;
547+ signed int y;
548+ int millisecs;
549+ int flags;
550+};
551+struct collie_ts_event { /* Used in the Sharp Zaurus SL-5000d and SL-5500 */
552+ long y;
553+ long x;
554+ long pressure;
555+ long long millisecs;
556+};
557+struct corgi_ts_event { /* Used in the Sharp Zaurus SL-C700 */
558+ short pressure;
559+ short x;
560+ short y;
561+ short millisecs;
562+};
563+
564+static inline int get_ucb1x00_event(struct tsdev *ts, struct ts_sample *samp) {
565+ struct ucb1x00_ts_event evt;
566+ int ret = read(ts->fd, &evt, sizeof(struct ucb1x00_ts_event));
567+ if (ret > 0) {
568+ samp->x = evt.x;
569+ samp->y = evt.y;
570+ samp->pressure = evt.pressure;
571+ samp->tv.tv_usec = evt.stamp.tv_usec;
572+ samp->tv.tv_sec = evt.stamp.tv_sec;
573+ ret = 0; /* success */
574+ }
575+ return ret;
576+}
577+
578+static inline int get_h3600_event(struct tsdev *ts, struct ts_sample *samp) {
579+ struct h3600_ts_event evt;
580+ int ret = read(ts->fd, &evt, sizeof(struct h3600_ts_event));
581+ if (ret > 0) {
582+ samp->x = evt.x;
583+ samp->y = evt.y;
584+ samp->pressure = evt.pressure;
585+ gettimeofday(&samp->tv, NULL);
586+ ret = 0; /* success */
587+ }
588+ return ret;
589+}
590+
591+static inline int get_mk712_event(struct tsdev *ts, struct ts_sample *samp) {
592+ struct mk712_ts_event evt;
593+ int ret = read(ts->fd, &evt, sizeof(struct mk712_ts_event));
594+ if (ret > 0) {
595+ samp->x = (short)evt.x;
596+ samp->y = (short)evt.y;
597+ if(evt.header==0)
598+ samp->pressure=1;
599+ else
600+ samp->pressure=0;
601+ gettimeofday(&samp->tv, NULL);
602+ ret = 0; /* success */
603+ }
604+ return ret;
605+}
606+
607+static inline int get_arctic2_event(struct tsdev *ts, struct ts_sample *samp) {
608+ struct arctic2_ts_event evt;
609+ int ret = read(ts->fd, &evt, sizeof(struct arctic2_ts_event));
610+ if (ret > 0) {
611+ samp->x = (short)evt.x;
612+ samp->y = (short)evt.y;
613+ samp->pressure = evt.pressure;
614+ gettimeofday(&samp->tv, NULL);
615+ ret = 0; /* success */
616+ }
617+ return ret;
618+}
619+
620+static inline int get_collie_event(struct tsdev *ts, struct ts_sample *samp) {
621+ struct collie_ts_event evt;
622+ int ret = read(ts->fd, &evt, sizeof(struct collie_ts_event));
623+ if (ret > 0) {
624+ samp->x = evt.x;
625+ samp->y = evt.y;
626+ samp->pressure = evt.pressure;
627+ samp->tv.tv_usec = evt.millisecs % 1000;
628+ samp->tv.tv_sec = evt.millisecs / 1000;
629+ ret = 0; /* success */
630+ }
631+ return ret;
632+}
633+
634+static inline int get_corgi_event(struct tsdev *ts, struct ts_sample *samp) {
635+ struct corgi_ts_event evt;
636+ int ret = read(ts->fd, &evt, sizeof(struct corgi_ts_event));
637+ if (ret > 0) {
638+ samp->x = evt.x;
639+ samp->y = evt.y;
640+ samp->pressure = evt.pressure;
641+ samp->tv.tv_usec = evt.millisecs % 1000;
642+ samp->tv.tv_sec = evt.millisecs / 1000;
643+ ret = 0; /* success */
644+ }
645+ return ret;
646+}
647+
648+#endif
649+
650+int ts_read_raw(struct tsdev *ts, struct ts_sample *samp, int nr)
651+{
652+ int ret;
653+ int total = 0;
654+ int pen_down = 1;
655+ static short x_save = 0, y_save = 0;
656+ static int pthres = -1;
657+
658+#ifndef USE_INPUT_API
659+ char *tseventtype=NULL;
660+ char *defaulttseventtype="UCB1x00";
661 tseventtype = getenv("TSLIB_TSEVENTTYPE");
662 if(tseventtype==NULL) tseventtype=defaulttseventtype;
663+#endif
664
665- if( strcmp(tseventtype,"H3600") == 0) { /* iPAQ style h3600 touchscreen events */
666- hevt = alloca(sizeof(*hevt) * nr);
667- ret = read(ts->fd, hevt, sizeof(*hevt) * nr);
668- if(ret > 0) {
669- int nr = ret / sizeof(*hevt);
670- while(ret >= sizeof(*hevt)) {
671- samp->x = hevt->x;
672- samp->y = hevt->y;
673- samp->pressure = hevt->pressure;
674-#ifdef DEBUG
675- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
676-#endif /*DEBUG*/
677- gettimeofday(&samp->tv,NULL);
678- samp++;
679- hevt++;
680- ret -= sizeof(*hevt);
681- }
682- } else {
683- return -1;
684- }
685- } else if( strcmp(tseventtype,"MK712") == 0) { /* Hitachi Webpad events */
686- mevt = alloca(sizeof(*mevt) * nr);
687- ret = read(ts->fd, mevt, sizeof(*mevt) * nr);
688- if(ret > 0) {
689- int nr = ret / sizeof(*mevt);
690- while(ret >= sizeof(*mevt)) {
691- samp->x = (short)mevt->x;
692- samp->y = (short)mevt->y;
693- if(mevt->header==0)
694- samp->pressure=1;
695- else
696- samp->pressure=0;
697-#ifdef DEBUG
698- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
699-#endif /*DEBUG*/
700- gettimeofday(&samp->tv,NULL);
701- samp++;
702- mevt++;
703- ret -= sizeof(*mevt);
704- }
705- } else {
706- return -1;
707- }
708-
709- } else if( strcmp(tseventtype,"ARCTIC2") == 0) { /* IBM Arctic II events */
710- aevt = alloca(sizeof(*aevt) * nr);
711- ret = read(ts->fd, aevt, sizeof(*aevt) * nr);
712- if(ret > 0) {
713- int nr = ret / sizeof(*aevt);
714- while(ret >= sizeof(*aevt)) {
715- samp->x = (short)aevt->x;
716- samp->y = (short)aevt->y;
717- samp->pressure = aevt->pressure;
718-#ifdef DEBUG
719- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
720-#endif /*DEBUG*/
721- gettimeofday(&samp->tv,NULL);
722- samp++;
723- aevt++;
724- ret -= sizeof(*aevt);
725- }
726+ while ((total < nr) && pen_down) {
727+// fprintf(stdout, "total: %d, nr: %d\n", total, nr);
728+#ifdef USE_INPUT_API
729+ ret = get_input_event(ts, samp);
730+#else
731+ if (strcmp(tseventtype, "H3600") == 0) {
732+ /* iPAQ style h3600 touchscreen events */
733+ ret = get_h3600_event(ts, samp);
734+ } else if (strcmp(tseventtype, "MK712") == 0) {
735+ /* Hitachi Webpad events */
736+ ret = get_mk712_event(ts, samp);
737+ } else if (strcmp(tseventtype, "ARCTIC2") == 0) {
738+ /* IBM Arctic II events */
739+ ret = get_arctic2_event(ts, samp);
740+ } else if (strcmp(tseventtype, "COLLIE") == 0) {
741+ /* Sharp Zaurus SL-5000d/5500 events */
742+ ret = get_collie_event(ts, samp);
743+ } else if (strcmp(tseventtype,"CORGI") == 0) {
744+ /* Sharp Zaurus SL-C700 events */
745+ ret = get_corgi_event(ts, samp);
746 } else {
747- return -1;
748+ /* Use normal UCB1x00 type events */
749+ ret = get_ucb1x00_event(ts, samp);
750 }
751+#endif
752+ if (ret != 0) break;
753
754- } else if( strcmp(tseventtype,"COLLIE") == 0) { /* Sharp Zaurus SL-5000d/5500 events */
755- collie_evt = alloca(sizeof(*collie_evt) * nr);
756- ret = read(ts->fd, collie_evt, sizeof(*collie_evt) * nr);
757- if(ret > 0) {
758- int nr = ret / sizeof(*collie_evt);
759- while(ret >= sizeof(*collie_evt)) {
760- samp->x = collie_evt->x;
761- samp->y = collie_evt->y;
762- samp->pressure = collie_evt->pressure;
763-#ifdef DEBUG
764- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
765-#endif /*DEBUG*/
766- samp->tv.tv_usec = collie_evt->millisecs % 1000;
767- samp->tv.tv_sec = collie_evt->millisecs / 1000;
768- samp++;
769- collie_evt++;
770- ret -= sizeof(*collie_evt);
771+ if (pthres == -1) {
772+ char *pthresvar = getenv("TSLIB_PTHRES");
773+ pthres = 100;
774+ if (pthresvar != NULL) {
775+ int p = strtol(pthresvar, (char **)NULL, 10);
776+ if (p != -1) pthres = p;
777 }
778- } else {
779- return -1;
780 }
781
782- } else if( strcmp(tseventtype,"CORGI") == 0) { /* Sharp Zaurus SL-C700 events */
783- corgi_evt = alloca(sizeof(*corgi_evt) * nr);
784- ret = read(ts->fd, corgi_evt, sizeof(*corgi_evt) * nr);
785- if(ret > 0) {
786- int nr = ret / sizeof(*corgi_evt);
787- while(ret >= sizeof(*corgi_evt)) {
788- samp->x = corgi_evt->x;
789- samp->y = corgi_evt->y;
790- samp->pressure = corgi_evt->pressure;
791-#ifdef DEBUG
792- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
793-#endif /*DEBUG*/
794- samp->tv.tv_usec = corgi_evt->millisecs % 1000;
795- samp->tv.tv_sec = corgi_evt->millisecs / 1000;
796- samp++;
797- corgi_evt++;
798- ret -= sizeof(*corgi_evt);
799- }
800+ if (samp->pressure < pthres) {
801+ /* pen released, send events up */
802+ pen_down = 0;
803+ /* set x and y to previous values */
804+ samp->x = x_save;
805+ samp->y = y_save;
806 } else {
807- return -1;
808+ pen_down = 1;
809+ x_save = samp->x;
810+ y_save = samp->y;
811 }
812-
813- } else { /* Use normal UCB1x00 type events */
814- evt = alloca(sizeof(*evt) * nr);
815- ret = read(ts->fd, evt, sizeof(*evt) * nr);
816- if(ret > 0) {
817- int nr = ret / sizeof(*evt);
818- while(ret >= sizeof(*evt)) {
819- samp->x = evt->x;
820- samp->y = evt->y;
821- samp->pressure = evt->pressure;
822 #ifdef DEBUG
823- fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x,samp->y,samp->pressure);
824+ fprintf(stderr,"RAW---------------------------> %d %d %d\n",samp->x, samp->y, samp->pressure);
825 #endif /*DEBUG*/
826- samp->tv.tv_usec = evt->stamp.tv_usec;
827- samp->tv.tv_sec = evt->stamp.tv_sec;
828- samp++;
829- evt++;
830- ret -= sizeof(*evt);
831- }
832- } else {
833- return -1;
834- }
835+ samp++;
836+ total++;
837 }
838- ret = nr;
839-#endif /* USE_INPUT_API */
840
841+ if (ret != 0) ret = -1;
842+ if (total) ret = total;
843 return ret;
844 }
845