test/testmmousetablet.c
changeset 2736 ae653575d4af
parent 2734 dd25eabe441c
child 3299 975fd903466b
     1.1 --- a/test/testmmousetablet.c	Wed Aug 27 15:10:03 2008 +0000
     1.2 +++ b/test/testmmousetablet.c	Sun Aug 31 16:03:55 2008 +0000
     1.3 @@ -1,60 +1,67 @@
     1.4  #include <stdio.h>
     1.5  #include "SDL.h"
     1.6  
     1.7 -SDL_Surface* screen;
     1.8 -int quit=0;
     1.9 +SDL_Surface *screen;
    1.10 +int quit = 0;
    1.11  
    1.12 -int main()
    1.13 +int
    1.14 +main()
    1.15  {
    1.16 -	SDL_Event event;
    1.17 -	int mice;
    1.18 -	int i;
    1.19 -	printf("Initing...\n");
    1.20 -	if (SDL_Init(0)!=0) {
    1.21 -		return 1;
    1.22 -    	}
    1.23 -	if (SDL_InitSubSystem(SDL_INIT_VIDEO)!=0) {
    1.24 -		return 1;
    1.25 -	}
    1.26 -	else {
    1.27 -		screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF);
    1.28 -      	}
    1.29 -	mice = SDL_GetNumMice();
    1.30 -	printf("%d pointing devices found\n", mice);
    1.31 -	for(i=0; i<mice; ++i) {
    1.32 -		printf("device index: %d name:%s\n",i,SDL_GetMouseName(i));
    1.33 -	}
    1.34 -	while(quit!=1) {
    1.35 -		if(SDL_PollEvent(&event)==0) {}
    1.36 -		else {
    1.37 -			switch (event.type) {
    1.38 -				case SDL_MOUSEMOTION:
    1.39 -					printf("Device id: %d x: %d y: %d relx: %d rely: %d pressure: %d\n \
    1.40 -					pressure_max: %d pressure_min: %d current cursor:%d\n", event.motion.which, event.motion.x,\
    1.41 -				       	event.motion.y, event.motion.xrel, event.motion.yrel, event.motion.pressure, event.motion.pressure_max,\
    1.42 -				       	event.motion.pressure_min, event.motion.cursor);
    1.43 -				break;
    1.44 -				case SDL_PROXIMITYIN:
    1.45 -					printf("proximity in id: %d x: %d y: %d\n", (int) event.proximity.which, event.proximity.x, event.proximity.y);
    1.46 -				break;
    1.47 -				case SDL_PROXIMITYOUT:
    1.48 -					printf("proximity out id: %d x: %d y: %d\n", (int) event.proximity.which, event.proximity.x, event.proximity.y);
    1.49 -				break;
    1.50 -				case SDL_MOUSEBUTTONDOWN:
    1.51 -					printf("mouse button down id: %d button:%d\n", event.button.which, event.button.button);
    1.52 -				break;
    1.53 -				case SDL_MOUSEBUTTONUP:
    1.54 -					printf("mouse button up id: %d button: %d\n", event.button.which, event.button.button);
    1.55 -				break;
    1.56 -				case SDL_QUIT:
    1.57 -					printf("Quitting\n");
    1.58 -					SDL_QuitSubSystem(SDL_INIT_VIDEO);
    1.59 -					SDL_Quit();
    1.60 -					quit=1;
    1.61 -				break;
    1.62 -			}
    1.63 -		}
    1.64 -	}
    1.65 -	return 0;
    1.66 +    SDL_Event event;
    1.67 +    int mice;
    1.68 +    int i;
    1.69 +    printf("Initing...\n");
    1.70 +    if (SDL_Init(0) != 0) {
    1.71 +        return 1;
    1.72 +    }
    1.73 +    if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
    1.74 +        return 1;
    1.75 +    } else {
    1.76 +        screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF);
    1.77 +    }
    1.78 +    mice = SDL_GetNumMice();
    1.79 +    printf("%d pointing devices found\n", mice);
    1.80 +    for (i = 0; i < mice; ++i) {
    1.81 +        printf("device index: %d name:%s\n", i, SDL_GetMouseName(i));
    1.82 +    }
    1.83 +    while (quit != 1) {
    1.84 +        if (SDL_PollEvent(&event) == 0) {
    1.85 +        } else {
    1.86 +            switch (event.type) {
    1.87 +            case SDL_MOUSEMOTION:
    1.88 +                printf
    1.89 +                    ("Device id: %d x: %d y: %d relx: %d rely: %d pressure: %d\n \
    1.90 +					pressure_max: %d pressure_min: %d current cursor:%d\n",
    1.91 +                     event.motion.which, event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel,
    1.92 +                     event.motion.pressure, event.motion.pressure_max, event.motion.pressure_min,
    1.93 +                     event.motion.cursor);
    1.94 +                break;
    1.95 +            case SDL_PROXIMITYIN:
    1.96 +                printf("proximity in id: %d x: %d y: %d\n",
    1.97 +                       (int) event.proximity.which, event.proximity.x,
    1.98 +                       event.proximity.y);
    1.99 +                break;
   1.100 +            case SDL_PROXIMITYOUT:
   1.101 +                printf("proximity out id: %d x: %d y: %d\n",
   1.102 +                       (int) event.proximity.which, event.proximity.x,
   1.103 +                       event.proximity.y);
   1.104 +                break;
   1.105 +            case SDL_MOUSEBUTTONDOWN:
   1.106 +                printf("mouse button down id: %d button:%d\n",
   1.107 +                       event.button.which, event.button.button);
   1.108 +                break;
   1.109 +            case SDL_MOUSEBUTTONUP:
   1.110 +                printf("mouse button up id: %d button: %d\n",
   1.111 +                       event.button.which, event.button.button);
   1.112 +                break;
   1.113 +            case SDL_QUIT:
   1.114 +                printf("Quitting\n");
   1.115 +                SDL_QuitSubSystem(SDL_INIT_VIDEO);
   1.116 +                SDL_Quit();
   1.117 +                quit = 1;
   1.118 +                break;
   1.119 +            }
   1.120 +        }
   1.121 +    }
   1.122 +    return 0;
   1.123  }
   1.124 -