Skip to content

Commit

Permalink
Fix: Default app size now shows normally and other Adaptive fixes plu…
Browse files Browse the repository at this point in the history
…s responsive fix on default (PlayCover#77)

* Fix for default screen

* Code cleanup

* setting @objc to scene control vars

* PR to make default size work correctly (#1)

* Reverting cleanup

* Testing removing new scaling methods for default

* Revert to new methods for testing

* Setting orientation to 1

* 4

* commenting suspect stuff

* 12

* sd

* removing FBS

* test

* returning back to normal

* Test

* a

* test

* x

* a

* a

* a

* as

* 1

* as

* así

* aa

* as

* Change names

* testing something

* testing 2

* more test

* 12

* return

* 123

* Testing defaults and auto fix

* Testing c

* is this ready?

* test

* 1

* returning adaptive

* Delete PlayScreenDefault.swift

* Update project.pbxproj

Removing All references to PlayScreenDefault.swift

* Adds fix for some apps with adaptive display enabled (#3)

* testing changing to default bounds

* Update project.pbxproj (#2)

Removing All references to PlayScreenDefault.swift

* test 2

* rest

* test

* as

* asd

* test

* 123

* Adding inverseScreenValues to settings

* Reduced code and added ternaries

* added else when inverseScreenValues is false (might rework

* Adds MacOSVersion to plist and a 'fix' for screen issue (PlayCover#4)

* testing changing to default bounds

* Update project.pbxproj (#2)

Removing All references to PlayScreenDefault.swift

* test 2

* rest

* test

* as

* asd

* test

* 123

* Adding inverseScreenValues to settings

* Reduced code and added ternaries

* added else when inverseScreenValues is false (might rework

* Test to fix pre MacOS 13.2

* Check this out

* Using float instead of string

* v2

* test

* lets see

* adding print

* NSLog(@"macOS version: %f", [[PlaySettings shared] macOSVersion]);

* [[PlaySettings shared] macOSVersion] rounded

* adding 00000 to every float

* testing

* return back to normal double

* Forgot about floating point error

* more than 13.1

* more

* 13.199

* setting to latest macOS version

* more floating error and macOS fixes

* reduced lines and fix some errors

* Update project.pbxproj

* Update project.pbxproj

* Update PlaySettings.swift

* Enables responsiveness for some apps for default screen settings if toggle enabled (PlayCover#5)

* test disabling FBSDisplayMode

* disabling FBS

* Adding experimental fix toggle to fix responsiveness

* adding an extra log

* extra

* moving the function to a better place

* back to another place

* added CheckResizabilityHasRun

* Testing some stuff

* name issue

* added some comments to test

* added fuction stop

* True to yes

* Changed yes to no

* adding observer for resize

* adding chess

* test

* back again

* Removing extra check for a future commit

* changed macos check to ios check

* Remove macOSVersion
  • Loading branch information
JoseMoreville authored and IsaacMarovitz committed May 8, 2023
1 parent edfc1fe commit 29ebd3d
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 23 deletions.
8 changes: 4 additions & 4 deletions PlayTools.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
objects = {

/* Begin PBXBuildFile section */
2847AE48298EFC0F00B0F983 /* PlayScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2847AE47298EFC0F00B0F983 /* PlayScreen.swift */; };
6E76639B28D0FAE700DE4AF9 /* Plugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E76639A28D0FAE700DE4AF9 /* Plugin.swift */; };
6E76639C28D0FAE700DE4AF9 /* Plugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E76639A28D0FAE700DE4AF9 /* Plugin.swift */; };
6E7663A128D0FB5300DE4AF9 /* AKPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E7663A028D0FB5300DE4AF9 /* AKPlugin.swift */; };
6E7663A528D0FEBE00DE4AF9 /* AKPluginLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E7663A428D0FEBE00DE4AF9 /* AKPluginLoader.swift */; };
6E84A14528D0F94E00BF7495 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA818CBA287ABFD5000BEE9D /* UIKit.framework */; };
6E84A15028D0F97500BF7495 /* AKInterface.bundle in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 6E84A14C28D0F96D00BF7495 /* AKInterface.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
AA71970B287A44D200623C15 /* PlayLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = AA719702287A44D200623C15 /* PlayLoader.m */; };
AA71970C287A44D200623C15 /* PlayScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA719703287A44D200623C15 /* PlayScreen.swift */; };
AA71970D287A44D200623C15 /* PlaySettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA719704287A44D200623C15 /* PlaySettings.swift */; };
AA71970E287A44D200623C15 /* PlayLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = AA719705287A44D200623C15 /* PlayLoader.h */; };
AA71970F287A44D200623C15 /* PlayCover.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA719706287A44D200623C15 /* PlayCover.swift */; };
Expand Down Expand Up @@ -67,14 +67,14 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
2847AE47298EFC0F00B0F983 /* PlayScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayScreen.swift; sourceTree = "<group>"; };
6E76639628D0FA6200DE4AF9 /* AKInterface-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AKInterface-Bridging-Header.h"; sourceTree = "<group>"; };
6E76639A28D0FAE700DE4AF9 /* Plugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Plugin.swift; sourceTree = "<group>"; };
6E7663A028D0FB5300DE4AF9 /* AKPlugin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AKPlugin.swift; sourceTree = "<group>"; };
6E7663A428D0FEBE00DE4AF9 /* AKPluginLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AKPluginLoader.swift; sourceTree = "<group>"; };
6E84A14C28D0F96D00BF7495 /* AKInterface.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AKInterface.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
AA7196D8287A447700623C15 /* PlayTools.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PlayTools.framework; sourceTree = BUILT_PRODUCTS_DIR; };
AA719702287A44D200623C15 /* PlayLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PlayLoader.m; sourceTree = "<group>"; };
AA719703287A44D200623C15 /* PlayScreen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayScreen.swift; sourceTree = "<group>"; };
AA719704287A44D200623C15 /* PlaySettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlaySettings.swift; sourceTree = "<group>"; };
AA719705287A44D200623C15 /* PlayLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlayLoader.h; sourceTree = "<group>"; };
AA719706287A44D200623C15 /* PlayCover.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlayCover.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -175,11 +175,11 @@
AA719791287A481500623C15 /* Utils */,
AA71970A287A44D200623C15 /* Info.plist */,
AA719706287A44D200623C15 /* PlayCover.swift */,
AA719703287A44D200623C15 /* PlayScreen.swift */,
AA719704287A44D200623C15 /* PlaySettings.swift */,
AA719705287A44D200623C15 /* PlayLoader.h */,
AA719702287A44D200623C15 /* PlayLoader.m */,
AA719708287A44D200623C15 /* PlayTools.h */,
2847AE47298EFC0F00B0F983 /* PlayScreen.swift */,
);
path = PlayTools;
sourceTree = "<group>";
Expand Down Expand Up @@ -445,6 +445,7 @@
AA71970D287A44D200623C15 /* PlaySettings.swift in Sources */,
AA719759287A480D00623C15 /* PlayAction.swift in Sources */,
6E7663A528D0FEBE00DE4AF9 /* AKPluginLoader.swift in Sources */,
2847AE48298EFC0F00B0F983 /* PlayScreen.swift in Sources */,
AA7197A2287A481500623C15 /* CircleMenu.swift in Sources */,
AA71978B287A480D00623C15 /* MenuController.swift in Sources */,
AA7197AA287A481500623C15 /* Toast.swift in Sources */,
Expand All @@ -457,7 +458,6 @@
AA7197A3287A481500623C15 /* CircleMenuButton.swift in Sources */,
AA7197A9287A481500623C15 /* PlayInfo.swift in Sources */,
AA71986A287A81A000623C15 /* PTFakeMetaTouch.m in Sources */,
AA71970C287A44D200623C15 /* PlayScreen.swift in Sources */,
ABCECEE629750BA600746595 /* PlayedApple.swift in Sources */,
AA71986C287A81A000623C15 /* NSObject+Swizzle.m in Sources */,
AA71970F287A44D200623C15 /* PlayCover.swift in Sources */,
Expand Down
96 changes: 79 additions & 17 deletions PlayTools/Controls/PTFakeTouch/NSObject+Swizzle.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#import "UIKit/UIKit.h"
#import <PlayTools/PlayTools-Swift.h>
#import "PTFakeMetaTouch.h"
#import <VideoSubscriberAccount/VideoSubscriberAccount.h>

