Mercurial > sdl-ios-xcode
changeset 2427:32b9909db651 gsoc2008_iphone
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.
author | Holmes Futrell <hfutrell@umail.ucsb.edu> |
---|---|
date | Fri, 15 Aug 2008 00:46:58 +0000 |
parents | aad0c5ccf6bb |
children | 826210ef2c10 |
files | src/joystick/iphoneos/SDLUIAccelerationDelegate.m |
diffstat | 1 files changed, 11 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/joystick/iphoneos/SDLUIAccelerationDelegate.m Fri Aug 15 00:44:07 2008 +0000 +++ b/src/joystick/iphoneos/SDLUIAccelerationDelegate.m Fri Aug 15 00:46:58 2008 +0000 @@ -7,6 +7,7 @@ // #import "SDLUIAccelerationDelegate.h" +#import "../../../include/SDL_config_iphoneos.h" static SDLUIAccelerationDelegate *sharedDelegate=nil; @@ -32,21 +33,20 @@ -(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; }