Skip to content

Commit

Permalink
Support trackpad on macOS and clipboard sharing on Linux (#202)
Browse files Browse the repository at this point in the history
Fixes #66
Relates to #14 since fixes on Linux
  • Loading branch information
fkorotkov authored Aug 27, 2022
1 parent 553b363 commit 048a550
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Sources/tart/Platform/Darwin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,14 @@ struct Darwin: Platform {

return result
}

func pointingDevices() -> [VZPointingDeviceConfiguration] {
if #available(macOS 13, *) {
// Trackpad is only supported starting with macOS Ventura
// macOS Monterey will continue using a USB device == .darwin
return [VZMacTrackpadConfiguration(), VZUSBScreenCoordinatePointingDeviceConfiguration()]
} else {
return [VZUSBScreenCoordinatePointingDeviceConfiguration()]
}
}
}
4 changes: 4 additions & 0 deletions Sources/tart/Platform/Linux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ struct Linux: Platform {

return result
}

func pointingDevices() -> [VZPointingDeviceConfiguration] {
[VZUSBScreenCoordinatePointingDeviceConfiguration()]
}
}
1 change: 1 addition & 0 deletions Sources/tart/Platform/Platform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ protocol Platform: Codable {
func bootLoader(nvramURL: URL) throws -> VZBootLoader
func platform(nvramURL: URL) -> VZPlatformConfiguration
func graphicsDevice(vmConfig: VMConfig) -> VZGraphicsDeviceConfiguration
func pointingDevices() -> [VZPointingDeviceConfiguration]
}
2 changes: 1 addition & 1 deletion Sources/tart/VM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {

// Keyboard and mouse
configuration.keyboards = [VZUSBKeyboardConfiguration()]
configuration.pointingDevices = [VZUSBScreenCoordinatePointingDeviceConfiguration()]
configuration.pointingDevices = vmConfig.platform.pointingDevices()

// Networking
let vio = VZVirtioNetworkDeviceConfiguration()
Expand Down

0 comments on commit 048a550

Please sign in to comment.