Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions engine/Sources/ODHubViewerApp/ViewerMain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,36 @@ struct ODHubViewer: ParsableCommand {
}
}
},
setOrientation: { orientation in
for udid in manager.openUDIDs {
guard let controller = manager.controller(for: udid) else { continue }
do {
try adapter.setOrientation(orientation, udid: udid)
controller.setOrientation(orientation)
} catch {
print("rotate failed: \(error.localizedDescription)")
}
}
},
appSwitcher: {
for udid in manager.openUDIDs {
Task {
do {
let session = try adapter.openInput(udid)
defer { session.close() }
try await openAppSwitcher(session)
} catch {
print("app switcher failed: \(error.localizedDescription)")
}
}
}
},
stopRecording: {
for url in manager.toggleRecording(into: recordingDirectory()) {
print("recorded \(url.path(percentEncoded: false))")
}
},
isRecording: { manager.isRecording },
checkForUpdates: updates.map { updater in { updater.checkForUpdates() } }
), capabilities: adapter.capabilities, openSimulatorMenu: chooser.menu,
commandLineTool: CommandLineToolInstaller.bundledTool == nil ? nil : CommandLineToolMenu(
Expand Down Expand Up @@ -469,6 +499,23 @@ private func installToolbar(
))
}

private func openAppSwitcher(_ session: any InputSession) async throws {
let path = HomeGesture.appSwitcherPath()
try await session.touch(TouchEvent(phase: .began, points: [path[0]], edge: .bottom))
for point in path.dropFirst() {
try await Task.sleep(for: .milliseconds(10))
try await session.touch(TouchEvent(phase: .moved, points: [point], edge: .bottom))
}
let settle = HomeGesture.settlePath(around: path[path.count - 1])
for point in settle {
try await Task.sleep(for: .milliseconds(40))
try await session.touch(TouchEvent(phase: .moved, points: [point], edge: .bottom))
}
try await session.touch(
TouchEvent(phase: .ended, points: [settle[settle.count - 1]], edge: .bottom)
)
}

private func swipeHome(_ session: any InputSession) async throws {
let path = HomeGesture.swipePath()
try await session.touch(TouchEvent(phase: .began, points: [path[0]], edge: .bottom))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ public enum DeviceOrientation: String, Sendable, Hashable, CaseIterable, Codable
self == .landscapeLeft || self == .landscapeRight
}

public var displayName: String {
switch self {
case .portrait: "Portrait"
case .landscapeRight: "Landscape Right"
case .portraitUpsideDown: "Portrait Upside Down"
case .landscapeLeft: "Landscape Left"
}
}

/// The size the viewer draws, which swaps the axes in landscape.
public func displayedSize(portraitNative: CGSize) -> CGSize {
isLandscape
Expand Down
3 changes: 3 additions & 0 deletions engine/Sources/OpenDeviceHubViewer/DeviceToolbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ final class DeviceToolbar: NSObject, NSToolbarDelegate, NSToolbarItemValidation
private func describeCapture(_ item: NSToolbarItem) {
if isRecording {
describe(item, symbol: "stop.circle", title: "Stop Recording", tip: "Stop Recording (\u{2318}R)")
item.image = item.image?.withSymbolConfiguration(
NSImage.SymbolConfiguration(paletteColors: [.systemRed])
)
} else {
describe(
item,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public final class DeviceWindowController: NSWindowController, NSWindowDelegate
private let presentationView: DevicePresentationView
private var chrome: DeviceChrome?
private var toolbar: DeviceToolbar?
private let recordingIndicator = RecordingIndicator()
private var frameTask: Task<Void, Never>?
private var overlay: ShutdownOverlayView?
/// Called when the window's Reboot button is pressed. The owner boots the device; the window
Expand Down Expand Up @@ -143,7 +142,6 @@ public final class DeviceWindowController: NSWindowController, NSWindowDelegate
public func stop() {
guard !isStopped else { return }
isStopped = true
recordingIndicator.detach()
closeSessions()
}

Expand Down Expand Up @@ -381,7 +379,6 @@ public final class DeviceWindowController: NSWindowController, NSWindowDelegate
}

public func setRecordingIndicatorVisible(_ visible: Bool) {
recordingIndicator.setVisible(visible, on: window)
updateTitle()
toolbar?.setRecording(visible)
}
Expand Down
75 changes: 0 additions & 75 deletions engine/Sources/OpenDeviceHubViewer/RecordingIndicator.swift

This file was deleted.

Loading
Loading