forked from part-cw/lambdanative
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ROTATION: Add ios code and rename variables to be consistent
- Loading branch information
Showing
4 changed files
with
58 additions
and
25 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
modules/rotation/IOS_launcherappdelegate_didfinishlaunching
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Gyroscope | ||
if (motionmanager_needsinit) { | ||
motionManager = [[CMMotionManager alloc] init]; | ||
motionmanager_needsinit = 0; | ||
} | ||
|
||
if ([motionManager isDeviceMotionAvailable]) { | ||
[motionManager setDeviceMotionUpdateInterval: (1.0 / 50)]; | ||
[motionManager startDeviceMotionUpdatesToQueue: [NSOperationQueue mainQueue] withHandler: ^(CMDeviceMotion *motion, NSError *error) { | ||
[[NSUserDefaults standardUserDefaults] setValue: [NSNumber numberWithDouble: motion.attitude.quaternion.x] forKey: @"quaternion_x"]; | ||
[[NSUserDefaults standardUserDefaults] setValue: [NSNumber numberWithDouble: motion.attitude.quaternion.y] forKey: @"quaternion_y"]; | ||
[[NSUserDefaults standardUserDefaults] setValue: [NSNumber numberWithDouble: motion.attitude.quaternion.z] forKey: @"quaternion_z"]; | ||
[[NSUserDefaults standardUserDefaults] setValue: [NSNumber numberWithDouble: motion.attitude.quaternion.w] forKey: @"quaternion_w"]; | ||
[[NSUserDefaults standardUserDefaults] synchronize]; | ||
}]; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// attitude quaternion | ||
extern double ios_rot_getx() { | ||
NSNumber* x = [[NSUserDefaults standardUserDefaults] valueForKey:@"quaternion_x"]; | ||
return [x doubleValue]; | ||
} | ||
extern double ios_rot_gety() { | ||
NSNumber* y = [[NSUserDefaults standardUserDefaults] valueForKey:@"quaternion_y"]; | ||
return [y doubleValue]; | ||
} | ||
extern double ios_rot_getz() { | ||
NSNumber* z = [[NSUserDefaults standardUserDefaults] valueForKey:@"quaternion_z"]; | ||
return [z doubleValue]; | ||
} | ||
extern double ios_rot_getw() { | ||
NSNumber* w = [[NSUserDefaults standardUserDefaults] valueForKey:@"quaternion_w"]; | ||
return [w doubleValue]; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<string>gyroscope</string> |
This file contains 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