mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
iOS: Delete untested multi-screen-management code that uses deprecated APIs
This commit is contained in:
@@ -1371,8 +1371,6 @@ elseif(IOS AND NOT LIBRETRO)
|
||||
ios/AppDelegate.h
|
||||
ios/SceneDelegate.mm
|
||||
ios/SceneDelegate.h
|
||||
ios/DisplayManager.h
|
||||
ios/DisplayManager.mm
|
||||
ios/Controls.h
|
||||
ios/Controls.mm
|
||||
ios/ViewControllerCommon.h
|
||||
@@ -1421,7 +1419,6 @@ elseif(IOS AND NOT LIBRETRO)
|
||||
ios/CameraHelper.mm
|
||||
ios/AudioEngine.mm
|
||||
ios/LocationHelper.mm
|
||||
ios/DisplayManager.mm
|
||||
ios/Controls.mm
|
||||
UI/DarwinFileSystemServices.mm
|
||||
Common/Battery/AppleBatteryClient.m
|
||||
|
||||
+1
-17
@@ -804,14 +804,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\DisplayManager.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\iCade\iCadeReaderView.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -1241,14 +1233,6 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</None>
|
||||
<None Include="..\ios\DisplayManager.mm">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</None>
|
||||
<None Include="..\ios\iCade\iCadeReaderView.m">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
@@ -1442,4 +1426,4 @@
|
||||
<UserProperties RESOURCE_FILE="DaSh.rc" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -433,9 +433,6 @@
|
||||
<ClInclude Include="..\ios\PPSSPPUIApplication.h">
|
||||
<Filter>Other Platforms\iOS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\DisplayManager.h">
|
||||
<Filter>Other Platforms\iOS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ios\AppDelegate.h">
|
||||
<Filter>Other Platforms\iOS</Filter>
|
||||
</ClInclude>
|
||||
@@ -689,9 +686,6 @@
|
||||
<None Include="..\ios\CameraHelper.mm">
|
||||
<Filter>Other Platforms\iOS</Filter>
|
||||
</None>
|
||||
<None Include="..\ios\DisplayManager.mm">
|
||||
<Filter>Other Platforms\iOS</Filter>
|
||||
</None>
|
||||
<None Include="..\ios\iOSCoreAudio.mm">
|
||||
<Filter>Other Platforms\iOS</Filter>
|
||||
</None>
|
||||
@@ -871,4 +865,4 @@
|
||||
<Filter>Other Platforms\SDL</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
//
|
||||
// DisplayManager.h
|
||||
// native
|
||||
//
|
||||
// Created by xieyi on 2019/6/9.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface DisplayManager : NSObject
|
||||
|
||||
- (void)setupDisplayListener;
|
||||
- (void)updateResolution:(UIScreen *)screen;
|
||||
|
||||
@property (nonatomic, strong) UIScreen *mainScreen;
|
||||
|
||||
@property (class, readonly, strong) DisplayManager *shared;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,167 +0,0 @@
|
||||
//
|
||||
// DisplayManager.m
|
||||
// native
|
||||
//
|
||||
// Created by xieyi on 2019/6/9.
|
||||
//
|
||||
|
||||
#import "DisplayManager.h"
|
||||
#import "iOSCoreAudio.h"
|
||||
#import "ViewController.h"
|
||||
#import "AppDelegate.h"
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/System/System.h"
|
||||
#include "Common/System/NativeApp.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
#define IS_IPAD() ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad)
|
||||
|
||||
@interface DisplayManager ()
|
||||
|
||||
@property BOOL listenerActive;
|
||||
@property (atomic, retain) NSMutableArray<UIScreen *> *extDisplays;
|
||||
@property CGRect originalFrame;
|
||||
@property CGRect originalBounds;
|
||||
@property CGAffineTransform originalTransform;
|
||||
|
||||
- (void)updateScreen:(UIScreen *)screen;
|
||||
|
||||
@end
|
||||
|
||||
@implementation DisplayManager
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
[self setListenerActive:NO];
|
||||
[self setExtDisplays:[[NSMutableArray<UIScreen *> alloc] init]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (DisplayManager *)shared {
|
||||
static DisplayManager *sharedInstance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
sharedInstance = [[DisplayManager alloc] init];
|
||||
});
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
- (void)setupDisplayListener {
|
||||
// Disable external display by default
|
||||
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"enable_external_display"] == NO) {
|
||||
return;
|
||||
}
|
||||
if ([self listenerActive]) {
|
||||
NSLog(@"setupDisplayListener already called");
|
||||
return;
|
||||
}
|
||||
NSLog(@"Setting up display manager");
|
||||
[self setMainScreen:[UIScreen mainScreen]];
|
||||
UIWindow *gameWindow = [(AppDelegate *)[[UIApplication sharedApplication] delegate] window];
|
||||
[self setOriginalFrame: [gameWindow frame]];
|
||||
[self setOriginalBounds:[gameWindow bounds]];
|
||||
[self setOriginalTransform:[gameWindow transform]];
|
||||
|
||||
// TODO: From iOS 13, should use UIScreenDidConnectNotification instead of the below.
|
||||
|
||||
// Display connected
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:UIScreenDidConnectNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull notification) {
|
||||
UIScreen *screen = (UIScreen *) notification.object;
|
||||
NSLog(@"New display connected: %@", [screen debugDescription]);
|
||||
[[self extDisplays] addObject:screen];
|
||||
// Do not switch to second connected display
|
||||
if ([self mainScreen] != [UIScreen mainScreen]) {
|
||||
return;
|
||||
}
|
||||
// Ignore mute switch when connected to external display
|
||||
iOSCoreAudioSetDisplayConnected(true);
|
||||
[self updateScreen:screen];
|
||||
}];
|
||||
// Display disconnected
|
||||
[[NSNotificationCenter defaultCenter] addObserverForName:UIScreenDidDisconnectNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull notification) {
|
||||
UIScreen *screen = (UIScreen *) notification.object;
|
||||
NSLog(@"Display disconnected: %@", [screen debugDescription]);
|
||||
if ([[self extDisplays] containsObject:screen]) {
|
||||
[[self extDisplays] removeObject:screen];
|
||||
}
|
||||
if ([[self extDisplays] count] > 0) {
|
||||
UIScreen *newScreen = [[self extDisplays] lastObject];
|
||||
[self updateScreen:newScreen];
|
||||
} else {
|
||||
iOSCoreAudioSetDisplayConnected(false);
|
||||
[self updateScreen:[UIScreen mainScreen]];
|
||||
}
|
||||
}];
|
||||
[self setListenerActive:YES];
|
||||
}
|
||||
|
||||
- (void)updateScreen:(UIScreen *)screen {
|
||||
[self setMainScreen:screen];
|
||||
UIWindow *gameWindow = [(AppDelegate *)[[UIApplication sharedApplication] delegate] window];
|
||||
// Hide before moving window to external display, otherwise iPhone won't switch to it
|
||||
[gameWindow setHidden:YES];
|
||||
[gameWindow setScreen:screen];
|
||||
// Set optimal resolution
|
||||
// Dispatch later to prevent "no window is preset" error
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (screen != [UIScreen mainScreen]) {
|
||||
NSUInteger count = [[screen availableModes] count];
|
||||
UIScreenMode* mode = [screen availableModes][count - 1];
|
||||
[screen setCurrentMode:mode];
|
||||
mode = [screen currentMode];
|
||||
// Fix overscan
|
||||
// TODO: Hacky solution. Screen is still scaled even if UIScreenOverscanCompensationNone is set.
|
||||
[screen setOverscanCompensation:UIScreenOverscanCompensationNone];
|
||||
CGSize fullSize = mode.size;
|
||||
UIEdgeInsets insets = [screen overscanCompensationInsets];
|
||||
fullSize.width -= insets.left + insets.right;
|
||||
fullSize.height -= insets.top + insets.bottom;
|
||||
[gameWindow setFrame:CGRectMake(insets.left, insets.top, fullSize.width, fullSize.height)];
|
||||
[gameWindow setBounds:CGRectMake(0, 0, fullSize.width, fullSize.height)];
|
||||
[self updateResolution:screen];
|
||||
[gameWindow setTransform:CGAffineTransformMakeScale(mode.size.width / fullSize.width, mode.size.height / fullSize.height)];
|
||||
} else {
|
||||
[gameWindow setTransform:[self originalTransform]];
|
||||
[gameWindow setFrame:[self originalFrame]];
|
||||
[gameWindow setBounds:[self originalBounds]];
|
||||
[self updateResolution:screen];
|
||||
}
|
||||
[gameWindow setHidden:NO];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)updateResolution:(UIScreen *)screen {
|
||||
float scale = screen.nativeScale;
|
||||
CGSize size = screen.bounds.size;
|
||||
|
||||
float dpi;
|
||||
if (screen == [UIScreen mainScreen]) {
|
||||
dpi = (IS_IPAD() ? 200.0f : 150.0f) * scale;
|
||||
} else {
|
||||
float diagonal = sqrt(size.height * size.height + size.width * size.width);
|
||||
dpi = diagonal * scale * 0.1f;
|
||||
}
|
||||
|
||||
const float dpi_scale_x = 240.0f / dpi;
|
||||
const float dpi_scale_y = 240.0f / dpi;
|
||||
g_display.Recalculate(size.width * scale, size.height * scale, dpi_scale_x, dpi_scale_y, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor));
|
||||
|
||||
[[sharedViewController getView] setContentScaleFactor:scale];
|
||||
|
||||
// PSP native resize
|
||||
PSP_CoreParameter().pixelWidth = g_display.pixel_xres;
|
||||
PSP_CoreParameter().pixelHeight = g_display.pixel_yres;
|
||||
|
||||
NativeResized();
|
||||
|
||||
NSLog(@"Updated display resolution: (%d, %d) @%.1fx", g_display.pixel_xres, g_display.pixel_yres, scale);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "ViewController.h"
|
||||
#import "DisplayManager.h"
|
||||
#import "iOSCoreAudio.h"
|
||||
|
||||
#import <GLKit/GLKit.h>
|
||||
@@ -216,8 +215,6 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
|
||||
|
||||
self.lastTimestamp = 0;
|
||||
|
||||
[[DisplayManager shared] setupDisplayListener];
|
||||
|
||||
UIScreen* screen = [(AppDelegate*)[UIApplication sharedApplication].delegate screen];
|
||||
self.view.frame = [screen bounds];
|
||||
self.view.multipleTouchEnabled = YES;
|
||||
@@ -317,7 +314,7 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
|
||||
INFO_LOG(Log::System, "didBecomeActive begin");
|
||||
|
||||
[self runGLRenderLoop];
|
||||
[[DisplayManager shared] updateResolution:[UIScreen mainScreen]];
|
||||
[self updateResolution:[UIScreen mainScreen]];
|
||||
|
||||
INFO_LOG(Log::System, "didBecomeActive end");
|
||||
|
||||
@@ -387,7 +384,7 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) {
|
||||
// Reinitialize graphics context to match new size
|
||||
[self requestExitGLRenderLoop];
|
||||
[self runGLRenderLoop];
|
||||
[[DisplayManager shared] updateResolution:[UIScreen mainScreen]];
|
||||
[self updateResolution:[UIScreen mainScreen]];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
- (void)uiStateChanged;
|
||||
- (void)pickPhoto:(NSString *)saveFilename requestId:(int)requestId;
|
||||
- (void)updateResolution:(UIScreen *)screen;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Common/System/Request.h"
|
||||
#include "Common/Input/InputState.h"
|
||||
#include "Common/System/NativeApp.h"
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Core/HLE/sceUsbCam.h"
|
||||
#include "Core/HLE/sceUsbGps.h"
|
||||
@@ -441,4 +442,25 @@ extern float g_safeInsetBottom;
|
||||
[self setNeedsStatusBarAppearanceUpdate];
|
||||
}
|
||||
|
||||
- (void)updateResolution:(UIScreen *)screen {
|
||||
float scale = screen.nativeScale;
|
||||
CGSize size = screen.bounds.size;
|
||||
|
||||
float dpi = (IS_IPAD() ? 200.0f : 150.0f) * scale;
|
||||
|
||||
const float dpi_scale_x = 240.0f / dpi;
|
||||
const float dpi_scale_y = 240.0f / dpi;
|
||||
g_display.Recalculate(size.width * scale, size.height * scale, dpi_scale_x, dpi_scale_y, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor));
|
||||
|
||||
[[sharedViewController getView] setContentScaleFactor:scale];
|
||||
|
||||
// PSP native resize
|
||||
PSP_CoreParameter().pixelWidth = g_display.pixel_xres;
|
||||
PSP_CoreParameter().pixelHeight = g_display.pixel_yres;
|
||||
|
||||
NativeResized();
|
||||
|
||||
NSLog(@"Updated display resolution: (%d, %d) @%.1fx", g_display.pixel_xres, g_display.pixel_yres, scale);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#import "AppDelegate.h"
|
||||
#import "ViewControllerMetal.h"
|
||||
#import "DisplayManager.h"
|
||||
#import "iOSCoreAudio.h"
|
||||
|
||||
#include "Common/Log.h"
|
||||
@@ -296,7 +295,7 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye
|
||||
// Spin up the emu thread. It will in turn spin up the Vulkan render thread
|
||||
// on its own.
|
||||
[self runVulkanRenderLoop];
|
||||
[[DisplayManager shared] updateResolution:[UIScreen mainScreen]];
|
||||
[self updateResolution:[UIScreen mainScreen]];
|
||||
}
|
||||
|
||||
- (void)willResignActive {
|
||||
@@ -340,8 +339,6 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye
|
||||
[super viewDidLoad];
|
||||
[self hideKeyboard];
|
||||
|
||||
[[DisplayManager shared] setupDisplayListener];
|
||||
|
||||
INFO_LOG(Log::System, "Metal viewDidLoad");
|
||||
|
||||
UIScreen* screen = [(AppDelegate*)[UIApplication sharedApplication].delegate screen];
|
||||
@@ -352,7 +349,7 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye
|
||||
|
||||
graphicsContext = new IOSVulkanContext();
|
||||
|
||||
[[DisplayManager shared] updateResolution:[UIScreen mainScreen]];
|
||||
[self updateResolution:[UIScreen mainScreen]];
|
||||
|
||||
if (!graphicsContext->InitAPI()) {
|
||||
_assert_msg_(false, "Failed to init Vulkan");
|
||||
@@ -403,7 +400,7 @@ void VulkanRenderLoop(IOSVulkanContext *graphicsContext, CAMetalLayer *metalLaye
|
||||
// Reinitialize graphics context to match new size
|
||||
[self requestExitVulkanRenderLoop];
|
||||
[self runVulkanRenderLoop];
|
||||
[[DisplayManager shared] updateResolution:[UIScreen mainScreen]];
|
||||
[self updateResolution:[UIScreen mainScreen]];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user