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. gsoc2008_iphone
authorHolmes Futrell <hfutrell@umail.ucsb.edu>
Fri, 15 Aug 2008 00:46:58 +0000
branchgsoc2008_iphone
changeset 242732b9909db651
parent 2426 aad0c5ccf6bb
child 2428 826210ef2c10
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.
src/joystick/iphoneos/SDLUIAccelerationDelegate.m
     1.1 --- a/src/joystick/iphoneos/SDLUIAccelerationDelegate.m	Fri Aug 15 00:44:07 2008 +0000
     1.2 +++ b/src/joystick/iphoneos/SDLUIAccelerationDelegate.m	Fri Aug 15 00:46:58 2008 +0000
     1.3 @@ -7,6 +7,7 @@
     1.4  //
     1.5  
     1.6  #import "SDLUIAccelerationDelegate.h"
     1.7 +#import "../../../include/SDL_config_iphoneos.h"
     1.8  
     1.9  static SDLUIAccelerationDelegate *sharedDelegate=nil;
    1.10  
    1.11 @@ -32,21 +33,20 @@
    1.12  
    1.13  -(void)getLastOrientation:(Sint16 *)data {
    1.14  
    1.15 -#define MAX_G_FORCE 5.0
    1.16 -#define MAX_SINT16 0x7FFF	
    1.17 +	#define MAX_SINT16 0x7FFF	
    1.18  
    1.19 -	if (x > MAX_G_FORCE) x = MAX_G_FORCE;
    1.20 -	else if (x < -MAX_G_FORCE) x = -MAX_G_FORCE;
    1.21 +	if (x > SDL_IPHONE_MAX_GFORCE) x = SDL_IPHONE_MAX_GFORCE;
    1.22 +	else if (x < -SDL_IPHONE_MAX_GFORCE) x = -SDL_IPHONE_MAX_GFORCE;
    1.23  
    1.24 -	if (y > MAX_G_FORCE) y = MAX_G_FORCE;
    1.25 -	else if (y < -MAX_G_FORCE) y = -MAX_G_FORCE;
    1.26 +	if (y > SDL_IPHONE_MAX_GFORCE) y = SDL_IPHONE_MAX_GFORCE;
    1.27 +	else if (y < -SDL_IPHONE_MAX_GFORCE) y = -SDL_IPHONE_MAX_GFORCE;
    1.28  
    1.29 -	if (z > MAX_G_FORCE) z = MAX_G_FORCE;
    1.30 -	else if (z < -MAX_G_FORCE) z = -MAX_G_FORCE;
    1.31 +	if (z > SDL_IPHONE_MAX_GFORCE) z = SDL_IPHONE_MAX_GFORCE;
    1.32 +	else if (z < -SDL_IPHONE_MAX_GFORCE) z = -SDL_IPHONE_MAX_GFORCE;
    1.33  	
    1.34 -	data[0] = (x / MAX_G_FORCE) * MAX_SINT16;
    1.35 -	data[1] = (y / MAX_G_FORCE) * MAX_SINT16;
    1.36 -	data[2] = (z / MAX_G_FORCE) * MAX_SINT16;
    1.37 +	data[0] = (x / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16;
    1.38 +	data[1] = (y / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16;
    1.39 +	data[2] = (z / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16;
    1.40  
    1.41  }
    1.42