-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Objective-C polyfills for events that cannot be used through sw…
…ift alone
- Loading branch information
Showing
7 changed files
with
185 additions
and
6 deletions.
There are no files selected for viewing
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
41 changes: 41 additions & 0 deletions
41
HelloMyoSwift.xcworkspace/xcshareddata/HelloMyoSwift.xccheckout
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,41 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDESourceControlProjectFavoriteDictionaryKey</key> | ||
<false/> | ||
<key>IDESourceControlProjectIdentifier</key> | ||
<string>FD45879A-1C50-439F-8095-ECAADA55F90F</string> | ||
<key>IDESourceControlProjectName</key> | ||
<string>HelloMyoSwift</string> | ||
<key>IDESourceControlProjectOriginsDictionary</key> | ||
<dict> | ||
<key>C5799279B946F5200577EF4B07E5197F26088DCB</key> | ||
<string>github.com:yagudaev/HelloMyoSwift.git</string> | ||
</dict> | ||
<key>IDESourceControlProjectPath</key> | ||
<string>HelloMyoSwift.xcworkspace</string> | ||
<key>IDESourceControlProjectRelativeInstallPathDictionary</key> | ||
<dict> | ||
<key>C5799279B946F5200577EF4B07E5197F26088DCB</key> | ||
<string>..</string> | ||
</dict> | ||
<key>IDESourceControlProjectURL</key> | ||
<string>github.com:yagudaev/HelloMyoSwift.git</string> | ||
<key>IDESourceControlProjectVersion</key> | ||
<integer>111</integer> | ||
<key>IDESourceControlProjectWCCIdentifier</key> | ||
<string>C5799279B946F5200577EF4B07E5197F26088DCB</string> | ||
<key>IDESourceControlProjectWCConfigurations</key> | ||
<array> | ||
<dict> | ||
<key>IDESourceControlRepositoryExtensionIdentifierKey</key> | ||
<string>public.vcs.git</string> | ||
<key>IDESourceControlWCCIdentifierKey</key> | ||
<string>C5799279B946F5200577EF4B07E5197F26088DCB</string> | ||
<key>IDESourceControlWCCName</key> | ||
<string>HelloMyoSwift</string> | ||
</dict> | ||
</array> | ||
</dict> | ||
</plist> |
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
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,48 @@ | ||
// | ||
// GLKitPolyfill.h | ||
// HelloMyoSwift | ||
// | ||
// Created by Michael Yagudaev on 2014-10-26. | ||
// Copyright (c) 2014 Michael Yagudaev. All rights reserved. | ||
// | ||
|
||
#ifndef HelloMyoSwift_GLKitPolyfill_h | ||
#define HelloMyoSwift_GLKitPolyfill_h | ||
|
||
#import <MyoKit/MyoKit.h> | ||
|
||
@interface AccelerationData: NSObject | ||
@property (nonatomic) float magnitude; | ||
@property (nonatomic) float x; | ||
@property (nonatomic) float y; | ||
@property (nonatomic) float z; | ||
@end | ||
|
||
@implementation AccelerationData | ||
@end | ||
|
||
@interface OrientationData: NSObject | ||
@property (nonatomic) TLMAngle *pitch; | ||
@property (nonatomic) TLMAngle *yaw; | ||
@property (nonatomic) TLMAngle *roll; | ||
@end | ||
|
||
@implementation OrientationData | ||
@end | ||
|
||
@interface GyroData: NSObject | ||
@property (nonatomic) float x; | ||
@property (nonatomic) float y; | ||
@property (nonatomic) float z; | ||
@end | ||
|
||
@implementation GyroData | ||
@end | ||
|
||
@interface GLKitPolyfill: NSObject | ||
+ (AccelerationData *) getAcceleration:(TLMAccelerometerEvent *)accelerometerEvent; | ||
+ (OrientationData *) getOrientation:(TLMOrientationEvent *)orientationEvent; | ||
+ (GyroData *) getGyro:(TLMGyroscopeEvent *)gyroEvent; | ||
@end | ||
|
||
#endif |
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,50 @@ | ||
// | ||
// GLKitPolyfill.m | ||
// HelloMyoSwift | ||
// | ||
// Created by Michael Yagudaev on 2014-10-26. | ||
// Copyright (c) 2014 Michael Yagudaev. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "GLKitPolyfill.h" | ||
|
||
@implementation GLKitPolyfill | ||
|
||
+ (AccelerationData *) getAcceleration:(TLMAccelerometerEvent *)accelerometerEvent { | ||
AccelerationData *result = [AccelerationData new]; | ||
|
||
// Get the acceleration vector from the accelerometer event. | ||
GLKVector3 accelerationVector = accelerometerEvent.vector; | ||
|
||
// Calculate the magnitude of the acceleration vector. | ||
result.magnitude = GLKVector3Length(accelerationVector); | ||
result.x = accelerationVector.x; | ||
result.y = accelerationVector.y; | ||
result.z = accelerationVector.z; | ||
|
||
return result; | ||
} | ||
|
||
+ (OrientationData *) getOrientation:(TLMOrientationEvent *)orientationEvent { | ||
TLMEulerAngles *angles = [TLMEulerAngles anglesWithQuaternion:orientationEvent.quaternion]; | ||
|
||
OrientationData *result = [OrientationData new]; | ||
result.pitch = angles.pitch; | ||
result.yaw = angles.yaw; | ||
result.roll = angles.roll; | ||
|
||
return result; | ||
} | ||
|
||
+ (GyroData *) getGyro:(TLMGyroscopeEvent *)gyroEvent { | ||
GLKVector3 vector = gyroEvent.vector; | ||
GyroData *result = [GyroData new]; | ||
result.x = vector.x; | ||
result.y = vector.y; | ||
result.z = vector.z; | ||
|
||
return result; | ||
} | ||
|
||
@end |
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
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 |
---|---|---|
|
@@ -10,5 +10,6 @@ | |
#define HelloMyoSwift_bridge_h | ||
|
||
#import <MyoKit/MyoKit.h> | ||
#import "HelloMyoSwift/GLKitPolyfill.h" | ||
|
||
#endif |