From 3c6824a40f2c3d08a11f92aefb81dc484cd610a8 Mon Sep 17 00:00:00 2001 From: Catta1997 Date: Sun, 29 Dec 2024 10:02:16 +0100 Subject: [PATCH 1/3] hideCursor --- AKPlugin.swift | 4 ++++ PlayTools/Controls/MenuController.swift | 16 +++++++++++++--- Plugin.swift | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/AKPlugin.swift b/AKPlugin.swift index 23ad8f2f..9ef99ba5 100644 --- a/AKPlugin.swift +++ b/AKPlugin.swift @@ -45,6 +45,10 @@ class AKPlugin: NSObject, Plugin { CGAssociateMouseAndMouseCursorPosition(0) warpCursor() } + + func hideCursorMove() { + NSCursor.setHiddenUntilMouseMoves(true) + } func warpCursor() { guard let firstScreen = NSScreen.screens.first else {return} diff --git a/PlayTools/Controls/MenuController.swift b/PlayTools/Controls/MenuController.swift index 597bfa5f..b5755862 100644 --- a/PlayTools/Controls/MenuController.swift +++ b/PlayTools/Controls/MenuController.swift @@ -71,6 +71,12 @@ extension UIApplication { func toggleDebugOverlay(_ sender: AnyObject) { DebugController.instance.toggleDebugOverlay() } + + @objc func hideCursor(_ sender: AnyObject) { + if(AKInterface.shared!.isFullscreen) { + AKInterface.shared!.hideCursorMove() + } + } } extension UIViewController { @@ -101,14 +107,17 @@ var keymapping = [ NSLocalizedString("menu.keymapping.rotateDisplay", tableName: "Playtools", value: "Rotate display area", comment: ""), NSLocalizedString("menu.keymapping.toggleDebug", tableName: "Playtools", - value: "Toggle Debug Overlay", comment: "") + value: "Toggle Debug Overlay", comment: ""), + NSLocalizedString("menu.keymapping.hide.pointer", tableName: "Playtools", + value: "Hide pointer on fullscreen", comment: "") ] var keymappingSelectors = [#selector(UIApplication.switchEditorMode(_:)), #selector(UIApplication.removeElement(_:)), #selector(UIApplication.upscaleElement(_:)), #selector(UIApplication.downscaleElement(_:)), #selector(UIApplication.rotateView(_:)), - #selector(UIApplication.toggleDebugOverlay(_:)) + #selector(UIApplication.toggleDebugOverlay(_:)), + #selector(UIApplication.hideCursor(_:)) ] class MenuController { @@ -150,7 +159,7 @@ class MenuController { class func keymappingMenu() -> UIMenu { let keyCommands = [ "K", UIKeyCommand.inputDelete, - UIKeyCommand.inputUpArrow, UIKeyCommand.inputDownArrow, "R", "D"] + UIKeyCommand.inputUpArrow, UIKeyCommand.inputDownArrow, "R", "D","."] let arrowKeyChildrenCommands = zip(keyCommands, keymapping).map { (command, btn) in UIKeyCommand(title: btn, image: nil, @@ -181,4 +190,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 hidePointer: UIMenu.Identifier { UIMenu.Identifier("io.playcover.PlayTools.hide.pointer") } } diff --git a/Plugin.swift b/Plugin.swift index 0949bd2d..6520c2eb 100644 --- a/Plugin.swift +++ b/Plugin.swift @@ -20,6 +20,7 @@ public protocol Plugin: NSObjectProtocol { var cmdPressed: Bool { get } func hideCursor() + func hideCursorMove() func warpCursor() func unhideCursor() func terminateApplication() From 08f47fbbe9a6c9a771b43cbe674f42df1649dea2 Mon Sep 17 00:00:00 2001 From: Catta1997 Date: Tue, 31 Dec 2024 18:38:41 +0100 Subject: [PATCH 2/3] fix --- PlayTools/Controls/MenuController.swift | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/PlayTools/Controls/MenuController.swift b/PlayTools/Controls/MenuController.swift index b5755862..5cddfff3 100644 --- a/PlayTools/Controls/MenuController.swift +++ b/PlayTools/Controls/MenuController.swift @@ -73,9 +73,7 @@ extension UIApplication { } @objc func hideCursor(_ sender: AnyObject) { - if(AKInterface.shared!.isFullscreen) { - AKInterface.shared!.hideCursorMove() - } + AKInterface.shared!.hideCursorMove() } } @@ -109,7 +107,7 @@ var keymapping = [ NSLocalizedString("menu.keymapping.toggleDebug", tableName: "Playtools", value: "Toggle Debug Overlay", comment: ""), NSLocalizedString("menu.keymapping.hide.pointer", tableName: "Playtools", - value: "Hide pointer on fullscreen", comment: "") + value: "Hide Mouse Pointer", comment: "") ] var keymappingSelectors = [#selector(UIApplication.switchEditorMode(_:)), #selector(UIApplication.removeElement(_:)), @@ -190,5 +188,4 @@ 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 hidePointer: UIMenu.Identifier { UIMenu.Identifier("io.playcover.PlayTools.hide.pointer") } } From 1f64c63d2f6044ff3aa18dfe6d0e2f6816ff7781 Mon Sep 17 00:00:00 2001 From: Catta1997 Date: Tue, 31 Dec 2024 18:42:22 +0100 Subject: [PATCH 3/3] fix SwiftLint --- AKPlugin.swift | 2 +- PlayTools/Controls/MenuController.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AKPlugin.swift b/AKPlugin.swift index 9ef99ba5..cc08a418 100644 --- a/AKPlugin.swift +++ b/AKPlugin.swift @@ -45,7 +45,7 @@ class AKPlugin: NSObject, Plugin { CGAssociateMouseAndMouseCursorPosition(0) warpCursor() } - + func hideCursorMove() { NSCursor.setHiddenUntilMouseMoves(true) } diff --git a/PlayTools/Controls/MenuController.swift b/PlayTools/Controls/MenuController.swift index 5cddfff3..1e970a9d 100644 --- a/PlayTools/Controls/MenuController.swift +++ b/PlayTools/Controls/MenuController.swift @@ -71,7 +71,7 @@ extension UIApplication { func toggleDebugOverlay(_ sender: AnyObject) { DebugController.instance.toggleDebugOverlay() } - + @objc func hideCursor(_ sender: AnyObject) { AKInterface.shared!.hideCursorMove() } @@ -157,7 +157,7 @@ class MenuController { class func keymappingMenu() -> UIMenu { let keyCommands = [ "K", UIKeyCommand.inputDelete, - UIKeyCommand.inputUpArrow, UIKeyCommand.inputDownArrow, "R", "D","."] + UIKeyCommand.inputUpArrow, UIKeyCommand.inputDownArrow, "R", "D", "."] let arrowKeyChildrenCommands = zip(keyCommands, keymapping).map { (command, btn) in UIKeyCommand(title: btn, image: nil,