跳到主要内容
本页面由机器自动翻译,可能包含错误。 查看英文原文

Class BhapticsAppleDevices

BhapticsAppleDevices 提供在 iOS 和 visionOS 上通过 CoreBluetooth 直接扫描并连接 bHaptics 设备的 API。整体设置和示例 UI 请参阅 iOS/visionOS 连接指南

备注

仅在 iOS/visionOS 真机上使用这些 API。

API行为
BhapticsAppleDevices.Scan()开始 BLE 扫描附近的 bHaptics 设备
BhapticsAppleDevices.StopScan()停止扫描
BhapticsAppleDevices.IsScanning()扫描是否正在进行中
BhapticsAppleDevices.GetDevices()设备列表 —— HapticDevice (name, Position, IsConnected, IsPaired)
BhapticsAppleDevices.Pair(id)配对(记住)+ 连接
BhapticsAppleDevices.Unpair(id)取消配对 + 断开连接
BhapticsAppleDevices.IsSupported是否为 iOS/visionOS 真机(在编辑器或其他平台上为 false
// Minimal example: start scanning → poll the list → connect to the first device
BhapticsAppleDevices.Scan();

var devices = BhapticsAppleDevices.GetDevices(); // Call periodically to refresh
if (devices.Count > 0 && !devices[0].IsPaired)
{
BhapticsAppleDevices.Pair(devices[0].Address);
}