コード例 #1
0
        public virtual void OnControllerReady(ControllerHand hand)
        {
            VRTKSDKBaseControllerEventArgs e;

            e.controllerReference = VRTK_ControllerReference.GetControllerReference(hand);

            switch (hand)
            {
            case ControllerHand.Left:
                if (LeftControllerReady != null)
                {
                    LeftControllerReady(this, e);
                }
                break;

            case ControllerHand.Right:
                if (RightControllerReady != null)
                {
                    RightControllerReady(this, e);
                }
                break;
            }
        }
コード例 #2
0
ファイル: VRTK_TrackedController.cs プロジェクト: KKJSP/USPTO
        protected virtual void Update()
        {
            uint checkIndex = VRTK_DeviceFinder.GetControllerIndex(gameObject);
            if (checkIndex != index)
            {
                uint previousIndex = index;
                index = checkIndex;
                //If the controller model listeners have already been registered, then make sure to unsub and sub when index changes.
                if (controllerModelWaitSubscribed)
                {
                    ManageControllerModelListeners(false);
                    ManageControllerModelListeners(true);
                }
                OnControllerIndexChanged(SetEventPayload(previousIndex));
                SetControllerType();
            }

            VRTK_SDK_Bridge.ControllerProcessUpdate(VRTK_ControllerReference.GetControllerReference(index));

            if (aliasController != null && gameObject.activeInHierarchy && !aliasController.activeSelf)
            {
                aliasController.SetActive(true);
            }
        }
コード例 #3
0
 public virtual void HapticsOnUse(uint controllerIndex)
 {
     this.HapticsOnUse(VRTK_ControllerReference.GetControllerReference(controllerIndex));
 }
コード例 #4
0
 public static Vector3 GetControllerAngularVelocity(GameObject givenController)
 {
     return(GetControllerAngularVelocity(VRTK_ControllerReference.GetControllerReference(givenController)));
 }
コード例 #5
0
 protected virtual VRTK_ControllerReference GetControllerReference(GameObject reference = null)
 {
     reference = (reference == null && controllingPointer != null && controllingPointer.controllerEvents != null ? controllingPointer.controllerEvents.gameObject : reference);
     return(VRTK_ControllerReference.GetControllerReference(reference));
 }
コード例 #6
0
 public static void TriggerHapticPulse(uint controllerIndex, float strength, float duration, float pulseInterval)
 {
     VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controllerIndex), strength, duration, pulseInterval);
 }
コード例 #7
0
 public static Vector3 GetControllerVelocity(GameObject givenController)
 {
     return(VRTK_DeviceFinder.GetControllerVelocity(VRTK_ControllerReference.GetControllerReference(givenController)));
 }
コード例 #8
0
 protected virtual VRTK_ControllerReference GetReferenceFromEvents(VRTK_ControllerEvents controllerEvents)
 {
     return(VRTK_ControllerReference.GetControllerReference((controllerEvents != null ? controllerEvents.gameObject : null)));
 }
コード例 #9
0
 public static bool IsHairTriggerDownOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.TriggerHairline, SDK_BaseController.ButtonPressTypes.PressDown, VRTK_ControllerReference.GetControllerReference(index)));
 }
コード例 #10
0
 public static float GetGripHairlineDeltaOnIndex(uint index)
 {
     return(GetControllerHairlineDelta(SDK_BaseController.ButtonTypes.GripHairline, VRTK_ControllerReference.GetControllerReference(index)));
 }
コード例 #11
0
 public static Vector2 GetGripAxisOnIndex(uint index)
 {
     return(GetControllerAxis(SDK_BaseController.ButtonTypes.Grip, VRTK_ControllerReference.GetControllerReference(index)));
 }
コード例 #12
0
 public static Vector3 GetAngularVelocityOnIndex(uint index)
 {
     return(GetControllerAngularVelocity(VRTK_ControllerReference.GetControllerReference(index)));
 }
コード例 #13
0
 public static void HapticPulseOnIndex(uint index, float strength = 0.5f)
 {
     HapticPulse(VRTK_ControllerReference.GetControllerReference(index), strength);
 }
コード例 #14
0
 public static GameObject GetControllerRenderModel(GameObject controller)
 {
     return(GetControllerRenderModel(VRTK_ControllerReference.GetControllerReference(controller)));
 }
