annotate touchTest/touchTest.c @ 4643:8806b78988f7

Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
author Jim Grandpre <jim.tla@gmail.com>
date Sat, 29 May 2010 01:47:19 -0400
parents 057e8762d2a1
children fb500b3e1717
rev   line source
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
1 #include <stdio.h>
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
2 #include <SDL.h>
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
3 #include <math.h>
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
4 #include "../src/events/SDL_touch_c.h" //BAD!!!
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
5
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
6 #define PI 3.1415926535897
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
7 #define WIDTH 640
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
8 #define HEIGHT 480
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
9 #define BPP 4
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
10 #define DEPTH 32
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
11
4643
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
12 #define MAXFINGERS 3
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
13
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
14 int mousx,mousy;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
15 int keystat[512];
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
16 int bstatus;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
17
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
18
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
19
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
20
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
21 typedef struct {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
22 int x,y;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
23 } Point;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
24
4643
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
25
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
26 Point finger[MAXFINGERS];
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
27
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
28 void handler (int sig)
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
29 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
30 printf ("\nexiting...(%d)\n", sig);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
31 exit (0);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
32 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
33
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
34 void perror_exit (char *error)
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
35 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
36 perror (error);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
37 handler (9);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
38 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
39
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
40
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
41 void setpix(SDL_Surface *screen, int x, int y, int col)
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
42 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
43 Uint32 *pixmem32;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
44 Uint32 colour;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
45
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
46 if((unsigned)x > screen->w) return;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
47 if((unsigned)y > screen->h) return;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
48
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
49 colour = SDL_MapRGB( screen->format, (col>>16)&0xFF, (col>>8)&0xFF, col&0xFF);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
50
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
51 pixmem32 = (Uint32*) screen->pixels + y*screen->pitch/BPP + x;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
52 *pixmem32 = colour;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
53 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
54
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
55 void drawCircle(SDL_Surface* screen,int x,int y,int r,int c)
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
56 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
57
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
58 float a;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
59 for(a=0;a<2*PI;a+=1.f/(float)r)
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
60 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
61 setpix(screen,(int)(x+r*cos(a)),(int)(y+r*sin(a)),c);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
62 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
63 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
64
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
65 void DrawScreen(SDL_Surface* screen, int h)
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
66 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
67 int x, y, xm,ym,c;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
68 if(SDL_MUSTLOCK(screen))
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
69 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
70 if(SDL_LockSurface(screen) < 0) return;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
71 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
72 for(y = 0; y < screen->h; y++ )
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
73 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
74 for( x = 0; x < screen->w; x++ )
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
75 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
76 //setpixel(screen, x, y, (x*x)/256+3*y+h, (y*y)/256+x+h, h);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
77 //xm = (x+h)%screen->w;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
78 //ym = (y+h)%screen->w;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
79 //c = sin(h/256*2*PI)*x*y/screen->w/screen->h;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
80 //setpix(screen,x,y,255*sin(xm/screen->w*2*PI),sin(h/255*2*PI)*255*y/screen->h,c);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
81 setpix(screen,x,y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
82 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
83 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
84 drawCircle(screen,mousx,mousy,30,0xFFFFFF);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
85
4643
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
86 int i;
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
87 for(i=0;i<MAXFINGERS;i++)
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
88 if(finger[i].x >= 0 && finger[i].y >= 0)
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
89 drawCircle(screen,finger[i].x,finger[i].y,20,0xFF6600);
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
90
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
91 if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
92
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
93 SDL_Flip(screen);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
94 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
95
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
96 SDL_Surface* initScreen(int width,int height)
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
97 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
98 return SDL_SetVideoMode(width, height, DEPTH,
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
99 SDL_HWSURFACE | SDL_RESIZABLE);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
100 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
101
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
102 int main(int argc, char* argv[])
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
103 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
104 SDL_Surface *screen;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
105 SDL_Event event;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
106
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
107 int keypress = 0;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
108 int h=0,s=1,i,j;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
109
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
110 memset(keystat,0,512*sizeof(keystat[0]));
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
111 if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
112
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
113 if (!(screen = initScreen(WIDTH,HEIGHT)))
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
114 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
115 SDL_Quit();
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
116 return 1;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
117 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
118
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
119 while(!keystat[27]) {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
120 //Poll SDL
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
121 while(SDL_PollEvent(&event))
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
122 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
123 switch (event.type)
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
124 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
125 case SDL_QUIT:
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
126 keystat[27] = 1;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
127 break;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
128 case SDL_KEYDOWN:
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
129 //printf("%i\n",event.key.keysym.sym);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
130 keystat[event.key.keysym.sym] = 1;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
131 //keypress = 1;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
132 break;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
133 case SDL_KEYUP:
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
134 //printf("%i\n",event.key.keysym.sym);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
135 keystat[event.key.keysym.sym] = 0;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
136 //keypress = 1;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
137 break;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
138 case SDL_VIDEORESIZE:
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
139 if (!(screen = initScreen(event.resize.w,
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
140 event.resize.h)))
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
141 {
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
142 SDL_Quit();
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
143 return 1;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
144 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
145 break;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
146 case SDL_MOUSEMOTION:
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
147 mousx = event.motion.x;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
148 mousy = event.motion.y;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
149 break;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
150 case SDL_MOUSEBUTTONDOWN:
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
151 bstatus |= (1<<(event.button.button-1));
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
152 break;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
153 case SDL_MOUSEBUTTONUP:
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
154 bstatus &= ~(1<<(event.button.button-1));
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
155 break;
4643
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
156 case SDL_FINGERMOTION:
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
157
4643
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
158 //printf("Finger: %i,x: %i, y: %i\n",event.tfinger.fingerId,
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
159 // event.tfinger.x,event.tfinger.y);
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
160 finger[event.tfinger.fingerId].x = event.tfinger.x;
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
161 finger[event.tfinger.fingerId].y = event.tfinger.y;
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
162 break;
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
163 case SDL_FINGERDOWN:
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
164 printf("Figner: %i down - x: %i, y: %i\n",event.tfinger.fingerId,
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
165 event.tfinger.x,event.tfinger.y);
4643
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
166 finger[event.tfinger.fingerId].x = event.tfinger.x;
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
167 finger[event.tfinger.fingerId].y = event.tfinger.y;
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
168 break;
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
169 case SDL_FINGERUP:
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
170 printf("Figner: %i up - x: %i, y: %i\n",event.tfinger.fingerId,
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
171 event.tfinger.x,event.tfinger.y);
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
172 finger[event.tfinger.fingerId].x = -1;
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
173 finger[event.tfinger.fingerId].y = -1;
8806b78988f7 Bug fixes. Basic touch events (finger up, finger down, finger move) supported.
Jim Grandpre <jim.tla@gmail.com>
parents: 4642
diff changeset
174 break;
4642
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
175 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
176 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
177 //And draw
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
178 DrawScreen(screen,h);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
179 /*
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
180 for(i=0;i<512;i++)
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
181 if(keystat[i]) printf("%i\n",i);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
182 printf("Buttons:%i\n",bstatus);
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
183 */
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
184 }
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
185 SDL_Quit();
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
186
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
187 return 0;
057e8762d2a1 Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff changeset
188 }