__attribute__((visibility("hidden")))
@interface PTSwizzleLoader : NSObject
Expand Down Expand Up @@ -54,6 +53,23 @@ - (BOOL) hook_prefersPointerLocked {
return false;
}

- (CGRect) hook_frameDefault {
return [PlayScreen frameDefault:[self hook_frameDefault]];
}

- (CGRect) hook_boundsDefault {
return [PlayScreen boundsDefault:[self hook_boundsDefault]];
}

- (CGRect) hook_nativeBoundsDefault {
return [PlayScreen nativeBoundsDefault:[self hook_nativeBoundsDefault]];
}

- (CGSize) hook_sizeDelfault {
return [PlayScreen sizeAspectRatioDefault:[self hook_sizeDelfault]];
}


- (CGRect) hook_frame {
return [PlayScreen frame:[self hook_frame]];
}
Expand All @@ -71,6 +87,7 @@ - (CGSize) hook_size {
}



- (long long) hook_orientation {
return 0;
}
Expand All @@ -83,11 +100,17 @@ - (double) hook_scale {
return 2.0;
}

- (void) hook_setCurrentSubscription:(VSSubscription *)currentSubscription {
// do nothing
- (double) get_default_height {
return [[UIScreen mainScreen] bounds].size.height;

}
- (double) get_default_width {
return [[UIScreen mainScreen] bounds].size.width;

}



bool menuWasCreated = false;
- (id) initWithRootMenuHook:(id)rootMenu {
self = [self initWithRootMenuHook:rootMenu];
Expand Down Expand Up @@ -124,25 +147,64 @@ -(CGRect) hook_frame {
However, doing this would require generating @interface declarations (either with class-dump or by hand) which would add a lot
of code and complexity. I'm not sure this trade-off is "worth it", at least at the time of writing.
*/

@implementation PTSwizzleLoader
+ (void)load {
if ([[PlaySettings shared] adaptiveDisplay]) {
// This lines set external Scene (frame and those things) settings and other IOS10 Runtime services by swizzling
[objc_getClass("FBSSceneSettings") swizzleInstanceMethod:@selector(frame) withMethod:@selector(hook_frame)];
[objc_getClass("FBSSceneSettings") swizzleInstanceMethod:@selector(bounds) withMethod:@selector(hook_bounds)];
[objc_getClass("FBSDisplayMode") swizzleInstanceMethod:@selector(size) withMethod:@selector(hook_size)];

// This actually fixes Apple mess at MacOS 13.2
[objc_getClass("UIDevice") swizzleInstanceMethod:@selector(orientation) withMethod:@selector(hook_orientation)];
[objc_getClass("UIScreen") swizzleInstanceMethod:@selector(nativeBounds) withMethod:@selector(hook_nativeBounds)];
[objc_getClass("UIScreen") swizzleInstanceMethod:@selector(nativeScale) withMethod:@selector(hook_nativeScale)];
[objc_getClass("UIScreen") swizzleInstanceMethod:@selector(scale) withMethod:@selector(hook_scale)];
// This might need refactor soon
if(@available(iOS 16.3, *)) {
if ([[PlaySettings shared] adaptiveDisplay]) {
// This is an experimental fix
if ([[PlaySettings shared] inverseScreenValues]) {
// This lines set External Scene settings and other IOS10 Runtime services by swizzling
[objc_getClass("FBSSceneSettings") swizzleInstanceMethod:@selector(frame) withMethod:@selector(hook_frameDefault)];
[objc_getClass("FBSSceneSettings") swizzleInstanceMethod:@selector(bounds) withMethod:@selector(hook_boundsDefault)];
[objc_getClass("FBSDisplayMode") swizzleInstanceMethod:@selector(size) withMethod:@selector(hook_sizeDelfault)];

// Fixes Apple mess at MacOS 13.2
[objc_getClass("UIDevice") swizzleInstanceMethod:@selector(orientation) withMethod:@selector(hook_orientation)];
[objc_getClass("UIScreen") swizzleInstanceMethod:@selector(nativeBounds) withMethod:@selector(hook_nativeBoundsDefault)];
[objc_getClass("UIScreen") swizzleInstanceMethod:@selector(nativeScale) withMethod:@selector(hook_nativeScale)];
[objc_getClass("UIScreen") swizzleInstanceMethod:@selector(scale) withMethod:@selector(hook_scale)];
} else {
// This acutally runs when adaptiveDisplay is normally triggered
[objc_getClass("FBSSceneSettings") swizzleInstanceMethod:@selector(frame) withMethod:@selector(hook_frame)];
[objc_getClass("FBSSceneSettings") swizzleInstanceMethod:@selector(bounds) withMethod:@selector(hook_bounds)];
[objc_getClass("FBSDisplayMode") swizzleInstanceMethod:@selector(size) withMethod:@selector(hook_size)];

[objc_getClass("UIDevice") swizzleInstanceMethod:@selector(orientation) withMethod:@selector(hook_orientation)];
[objc_getClass("UIScreen") swizzleInstanceMethod:@selector(nativeBounds) withMethod:@selector(hook_nativeBounds)];
[objc_getClass("UIScreen") swizzleInstanceMethod:@selector(nativeScale) withMethod:@selector(hook_nativeScale)];
[objc_getClass("UIScreen") swizzleInstanceMethod:@selector(scale) withMethod:@selector(hook_scale)];
}
}
else {
CGFloat newValueW = (CGFloat) [self get_default_width];
[[PlaySettings shared] setValue:@(newValueW) forKey:@"windowSizeWidth"];

CGFloat newValueH = (CGFloat)[self get_default_height];
[[PlaySettings shared] setValue:@(newValueH) forKey:@"windowSizeHeight"];
if (![[PlaySettings shared] inverseScreenValues]) {
[objc_getClass("FBSSceneSettings") swizzleInstanceMethod:@selector(frame) withMethod:@selector(hook_frameDefault)];
[objc_getClass("FBSSceneSettings") swizzleInstanceMethod:@selector(bounds) withMethod:@selector(hook_boundsDefault)];
[objc_getClass("FBSDisplayMode") swizzleInstanceMethod:@selector(size) withMethod:@selector(hook_sizeDelfault)];
}
[objc_getClass("UIDevice") swizzleInstanceMethod:@selector(orientation) withMethod:@selector(hook_orientation)];
[objc_getClass("UIScreen") swizzleInstanceMethod:@selector(nativeBounds) withMethod:@selector(hook_nativeBoundsDefault)];

[objc_getClass("UIScreen") swizzleInstanceMethod:@selector(nativeScale) withMethod:@selector(hook_nativeScale)];
[objc_getClass("UIScreen") swizzleInstanceMethod:@selector(scale) withMethod:@selector(hook_scale)];
}
}
else {
if ([[PlaySettings shared] adaptiveDisplay]) {
[objc_getClass("FBSSceneSettings") swizzleInstanceMethod:@selector(frame) withMethod:@selector(hook_frame)];
[objc_getClass("FBSSceneSettings") swizzleInstanceMethod:@selector(bounds) withMethod:@selector(hook_bounds)];
[objc_getClass("FBSDisplayMode") swizzleInstanceMethod:@selector(size) withMethod:@selector(hook_size)];
}
}

[objc_getClass("_UIMenuBuilder") swizzleInstanceMethod:sel_getUid("initWithRootMenu:") withMethod:@selector(initWithRootMenuHook:)];
[objc_getClass("IOSViewController") swizzleInstanceMethod:@selector(prefersPointerLocked) withMethod:@selector(hook_prefersPointerLocked)];

[objc_getClass("VSSubscriptionRegistrationCenter") swizzleInstanceMethod:@selector(setCurrentSubscription:) withMethod:@selector(hook_setCurrentSubscription:)];
}

@end
1 change: 1 addition & 0 deletions PlayTools/PlayLoader.m
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ static OSStatus pt_SecItemDelete(CFDictionaryRef query) {
DYLD_INTERPOSE(pt_SecItemDelete, SecItemDelete)



@implementation PlayLoader

static void __attribute__((constructor)) initialize(void) {
Expand Down
7 changes: 5 additions & 2 deletions PlayTools/PlaySettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ let settings = PlaySettings.shared

lazy var sensitivity = settingsData.sensitivity / 100

lazy var windowSizeHeight = CGFloat(settingsData.windowHeight)
@objc lazy var windowSizeHeight = CGFloat(settingsData.windowHeight)

lazy var windowSizeWidth = CGFloat(settingsData.windowWidth)
@objc lazy var windowSizeWidth = CGFloat(settingsData.windowWidth)

@objc lazy var inverseScreenValues = settingsData.inverseScreenValues

@objc lazy var adaptiveDisplay = settingsData.resolution == 0 ? false : true

Expand Down Expand Up @@ -82,4 +84,5 @@ struct AppSettingsData: Codable {
var version = "2.0.0"
var playChain = false
var playChainDebugging = false
var inverseScreenValues = false
}

0 comments on commit 29ebd3d

Please sign in to comment.