/// <summary>
        ///
        /// </summary>
        /// <param name="pos"></param>
        /// <param name="isLeft">Value used for devices with left and right sides.(Default: Left)</param>
        /// <returns></returns>
        public static PositionType ToPositionType(HapticDeviceType pos, bool isLeft = true)
        {
            switch (pos)
            {
            case HapticDeviceType.Tactal:
                return(PositionType.Head);

            case HapticDeviceType.TactSuit:
                return(PositionType.Vest);

            case HapticDeviceType.Tactosy_arms:
                return(isLeft ? PositionType.ForearmL : PositionType.ForearmR);

            case HapticDeviceType.Tactosy_feet:
                return(isLeft ? PositionType.FootL : PositionType.FootR);

            case HapticDeviceType.Tactosy_hands:
                return(isLeft ? PositionType.HandL : PositionType.HandR);

            case HapticDeviceType.TactGlove:
                return(isLeft ? PositionType.GloveL : PositionType.GloveR);
            }

            return(PositionType.Head);
        }
Exemple #2
0
        public bool IsConnect(HapticDeviceType type, bool isLeft = true)
        {
            foreach (var device in deviceList)
            {
                if (device.Position == BhapticsUtils.ToPositionType(type, isLeft) && device.IsConnected)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #3
0
 public bool IsConnect(HapticDeviceType type, bool isLeft = true)
 {
     return(HapticApi.IsDevicePlaying(BhapticsUtils.ToPositionType(type, isLeft)));
 }
        private static void CreateTactClip(string tactFilePath)
        {
            try
            {
                var fileName = Path.GetFileNameWithoutExtension(tactFilePath);
                if (fileName == null)
                {
                    BhapticsLogger.LogError("File name is null. Path: ");
                    return;
                }
                string json = LoadJsonStringFromFile(tactFilePath);
                var    file = CommonUtils.ConvertJsonStringToTactosyFile(json);
                // var fileHash = GetHash(tactFilePath);
                var clipPath = tactFilePath.Replace(".tact", ".asset");

                if (File.Exists(clipPath))
                {
                    clipPath = GetUsableFileName(clipPath);
                    if (clipPath == null)
                    {
                        BhapticsLogger.LogError("File duplicated. Path: " + tactFilePath);
                        return;
                    }
                }
                clipPath = ConvertToAssetPathFromAbsolutePath(clipPath);

                HapticDeviceType type = GetMappedDeviceType(file.Project.Layout.Type);

                FileHapticClip tactClip;
                if (type == HapticDeviceType.TactSuit)
                {
                    tactClip = CreateInstance <VestHapticClip>();
                }
                else if (type == HapticDeviceType.Tactal)
                {
                    tactClip = CreateInstance <HeadHapticClip>();
                }
                else if (type == HapticDeviceType.Tactosy_arms)
                {
                    tactClip = CreateInstance <ArmsHapticClip>();
                }
                else if (type == HapticDeviceType.Tactosy_hands)
                {
                    tactClip = CreateInstance <HandsHapticClip>();
                }
                else if (type == HapticDeviceType.Tactosy_feet)
                {
                    tactClip = CreateInstance <FeetHapticClip>();
                }
                else
                {
                    tactClip = CreateInstance <FileHapticClip>();
                }

                tactClip.JsonValue = json;
                tactClip.ClipType  = type;

                File.Delete(tactFilePath);
                AssetDatabase.CreateAsset(tactClip, clipPath);
                AssetDatabase.Refresh();
                AssetDatabase.SaveAssets();
            }
            catch (Exception e)
            {
                BhapticsLogger.LogError("Failed to read tact file. Path: " + tactFilePath + "\n" + e.Message);
            }
        }