コード例 #15
0
        protected virtual void SetControllerButtons(ControllerHand hand)
        {
            List <string> checkhands = (hand == ControllerHand.Right ? validRightHands : validLeftHands);

            bool joystickFound      = false;
            int  validJoystickIndex = 0;

            string[] availableJoysticks = Input.GetJoystickNames();
            for (int i = 0; i < availableJoysticks.Length; i++)
            {
                if (checkhands.Contains(availableJoysticks[i]))
                {
                    SetCachedControllerType(availableJoysticks[i]);
                    joystickFound      = true;
                    validJoystickIndex = i + 1;
                }
            }

            //If the joystick isn't found then try and match on headset type
            if (!joystickFound)
            {
                switch (VRTK_DeviceFinder.GetHeadsetType())
                {
                case SDK_BaseHeadset.HeadsetType.GoogleDaydream:
                    SetCachedControllerType("googledaydream");
                    joystickFound      = true;
                    validJoystickIndex = 1;
                    break;
                }
            }

            if (joystickFound)
            {
                if (hand == ControllerHand.Right)
                {
                    SetControllerButtonValues(ref rightControllerTouchKeyCodes, ref rightControllerPressKeyCodes, validJoystickIndex, rightControllerTouchCodes, rightControllerPressCodes);
                }
                else
                {
                    SetControllerButtonValues(ref leftControllerTouchKeyCodes, ref leftControllerPressKeyCodes, validJoystickIndex, leftControllerTouchCodes, leftControllerPressCodes);
                }
            }
            else if (availableJoysticks.Length > 0 && VRTK_ControllerReference.GetControllerReference(hand) != null && VRTK_ControllerReference.GetControllerReference(hand).actual.gameObject.activeInHierarchy)
            {
                VRTK_Logger.Warn("Failed setting controller buttons on [" + hand + "] due to no valid joystick type found in `GetJoyStickNames` -> " + string.Join(", ", availableJoysticks));
            }
        }
コード例 #16
0
        /// <summary>
        /// The ToggleBeam method allows the pointer beam to be toggled on or off via code at runtime. If true is passed as the state then the beam is activated, if false then the beam is deactivated.
        /// </summary>
        /// <param name="state">The state of whether to enable or disable the beam.</param>
        public virtual void ToggleBeam(bool state)
        {
            VRTK_ControllerReference givenControllerReference = (controller != null ? VRTK_ControllerReference.GetControllerReference(controller.gameObject) : null);

            if (state)
            {
                TurnOnBeam(givenControllerReference);
            }
            else
            {
                TurnOffBeam(givenControllerReference);
            }
        }
コード例 #17
0
ファイル: VRTK_TrackedController.cs プロジェクト: KKJSP/USPTO
 protected virtual void FixedUpdate()
 {
     VRTK_SDK_Bridge.ControllerProcessFixedUpdate(VRTK_ControllerReference.GetControllerReference(index));
 }
コード例 #18
0
 public static bool IsGripPressedOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.Grip, SDK_BaseController.ButtonPressTypes.Press, VRTK_ControllerReference.GetControllerReference(index)));
 }
コード例 #19
0
 public static bool IsHairGripUpOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.GripHairline, SDK_BaseController.ButtonPressTypes.PressUp, VRTK_ControllerReference.GetControllerReference(index)));
 }
コード例 #20
0
 public static bool IsTouchpadTouchedOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.Touchpad, SDK_BaseController.ButtonPressTypes.Touch, VRTK_ControllerReference.GetControllerReference(index)));
 }
コード例 #21
0
        protected virtual VRTK_ControllerReference GetRightThenLeftReference()
        {
            VRTK_ControllerReference controllerReference = VRTK_ControllerReference.GetControllerReference(SDK_BaseController.ControllerHand.Right);

            return(VRTK_ControllerReference.IsValid(controllerReference) ? controllerReference : VRTK_ControllerReference.GetControllerReference(SDK_BaseController.ControllerHand.Left));
        }
コード例 #22
0
 public static bool IsButtonTwoPressedUpOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.ButtonTwo, SDK_BaseController.ButtonPressTypes.PressUp, VRTK_ControllerReference.GetControllerReference(index)));
 }
コード例 #23
0
 public static void TriggerHapticPulse(uint controllerIndex, float strength)
 {
     VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controllerIndex), strength);
 }
コード例 #24
0
 public static bool IsButtonTwoTouchedDownOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.ButtonTwo, SDK_BaseController.ButtonPressTypes.TouchDown, VRTK_ControllerReference.GetControllerReference(index)));
 }
コード例 #25
0
 public static void CancelHapticPulse(uint controllerIndex)
 {
     VRTK_ControllerHaptics.CancelHapticPulse(VRTK_ControllerReference.GetControllerReference(controllerIndex));
 }
コード例 #26
0
 public static bool IsStartMenuPressedDownOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.StartMenu, SDK_BaseController.ButtonPressTypes.PressDown, VRTK_ControllerReference.GetControllerReference(index)));
 }
コード例 #27
0
 public virtual void HapticsOnGrab(uint controllerIndex)
 {
     HapticsOnGrab(VRTK_ControllerReference.GetControllerReference(controllerIndex));
 }
コード例 #28
0
 public static bool IsStartMenuTouchedUpOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.StartMenu, SDK_BaseController.ButtonPressTypes.TouchUp, VRTK_ControllerReference.GetControllerReference(index)));
 }
コード例 #29
0
 public static Transform GetControllerOrigin(GameObject controller)
 {
     return(GetControllerOrigin(VRTK_ControllerReference.GetControllerReference(controller)));
 }
コード例 #30
0
ファイル: VRTK_DeviceFinder.cs プロジェクト: KKJSP/USPTO
 /// <summary>
 /// The GetControllerReferenceForHand returns a Controller Reference for the given hand controller.
 /// </summary>
 /// <returns>The Controller Reference for the given hand controller.</returns>
 public static VRTK_ControllerReference GetControllerReferenceForHand(SDK_BaseController.ControllerHand hand)
 {
     return(VRTK_ControllerReference.GetControllerReference(hand));
 }