Skip to content

People have dreamed of running macOS on iPad for more than a decade. Today, that dream comes true. With Virtual Mac, iPad finally breaks free from iPadOS, enabling pro apps like Xcode, Terminal, Final Cut Pro, Logic Pro, and Pixelmator Pro to run directly on device. Requires iPad Pro (M1, M2) or iPad Air (M1) running iPadOS 14 up to 16.3.1.

Shell

Send coalesced touches for full 240Hz Pencil resolution

ma-syuf89d915e4cb1
diff --git a/VirtualMac/vz/host/VirtualMacApp.m b/VirtualMac/vz/host/VirtualMacApp.m
index 5941cd8..4348ab1 100644
--- a/VirtualMac/vz/host/VirtualMacApp.m
+++ b/VirtualMac/vz/host/VirtualMacApp.m
@@ -2450,18 +2450,26 @@ static bool pencilVsockSend(uint8_t type, float pressure,
// type=0 (point) for continuous drag events.
if (_vzPencilRelayStrokeClaimed) for (UITouch *t in touches) {
if (t.type == UITouchTypeStylus) {
- CGPoint p = [t locationInView:self];
CGRect b = self.bounds;
- float pressure = (t.maximumPossibleForce > 0)
- ? (float)(t.force / t.maximumPossibleForce) : 0;
- float nx = (b.size.width > 0) ? (float)(p.x / b.size.width) : 0;
- float ny = (b.size.height > 0) ? (float)(p.y / b.size.height) : 0;
- float altitude = (float)t.altitudeAngle;
- float azimuth = (float)[t azimuthAngleInView:self];
- if (_vzPencilRelayStrokeConnected)
- _vzPencilRelayStrokeConnected = pencilVsockSend(
- kPencilEventPoint, pressure, nx, ny,
- altitude, azimuth);
+ // coalescedTouchesForTouch: が返す中間タッチをすべて送信し、
+ // iPad の 240Hz サンプリングに近い描画解像度を得る。
+ // nil の場合は現タッチ 1 つだけ送信(フォールバック)。
+ NSArray<UITouch *> *coalesced = [event coalescedTouchesForTouch:t];
+ if (!coalesced) coalesced = @[t];
+ for (UITouch *ct in coalesced) {
+ CGPoint p = [ct locationInView:self];
+ float pressure = (ct.maximumPossibleForce > 0)
+ ? (float)(ct.force / ct.maximumPossibleForce) : 0;
+ float nx = (b.size.width > 0) ? (float)(p.x / b.size.width) : 0;
+ float ny = (b.size.height > 0) ? (float)(p.y / b.size.height) : 0;
+ float altitude = (float)ct.altitudeAngle;
+ float azimuth = (float)[ct azimuthAngleInView:self];
+ if (_vzPencilRelayStrokeConnected)
+ _vzPencilRelayStrokeConnected = pencilVsockSend(
+ kPencilEventPoint, pressure, nx, ny,
+ altitude, azimuth);
+ if (!_vzPencilRelayStrokeConnected) break;
+ }
return;
}
}