Beispiel #1
0
        public void RefreshDevice(HapticDevice d)
        {
            device = d;

            if (device == null)
            {
                gameObject.SetActive(false);
                return;
            }

            if (!gameObject.activeSelf)
            {
                gameObject.SetActive(true);
            }

            UpdateIcon(d);

            if (d.IsConnected)
            {
                RenderConnectMenu();
            }
            else
            {
                RenderDisconnectMenu();
            }
        }
        public void Refresh(HapticDevice tactDevice, Bhaptics_Widget_Setting setting)
        {
            device                    = tactDevice;
            deviceName.text           = device.DeviceName;
            toggleButton.interactable = tactDevice.IsConnected;

            if (!AndroidUtils.CanChangePosition(tactDevice.Position))
            {
                toggleButton.gameObject.SetActive(false);
            }
            else
            {
                if (tactDevice.IsConnected)
                {
                    if (AndroidUtils.IsLeft(device.Position))
                    {
                        toggleButton.image.sprite = leftSide;
                    }
                    else
                    {
                        toggleButton.image.sprite = rightSide;
                    }
                }

                toggleButton.gameObject.SetActive(true);
            }

            if (setting != null)
            {
                deviceImage.sprite = setting.GetPairedDeviceSprite(device);
            }
        }
        public Sprite GetPairedDeviceSprite(HapticDevice device)
        {
            string deviceType = device.DeviceName;
            var    isConnect  = device.IsConnected;

            if (deviceType.StartsWith("TactosyH"))
            {
                return(isConnect ? SettingTactosyHand.pairImage : SettingTactosyHand.unpairImage);
            }

            if (deviceType.StartsWith("TactosyF"))
            {
                return(isConnect ? SettingTactosyFoot.pairImage : SettingTactosyFoot.unpairImage);
            }

            if (deviceType.StartsWith("Tactosy"))
            {
                return(isConnect ? SettingTactosyArm.pairImage : SettingTactosyArm.unpairImage);
            }

            if (deviceType.StartsWith("Tactal"))
            {
                return(isConnect ? SettingTactal.pairImage : SettingTactal.unpairImage);
            }

            if (deviceType.StartsWith("Tactot"))
            {
                return(isConnect ? SettingTactot.pairImage : SettingTactot.unpairImage);
            }

            return(null);
        }
Beispiel #4
0
 public void Refresh(HapticDevice tactDevice, Bhaptics_Widget_Setting setting)
 {
     device          = tactDevice;
     deviceName.text = device.DeviceName;
     if (setting != null)
     {
         deviceImage.sprite = setting.GetScannedDeviceSprite(device.DeviceName);
     }
 }
Beispiel #5
0
        public static void ToggleEnableDevice(HapticDevice device)
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            androidHapticPlayer.EnableDevice(device.Address, !device.IsEnable);
        }
Beispiel #6
0
        public static void Ping(HapticDevice device)
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                return;
            }

            androidHapticPlayer.Ping(device.Address);
        }
Beispiel #7
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);
        }
        public static bool CanPair(HapticDevice device, PositionType deviceType)
        {
            var containsInCandidates = false;

            for (var i = 0; i < device.Candidates.Length; i++)
            {
                var candi = device.Candidates[i];
                if (candi == deviceType)
                {
                    containsInCandidates = true;
                    break;
                }
            }

            return((containsInCandidates || device.Position == deviceType) &&
                   !device.IsPaired);
        }
Beispiel #9
0
        private void UpdateIcon(HapticDevice d)
        {
            switch (d.Position)
            {
            case PositionType.Vest:
                if (d.IsAudioJack)
                {
                    icon.sprite = TactsuitWiredIcon;
                    return;
                }

                icon.sprite = GetSprite(widgetSetting.Vest, d.IsConnected);
                break;

            case PositionType.FootL:
            case PositionType.FootR:
                icon.sprite = GetSprite(widgetSetting.Foot, d.IsConnected);
                break;

            case PositionType.HandL:
            case PositionType.HandR:
                icon.sprite = GetSprite(widgetSetting.Hand, d.IsConnected);
                break;

            case PositionType.ForearmL:
            case PositionType.ForearmR:
                icon.sprite = GetSprite(widgetSetting.Arm, d.IsConnected);
                break;

            case PositionType.GloveL:
                icon.sprite = GetSprite(widgetSetting.GloveL, d.IsConnected);
                break;

            case PositionType.GloveR:
                icon.sprite = GetSprite(widgetSetting.GloveR, d.IsConnected);
                break;

            case PositionType.Head:
                icon.sprite = GetSprite(widgetSetting.Head, d.IsConnected);
                break;

            default:
                icon.sprite = null;
                break;
            }
        }
Beispiel #10
0
        public static List <HapticDevice> GetDevices(bool force = false)
        {
            var androidHapticPlayer = BhapticsManager.GetHaptic() as AndroidHaptic;

            if (androidHapticPlayer == null)
            {
                var device = new HapticDevice()
                {
                    Position         = PositionType.Vest,
                    IsConnected      = false,
                    IsPaired         = true,
                    Address          = "aaaa",
                    Battery          = 100,
                    Rssi             = -100,
                    DeviceName       = "Tactot",
                    Candidates       = new PositionType[] { PositionType.Vest },
                    ConnectionStatus = "Disconnected",
                };
                var device2 = new HapticDevice()
                {
                    Position         = PositionType.ForearmL,
                    IsConnected      = false,
                    IsPaired         = false,
                    Address          = "aaaa22",
                    Battery          = 100,
                    Rssi             = -100,
                    DeviceName       = "Tactosy",
                    ConnectionStatus = "Disconnected",
                    Candidates       = new PositionType[] { PositionType.ForearmR, PositionType.ForearmL },
                };
                var list = new List <HapticDevice>();
                // list.Add(device);
                // list.Add(device2);
                // TODO DEBUGGING USAGE.
                return(list);
            }

            return(androidHapticPlayer.GetDevices(force));
        }
Beispiel #11
0
        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    = true,
                        Address     = "aaaa22",
                        DeviceName  = "Tactosy",
                        Candidates  = new PositionType[] { PositionType.ForearmR, PositionType.ForearmL },
                    };
                    var device3 = new HapticDevice()
                    {
                        Position    = PositionType.HandL,
                        IsConnected = true,
                        IsPaired    = true,
                        Address     = "aaaa22",
                        DeviceName  = "Tactosy",
                        Candidates  = new PositionType[] { PositionType.HandL, PositionType.HandR },
                    };
                    var device4 = new HapticDevice()
                    {
                        Position    = PositionType.Head,
                        IsConnected = true,
                        IsPaired    = true,
                        Address     = "aaaa22",
                        DeviceName  = "Tactal",
                        Candidates  = new PositionType[] { PositionType.Head },
                    };

                    var device5 = new HapticDevice()
                    {
                        Position    = PositionType.Vest,
                        IsConnected = true,
                        IsPaired    = true,
                        IsAudioJack = true,
                        Address     = "aaaa",
                        DeviceName  = "Tactot",
                        Battery     = 10,
                        Candidates  = new PositionType[] { PositionType.Vest },
                    };
                    //Devices.Add(device);
                    //Devices.Add(device2);
                    //Devices.Add(device3);
                    //Devices.Add(device4);
                    //Devices.Add(device5);
                }
                // 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();
            }
        }