Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable external display support on iPad by allowing the OS to control the window shape and size. #608

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Limelight/Input/OnScreenControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef NS_ENUM(NSInteger, OnScreenControlsLevel) {
- (BOOL) handleTouchMovedEvent:(NSSet*)touches;
- (void) setLevel:(OnScreenControlsLevel)level;
- (OnScreenControlsLevel) getLevel;
- (void) transitionStreamViewSize;
- (void) show;

@end
16 changes: 16 additions & 0 deletions Limelight/Input/OnScreenControls.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ - (OnScreenControlsLevel) getLevel {
return _level;
}

- (void)transitionStreamViewSize {
_controlArea = CGRectMake(0, 0, _view.frame.size.width, _view.frame.size.height);
if (_iPad)
{
// Cut down the control area on an iPad so the controls are more reachable
_controlArea.size.height = _view.frame.size.height / 2.0;
_controlArea.origin.y = _view.frame.size.height - _controlArea.size.height;
}
else
{
_controlArea.origin.x = _controlArea.size.width * EDGE_WIDTH;
_controlArea.size.width -= _controlArea.origin.x * 2;
}
[self updateControls];
}

- (void) updateControls {
switch (_level) {
case OnScreenControlsLevelOff:
Expand Down
1 change: 1 addition & 0 deletions Limelight/Input/StreamView.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
interactionDelegate:(id<UserInteractionDelegate>)interactionDelegate
config:(StreamConfiguration*)streamConfig;
- (void) showOnScreenControls;
- (void) refreshOnScreenControls;
- (OnScreenControlsLevel) getCurrentOscState;

#if !TARGET_OS_TV
Expand Down
6 changes: 6 additions & 0 deletions Limelight/Input/StreamView.m
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ - (void) showOnScreenControls {
#endif
}

- (void) refreshOnScreenControls {
#if !TARGET_OS_TV
[onScreenControls transitionStreamViewSize];
#endif
}

- (OnScreenControlsLevel) getCurrentOscState {
if (onScreenControls == nil) {
return OnScreenControlsLevelOff;
Expand Down
4 changes: 2 additions & 2 deletions Limelight/Limelight-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@
<array>
<string>armv7</string>
</array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
Expand All @@ -81,6 +79,8 @@
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
Expand Down
2 changes: 2 additions & 0 deletions Limelight/Stream/StreamManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

- (void) stopStream;

- (void) transitionStreamViewSize;

- (NSString*) getStatsOverlayText;

@end
11 changes: 9 additions & 2 deletions Limelight/Stream/StreamManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ @implementation StreamManager {
StreamConfiguration* _config;

UIView* _renderView;
VideoDecoderRenderer* _renderer;
id<ConnectionCallbacks> _callbacks;
Connection* _connection;
}
Expand Down Expand Up @@ -99,8 +100,8 @@ - (void)main {

// Initializing the renderer must be done on the main thread
dispatch_async(dispatch_get_main_queue(), ^{
VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc] initWithView:self->_renderView callbacks:self->_callbacks streamAspectRatio:(float)self->_config.width / (float)self->_config.height useFramePacing:self->_config.useFramePacing];
self->_connection = [[Connection alloc] initWithConfig:self->_config renderer:renderer connectionCallbacks:self->_callbacks];
self->_renderer = [[VideoDecoderRenderer alloc] initWithView:self->_renderView callbacks:self->_callbacks streamAspectRatio:(float)self->_config.width / (float)self->_config.height useFramePacing:self->_config.useFramePacing];
self->_connection = [[Connection alloc] initWithConfig:self->_config renderer:self->_renderer connectionCallbacks:self->_callbacks];
NSOperationQueue* opQueue = [[NSOperationQueue alloc] init];
[opQueue addOperation:self->_connection];
});
Expand All @@ -111,6 +112,12 @@ - (void) stopStream
[_connection terminate];
}

- (void) transitionStreamViewSize {
dispatch_async(dispatch_get_main_queue(), ^{
[self->_renderer reinitializeDisplayLayer];
});
}

- (BOOL) launchApp:(HttpManager*)hMan receiveSessionUrl:(NSString**)sessionUrl {
HttpResponse* launchResp = [[HttpResponse alloc] init];
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:launchResp withUrlRequest:[hMan newLaunchOrResumeRequest:@"launch" config:_config]]];
Expand Down
1 change: 1 addition & 0 deletions Limelight/Stream/VideoDecoderRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- (void)start;
- (void)stop;
- (void)setHdrMode:(BOOL)enabled;
- (void)reinitializeDisplayLayer;

- (int)submitDecodeBuffer:(unsigned char *)data length:(int)length bufferType:(int)bufferType decodeUnit:(PDECODE_UNIT)du;

Expand Down
7 changes: 7 additions & 0 deletions Limelight/ViewControllers/MainFrameViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,13 @@ - (void)viewSafeAreaInsetsDidChange {
[self adjustScrollViewForSafeArea:self->hostScrollView];
}

- (void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
NSLog(@"transitioning from %f to %f", hostScrollView.frame.size.height, size.height / 2);
hostScrollView.frame = CGRectMake(0, self.navigationController.navigationBar.frame.origin.y + self.navigationController.navigationBar.frame.size.height, size.width, size.height / 2);
[self updateHosts];
}

- (void)viewDidLoad
{
[super viewDidLoad];
Expand Down
7 changes: 7 additions & 0 deletions Limelight/ViewControllers/StreamFrameViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,13 @@ - (void)mousePresenceChanged {
#endif
}

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
_streamView.frame = CGRectMake(_streamView.frame.origin.x, _streamView.frame.origin.y, size.width, size.height);
[_streamView refreshOnScreenControls];
[_streamMan transitionStreamViewSize];
}

- (void) streamExitRequested {
Log(LOG_I, @"Gamepad combo requested stream exit");

Expand Down