我正在尝试使用以下代码获得 MacBook Pro 触控板压力:
CGEventRef eventTapCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef eventRef, void *refcon) {
NSEvent *event = [NSEvent eventWithCGEvent:eventRef];
NSLog(@"%lld", (int64_t)CGEventGetIntegerValueField(eventRef, kCGMouseEventPressure)); // returns 0
NSLog(@"%lld", (int64_t)CGEventGetIntegerValueField(eventRef, kCGTabletEventPointPressure)); // returns 0
NSLog(@"%lld", (int64_t)CGEventGetIntegerValueField(eventRef, kCGTabletEventTangentialPressure)); // returns 0
NSLog(@"%f", [event pressure]); // Assertion failure
return eventRef;
}
你知道怎么做吗?