56431b6922
- updates all imports to prefix kivy_ios - adds basic `setup.py` file - adds a simple `toolchain.py` to the root folder for compat Makes it possible to install kivy-ios from PyPI: ``` pip install kivy-ios toolchain --help ``` Note the `rebuild_updated_recipes.py` is expected to fail as we moved all the recipes. This is a working, but unperfect iteration that come with limitations we would address in subsequent pull requests, such as: - the new usage is not yet documented - CI is not testing the source distribution creation and install - Continuous Delivery to PyPI is not in place - `toolchain` binary is a bit too generic name - we're still vendoring things under `tools/`
64 lines
1.7 KiB
Objective-C
64 lines
1.7 KiB
Objective-C
#import "bridge.h"
|
|
|
|
@implementation bridge
|
|
|
|
- (id) init {
|
|
if(self = [super init]) {
|
|
self.motionManager = [[CMMotionManager alloc] init];
|
|
queue = [[NSOperationQueue alloc] init];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)startAccelerometer {
|
|
|
|
if ([self.motionManager isAccelerometerAvailable] == YES) {
|
|
[self.motionManager startAccelerometerUpdatesToQueue:queue withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
|
|
self.ac_x = accelerometerData.acceleration.x;
|
|
self.ac_y = accelerometerData.acceleration.y;
|
|
self.ac_z = accelerometerData.acceleration.z;
|
|
}];
|
|
}
|
|
}
|
|
|
|
- (void)startGyroscope {
|
|
|
|
if ([self.motionManager isGyroAvailable] == YES) {
|
|
[self.motionManager startGyroUpdatesToQueue:queue withHandler:^(CMGyroData *gyroData, NSError *error) {
|
|
self.gy_x = gyroData.rotationRate.x;
|
|
self.gy_y = gyroData.rotationRate.y;
|
|
self.gy_z = gyroData.rotationRate.z;
|
|
}];
|
|
}
|
|
}
|
|
|
|
- (void)startMagnetometer {
|
|
|
|
if (self.motionManager.magnetometerAvailable) {
|
|
[self.motionManager startMagnetometerUpdatesToQueue:queue withHandler:^(CMMagnetometerData *magnetometerData, NSError *error) {
|
|
self.mg_x = magnetometerData.magneticField.x;
|
|
self.mg_y = magnetometerData.magneticField.y;
|
|
self.mg_z = magnetometerData.magneticField.z;
|
|
}];
|
|
}
|
|
}
|
|
|
|
- (void) stopAccelerometer {
|
|
[self.motionManager stopAccelerometerUpdates];
|
|
}
|
|
|
|
- (void) stopGyroscope {
|
|
[self.motionManager stopGyroUpdates];
|
|
}
|
|
|
|
- (void) stopMagnetometer {
|
|
[self.motionManager stopMagnetometerUpdates];
|
|
}
|
|
|
|
- (void) dealloc {
|
|
[self.motionManager release];
|
|
[queue release];
|
|
[super dealloc];
|
|
}
|
|
|
|
@end
|