├── README.md ├── VirtualMouse.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcuserdata │ └── exerhythm.xcuserdatad │ └── xcschemes │ └── xcschememanagement.plist └── VirtualMouse ├── AppDelegate.swift ├── Assets.xcassets ├── AccentColor.colorset │ └── Contents.json ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── SceneDelegate.swift └── ViewController.swift /README.md: -------------------------------------------------------------------------------- 1 | # VirtualMouseiOS 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/VirtualMouseMacOS 8 | -------------------------------------------------------------------------------- /VirtualMouse.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 55; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CE18BC132731B579001B20B7 /* PeertalkManager in Frameworks */ = {isa = PBXBuildFile; productRef = CE18BC122731B579001B20B7 /* PeertalkManager */; }; 11 | CE36DA472731A51B00CD68D0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE36DA462731A51B00CD68D0 /* AppDelegate.swift */; }; 12 | CE36DA492731A51B00CD68D0 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE36DA482731A51B00CD68D0 /* SceneDelegate.swift */; }; 13 | CE36DA4B2731A51B00CD68D0 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE36DA4A2731A51B00CD68D0 /* ViewController.swift */; }; 14 | CE36DA4E2731A51B00CD68D0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE36DA4C2731A51B00CD68D0 /* Main.storyboard */; }; 15 | CE36DA502731A51C00CD68D0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CE36DA4F2731A51C00CD68D0 /* Assets.xcassets */; }; 16 | CE36DA532731A51C00CD68D0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CE36DA512731A51C00CD68D0 /* LaunchScreen.storyboard */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | CE36DA432731A51B00CD68D0 /* VirtualMouse.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VirtualMouse.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | CE36DA462731A51B00CD68D0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 22 | CE36DA482731A51B00CD68D0 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; 23 | CE36DA4A2731A51B00CD68D0 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 24 | CE36DA4D2731A51B00CD68D0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 25 | CE36DA4F2731A51C00CD68D0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 26 | CE36DA522731A51C00CD68D0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 27 | CE36DA542731A51C00CD68D0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 28 | /* End PBXFileReference section */ 29 | 30 | /* Begin PBXFrameworksBuildPhase section */ 31 | CE36DA402731A51B00CD68D0 /* Frameworks */ = { 32 | isa = PBXFrameworksBuildPhase; 33 | buildActionMask = 2147483647; 34 | files = ( 35 | CE18BC132731B579001B20B7 /* PeertalkManager in Frameworks */, 36 | ); 37 | runOnlyForDeploymentPostprocessing = 0; 38 | }; 39 | /* End PBXFrameworksBuildPhase section */ 40 | 41 | /* Begin PBXGroup section */ 42 | CE18BC102731B562001B20B7 /* Frameworks */ = { 43 | isa = PBXGroup; 44 | children = ( 45 | ); 46 | name = Frameworks; 47 | sourceTree = ""; 48 | }; 49 | CE36DA3A2731A51B00CD68D0 = { 50 | isa = PBXGroup; 51 | children = ( 52 | CE36DA452731A51B00CD68D0 /* VirtualMouse */, 53 | CE36DA442731A51B00CD68D0 /* Products */, 54 | CE18BC102731B562001B20B7 /* Frameworks */, 55 | ); 56 | sourceTree = ""; 57 | }; 58 | CE36DA442731A51B00CD68D0 /* Products */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | CE36DA432731A51B00CD68D0 /* VirtualMouse.app */, 62 | ); 63 | name = Products; 64 | sourceTree = ""; 65 | }; 66 | CE36DA452731A51B00CD68D0 /* VirtualMouse */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | CE36DA462731A51B00CD68D0 /* AppDelegate.swift */, 70 | CE36DA482731A51B00CD68D0 /* SceneDelegate.swift */, 71 | CE36DA4A2731A51B00CD68D0 /* ViewController.swift */, 72 | CE36DA4C2731A51B00CD68D0 /* Main.storyboard */, 73 | CE36DA4F2731A51C00CD68D0 /* Assets.xcassets */, 74 | CE36DA512731A51C00CD68D0 /* LaunchScreen.storyboard */, 75 | CE36DA542731A51C00CD68D0 /* Info.plist */, 76 | ); 77 | path = VirtualMouse; 78 | sourceTree = ""; 79 | }; 80 | /* End PBXGroup section */ 81 | 82 | /* Begin PBXNativeTarget section */ 83 | CE36DA422731A51B00CD68D0 /* VirtualMouse */ = { 84 | isa = PBXNativeTarget; 85 | buildConfigurationList = CE36DA572731A51C00CD68D0 /* Build configuration list for PBXNativeTarget "VirtualMouse" */; 86 | buildPhases = ( 87 | CE36DA3F2731A51B00CD68D0 /* Sources */, 88 | CE36DA402731A51B00CD68D0 /* Frameworks */, 89 | CE36DA412731A51B00CD68D0 /* Resources */, 90 | ); 91 | buildRules = ( 92 | ); 93 | dependencies = ( 94 | ); 95 | name = VirtualMouse; 96 | packageProductDependencies = ( 97 | CE18BC122731B579001B20B7 /* PeertalkManager */, 98 | ); 99 | productName = VirtualMouse; 100 | productReference = CE36DA432731A51B00CD68D0 /* VirtualMouse.app */; 101 | productType = "com.apple.product-type.application"; 102 | }; 103 | /* End PBXNativeTarget section */ 104 | 105 | /* Begin PBXProject section */ 106 | CE36DA3B2731A51B00CD68D0 /* Project object */ = { 107 | isa = PBXProject; 108 | attributes = { 109 | BuildIndependentTargetsInParallel = 1; 110 | LastSwiftUpdateCheck = 1300; 111 | LastUpgradeCheck = 1300; 112 | TargetAttributes = { 113 | CE36DA422731A51B00CD68D0 = { 114 | CreatedOnToolsVersion = 13.0; 115 | }; 116 | }; 117 | }; 118 | buildConfigurationList = CE36DA3E2731A51B00CD68D0 /* Build configuration list for PBXProject "VirtualMouse" */; 119 | compatibilityVersion = "Xcode 13.0"; 120 | developmentRegion = en; 121 | hasScannedForEncodings = 0; 122 | knownRegions = ( 123 | en, 124 | Base, 125 | ); 126 | mainGroup = CE36DA3A2731A51B00CD68D0; 127 | packageReferences = ( 128 | CE18BC112731B579001B20B7 /* XCRemoteSwiftPackageReference "peertalk-simple" */, 129 | ); 130 | productRefGroup = CE36DA442731A51B00CD68D0 /* Products */; 131 | projectDirPath = ""; 132 | projectRoot = ""; 133 | targets = ( 134 | CE36DA422731A51B00CD68D0 /* VirtualMouse */, 135 | ); 136 | }; 137 | /* End PBXProject section */ 138 | 139 | /* Begin PBXResourcesBuildPhase section */ 140 | CE36DA412731A51B00CD68D0 /* Resources */ = { 141 | isa = PBXResourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | CE36DA532731A51C00CD68D0 /* LaunchScreen.storyboard in Resources */, 145 | CE36DA502731A51C00CD68D0 /* Assets.xcassets in Resources */, 146 | CE36DA4E2731A51B00CD68D0 /* Main.storyboard in Resources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXResourcesBuildPhase section */ 151 | 152 | /* Begin PBXSourcesBuildPhase section */ 153 | CE36DA3F2731A51B00CD68D0 /* Sources */ = { 154 | isa = PBXSourcesBuildPhase; 155 | buildActionMask = 2147483647; 156 | files = ( 157 | CE36DA4B2731A51B00CD68D0 /* ViewController.swift in Sources */, 158 | CE36DA472731A51B00CD68D0 /* AppDelegate.swift in Sources */, 159 | CE36DA492731A51B00CD68D0 /* SceneDelegate.swift in Sources */, 160 | ); 161 | runOnlyForDeploymentPostprocessing = 0; 162 | }; 163 | /* End PBXSourcesBuildPhase section */ 164 | 165 | /* Begin PBXVariantGroup section */ 166 | CE36DA4C2731A51B00CD68D0 /* Main.storyboard */ = { 167 | isa = PBXVariantGroup; 168 | children = ( 169 | CE36DA4D2731A51B00CD68D0 /* Base */, 170 | ); 171 | name = Main.storyboard; 172 | sourceTree = ""; 173 | }; 174 | CE36DA512731A51C00CD68D0 /* LaunchScreen.storyboard */ = { 175 | isa = PBXVariantGroup; 176 | children = ( 177 | CE36DA522731A51C00CD68D0 /* Base */, 178 | ); 179 | name = LaunchScreen.storyboard; 180 | sourceTree = ""; 181 | }; 182 | /* End PBXVariantGroup section */ 183 | 184 | /* Begin XCBuildConfiguration section */ 185 | CE36DA552731A51C00CD68D0 /* Debug */ = { 186 | isa = XCBuildConfiguration; 187 | buildSettings = { 188 | ALWAYS_SEARCH_USER_PATHS = NO; 189 | CLANG_ANALYZER_NONNULL = YES; 190 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 191 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 192 | CLANG_CXX_LIBRARY = "libc++"; 193 | CLANG_ENABLE_MODULES = YES; 194 | CLANG_ENABLE_OBJC_ARC = YES; 195 | CLANG_ENABLE_OBJC_WEAK = YES; 196 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 197 | CLANG_WARN_BOOL_CONVERSION = YES; 198 | CLANG_WARN_COMMA = YES; 199 | CLANG_WARN_CONSTANT_CONVERSION = YES; 200 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 201 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 202 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 203 | CLANG_WARN_EMPTY_BODY = YES; 204 | CLANG_WARN_ENUM_CONVERSION = YES; 205 | CLANG_WARN_INFINITE_RECURSION = YES; 206 | CLANG_WARN_INT_CONVERSION = YES; 207 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 208 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 209 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 210 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 211 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 212 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 213 | CLANG_WARN_STRICT_PROTOTYPES = YES; 214 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 215 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 216 | CLANG_WARN_UNREACHABLE_CODE = YES; 217 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 218 | COPY_PHASE_STRIP = NO; 219 | DEBUG_INFORMATION_FORMAT = dwarf; 220 | ENABLE_STRICT_OBJC_MSGSEND = YES; 221 | ENABLE_TESTABILITY = YES; 222 | GCC_C_LANGUAGE_STANDARD = gnu11; 223 | GCC_DYNAMIC_NO_PIC = NO; 224 | GCC_NO_COMMON_BLOCKS = YES; 225 | GCC_OPTIMIZATION_LEVEL = 0; 226 | GCC_PREPROCESSOR_DEFINITIONS = ( 227 | "DEBUG=1", 228 | "$(inherited)", 229 | ); 230 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 231 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 232 | GCC_WARN_UNDECLARED_SELECTOR = YES; 233 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 234 | GCC_WARN_UNUSED_FUNCTION = YES; 235 | GCC_WARN_UNUSED_VARIABLE = YES; 236 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 237 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 238 | MTL_FAST_MATH = YES; 239 | ONLY_ACTIVE_ARCH = YES; 240 | SDKROOT = iphoneos; 241 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 242 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 243 | }; 244 | name = Debug; 245 | }; 246 | CE36DA562731A51C00CD68D0 /* Release */ = { 247 | isa = XCBuildConfiguration; 248 | buildSettings = { 249 | ALWAYS_SEARCH_USER_PATHS = NO; 250 | CLANG_ANALYZER_NONNULL = YES; 251 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 252 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; 253 | CLANG_CXX_LIBRARY = "libc++"; 254 | CLANG_ENABLE_MODULES = YES; 255 | CLANG_ENABLE_OBJC_ARC = YES; 256 | CLANG_ENABLE_OBJC_WEAK = YES; 257 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 258 | CLANG_WARN_BOOL_CONVERSION = YES; 259 | CLANG_WARN_COMMA = YES; 260 | CLANG_WARN_CONSTANT_CONVERSION = YES; 261 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 262 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 263 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 264 | CLANG_WARN_EMPTY_BODY = YES; 265 | CLANG_WARN_ENUM_CONVERSION = YES; 266 | CLANG_WARN_INFINITE_RECURSION = YES; 267 | CLANG_WARN_INT_CONVERSION = YES; 268 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 269 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 270 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 271 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 272 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 273 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 274 | CLANG_WARN_STRICT_PROTOTYPES = YES; 275 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 276 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 277 | CLANG_WARN_UNREACHABLE_CODE = YES; 278 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 279 | COPY_PHASE_STRIP = NO; 280 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 281 | ENABLE_NS_ASSERTIONS = NO; 282 | ENABLE_STRICT_OBJC_MSGSEND = YES; 283 | GCC_C_LANGUAGE_STANDARD = gnu11; 284 | GCC_NO_COMMON_BLOCKS = YES; 285 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 286 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 287 | GCC_WARN_UNDECLARED_SELECTOR = YES; 288 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 289 | GCC_WARN_UNUSED_FUNCTION = YES; 290 | GCC_WARN_UNUSED_VARIABLE = YES; 291 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 292 | MTL_ENABLE_DEBUG_INFO = NO; 293 | MTL_FAST_MATH = YES; 294 | SDKROOT = iphoneos; 295 | SWIFT_COMPILATION_MODE = wholemodule; 296 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 297 | VALIDATE_PRODUCT = YES; 298 | }; 299 | name = Release; 300 | }; 301 | CE36DA582731A51C00CD68D0 /* Debug */ = { 302 | isa = XCBuildConfiguration; 303 | buildSettings = { 304 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 305 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 306 | CODE_SIGN_STYLE = Automatic; 307 | CURRENT_PROJECT_VERSION = 1; 308 | DEVELOPMENT_TEAM = 92S6JX27W2; 309 | GENERATE_INFOPLIST_FILE = YES; 310 | INFOPLIST_FILE = VirtualMouse/Info.plist; 311 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 312 | INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; 313 | INFOPLIST_KEY_UIMainStoryboardFile = Main; 314 | INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; 315 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 316 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 317 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 318 | LD_RUNPATH_SEARCH_PATHS = ( 319 | "$(inherited)", 320 | "@executable_path/Frameworks", 321 | ); 322 | MARKETING_VERSION = 1.0; 323 | PRODUCT_BUNDLE_IDENTIFIER = ovh.exerhythm.VirtualMouse; 324 | PRODUCT_NAME = "$(TARGET_NAME)"; 325 | SWIFT_EMIT_LOC_STRINGS = YES; 326 | SWIFT_VERSION = 5.0; 327 | TARGETED_DEVICE_FAMILY = "1,2"; 328 | }; 329 | name = Debug; 330 | }; 331 | CE36DA592731A51C00CD68D0 /* Release */ = { 332 | isa = XCBuildConfiguration; 333 | buildSettings = { 334 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 335 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 336 | CODE_SIGN_STYLE = Automatic; 337 | CURRENT_PROJECT_VERSION = 1; 338 | DEVELOPMENT_TEAM = 92S6JX27W2; 339 | GENERATE_INFOPLIST_FILE = YES; 340 | INFOPLIST_FILE = VirtualMouse/Info.plist; 341 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 342 | INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; 343 | INFOPLIST_KEY_UIMainStoryboardFile = Main; 344 | INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; 345 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 346 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 347 | IPHONEOS_DEPLOYMENT_TARGET = 14.0; 348 | LD_RUNPATH_SEARCH_PATHS = ( 349 | "$(inherited)", 350 | "@executable_path/Frameworks", 351 | ); 352 | MARKETING_VERSION = 1.0; 353 | PRODUCT_BUNDLE_IDENTIFIER = ovh.exerhythm.VirtualMouse; 354 | PRODUCT_NAME = "$(TARGET_NAME)"; 355 | SWIFT_EMIT_LOC_STRINGS = YES; 356 | SWIFT_VERSION = 5.0; 357 | TARGETED_DEVICE_FAMILY = "1,2"; 358 | }; 359 | name = Release; 360 | }; 361 | /* End XCBuildConfiguration section */ 362 | 363 | /* Begin XCConfigurationList section */ 364 | CE36DA3E2731A51B00CD68D0 /* Build configuration list for PBXProject "VirtualMouse" */ = { 365 | isa = XCConfigurationList; 366 | buildConfigurations = ( 367 | CE36DA552731A51C00CD68D0 /* Debug */, 368 | CE36DA562731A51C00CD68D0 /* Release */, 369 | ); 370 | defaultConfigurationIsVisible = 0; 371 | defaultConfigurationName = Release; 372 | }; 373 | CE36DA572731A51C00CD68D0 /* Build configuration list for PBXNativeTarget "VirtualMouse" */ = { 374 | isa = XCConfigurationList; 375 | buildConfigurations = ( 376 | CE36DA582731A51C00CD68D0 /* Debug */, 377 | CE36DA592731A51C00CD68D0 /* Release */, 378 | ); 379 | defaultConfigurationIsVisible = 0; 380 | defaultConfigurationName = Release; 381 | }; 382 | /* End XCConfigurationList section */ 383 | 384 | /* Begin XCRemoteSwiftPackageReference section */ 385 | CE18BC112731B579001B20B7 /* XCRemoteSwiftPackageReference "peertalk-simple" */ = { 386 | isa = XCRemoteSwiftPackageReference; 387 | repositoryURL = "https://github.com/kokluch/peertalk-simple"; 388 | requirement = { 389 | kind = upToNextMajorVersion; 390 | minimumVersion = 0.2.0; 391 | }; 392 | }; 393 | /* End XCRemoteSwiftPackageReference section */ 394 | 395 | /* Begin XCSwiftPackageProductDependency section */ 396 | CE18BC122731B579001B20B7 /* PeertalkManager */ = { 397 | isa = XCSwiftPackageProductDependency; 398 | package = CE18BC112731B579001B20B7 /* XCRemoteSwiftPackageReference "peertalk-simple" */; 399 | productName = PeertalkManager; 400 | }; 401 | /* End XCSwiftPackageProductDependency section */ 402 | }; 403 | rootObject = CE36DA3B2731A51B00CD68D0 /* Project object */; 404 | } 405 | -------------------------------------------------------------------------------- /VirtualMouse.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /VirtualMouse.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /VirtualMouse.xcodeproj/xcuserdata/exerhythm.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | VirtualMouse.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /VirtualMouse/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // VirtualMouse 4 | // 5 | // Created by exerhythm on 11/2/21. 6 | // 7 | 8 | import UIKit 9 | 10 | @main 11 | class AppDelegate: UIResponder, UIApplicationDelegate { 12 | 13 | 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 16 | // Override point for customization after application launch. 17 | return true 18 | } 19 | 20 | // MARK: UISceneSession Lifecycle 21 | 22 | func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { 23 | // Called when a new scene session is being created. 24 | // Use this method to select a configuration to create the new scene with. 25 | return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) 26 | } 27 | 28 | func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { 29 | // Called when the user discards a scene session. 30 | // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. 31 | // Use this method to release any resources that were specific to the discarded scenes, as they will not return. 32 | } 33 | 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /VirtualMouse/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 | -------------------------------------------------------------------------------- /VirtualMouse/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /VirtualMouse/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /VirtualMouse/Base.lproj/LaunchScreen.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 | -------------------------------------------------------------------------------- /VirtualMouse/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 | 37 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 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 | -------------------------------------------------------------------------------- /VirtualMouse/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIApplicationSceneManifest 6 | 7 | UIApplicationSupportsMultipleScenes 8 | 9 | UISceneConfigurations 10 | 11 | UIWindowSceneSessionRoleApplication 12 | 13 | 14 | UISceneConfigurationName 15 | Default Configuration 16 | UISceneDelegateClassName 17 | $(PRODUCT_MODULE_NAME).SceneDelegate 18 | UISceneStoryboardFile 19 | Main 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /VirtualMouse/SceneDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SceneDelegate.swift 3 | // VirtualMouse 4 | // 5 | // Created by exerhythm on 11/2/21. 6 | // 7 | 8 | import UIKit 9 | 10 | class SceneDelegate: UIResponder, UIWindowSceneDelegate { 11 | 12 | var window: UIWindow? 13 | 14 | 15 | func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { 16 | // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. 17 | // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. 18 | // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). 19 | guard let _ = (scene as? UIWindowScene) else { return } 20 | } 21 | 22 | func sceneDidDisconnect(_ scene: UIScene) { 23 | // Called as the scene is being released by the system. 24 | // This occurs shortly after the scene enters the background, or when its session is discarded. 25 | // Release any resources associated with this scene that can be re-created the next time the scene connects. 26 | // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). 27 | } 28 | 29 | func sceneDidBecomeActive(_ scene: UIScene) { 30 | // Called when the scene has moved from an inactive state to an active state. 31 | // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. 32 | } 33 | 34 | func sceneWillResignActive(_ scene: UIScene) { 35 | // Called when the scene will move from an active state to an inactive state. 36 | // This may occur due to temporary interruptions (ex. an incoming phone call). 37 | } 38 | 39 | func sceneWillEnterForeground(_ scene: UIScene) { 40 | // Called as the scene transitions from the background to the foreground. 41 | // Use this method to undo the changes made on entering the background. 42 | } 43 | 44 | func sceneDidEnterBackground(_ scene: UIScene) { 45 | // Called as the scene transitions from the foreground to the background. 46 | // Use this method to save data, release shared resources, and store enough scene-specific state information 47 | // to restore the scene back to its current state. 48 | } 49 | 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /VirtualMouse/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // VirtualMouse 4 | // 5 | // Created by exerhythm on 11/2/21. 6 | // 7 | 8 | import UIKit 9 | import CoreMotion 10 | import Peertalk 11 | import PeertalkManager 12 | 13 | class ViewController: UIViewController, PTManagerDelegate { 14 | let motion = CMMotionManager() 15 | var timer: Timer? 16 | var mngr = PTManager() 17 | var sendData = false 18 | var calTime: Double = 5 19 | var antiCal: (Double, Double,Double) = (0,0,0) 20 | 21 | var offset: (Double, Double,Double) = (0,0,0) 22 | 23 | var sens: (Double,Double) = { 24 | return (UserDefaults.standard.double(forKey: "xsens") + 1, UserDefaults.standard.double(forKey: "ysens") + 1) 25 | }() 26 | 27 | @IBOutlet weak var label: UILabel! 28 | @IBOutlet weak var button: UIButton! 29 | @IBOutlet weak var gunModeSwitch: UISwitch! 30 | 31 | @IBOutlet weak var xsens: UISlider! 32 | @IBOutlet weak var ysens: UISlider! 33 | @IBAction func xsens(_ sender: UISlider) { 34 | sens.0 = Double(sender.value) 35 | UserDefaults.standard.set(sens.0 - 1, forKey: "xsens") 36 | } 37 | @IBAction func ysens(_ sender: UISlider) { 38 | sens.1 = Double(sender.value) 39 | UserDefaults.standard.set(sens.1 - 1, forKey: "ysens") 40 | } 41 | 42 | @IBAction func start(_ sender: UIButton) { 43 | if self.motion.isGyroAvailable && timer == nil { 44 | sender.setTitle("Calibrating...",for: []) 45 | startGyro() 46 | 47 | DispatchQueue.main.asyncAfter(deadline: .now() + (sendData ? 0.0 : calTime), execute: { 48 | self.antiCal = (self.offset.0 / 60 / self.calTime, self.offset.1 / 60 / self.calTime, self.offset.2 / 60 / self.calTime) 49 | print(self.offset) 50 | sender.setTitle("Stop VirtualMouse", for: []) 51 | self.sendData = true 52 | }) 53 | 54 | 55 | } else { 56 | sender.setTitle("Start VirtualMouse", for: []) 57 | timer?.invalidate() 58 | timer = nil 59 | } 60 | } 61 | 62 | override func viewDidLoad() { 63 | super.viewDidLoad() 64 | 65 | mngr.delegate = self 66 | mngr.connect(portNumber: 2345) 67 | 68 | xsens.value = Float(sens.0) 69 | ysens.value = Float(sens.1) 70 | view.isMultipleTouchEnabled = true 71 | } 72 | 73 | fileprivate func startGyro() { 74 | motion.gyroUpdateInterval = 1/60 75 | motion.startGyroUpdates() 76 | 77 | timer = Timer(fire: Date(), interval: (1/60), repeats: true, block: { (timer) in 78 | if let data = self.motion.gyroData { 79 | if self.sendData { 80 | self.gyroFire(data: data) 81 | } else { 82 | self.offset = (self.offset.0 + data.rotationRate.x, self.offset.1 + data.rotationRate.y, self.offset.2 + data.rotationRate.z) 83 | self.label.text = "calibration in progress" 84 | } 85 | } 86 | }) 87 | 88 | RunLoop.current.add(timer!, forMode: .default) 89 | } 90 | func gyroFire(data: CMGyroData) { 91 | let x = data.rotationRate.x - antiCal.0 92 | let y = data.rotationRate.y - antiCal.1 93 | let z = data.rotationRate.z - antiCal.2 94 | self.label.text = "X:\(x)\nY:\(y)\nZ:\(z)" 95 | print(x,y,z) 96 | 97 | if !gunModeSwitch.isOn { 98 | self.mngr.send(data: "\(x * sens.1);\(y * sens.0);\(z)".data(using: .utf8)!, type: 100) 99 | } else { 100 | self.mngr.send(data: "\(-z * sens.1);\(x * sens.0);\(y)".data(using: .utf8)!, type: 100) 101 | } 102 | } 103 | 104 | 105 | func peertalk(shouldAcceptDataOfType type: UInt32) -> Bool { 106 | return true 107 | } 108 | 109 | func peertalk(didReceiveData data: Data?, ofType type: UInt32) { 110 | print(data ?? "none") 111 | } 112 | 113 | func peertalk(didChangeConnection connected: Bool) { 114 | print(connected) 115 | } 116 | 117 | 118 | override func touchesBegan(_ touches: Set, with event: UIEvent?) { 119 | for touch in touches { 120 | let loc = touch.location(in: view) 121 | if loc.x < view.frame.width / 2 { 122 | self.mngr.send(data: "down".data(using: .utf8)!, type: 101) 123 | } else{ 124 | self.mngr.send(data: "down".data(using: .utf8)!, type: 102) 125 | } 126 | } 127 | } 128 | override func touchesEnded(_ touches: Set, with event: UIEvent?) { 129 | for touch in touches { 130 | let loc = touch.location(in: view) 131 | if loc.x < view.frame.width / 2 { 132 | self.mngr.send(data: "up".data(using: .utf8)!, type: 101) 133 | } else { 134 | self.mngr.send(data: "up".data(using: .utf8)!, type: 102) 135 | } 136 | } 137 | } 138 | } 139 | --------------------------------------------------------------------------------