public void OnPairDevice() { var devices = DeviceManager.Instance.GetDeviceList(); int rssi = -9999; int index = -1; for (int i = 0; i < devices.Count; i++) { string pairDevice = CompareDeviceString.GetDeviceNameString(DeviceType); if (devices[i].DeviceName.StartsWith(pairDevice) && CompareDeviceString.convertConnectionStatus(devices[i].ConnectionStatus) == 2) { if (rssi < int.Parse(devices[i].Rssi)) { rssi = int.Parse(devices[i].Rssi); index = i; } else { continue; } } } if (index != -1) { DeviceManager.Instance.Pair(devices[index].Address); StartCoroutine(CheckPosition(devices[index], isLeft)); } }
private void OnPair() { if (CompareDeviceString.convertConnectionStatus(device.ConnectionStatus) == 2) { DeviceManager.Instance.Pair(device.Address); } }
private void OnUnpair() { if (CompareDeviceString.convertConnectionStatus(device.ConnectionStatus) == 0 || (CompareDeviceString.convertConnectionStatus(device.ConnectionStatus) == 2 && device.IsPaired)) { DeviceManager.Instance.Unpair(device.Address); } }
private bool CanPairedDevice() { var deviceList = DeviceManager.Instance.GetDeviceList(); string position = CompareDeviceString.GetDeviceNameString(DeviceType); foreach (var device in deviceList) { if (!device.IsPaired && device.DeviceName.StartsWith(position)) { return(true); } } return(false); }
private void OnUnpairDevice() { var pairedDevices = GetPariedDevice(); foreach (var pairedDevice in pairedDevices) { if (CompareDeviceString.convertConnectionStatus(pairedDevice.ConnectionStatus) == 0 || (CompareDeviceString.convertConnectionStatus(pairedDevice.ConnectionStatus) == 2 && pairedDevice.IsPaired)) { DeviceManager.Instance.Unpair(pairedDevice.Address); } } }
private void OnSwap() { if (CompareDeviceString.convertConnectionStatus(device.ConnectionStatus) == 0) { DeviceManager.Instance.TogglePosition(device.Address); if (device.IsLeft()) { toggleButton.image.sprite = leftSide; } else { toggleButton.image.sprite = rightSide; } } }
private List <BhapticsDevice> GetPariedDevice() { List <BhapticsDevice> pairedDeviceList = new List <BhapticsDevice>(); var deviceList = DeviceManager.Instance.GetDeviceList(); string position = CompareDeviceString.GetPositionString(DeviceType); foreach (var device in deviceList) { if (device.IsPaired && device.Position.StartsWith(position) && CompareDeviceString.convertConnectionStatus(device.ConnectionStatus) == 0) { pairedDeviceList.Add(device); } } return(pairedDeviceList); }
private void PairedUiRefresh(List <BhapticsDevice> devices) { if (!IsActivateWidget) { return; } foreach (var device in devices) { if (device.IsPaired) { bool isConnect = (CompareDeviceString.convertConnectionStatus(device.ConnectionStatus) == 0); PairedDeviceUI deviceUI = settingObjectPool.GetPairedDeviceUI(); if (deviceUI != null) { deviceUI.Setup(device, isConnect, GetPairedDeviceSprite(device.DeviceName, isConnect)); deviceUI.gameObject.SetActive(true); } } } }