annotate touchTest/touchSimp.c @ 4679:5ee96ba0c01e

Fixed various type and print format issues
author Sam Lantinga <slouken@libsdl.org>
date Sat, 31 Jul 2010 20:38:37 -0700
parents 3c4e0130c9b1
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
4662
3c4e0130c9b1 Added alternative finger tracking method. Still prefer IPHONE_TOUCH_EFFICIENT_DANGEROUS.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
15 #define MAX_FINGERS 5
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
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
4640
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
23
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
24 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
25 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
26 } 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
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 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
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 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
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 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
33 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
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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
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 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
39 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
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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
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 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
46 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
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 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
49 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
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 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
52
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
54 *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
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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
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 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
61 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
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 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
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
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 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
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 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
70 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
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 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
73 }
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
75 {
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
77 {
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 //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
79 //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
80 //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
81 //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
82 //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
83 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
84 }
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 }
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
87 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
88 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
89 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
90
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
92
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
94 }
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
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 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
99 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
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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
103 {
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
105 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
106 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
107 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
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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 //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
112 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
113 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
114 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
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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 ((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
118 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
119
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
121 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
122
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 //Open Device
4640
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
124 if ((fd = open (device, O_RDONLY | O_NONBLOCK)) == -1)
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
125 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
126
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 //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
128 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
129 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
130
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
136 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
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 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
139 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
140 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
141
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
143 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
144
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
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 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
148 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
149 }
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
152 {
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 //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
154 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
155 {
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
157 {
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
159 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
160 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
161 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
162 //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
163 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
164 //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
165 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
166 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
167 //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
168 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
169 //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
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_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
172 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
173 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
174 {
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
176 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
177 }
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 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
179 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
180 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
181 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
182 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
183 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
184 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
185 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
186 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
187 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
188 break;
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
189 case SDL_FINGERMOTION:
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
190 printf("Holy SH!T\n");
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
191 break;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents: 4640
diff changeset
192
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
193 }
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 }
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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
f5cd4b6231ba Added Test Directory. Touch input works in touchSimp for wacom bamboo fun on Ubuntu linux. Not yet integrated into library. 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 //poll for Touch <- Goal: make this a case:
4640
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
197
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
198
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
199 /*if ((rd = read (fd, ev, size * 64)) < size)
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
200 perror_exit ("read()"); */
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
201 //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
202 // ev->time,ev->type,ev->code,ev->value);
4640
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
203 if((rd = read (fd, ev, size * 64)) >= size)
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
204 for (i = 0; i < rd / sizeof(struct input_event); i++)
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
205 switch (ev[i].type)
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
206 {
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
207 case EV_ABS:
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
208 if(ev[i].code == ABS_X)
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
209 tx = ev[i].value;
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
210 else if (ev[i].code == ABS_Y)
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
211 ty = ev[i].value;
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
212 else if (ev[i].code == ABS_MISC)
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
213 {
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
214 //printf("Misc:type: %X\n code: %X\n value: %i\n ",
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
215 // ev[i].type,ev[i].code,ev[i].value);
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
216 }
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
217 break;
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
218 case EV_MSC:
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
219 if(ev[i].code == MSC_SERIAL)
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
220 curf = ev[i].value;
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
221 break;
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
222 case EV_SYN:
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
223 curf -= 1;
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
224 if(tx >= 0)
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
225 finger[curf].x = tx;
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
226 if(ty >= 0)
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
227 finger[curf].y = ty;
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
228
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
229 //printf("Synched: %i tx: %i, ty: %i\n",curf,finger[curf].x,finger[curf].y);
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
230 tx = -1;
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
231 ty = -1;
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
232 break;
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
233
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
234 }
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
235 //And draw
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
236 DrawScreen(screen,h);
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
237 /*
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
238 for(i=0;i<512;i++)
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
239 if(keystat[i]) printf("%i\n",i);
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
240 printf("Buttons:%i\n",bstatus);
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
241 */
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
242 }
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
243 SDL_Quit();
f068a6dfc858 Added SDL_touch.c/SDL_touch_c.h as slightly modifeind SDL_mouse*. Made reads in touchSimp non-blocking.
Jim Grandpre <jim.tla@gmail.com>
parents: 4639
diff changeset
244
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
245 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
246 }