Get orientation Siri Remote (or get notified of changes?)

I was looking for a way to check the current Siri Remote orientation or register for Siri Remote orientation changes, but I haven't found anything yet. Is it possible to do this (without resorting to the interpretation of raw gravity data)?

I figured out how to disable auto-orientation changes using "allowRotation" on "microGamepad". This is pretty cool!

+8
tvos orientation-changes apple-tv siri-remote
source share
1 answer

I have not seen the API either, but as you mentioned, you can poll gravity data, and I just wanted to post this code here if some find it useful. You can change this at your discretion, for example, determine the last orientation and compare it with the current one if you want to receive a callback.

//************************************************************** // Update loop portion to UIViewController //************************************************************** @property (strong) CADisplayLink *updateLoopTimer; self.updateLoopTimer = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateRefreshRate:)]; [self.updateLoopTimer addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; -(void)updateRefreshRate:(CADisplayLink *)displayLink { CFTimeInterval deltaTime = displayLink.duration * displayLink.frameInterval; [self update:(float)deltaTime]; } //****************************************************** // Update loop //****************************************************** -(void)update:(float)dt { #ifdef TV //*************************************** // Detect button presses //*************************************** //self.gameControler = [[GCController controllers] firstObject]; if( self.gameController != nil ) { GCMicroGamepad* microPad = self.gameController.microGamepad; if ( microPad != nil ) { GCMotion *motion = self.gameController.motion; GCControllerDirectionPad *dpad = microPad.dpad; if( motion != nil ) { GCAcceleration accelVector = motion.gravity; if( fabs(accelVector.x) > fabs(accelVector.y) ) { NSLog(@"Sideways"); } else { NSLog(@"Upright"); } } } } #endif } 
+1
source share

All Articles