mirror of
https://github.com/thes3m/XNI
synced 2024-12-26 13:26:06 +01:00
Completed Accelerometer support.
MediaPlayer stop corrected. git-svn-id: http://xni.googlecode.com/svn/XNI@61 ac433895-eea3-a490-d80a-17149a75e588
This commit is contained in:
parent
0dc35e2de2
commit
b212fc7d44
@ -7,10 +7,21 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "System.h"
|
||||
#import "Retronator.Devices.Sensors.classes.h"
|
||||
|
||||
@interface Accelerometer : NSObject {
|
||||
@interface Accelerometer : NSObject<UIAccelerometerDelegate> {
|
||||
SensorState state;
|
||||
|
||||
Event *readingChanged;
|
||||
}
|
||||
|
||||
@property (nonatomic, readonly) SensorState state;
|
||||
@property (nonatomic, readonly) Event *readingChanged;
|
||||
|
||||
- (void) start;
|
||||
- (void) stop;
|
||||
|
||||
@end
|
||||
|
@ -8,7 +8,49 @@
|
||||
|
||||
#import "Accelerometer.h"
|
||||
|
||||
#import "Retronator.Devices.Sensors.h"
|
||||
#import "AccelerometerReadingEventArgs+Internal.h"
|
||||
|
||||
@implementation Accelerometer
|
||||
|
||||
- (id) init
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
state = SensorStateInitializing;
|
||||
readingChanged = [[Event alloc] init];
|
||||
[UIAccelerometer sharedAccelerometer].updateInterval = 1.0/30.0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@synthesize state, readingChanged;
|
||||
|
||||
- (void) start {
|
||||
state = SensorStateReady;
|
||||
[UIAccelerometer sharedAccelerometer].delegate = self;
|
||||
}
|
||||
|
||||
- (void) stop {
|
||||
state = SensorStateDisabled;
|
||||
[UIAccelerometer sharedAccelerometer].delegate = nil;
|
||||
}
|
||||
|
||||
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)uiAcceleration
|
||||
{
|
||||
AccelerometerReadingEventArgs *eventArgs = [[[AccelerometerReadingEventArgs alloc] initWithTimestamp:uiAcceleration.timestamp
|
||||
x:uiAcceleration.x
|
||||
y:uiAcceleration.y
|
||||
z:uiAcceleration.z] autorelease];
|
||||
|
||||
[readingChanged raiseWithSender:self eventArgs:eventArgs];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[readingChanged release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
@ -0,0 +1,16 @@
|
||||
//
|
||||
// AccelerometerReadingEventArgs+Internal.h
|
||||
// XNI
|
||||
//
|
||||
// Created by Matej Jan on 15.2.11.
|
||||
// Copyright 2011 Retronator. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
@interface AccelerometerReadingEventArgs (Internal)
|
||||
|
||||
- (id) initWithTimestamp:(NSTimeInterval)timestampValue x:(double)xValue y:(double)yValue z:(double)zValue;
|
||||
|
||||
@end
|
@ -0,0 +1,21 @@
|
||||
//
|
||||
// AccelerometerReadingEventArgs.h
|
||||
// XNI
|
||||
//
|
||||
// Created by Matej Jan on 15.2.11.
|
||||
// Copyright 2011 Retronator. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "System.h"
|
||||
|
||||
@interface AccelerometerReadingEventArgs : EventArgs {
|
||||
NSTimeInterval timestamp;
|
||||
double x, y, z;
|
||||
}
|
||||
|
||||
@property (nonatomic, readonly) NSTimeInterval timestamp;
|
||||
@property (nonatomic, readonly) double x, y, z;
|
||||
|
||||
@end
|
@ -0,0 +1,33 @@
|
||||
//
|
||||
// AccelerometerReadingEventArgs.m
|
||||
// XNI
|
||||
//
|
||||
// Created by Matej Jan on 15.2.11.
|
||||
// Copyright 2011 Retronator. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AccelerometerReadingEventArgs.h"
|
||||
#import "AccelerometerReadingEventArgs+Internal.h"
|
||||
|
||||
@implementation AccelerometerReadingEventArgs
|
||||
|
||||
- (id) initWithTimestamp:(NSTimeInterval)timestampValue x:(double)xValue y:(double)yValue z:(double)zValue
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
timestamp = timestampValue;
|
||||
x = xValue;
|
||||
y = yValue;
|
||||
z = zValue;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@synthesize timestamp, x, y, z;
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end
|
@ -1,3 +1,3 @@
|
||||
#import "SensorsEnums.h"
|
||||
|
||||
@class Accelerometer;
|
||||
@class Accelerometer, AccelerometerReadingEventArgs;
|
@ -1,2 +1,4 @@
|
||||
#import "SensorsEnums.h"
|
||||
#import "Accelerometer.h"
|
||||
|
||||
#import "Accelerometer.h"
|
||||
#import "AccelerometerReadingEventArgs.h"
|
@ -182,8 +182,8 @@ static MediaPlayer *instance;
|
||||
return;
|
||||
}
|
||||
|
||||
[queue.activeSong.audioPlayer pause];
|
||||
queue.activeSong.audioPlayer.currentTime = 0;
|
||||
[queue.activeSong.audioPlayer stop];
|
||||
[self setMediaState:MediaStateStopped];
|
||||
|
||||
// The music stops, activate the ambient category again.
|
||||
|
@ -16,7 +16,6 @@
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
|
||||
[audioPlayer prepareToPlay];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -115,11 +115,14 @@
|
||||
B554FC9B12A45A9D00F20A0D /* VertexPositionNormalTextureArray.m in Sources */ = {isa = PBXBuildFile; fileRef = B554FC9912A45A9D00F20A0D /* VertexPositionNormalTextureArray.m */; };
|
||||
B554FC9E12A45B3300F20A0D /* VertexPositionNormalTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = B554FC9C12A45B3300F20A0D /* VertexPositionNormalTexture.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B554FC9F12A45B3300F20A0D /* VertexPositionNormalTexture.m in Sources */ = {isa = PBXBuildFile; fileRef = B554FC9D12A45B3300F20A0D /* VertexPositionNormalTexture.m */; };
|
||||
B562E6E7130ADB5400017D99 /* Retronator.Devices.Sensors.h in Headers */ = {isa = PBXBuildFile; fileRef = B562E6E6130ADB5400017D99 /* Retronator.Devices.Sensors.h */; };
|
||||
B562E6E9130ADB5D00017D99 /* Retronator.Devices.Sensors.classes.h in Headers */ = {isa = PBXBuildFile; fileRef = B562E6E8130ADB5D00017D99 /* Retronator.Devices.Sensors.classes.h */; };
|
||||
B562E6EC130ADB8900017D99 /* Accelerometer.h in Headers */ = {isa = PBXBuildFile; fileRef = B562E6EA130ADB8900017D99 /* Accelerometer.h */; };
|
||||
B562E6E7130ADB5400017D99 /* Retronator.Devices.Sensors.h in Headers */ = {isa = PBXBuildFile; fileRef = B562E6E6130ADB5400017D99 /* Retronator.Devices.Sensors.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B562E6E9130ADB5D00017D99 /* Retronator.Devices.Sensors.classes.h in Headers */ = {isa = PBXBuildFile; fileRef = B562E6E8130ADB5D00017D99 /* Retronator.Devices.Sensors.classes.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B562E6EC130ADB8900017D99 /* Accelerometer.h in Headers */ = {isa = PBXBuildFile; fileRef = B562E6EA130ADB8900017D99 /* Accelerometer.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B562E6ED130ADB8900017D99 /* Accelerometer.m in Sources */ = {isa = PBXBuildFile; fileRef = B562E6EB130ADB8900017D99 /* Accelerometer.m */; };
|
||||
B562E6EF130ADBD400017D99 /* SensorsEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = B562E6EE130ADBD400017D99 /* SensorsEnums.h */; };
|
||||
B562E6EF130ADBD400017D99 /* SensorsEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = B562E6EE130ADBD400017D99 /* SensorsEnums.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B562E781130ADFAB00017D99 /* AccelerometerReadingEventArgs.h in Headers */ = {isa = PBXBuildFile; fileRef = B562E77F130ADFAB00017D99 /* AccelerometerReadingEventArgs.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B562E782130ADFAB00017D99 /* AccelerometerReadingEventArgs.m in Sources */ = {isa = PBXBuildFile; fileRef = B562E780130ADFAB00017D99 /* AccelerometerReadingEventArgs.m */; };
|
||||
B562E784130AE18400017D99 /* AccelerometerReadingEventArgs+Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = B562E783130AE18400017D99 /* AccelerometerReadingEventArgs+Internal.h */; };
|
||||
B5672C6C129AFDCE00DE5AAC /* ModelMeshCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = B5672C6A129AFDCE00DE5AAC /* ModelMeshCollection.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
B5672C6D129AFDCE00DE5AAC /* ModelMeshCollection.m in Sources */ = {isa = PBXBuildFile; fileRef = B5672C6B129AFDCE00DE5AAC /* ModelMeshCollection.m */; };
|
||||
B5672C7A129AFE8500DE5AAC /* ModelMeshPartCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = B5672C78129AFE8500DE5AAC /* ModelMeshPartCollection.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
@ -524,6 +527,9 @@
|
||||
B562E6EA130ADB8900017D99 /* Accelerometer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Accelerometer.h; sourceTree = "<group>"; };
|
||||
B562E6EB130ADB8900017D99 /* Accelerometer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Accelerometer.m; sourceTree = "<group>"; };
|
||||
B562E6EE130ADBD400017D99 /* SensorsEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SensorsEnums.h; sourceTree = "<group>"; };
|
||||
B562E77F130ADFAB00017D99 /* AccelerometerReadingEventArgs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccelerometerReadingEventArgs.h; sourceTree = "<group>"; };
|
||||
B562E780130ADFAB00017D99 /* AccelerometerReadingEventArgs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AccelerometerReadingEventArgs.m; sourceTree = "<group>"; };
|
||||
B562E783130AE18400017D99 /* AccelerometerReadingEventArgs+Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AccelerometerReadingEventArgs+Internal.h"; sourceTree = "<group>"; };
|
||||
B5672C6A129AFDCE00DE5AAC /* ModelMeshCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModelMeshCollection.h; sourceTree = "<group>"; };
|
||||
B5672C6B129AFDCE00DE5AAC /* ModelMeshCollection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ModelMeshCollection.m; sourceTree = "<group>"; };
|
||||
B5672C78129AFE8500DE5AAC /* ModelMeshPartCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModelMeshPartCollection.h; sourceTree = "<group>"; };
|
||||
@ -946,6 +952,9 @@
|
||||
B562E6EE130ADBD400017D99 /* SensorsEnums.h */,
|
||||
B562E6EA130ADB8900017D99 /* Accelerometer.h */,
|
||||
B562E6EB130ADB8900017D99 /* Accelerometer.m */,
|
||||
B562E77F130ADFAB00017D99 /* AccelerometerReadingEventArgs.h */,
|
||||
B562E783130AE18400017D99 /* AccelerometerReadingEventArgs+Internal.h */,
|
||||
B562E780130ADFAB00017D99 /* AccelerometerReadingEventArgs.m */,
|
||||
);
|
||||
path = Sensors;
|
||||
sourceTree = "<group>";
|
||||
@ -1651,6 +1660,8 @@
|
||||
B562E6E9130ADB5D00017D99 /* Retronator.Devices.Sensors.classes.h in Headers */,
|
||||
B562E6EC130ADB8900017D99 /* Accelerometer.h in Headers */,
|
||||
B562E6EF130ADBD400017D99 /* SensorsEnums.h in Headers */,
|
||||
B562E781130ADFAB00017D99 /* AccelerometerReadingEventArgs.h in Headers */,
|
||||
B562E784130AE18400017D99 /* AccelerometerReadingEventArgs+Internal.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -1902,6 +1913,7 @@
|
||||
B507F87612E58AC300A7302B /* SongReader.m in Sources */,
|
||||
B507F8BD12E58E7000A7302B /* MediaQueue.m in Sources */,
|
||||
B562E6ED130ADB8900017D99 /* Accelerometer.m in Sources */,
|
||||
B562E782130ADFAB00017D99 /* AccelerometerReadingEventArgs.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user