test/testmmousetablet.c
author Szymon Wilczek <kazeuser@gmail.com>
Wed, 27 Aug 2008 13:37:19 +0000
changeset 2734 dd25eabe441c
child 2736 ae653575d4af
permissions -rw-r--r--
Many mouse and tablet linux test file added
kazeuser@2734
     1
#include <stdio.h>
kazeuser@2734
     2
#include "SDL.h"
kazeuser@2734
     3
kazeuser@2734
     4
SDL_Surface* screen;
kazeuser@2734
     5
int quit=0;
kazeuser@2734
     6
kazeuser@2734
     7
int main()
kazeuser@2734
     8
{
kazeuser@2734
     9
	SDL_Event event;
kazeuser@2734
    10
	int mice;
kazeuser@2734
    11
	int i;
kazeuser@2734
    12
	printf("Initing...\n");
kazeuser@2734
    13
	if (SDL_Init(0)!=0) {
kazeuser@2734
    14
		return 1;
kazeuser@2734
    15
    	}
kazeuser@2734
    16
	if (SDL_InitSubSystem(SDL_INIT_VIDEO)!=0) {
kazeuser@2734
    17
		return 1;
kazeuser@2734
    18
	}
kazeuser@2734
    19
	else {
kazeuser@2734
    20
		screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF);
kazeuser@2734
    21
      	}
kazeuser@2734
    22
	mice = SDL_GetNumMice();
kazeuser@2734
    23
	printf("%d pointing devices found\n", mice);
kazeuser@2734
    24
	for(i=0; i<mice; ++i) {
kazeuser@2734
    25
		printf("device index: %d name:%s\n",i,SDL_GetMouseName(i));
kazeuser@2734
    26
	}
kazeuser@2734
    27
	while(quit!=1) {
kazeuser@2734
    28
		if(SDL_PollEvent(&event)==0) {}
kazeuser@2734
    29
		else {
kazeuser@2734
    30
			switch (event.type) {
kazeuser@2734
    31
				case SDL_MOUSEMOTION:
kazeuser@2734
    32
					printf("Device id: %d x: %d y: %d relx: %d rely: %d pressure: %d\n \
kazeuser@2734
    33
					pressure_max: %d pressure_min: %d current cursor:%d\n", event.motion.which, event.motion.x,\
kazeuser@2734
    34
				       	event.motion.y, event.motion.xrel, event.motion.yrel, event.motion.pressure, event.motion.pressure_max,\
kazeuser@2734
    35
				       	event.motion.pressure_min, event.motion.cursor);
kazeuser@2734
    36
				break;
kazeuser@2734
    37
				case SDL_PROXIMITYIN:
kazeuser@2734
    38
					printf("proximity in id: %d x: %d y: %d\n", (int) event.proximity.which, event.proximity.x, event.proximity.y);
kazeuser@2734
    39
				break;
kazeuser@2734
    40
				case SDL_PROXIMITYOUT:
kazeuser@2734
    41
					printf("proximity out id: %d x: %d y: %d\n", (int) event.proximity.which, event.proximity.x, event.proximity.y);
kazeuser@2734
    42
				break;
kazeuser@2734
    43
				case SDL_MOUSEBUTTONDOWN:
kazeuser@2734
    44
					printf("mouse button down id: %d button:%d\n", event.button.which, event.button.button);
kazeuser@2734
    45
				break;
kazeuser@2734
    46
				case SDL_MOUSEBUTTONUP:
kazeuser@2734
    47
					printf("mouse button up id: %d button: %d\n", event.button.which, event.button.button);
kazeuser@2734
    48
				break;
kazeuser@2734
    49
				case SDL_QUIT:
kazeuser@2734
    50
					printf("Quitting\n");
kazeuser@2734
    51
					SDL_QuitSubSystem(SDL_INIT_VIDEO);
kazeuser@2734
    52
					SDL_Quit();
kazeuser@2734
    53
					quit=1;
kazeuser@2734
    54
				break;
kazeuser@2734
    55
			}
kazeuser@2734
    56
		}
kazeuser@2734
    57
	}
kazeuser@2734
    58
	return 0;
kazeuser@2734
    59
}
kazeuser@2734
    60