是否可以使用 Xcode 让游戏控制器振动?

Is it possible to make a Game Controller vibrate using Xcode?

到目前为止,我一直在使用 Apple 的 GameController 框架,但无法使控制器振动。我正在寻找与 Unity 的 Handheld.Vibrate() 类似的东西,但最近几个小时的研究让我相信没有简单的 API.

是否可以使用 Xcode 使与 macOS/iOS 配对的游戏控制器振动? (也许通过直接向控制器发送信号)

根据 Apple 的 Game Controller Programming Guide,这不是与控制器交互的受支持方式。

Understanding the Controllers Supported by Apple

Apple has created specifications for distinct kinds of MFi game controllers.

Although specific controllers vary, many common characteristics must be implemented strictly according to the specification.

The extended control layout contains the following controls:

  • Four analog face buttons arranged in a diamond on the right side of the controller (labeled A, B, X, and Y)
  • An analog directional pad on the left side of the controller
  • Two analog thumbsticks on the left and right sides of the controller
  • Two analog shoulder buttons (labeled L1 and R1)
  • Two analog triggers (labeled L2 and R2)
  • A button to pause and resume gameplay

The Siri Remote has its own micro control layout.

  • An analog directional pad on the top of the remote
  • Two digital buttons (A,X)
  • One button to pause and resume gameplay

如果您通过蓝牙或类似方式直接与给定的控制器通信,您可以直接发出特定于控制器的命令(例如振动)。显然,这会复杂得多,因为您基本上必须自己重新实现 GameController 框架,在事件循环中侦听命令并在您的应用程序中响应这些命令。控制器的通信协议也可能因不同的品牌和型号而异,从而增加了开发的复杂性和成本。

最好的办法是通过 Feedback Assistant 直接向 Apple 提交功能请求。

Apple 通过反馈助理对我的功能请求的回复:

Thanks for your feedback! For now, this issue behaves as intended.

We love rumble in the Xbox Wireless Controller and Sony DualShock4 controllers, too - we think it would be great in games on iPhones, iPads, tvOS, and macOS, too.


看来这终于可以实现了!会有一个talk about this on Wednesday。我会尽快更新这个答案。

iOS14 将支持来自第三方控制器的触觉反馈。 https://developer.apple.com/videos/play/wwdc2020/10614/