Question

I'm trying to get my game working on Android. I've ported it with the free version of Apportable and it works quite well, but I haven't been able to implement the gyroscope feature.

CMMotionManager gets initialized but the motion updates never start (or at least handleDeviceMotion: never gets called). The motion manager's isAccelerometerActive property is always NO, but isAccelerometerAvailable is YES.

Using [NSOperationQueue mainQueue] doesn't help either.

This is how I initialize the motion manager:

self.motionManager = [[CMMotionManager alloc] init];
self.motionManager.gyroUpdateInterval = .2;

[self.motionManager startDeviceMotionUpdatesToQueue:[[NSOperationQueue alloc] init]
                                                withHandler:^(CMDeviceMotion *motion, NSError *error) {
                                                    dispatch_async(dispatch_get_main_queue(), ^{
                                                        [self handleDeviceMotion:motion];
                                                    });
                                                }];

It produces the following message to logcat:

E/Sensors (  507): HAL:ERR open file /sys/bus/iio/devices/iio:device0/dmp_event_int_on to write with error 2
E/Sensors (  507): HAL:ERR can't disable DMP event interrupt

I have no idea what this means... I'm testing the app on Asus Nexus 7.

Is there something special I need to do to use CoreMotion with Apportable?

Edit: Here's a simple test project I created to demonstrate the issue.

No correct solution

OTHER TIPS

CoreMotion should work with apportable. Here is a simplified initialization and usage paradigm that I've tested on a Nexus 7 (2012).

self.motionManager = [[CMMotionManager alloc] init];
[self.motionManager startDeviceMotionUpdates];

self.motionTimer = [NSTimer scheduledTimerWithTimeInterval:0.2 
    target:self 
    selector:@selector(handleDeviceMotion) 
    userInfo:nil 
    repeats:YES];

Instead of using startDeviceMotionUpdatesToQueue: withHandler: to process the motion events, try explicitly accessing the deviceMotion property in a handleDeviceMotion method which will be called by the repeating timer.

-(void) handleDeviceMotion {
    CMDeviceMotion *motion = [self.motionManager deviceMotion];
    // use motion data accordingly
}    

And don't forget to stop updates when you're done!

[self.motionManager stopDeviceMotionUpdates];

For this sort of device motion in particular, we had a fairly layered series of issues that I've (hopefully) resolved with the next SDK update. I've implemented yaw, pitch, and roll, and they seem to give relatively sane values. If you're still having issues, email sdk(@)apportable.com (delete the parens obviously) and mention me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top