Get Siri Remote orientation (or get notifications of change?)
Asked Answered
P

1

8

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

I've have found out how to disable auto-orientation changes with "allowsRotation" on "microGamepad". Which is pretty cool!

Pyuria answered 16/12, 2015 at 18:14 Comment(3)
I was just at an Apple TV tech talk yesterday that was hosted by the Apple TV team @ Apple. They did mention detecting orientation of the remote, though I don't remember if they showed any code.Scevor
Oh man, I was at the tech talk in Austin. I thought they said something about detecting orientation too. I remember a slide saying something about "portrait, landscape, and landscape flipped". But I can't find any references to it online.Pyuria
Closest thing I can find is: Using the Apple TV Remote as a Game Controller. The remote can be used in either a portrait or landscape orientation. When you create your app, you decide whether the profile object flips the input data automatically when the user changes the remote orientation.Viol
C
1

I didn't see an API either, however as you mentioned, you can poll for the gravity data, and I just wanted to post that code here in case some find it useful. You can modify this to your own need, such as detecting last orientation and comparing it to current if you want a callback of the change.

    //**************************************************************
    // 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
}
Cryptonymous answered 1/2, 2016 at 2:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.