public override void Play(float intensity, float duration, float vestRotationAngleX, float vestRotationOffsetY, string identifier = "")
        {
            if (!BhapticsManager.Init)
            {
                BhapticsManager.Initialize();
            }

            var haptic = BhapticsManager.GetHaptic();

            if (haptic == null)
            {
                return;
            }

            if (!haptic.IsFeedbackRegistered(assetId))
            {
                haptic.RegisterTactFileStr(assetId, JsonValue);
            }

            _rotationOption.OffsetAngleX = vestRotationAngleX + this.TactFileAngleX;
            _rotationOption.OffsetY      = vestRotationOffsetY + this.TactFileOffsetY;

            _scaleOption.Intensity = intensity;
            _scaleOption.Duration  = duration;

            haptic.SubmitRegistered(assetId, keyId + identifier,
                                    _rotationOption, _scaleOption);
        }
Exemple #2
0
        void Awake()
        {
            BhapticsManager.GetHaptic();

            if (Bhaptics_Setup.instance == null)
            {
                var findObjectOfType = FindObjectOfType <Bhaptics_Setup>();
                if (findObjectOfType == null)
                {
                    var go = new GameObject("[bhaptics]");
                    go.SetActive(false);
                    var setup  = go.AddComponent <Bhaptics_Setup>();
                    var config = Resources.Load <BhapticsConfig>("BhapticsConfig");
                    if (config == null)
                    {
                        BhapticsLogger.LogError("Cannot find 'BhapticsConfig' in the Resources folder.");
                    }
                    setup.Config = config;
                    go.SetActive(true);
                }
            }


            if (playOnAwake)
            {
                if (loop)
                {
                    PlayLoop();
                }
                else
                {
                    PlayHapticClip();
                }
            }
        }
Exemple #3
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0))
     {
         BhapticsManager.HapticPlayer.SubmitRegistered(BhapticsManager.GetFeedbackId("BowShoot"));
     }
 }
        void Awake()
        {
            if (dontDestroyOnLoad)
            {
                if (_manager == null)
                {
                    DontDestroyOnLoad(gameObject);
                }
                else
                {
                    Destroy(gameObject);
                    return;
                }
            }

            var uninstalledMessage = "bHaptics Player is not installed. Plugin is now disabled. Please download here." +
                                     "\nhttp://bhaptics.com/app.html#download";

            _manager = this;
            if (!BhapticsUtils.IsPlayerInstalled())
            {
                Debug.LogError(uninstalledMessage);
                return;
            }

            if (!BhapticsUtils.IsPlayerRunning())
            {
                Debug.Log("bHaptics Player is not running, try launching bHaptics Player.");
                BhapticsUtils.LaunchPlayer(launchPlayerIfNotRunning);
            }
        }
Exemple #5
0
        public virtual void Stop()
        {
            var haptic = BhapticsManager.GetHaptic();

            if (haptic != null)
            {
                haptic.TurnOff();
            }
        }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="identifier">Use when stopping haptic feedback independently.</param>
        public virtual void Stop(string identifier)
        {
            var haptic = BhapticsManager.GetHaptic();

            if (haptic != null)
            {
                haptic.TurnOff(keyId + identifier);
            }
        }
Exemple #7
0
        private static void OnUpdateDevicesChange(List <HapticDevice> devices)
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }
            androidHapticPlayer.UpdateDeviceList(devices);
        }
Exemple #8
0
        public static void UnpairAll()
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }
            androidHapticPlayer.UnpairAll();
        }
Exemple #9
0
        public static void Pair(string address, string position = "")
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }
            androidHapticPlayer.Pair(address, position);
        }
Exemple #10
0
        public static void TogglePosition(string address)
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            androidHapticPlayer.TogglePosition(address);
        }
Exemple #11
0
        public static void Ping(HapticDevice device)
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            androidHapticPlayer.Ping(device.Address);
        }
Exemple #12
0
        public static void ScanStop()
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            androidHapticPlayer.StopScan();
        }
Exemple #13
0
        public static void Unpair(string address)
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            androidHapticPlayer.Unpair(address);
        }
        public static void RequestPermission()
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            androidHapticPlayer.RequestPermission();
        }
Exemple #15
0
        public static bool IsStreaming()
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return(false);
            }

            return(androidHapticPlayer.IsStreamingEnable());
        }
