├── README.md ├── VirtualMouseMac.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── exerhythm.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist └── VirtualMouseMac ├── AppDelegate.swift ├── Assets.xcassets ├── AccentColor.colorset │ └── Contents.json ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Base.lproj └── Main.storyboard ├── ViewController.swift └── VirtualMouseMac.entitlements /README.md: -------------------------------------------------------------------------------- 1 | # VirtualMouseMacOS 2 | 3 | https://www.youtube.com/watch?v=rfGpdr-4nuM 4 | 5 | Use your iPhone as a mouse. Rotate it, move it to move the mouse 6 | 7 | Use with https://github.com/ExeRhythm/VirtualMouseiOS 8 | -------------------------------------------------------------------------------- /VirtualMouseMac.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 55; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CE18BC022731B508001B20B7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE18BC012731B508001B20B7 /* AppDelegate.swift */; }; 11 | CE18BC042731B508001B20B7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE18BC032731B508001B20B7 /* ViewController.swift */; }; 12 | CE18BC062731B509001B20B7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CE18BC052731B509001B20B7 /* Assets.xcassets */; }; 13 | CE18BC092731B509001B20B7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE18BC072731B509001B20B7 /* Main.storyboard */; }; 14 | CE18BC162731B589001B20B7 /* PeertalkManager in Frameworks */ = {isa = PBXBuildFile; productRef = CE18BC152731B589001B20B7 /* PeertalkManager */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXFileReference section */ 18 | CE18BBFE2731B508001B20B7 /* VirtualMouseMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VirtualMouseMac.app; sourceTree = BUILT_PRODUCTS_DIR; }; 19 | CE18BC012731B508001B20B7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 20 | CE18BC032731B508001B20B7 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 21 | CE18BC052731B509001B20B7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 22 | CE18BC082731B509001B20B7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 23 | CE18BC0A2731B509001B20B7 /* VirtualMouseMac.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = VirtualMouseMac.entitlements; sourceTree = ""; }; 24 | /* End PBXFileReference section */ 25 | 26 | /* Begin PBXFrameworksBuildPhase section */ 27 | CE18BBFB2731B508001B20B7 /* Frameworks */ = { 28 | isa = PBXFrameworksBuildPhase; 29 | buildActionMask = 2147483647; 30 | files = ( 31 | CE18BC162731B589001B20B7 /* PeertalkManager in Frameworks */, 32 | ); 33 | runOnlyForDeploymentPostprocessing = 0; 34 | }; 35 | /* End PBXFrameworksBuildPhase section */ 36 | 37 | /* Begin PBXGroup section */ 38 | CE18BBF52731B508001B20B7 = { 39 | isa = PBXGroup; 40 | children = ( 41 | CE18BC002731B508001B20B7 /* VirtualMouseMac */, 42 | CE18BBFF2731B508001B20B7 /* Products */, 43 | ); 44 | sourceTree = ""; 45 | }; 46 | CE18BBFF2731B508001B20B7 /* Products */ = { 47 | isa = PBXGroup; 48 | children = ( 49 | CE18BBFE2731B508001B20B7 /* VirtualMouseMac.app */, 50 | ); 51 | name = Products; 52 | sourceTree = ""; 53 | }; 54 | CE18BC002731B508001B20B7 /* VirtualMouseMac */ = { 55 | isa = PBXGroup; 56 | children = ( 57 | CE18BC012731B508001B20B7 /* AppDelegate.swift */, 58 | CE18BC032731B508001B20B7 /* ViewController.swift */, 59 | CE18BC052731B509001B20B7 /* Assets.xcassets */, 60 | CE18BC072731B509001B20B7 /* Main.storyboard */, 61 | CE18BC0A2731B509001B20B7 /* VirtualMouseMac.entitlements */, 62 | ); 63 | path = VirtualMouseMac; 64 | sourceTree = ""; 65 | }; 66 | /* End PBXGroup section */ 67 | 68 | /* Begin PBXNativeTarget section */ 69 | CE18BBFD2731B508001B20B7 /* VirtualMouseMac */ = { 70 | isa = PBXNativeTarget; 71 | buildConfigurationList = CE18BC0D2731B509001B20B7 /* Build configuration list for PBXNativeTarget "VirtualMouseMac" */; 72 | buildPhases = ( 73 | CE18BBFA2731B508001B20B7 /* Sources */, 74 | CE18BBFB2731B508001B20B7 /* Frameworks */, 75 | CE18BBFC2731B508001B20B7 /* Resources */, 76 | ); 77 | buildRules = ( 78 | ); 79 | dependencies = ( 80 | ); 81 | name = VirtualMouseMac; 82 | packageProductDependencies = ( 83 | CE18BC152731B589001B20B7 /* PeertalkManager */, 84 | ); 85 | productName = VirtualMouseMac; 86 | productReference = CE18BBFE2731B508001B20B7 /* VirtualMouseMac.app */; 87 | productType = "com.apple.product-type.application"; 88 | }; 89 | /* End PBXNativeTarget section */ 90 | 91 | /* Begin PBXProject section */ 92 | CE18BBF62731B508001B20B7 /* Project object */ = { 93 | isa = PBXProject; 94 | attributes = { 95 | BuildIndependentTargetsInParallel = 1; 96 | LastSwiftUpdateCheck = 1300; 97 | LastUpgradeCheck = 1300; 98 | TargetAttributes = { 99 | CE18BBFD2731B508001B20B7 = { 100 | CreatedOnToolsVersion = 13.0; 101 | }; 102 | }; 103 | }; 104 | buildConfigurationList = CE18BBF92731B508001B20B7 /* Build configuration list for PBXProject "VirtualMouseMac" */; 105 | compatibilityVersion = "Xcode 13.0"; 106 | developmentRegion = en; 107 | hasScannedForEncodings = 0; 108 | knownRegions = ( 109 | en, 110 | Base, 111 | ); 112 | mainGroup = CE18BBF52731B508001B20B7; 113 | packageReferences = ( 114 | CE18BC142731B589001B20B7 /* XCRemoteSwiftPackageReference "peertalk-simple" */, 115 | ); 116 | productRefGroup = CE18BBFF2731B508001B20B7 /* Products */; 117 | projectDirPath = ""; 118 | projectRoot = ""; 119 | targets = ( 120 | CE18BBFD2731B508001B20B7 /* VirtualMouseMac */, 121 | ); 122 | }; 123 | /* End PBXProject section */ 124 | 125 | /* Begin PBXResourcesBuildPhase section */ 126 | CE18BBFC2731B508001B20B7 /* Resources */ = { 127 | isa = PBXResourcesBuildPhase; 128 | buildActionMask = 2147483647; 129 | files = ( 130 | CE18BC062731B509001B20B7 /* Assets.xcassets in Resources */, 131 | CE18BC092731B509001B20B7 /* Main.storyboard in Resources */, 132 | ); 133 | runOnlyForDeploymentPostprocessing = 0; 134 | }; 135 | /* End PBXResourcesBuildPhase section */ 136 | 137 | /* Begin PBXSourcesBuildPhase section */ 138 | CE18BBFA2731B508001B20B7 /* Sources */ = { 139 | isa = PBXSourcesBuildPhase; 140 | buildActionMask = 2147483647; 141 | files = ( 142 | CE18BC042731B508001B20B7 /* ViewController.swift in Sources */, 143 | CE18BC022731B508001B20B7 /* AppDelegate.swift in Sources */, 144 | ); 145 | runOnlyForDeploymentPostprocessing = 0; 146 | }; 147 | /* End PBXSourcesBuildPhase section */ 148 | 149 | /* Begin PBXVariantGroup section */ 150 | CE18BC072731B509001B20B7 /* Main.storyboard */ = { 151 | isa = PBXVariantGroup; 152 | children = ( 153 | CE18BC082731B509001B20B7 /* Base */, 154 | ); 155 | name = Main.storyboard; 156 | sourceTree = ""; 157 | }; 158 | /* End PBXVariantGroup section */ 159 | 160 | /* Begin XCBuildConfiguration section */ 161 | CE18BC0B2731B509001B20B7 /* Debug */ = { 162 | isa = XCBuildConfiguration; 163 | buildSettings = { 164 | ALWAYS_SEARCH_USER_PATHS = NO; 165 | CLANG_ANALYZER_NONNULL = YES; 166 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 167 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 168 | CLANG_CXX_LIBRARY = "libc++"; 169 | CLANG_ENABLE_MODULES = YES; 170 | CLANG_ENABLE_OBJC_ARC = YES; 171 | CLANG_ENABLE_OBJC_WEAK = YES; 172 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 173 | CLANG_WARN_BOOL_CONVERSION = YES; 174 | CLANG_WARN_COMMA = YES; 175 | CLANG_WARN_CONSTANT_CONVERSION = YES; 176 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 177 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 178 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 179 | CLANG_WARN_EMPTY_BODY = YES; 180 | CLANG_WARN_ENUM_CONVERSION = YES; 181 | CLANG_WARN_INFINITE_RECURSION = YES; 182 | CLANG_WARN_INT_CONVERSION = YES; 183 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 184 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 185 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 186 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 187 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 188 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 189 | CLANG_WARN_STRICT_PROTOTYPES = YES; 190 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 191 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 192 | CLANG_WARN_UNREACHABLE_CODE = YES; 193 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 194 | COPY_PHASE_STRIP = NO; 195 | DEBUG_INFORMATION_FORMAT = dwarf; 196 | ENABLE_STRICT_OBJC_MSGSEND = YES; 197 | ENABLE_TESTABILITY = YES; 198 | GCC_C_LANGUAGE_STANDARD = gnu11; 199 | GCC_DYNAMIC_NO_PIC = NO; 200 | GCC_NO_COMMON_BLOCKS = YES; 201 | GCC_OPTIMIZATION_LEVEL = 0; 202 | GCC_PREPROCESSOR_DEFINITIONS = ( 203 | "DEBUG=1", 204 | "$(inherited)", 205 | ); 206 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 207 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 208 | GCC_WARN_UNDECLARED_SELECTOR = YES; 209 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 210 | GCC_WARN_UNUSED_FUNCTION = YES; 211 | GCC_WARN_UNUSED_VARIABLE = YES; 212 | MACOSX_DEPLOYMENT_TARGET = 11.3; 213 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 214 | MTL_FAST_MATH = YES; 215 | ONLY_ACTIVE_ARCH = YES; 216 | SDKROOT = macosx; 217 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 218 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 219 | }; 220 | name = Debug; 221 | }; 222 | CE18BC0C2731B509001B20B7 /* Release */ = { 223 | isa = XCBuildConfiguration; 224 | buildSettings = { 225 | ALWAYS_SEARCH_USER_PATHS = NO; 226 | CLANG_ANALYZER_NONNULL = YES; 227 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 228 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 229 | CLANG_CXX_LIBRARY = "libc++"; 230 | CLANG_ENABLE_MODULES = YES; 231 | CLANG_ENABLE_OBJC_ARC = YES; 232 | CLANG_ENABLE_OBJC_WEAK = YES; 233 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 234 | CLANG_WARN_BOOL_CONVERSION = YES; 235 | CLANG_WARN_COMMA = YES; 236 | CLANG_WARN_CONSTANT_CONVERSION = YES; 237 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 238 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 239 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 240 | CLANG_WARN_EMPTY_BODY = YES; 241 | CLANG_WARN_ENUM_CONVERSION = YES; 242 | CLANG_WARN_INFINITE_RECURSION = YES; 243 | CLANG_WARN_INT_CONVERSION = YES; 244 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 245 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 246 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 247 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 248 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 249 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 250 | CLANG_WARN_STRICT_PROTOTYPES = YES; 251 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 252 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 253 | CLANG_WARN_UNREACHABLE_CODE = YES; 254 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 255 | COPY_PHASE_STRIP = NO; 256 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 257 | ENABLE_NS_ASSERTIONS = NO; 258 | ENABLE_STRICT_OBJC_MSGSEND = YES; 259 | GCC_C_LANGUAGE_STANDARD = gnu11; 260 | GCC_NO_COMMON_BLOCKS = YES; 261 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 262 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 263 | GCC_WARN_UNDECLARED_SELECTOR = YES; 264 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 265 | GCC_WARN_UNUSED_FUNCTION = YES; 266 | GCC_WARN_UNUSED_VARIABLE = YES; 267 | MACOSX_DEPLOYMENT_TARGET = 11.3; 268 | MTL_ENABLE_DEBUG_INFO = NO; 269 | MTL_FAST_MATH = YES; 270 | SDKROOT = macosx; 271 | SWIFT_COMPILATION_MODE = wholemodule; 272 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 273 | }; 274 | name = Release; 275 | }; 276 | CE18BC0E2731B509001B20B7 /* Debug */ = { 277 | isa = XCBuildConfiguration; 278 | buildSettings = { 279 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 280 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 281 | CODE_SIGN_ENTITLEMENTS = VirtualMouseMac/VirtualMouseMac.entitlements; 282 | CODE_SIGN_STYLE = Automatic; 283 | COMBINE_HIDPI_IMAGES = YES; 284 | CURRENT_PROJECT_VERSION = 1; 285 | DEVELOPMENT_TEAM = 92S6JX27W2; 286 | ENABLE_HARDENED_RUNTIME = NO; 287 | GENERATE_INFOPLIST_FILE = YES; 288 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 289 | INFOPLIST_KEY_NSMainStoryboardFile = Main; 290 | INFOPLIST_KEY_NSPrincipalClass = NSApplication; 291 | LD_RUNPATH_SEARCH_PATHS = ( 292 | "$(inherited)", 293 | "@executable_path/../Frameworks", 294 | ); 295 | MARKETING_VERSION = 1.0; 296 | PRODUCT_BUNDLE_IDENTIFIER = ovh.exerhythm.VirtualMouseMac; 297 | PRODUCT_NAME = "$(TARGET_NAME)"; 298 | SWIFT_EMIT_LOC_STRINGS = YES; 299 | SWIFT_VERSION = 5.0; 300 | }; 301 | name = Debug; 302 | }; 303 | CE18BC0F2731B509001B20B7 /* Release */ = { 304 | isa = XCBuildConfiguration; 305 | buildSettings = { 306 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 307 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 308 | CODE_SIGN_ENTITLEMENTS = VirtualMouseMac/VirtualMouseMac.entitlements; 309 | CODE_SIGN_STYLE = Automatic; 310 | COMBINE_HIDPI_IMAGES = YES; 311 | CURRENT_PROJECT_VERSION = 1; 312 | DEVELOPMENT_TEAM = 92S6JX27W2; 313 | ENABLE_HARDENED_RUNTIME = NO; 314 | GENERATE_INFOPLIST_FILE = YES; 315 | INFOPLIST_KEY_NSHumanReadableCopyright = ""; 316 | INFOPLIST_KEY_NSMainStoryboardFile = Main; 317 | INFOPLIST_KEY_NSPrincipalClass = NSApplication; 318 | LD_RUNPATH_SEARCH_PATHS = ( 319 | "$(inherited)", 320 | "@executable_path/../Frameworks", 321 | ); 322 | MARKETING_VERSION = 1.0; 323 | PRODUCT_BUNDLE_IDENTIFIER = ovh.exerhythm.VirtualMouseMac; 324 | PRODUCT_NAME = "$(TARGET_NAME)"; 325 | SWIFT_EMIT_LOC_STRINGS = YES; 326 | SWIFT_VERSION = 5.0; 327 | }; 328 | name = Release; 329 | }; 330 | /* End XCBuildConfiguration section */ 331 | 332 | /* Begin XCConfigurationList section */ 333 | CE18BBF92731B508001B20B7 /* Build configuration list for PBXProject "VirtualMouseMac" */ = { 334 | isa = XCConfigurationList; 335 | buildConfigurations = ( 336 | CE18BC0B2731B509001B20B7 /* Debug */, 337 | CE18BC0C2731B509001B20B7 /* Release */, 338 | ); 339 | defaultConfigurationIsVisible = 0; 340 | defaultConfigurationName = Release; 341 | }; 342 | CE18BC0D2731B509001B20B7 /* Build configuration list for PBXNativeTarget "VirtualMouseMac" */ = { 343 | isa = XCConfigurationList; 344 | buildConfigurations = ( 345 | CE18BC0E2731B509001B20B7 /* Debug */, 346 | CE18BC0F2731B509001B20B7 /* Release */, 347 | ); 348 | defaultConfigurationIsVisible = 0; 349 | defaultConfigurationName = Release; 350 | }; 351 | /* End XCConfigurationList section */ 352 | 353 | /* Begin XCRemoteSwiftPackageReference section */ 354 | CE18BC142731B589001B20B7 /* XCRemoteSwiftPackageReference "peertalk-simple" */ = { 355 | isa = XCRemoteSwiftPackageReference; 356 | repositoryURL = "https://github.com/kokluch/peertalk-simple"; 357 | requirement = { 358 | kind = upToNextMajorVersion; 359 | minimumVersion = 0.2.0; 360 | }; 361 | }; 362 | /* End XCRemoteSwiftPackageReference section */ 363 | 364 | /* Begin XCSwiftPackageProductDependency section */ 365 | CE18BC152731B589001B20B7 /* PeertalkManager */ = { 366 | isa = XCSwiftPackageProductDependency; 367 | package = CE18BC142731B589001B20B7 /* XCRemoteSwiftPackageReference "peertalk-simple" */; 368 | productName = PeertalkManager; 369 | }; 370 | /* End XCSwiftPackageProductDependency section */ 371 | }; 372 | rootObject = CE18BBF62731B508001B20B7 /* Project object */; 373 | } 374 | -------------------------------------------------------------------------------- /VirtualMouseMac.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /VirtualMouseMac.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /VirtualMouseMac.xcodeproj/xcuserdata/exerhythm.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | VirtualMouseMac.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /VirtualMouseMac/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // VirtualMouseMac 4 | // 5 | // Created by exerhythm on 11/2/21. 6 | // 7 | 8 | import Cocoa 9 | 10 | @main 11 | class AppDelegate: NSObject, NSApplicationDelegate { 12 | 13 | 14 | 15 | 16 | func applicationDidFinishLaunching(_ aNotification: Notification) { 17 | // Insert code here to initialize your application 18 | } 19 | 20 | func applicationWillTerminate(_ aNotification: Notification) { 21 | // Insert code here to tear down your application 22 | } 23 | 24 | func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { 25 | return true 26 | } 27 | 28 | 29 | } 30 | 31 | -------------------------------------------------------------------------------- /VirtualMouseMac/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /VirtualMouseMac/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "scale" : "1x", 6 | "size" : "16x16" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "scale" : "2x", 11 | "size" : "16x16" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "scale" : "1x", 16 | "size" : "32x32" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "scale" : "2x", 21 | "size" : "32x32" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "scale" : "1x", 26 | "size" : "128x128" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "scale" : "2x", 31 | "size" : "128x128" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "scale" : "1x", 36 | "size" : "256x256" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "scale" : "2x", 41 | "size" : "256x256" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "scale" : "1x", 46 | "size" : "512x512" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "scale" : "2x", 51 | "size" : "512x512" 52 | } 53 | ], 54 | "info" : { 55 | "author" : "xcode", 56 | "version" : 1 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /VirtualMouseMac/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /VirtualMouseMac/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | Default 531 | 532 | 533 | 534 | 535 | 536 | 537 | Left to Right 538 | 539 | 540 | 541 | 542 | 543 | 544 | Right to Left 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | Default 556 | 557 | 558 | 559 | 560 | 561 | 562 | Left to Right 563 | 564 | 565 | 566 | 567 | 568 | 569 | Right to Left 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | -------------------------------------------------------------------------------- /VirtualMouseMac/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // VirtualMouseMac 4 | // 5 | // Created by exerhythm on 11/2/21. 6 | // 7 | 8 | import Cocoa 9 | import PeertalkManager 10 | 11 | class ViewController: NSViewController, PTManagerDelegate { 12 | 13 | var sensivity: Double = 35 14 | var acc = 1.2 15 | 16 | var leftMouseHeld = false 17 | func peertalk(shouldAcceptDataOfType type: UInt32) -> Bool { 18 | return true 19 | } 20 | 21 | func peertalk(didReceiveData data: Data?, ofType type: UInt32) { 22 | switch type { 23 | case PTType.pos.rawValue: 24 | guard let str = String(data: data!, encoding: .utf8) else { return } 25 | let pos = str.components(separatedBy: ";").map { Double($0)! } 26 | mouseMoveBy(x: pos[1], y: pos[0]) 27 | case PTType.clickleft.rawValue, PTType.clickright.rawValue: 28 | guard let str = String(data: data!, encoding: .utf8) else { return } 29 | print(str) 30 | switch str { 31 | case "down": 32 | mouseDown(point: CGPoint(x: NSEvent.mouseLocation.x, y: NSScreen.main!.frame.size.height - NSEvent.mouseLocation.y), mouseButton: type == 101 ? .left : .right) 33 | leftMouseHeld = true 34 | case "up": 35 | mouseUp(point: CGPoint(x: NSEvent.mouseLocation.x, y: NSScreen.main!.frame.size.height - NSEvent.mouseLocation.y), mouseButton: type == 101 ? .left : .right) 36 | leftMouseHeld = false 37 | default: 38 | break 39 | } 40 | default: 41 | break 42 | } 43 | } 44 | 45 | func peertalk(didChangeConnection connected: Bool) { 46 | print(connected) 47 | } 48 | 49 | 50 | let mngr = PTManager() 51 | 52 | @IBAction func start(_ sender: NSButton) { 53 | mngr.delegate = self 54 | mngr.connect(portNumber: 2345) 55 | } 56 | 57 | override func viewDidLoad() { 58 | super.viewDidLoad() 59 | 60 | // Do any additional setup after loading the view. 61 | } 62 | 63 | override var representedObject: Any? { 64 | didSet { 65 | // Update the view, if already loaded. 66 | } 67 | } 68 | 69 | func mouseDown(point: CGPoint, mouseButton: CGMouseButton = CGMouseButton.left) { 70 | CGEvent(mouseEventSource: nil, mouseType: mouseButton == .left ? .leftMouseDown : .rightMouseDown, mouseCursorPosition: point, mouseButton: mouseButton)?.post(tap: CGEventTapLocation.cghidEventTap) 71 | } 72 | func mouseDrag(point: CGPoint, mouseButton: CGMouseButton = CGMouseButton.left) { 73 | CGEvent(mouseEventSource: nil, mouseType: mouseButton == .left ? .leftMouseDragged : .rightMouseDragged, mouseCursorPosition: point, mouseButton: mouseButton)?.post(tap: CGEventTapLocation.cghidEventTap) 74 | } 75 | func mouseUp(point: CGPoint, mouseButton: CGMouseButton = CGMouseButton.left) { 76 | CGEvent(mouseEventSource: nil, mouseType: mouseButton == .left ? .leftMouseUp : .rightMouseUp, mouseCursorPosition: point, mouseButton: mouseButton)?.post(tap: CGEventTapLocation.cghidEventTap) 77 | } 78 | 79 | func moveMouseTo(point: CGPoint) { 80 | CGEvent(mouseEventSource: nil, mouseType: CGEventType.mouseMoved, mouseCursorPosition: point, mouseButton: CGMouseButton.left)?.post(tap: CGEventTapLocation.cghidEventTap) 81 | } 82 | func mouseMoveBy(x: Double, y: Double) { 83 | // print(x,y) 84 | let screenSize = NSScreen.main?.frame.size 85 | let currentLocation = NSEvent.mouseLocation 86 | let destination = CGPoint(x: currentLocation.x + x * sensivity, y: screenSize!.height - (currentLocation.y - y * sensivity)) 87 | 88 | if !leftMouseHeld { 89 | moveMouseTo(point: destination) 90 | } else { 91 | mouseDrag(point: destination) 92 | } 93 | } 94 | } 95 | 96 | 97 | enum PTType: UInt32 { 98 | case pos = 100 99 | case clickleft = 101 100 | case clickright = 102 101 | } 102 | -------------------------------------------------------------------------------- /VirtualMouseMac/VirtualMouseMac.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | --------------------------------------------------------------------------------