Merge pull request #37 from xzzpig/ExternalScreen

Add support to change app size
This commit is contained in:
TrueZhuanJia authored and GitHub committed 2024-11-19 21:02:28 +08:00
commit ea89d0a822
11 files changed
+122 -22

No files matched your search

+2 -1
View File
@@ -42,7 +42,8 @@
// absoluteTouchMode:(BOOL)absoluteTouchMode // absoluteTouchMode:(BOOL)absoluteTouchMode
touchMode:(NSInteger)touchMode touchMode:(NSInteger)touchMode
statsOverlay:(BOOL)statsOverlay statsOverlay:(BOOL)statsOverlay
allowPortrait:(BOOL)allowPortrait; allowPortrait:(BOOL)allowPortrait
resolutionSelected:(NSInteger)resolutionSelected;
- (NSArray*) getHosts; - (NSArray*) getHosts;
- (void) updateHost:(TemporaryHost*)host; - (void) updateHost:(TemporaryHost*)host;
+3 -1
View File
@@ -81,7 +81,8 @@
// absoluteTouchMode:(BOOL)absoluteTouchMode // absoluteTouchMode:(BOOL)absoluteTouchMode
touchMode:(NSInteger)touchMode touchMode:(NSInteger)touchMode
statsOverlay:(BOOL)statsOverlay statsOverlay:(BOOL)statsOverlay
allowPortrait:(BOOL)allowPortrait{ allowPortrait:(BOOL)allowPortrait
resolutionSelected:(NSInteger)resolutionSelected {
[_managedObjectContext performBlockAndWait:^{ [_managedObjectContext performBlockAndWait:^{
Settings* settingsToSave = [self retrieveSettings]; Settings* settingsToSave = [self retrieveSettings];
@@ -115,6 +116,7 @@
settingsToSave.touchMode = [NSNumber numberWithInteger:(uint16_t)touchMode]; settingsToSave.touchMode = [NSNumber numberWithInteger:(uint16_t)touchMode];
settingsToSave.statsOverlay = statsOverlay; settingsToSave.statsOverlay = statsOverlay;
settingsToSave.allowPortrait = allowPortrait; settingsToSave.allowPortrait = allowPortrait;
settingsToSave.resolutionSelected = [NSNumber numberWithInteger:resolutionSelected];
[self saveData]; [self saveData];
}]; }];
+1
View File
@@ -33,6 +33,7 @@
@property (nonatomic, retain) NSNumber * mousePointerVelocityFactor; @property (nonatomic, retain) NSNumber * mousePointerVelocityFactor;
@property (nonatomic, retain) NSNumber * pointerVelocityModeDivider; @property (nonatomic, retain) NSNumber * pointerVelocityModeDivider;
@property (nonatomic, retain) NSString * uniqueId; @property (nonatomic, retain) NSString * uniqueId;
@property (nonatomic, retain) NSNumber * resolutionSelected;
@property (nonatomic) enum { @property (nonatomic) enum {
CODEC_PREF_AUTO, CODEC_PREF_AUTO,
CODEC_PREF_H264, CODEC_PREF_H264,
+1
View File
@@ -99,6 +99,7 @@
self.mousePointerVelocityFactor = settings.mousePointerVelocityFactor; self.mousePointerVelocityFactor = settings.mousePointerVelocityFactor;
self.pointerVelocityModeDivider = settings.pointerVelocityModeDivider; self.pointerVelocityModeDivider = settings.pointerVelocityModeDivider;
self.allowPortrait = settings.allowPortrait; self.allowPortrait = settings.allowPortrait;
self.resolutionSelected = settings.resolutionSelected;
#endif #endif
self.uniqueId = settings.uniqueId; self.uniqueId = settings.uniqueId;
-2
View File
@@ -73,8 +73,6 @@
<array> <array>
<string>armv7</string> <string>armv7</string>
</array> </array>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIStatusBarHidden</key> <key>UIStatusBarHidden</key>
<true/> <true/>
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
@@ -3,6 +3,6 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>_XCCurrentVersionName</key> <key>_XCCurrentVersionName</key>
<string>Moonlight v1.10.xcdatamodel</string> <string>Moonlight v1.11.xcdatamodel</string>
</dict> </dict>
</plist> </plist>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23507" systemVersion="24B83" minimumToolsVersion="Xcode 7.3" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="">
<entity name="App" representedClassName="App" syncable="YES" codeGenerationType="class">
<attribute name="hdrSupported" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="hidden" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="id" attributeType="String" syncable="YES"/>
<attribute name="name" attributeType="String" syncable="YES"/>
<relationship name="host" maxCount="1" deletionRule="Nullify" destinationEntity="Host" inverseName="appList" inverseEntity="Host" syncable="YES"/>
</entity>
<entity name="Host" representedClassName="Host" syncable="YES" codeGenerationType="class">
<attribute name="address" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="externalAddress" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="ipv6Address" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="localAddress" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="mac" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="name" attributeType="String" syncable="YES"/>
<attribute name="pairState" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<attribute name="serverCert" optional="YES" attributeType="Binary" syncable="YES"/>
<attribute name="serverCodecModeSupport" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
<attribute name="uuid" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="appList" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="App" inverseName="host" inverseEntity="App" syncable="YES"/>
</entity>
<entity name="Settings" representedClassName="Settings" syncable="YES" codeGenerationType="class">
<attribute name="allowPortrait" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="audioConfig" attributeType="Integer 32" defaultValueString="2" usesScalarValueType="NO" syncable="YES"/>
<attribute name="bitrate" attributeType="Integer 32" defaultValueString="10000" usesScalarValueType="NO" syncable="YES"/>
<attribute name="btMouseSupport" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="deviceGyroMode" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<attribute name="enableHdr" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="framerate" attributeType="Integer 32" defaultValueString="60" usesScalarValueType="NO" syncable="YES"/>
<attribute name="height" attributeType="Integer 32" defaultValueString="720" usesScalarValueType="NO" syncable="YES"/>
<attribute name="keyboardToggleFingers" optional="YES" attributeType="Integer 16" defaultValueString="3" usesScalarValueType="NO" syncable="YES"/>
<attribute name="largerStickLR1" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<attribute name="liftStreamViewForKeyboard" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<attribute name="mousePointerVelocityFactor" optional="YES" attributeType="Float" defaultValueString="1" usesScalarValueType="NO" syncable="YES"/>
<attribute name="multiController" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<attribute name="onscreenControls" attributeType="Integer 32" defaultValueString="1" usesScalarValueType="NO" syncable="YES"/>
<attribute name="optimizeGames" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<attribute name="oscLayoutToolFingers" optional="YES" attributeType="Integer 16" defaultValueString="4" usesScalarValueType="NO" syncable="YES"/>
<attribute name="oscTapExlusionAreaSize" optional="YES" attributeType="Float" defaultValueString="1.05" usesScalarValueType="NO" syncable="YES"/>
<attribute name="playAudioOnPC" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="pointerVelocityModeDivider" optional="YES" attributeType="Float" defaultValueString="0.5" usesScalarValueType="NO" syncable="YES"/>
<attribute name="preferredCodec" attributeType="Integer 32" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<attribute name="resolutionSelected" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<attribute name="reverseMouseWheelDirection" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<attribute name="showKeyboardToolbar" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="slideToSettingsDistance" optional="YES" attributeType="Float" defaultValueString="0.5" usesScalarValueType="NO" syncable="YES"/>
<attribute name="slideToSettingsScreenEdge" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<attribute name="statsOverlay" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="swapABXYButtons" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="touchMode" optional="YES" attributeType="Integer 16" defaultValueString="1" usesScalarValueType="NO" syncable="YES"/>
<attribute name="touchPointerVelocityFactor" optional="YES" attributeType="Float" defaultValueString="1" usesScalarValueType="NO" syncable="YES"/>
<attribute name="uniqueId" attributeType="String" syncable="YES"/>
<attribute name="useFramePacing" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<attribute name="width" attributeType="Integer 32" defaultValueString="1280" usesScalarValueType="NO" syncable="YES"/>
</entity>
</model>
@@ -1149,9 +1149,11 @@ static NSMutableSet* hostList;
//[self simulateSettingsButtonPress]; //force expand setting view if orientation changed since last quit from app. //[self simulateSettingsButtonPress]; //force expand setting view if orientation changed since last quit from app.
//[self simulateSettingsButtonPress]; //force expand setting view if orientation changed since last quit from app. //[self simulateSettingsButtonPress]; //force expand setting view if orientation changed since last quit from app.
[self swapResolutionWidthHeightAccordingly]; [self swapResolutionWidthHeightAccordingly];
SettingsViewController* settingsViewController = (SettingsViewController*)[self.revealViewController rearViewController];
[settingsViewController updateResolutionTable];
} }
-(void)handleRealOrientationChange{ -(void)handleRealOrientationChange{
} }
@@ -1194,14 +1196,26 @@ static NSMutableSet* hostList;
} }
-(void)swapResolutionWidthHeightAccordingly{ -(void) swapResolutionWidthHeightAccordingly {
return;
DataManager* dataMan = [[DataManager alloc] init]; DataManager* dataMan = [[DataManager alloc] init];
Settings *currentSettings = [dataMan retrieveSettings]; Settings *currentSettings = [dataMan retrieveSettings];
CGFloat screenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]);
CGFloat screenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds]); UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
bool needSwap = ((currentSettings.width.floatValue - currentSettings.height.floatValue) * (screenWidthInPoints - screenHeightInPoints)) < 0; //update the current resolution accordingly CGFloat screenScale = window.screen.scale;
NSLog(@"need to swap width & height: %d", needSwap); CGFloat screenWidthInPoints = CGRectGetWidth(window.frame);
if(needSwap){ CGFloat screenHeightInPoints = CGRectGetHeight(window.frame);
CGFloat fullScreenWidth = screenWidthInPoints * screenScale;
CGFloat fullScreenHeight = screenHeightInPoints * screenScale;
bool needSwap = ((currentSettings.width.floatValue - currentSettings.height.floatValue) *
(fullScreenWidth - fullScreenHeight)) < 0;
NSLog(@"Current screen size: %.0f x %.0f", fullScreenWidth, fullScreenHeight);
NSLog(@"Current setting size: %.0f x %.0f", currentSettings.width.floatValue, currentSettings.height.floatValue);
NSLog(@"Need to swap width & height: %d", needSwap);
if(needSwap) {
CGFloat tmpLength = currentSettings.width.floatValue; CGFloat tmpLength = currentSettings.width.floatValue;
currentSettings.width = @(currentSettings.height.floatValue); currentSettings.width = @(currentSettings.height.floatValue);
currentSettings.height = @(tmpLength); currentSettings.height = @(tmpLength);
@@ -1209,7 +1223,6 @@ static NSMutableSet* hostList;
} }
} }
#if TARGET_OS_TV #if TARGET_OS_TV
-(void)handleCollectionViewLongPress:(UILongPressGestureRecognizer *)gestureRecognizer -(void)handleCollectionViewLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
{ {
@@ -68,6 +68,7 @@
- (void) saveSettings; - (void) saveSettings;
+ (bool) isLandscapeNow; + (bool) isLandscapeNow;
- (void)updateResolutionTable;
- (void) widget:(UISlider*)widget setEnabled:(bool)enabled; - (void) widget:(UISlider*)widget setEnabled:(bool)enabled;
@end @end
@@ -217,6 +217,7 @@ BOOL isCustomResolution(CGSize res) {
CGFloat safeAreaWidth = (window.frame.size.width - window.safeAreaInsets.left - window.safeAreaInsets.right) * screenScale; CGFloat safeAreaWidth = (window.frame.size.width - window.safeAreaInsets.left - window.safeAreaInsets.right) * screenScale;
CGFloat fullScreenWidth = window.frame.size.width * screenScale; CGFloat fullScreenWidth = window.frame.size.width * screenScale;
CGFloat fullScreenHeight = window.frame.size.height * screenScale; CGFloat fullScreenHeight = window.frame.size.height * screenScale;
bool isLandscapeNow = fullScreenWidth > fullScreenHeight;
resolutionTable[4] = CGSizeMake(safeAreaWidth, fullScreenHeight); resolutionTable[4] = CGSizeMake(safeAreaWidth, fullScreenHeight);
resolutionTable[5] = CGSizeMake(fullScreenWidth, fullScreenHeight); resolutionTable[5] = CGSizeMake(fullScreenWidth, fullScreenHeight);
@@ -224,13 +225,27 @@ BOOL isCustomResolution(CGSize res) {
for(uint8_t i=0;i<7;i++){ for(uint8_t i=0;i<7;i++){
CGFloat longSideLen = resolutionTable[i].height > resolutionTable[i].width ? resolutionTable[i].height : resolutionTable[i].width; CGFloat longSideLen = resolutionTable[i].height > resolutionTable[i].width ? resolutionTable[i].height : resolutionTable[i].width;
CGFloat shortSideLen = resolutionTable[i].height < resolutionTable[i].width ? resolutionTable[i].height : resolutionTable[i].width; CGFloat shortSideLen = resolutionTable[i].height < resolutionTable[i].width ? resolutionTable[i].height : resolutionTable[i].width;
if([SettingsViewController isLandscapeNow]) resolutionTable[i] = CGSizeMake(longSideLen, shortSideLen); if(isLandscapeNow) resolutionTable[i] = CGSizeMake(longSideLen, shortSideLen);
else resolutionTable[i] = CGSizeMake(shortSideLen, longSideLen); else resolutionTable[i] = CGSizeMake(shortSideLen, longSideLen);
} }
[self updateResolutionSettings];
[self updateResolutionDisplayViewText]; [self updateResolutionDisplayViewText];
} }
- (void)updateResolutionSettings{
DataManager* dataMgr = [[DataManager alloc] init];
Settings *currentSettings = [dataMgr retrieveSettings];
int resolution = currentSettings.resolutionSelected.intValue;
if(resolution==4 || resolution==5){
currentSettings.width = @(resolutionTable[resolution].width);
currentSettings.height = @(resolutionTable[resolution].height);
NSLog(@"Modify setting width & height: %.0f x %.0f", currentSettings.width.floatValue, currentSettings.height.floatValue);
[dataMgr saveData];
}
}
- (void)viewDidAppear:(BOOL)animated{ - (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated]; [super viewDidAppear:animated];
[self updateResolutionTable]; [self updateResolutionTable];
@@ -359,13 +374,10 @@ BOOL isCustomResolution(CGSize res) {
break; break;
} }
NSInteger resolution = 1; NSInteger resolution = currentSettings.resolutionSelected.integerValue;
for (int i = 0; i < RESOLUTION_TABLE_SIZE; i++) { if(resolution >= RESOLUTION_TABLE_SIZE){
if (((int) resolutionTable[i].height == [currentSettings.height intValue] && (int) resolutionTable[i].width == [currentSettings.width intValue]) || ((int) resolutionTable[i].width == [currentSettings.height intValue] && (int) resolutionTable[i].height == [currentSettings.width intValue])){ resolution = 0;
resolution = i; }
break;
}
}
// Only show the 120 FPS option if we have a > 60-ish Hz display // Only show the 120 FPS option if we have a > 60-ish Hz display
bool enable120Fps = false; bool enable120Fps = false;
@@ -1030,6 +1042,7 @@ BOOL isCustomResolution(CGSize res) {
BOOL statsOverlay = [self.statsOverlaySelector selectedSegmentIndex] == 1; BOOL statsOverlay = [self.statsOverlaySelector selectedSegmentIndex] == 1;
BOOL enableHdr = [self.hdrSelector selectedSegmentIndex] == 1; BOOL enableHdr = [self.hdrSelector selectedSegmentIndex] == 1;
BOOL allowPortrait = [self.allowPortraitSelector selectedSegmentIndex] == 1; BOOL allowPortrait = [self.allowPortraitSelector selectedSegmentIndex] == 1;
NSInteger resolutionSelected = [self.resolutionSelector selectedSegmentIndex];
[dataMan saveSettingsWithBitrate:_bitrate [dataMan saveSettingsWithBitrate:_bitrate
framerate:framerate framerate:framerate
height:height height:height
@@ -1059,7 +1072,8 @@ BOOL isCustomResolution(CGSize res) {
// absoluteTouchMode:absoluteTouchMode // absoluteTouchMode:absoluteTouchMode
touchMode:touchMode touchMode:touchMode
statsOverlay:statsOverlay statsOverlay:statsOverlay
allowPortrait:allowPortrait]; allowPortrait:allowPortrait
resolutionSelected:resolutionSelected];
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning {
@@ -1073,5 +1087,10 @@ BOOL isCustomResolution(CGSize res) {
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
} }
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
[self deviceOrientationDidChange];
}
@end @end
@@ -860,4 +860,11 @@
} }
#endif #endif
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
Log(LOG_I, @"View size changed, terminating stream");
[self returnToMainFrame];
}
@end @end