Skip to content

Commit

Permalink
Open source
Browse files Browse the repository at this point in the history
  • Loading branch information
tattn committed Oct 11, 2023
1 parent 34a498c commit 4c20c81
Show file tree
Hide file tree
Showing 10 changed files with 541 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/xcode/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ let package = Package(
targets: [
.target(name: "VCamUI", dependencies: [
"VCamUIFoundation", "VCamTracking", "VCamCamera", "VCamData", "VCamLocalization", "VCamBridge",
], resources: [
.process("Resources"),
]),
.target(name: "VCamUIFoundation"),
.target(name: "VCamData", dependencies: ["VCamBridge", "VCamEntity"]),
Expand Down
1 change: 1 addition & 0 deletions app/xcode/Sources/VCamData/UserDefaultsKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public extension UserDefaults.Key {
static var eyeTrackingOffsetY: Key<Double> { .init("vc_eye_tracking_offset_y", default: -0.2) }
static var fingerTrackingOpenIntensity: Key<Double> { .init("vc_ftracking_open_intensity", default: 1) }
static var fingerTrackingCloseIntensity: Key<Double> { .init("vc_ftracking_close_intensity", default: 1) }
static var recordMicSyncOffset: Key<Int> { .init("vc_rec_mic_sync_offset", default: -160) }
static var integrationVCamMocap: Key<Bool> { .init("vc_intg_vcammocap", default: false) }
static var macOSMicModeEnabled: Key<Bool> { .init("vc_macos_micmode_enabled", default: false) }
}
1 change: 1 addition & 0 deletions app/xcode/Sources/VCamUI/Extensions/NSApp+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import AppKit

public extension NSApplication {
var mainOrFirstWindow: NSWindow? {
// If the app is in the background during launch, mainWindow becomes nil
mainWindow ?? windows.first
}

Expand Down
2 changes: 2 additions & 0 deletions app/xcode/Sources/VCamUI/MacWindowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public final class MacWindowManager {

private var openWindows: [String: NSWindow] = [:]

public var openSettings = {}

public func open<T: MacWindow>(_ windowView: T) {
let id = self.id(T.self)
if let window = openWindows[id] {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"images" : [
{
"filename" : "StatusItemIcon.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true,
"template-rendering-intent" : "template"
}
}
Binary file not shown.
74 changes: 74 additions & 0 deletions app/xcode/Sources/VCamUI/VCamSystem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// VCamSystem.swift
//
//
// Created by Tatsuya Tanaka on 2023/02/25.
//

import Foundation
import VCamAppExtension
import VCamBridge
import VCamTracking
import VCamLogger

public final class VCamSystem {
public let pasteboardObserver = PasteboardObserver()

public private(set) var isStarted = false
public var isUniVCamSystemEnabled = false

init() {
ExtensionNotificationCenter.default.setObserver(for: .startCameraExtensionStream) { [weak self] in
self?.startSystem()
}

ExtensionNotificationCenter.default.setObserver(for: .stopAllCameraExtensionStreams) { [weak self] in
self?.stopSystem()
}
}

public func startSystem() {
Logger.log("\(isStarted)")
guard !isStarted else { return }
isStarted = true
Tracking.shared.configure()
AvatarAudioManager.shared.startIfNeeded()
RenderTextureManager.shared.resume()
pasteboardObserver.observe()
UniBridge.shared.resumeApp()
}

public func stopSystem() {
Logger.log("\(isStarted), \(WindowManager.shared.isWindowClosed)")
guard isStarted, WindowManager.shared.isWindowClosed else { return }
isStarted = false
Tracking.shared.stop()
AvatarAudioManager.shared.stop(usage: .all)
VideoRecorder.shared.stop()
RenderTextureManager.shared.pause()
pasteboardObserver.dispose()
UniBridge.shared.pauseApp()
}

public func dispose() {
isStarted = false
Tracking.shared.stop()
AvatarAudioManager.shared.stop(usage: .all)
VideoRecorder.shared.stop()
RenderTextureManager.shared.pause()
pasteboardObserver.dispose()
UniBridge.shared.reset()
}
}

private extension UniBridge {
func reset() {
intMapper.reset()
boolMapper.reset()
arrayMapper.reset()
floatMapper.reset()
stringMapper.reset()
structMapper.reset()
triggerMapper.reset()
}
}
Loading

0 comments on commit 4c20c81

Please sign in to comment.