Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
6 changes: 4 additions & 2 deletions PlayTools.xcodeproj/project.pbxproj
Comment thread
luka2272 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 47 additions & 13 deletions PlayTools/Controls/MenuController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class RotateViewController: UIViewController {
.landscapeLeft, .portrait, .landscapeRight, .portraitUpsideDown]
static var orientationTraverser = 0

static func rotate() {
orientationTraverser += 1
static func rotate(ori: Int) {
Comment thread
luka2272 marked this conversation as resolved.
Outdated
orientationTraverser = ori
}

override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
Expand Down Expand Up @@ -58,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)
}
}
}

Expand Down Expand Up @@ -114,8 +117,9 @@ 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)
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 1, execute: {
Expand All @@ -137,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",
Expand Down Expand Up @@ -222,7 +224,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
Expand All @@ -238,11 +239,43 @@ class MenuController {
)
}

let arrowKeysGroup = UIMenu(title: "",
image: nil,
identifier: .keymappingOptionsMenu,
options: .displayInline,
children: arrowKeyChildrenCommands)
let rotationTitles = [
Comment thread
TheMoonThatRises marked this conversation as resolved.
Outdated
"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: NSLocalizedString("menu.keymapping.rotateDisplay", tableName: "Playtools",
value: "Rotate display area", comment: ""),
image: nil,
identifier: .rotationOptionsMenu,
options: [],
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: ""),
Expand All @@ -258,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") }
}
19 changes: 19 additions & 0 deletions PlayTools/PlayCover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ public class PlayCover: NSObject {
// Change the working directory to / just like iOS
FileManager.default.changeCurrentDirectoryPath("/")
}

if PlaySettings.shared.displayRotation != 0 {
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5, execute: {
let rotateCommand = UIKeyCommand(
title: "Keep Rotation Command",
image: nil,
action: #selector(UIApplication.rotateView(_:)),
input: "",
modifierFlags: [],
propertyList: ["rotationIndex": PlaySettings.shared.displayRotation]
)
UIApplication.shared.sendAction(
#selector(UIApplication.rotateView(_:)),
to: UIApplication.shared,
from: rotateCommand,
for: nil
)
})
}
}

@objc static public func initMenu(menu: NSObject) {
Expand Down
3 changes: 3 additions & 0 deletions PlayTools/PlaySettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ let settings = PlaySettings.shared

@objc lazy var floatingWindow = settingsData.floatingWindow

@objc lazy var displayRotation = settingsData.displayRotation

@objc lazy var checkMicPermissionSync = settingsData.checkMicPermissionSync

@objc lazy var limitMotionUpdateFrequency = settingsData.limitMotionUpdateFrequency
Expand All @@ -104,6 +106,7 @@ struct AppSettingsData: Codable {
var customScaler = 2.0
var resolution = 2
var aspectRatio = 1
var displayRotation = 0
var notch = false
var bypass = false
var discordActivity = DiscordActivity()
Expand Down