Created
February 20, 2017 19:42
-
-
Save jmenter/9797e4dc0952219d3f875fe2d77f3b1b to your computer and use it in GitHub Desktop.
Fake accelerometer data from iOS Simulator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (CMAcceleration)platformSpecificAcceleration; | |
{ | |
CMAcceleration acceleration = self.motionManager.accelerometerData.acceleration; | |
#if (TARGET_OS_SIMULATOR) | |
acceleration = (CMAcceleration){ | |
UIDevice.currentDevice.orientation == UIDeviceOrientationLandscapeLeft ? -1.f : | |
UIDevice.currentDevice.orientation == UIDeviceOrientationLandscapeRight ? 1.f : 0.f, | |
UIDevice.currentDevice.orientation == UIDeviceOrientationPortrait ? -1.f : | |
UIDevice.currentDevice.orientation == UIDeviceOrientationPortraitUpsideDown ? 1.f : 0.f, 0.f}; | |
#endif | |
return acceleration; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment