Example #1
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 (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);
        }
Example #2
0
        public void TriggerHapticPulse(ushort durationMicroSec = 500, EVRButtonId buttonId = EVRButtonId.k_EButton_Axis0)
        {
            CVRSystem system = OpenVR.System;

            if (system != null)
            {
                uint unAxisId = (uint)(buttonId - EVRButtonId.k_EButton_Axis0);
                system.TriggerHapticPulse(this.index, unAxisId, (char)durationMicroSec);
            }
        }
Example #3
0
        public bool TriggerHapticPulse(uint index, ushort us = 3000)
        {
            //有効なデバイスか
            if (!IsDeviceValid(index))
            {
                return(false);
            }

            openvr.TriggerHapticPulse(index, 1, us);
            return(true);
        }
Example #4
0
    //振動フィードバックを行う
    private void haptic(LeftOrRight lr)
    {
#pragma warning disable 0219
        string Tag = "[" + this.GetType().Name + ":" + System.Reflection.MethodBase.GetCurrentMethod(); //クラス名とメソッド名を自動取得
#pragma warning restore 0219

        //左手コントローラーが有効かチェック
        uint Leftidx = openvr.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.LeftHand);
        if (Leftidx != OpenVR.k_unTrackedDeviceIndexInvalid && lr == LeftOrRight.Left)
        {
            //ぶるっと
            openvr.TriggerHapticPulse(Leftidx, 0, 3000);
        }
        //右手コントローラーが有効かチェック
        uint Rightidx = openvr.GetTrackedDeviceIndexForControllerRole(ETrackedControllerRole.RightHand);
        if (Rightidx != OpenVR.k_unTrackedDeviceIndexInvalid && lr == LeftOrRight.Right)
        {
            //ぶるっと
            openvr.TriggerHapticPulse(Rightidx, 0, 3000);
        }
    }
Example #5
0
 protected override void OnRenderFrame(FrameEventArgs e)
 {
     base.OnRenderFrame(e);
     if (mScene.leftControllerShouldVibrate())
     {
         mHMD.TriggerHapticPulse((uint)mScene.leftControllerIdx, 0, (char)127);
     }
     if (mScene.rightControllerShouldVibrate())
     {
         mHMD.TriggerHapticPulse((uint)mScene.rightControllerIdx, 0, (char)127);
     }
     MakeCurrent();
     updateMatrixPose();
     notifyRobotIfSafe();
     handleSignals();
     handleInteractions();
     if (isCalibrateController)
     {
         updateControllerCallibration();
     }
     mRenderer.renderFrame();
     SwapBuffers();
 }
        public void TriggerHapticPulse(XRNode node, byte strength)
        {
            if (strength == 0)
            {
                return;
            }

            float     pulseDuration  = Time.smoothDeltaTime * 1000000.0f;
            float     biasedStrength = Plugin.SteamBiasTable[Math.Min(9, (int)strength)];
            float     F      = pulseDuration * biasedStrength;
            CVRSystem system = OpenVR.System;
            ETrackedControllerRole unDeviceType      = (node == XRNode.LeftHand) ? ETrackedControllerRole.LeftHand : ETrackedControllerRole.RightHand;
            uint trackedDeviceIndexForControllerRole = system.GetTrackedDeviceIndexForControllerRole(unDeviceType);

            system.TriggerHapticPulse(trackedDeviceIndexForControllerRole, 0u, (char)F);
        }