Skip to content

Commit

Permalink
config(apple): switch to trackpad when macOS guest is used on macOS 1…
Browse files Browse the repository at this point in the history
…3+ host

This is the second attempt to fix #4636 and #4645
  • Loading branch information
osy committed Mar 11, 2023
1 parent a358d5c commit ae8cce8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 1 addition & 8 deletions Configuration/UTMAppleConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,8 @@ extension UTMAppleConfiguration {
vzconfig.networkDevices.append(contentsOf: networks.compactMap({ $0.vzNetworking() }))
vzconfig.serialPorts.append(contentsOf: serials.compactMap({ $0.vzSerial() }))
// add remaining devices
try virtualization.fillVZConfiguration(vzconfig)
try virtualization.fillVZConfiguration(vzconfig, isMacOSGuest: system.boot.operatingSystem == .macOS)
#if arch(arm64)
/*
// Disable trackpad due to reported issues (#4636, #4645)
if #available(macOS 13, *), virtualization.hasPointer && system.boot.operatingSystem == .macOS {
// add a trackpad device
vzconfig.pointingDevices.insert(VZMacTrackpadConfiguration(), at: 0)
}
*/
if #available(macOS 12, *), system.boot.operatingSystem == .macOS {
let graphics = VZMacGraphicsDeviceConfiguration()
graphics.displays = displays.map({ display in
Expand Down
8 changes: 7 additions & 1 deletion Configuration/UTMAppleConfigurationVirtualization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ extension UTMAppleConfigurationVirtualization {
@available(iOS, unavailable, message: "Apple Virtualization not available on iOS")
@available(macOS 11, *)
extension UTMAppleConfigurationVirtualization {
func fillVZConfiguration(_ vzconfig: VZVirtualMachineConfiguration) throws {
func fillVZConfiguration(_ vzconfig: VZVirtualMachineConfiguration, isMacOSGuest: Bool = false) throws {
if hasBalloon {
vzconfig.memoryBalloonDevices = [VZVirtioTraditionalMemoryBalloonDeviceConfiguration()]
}
Expand All @@ -137,6 +137,12 @@ extension UTMAppleConfigurationVirtualization {
}
if hasPointer {
vzconfig.pointingDevices = [VZUSBScreenCoordinatePointingDeviceConfiguration()]
#if arch(arm64)
if #available(macOS 13, *), isMacOSGuest {
// replace with trackpad device
vzconfig.pointingDevices = [VZMacTrackpadConfiguration()]
}
#endif
}
} else {
if hasAudio || hasKeyboard || hasPointer {
Expand Down

0 comments on commit ae8cce8

Please sign in to comment.