android - Apportable & CoreMotion -


i'm trying game working on android. i've ported free version of apportable , works quite well, haven't been able implement gyroscope feature.

cmmotionmanager gets initialized motion updates never start (or @ least handledevicemotion: never gets called). motion manager's isaccelerometeractive property no, isaccelerometeravailable yes.

using [nsoperationqueue mainqueue] doesn't either.

this how initialize 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 following message logcat:

e/sensors (  507): hal:err open file /sys/bus/iio/devices/iio:device0/dmp_event_int_on write error 2 e/sensors (  507): hal:err can't disable dmp event interrupt 

i have no idea means... i'm testing app on asus nexus 7.

is there special need use coremotion apportable?

edit: here's simple test project created demonstrate issue.

coremotion should work apportable. here simplified initialization , usage paradigm i've tested on 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: process motion events, try explicitly accessing devicemotion property in handledevicemotion method called repeating timer.

-(void) handledevicemotion {     cmdevicemotion *motion = [self.motionmanager devicemotion];     // use motion data accordingly }     

and don't forget stop updates when you're done!

[self.motionmanager stopdevicemotionupdates]; 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -