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
        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));
 }
 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)));
 }
 protected virtual VRTK_ControllerReference GetReferenceFromEvents(VRTK_ControllerEvents controllerEvents)
 {
     return(VRTK_ControllerReference.GetControllerReference((controllerEvents != null ? controllerEvents.gameObject : null)));
 }
 public static bool IsHairTriggerDownOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.TriggerHairline, SDK_BaseController.ButtonPressTypes.PressDown, VRTK_ControllerReference.GetControllerReference(index)));
 }
 public static float GetGripHairlineDeltaOnIndex(uint index)
 {
     return(GetControllerHairlineDelta(SDK_BaseController.ButtonTypes.GripHairline, VRTK_ControllerReference.GetControllerReference(index)));
 }
 public static Vector2 GetGripAxisOnIndex(uint index)
 {
     return(GetControllerAxis(SDK_BaseController.ButtonTypes.Grip, VRTK_ControllerReference.GetControllerReference(index)));
 }
 public static Vector3 GetAngularVelocityOnIndex(uint index)
 {
     return(GetControllerAngularVelocity(VRTK_ControllerReference.GetControllerReference(index)));
 }
 public static void HapticPulseOnIndex(uint index, float strength = 0.5f)
 {
     HapticPulse(VRTK_ControllerReference.GetControllerReference(index), strength);
 }
 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
 protected virtual void FixedUpdate()
 {
     VRTK_SDK_Bridge.ControllerProcessFixedUpdate(VRTK_ControllerReference.GetControllerReference(index));
 }
 public static bool IsGripPressedOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.Grip, SDK_BaseController.ButtonPressTypes.Press, VRTK_ControllerReference.GetControllerReference(index)));
 }
 public static bool IsHairGripUpOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.GripHairline, SDK_BaseController.ButtonPressTypes.PressUp, VRTK_ControllerReference.GetControllerReference(index)));
 }
 public static bool IsTouchpadTouchedOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.Touchpad, SDK_BaseController.ButtonPressTypes.Touch, VRTK_ControllerReference.GetControllerReference(index)));
 }
        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));
        }
 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);
 }
 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));
 }
 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));
 }
 public static bool IsStartMenuTouchedUpOnIndex(uint index)
 {
     return(GetControllerButtonState(SDK_BaseController.ButtonTypes.StartMenu, SDK_BaseController.ButtonPressTypes.TouchUp, VRTK_ControllerReference.GetControllerReference(index)));
 }
 public static Transform GetControllerOrigin(GameObject controller)
 {
     return(GetControllerOrigin(VRTK_ControllerReference.GetControllerReference(controller)));
 }
示例#30
0
 /// <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));
 }