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