fix copy'n paste error
[buildroot.git] / package / tslib / tslib_add_finddef_and_inputattach_utils.patch
blobb1ab81b75cc1cbd2f61a71a69ccc5c9bb25daf3a
1 diff -Naur tslib-org/tests/Makefile.am tslib-1.0/tests/Makefile.am
2 --- tslib-org/tests/Makefile.am 2006-08-25 00:02:55.000000000 +0300
3 +++ tslib-1.0/tests/Makefile.am 2007-05-07 17:39:54.000000000 +0300
4 @@ -12,7 +12,7 @@
5 AM_CFLAGS = $(DEBUGFLAGS)
6 INCLUDES = -I$(top_srcdir)/src
8 -bin_PROGRAMS = ts_test ts_calibrate ts_print ts_print_raw ts_harvest
9 +bin_PROGRAMS = ts_test ts_calibrate ts_print ts_print_raw ts_harvest ts_finddev inputattach
11 ts_test_SOURCES = ts_test.c fbutils.c fbutils.h font_8x8.c font_8x16.c font.h
12 ts_test_LDADD = $(top_builddir)/src/libts.la
13 @@ -27,4 +27,10 @@
14 ts_calibrate_LDADD = $(top_builddir)/src/libts.la
16 ts_harvest_SOURCES = ts_harvest.c fbutils.c fbutils.h testutils.c testutils.h font_8x8.c font_8x16.c font.h
17 -ts_harvest_LDADD = $(top_builddir)/src/libts.la
18 +ts_harvest_LDADD = $(top_builddir)/src/libts.la
20 +ts_finddev_SOURCES = ts_finddev.c
21 +ts_finddev_LDADD = $(top_builddir)/src/libts.la
23 +inputattach_SOURCES = inputattach.c
24 +inputattach_LDADD =
25 diff -Naur tslib-org/tests/inputattach.c tslib-1.0/tests/inputattach.c
26 --- tslib-org/tests/inputattach.c 1970-01-01 02:00:00.000000000 +0200
27 +++ tslib-1.0/tests/inputattach.c 2007-05-07 17:36:37.000000000 +0300
28 @@ -0,0 +1,611 @@
29 +/*
30 + * $Id: inputattach.c,v 1.24 2006/02/08 12:19:31 vojtech Exp $
31 + *
32 + * Copyright (c) 1999-2000 Vojtech Pavlik
33 + *
34 + * Sponsored by SuSE
35 + *
36 + * Twiddler support Copyright (c) 2001 Arndt Schoenewald
37 + * Sponsored by Quelltext AG (http://www.quelltext-ag.de), Dortmund, Germany
38 + */
40 +/*
41 + * Input line discipline attach program
42 + */
44 +/*
45 + * This program is free software; you can redistribute it and/or modify
46 + * it under the terms of the GNU General Public License as published by
47 + * the Free Software Foundation; either version 2 of the License, or
48 + * (at your option) any later version.
49 + *
50 + * This program is distributed in the hope that it will be useful,
51 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
52 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53 + * GNU General Public License for more details.
54 + *
55 + * You should have received a copy of the GNU General Public License
56 + * along with this program; if not, write to the Free Software
57 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
58 + *
59 + * Should you need to contact me, the author, you can do so either by
60 + * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
61 + * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
62 + */
64 +/* softa note:
65 +cvs version is here:
66 +http://cvs.sourceforge.net/viewcvs.py/ *checkout* /linuxconsole/ruby/utils/inputattach.c
67 +*/
69 +#include <linux/serio.h>
71 +#include <sys/types.h>
72 +#include <sys/stat.h>
73 +#include <sys/ioctl.h>
74 +#include <sys/time.h>
76 +#include <stdio.h>
77 +#include <stdlib.h>
78 +#include <unistd.h>
79 +#include <fcntl.h>
80 +#include <termios.h>
81 +#include <string.h>
82 +#include <assert.h>
83 +#include <ctype.h>
85 +// softa patch!
86 +/*
87 + * Serio types
88 + */
89 +#ifndef SERIO_UNKNOWN
90 + #define SERIO_UNKNOWN 0x00
91 +#endif
92 +#ifndef SERIO_MSC
93 + #define SERIO_MSC 0x01
94 +#endif
95 +#ifndef SERIO_SUN
96 + #define SERIO_SUN 0x02
97 +#endif
98 +#ifndef SERIO_MS
99 + #define SERIO_MS 0x03
100 +#endif
101 +#ifndef SERIO_MP
102 + #define SERIO_MP 0x04
103 +#endif
104 +#ifndef SERIO_MZ
105 + #define SERIO_MZ 0x05
106 +#endif
107 +#ifndef SERIO_MZP
108 + #define SERIO_MZP 0x06
109 +#endif
110 +#ifndef SERIO_MZPP
111 + #define SERIO_MZPP 0x07
112 +#endif
113 +#ifndef SERIO_VSXXXAA
114 + #define SERIO_VSXXXAA 0x08
115 +#endif
116 +#ifndef SERIO_SUNKBD
117 + #define SERIO_SUNKBD 0x10
118 +#endif SERIO_SUNKBD
119 +#ifndef SERIO_WARRIOR
120 + #define SERIO_WARRIOR 0x18
121 +#endif
122 +#ifndef SERIO_WARRIOR
123 + #define SERIO_SPACEORB 0x19
124 +#endif
125 +#ifndef SERIO_MAGELLAN
126 + #define SERIO_MAGELLAN 0x1a
127 +#endif
128 +#ifndef SERIO_SPACEBALL
129 + #define SERIO_SPACEBALL 0x1b
130 +#endif
131 +#ifndef SERIO_GUNZE
132 + #define SERIO_GUNZE 0x1c
133 +#endif
134 +#ifndef SERIO_IFORCE
135 + #define SERIO_IFORCE 0x1d
136 +#endif
137 +#ifndef SERIO_STINGER
138 + #define SERIO_STINGER 0x1e
139 +#endif
140 +#ifndef SERIO_NEWTON
141 + #define SERIO_NEWTON 0x1f
142 +#endif
143 +#ifndef SERIO_STOWAWAY
144 + #define SERIO_STOWAWAY 0x20
145 +#endif
146 +#ifndef SERIO_H3600
147 + #define SERIO_H3600 0x21
148 +#endif
149 +#ifndef SERIO_PS2SER
150 + #define SERIO_PS2SER 0x22
151 +#endif
152 +#ifndef SERIO_TWIDKBD
153 + #define SERIO_TWIDKBD 0x23
154 +#endif
155 +#ifndef SERIO_TWIDJOY
156 + #define SERIO_TWIDJOY 0x24
157 +#endif
158 +#ifndef SERIO_HIL
159 + #define SERIO_HIL 0x25
160 +#endif
161 +#ifndef SERIO_SNES232
162 + #define SERIO_SNES232 0x26
163 +#endif
164 +#ifndef SERIO_SEMTECH
165 + #define SERIO_SEMTECH 0x27
166 +#endif
167 +#ifndef SERIO_LKKBD
168 + #define SERIO_LKKBD 0x28
169 +#endif
170 +#ifndef SERIO_ELO
171 + #define SERIO_ELO 0x29
172 +#endif
173 +#ifndef SERIO_MICROTOUCH
174 + #define SERIO_MICROTOUCH 0x30
175 +#endif
176 +#ifndef SERIO_PENMOUNT
177 + #define SERIO_PENMOUNT 0x31
178 +#endif
179 +#ifndef SERIO_TOUCHRIGHT
180 + #define SERIO_TOUCHRIGHT 0x32
181 +#endif
182 +#ifndef SERIO_TOUCHWIN
183 + #define SERIO_TOUCHWIN 0x33
184 +#endif
185 +// end softa patch!
187 +int readchar(int fd, unsigned char *c, int timeout)
189 + struct timeval tv;
190 + fd_set set;
192 + tv.tv_sec = 0;
193 + tv.tv_usec = timeout * 1000;
195 + FD_ZERO(&set);
196 + FD_SET(fd, &set);
198 + if (!select(fd+1, &set, NULL, NULL, &tv)) return -1;
199 + if (read(fd, c, 1) != 1) return -1;
201 + return 0;
206 +void setline(int fd, int flags, int speed)
208 + struct termios t;
210 + tcgetattr(fd, &t);
212 + t.c_cflag = flags | CREAD | HUPCL | CLOCAL;
213 + t.c_iflag = IGNBRK | IGNPAR;
214 + t.c_oflag = 0;
215 + t.c_lflag = 0;
216 + t.c_cc[VMIN ] = 1;
217 + t.c_cc[VTIME] = 0;
219 + cfsetispeed(&t, speed);
220 + cfsetospeed(&t, speed);
222 + tcsetattr(fd, TCSANOW, &t);
225 +int logitech_command(int fd, char *c)
227 + int i;
228 + unsigned char d;
229 + for (i = 0; c[i]; i++) {
230 + write(fd, c + i, 1);
231 + if (readchar(fd, &d, 1000))
232 + return -1;
233 + if (c[i] != d)
234 + return -1;
236 + return 0;
239 +int magellan_init(int fd, long *id, long *extra)
241 + write(fd, "m3\rpBB\rz\r", 9);
242 + return 0;
245 +int warrior_init(int fd, long *id, long *extra)
247 + if (logitech_command(fd, "*S")) return -1;
248 + setline(fd, CS8, B4800);
249 + return 0;
252 +int spaceball_waitchar(int fd, unsigned char c, unsigned char *d, int timeout)
254 + unsigned char b = 0;
256 + while (!readchar(fd, &b, timeout)) {
257 + if (b == 0x0a) continue;
258 + *d++ = b;
259 + if (b == c) break;
262 + *d = 0;
264 + return -(b != c);
267 +int spaceball_waitcmd(int fd, char c, char *d)
269 + int i;
271 + for (i = 0; i < 8; i++) {
272 + if (spaceball_waitchar(fd, 0x0d, d, 1000))
273 + return -1;
274 + if (d[0] == c)
275 + return 0;
278 + return -1;
281 +int spaceball_cmd(int fd, char *c, char *d)
283 + int i;
285 + for (i = 0; c[i]; i++)
286 + write(fd, c + i, 1);
287 + write(fd, "\r", 1);
289 + i = spaceball_waitcmd(fd, toupper(c[0]), d);
291 + return i;
294 +#define SPACEBALL_1003 1
295 +#define SPACEBALL_2003B 3
296 +#define SPACEBALL_2003C 4
297 +#define SPACEBALL_3003C 7
298 +#define SPACEBALL_4000FLX 8
299 +#define SPACEBALL_4000FLX_L 9
301 +int spaceball_init(int fd, long *id, long *extra)
303 + char r[64];
305 + if (spaceball_waitchar(fd, 0x11, r, 4000) ||
306 + spaceball_waitchar(fd, 0x0d, r, 1000))
307 + return -1;
309 + if (spaceball_waitcmd(fd, '@', r))
310 + return -1;
312 + if (strncmp("@1 Spaceball alive", r, 18))
313 + return -1;
315 + if (spaceball_waitcmd(fd, '@', r))
316 + return -1;
318 + if (spaceball_cmd(fd, "hm", r))
319 + return -1;
321 + if (!strncmp("Hm2003B", r, 7))
322 + *id = SPACEBALL_2003B;
323 + if (!strncmp("Hm2003C", r, 7))
324 + *id = SPACEBALL_2003C;
325 + if (!strncmp("Hm3003C", r, 7))
326 + *id = SPACEBALL_3003C;
328 + if (!strncmp("HvFirmware", r, 10)) {
330 + if (spaceball_cmd(fd, "\"", r))
331 + return -1;
333 + if (strncmp("\"1 Spaceball 4000 FLX", r, 21))
334 + return -1;
336 + if (spaceball_waitcmd(fd, '"', r))
337 + return -1;
339 + if (strstr(r, " L "))
340 + *id = SPACEBALL_4000FLX_L;
341 + else
342 + *id = SPACEBALL_4000FLX;
344 + if (spaceball_waitcmd(fd, '"', r))
345 + return -1;
347 + if (spaceball_cmd(fd, "YS", r))
348 + return -1;
350 + if (spaceball_cmd(fd, "M", r))
351 + return -1;
353 + return 0;
356 + if (spaceball_cmd(fd, "P@A@A", r) ||
357 + spaceball_cmd(fd, "FT@", r) ||
358 + spaceball_cmd(fd, "MSS", r))
359 + return -1;
361 + return 0;
364 +int stinger_init(int fd, long *id, long *extra)
366 + int i;
367 + unsigned char c;
368 + unsigned char *response = "\r\n0600520058C272";
370 + if (write(fd, " E5E5", 5) != 5) /* Enable command */
371 + return -1;
373 + for (i = 0; i < 16; i++) /* Check for Stinger */
374 + if (readchar(fd, &c, 200) || (c != response[i]))
375 + return -1;
377 + return 0;
380 +int mzp_init(int fd, long *id, long *extra)
382 + if (logitech_command(fd, "*X*q")) return -1;
383 + setline(fd, CS8, B9600);
384 + return 0;
387 +int newton_init(int fd, long *id, long *extra)
389 + int i;
390 + unsigned char c;
391 + unsigned char response[35] =
392 + { 0x16, 0x10, 0x02, 0x64, 0x5f, 0x69, 0x64, 0x00,
393 + 0x00, 0x00, 0x0c, 0x6b, 0x79, 0x62, 0x64, 0x61,
394 + 0x70, 0x70, 0x6c, 0x00, 0x00, 0x00, 0x01, 0x6e,
395 + 0x6f, 0x66, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x10,
396 + 0x03, 0xdd, 0xe7 };
398 + for (i = 0; i < 35; i++)
399 + if (readchar(fd, &c, 400) || (c != response[i]))
400 + return -1;
402 + return 0;
405 +int twiddler_init(int fd, long *id, long *extra)
407 + unsigned char c[10];
408 + int count, line;
410 + /* Turn DTR off, otherwise the Twiddler won't send any data. */
411 + if (ioctl(fd, TIOCMGET, &line)) return -1;
412 + line &= ~TIOCM_DTR;
413 + if (ioctl(fd, TIOCMSET, &line)) return -1;
415 + /* Check whether the device on the serial line is the Twiddler.
417 + * The Twiddler sends data packets of 5 bytes which have the following
418 + * properties: the MSB is 0 on the first and 1 on all other bytes, and
419 + * the high order nibble of the last byte is always 0x8.
421 + * We read and check two of those 5 byte packets to be sure that we
422 + * are indeed talking to a Twiddler. */
424 + /* Read at most 5 bytes until we find one with the MSB set to 0 */
425 + for (count = 0; count < 5; count++) {
426 + if (readchar(fd, c+0, 500)) return -1;
427 + if ((c[0] & 0x80) == 0) break;
430 + if (count == 5) {
431 + /* Could not find header byte in data stream */
432 + return -1;
435 + /* Read remaining 4 bytes plus the full next data packet */
436 + for (count = 1; count < 10; count++) {
437 + if (readchar(fd, c+count, 500)) return -1;
440 + /* Check whether the bytes of both data packets obey the rules */
441 + for (count = 1; count < 10; count++) {
442 + if ((count % 5 == 0 && (c[count] & 0x80) != 0)
443 + || (count % 5 == 4 && (c[count] & 0xF0) != 0x80)
444 + || (count % 5 != 0 && (c[count] & 0x80) != 0x80)) {
445 + /* Invalid byte in data packet */
446 + return -1;
450 + return 0;
453 +int penmount_init(int fd, long *id, long *extra)
455 + unsigned char init_cmd[5] = { 0xF2, 0x00, 0x00, 0x00, 0x00 };
456 + unsigned char start_cmd[5] = { 0xF1, 0x00, 0x00, 0x00, 0x00 };
457 + unsigned char c[10];
458 + int count;
460 + /* try to initialize device */
461 + if (write( fd, init_cmd, 5 ) != 5)
462 + return -1;
464 + /* read the responce */
465 + for (count = 0; count < 5; count ++) {
466 + if (readchar(fd, c+0, 500)) return -1;
467 + if (c[0] == 0xf2) break;
470 + if (readchar(fd, c+1, 500)) return -1;
471 + if (c[1] != 0xd9) return -1;
473 + if (readchar(fd, c+2, 500)) return -1;
474 + if (c[2] != 0x0a) return -1;
476 + /* the device is present! start it! */
477 + if (write( fd, start_cmd, 5 ) != 5)
478 + return -1;
480 + return 0;
483 +int dump_init(int fd, long *id, long *extra)
485 + unsigned char c, o = 0;
487 + c = 0x80;
489 + if (write(fd, &c, 1) != 1) /* Enable command */
490 + return -1;
492 + while (1)
493 + if (!readchar(fd, &c, 1)) {
494 + printf("%02x (%c) ", c, ((c > 32) && (c < 127)) ? c : 'x');
495 + o = 1;
496 + } else {
497 + if (o) {
498 + printf("\n");
499 + o = 0;
504 +struct input_types {
505 + char name[16];
506 + char name2[16];
507 + int speed;
508 + int flags;
509 + unsigned long type;
510 + unsigned long id;
511 + unsigned long extra;
512 + int flush;
513 + int (*init)(int fd, long *id, long *extra);
516 +struct input_types input_types[] = {
518 +{ "--sunkbd", "-skb", B1200, CS8, SERIO_SUNKBD, 0, 0, 1, NULL },
519 +{ "--lkkbd", "-lk", B4800, CS8|CSTOPB, SERIO_LKKBD, 0, 0, 1, NULL },
520 +{ "--vsxxx-aa", "-vs", B4800, CS8|CSTOPB|PARENB|PARODD,SERIO_VSXXXAA, 0, 0, 1, NULL },
521 +{ "--spaceorb", "-orb", B9600, CS8, SERIO_SPACEORB, 0, 0, 1, NULL },
522 +{ "--spaceball", "-sbl", B9600, CS8, SERIO_SPACEBALL,0, 0, 0, spaceball_init },
523 +{ "--magellan", "-mag", B9600, CS8 | CSTOPB | CRTSCTS, SERIO_MAGELLAN, 0, 0, 1, magellan_init },
524 +{ "--warrior", "-war", B1200, CS7 | CSTOPB, SERIO_WARRIOR, 0, 0, 1, warrior_init },
525 +{ "--stinger", "-sting", B1200, CS8, SERIO_STINGER, 0, 0, 1, stinger_init },
526 +{ "--mousesystems", "-msc", B1200, CS8, SERIO_MSC, 0, 0x01, 1, NULL },
527 +{ "--sunmouse", "-sun", B1200, CS8, SERIO_SUN, 0, 0x01, 1, NULL },
528 +{ "--microsoft", "-bare", B1200, CS7, SERIO_MS, 0, 0, 1, NULL },
529 +{ "--mshack", "-ms", B1200, CS7, SERIO_MS, 0, 0x01, 1, NULL },
530 +{ "--mouseman", "-mman", B1200, CS7, SERIO_MP, 0, 0x01, 1, NULL },
531 +{ "--intellimouse", "-ms3", B1200, CS7, SERIO_MZ, 0, 0x11, 1, NULL },
532 +{ "--mmwheel", "-mmw", B1200, CS7 | CSTOPB, SERIO_MZP, 0, 0x13, 1, mzp_init },
533 +{ "--iforce", "-ifor", B38400, CS8, SERIO_IFORCE, 0, 0, 0, NULL },
534 +{ "--newtonkbd", "-newt", B9600, CS8, SERIO_NEWTON, 0, 0, 0, newton_init },
535 +{ "--h3600ts", "-ipaq", B115200, CS8, SERIO_H3600, 0, 0, 0, NULL },
536 +{ "--stowawaykbd", "-ipaqkbd", B115200, CS8, SERIO_STOWAWAY, 0, 0, 0, NULL },
537 +{ "--ps2serkbd", "-ps2ser", B1200, CS8, SERIO_PS2SER, 0, 0, 1, NULL },
538 +{ "--twiddler", "-twid", B2400, CS8, SERIO_TWIDKBD, 0, 0, 0, twiddler_init },
539 +{ "--twiddler-joy", "-twidjoy", B2400, CS8, SERIO_TWIDJOY, 0, 0, 0, twiddler_init },
540 +{ "--elotouch", "-elo", B9600, CS8 | CRTSCTS, SERIO_ELO, 0, 0, 0, NULL },
541 +{ "--elo4002", "-elo6b", B9600, CS8 | CRTSCTS, SERIO_ELO, 1, 0, 0, NULL },
542 +{ "--elo271-140", "-elo4b", B9600, CS8 | CRTSCTS, SERIO_ELO, 2, 0, 0, NULL },
543 +{ "--elo261-280", "-elo3b", B9600, CS8 | CRTSCTS, SERIO_ELO, 3, 0, 0, NULL },
544 +{ "--dump", "-dump", B2400, CS8, 0, 0, 0, 0, dump_init },
545 +{ "--dmc9000", "-dmc", B19200, CS8, SERIO_PENMOUNT, 0, 0, 0, penmount_init },
546 +{ "", "", 0, 0 }
550 +int main(int argc, char **argv)
552 + unsigned long devt;
553 + int ldisc;
554 + int type;
555 + long id, extra;
556 + int fd;
557 + char c;
559 + if (argc < 2 || argc > 3 || !strcmp("--help", argv[1])) {
560 + puts("");
561 + puts("Usage: inputttach <mode> <device>");
562 + puts("");
563 + puts("Modes:");
564 + puts(" --sunkbd -skb Sun Type 4 and Type 5 keyboards");
565 + puts(" --lkkbd -lk DEC LK201 / LK401 keyboards");
566 + puts(" --vsxxx-aa -vs DEC VSXXX-AA / VSXXX-GA mouse and VSXXX-AB tablet");
567 + puts(" --spaceorb -orb SpaceOrb 360 / SpaceBall Avenger");
568 + puts(" --spaceball -sbl SpaceBall 2003 / 3003 / 4000 FLX");
569 + puts(" --magellan -mag Magellan / SpaceMouse");
570 + puts(" --warrior -war WingMan Warrior");
571 + puts(" --stinger -stng Gravis Stinger");
572 + puts(" --mousesystems -msc 3-button Mouse Systems mice");
573 + puts(" --sunmouse -sun 3-button Sun mice");
574 + puts(" --microsoft -bare 2-button Microsoft mice");
575 + puts(" --mshack -ms 3-button mice in Microsoft mode");
576 + puts(" --mouseman -mman 3-button Logitech and Genius mice");
577 + puts(" --intellimouse -ms3 Microsoft IntelliMouse");
578 + puts(" --mmwheel -mmw Logitech mice with 4-5 buttons or wheel");
579 + puts(" --iforce -ifor I-Force joysticks and wheels");
580 + puts(" --h3600ts -ipaq Ipaq h3600 touchscreen");
581 + puts(" --stowawaykbd -ipaqkbd Stowaway keyboard");
582 + puts(" --ps2serkbd -ps2ser PS/2 via serial keyboard");
583 + puts(" --twiddler -twid Handykey Twiddler chording keyboard");
584 + puts(" --twiddler-joy -twidjoy Handykey Twiddler used as a joystick");
585 + puts(" --dmc9000 -dmc DMC9000/Penpount touchscreen");
586 + puts("");
587 + return 1;
590 + for (type = 0; input_types[type].speed; type++) {
591 + if (!strncasecmp(argv[1], input_types[type].name, 16) ||
592 + !strncasecmp(argv[1], input_types[type].name2, 16))
593 + break;
596 + if (!input_types[type].speed) {
597 + fprintf(stderr, "inputattach: invalid mode\n");
598 + return 1;
601 + if ((fd = open(argv[2], O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0) {
602 + perror("inputattach");
603 + return 1;
606 + setline(fd, input_types[type].flags, input_types[type].speed);
608 + if (input_types[type].flush)
609 + while (!readchar(fd, &c, 100));
611 + id = input_types[type].id;
612 + extra = input_types[type].extra;
614 + if (input_types[type].init && input_types[type].init(fd, &id, &extra)) {
615 + fprintf(stderr, "inputattach: device initialization failed\n");
616 + return 1;
619 + ldisc = N_MOUSE;
620 + if(ioctl(fd, TIOCSETD, &ldisc)) {
621 + fprintf(stderr, "inputattach: can't set line discipline\n");
622 + return 1;
625 + devt = input_types[type].type | (id << 8) | (extra << 16);
627 + if(ioctl(fd, SPIOCSTYPE, &devt)) {
628 + fprintf(stderr, "inputattach: can't set device type\n");
629 + return 1;
632 + read(fd, NULL, 0);
634 + ldisc = 0;
635 + ioctl(fd, TIOCSETD, &ldisc);
636 + close(fd);
638 + return 0;
640 diff -Naur tslib-org/tests/ts_finddev.c tslib-1.0/tests/ts_finddev.c
641 --- tslib-org/tests/ts_finddev.c 1970-01-01 02:00:00.000000000 +0200
642 +++ tslib-1.0/tests/ts_finddev.c 2007-05-07 17:36:37.000000000 +0300
643 @@ -0,0 +1,75 @@
645 + * tslib/src/ts_print.c
647 + * Derived from tslib/src/ts_test.c by Douglas Lowder
648 + * Just prints touchscreen events -- does not paint them on framebuffer
650 + * This file is placed under the GPL. Please see the file
651 + * COPYING for more details.
653 + * Basic test program for touchscreen library.
654 + */
655 +#include <stdio.h>
656 +#include <stdlib.h>
657 +#include <signal.h>
658 +#include <sys/fcntl.h>
659 +#include <sys/ioctl.h>
660 +#include <sys/mman.h>
661 +#include <sys/time.h>
662 +#include <sys/types.h>
663 +#include <unistd.h>
665 +#include "tslib.h"
667 +void usage( int argc, char** argv ) {
668 + printf( "Usage: %s device_name wait_for_sec\n", argv[0] );
669 + printf( "\tdevice_name - tdevice to probe, example /dev/input/event0\n" );
670 + printf( "\twait_for_sec - wait seconds for touch event, if 0 - dont wait!\n" );
671 + printf( "\tReturn codes:\n" );
672 + printf( "\t 0 - timeout expired without receiving event.\n" );
673 + printf( "\t But this maybe is TouchScreen.\n" );
674 + printf( "\t -1 - this is NOT TouchScreen device!\n" );
675 + printf( "\t 1 - this is TouchScreen for shure!\n" );
676 + exit(-1);
679 +void alarm_handler( int sig ) {
680 + // time is expired!
681 + exit(0);
684 +int main( int argc, char** argv )
686 + struct tsdev *ts;
687 + struct ts_sample samp;
688 + char *tsdevice=NULL;
689 + int waitsec;
690 + int ret;
692 + if (argc != 3)
693 + usage( argc, argv );
695 + tsdevice = argv[1];
696 + waitsec = atoi( argv[2] );
697 + if (waitsec < 0)
698 + usage( argc, argv );
700 + ts = ts_open( tsdevice, 0 );
701 + if (!ts)
702 + return -1;
703 + if (ts_config(ts))
704 + return -1;
706 + if (!waitsec) {
707 + return 0;
710 + printf( "Probe device %s, Please Touch Screen Anywhere in %i seconds! ... \n", tsdevice, waitsec );
711 + signal( SIGALRM, alarm_handler );
712 + alarm( waitsec );
713 + ret = ts_read_raw(ts, &samp, 1 );
714 + if (ret)
715 + return 1;
717 + return -1;