mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-04-23 08:47:02 +00:00
@@ -15,18 +15,57 @@
|
||||
|
||||
self.parent = settings;
|
||||
|
||||
#if TARGET_OS_TV
|
||||
NSInteger _bitrate = [[NSUserDefaults standardUserDefaults] integerForKey:@"bitrate"];
|
||||
NSInteger _framerate = [[NSUserDefaults standardUserDefaults] integerForKey:@"framerate"];
|
||||
|
||||
if (_bitrate) {
|
||||
self.bitrate = [NSNumber numberWithInteger:_bitrate];
|
||||
} else {
|
||||
self.bitrate = [NSNumber numberWithInteger:20000];
|
||||
}
|
||||
|
||||
if (_framerate) {
|
||||
self.framerate = [NSNumber numberWithInteger:_framerate];
|
||||
} else {
|
||||
self.framerate = [NSNumber numberWithInteger:60];
|
||||
}
|
||||
|
||||
self.useHevc = [[NSUserDefaults standardUserDefaults] boolForKey:@"useHevc"] || NO;
|
||||
self.playAudioOnPC = [[NSUserDefaults standardUserDefaults] boolForKey:@"audioOnPC"] || NO;
|
||||
self.enableHdr = [[NSUserDefaults standardUserDefaults] boolForKey:@"enableHdr"] || NO;
|
||||
self.optimizeGames = [[NSUserDefaults standardUserDefaults] boolForKey:@"optimizeGames"] || YES;
|
||||
self.multiController = YES;
|
||||
NSInteger _screenSize = [[NSUserDefaults standardUserDefaults] integerForKey:@"streamResolution"];
|
||||
switch (_screenSize) {
|
||||
case 0:
|
||||
self.height = [NSNumber numberWithInteger:720];
|
||||
self.width = [NSNumber numberWithInteger:1280];
|
||||
break;
|
||||
case 2:
|
||||
self.height = [NSNumber numberWithInteger:2160];
|
||||
self.width = [NSNumber numberWithInteger:3840];
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
self.height = [NSNumber numberWithInteger:1080];
|
||||
self.width = [NSNumber numberWithInteger:1920];
|
||||
break;
|
||||
}
|
||||
#else
|
||||
self.bitrate = settings.bitrate;
|
||||
self.framerate = settings.framerate;
|
||||
self.height = settings.height;
|
||||
self.width = settings.width;
|
||||
self.onscreenControls = settings.onscreenControls;
|
||||
self.uniqueId = settings.uniqueId;
|
||||
self.streamingRemotely = settings.streamingRemotely;
|
||||
self.useHevc = settings.useHevc;
|
||||
self.multiController = settings.multiController;
|
||||
self.playAudioOnPC = settings.playAudioOnPC;
|
||||
self.enableHdr = settings.enableHdr;
|
||||
self.optimizeGames = settings.optimizeGames;
|
||||
self.multiController = settings.multiController;
|
||||
#endif
|
||||
self.onscreenControls = settings.onscreenControls;
|
||||
self.uniqueId = settings.uniqueId;
|
||||
self.streamingRemotely = settings.streamingRemotely;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,11 @@ static UIImage* noImage;
|
||||
noImage = [UIImage imageNamed:@"NoAppImage"];
|
||||
}
|
||||
|
||||
#if TARGET_OS_TV
|
||||
_appButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
#else
|
||||
_appButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
#endif
|
||||
[_appButton setBackgroundImage:noImage forState:UIControlStateNormal];
|
||||
[_appButton setContentEdgeInsets:UIEdgeInsetsMake(0, 4, 0, 4)];
|
||||
[_appButton sizeToFit];
|
||||
@@ -64,10 +68,12 @@ static UIImage* noImage;
|
||||
if ([_app.id isEqualToString:_app.host.currentGame]) {
|
||||
// Only create the app overlay if needed
|
||||
_appOverlay = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Play"]];
|
||||
#if !TARGET_OS_TV
|
||||
_appOverlay.layer.shadowColor = [UIColor blackColor].CGColor;
|
||||
_appOverlay.layer.shadowOffset = CGSizeMake(0, 0);
|
||||
_appOverlay.layer.shadowOpacity = 1;
|
||||
_appOverlay.layer.shadowRadius = 2.0;
|
||||
#endif
|
||||
|
||||
[self addSubview:_appOverlay];
|
||||
|
||||
@@ -91,8 +97,20 @@ static UIImage* noImage;
|
||||
// TODO: Improve no-app image detection
|
||||
if (!(appImage.size.width == 130.f && appImage.size.height == 180.f) && // GFE 2.0
|
||||
!(appImage.size.width == 628.f && appImage.size.height == 888.f)) { // GFE 3.0
|
||||
#if TARGET_OS_TV
|
||||
//custom image to do TvOS hover popup effect
|
||||
UIImageView *imageView = [[UIImageView alloc] initWithImage:appImage];
|
||||
imageView.userInteractionEnabled = YES;
|
||||
imageView.adjustsImageWhenAncestorFocused = YES;
|
||||
imageView.frame = CGRectMake(0, 0, 200, 265);
|
||||
[_appButton addSubview:imageView];
|
||||
|
||||
_appButton.frame = CGRectMake(0, 0, 200, 265);
|
||||
self.frame = CGRectMake(0, 0, 200, 265);
|
||||
#else
|
||||
_appButton.frame = CGRectMake(0, 0, appImage.size.width / 2, appImage.size.height / 2);
|
||||
self.frame = CGRectMake(0, 0, appImage.size.width / 2, appImage.size.height / 2);
|
||||
#endif
|
||||
_appOverlay.frame = CGRectMake(0, 0, self.frame.size.width / 2.f, self.frame.size.height / 4.f);
|
||||
_appOverlay.layer.shadowRadius = 4.0;
|
||||
[_appOverlay setCenter:CGPointMake(self.frame.size.width/2, self.frame.size.height/6)];
|
||||
@@ -107,18 +125,35 @@ static UIImage* noImage;
|
||||
|
||||
if (noAppImage) {
|
||||
_appLabel = [[UILabel alloc] init];
|
||||
CGFloat padding = 4.f;
|
||||
[_appLabel setFrame: CGRectMake(padding, padding, _appButton.frame.size.width - 2 * padding, _appButton.frame.size.height - 2 * padding)];
|
||||
[_appLabel setTextColor:[UIColor whiteColor]];
|
||||
[_appLabel setBaselineAdjustment:UIBaselineAdjustmentAlignCenters];
|
||||
[_appLabel setTextAlignment:NSTextAlignmentCenter];
|
||||
[_appLabel setLineBreakMode:NSLineBreakByWordWrapping];
|
||||
[_appLabel setNumberOfLines:0];
|
||||
[_appLabel setText:_app.name];
|
||||
#if TARGET_OS_TV
|
||||
[_appLabel setFont:[UIFont systemFontOfSize:16]];
|
||||
#endif
|
||||
[_appLabel setText:_app.name];
|
||||
[_appLabel setAdjustsFontSizeToFitWidth:YES];
|
||||
[_appLabel setFrame: CGRectMake(0, 0, 200, 265)];
|
||||
//custom image to do TvOS hover popup effect
|
||||
UIImageView *imageView = [[UIImageView alloc] initWithImage:appImage];
|
||||
imageView.userInteractionEnabled = YES;
|
||||
imageView.adjustsImageWhenAncestorFocused = YES;
|
||||
imageView.frame = CGRectMake(0, 0, 200, 265);
|
||||
UIGraphicsBeginImageContextWithOptions(_appLabel.frame.size, false, 0);
|
||||
[imageView.layer renderInContext:(UIGraphicsGetCurrentContext())];
|
||||
[_appLabel.layer renderInContext:(UIGraphicsGetCurrentContext())];
|
||||
UIImage *imageWithText = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
[imageView setImage:imageWithText];
|
||||
[_appButton addSubview:imageView];
|
||||
_appButton.frame = CGRectMake(0, 0, 200, 265);
|
||||
self.frame = CGRectMake(0, 0, 200, 265);
|
||||
#else
|
||||
CGFloat padding = 4.f;
|
||||
[_appLabel setFrame: CGRectMake(padding, padding, _appButton.frame.size.width - 2 * padding, _appButton.frame.size.height - 2 * padding)];
|
||||
[_appButton addSubview:_appLabel];
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,9 @@ static const int LABEL_DY = 20;
|
||||
|
||||
[_hostLabel setText:@"Add Host"];
|
||||
[_hostLabel sizeToFit];
|
||||
#if !TARGET_OS_TV
|
||||
_hostLabel.textColor = [UIColor whiteColor];
|
||||
#endif
|
||||
_hostLabel.center = CGPointMake(_hostButton.frame.origin.x + (_hostButton.frame.size.width / 2), _hostButton.frame.origin.y + _hostButton.frame.size.height + LABEL_DY);
|
||||
|
||||
UIImageView* addIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"AddComputerIcon"]];
|
||||
@@ -128,7 +130,9 @@ static const int LABEL_DY = 20;
|
||||
|
||||
- (void) updateContentsForHost:(TemporaryHost*)host {
|
||||
_hostLabel.text = _host.name;
|
||||
#if !TARGET_OS_TV
|
||||
_hostLabel.textColor = [UIColor whiteColor];
|
||||
#endif
|
||||
[_hostLabel sizeToFit];
|
||||
|
||||
switch (host.pairState) {
|
||||
@@ -142,7 +146,9 @@ static const int LABEL_DY = 20;
|
||||
_hostPairState.text = @"Paired";
|
||||
break;
|
||||
}
|
||||
#if !TARGET_OS_TV
|
||||
_hostPairState.textColor = [UIColor whiteColor];
|
||||
#endif
|
||||
[_hostPairState sizeToFit];
|
||||
|
||||
if (host.online) {
|
||||
|
||||
@@ -1001,9 +1001,8 @@ static NSMutableSet* hostList;
|
||||
cell.layer.shadowOpacity = 0.5f;
|
||||
cell.layer.shadowPath = shadowPath.CGPath;
|
||||
|
||||
cell.layer.borderWidth = 1;
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
cell.layer.borderWidth = 1;
|
||||
cell.layer.borderColor = [[UIColor colorWithRed:0 green:0 blue:0 alpha:0.3f] CGColor];
|
||||
cell.exclusiveTouch = YES;
|
||||
#endif
|
||||
@@ -1055,12 +1054,20 @@ static NSMutableSet* hostList;
|
||||
self.navigationController.navigationBar.topItem.rightBarButtonItem.enabled = YES;
|
||||
}
|
||||
|
||||
#if TARGET_OS_TV
|
||||
- (BOOL)canBecomeFocused {
|
||||
return YES;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator {
|
||||
|
||||
#if !TARGET_OS_TV
|
||||
if (context.nextFocusedView != nil) {
|
||||
[context.nextFocusedView setAlpha:0.8];
|
||||
}
|
||||
[context.previouslyFocusedView setAlpha:1.0];
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -12,7 +12,13 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#if TARGET_OS_TV
|
||||
@import GameController;
|
||||
|
||||
@interface StreamFrameViewController : GCEventViewController <ConnectionCallbacks, EdgeDetectionDelegate>
|
||||
#else
|
||||
@interface StreamFrameViewController : UIViewController <ConnectionCallbacks, EdgeDetectionDelegate>
|
||||
#endif
|
||||
@property (strong, nonatomic) IBOutlet UILabel *stageLabel;
|
||||
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *spinner;
|
||||
@property (nonatomic) StreamConfiguration* streamConfig;
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user