macOS 10.15 Catalina 的安全系统偏好设置中的隐私功能 "Input Monitoring" 背后的哪个 API?

Which API is behind the privacy feature "Input Monitoring" in the Security system preferences of macOS 10.15 Catalina?

在 macOS 10.15 Catalina 中,安全系统首选项中有一个名为 输入监控 的新部分。

它说:

Allow the apps below to monitor input from your keyboard even while using other apps.

我想知道这背后是哪个 API 将应用程序添加到此部分。

我知道 AXIsProcessTrustedWithOptions(),它在 输入监控 上方的 辅助功能 部分添加了一个应用程序。然后我可以使用 NSEvent.addGlobalMonitorForEvents(matching: .keyDown, handler: self.keyDown(event:)) 来观察其他应用程序的按键操作。但是输入监控有什么用呢?

似乎手动将应用程序添加到 输入监控 不允许您使用 NSEvent.addGlobalMonitorForEvents(...).

像 Steam 这样的应用程序在更新到 Catalina 后已被放入该部分,因此必须有一些东西告诉系统将它们放在那里...

@Nick Moore 是对的。此 API 仅在 10.15 后可用。

IOHIDRequestAccess() 有两种类型的请求,几乎没有关于它的文档:-( https://developer.apple.com/documentation/iokit/3181574-iohidrequestaccess?language=objc

if #available(macOS 10.15, *) {
    // below requests "Input Monitoring"
    IOHIDRequestAccess(kIOHIDRequestTypeListenEvent)
    // below requests "Accessibility"
    IOHIDRequestAccess(kIOHIDRequestTypePostEvent)
}