annotate XCodeiPhoneOS/Demos/src/accelerometer.c @ 2429:2c55b72ba46e gsoc2008_iphone

testdyngles is exactly what it sounds like -- a version of testdyngl that uses OpenGL ES calls instead of OpenGL. Was necessary to create because glOrtho is called glOrthof in OpenGL ES, and OpenGL ES doesn't have glBegin() type semantics for specifying geometry.
author Holmes Futrell <hfutrell@umail.ucsb.edu>
date Fri, 15 Aug 2008 00:52:52 +0000
parents ecc18fbfdec3
children
rev   line source
2380
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
1 /*
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
2 * accelerometer.c
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
3 * written by Holmes Futrell
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
4 * use however you want
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
5 */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
6
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
7 #include "SDL.h"
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
8 #include "math.h"
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
9 #include "common.h"
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
10
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
11 #define MILLESECONDS_PER_FRAME 16 /* about 60 frames per second */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
12 #define DAMPING 0.5f; /* after bouncing off a wall, damping coefficient determines final speed */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
13 #define FRICTION 0.0008f /* coefficient of acceleration that opposes direction of motion */
2424
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
14 #define GRAVITY_CONSTANT 0.004f /* how sensitive the ship is to the accelerometer */
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
15
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
16 /* If we aren't on an iPhone, then this definition ought to yield reasonable behavior */
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
17 #ifndef SDL_IPHONE_MAX_GFORCE
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
18 #define SDL_IPHONE_MAX_GFORCE 5.0f
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
19 #endif
2380
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
20
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
21 static SDL_Joystick *accelerometer; /* used for controlling the ship */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
22
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
23 static struct {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
24 float x, y; /* position of ship */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
25 float vx, vy; /* velocity of ship (in pixels per millesecond) */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
26 SDL_Rect rect; /* (drawn) position and size of ship */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
27 } ship;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
28
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
29 static SDL_TextureID shipID=0; /* texture for spaceship */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
30 static SDL_TextureID spaceID=0; /* texture for space (background */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
31
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
32 void render(void) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
33
2424
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
34
2380
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
35 /* get joystick (accelerometer) axis values and normalize them */
2424
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
36 float ax = SDL_JoystickGetAxis(accelerometer, 0);
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
37 float ay = -SDL_JoystickGetAxis(accelerometer, 1);
2380
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
38
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
39 /* ship screen constraints */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
40 Uint32 minx = 0.0f;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
41 Uint32 maxx = SCREEN_WIDTH - ship.rect.w;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
42 Uint32 miny = 0.0f;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
43 Uint32 maxy = SCREEN_HEIGHT - ship.rect.h;
2424
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
44
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
45 #define SINT16_MAX ((float)(0x7FFF))
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
46
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
47 /* update velocity from accelerometer
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
48 the factor SDL_IPHONE_MAX_G_FORCE / SINT16_MAX converts between
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
49 SDL's units reported from the joytick, and units of g-force, as reported by the accelerometer
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
50 */
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
51 ship.vx += ax * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT * MILLESECONDS_PER_FRAME;
ecc18fbfdec3 Added references to SDL_IPHONE_MAX_GFORCE ... that way this value can change without altering the demos behavior. More understandable too.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2380
diff changeset
52 ship.vy += ay * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT * MILLESECONDS_PER_FRAME;
2380
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
53
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
54 float speed = sqrt(ship.vx * ship.vx + ship.vy * ship.vy);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
55
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
56 if (speed > 0) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
57 /* compensate for friction */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
58 float dirx = ship.vx / speed; /* normalized x velocity */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
59 float diry = ship.vy / speed; /* normalized y velocity */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
60
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
61 /* update velocity due to friction */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
62 if (speed - FRICTION * MILLESECONDS_PER_FRAME > 0) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
63 /* apply friction */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
64 ship.vx -= dirx * FRICTION * MILLESECONDS_PER_FRAME;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
65 ship.vy -= diry * FRICTION * MILLESECONDS_PER_FRAME;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
66 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
67 else {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
68 /* applying friction would MORE than stop the ship, so just stop the ship */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
69 ship.vx = 0.0f;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
70 ship.vy = 0.0f;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
71 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
72 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
73
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
74 /* update ship location */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
75 ship.x += ship.vx * MILLESECONDS_PER_FRAME;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
76 ship.y += ship.vy * MILLESECONDS_PER_FRAME;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
77
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
78 if (ship.x > maxx) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
79 ship.x = maxx;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
80 ship.vx = -ship.vx * DAMPING;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
81 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
82 else if (ship.x < minx) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
83 ship.x = minx;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
84 ship.vx = -ship.vx * DAMPING;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
85 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
86 if (ship.y > maxy) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
87 ship.y = maxy;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
88 ship.vy = -ship.vy * DAMPING;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
89 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
90 else if (ship.y < miny) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
91 ship.y = miny;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
92 ship.vy = -ship.vy * DAMPING;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
93 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
94
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
95 /* draw the background */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
96 SDL_RenderCopy(spaceID, NULL, NULL);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
97
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
98 /* draw the ship */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
99 ship.rect.x = ship.x;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
100 ship.rect.y = ship.y;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
101
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
102 SDL_RenderCopy(shipID, NULL, &ship.rect);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
103
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
104 /* update screen */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
105 SDL_RenderPresent();
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
106
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
107 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
108
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
109 void initializeTextures() {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
110
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
111 SDL_Surface *bmp_surface;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
112 SDL_Surface *bmp_surface_rgba;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
113 int format = SDL_PIXELFORMAT_ABGR8888; /* desired texture format */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
114 Uint32 Rmask, Gmask, Bmask, Amask; /* masks for desired format */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
115 int bpp; /* bits per pixel for desired format */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
116
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
117 /* load the ship */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
118 bmp_surface = SDL_LoadBMP("ship.bmp");
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
119 if (bmp_surface == NULL) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
120 fatalError("could not ship.bmp");
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
121 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
122 /* set blue to transparent on the ship */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
123 SDL_SetColorKey(bmp_surface, 1, SDL_MapRGB(bmp_surface->format, 0, 0, 255));
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
124 SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
125 /*
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
126 create a new RGBA surface and blit the bmp to it
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
127 this is an extra step, but it seems to be necessary for the color key to work
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
128
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
129 does the fact that this is necessary indicate a bug in SDL?
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
130 */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
131 bmp_surface_rgba = SDL_CreateRGBSurface(0, bmp_surface->w, bmp_surface->h, bpp, Rmask, Gmask, Bmask, Amask);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
132 SDL_BlitSurface(bmp_surface, NULL, bmp_surface_rgba, NULL);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
133
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
134 /* create ship texture from surface */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
135 shipID = SDL_CreateTextureFromSurface(format, bmp_surface_rgba);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
136 if (shipID == 0) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
137 fatalError("could not create ship texture");
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
138 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
139 SDL_SetTextureBlendMode(shipID, SDL_TEXTUREBLENDMODE_BLEND);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
140
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
141 /* set the width and height of the ship from the surface dimensions */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
142 ship.rect.w = bmp_surface->w;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
143 ship.rect.h = bmp_surface->h;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
144
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
145 SDL_FreeSurface(bmp_surface_rgba);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
146 SDL_FreeSurface(bmp_surface);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
147
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
148 /* load the space background */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
149 bmp_surface = SDL_LoadBMP("space.bmp");
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
150 if (bmp_surface == NULL) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
151 fatalError("could not load space.bmp");
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
152 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
153 /* create space texture from surface */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
154 spaceID = SDL_CreateTextureFromSurface(format, bmp_surface);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
155 if (spaceID == 0) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
156 fatalError("could not create space texture");
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
157 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
158 SDL_FreeSurface(bmp_surface);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
159
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
160 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
161
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
162
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
163
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
164 int main(int argc, char *argv[]) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
165
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
166 SDL_WindowID windowID; /* ID of main window */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
167 Uint32 startFrame; /* time frame began to process */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
168 Uint32 endFrame; /* time frame ended processing */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
169 Uint32 delay; /* time to pause waiting to draw next frame */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
170 int done; /* should we clean up and exit? */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
171
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
172 /* initialize SDL */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
173 if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
174 fatalError("Could not initialize SDL");
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
175 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
176
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
177 /* create main window and renderer */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
178 windowID = SDL_CreateWindow(NULL, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,\
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
179 SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN|SDL_WINDOW_BORDERLESS);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
180 SDL_CreateRenderer(windowID, 0, 0);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
181
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
182 /* print out some info about joysticks and try to open accelerometer for use */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
183 printf("There are %d joysticks available\n", SDL_NumJoysticks());
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
184 printf("Default joystick (index 0) is %s\n", SDL_JoystickName(0));
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
185 accelerometer = SDL_JoystickOpen(0);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
186 if (accelerometer == NULL) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
187 fatalError("Could not open joystick (accelerometer)");
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
188 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
189 printf("joystick number of axis = %d\n", SDL_JoystickNumAxes(accelerometer));
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
190 printf("joystick number of hats = %d\n", SDL_JoystickNumHats(accelerometer));
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
191 printf("joystick number of balls = %d\n", SDL_JoystickNumBalls(accelerometer));
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
192 printf("joystick number of buttons = %d\n", SDL_JoystickNumButtons(accelerometer));
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
193
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
194 /* load graphics */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
195 initializeTextures();
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
196
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
197 /* setup ship */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
198 ship.x = (SCREEN_WIDTH - ship.rect.w) / 2;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
199 ship.y = (SCREEN_HEIGHT - ship.rect.h) / 2;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
200 ship.vx = 0.0f;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
201 ship.vy = 0.0f;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
202
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
203 done = 0;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
204 /* enter main loop */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
205 while(!done) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
206 startFrame = SDL_GetTicks();
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
207 SDL_Event event;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
208 while (SDL_PollEvent(&event)) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
209 if (event.type == SDL_QUIT) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
210 done = 1;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
211 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
212 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
213 render();
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
214 endFrame = SDL_GetTicks();
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
215
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
216 /* figure out how much time we have left, and then sleep */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
217 delay = MILLESECONDS_PER_FRAME - (endFrame - startFrame);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
218 if (delay < 0) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
219 delay = 0;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
220 } else if (delay > MILLESECONDS_PER_FRAME) {
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
221 delay = MILLESECONDS_PER_FRAME;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
222 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
223 SDL_Delay(delay);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
224 }
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
225
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
226 /* delete textures */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
227 SDL_DestroyTexture(shipID);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
228 SDL_DestroyTexture(spaceID);
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
229
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
230 /* shutdown SDL */
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
231 SDL_Quit();
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
232
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
233 return 0;
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
234
7fbcfc1574dc Demo of iPhone accelerometer as SDL joystick
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
235 }