Mercurial > sdl-ios-xcode
annotate touchTest/touchTest.c @ 4642:057e8762d2a1
Added reading of event* for touch events.
author | Jim Grandpre <jim.tla@gmail.com> |
---|---|
date | Fri, 28 May 2010 01:26:52 -0400 |
parents | |
children | 8806b78988f7 |
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 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
12 int mousx,mousy; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
13 int keystat[512]; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
14 int bstatus; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
15 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
16 |
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 typedef struct { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
20 int x,y; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
21 } Point; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
22 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
23 void handler (int sig) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
24 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
25 printf ("\nexiting...(%d)\n", sig); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
26 exit (0); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
27 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
28 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
29 void perror_exit (char *error) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
30 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
31 perror (error); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
32 handler (9); |
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 |
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 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
|
37 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
38 Uint32 *pixmem32; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
39 Uint32 colour; |
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 if((unsigned)x > screen->w) return; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
42 if((unsigned)y > screen->h) return; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
43 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
44 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
|
45 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
46 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
|
47 *pixmem32 = colour; |
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 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
50 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
|
51 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
52 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
53 float a; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
54 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
|
55 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
56 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
|
57 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
58 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
59 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
60 void DrawScreen(SDL_Surface* screen, int h) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
61 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
62 int x, y, xm,ym,c; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
63 if(SDL_MUSTLOCK(screen)) |
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 if(SDL_LockSurface(screen) < 0) return; |
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 for(y = 0; y < screen->h; y++ ) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
68 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
69 for( x = 0; x < screen->w; x++ ) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
70 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
71 //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
|
72 //xm = (x+h)%screen->w; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
73 //ym = (y+h)%screen->w; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
74 //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
|
75 //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
|
76 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
|
77 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
78 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
79 drawCircle(screen,mousx,mousy,30,0xFFFFFF); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
80 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
81 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
82 if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); |
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 SDL_Flip(screen); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
85 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
86 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
87 SDL_Surface* initScreen(int width,int height) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
88 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
89 return SDL_SetVideoMode(width, height, DEPTH, |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
90 SDL_HWSURFACE | SDL_RESIZABLE); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
91 } |
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 int main(int argc, char* argv[]) |
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 SDL_Surface *screen; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
96 SDL_Event event; |
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 int keypress = 0; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
99 int h=0,s=1,i,j; |
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 memset(keystat,0,512*sizeof(keystat[0])); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
102 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
|
103 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
104 if (!(screen = initScreen(WIDTH,HEIGHT))) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
105 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
106 SDL_Quit(); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
107 return 1; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
108 } |
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 while(!keystat[27]) { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
111 //Poll SDL |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
112 while(SDL_PollEvent(&event)) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
113 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
114 switch (event.type) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
115 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
116 case SDL_QUIT: |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
117 keystat[27] = 1; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
118 break; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
119 case SDL_KEYDOWN: |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
120 //printf("%i\n",event.key.keysym.sym); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
121 keystat[event.key.keysym.sym] = 1; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
122 //keypress = 1; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
123 break; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
124 case SDL_KEYUP: |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
125 //printf("%i\n",event.key.keysym.sym); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
126 keystat[event.key.keysym.sym] = 0; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
127 //keypress = 1; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
128 break; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
129 case SDL_VIDEORESIZE: |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
130 if (!(screen = initScreen(event.resize.w, |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
131 event.resize.h))) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
132 { |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
133 SDL_Quit(); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
134 return 1; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
135 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
136 break; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
137 case SDL_MOUSEMOTION: |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
138 mousx = event.motion.x; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
139 mousy = event.motion.y; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
140 break; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
141 case SDL_MOUSEBUTTONDOWN: |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
142 bstatus |= (1<<(event.button.button-1)); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
143 break; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
144 case SDL_MOUSEBUTTONUP: |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
145 bstatus &= ~(1<<(event.button.button-1)); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
146 break; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
147 case SDL_FINGERMOTION: |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
148 i = 1; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
149 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
150 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
151 printf("Finger: %i,x: %i, y: %i\n",event.tfinger.fingerId, |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
152 event.tfinger.x,event.tfinger.y); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
153 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
154 break; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
155 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
156 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
157 //And draw |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
158 DrawScreen(screen,h); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
159 /* |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
160 for(i=0;i<512;i++) |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
161 if(keystat[i]) printf("%i\n",i); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
162 printf("Buttons:%i\n",bstatus); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
163 */ |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
164 } |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
165 SDL_Quit(); |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
166 |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
167 return 0; |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
diff
changeset
|
168 } |