Browse Source

Merge pull request #354 from blackberry-gaming/next-setaylor

Next setaylor
Sean Paul Taylor 13 years ago
parent
commit
b5be171b2b

+ 2 - 2
gameplay/src/PlatformMacOSX.mm

@@ -251,8 +251,8 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
     if (__rightMouseDown)
     {
         // Update the pitch and roll by adding the scaled deltas.
-        __roll += -(float)(point.x - __lx) * ACCELEROMETER_FACTOR_X;
-        __pitch -= (float)(point.y - (WINDOW_HEIGHT - __ly)) * ACCELEROMETER_FACTOR_Y;
+        __roll += (float)(point.x - __lx) * ACCELEROMETER_FACTOR_X;
+        __pitch -= -(float)(point.y - (WINDOW_HEIGHT - __ly)) * ACCELEROMETER_FACTOR_Y;
     
         // Clamp the values to the valid range.
         __roll = max(min(__roll, 90.0f), -90.0f);

+ 16 - 7
gameplay/src/PlatformQNX.cpp

@@ -1046,13 +1046,22 @@ void Platform::getAccelerometerValues(float* pitch, float* roll)
     double tx, ty, tz;
     accelerometer_read_forces(&tx, &ty, &tz);
 
-    // Hack landscape adjustment only.
-    if (__orientationAngle == 0)
-    {
-        tx = -tx;
-        ty = -ty;
-        tz = -tz;
-    }
+    if (__orientationAngle == 90)
+	{
+		tx = -ty;
+		ty = tx;
+	}
+	else if (__orientationAngle == 180)
+	{
+		tx = -tx;
+		ty = -ty;
+		tz = -tz;
+	}
+	else if (__orientationAngle == 270)
+	{
+		tx = ty;
+		ty = -tx;
+	}
 
     if (pitch != NULL)
         *pitch = atan(ty / sqrt(tx * tx + tz * tz)) * 180.0f * M_1_PI;

+ 4 - 4
gameplay/src/PlatformWin32.cpp

@@ -332,7 +332,7 @@ LRESULT CALLBACK __WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
         break;
 
     case WM_MOUSEMOVE:
-    {
+    {
         int x = GET_X_LPARAM(lParam);
         int y = GET_Y_LPARAM(lParam);
 
@@ -348,8 +348,8 @@ LRESULT CALLBACK __WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 			else if ((wParam & MK_RBUTTON) == MK_RBUTTON)
 			{
 				// Update the pitch and roll by adding the scaled deltas.
-				__roll += -(float)(x - lx) * ACCELEROMETER_X_FACTOR;
-				__pitch += (float)(y - ly) * ACCELEROMETER_Y_FACTOR;
+				__roll += (float)(x - lx) * ACCELEROMETER_X_FACTOR;
+				__pitch += -(float)(y - ly) * ACCELEROMETER_Y_FACTOR;
 
 				// Clamp the values to the valid range.
 				__roll = max(min(__roll, 90.0f), -90.0f);
@@ -359,7 +359,7 @@ LRESULT CALLBACK __WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 				lx = x;
 				ly = y;
 			}
-		}
+		}
         break;
     }
 

+ 6 - 5
gameplay/src/PlatformiOS.mm

@@ -460,17 +460,18 @@ int getKey(unichar keyCode);
     return YES;
 }
 
-- (void)getAccelerometerPitch:(float *)pitch roll:(float *)roll 
+- (void)getAccelerometerPitch:(float*)pitch roll:(float*)roll 
 {
     float p = 0.0f;
     float r = 0.0f;
-    CMAccelerometerData *accelerometerData = motionManager.accelerometerData;
+    CMAccelerometerData* accelerometerData = motionManager.accelerometerData;
     if(accelerometerData != nil) 
     {
         float tx, ty, tz;
-        tx = accelerometerData.acceleration.y;
-        ty = -accelerometerData.acceleration.x;
-        tz = -accelerometerData.acceleration.z;      
+        tx = -accelerometerData.acceleration.y;
+        ty = accelerometerData.acceleration.x;
+        tz = accelerometerData.acceleration.z;  
+        
         p = atan(ty / sqrt(tx * tx + tz * tz)) * 180.0f * M_1_PI;
         r = atan(tx / sqrt(ty * ty + tz * tz)) * 180.0f * M_1_PI;     
     }