annotate touchTest/touchPong.c @ 4656:b5007b7995c6

Added multi-finger gestures
author Jim Grandpre <jim.tla@gmail.com>
date Tue, 06 Jul 2010 02:05:27 -0700
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 <SDL.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 <math.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 <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
5 #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
6
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
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 #define PI 3.1415926535897
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 #define WIDTH 640
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 #define HEIGHT 480
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 #define BPP 4
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 #define DEPTH 32
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
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
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 #define MAX_FINGERS 2
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
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 int mousx,mousy;
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 int keystat[512];
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 int bstatus;
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
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 typedef struct {
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 int x,y;
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 } Point;
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 Point finger[MAX_FINGERS];
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
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 //Pong 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
30 Point ball,ballv;
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
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
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 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
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 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
36 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
37 }
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
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 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
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 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
42 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
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
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
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 void setpix(SDL_Surface *screen, int x, int y, int col)
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 {
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 Uint32 *pixmem32;
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 Uint32 colour;
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 if((unsigned)x > screen->w) return;
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 if((unsigned)y > screen->h) return;
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
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 colour = SDL_MapRGB( screen->format, (col>>16)&0xFF, (col>>8)&0xFF, col&0xFF);
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
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 pixmem32 = (Uint32*) screen->pixels + y*screen->pitch/BPP + x;
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 *pixmem32 = colour;
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 }
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
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 void drawCircle(SDL_Surface* screen,int x,int y,int r,int c)
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 {
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 float a;
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 for(a=0;a<2*PI;a+=1.f/(float)r)
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 setpix(screen,(int)(x+r*cos(a)),(int)(y+r*sin(a)),c);
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 }
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
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
70 void DrawScreen(SDL_Surface* screen, int 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
71 {
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
72 int x, y, xm,ym,c;
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
73 if(SDL_MUSTLOCK(screen))
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
74 {
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
75 if(SDL_LockSurface(screen) < 0) return;
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
76 }
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
77 for(y = 0; y < screen->h; y++ )
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
78 {
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
79 for( x = 0; x < screen->w; x++ )
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
80 {
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
81 //setpixel(screen, x, y, (x*x)/256+3*y+h, (y*y)/256+x+h, 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
82 //xm = (x+h)%screen->w;
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
83 //ym = (y+h)%screen->w;
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
84 //c = sin(h/256*2*PI)*x*y/screen->w/screen->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
85 //setpix(screen,x,y,255*sin(xm/screen->w*2*PI),sin(h/255*2*PI)*255*y/screen->h,c);
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
86 setpix(screen,x,y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255);
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
87 }
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
88 }
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
89 drawCircle(screen,mousx,mousy,30,0xFFFFFF);
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
90 int i;
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
91 for(i=0;i<MAX_FINGERS;i++)
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
92 drawCircle(screen,finger[i].x,finger[i].y,30,0xFFFFFF);
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
93
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
94 drawCircle(screen,ball.x,ball.y,30,0xFF00FF);
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
95
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
96 if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
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
97
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
98 SDL_Flip(screen);
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
99 }
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
100
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
101 SDL_Surface* initScreen(int width,int height)
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
102 {
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
103 return SDL_SetVideoMode(width, height, DEPTH,
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
104 SDL_HWSURFACE | SDL_RESIZABLE);
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
105 }
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
106
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
107 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
108 {
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
109 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
110 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
111 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
112 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
113
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
114
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
115
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
116 //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
117 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
118 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
119 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
120 }
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
121
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
122 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
123 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
124
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
125 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
126 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
127
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
128 //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
129 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
130 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
131
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
132 //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
133 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
134 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
135
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
136
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
137
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
138
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
139
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
140 SDL_Surface *screen;
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
141 SDL_Event 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
142
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
143 int keypress = 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
144 int h=0,s=1,i,j;
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
145 int tx,ty,curf=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
146
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
147
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
148
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
149 memset(keystat,0,512*sizeof(keystat[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
150 if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 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
151
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
152 if (!(screen = initScreen(WIDTH,HEIGHT)))
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
153 {
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
154 SDL_Quit();
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
155 return 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
156 }
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
157 ball.x = screen->w/2;
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
158 ball.y = screen->h/2;
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
159 ballv.x = -3;
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
160 ballv.y = 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
161 while(!keystat[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
162 {
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
163 //Poll SDL
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
164 while(SDL_PollEvent(&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
165 {
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
166 switch (event.type)
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
167 {
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
168 case SDL_QUIT:
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
169 keystat[27] = 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
170 break;
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
171 case SDL_KEYDOWN:
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
172 //printf("%i\n",event.key.keysym.sym);
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
173 keystat[event.key.keysym.sym] = 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
174 //keypress = 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
175 break;
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
176 case SDL_KEYUP:
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
177 //printf("%i\n",event.key.keysym.sym);
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
178 keystat[event.key.keysym.sym] = 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
179 //keypress = 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
180 break;
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
181 case SDL_VIDEORESIZE:
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
182 if (!(screen = initScreen(event.resize.w,
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
183 event.resize.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
184 {
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
185 SDL_Quit();
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
186 return 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
187 }
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
188 break;
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
189 case SDL_MOUSEMOTION:
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
190 mousx = event.motion.x;
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
191 mousy = event.motion.y;
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
192 break;
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
193 case SDL_MOUSEBUTTONDOWN:
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
194 bstatus |= (1<<(event.button.button-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
195 break;
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
196 case SDL_MOUSEBUTTONUP:
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
197 bstatus &= ~(1<<(event.button.button-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
198 break;
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
199 }
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
200 }
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
201
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
202 //poll for Touch <- Goal: make this a case:
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
203 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
204 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
205 //printf("time: %i\n type: %X\n code: %X\n value: %i\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
206 // ev->time,ev->type,ev->code,ev->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
207 for (i = 0; i < rd / sizeof(struct input_event); i++)
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
208 switch (ev[i].type)
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
209 {
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
210 case EV_ABS:
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
211 if(ev[i].code == ABS_X)
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
212 tx = ev[i].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
213 else if (ev[i].code == ABS_Y)
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
214 ty = ev[i].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
215 else if (ev[i].code == ABS_MISC)
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
216 {
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
217 //printf("Misc:type: %X\n code: %X\n value: %i\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
218 // ev[i].type,ev[i].code,ev[i].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
219 }
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
220 break;
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
221 case EV_MSC:
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
222 if(ev[i].code == MSC_SERIAL)
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
223 curf = ev[i].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
224 break;
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
225 case EV_SYN:
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
226 curf -= 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
227 if(tx >= 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
228 finger[curf].x = tx;
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
229 if(ty >= 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
230 finger[curf].y = ty;
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
231
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
232 //printf("Synched: %i tx: %i, ty: %i\n",curf,finger[curf].x,finger[curf].y);
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
233 tx = -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
234 ty = -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
235 break;
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
236
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
237 }
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
238
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
239 //Pong 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
240 ball.x += ballv.x;
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
241 ball.y += ballv.y;
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
242 for(i=0;i<MAX_FINGERS;i++)
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
243 {
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
244
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
245 if(finger[i].x > 0 || finger[i].y > 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
246 {
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
247 int d2 = (finger[i].x-ball.x)*(finger[i].x-ball.x) +
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
248 (finger[i].y-ball.y)*(finger[i].y-ball.y);
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
249 ballv.x += (50*(ball.x-finger[i].x))/d2;
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
250 ballv.y += (30*(ball.y-finger[i].y))/d2;
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
251 }
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
252 }
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
253 if((unsigned int)ball.x > screen->w){
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
254 ball.x = screen->w/2;
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
255 ball.y = screen->h/2;
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
256 ballv.x = -3;
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
257 ballv.y = 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
258 }
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
259 if((unsigned int)ball.y > screen->h) ballv.y *= -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
260 printf("(%i,%i)\n",ball.x,ball.y);
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
261 //And draw
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
262 DrawScreen(screen,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
263 /*
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
264 for(i=0;i<512;i++)
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
265 if(keystat[i]) printf("%i\n",i);
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
266 printf("Buttons:%i\n",bstatus);
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
267 */
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
268 }
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
269 SDL_Quit();
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
270
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
271 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
272 }