Exemple #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="identifier">Use when checking haptic feedback independently.</param>
        /// <returns></returns>
        public virtual bool IsPlaying(string identifier)
        {
            var haptic = BhapticsManager.GetHaptic();

            if (haptic == null)
            {
                return(false);
            }

            return(haptic.IsPlaying(keyId + identifier));
        }
Exemple #17
0
        public static void ToggleEnableDevice(HapticDevice device)
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            androidHapticPlayer.EnableDevice(device.Address, !device.IsEnable);
        }
Exemple #18
0
        public virtual bool IsPlaying()
        {
            var haptic = BhapticsManager.GetHaptic();

            if (haptic == null)
            {
                return(false);
            }

            return(haptic.IsPlaying(keyId));
        }
Exemple #19
0
        public static void ShowBluetoothSetting()
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            androidHapticPlayer.ShowBluetoothSetting();
        }
Exemple #20
0
        public static List <AndroidUtils.StreamHost> GetStreamingHosts()
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return(new List <AndroidUtils.StreamHost>());
            }

            return(androidHapticPlayer.GetStreamingHosts());
        }
Exemple #21
0
        public static void ToggleStreaming()
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            androidHapticPlayer.ToggleStreaming();
        }
Exemple #22
0
        public static void Ping(HapticDevice device)
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            Debug.LogFormat("PING  ..." + device.Address);

            androidHapticPlayer.Ping(device.Address);
        }
Exemple #23
0
        void OnApplicationFocus(bool pauseStatus)
        {
            if (pauseStatus)
            {
                var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;
                if (androidHapticPlayer == null)
                {
                    return;
                }

                androidHapticPlayer.RefreshPairingInfo();
            }
        }
        public static void Scan()
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            if (!androidHapticPlayer.IsScanning())
            {
                androidHapticPlayer.StartScan();
            }
        }
Exemple #25
0
        public static void Scan()
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null || !AndroidPermissionsManager.CheckBluetoothPermissions())
            {
                return;
            }

            if (!androidHapticPlayer.IsScanning())
            {
                androidHapticPlayer.StartScan();
            }
        }
Exemple #26
0
        private static void RefreshDeviceListUi()
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            if (Instance != null)
            {
                Instance.InvokeRefresh();
            }
        }
        private void RefreshDevices()
        {
            if (refreshActions.Count == 0)
            {
                return;
            }

            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                // if (Devices.Count == 0)
                // {
                //     var device = new HapticDevice()
                //     {
                //         Position = PositionType.Vest,
                //         IsConnected = true,
                //         IsPaired = true,
                //         Address = "aaaa",
                //         DeviceName = "Tactot",
                //         Candidates = new PositionType[] { PositionType.Vest },
                //     };
                //     var device2 = new HapticDevice()
                //     {
                //         Position = PositionType.ForearmL,
                //         IsConnected = false,
                //         IsPaired = false,
                //         Address = "aaaa22",
                //         DeviceName = "Tactosy",
                //         Candidates = new PositionType[] { PositionType.ForearmR, PositionType.ForearmL },
                //     };
                //     Devices.Add(device);
                //     Devices.Add(device2);
                //
                // }
                // // TODO DEBUGGING USAGE.
                // for (var i = 0; i < refreshActions.Count; i++)
                // {
                //     refreshActions[i].Invoke();
                // }
                return;
            }

            Devices = androidHapticPlayer.GetDevices();
            for (var i = 0; i < refreshActions.Count; i++)
            {
                refreshActions[i].Invoke();
            }
        }
        public static bool CheckPermission()
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                if (pcAndoidTestMode)
                {
                    return(true);
                }

                return(false);
            }

            return(androidHapticPlayer.CheckPermission());
        }
Exemple #29
0
        public void OnChange()
        {
            try
            {
                var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;
                if (androidHapticPlayer == null)
                {
                    return;
                }

                androidHapticPlayer.CheckChange();
            }
            catch (Exception e)
            {
                BhapticsLogger.LogInfo("OnChange {0}", e.Message);
            }
        }
        public override void Play(float intensity, float duration, float vestRotationAngleX, float vestRotationOffsetY)
        {
            if (!BhapticsManager.Init)
            {
                BhapticsManager.Initialize();
                return;
            }

            var haptic = BhapticsManager.GetHaptic();

            if (!haptic.IsFeedbackRegistered(assetId))
            {
                haptic.RegisterTactFileStr(assetId, JsonValue);
            }

            haptic.SubmitRegistered(assetId, keyId, new ScaleOption(intensity, duration));
        }