public void OnPairDevice() { var devices = BhapticsAndroidManager.GetDevices(); int rssi = -9999; int index = -1; for (int i = 0; i < devices.Count; i++) { if (AndroidUtils.CanPair(devices[i], DeviceType)) { if (rssi < devices[i].Rssi) { rssi = devices[i].Rssi; index = i; } } } if (index != -1) { if (DeviceType == PositionType.Vest) { BhapticsAndroidManager.Pair(devices[index].Address); } else { BhapticsAndroidManager.Pair(devices[index].Address, DeviceType.ToString()); } } }
private void OnUnpair() { if (device.IsPaired) { BhapticsAndroidManager.Unpair(device.Address); } }
private void OnPairSelected() { if (AndroidUtils.ConvertConnectionStatus(device.ConnectionStatus) == 2) { BhapticsAndroidManager.Pair(device.Address); } }
private void OnPing() { if (device.IsConnected) { BhapticsAndroidManager.Ping(device); } }
private void OnPairSelected() { if (!(device.IsPaired)) { BhapticsAndroidManager.Pair(device.Address); } }
// calling from the UI Button public void ToggleWidgetButton() { if (!AndroidPermissionsManager.CheckBluetoothPermissions()) { AndroidPermissionsManager.RequestPermission(); return; } if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Idle") || alwaysActive) { return; } widgetActive = !widgetActive; if (widgetActive) { BhapticsAndroidManager.ForceUpdateDeviceList(); foreach (var controlButton in controllButtons) { controlButton.Refresh(); } animator.Play("ShowWidget"); ShowWidget(); } else { animator.Play("HideWidget"); HideWidget(); } }
public void ShowWidget() { uiContainer.SetActive(true); hideTimer = autoHideTime; BhapticsAndroidManager.Scan(); scanCoroutine = StartCoroutine(LoopScan()); }
public void Refresh() { var devices = BhapticsAndroidManager.GetDevices(); settingObjectPool.DisableAll(); RefreshPairedDevices(devices); RefreshScannedDevices(devices); }
private void OnUnpair() { if (device.IsConnected || (AndroidUtils.ConvertConnectionStatus(device.ConnectionStatus) == 2 && device.IsPaired)) { BhapticsAndroidManager.Unpair(device.Address); } }
void Awake() { button = GetComponent <Button>(); unPairButton.GetComponent <Button>().onClick.AddListener(OnUnpairDevice); button.onClick.AddListener(OnClickDevice); BhapticsAndroidManager.AddRefresh(Refresh); BhapticsLogger.LogDebug("start"); }
private void Ping() { if (device == null) { return; } BhapticsAndroidManager.Ping(device); }
public void Refresh() { button = GetComponent <Button>(); BhapticsLogger.LogDebug("Refresh()"); var connectedDevices = BhapticsAndroidManager.GetConnectedDevices(DeviceType); if (connectedDevices.Count > 0) { button.image.sprite = pairImage; unPairButton.SetActive(true); var spriteState = button.spriteState; spriteState.highlightedSprite = pairHoverImage; button.spriteState = spriteState; canPairImage.gameObject.SetActive(false); for (int i = 0; i < pairDeviceCount.childCount; i++) { if (!pairDeviceCount.GetChild(i).gameObject.activeSelf) { break; } pairDeviceCount.GetChild(i).gameObject.SetActive(false); } for (int i = 0; i < connectedDevices.Count; i++) { if (pairDeviceCount.GetChild(i) != null) { pairDeviceCount.GetChild(i).gameObject.SetActive(true); } else { break; } } } else { BhapticsLogger.LogDebug("button + ", " + defaultImage"); button.image.sprite = defaultImage; unPairButton.SetActive(false); var spriteState = button.spriteState; spriteState.highlightedSprite = defaultHoverImage; button.spriteState = spriteState; canPairImage.gameObject.SetActive(BhapticsAndroidManager.CanPairDevice(DeviceType)); for (int i = 0; i < pairDeviceCount.childCount; i++) { pairDeviceCount.GetChild(i).gameObject.SetActive(false); } } }
private void OnDisable() { if (scanCoroutine != null) { StopCoroutine(scanCoroutine); scanCoroutine = null; } BhapticsAndroidManager.RemoveRefresh(Refresh); }
public void HideWidget() { uiContainer.SetActive(false); if (scanCoroutine != null) { BhapticsAndroidManager.ScanStop(); StopCoroutine(scanCoroutine); scanCoroutine = null; } }
private void Awake() { #if !UNITY_ANDROID return; #endif if (Instance == null) { Instance = this; } }
void Awake() { if (Instance != null) { DestroyImmediate(this); return; } Instance = this; name = "[bHapticsAndroidManager]"; }
private void OnUnpairDevice() { var pairedDevices = BhapticsAndroidManager.GetPairedDevices(DeviceType); foreach (var pairedDevice in pairedDevices) { if (pairedDevice.IsConnected) { BhapticsAndroidManager.Unpair(pairedDevice.Address); } } }
public void OnClickDevice() { var connectedDevices = BhapticsAndroidManager.GetConnectedDevices(DeviceType); if (connectedDevices.Count > 0) { OnPingDevice(); } else { OnPairDevice(); } }
private void OnSwap() { if (device.IsConnected) { BhapticsAndroidManager.TogglePosition(device.Address); if (AndroidUtils.IsLeft(device.Position)) { toggleButton.image.sprite = leftSide; } else { toggleButton.image.sprite = rightSide; } } }
private void OnEnable() { if (alwaysActive) { scanCoroutine = StartCoroutine(LoopScan()); } else { if (animator != null) { animator.Play("HideWidget", -1, 1); } } BhapticsAndroidManager.AddRefresh(Refresh); }
private void ToRight() { if (device == null) { return; } if (IsLeft(device.Position)) { BhapticsAndroidManager.TogglePosition(device.Address); } else { Ping(); } }
void Awake() { for (int i = 0; i < deviceListSize; i++) { var go = Instantiate(devicePrefab, devicesContainer.transform); go.gameObject.SetActive(false); controllers.Add(go); } BhapticsAndroidManager.AddRefreshAction(Refresh); if (helpButton != null) { helpButton.onClick.AddListener(OnHelp); } if (helpCloseButton != null) { helpCloseButton.onClick.AddListener(CloseHelpNotification); } if (bHpaticsLinkButton != null) { bHpaticsLinkButton.onClick.AddListener(OpenLink); } if (deviceListNextPageButton != null) { deviceListNextPageButton.onClick.AddListener(NextPage); } if (deviceListBackPageButton != null) { deviceListBackPageButton.onClick.AddListener(BackPage); } if (mainPanel != null) { defaultMainPanelSize = mainPanel.sizeDelta; mainPanelCollider = mainPanel.GetComponent <BoxCollider>(); } if (devicesContainer != null) { defaultDeviceContainerSize = defaultMainPanelSize; } }
public void Refresh() { var devices = BhapticsAndroidManager.GetDevices(); if (settingObjectPool != null) { settingObjectPool.DisableAll(); } RefreshPairedDevices(devices); RefreshScannedDevices(devices); foreach (var controlButton in controllButtons) { controlButton.Refresh(); } }
void Start() { if (WidgetSetting == null) { BhapticsLogger.LogError("[bhaptics] WidgetSetting is null"); } if (!alwaysActive) { animator.Play("HideWidget", -1, 1); } else { BhapticsAndroidManager.AddRefreshAction(Refresh); } Refresh(); }
// calling from the UI Button public void ToggleWidgetButton() { if (!BhapticsAndroidManager.CheckPermission()) { if (Bhaptics_Setup.instance != null && Bhaptics_Setup.instance.Config.UseOnlyBackgroundMode) { if (BhapticsAlertManager.Instance != null) { BhapticsAlertManager.Instance.ShowAlert(); } return; } BhapticsAndroidManager.RequestPermission(); return; } if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Idle") || alwaysActive) { return; } widgetActive = !widgetActive; if (widgetActive) { animator.Play("ShowWidget"); ShowWidget(); BhapticsAndroidManager.AddRefreshAction(Refresh); } else { animator.Play("HideWidget"); HideWidget(); BhapticsAndroidManager.RemoveRefreshAction(); } }
void Start() { if (!AndroidPermissionsManager.CheckBluetoothPermissions()) { BhapticsLogger.LogError("bhaptics requires bluetooth permission."); } if (WidgetSetting == null) { BhapticsLogger.LogError("[bhaptics] WidgetSetting is null"); } if (!alwaysActive) { animator.Play("HideWidget", -1, 1); } BhapticsAndroidManager.AddRefresh(Refresh); }
private IEnumerator LoopScan() { while (true) { BhapticsAndroidManager.Scan(); if (!alwaysActive) { if (hideTimer < 0f) { scanCoroutine = null; animator.Play("HideWidget"); HideWidget(); widgetActive = !widgetActive; break; } else { hideTimer -= 0.5f; } } yield return(new WaitForSeconds(0.5f)); } }
private void OnDisable() { CancelInvoke(); BhapticsAndroidManager.RemoveRefresh(Refresh); }
private void OnEnable() { InvokeRepeating("BlinkCanPair", 0f, 0.1f); BhapticsAndroidManager.AddRefresh(Refresh); }
public void OnPingDevice() { BhapticsAndroidManager.Ping(DeviceType); }