From 79f2737cdf6388c5bdb059f62fed1632666e6c45 Mon Sep 17 00:00:00 2001 From: Holmes Futrell Date: Fri, 15 Aug 2008 00:46:58 +0000 Subject: [PATCH] changed macro MAX_G_FORCE to SDL_IPHONE_MAX_GFORCE and moved it to the SDL_config_iphoneos.h file. This should allow users to convert between the Sint16 returned by polling the joystick and units of g-force, which better describe what is going on with the iPhone (and are what the iPhone OS actually gives you). This conversion wouldn't be necessary except that we'd need floating point to store everything as g-force. --- .../iphoneos/SDLUIAccelerationDelegate.m | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/joystick/iphoneos/SDLUIAccelerationDelegate.m b/src/joystick/iphoneos/SDLUIAccelerationDelegate.m index 6be4891ee..bb65eb9dd 100644 --- a/src/joystick/iphoneos/SDLUIAccelerationDelegate.m +++ b/src/joystick/iphoneos/SDLUIAccelerationDelegate.m @@ -7,6 +7,7 @@ // #import "SDLUIAccelerationDelegate.h" +#import "../../../include/SDL_config_iphoneos.h" static SDLUIAccelerationDelegate *sharedDelegate=nil; @@ -32,21 +33,20 @@ -(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAccelerat -(void)getLastOrientation:(Sint16 *)data { -#define MAX_G_FORCE 5.0 -#define MAX_SINT16 0x7FFF + #define MAX_SINT16 0x7FFF - if (x > MAX_G_FORCE) x = MAX_G_FORCE; - else if (x < -MAX_G_FORCE) x = -MAX_G_FORCE; + if (x > SDL_IPHONE_MAX_GFORCE) x = SDL_IPHONE_MAX_GFORCE; + else if (x < -SDL_IPHONE_MAX_GFORCE) x = -SDL_IPHONE_MAX_GFORCE; - if (y > MAX_G_FORCE) y = MAX_G_FORCE; - else if (y < -MAX_G_FORCE) y = -MAX_G_FORCE; + if (y > SDL_IPHONE_MAX_GFORCE) y = SDL_IPHONE_MAX_GFORCE; + else if (y < -SDL_IPHONE_MAX_GFORCE) y = -SDL_IPHONE_MAX_GFORCE; - if (z > MAX_G_FORCE) z = MAX_G_FORCE; - else if (z < -MAX_G_FORCE) z = -MAX_G_FORCE; + if (z > SDL_IPHONE_MAX_GFORCE) z = SDL_IPHONE_MAX_GFORCE; + else if (z < -SDL_IPHONE_MAX_GFORCE) z = -SDL_IPHONE_MAX_GFORCE; - data[0] = (x / MAX_G_FORCE) * MAX_SINT16; - data[1] = (y / MAX_G_FORCE) * MAX_SINT16; - data[2] = (z / MAX_G_FORCE) * MAX_SINT16; + data[0] = (x / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16; + data[1] = (y / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16; + data[2] = (z / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16; }