-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from PlayCover/2.0-UI
2.0
- Loading branch information
Showing
32 changed files
with
1,091 additions
and
1,405 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// | ||
// Use this file to import your target's public headers that you would like to expose to Swift. | ||
// | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// MacPlugin.swift | ||
// AKInterface | ||
// | ||
// Created by Isaac Marovitz on 13/09/2022. | ||
// | ||
|
||
import AppKit | ||
import Foundation | ||
|
||
class AKPlugin: NSObject, Plugin { | ||
required override init() { | ||
} | ||
|
||
var screenCount: Int { | ||
NSScreen.screens.count | ||
} | ||
|
||
var mousePoint: CGPoint { | ||
NSApplication.shared.windows.first!.mouseLocationOutsideOfEventStream as CGPoint | ||
} | ||
|
||
var windowFrame: CGRect { | ||
NSApplication.shared.windows.first!.frame as CGRect | ||
} | ||
|
||
var isMainScreenEqualToFirst: Bool { | ||
return NSScreen.main == NSScreen.screens.first | ||
} | ||
|
||
var mainScreenFrame: CGRect { | ||
return NSScreen.main!.frame as CGRect | ||
} | ||
|
||
var isFullscreen: Bool { | ||
NSApplication.shared.windows.first!.styleMask.contains(.fullScreen) | ||
} | ||
|
||
func hideCursor() { | ||
NSCursor.hide() | ||
} | ||
|
||
func unhideCursor() { | ||
NSCursor.unhide() | ||
} | ||
|
||
func terminateApplication() { | ||
NSApplication.shared.terminate(self) | ||
} | ||
|
||
func eliminateRedundantKeyPressEvents(_ dontIgnore: @escaping() -> Bool) { | ||
NSEvent.addLocalMonitorForEvents(matching: .keyDown, handler: { event in | ||
if dontIgnore() { | ||
return event | ||
} | ||
return nil | ||
}) | ||
} | ||
|
||
func setupMouseButton(_ _up: Int, _ _down: Int, _ dontIgnore: @escaping(Int, Bool, Bool) -> Bool) { | ||
NSEvent.addLocalMonitorForEvents(matching: NSEvent.EventTypeMask(rawValue: UInt64(_up)), handler: { event in | ||
let isEventWindow = event.window == NSApplication.shared.windows.first! | ||
if dontIgnore(_up, true, isEventWindow) { | ||
return event | ||
} | ||
return nil | ||
}) | ||
NSEvent.addLocalMonitorForEvents(matching: NSEvent.EventTypeMask(rawValue: UInt64(_down)), handler: { event in | ||
if dontIgnore(_up, false, true) { | ||
return event | ||
} | ||
return nil | ||
}) | ||
} | ||
|
||
func urlForApplicationWithBundleIdentifier(_ value: String) -> URL? { | ||
NSWorkspace.shared.urlForApplication(withBundleIdentifier: value) | ||
} | ||
|
||
func setMenuBarVisible(_ visible: Bool) { | ||
NSMenu.setMenuBarVisible(visible) | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.