From 7778ac39dfa8dc63eb586cfd3ed9cce91cd45123 Mon Sep 17 00:00:00 2001 From: luka2272 Date: Sun, 19 Oct 2025 22:57:03 +0300 Subject: [PATCH 1/8] Add displayRotation, keepDisplayRotation variables and logic for keeping and applying last rotation state --- PlayTools.xcodeproj/project.pbxproj | 6 ++- .../xcshareddata/swiftpm/Package.resolved | 51 +++++++++++++++++++ PlayTools/Controls/MenuController.swift | 18 +++++++ PlayTools/PlayCover.swift | 6 +++ PlayTools/PlaySettings.swift | 6 +++ 5 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 PlayTools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/PlayTools.xcodeproj/project.pbxproj b/PlayTools.xcodeproj/project.pbxproj index 6c0f2ad5..b622a44d 100644 --- a/PlayTools.xcodeproj/project.pbxproj +++ b/PlayTools.xcodeproj/project.pbxproj @@ -798,6 +798,7 @@ COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = 9H6323Q4VD; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_BUNDLE_NAME).AKPlugin"; @@ -830,6 +831,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = 9H6323Q4VD; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_BUNDLE_NAME).AKPlugin"; @@ -984,7 +986,7 @@ CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 792V9HMJW3; + DEVELOPMENT_TEAM = 9H6323Q4VD; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1029,7 +1031,7 @@ CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 792V9HMJW3; + DEVELOPMENT_TEAM = 9H6323Q4VD; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; diff --git a/PlayTools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/PlayTools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 00000000..b39ab74a --- /dev/null +++ b/PlayTools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,51 @@ +{ + "originHash" : "dd4b3820190814028b7a4ca2c138f5215df145753ed2a434b6bb89422721bd74", + "pins" : [ + { + "identity" : "swift-atomics", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-atomics.git", + "state" : { + "revision" : "b601256eab081c0f92f059e12818ac1d4f178ff7", + "version" : "1.3.0" + } + }, + { + "identity" : "swift-collections", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-collections.git", + "state" : { + "revision" : "7b847a3b7008b2dc2f47ca3110d8c782fb2e5c7e", + "version" : "1.3.0" + } + }, + { + "identity" : "swift-nio", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio", + "state" : { + "revision" : "4e8f4b1c9adaa59315c523540c1ff2b38adc20a9", + "version" : "2.87.0" + } + }, + { + "identity" : "swift-system", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-system.git", + "state" : { + "revision" : "395a77f0aa927f0ff73941d7ac35f2b46d47c9db", + "version" : "1.6.3" + } + }, + { + "identity" : "swordrpc", + "kind" : "remoteSourceControl", + "location" : "https://github.com/PlayCover/SwordRPC", + "state" : { + "branch" : "main", + "revision" : "914cf7d182dec59c7801136722c972c62ba16064" + } + } + ], + "version" : 3 +} diff --git a/PlayTools/Controls/MenuController.swift b/PlayTools/Controls/MenuController.swift index cd1d37f5..39255e56 100644 --- a/PlayTools/Controls/MenuController.swift +++ b/PlayTools/Controls/MenuController.swift @@ -14,6 +14,23 @@ class RotateViewController: UIViewController { static func rotate() { orientationTraverser += 1 + if PlaySettings.shared.keepDisplayRotation && orientationTraverser > PlaySettings.shared.displayRotation { + PlaySettings.shared.settingsData.displayRotation = orientationTraverser + let encoder = PropertyListEncoder() + encoder.outputFormat = .xml + + do { + let data = try encoder.encode(PlaySettings.shared.settingsData) + try data.write(to: PlaySettings.shared.settingsUrl) + } catch { + print(error) + } + } + if orientationTraverser == PlaySettings.shared.displayRotation-1 { + DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5, execute: { + UIApplication.shared.rotateView(self) + }) + } } override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { @@ -116,6 +133,7 @@ extension UIViewController { @objc func rotateView(_ sender: AnyObject) { RotateViewController.rotate() + RotateViewController.orientationTraverser %= RotateViewController.orientationList.count let viewController = RotateViewController(nibName: nil, bundle: nil) self.present(viewController, animated: true) DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1, execute: { diff --git a/PlayTools/PlayCover.swift b/PlayTools/PlayCover.swift index a45a24ab..5497c40f 100644 --- a/PlayTools/PlayCover.swift +++ b/PlayTools/PlayCover.swift @@ -21,6 +21,12 @@ public class PlayCover: NSObject { // Change the working directory to / just like iOS FileManager.default.changeCurrentDirectoryPath("/") } + + if PlaySettings.shared.displayRotation != 0 { + while RotateViewController.orientationTraverser Date: Sun, 19 Oct 2025 23:22:07 +0300 Subject: [PATCH 2/8] Add just the displayRotation variable and the logic for applying it --- PlayTools/Controls/MenuController.swift | 12 ------------ PlayTools/PlaySettings.swift | 5 +---- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/PlayTools/Controls/MenuController.swift b/PlayTools/Controls/MenuController.swift index 39255e56..3a3b3847 100644 --- a/PlayTools/Controls/MenuController.swift +++ b/PlayTools/Controls/MenuController.swift @@ -14,18 +14,6 @@ class RotateViewController: UIViewController { static func rotate() { orientationTraverser += 1 - if PlaySettings.shared.keepDisplayRotation && orientationTraverser > PlaySettings.shared.displayRotation { - PlaySettings.shared.settingsData.displayRotation = orientationTraverser - let encoder = PropertyListEncoder() - encoder.outputFormat = .xml - - do { - let data = try encoder.encode(PlaySettings.shared.settingsData) - try data.write(to: PlaySettings.shared.settingsUrl) - } catch { - print(error) - } - } if orientationTraverser == PlaySettings.shared.displayRotation-1 { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5, execute: { UIApplication.shared.rotateView(self) diff --git a/PlayTools/PlaySettings.swift b/PlayTools/PlaySettings.swift index 4caae283..fcc17b2d 100644 --- a/PlayTools/PlaySettings.swift +++ b/PlayTools/PlaySettings.swift @@ -85,9 +85,7 @@ let settings = PlaySettings.shared @objc lazy var hideTitleBar = settingsData.hideTitleBar @objc lazy var floatingWindow = settingsData.floatingWindow - - @objc lazy var keepDisplayRotation = settingsData.keepDisplayRotation - + @objc lazy var displayRotation = settingsData.displayRotation @objc lazy var checkMicPermissionSync = settingsData.checkMicPermissionSync @@ -108,7 +106,6 @@ struct AppSettingsData: Codable { var customScaler = 2.0 var resolution = 2 var aspectRatio = 1 - var keepDisplayRotation = true var displayRotation = 0 var notch = false var bypass = false From 092e0f739d501f808cdc01ab24d5b3d76fc73cfc Mon Sep 17 00:00:00 2001 From: luka2272 Date: Sat, 25 Oct 2025 08:53:32 +0300 Subject: [PATCH 3/8] Refactor display rotation logic --- PlayTools/Controls/MenuController.swift | 60 ++++++++++++++++++------- PlayTools/PlayCover.swift | 19 ++++++-- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/PlayTools/Controls/MenuController.swift b/PlayTools/Controls/MenuController.swift index 3a3b3847..96bc29c7 100644 --- a/PlayTools/Controls/MenuController.swift +++ b/PlayTools/Controls/MenuController.swift @@ -12,13 +12,8 @@ class RotateViewController: UIViewController { .landscapeLeft, .portrait, .landscapeRight, .portraitUpsideDown] static var orientationTraverser = 0 - static func rotate() { - orientationTraverser += 1 - if orientationTraverser == PlaySettings.shared.displayRotation-1 { - DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5, execute: { - UIApplication.shared.rotateView(self) - }) - } + static func rotate(ori: Int) { + orientationTraverser = ori } override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { @@ -63,7 +58,10 @@ extension UIApplication { guard let windowScene = scene as? UIWindowScene else { continue } for window in windowScene.windows { guard let rootViewController = window.rootViewController else { continue } - rootViewController.rotateView(sender) + if let dict = sender.propertyList as? [String: Any], + let index = dict["rotationIndex"] as? Int { + rootViewController.rotateView(sender, ori:index) + } } } @@ -119,8 +117,8 @@ extension UIApplication { extension UIViewController { @objc - func rotateView(_ sender: AnyObject) { - RotateViewController.rotate() + func rotateView(_ sender: AnyObject, ori: Int) { + RotateViewController.rotate(ori:ori) RotateViewController.orientationTraverser %= RotateViewController.orientationList.count let viewController = RotateViewController(nibName: nil, bundle: nil) self.present(viewController, animated: true) @@ -228,7 +226,6 @@ class MenuController { UIKeyCommand.inputDelete, // Remove keymap element UIKeyCommand.inputUpArrow, // Increase keymap element size UIKeyCommand.inputDownArrow, // Decrease keymap element size - "R", // Rotate display "D", // Toggle debug overlay ".", // Hide cursor until move "[", // Previous keymap @@ -244,11 +241,42 @@ class MenuController { ) } - let arrowKeysGroup = UIMenu(title: "", - image: nil, - identifier: .keymappingOptionsMenu, - options: .displayInline, - children: arrowKeyChildrenCommands) + let rotationTitles = [ + "Landscape Left (0°)", + "Portrait (90°)", + "Landscape Right (180°)", + "Portrait Upside Down (270°)" + ] + let rotationInputs = ["1", "2", "3", "4"] + + // Every rotation item calls the *same selector*, passing its index in propertyList + let rotationMenuItems = rotationTitles.enumerated().map { (index, title) in + UIKeyCommand( + title: title, + image: nil, + action: #selector(UIApplication.rotateView(_:)), + input: rotationInputs[index], + modifierFlags: [.command, .shift], // ⌘⇧1–4 + propertyList: ["rotationIndex": index] + ) + } + + let rotationMenu = UIMenu( + title: "Rotate Display", + image: nil, + identifier: UIMenu.Identifier("io.playcover.PlayTools.menus.rotation"), + options: .displayInline, + children: rotationMenuItems + ) + + // Combine all menus + let arrowKeysGroup = UIMenu( + title: "", + image: nil, + identifier: .keymappingOptionsMenu, + options: .displayInline, + children: arrowKeyChildrenCommands + [rotationMenu] + ) return UIMenu(title: NSLocalizedString("menu.keymapping", tableName: "Playtools", value: "Keymapping", comment: ""), diff --git a/PlayTools/PlayCover.swift b/PlayTools/PlayCover.swift index 5497c40f..df974a19 100644 --- a/PlayTools/PlayCover.swift +++ b/PlayTools/PlayCover.swift @@ -23,9 +23,22 @@ public class PlayCover: NSObject { } if PlaySettings.shared.displayRotation != 0 { - while RotateViewController.orientationTraverser Date: Sat, 25 Oct 2025 09:11:36 +0300 Subject: [PATCH 4/8] Try to fix wrong menu labels --- PlayTools/Controls/MenuController.swift | 2 -- 1 file changed, 2 deletions(-) diff --git a/PlayTools/Controls/MenuController.swift b/PlayTools/Controls/MenuController.swift index 96bc29c7..24e27be2 100644 --- a/PlayTools/Controls/MenuController.swift +++ b/PlayTools/Controls/MenuController.swift @@ -141,8 +141,6 @@ var keymapping = [ value: "Upsize selected element", comment: ""), NSLocalizedString("menu.keymapping.downsizeElement", tableName: "Playtools", value: "Downsize selected element", comment: ""), - NSLocalizedString("menu.keymapping.rotateDisplay", tableName: "Playtools", - value: "Rotate display area", comment: ""), NSLocalizedString("menu.keymapping.toggleDebug", tableName: "Playtools", value: "Toggle Debug Overlay", comment: ""), NSLocalizedString("menu.keymapping.hide.pointer", tableName: "Playtools", From 371c9f3074b25584f2ce45d17b3ae48f7315c66e Mon Sep 17 00:00:00 2001 From: luka2272 Date: Sat, 25 Oct 2025 09:27:48 +0300 Subject: [PATCH 5/8] Fix totation menu display --- PlayTools/Controls/MenuController.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PlayTools/Controls/MenuController.swift b/PlayTools/Controls/MenuController.swift index 24e27be2..b7d9d68e 100644 --- a/PlayTools/Controls/MenuController.swift +++ b/PlayTools/Controls/MenuController.swift @@ -260,10 +260,11 @@ class MenuController { } let rotationMenu = UIMenu( - title: "Rotate Display", + title: NSLocalizedString("menu.keymapping.rotateDisplay", tableName: "Playtools", + value: "Rotate display area", comment: ""), image: nil, - identifier: UIMenu.Identifier("io.playcover.PlayTools.menus.rotation"), - options: .displayInline, + identifier: .rotationOptionsMenu, + options: [], children: rotationMenuItems ) @@ -290,4 +291,5 @@ extension UIMenu.Identifier { static var keymappingOptionsMenu: UIMenu.Identifier { UIMenu.Identifier("io.playcover.PlayTools.menus.keymapping") } static var debuggingMenu: UIMenu.Identifier { UIMenu.Identifier("io.playcover.PlayTools.menus.debug") } static var debuggingOptionsMenu: UIMenu.Identifier { UIMenu.Identifier("io.playcover.PlayTools.menus.debugging") } + static var rotationOptionsMenu: UIMenu.Identifier { UIMenu.Identifier("io.playcover.PlayTools.menus.rotation") } } From 511dbee8327d19ca09301c8603d3cbc8b776eca0 Mon Sep 17 00:00:00 2001 From: luka2272 <105822062+luka2272@users.noreply.github.com> Date: Sun, 26 Oct 2025 08:48:42 +0200 Subject: [PATCH 6/8] Update project.pbxproj --- PlayTools.xcodeproj/project.pbxproj | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/PlayTools.xcodeproj/project.pbxproj b/PlayTools.xcodeproj/project.pbxproj index b622a44d..6c0f2ad5 100644 --- a/PlayTools.xcodeproj/project.pbxproj +++ b/PlayTools.xcodeproj/project.pbxproj @@ -798,7 +798,6 @@ COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; - DEVELOPMENT_TEAM = 9H6323Q4VD; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_BUNDLE_NAME).AKPlugin"; @@ -831,7 +830,6 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = 9H6323Q4VD; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_KEY_NSHumanReadableCopyright = ""; INFOPLIST_KEY_NSPrincipalClass = "$(PRODUCT_BUNDLE_NAME).AKPlugin"; @@ -986,7 +984,7 @@ CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 9H6323Q4VD; + DEVELOPMENT_TEAM = 792V9HMJW3; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1031,7 +1029,7 @@ CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 9H6323Q4VD; + DEVELOPMENT_TEAM = 792V9HMJW3; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; From ba364722308a76ab315be11b22d2e19c343eb31d Mon Sep 17 00:00:00 2001 From: luka2272 <105822062+luka2272@users.noreply.github.com> Date: Sun, 26 Oct 2025 08:58:58 +0200 Subject: [PATCH 7/8] Fix parameter name --- PlayTools/Controls/MenuController.swift | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/PlayTools/Controls/MenuController.swift b/PlayTools/Controls/MenuController.swift index b7d9d68e..dfbf00ce 100644 --- a/PlayTools/Controls/MenuController.swift +++ b/PlayTools/Controls/MenuController.swift @@ -12,8 +12,8 @@ class RotateViewController: UIViewController { .landscapeLeft, .portrait, .landscapeRight, .portraitUpsideDown] static var orientationTraverser = 0 - static func rotate(ori: Int) { - orientationTraverser = ori + static func rotate(deviceOrientation: Int) { + orientationTraverser = deviceOrientation } override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation { @@ -60,7 +60,7 @@ extension UIApplication { guard let rootViewController = window.rootViewController else { continue } if let dict = sender.propertyList as? [String: Any], let index = dict["rotationIndex"] as? Int { - rootViewController.rotateView(sender, ori:index) + rootViewController.rotateView(sender, deviceOrientation: index) } } } @@ -117,8 +117,8 @@ extension UIApplication { extension UIViewController { @objc - func rotateView(_ sender: AnyObject, ori: Int) { - RotateViewController.rotate(ori:ori) + func rotateView(_ sender: AnyObject, deviceOrientation: Int) { + RotateViewController.rotate(deviceOrientation: deviceOrientation) RotateViewController.orientationTraverser %= RotateViewController.orientationList.count let viewController = RotateViewController(nibName: nil, bundle: nil) self.present(viewController, animated: true) @@ -246,7 +246,7 @@ class MenuController { "Portrait Upside Down (270°)" ] let rotationInputs = ["1", "2", "3", "4"] - + // Every rotation item calls the *same selector*, passing its index in propertyList let rotationMenuItems = rotationTitles.enumerated().map { (index, title) in UIKeyCommand( @@ -258,7 +258,7 @@ class MenuController { propertyList: ["rotationIndex": index] ) } - + let rotationMenu = UIMenu( title: NSLocalizedString("menu.keymapping.rotateDisplay", tableName: "Playtools", value: "Rotate display area", comment: ""), @@ -267,7 +267,7 @@ class MenuController { options: [], children: rotationMenuItems ) - + // Combine all menus let arrowKeysGroup = UIMenu( title: "", From fb0335a43f90f6d5ce77bfbcd2ac88b2c3cab66a Mon Sep 17 00:00:00 2001 From: luka2272 <105822062+luka2272@users.noreply.github.com> Date: Mon, 27 Oct 2025 15:25:00 +0200 Subject: [PATCH 8/8] Delete Package.resolved --- .../xcshareddata/swiftpm/Package.resolved | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 PlayTools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved diff --git a/PlayTools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/PlayTools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved deleted file mode 100644 index b39ab74a..00000000 --- a/PlayTools.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ /dev/null @@ -1,51 +0,0 @@ -{ - "originHash" : "dd4b3820190814028b7a4ca2c138f5215df145753ed2a434b6bb89422721bd74", - "pins" : [ - { - "identity" : "swift-atomics", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-atomics.git", - "state" : { - "revision" : "b601256eab081c0f92f059e12818ac1d4f178ff7", - "version" : "1.3.0" - } - }, - { - "identity" : "swift-collections", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-collections.git", - "state" : { - "revision" : "7b847a3b7008b2dc2f47ca3110d8c782fb2e5c7e", - "version" : "1.3.0" - } - }, - { - "identity" : "swift-nio", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-nio", - "state" : { - "revision" : "4e8f4b1c9adaa59315c523540c1ff2b38adc20a9", - "version" : "2.87.0" - } - }, - { - "identity" : "swift-system", - "kind" : "remoteSourceControl", - "location" : "https://github.com/apple/swift-system.git", - "state" : { - "revision" : "395a77f0aa927f0ff73941d7ac35f2b46d47c9db", - "version" : "1.6.3" - } - }, - { - "identity" : "swordrpc", - "kind" : "remoteSourceControl", - "location" : "https://github.com/PlayCover/SwordRPC", - "state" : { - "branch" : "main", - "revision" : "914cf7d182dec59c7801136722c972c62ba16064" - } - } - ], - "version" : 3 -}