summaryrefslogtreecommitdiff
path: root/platform/iphone/app_delegate.mm
diff options
context:
space:
mode:
authorBastiaanOlij <mux213@gmail.com>2016-11-16 21:54:51 +1100
committerBastiaanOlij <mux213@gmail.com>2017-01-12 16:34:42 +1100
commitee98e06952555f140ffa9f3d18972760028cf87a (patch)
treed04a80fdb1f508a4fbb3a8446cd2d56ea2099dcb /platform/iphone/app_delegate.mm
parent51c60f7a49fad577f1c99ef0cf276933913a8b50 (diff)
Added gravity vector back into the accelerometer data and flipped Z on the gyro
Diffstat (limited to 'platform/iphone/app_delegate.mm')
-rw-r--r--platform/iphone/app_delegate.mm5
1 files changed, 4 insertions, 1 deletions
diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm
index 453ab85e3f..31e5e15e8d 100644
--- a/platform/iphone/app_delegate.mm
+++ b/platform/iphone/app_delegate.mm
@@ -203,8 +203,11 @@ static int frame_count = 0;
// Just using polling approach for now, we can set this up so it sends data to us in intervals, might be better.
// See Apple reference pages for more details:
// https://developer.apple.com/reference/coremotion/cmmotionmanager?language=objc
+
+ // Apple splits our accelerometer date into a gravity and user movement component. We add them back together
+ CMAcceleration gravity = motionManager.deviceMotion.gravity;
CMAcceleration acceleration = motionManager.deviceMotion.userAcceleration;
- OSIPhone::get_singleton()->update_accelerometer(acceleration.x, acceleration.y, acceleration.z);
+ OSIPhone::get_singleton()->update_accelerometer(acceleration.x + gravity.x, acceleration.y + gravity.y, acceleration.z + gravity.z);
CMMagneticField magnetic = motionManager.deviceMotion.magneticField.field;
OSIPhone::get_singleton()->update_magnetometer(magnetic.x, magnetic.y, magnetic.z);