Detect start of tap on direction arrows like AVPlayerViewController

When AVPlayerViewController plays a video it does a neat thing when the video is paused. If you put your finger on the touch pad of the remote at the right hand side it shows the jump forward 10 seconds icon. Similarly just touch the left and it shows the jump back icon, and touch the top it shows the info button. (Touch means put finger on the touch surface, don't then release it (tap) or push harder and release (click))


How does it do this?!


As far as I can tell using touchesBegan or pressesBegan there is no way to detect where a finger touches down on the surface until it has touched back up. Then both the began and end events are fired. Using a tap gesture recognizer also only gets fired after the finger has left the surface.


How do you get notified when the user has just touched down on a virtual button? This seems like a critical feature if we want to give users a consistent ui experience - the touch down but don't tap or click is almost like a right click / peek / additional info (at least that seems to be how AVPlayerViewController is using it).

You can determine this by hooking into the GCController's microPad and polling the normalized touch positions.


Here are a few relevant parts:


@property (strong) GCController* gameController;
-(void)viewDidLoad
{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(gameControllerDidConnect:) name:GCControllerDidConnectNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(gameControllerDidDisconnect:) name:GCControllerDidDisconnectNotification object:nil];
    [GCController startWirelessControllerDiscoveryWithCompletionHandler:nil];
    [super viewDidLoad];
}

-(void)gameControllerDidConnect:(NSNotification *)notification
{
    if( notification.object != nil )
    { self.gameController = notification.object; }

    NSLog(@"gameControllerDidConnect");
}

//For me I have my code in an update loop, however you want to use, consume or pipe this into
// your app's needs is up to you, but at some point you can poll for this remote's touch point
// YOu can add additional logic like a particular state, or see if there is any touch prior to
// polling...  Or simply add it to a timerLoop and watch the values to see what it does
    if( self.gameController != nil )
    {
        GCMicroGamepad* microPad = self.gameController.microGamepad;
        if ( microPad != nil )
        {
            GCControllerDirectionPad *dpad= microPad.dpad;
             NSLog(@"[%f %f]", dpad.xAxis.value, dpad.yAxis.Value);
               //In your case test if   xAxis.value <= -0.5f (left hand side)
        }
    }
Detect start of tap on direction arrows like AVPlayerViewController
 
 
Q