Mercurial > sdl-ios-xcode
annotate touchTest/testIn.c @ 4653:744b75ad18b8
Started adding vectorization of touch data.
author | Jim Grandpre <jim.tla@gmail.com> |
---|---|
date | Tue, 15 Jun 2010 02:12:16 -0400 |
parents | f5cd4b6231ba |
children |
rev | line source |
---|---|
4639
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
1 #include <stdio.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
2 #include <stdlib.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
3 #include <string.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
4 #include <unistd.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
5 #include <errno.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
6 #include <fcntl.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
7 #include <dirent.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
8 #include <linux/input.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
9 #include <sys/types.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
10 #include <sys/stat.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
11 #include <sys/select.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
12 #include <sys/time.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
13 #include <termios.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
14 #include <signal.h> |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
15 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
16 void handler (int sig) |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
17 { |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
18 printf ("\nexiting...(%d)\n", sig); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
19 exit (0); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
20 } |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
21 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
22 void perror_exit (char *error) |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
23 { |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
24 perror (error); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
25 handler (9); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
26 } |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
27 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
28 int main (int argc, char *argv[]) |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
29 { |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
30 struct input_event ev[64]; |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
31 int fd, rd, value, size = sizeof (struct input_event); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
32 char name[256] = "Unknown"; |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
33 char *device = NULL; |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
34 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
35 //Setup check |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
36 if (argv[1] == NULL){ |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
37 printf("Please specify (on the command line) the path to the dev event interface device\n"); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
38 exit (0); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
39 } |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
40 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
41 if ((getuid ()) != 0) |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
42 printf ("You are not root! This may not work...\n"); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
43 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
44 if (argc > 1) |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
45 device = argv[1]; |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
46 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
47 //Open Device |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
48 if ((fd = open (device, O_RDONLY)) == -1) |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
49 printf ("%s is not a vaild device.\n", device); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
50 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
51 //Print Device Name |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
52 ioctl (fd, EVIOCGNAME (sizeof (name)), name); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
53 printf ("Reading From : %s (%s)\n", device, name); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
54 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
55 while (1){ |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
56 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
57 if ((rd = read (fd, ev, size * 64)) < size) |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
58 perror_exit ("read()"); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
59 printf("time: %i\n type: %X\n code: %X\n value: %i\n ",ev[0].time,ev[0].type,ev[0].value,ev[0].value); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
60 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
61 value = ev[0].value; |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
62 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
63 if (value != ' ' && ev[1].value == 1 && ev[1].type == 1){ // Only read the key press event |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
64 printf ("Code[%d]\n", (ev[1].code)); |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
65 } |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
66 } |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
67 |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
68 return 0; |
f5cd4b6231ba
Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. Should support other touch devices and other linux distros, but not tested on anything else.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
69 } |