forked from saagarjha/Ensemble
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
2,102 additions
and
2 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,18 @@ | ||
// | ||
// Debug.xcconfig | ||
// MacCast | ||
// | ||
// Created by Saagar Jha on 10/8/23. | ||
// | ||
|
||
#include "Shared.xcconfig" | ||
|
||
DEBUG_INFORMATION_FORMAT = dwarf | ||
ENABLE_TESTABILITY = YES | ||
GCC_OPTIMIZATION_LEVEL = 0 | ||
GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1 $(inherited) | ||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE | ||
ONLY_ACTIVE_ARCH = YES | ||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG $(inherited) | ||
SWIFT_OPTIMIZATION_LEVEL = -Onone | ||
|
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,13 @@ | ||
// | ||
// Deployment.xcconfig | ||
// MacCast | ||
// | ||
// Created by Saagar Jha on 10/8/23. | ||
// | ||
|
||
CODE_SIGN_IDENTITY = Apple Development | ||
CURRENT_PROJECT_VERSION = 1 | ||
DEVELOPMENT_TEAM = X4A9GH5NN2 | ||
MACOSX_DEPLOYMENT_TARGET = 14.0 | ||
MARKETING_VERSION = 1.0 | ||
XROS_DEPLOYMENT_TARGET = 1.0 |
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,14 @@ | ||
// | ||
// Release.xcconfig | ||
// MacCast | ||
// | ||
// Created by Saagar Jha on 10/8/23. | ||
// | ||
|
||
#include "Shared.xcconfig" | ||
|
||
DEBUG_INFORMATION_FORMAT = dwarf-with-dsym | ||
ENABLE_NS_ASSERTIONS = NO | ||
MTL_ENABLE_DEBUG_INFO = NO | ||
SWIFT_COMPILATION_MODE = wholemodule | ||
VALIDATE_PRODUCT = YES |
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,56 @@ | ||
// | ||
// Shared.xcconfig | ||
// MacCast | ||
// | ||
// Created by Saagar Jha on 10/8/23. | ||
// | ||
|
||
#include "Deployment.xcconfig" | ||
|
||
ALWAYS_SEARCH_USER_PATHS = NO | ||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES | ||
CLANG_ANALYZER_NONNULL = YES | ||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE | ||
CLANG_CXX_LANGUAGE_STANDARD = gnu++20 | ||
CLANG_ENABLE_MODULES = YES | ||
CLANG_ENABLE_OBJC_ARC = YES | ||
CLANG_ENABLE_OBJC_WEAK = YES | ||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES | ||
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES | ||
CLANG_WARN_BOOL_CONVERSION = YES | ||
CLANG_WARN_COMMA = YES | ||
CLANG_WARN_CONSTANT_CONVERSION = YES | ||
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES | ||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR | ||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES | ||
CLANG_WARN_EMPTY_BODY = YES | ||
CLANG_WARN_ENUM_CONVERSION = YES | ||
CLANG_WARN_INFINITE_RECURSION = YES | ||
CLANG_WARN_INT_CONVERSION = YES | ||
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES | ||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES | ||
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES | ||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR | ||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES | ||
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES | ||
CLANG_WARN_STRICT_PROTOTYPES = YES | ||
CLANG_WARN_SUSPICIOUS_MOVE = YES | ||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE | ||
CLANG_WARN_UNREACHABLE_CODE = YES | ||
COPY_PHASE_STRIP = NO | ||
ENABLE_PREVIEWS = YES | ||
ENABLE_STRICT_OBJC_MSGSEND = YES | ||
ENABLE_USER_SCRIPT_SANDBOXING = YES | ||
GCC_C_LANGUAGE_STANDARD = gnu17 | ||
GCC_NO_COMMON_BLOCKS = YES | ||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES | ||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR | ||
GCC_WARN_UNDECLARED_SELECTOR = YES | ||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE | ||
GCC_WARN_UNUSED_FUNCTION = YES | ||
GCC_WARN_UNUSED_VARIABLE = YES | ||
GENERATE_INFOPLIST_FILE = YES | ||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES | ||
MTL_FAST_MATH = YES | ||
SWIFT_EMIT_LOC_STRINGS = YES | ||
SWIFT_VERSION = 5.0 |
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,17 @@ | ||
// | ||
// macOS.xcconfig | ||
// MacCast | ||
// | ||
// Created by Saagar Jha on 10/8/23. | ||
// | ||
|
||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon | ||
CODE_SIGN_ENTITLEMENTS = macOS/MacCast.entitlements | ||
CODE_SIGN_STYLE = Automatic | ||
COMBINE_HIDPI_IMAGES = YES | ||
DEVELOPMENT_ASSET_PATHS = "macOS/Preview Content" | ||
ENABLE_HARDENED_RUNTIME = YES | ||
INFOPLIST_KEY_LSApplicationCategoryType = public.app-category.productivity | ||
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks | ||
PRODUCT_BUNDLE_IDENTIFIER = com.saagarjha.MacCast.macOS | ||
PRODUCT_NAME = MacCast |
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,16 @@ | ||
// | ||
// visionOS.xcconfig | ||
// MacCast | ||
// | ||
// Created by Saagar Jha on 10/8/23. | ||
// | ||
|
||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon | ||
DEVELOPMENT_ASSET_PATHS = "visionOS/Preview Content" | ||
INFOPLIST_FILE = $(TARGET_NAME)/Info.plist | ||
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/Frameworks | ||
PRODUCT_BUNDLE_IDENTIFIER = com.saagarjha.MacCast.visionOS | ||
PRODUCT_NAME = MacCast | ||
SDKROOT = xros | ||
SUPPORTED_PLATFORMS = xros xrsimulator | ||
TARGETED_DEVICE_FAMILY = 1,2,7 |
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
MacCast.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
MacCast.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
23 changes: 23 additions & 0 deletions
23
MacCast.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
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,23 @@ | ||
{ | ||
"pins" : [ | ||
{ | ||
"identity" : "appleconnect", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/saagarjha/AppleConnect.git", | ||
"state" : { | ||
"branch" : "main", | ||
"revision" : "fc826eca2b50cdec69781c82c4dd03a2d9e51981" | ||
} | ||
}, | ||
{ | ||
"identity" : "cod", | ||
"kind" : "remoteSourceControl", | ||
"location" : "https://github.com/saagarjha/Cod.git", | ||
"state" : { | ||
"branch" : "main", | ||
"revision" : "9ab61a00a5d9e4d21ed15af36734ea435cb4cf8c" | ||
} | ||
} | ||
], | ||
"version" : 2 | ||
} |
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 |
---|---|---|
@@ -1,2 +1,11 @@ | ||
# MacCast | ||
Cast Mac windows to visionOS | ||
<p align="center"> | ||
<img height="256" src="https://github.com/saagarjha/MacCast/raw/main/macOS/Assets.xcassets/AppIcon.appiconset/icon_512x512%402x.png" /> | ||
</p> | ||
|
||
<h1 align="center">MacCast</h1> | ||
|
||
MacCast bridges windows from your Mac directly into visionOS, letting you move, resize, and interact with them just like you would with any other native app. It's wireless, like Mac Virtual Display, but without the limitations of resolution or working in a flat plane. | ||
|
||
## Status | ||
|
||
MacCast is currently "pre-alpha": it's really more of a demo at this point. There's a lot of things I need to work on and until then it is unlikely I will be taking any code contributions. You are welcome to try it out (especially if you have a Vision Pro, as I do not) and file issues or suggestions but you should probably reach out if you are looking for anything beyond that. The code is definitely not designed for general-purpose use yet, so don't expect much of it :) |
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,28 @@ | ||
// | ||
// Messages.swift | ||
// MacCast | ||
// | ||
// Created by Saagar Jha on 10/9/23. | ||
// | ||
|
||
enum Messages: UInt8, CaseIterable { | ||
static let version = 1 | ||
case visionOSHandshake | ||
case macOSHandshake | ||
case windows | ||
case windowPreview | ||
case startCasting | ||
case windowFrame | ||
} | ||
|
||
protocol Message { | ||
static var id: Messages { get } | ||
associatedtype Request: Serializable | ||
associatedtype Reply: Serializable | ||
} | ||
|
||
extension Message { | ||
static func send(_ parameters: Request, through connection: Multiplexer) async throws -> Reply { | ||
try await .decode(connection.sendWithReply(message: Self.id, data: parameters.encode())) | ||
} | ||
} |
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,92 @@ | ||
// | ||
// Multiplexer.swift | ||
// MacCast | ||
// | ||
// Created by Saagar Jha on 10/9/23. | ||
// | ||
|
||
import AppleConnect | ||
import Foundation | ||
|
||
struct Multiplexer { | ||
let connection: Connection | ||
let localInterface: LocalInterface | ||
|
||
actor Replies { | ||
var token: Int = 1 | ||
var continuations = [Int: CheckedContinuation<Data, Error>]() | ||
|
||
func enqueue(_ continuation: CheckedContinuation<Data, Error>) -> Int { | ||
defer { | ||
token += 1 | ||
} | ||
continuations[token] = continuation | ||
return token | ||
} | ||
|
||
func failAll(with error: Error) { | ||
for continuation in continuations.values { | ||
continuation.resume(throwing: error) | ||
} | ||
continuations.removeAll() | ||
} | ||
|
||
func yield(_ data: Data, forToken token: Int) { | ||
let continuation = continuations.removeValue(forKey: token)! | ||
continuation.resume(returning: data) | ||
} | ||
} | ||
let replies = Replies() | ||
|
||
init(connection: Connection, localInterface: LocalInterface) { | ||
self.connection = connection | ||
self.localInterface = localInterface | ||
serviceReplies() | ||
} | ||
|
||
func serviceReplies() { | ||
Task { | ||
do { | ||
for try await data in connection.data { | ||
let message = Messages(rawValue: data.first!)! | ||
var data = data.dropFirst() | ||
let token = try Int(uleb128: &data) | ||
if let data = try await localInterface.handle(message: message, data: data) { | ||
try await send(message: message, data: data, token: token) | ||
} else { | ||
await replies.yield(data, forToken: token) | ||
} | ||
} | ||
} catch { | ||
await replies.failAll(with: error) | ||
} | ||
} | ||
} | ||
|
||
func send(message: Messages, data: Data) async throws { | ||
try await send(message: message, data: data, token: 0) | ||
} | ||
|
||
func sendWithReply(message: Messages, data: Data) async throws -> Data { | ||
try await withCheckedThrowingContinuation { continuation in | ||
Task { | ||
Task { | ||
let token = await replies.enqueue(continuation) | ||
do { | ||
try await send(message: message, data: data, token: token) | ||
} catch { | ||
continuation.resume(throwing: error) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func send(message: Messages, data: Data, token: Int) async throws { | ||
try! await connection.send(data: Data([message.rawValue]) + token.uleb128 + data) | ||
} | ||
} | ||
|
||
protocol LocalInterface { | ||
func handle(message: Messages, data: Data) async throws -> Data? | ||
} |
Oops, something went wrong.