From bd379677a2beca71484401b666510b889ac12d7d Mon Sep 17 00:00:00 2001 From: Andrew Scagnelli Date: Tue, 23 Oct 2018 23:18:56 -0400 Subject: [PATCH] feat: updated menu button handling - on tapping menu once (or chording with LB/RB), behave as start/select/special - on doube-tapping menu, quit the stream --- .../StreamFrameViewController.m | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index f0c96b48..75fe0c1d 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -20,6 +20,8 @@ ControllerSupport *_controllerSupport; StreamManager *_streamMan; NSTimer *_inactivityTimer; + UITapGestureRecognizer *_menuGestureRecognizer; + UITapGestureRecognizer *_menuDoubleTapGestureRecognizer; } - (void)viewDidAppear:(BOOL)animated @@ -31,6 +33,15 @@ #endif } +#ifdef TARGET_OS_TV +- (void)controllerPauseButtonPressed:(id)sender { } +- (void)controllerPauseButtonDoublePressed:(id)sender { + Log(LOG_I, @"Menu double-pressed -- backing out of stream"); + [self returnToMainFrame]; +} +#endif + + - (void)viewDidLoad { [super viewDidLoad]; @@ -46,6 +57,21 @@ _controllerSupport = [[ControllerSupport alloc] initWithConfig:self.streamConfig]; _inactivityTimer = nil; +#if TARGET_OS_TV + if (!_menuGestureRecognizer || !_menuDoubleTapGestureRecognizer) { + _menuGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonPressed:)]; + _menuGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)]; + + _menuDoubleTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(controllerPauseButtonDoublePressed:)]; + _menuDoubleTapGestureRecognizer.numberOfTapsRequired = 2; + [_menuGestureRecognizer requireGestureRecognizerToFail:_menuDoubleTapGestureRecognizer]; + _menuDoubleTapGestureRecognizer.allowedPressTypes = @[@(UIPressTypeMenu)]; + } + + [self.view addGestureRecognizer:_menuGestureRecognizer]; + [self.view addGestureRecognizer:_menuDoubleTapGestureRecognizer]; +#endif + _streamMan = [[StreamManager alloc] initWithConfig:self.streamConfig renderView:self.view connectionCallbacks:self];