src/joystick/iphoneos/SDLUIAccelerationDelegate.m
branchgsoc2008_iphone
changeset 2427 32b9909db651
parent 2362 44fc2537ff9e
child 2439 78bddf0c0fa2
equal deleted inserted replaced
2426:aad0c5ccf6bb 2427:32b9909db651
     5 //  Created by Holmes Futrell on 6/21/08.
     5 //  Created by Holmes Futrell on 6/21/08.
     6 //  Copyright 2008 __MyCompanyName__. All rights reserved.
     6 //  Copyright 2008 __MyCompanyName__. All rights reserved.
     7 //
     7 //
     8 
     8 
     9 #import "SDLUIAccelerationDelegate.h"
     9 #import "SDLUIAccelerationDelegate.h"
       
    10 #import "../../../include/SDL_config_iphoneos.h"
    10 
    11 
    11 static SDLUIAccelerationDelegate *sharedDelegate=nil;
    12 static SDLUIAccelerationDelegate *sharedDelegate=nil;
    12 
    13 
    13 @implementation SDLUIAccelerationDelegate
    14 @implementation SDLUIAccelerationDelegate
    14 
    15 
    30 	
    31 	
    31 }
    32 }
    32 
    33 
    33 -(void)getLastOrientation:(Sint16 *)data {
    34 -(void)getLastOrientation:(Sint16 *)data {
    34 
    35 
    35 #define MAX_G_FORCE 5.0
    36 	#define MAX_SINT16 0x7FFF	
    36 #define MAX_SINT16 0x7FFF	
       
    37 
    37 
    38 	if (x > MAX_G_FORCE) x = MAX_G_FORCE;
    38 	if (x > SDL_IPHONE_MAX_GFORCE) x = SDL_IPHONE_MAX_GFORCE;
    39 	else if (x < -MAX_G_FORCE) x = -MAX_G_FORCE;
    39 	else if (x < -SDL_IPHONE_MAX_GFORCE) x = -SDL_IPHONE_MAX_GFORCE;
    40 
    40 
    41 	if (y > MAX_G_FORCE) y = MAX_G_FORCE;
    41 	if (y > SDL_IPHONE_MAX_GFORCE) y = SDL_IPHONE_MAX_GFORCE;
    42 	else if (y < -MAX_G_FORCE) y = -MAX_G_FORCE;
    42 	else if (y < -SDL_IPHONE_MAX_GFORCE) y = -SDL_IPHONE_MAX_GFORCE;
    43 
    43 
    44 	if (z > MAX_G_FORCE) z = MAX_G_FORCE;
    44 	if (z > SDL_IPHONE_MAX_GFORCE) z = SDL_IPHONE_MAX_GFORCE;
    45 	else if (z < -MAX_G_FORCE) z = -MAX_G_FORCE;
    45 	else if (z < -SDL_IPHONE_MAX_GFORCE) z = -SDL_IPHONE_MAX_GFORCE;
    46 	
    46 	
    47 	data[0] = (x / MAX_G_FORCE) * MAX_SINT16;
    47 	data[0] = (x / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16;
    48 	data[1] = (y / MAX_G_FORCE) * MAX_SINT16;
    48 	data[1] = (y / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16;
    49 	data[2] = (z / MAX_G_FORCE) * MAX_SINT16;
    49 	data[2] = (z / SDL_IPHONE_MAX_GFORCE) * MAX_SINT16;
    50 
    50 
    51 }
    51 }
    52 
    52 
    53 -(id)init {
    53 -(id)init {
    54 
    54