コード例 #1
0
ファイル: OpenVR_New.cs プロジェクト: Saticmotion/Vivista
        public override bool SetRumble(XRControllerRumbleSide controller, float strength, float duration)
        {
            if (strength < 0)
            {
                strength = 0;
            }
            if (strength > 1)
            {
                strength = 1;
            }
            if (duration < 0)
            {
                duration = 0;
            }

            if (leftHand >= 0 && (controller == XRControllerRumbleSide.Left || controller == XRControllerRumbleSide.Both))
            {
                input.TriggerHapticVibrationAction(viveAction_Rumble_LeftHand, 0, duration, 1, strength, 0);
            }

            if (rightHand >= 0 && (controller == XRControllerRumbleSide.Right || controller == XRControllerRumbleSide.Both))
            {
                input.TriggerHapticVibrationAction(viveAction_Rumble_RightHand, 0, duration, 1, strength, 0);
            }

            return(true);
        }
コード例 #2
0
ファイル: OpenVR_Legacy.cs プロジェクト: Saticmotion/Vivista
        public override bool SetRumble(XRControllerRumbleSide controller, float strength, float duration)
        {
            if (strength < 0)
            {
                strength = 0;
            }
            if (strength > 1)
            {
                strength = 1;
            }
            if (duration < 0)
            {
                duration = 0;
            }

            if (leftHand >= 0 && (controller == XRControllerRumbleSide.Left || controller == XRControllerRumbleSide.Both))
            {
                system.TriggerHapticPulse((uint)leftHand, 0, (ushort)(duration * 1000000));
            }

            if (rightHand >= 0 && (controller == XRControllerRumbleSide.Right || controller == XRControllerRumbleSide.Both))
            {
                system.TriggerHapticPulse((uint)rightHand, 0, (ushort)(duration * 1000000));
            }

            return(true);
        }
コード例 #3
0
 public static bool SetRumble(XRControllerRumbleSide controller, float strength, float duration = .1f)
 {
     if (singleton == null)
     {
         return(false);
     }
     return(singleton.api.SetRumble(controller, strength, duration));
 }
コード例 #4
0
        public override bool SetRumble(XRControllerRumbleSide controller, float strength, float duration)
        {
            if (strength < 0)
            {
                strength = 0;
            }
            if (strength > 1)
            {
                strength = 1;
            }
            if (duration < 0)
            {
                duration = 0;
            }

            if (controller == XRControllerRumbleSide.Left || controller == XRControllerRumbleSide.Both)
            {
                HapticCapabilities capabilities;
                if (handLeft.TryGetHapticCapabilities(out capabilities))
                {
                    if (capabilities.supportsImpulse)
                    {
                        return(handLeft.SendHapticImpulse(XRInput.singleton.rumbleChannel, strength, duration));
                    }
                }
            }

            if (controller == XRControllerRumbleSide.Right || controller == XRControllerRumbleSide.Both)
            {
                HapticCapabilities capabilities;
                if (handRight.TryGetHapticCapabilities(out capabilities))
                {
                    if (capabilities.supportsImpulse)
                    {
                        return(handRight.SendHapticImpulse(XRInput.singleton.rumbleChannel, strength, duration));
                    }
                }
            }

            return(false);
        }
コード例 #5
0
 public virtual bool SetRumble(XRControllerRumbleSide controller, float strength, float duration)
 {
     return(false);
 }