comparison test/testmmousetablet.c @ 2736:ae653575d4af

indent
author Sam Lantinga <slouken@libsdl.org>
date Sun, 31 Aug 2008 16:03:55 +0000
parents dd25eabe441c
children 975fd903466b
comparison
equal deleted inserted replaced
2735:204be4fc2726 2736:ae653575d4af
1 #include <stdio.h> 1 #include <stdio.h>
2 #include "SDL.h" 2 #include "SDL.h"
3 3
4 SDL_Surface* screen; 4 SDL_Surface *screen;
5 int quit=0; 5 int quit = 0;
6 6
7 int main() 7 int
8 main()
8 { 9 {
9 SDL_Event event; 10 SDL_Event event;
10 int mice; 11 int mice;
11 int i; 12 int i;
12 printf("Initing...\n"); 13 printf("Initing...\n");
13 if (SDL_Init(0)!=0) { 14 if (SDL_Init(0) != 0) {
14 return 1; 15 return 1;
15 } 16 }
16 if (SDL_InitSubSystem(SDL_INIT_VIDEO)!=0) { 17 if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
17 return 1; 18 return 1;
18 } 19 } else {
19 else { 20 screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF);
20 screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF); 21 }
21 } 22 mice = SDL_GetNumMice();
22 mice = SDL_GetNumMice(); 23 printf("%d pointing devices found\n", mice);
23 printf("%d pointing devices found\n", mice); 24 for (i = 0; i < mice; ++i) {
24 for(i=0; i<mice; ++i) { 25 printf("device index: %d name:%s\n", i, SDL_GetMouseName(i));
25 printf("device index: %d name:%s\n",i,SDL_GetMouseName(i)); 26 }
26 } 27 while (quit != 1) {
27 while(quit!=1) { 28 if (SDL_PollEvent(&event) == 0) {
28 if(SDL_PollEvent(&event)==0) {} 29 } else {
29 else { 30 switch (event.type) {
30 switch (event.type) { 31 case SDL_MOUSEMOTION:
31 case SDL_MOUSEMOTION: 32 printf
32 printf("Device id: %d x: %d y: %d relx: %d rely: %d pressure: %d\n \ 33 ("Device id: %d x: %d y: %d relx: %d rely: %d pressure: %d\n \
33 pressure_max: %d pressure_min: %d current cursor:%d\n", event.motion.which, event.motion.x,\ 34 pressure_max: %d pressure_min: %d current cursor:%d\n",
34 event.motion.y, event.motion.xrel, event.motion.yrel, event.motion.pressure, event.motion.pressure_max,\ 35 event.motion.which, event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel,
35 event.motion.pressure_min, event.motion.cursor); 36 event.motion.pressure, event.motion.pressure_max, event.motion.pressure_min,
36 break; 37 event.motion.cursor);
37 case SDL_PROXIMITYIN: 38 break;
38 printf("proximity in id: %d x: %d y: %d\n", (int) event.proximity.which, event.proximity.x, event.proximity.y); 39 case SDL_PROXIMITYIN:
39 break; 40 printf("proximity in id: %d x: %d y: %d\n",
40 case SDL_PROXIMITYOUT: 41 (int) event.proximity.which, event.proximity.x,
41 printf("proximity out id: %d x: %d y: %d\n", (int) event.proximity.which, event.proximity.x, event.proximity.y); 42 event.proximity.y);
42 break; 43 break;
43 case SDL_MOUSEBUTTONDOWN: 44 case SDL_PROXIMITYOUT:
44 printf("mouse button down id: %d button:%d\n", event.button.which, event.button.button); 45 printf("proximity out id: %d x: %d y: %d\n",
45 break; 46 (int) event.proximity.which, event.proximity.x,
46 case SDL_MOUSEBUTTONUP: 47 event.proximity.y);
47 printf("mouse button up id: %d button: %d\n", event.button.which, event.button.button); 48 break;
48 break; 49 case SDL_MOUSEBUTTONDOWN:
49 case SDL_QUIT: 50 printf("mouse button down id: %d button:%d\n",
50 printf("Quitting\n"); 51 event.button.which, event.button.button);
51 SDL_QuitSubSystem(SDL_INIT_VIDEO); 52 break;
52 SDL_Quit(); 53 case SDL_MOUSEBUTTONUP:
53 quit=1; 54 printf("mouse button up id: %d button: %d\n",
54 break; 55 event.button.which, event.button.button);
55 } 56 break;
56 } 57 case SDL_QUIT:
57 } 58 printf("Quitting\n");
58 return 0; 59 SDL_QuitSubSystem(SDL_INIT_VIDEO);
60 SDL_Quit();
61 quit = 1;
62 break;
63 }
64 }
65 }
66 return 0;
59 } 67 }
60