Esempio n. 1
0
        protected void InitControllerListener(bool state, GameObject controller, ref VRTK_ControllerEvents events, ref VRTK_InteractGrab grab,
                                              ControllerInteractionEventHandler triggerPressed, ControllerInteractionEventHandler triggerReleased)
        {
            if (controller != null)
            {
                events = controller.GetComponentInChildren <VRTK_ControllerEvents>();
                grab   = controller.GetComponentInChildren <VRTK_InteractGrab>();

                if (events != null)
                {
                    if (state == true)
                    {
                        events.SubscribeToButtonAliasEvent(activationButton, true, triggerPressed);
                        events.SubscribeToButtonAliasEvent(activationButton, false, triggerReleased);

                        if (cancelButton != VRTK_ControllerEvents.ButtonAlias.Undefined)
                        {
                            events.SubscribeToButtonAliasEvent(cancelButton, true, CancelButtonPressed);
                        }
                    }
                    else
                    {
                        events.UnsubscribeToButtonAliasEvent(activationButton, true, triggerPressed);
                        events.UnsubscribeToButtonAliasEvent(activationButton, false, triggerReleased);

                        if (cancelButton != VRTK_ControllerEvents.ButtonAlias.Undefined)
                        {
                            events.UnsubscribeToButtonAliasEvent(cancelButton, true, CancelButtonPressed);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
    public void Awake()
    {
        touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
        touchpadUntouched   = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);

        controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand();
    }
    // Controller Event Handling Register Helper

    private void RegisterHandler()
    {
        // register ApplicationMenuButton
        if (applicationButtonPressedHandler == null)
        {
            applicationButtonPressedHandler = new ControllerInteractionEventHandler(ApplicationMenuButtonPressed);
        }

        leftController.GetComponent <VRTK_ControllerEvents>().ApplicationMenuPressed  += applicationButtonPressedHandler;
        rightController.GetComponent <VRTK_ControllerEvents>().ApplicationMenuPressed += applicationButtonPressedHandler;

        // register GripButton
        if (gripButtonPressedHandler == null)
        {
            gripButtonPressedHandler = new ControllerInteractionEventHandler(GripButtonPressed);
        }

        leftController.GetComponent <VRTK_ControllerEvents>().GripPressed  += gripButtonPressedHandler;
        rightController.GetComponent <VRTK_ControllerEvents>().GripPressed += gripButtonPressedHandler;

        // register TouchPad
        if (touchPadPressedHandler == null)
        {
            touchPadPressedHandler = new ControllerInteractionEventHandler(TouchPadPressed);
        }

        leftController.GetComponent <VRTK_ControllerEvents>().TouchpadPressed  += touchPadPressedHandler;
        rightController.GetComponent <VRTK_ControllerEvents>().TouchpadPressed += touchPadPressedHandler;
    }
Esempio n. 4
0
    public void Awake()
    {
        CheckDevices();

        controllerEnabledHandler  = new ControllerInteractionEventHandler(ControllerEnabled);
        controllerDisabledHandler = new ControllerInteractionEventHandler(ControllerDisabled);
    }
        private void Awake()
        {
            touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
            touchpadUntouched = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);

            controllerLeftHand = VRTK_DeviceFinder.GetControllerLeftHand();
            controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand();
        }
Esempio n. 6
0
 private void Awake()
 {
     touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
     touchpadUntouched   = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);
     playArea            = VRTK_DeviceFinder.PlayAreaTransform();
     controllerLeftHand  = VRTK_DeviceFinder.GetControllerLeftHand();
     controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand();
 }
Esempio n. 7
0
 protected virtual void UnsubscribeButtonEvent(VRTK_ControllerEvents.ButtonAlias buttonType, ControllerInteractionEventHandler setEventHandler,
                                               ControllerInteractionEventHandler resetEventHandler)
 {
     if (buttonType != VRTK_ControllerEvents.ButtonAlias.Undefined)
     {
         controllerEvents.UnsubscribeToButtonAliasEvent(buttonType, true, setEventHandler);
         controllerEvents.UnsubscribeToButtonAliasEvent(buttonType, false, resetEventHandler);
     }
 }
    // Use this for initialization
    void Start()
    {
        ControllerInteractionEventHandler touchpadPressed = new ControllerInteractionEventHandler(DoTouchpadPressed);

        var controllerEvent = GameObject.FindObjectOfType <VRTK_ControllerEvents>();

        menuHandler = GameObject.FindObjectOfType <MenuManager>();
        controllerEvent.TouchpadPressed += touchpadPressed;
    }
Esempio n. 9
0
 private void Awake()
 {
     touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
     touchpadUntouched   = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);
     playArea            = VRTK_DeviceFinder.PlayAreaTransform();
     controllerLeftHand  = VRTK_DeviceFinder.GetControllerLeftHand();
     controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand();
     if (!playArea)
     {
         Debug.LogError("No play area could be found. Have you selected a valid Boundaries SDK in the SDK Manager? If you are unsure, then click the GameObject with the `VRTK_SDKManager` script attached to it in Edit Mode and select a Boundaries SDK from the dropdown.");
     }
 }
Esempio n. 10
0
    public void OnEvent(StartInteractionConceptEvent e)
    {
        if (e.newConcept == InteractionConcept.Selection)
        {
            VRTK_ControllerEvents rightController = VRTK.VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>();

            startIdle          = new ControllerInteractionEventHandler(StartIdle);
            selectionConfirmed = new ControllerInteractionEventHandler(SelectionConfirmed);
            rightController.TriggerTouchEnd += startIdle;
            rightController.TouchpadPressed += selectionConfirmed;
        }
    }
Esempio n. 11
0
    public void OnEvent(StartInteractionConceptEvent e)
    {
        if (e.newConcept == InteractionConcept.ReadyForCalibration)
        {
            VRTK_ControllerEvents leftController  = VRTK.VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>();
            VRTK_ControllerEvents rightController = VRTK.VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>();

            startCalibration             = new ControllerInteractionEventHandler(StartCalibration);
            leftController.GripPressed  += startCalibration;
            rightController.GripPressed += startCalibration;
        }
    }
Esempio n. 12
0
        protected virtual void Awake()
        {
            touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
            touchpadUntouched   = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);
            playArea            = VRTK_DeviceFinder.PlayAreaTransform();
            controllerLeftHand  = VRTK_DeviceFinder.GetControllerLeftHand();
            controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand();
            if (!playArea)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "PlayArea", "Boundaries SDK"));
            }

            VRTK_PlayerObject.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.CameraRig);
        }
Esempio n. 13
0
        private void Awake()
        {
            if (this.GetComponent<VRTK_PlayerPresence>())
            {
                playerPresence = this.GetComponent<VRTK_PlayerPresence>();
            }
            else
            {
                Debug.LogError("The VRTK_TouchpadWalking script requires the VRTK_PlayerPresence script to be attached to the [CameraRig]");
            }

            touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
            touchpadUntouched = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);

            controllerManager = this.GetComponent<SteamVR_ControllerManager>();
        }
        private void Awake()
        {
            if (this.GetComponent <VRTK_PlayerPresence>())
            {
                playerPresence = this.GetComponent <VRTK_PlayerPresence>();
            }
            else
            {
                Debug.LogError("The VRTK_TouchpadWalking script requires the VRTK_PlayerPresence script to be attached to the [CameraRig]");
            }

            touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
            touchpadUntouched   = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);

            controllerManager = this.GetComponent <SteamVR_ControllerManager>();
        }
Esempio n. 15
0
    public void OnEvent(StartInteractionConceptEvent e)
    {
        if (e.newConcept == InteractionConcept.Idle)
        {
            VRTK_ControllerEvents leftController  = VRTK.VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>();
            VRTK_ControllerEvents rightController = VRTK.VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>();

            startScaleRotate = new ControllerInteractionEventHandler(StartScaleRotate);
            leftController.TriggerTouchStart += startScaleRotate;


            startSelectNavigate = new ControllerInteractionEventHandler(StartSelectNavigate);
            rightController.TriggerTouchStart += startSelectNavigate;

            Hint.Display("BuildingSelectionTriggerHint");
            Hint.Display("ScaleTranslateTriggerHint");
        }
    }
Esempio n. 16
0
        private void Awake()
        {
            if (GetComponent <VRTK_PlayerPresence>())
            {
                playerPresence = GetComponent <VRTK_PlayerPresence>();
            }
            else
            {
                Debug.LogError("The VRTK_TouchpadWalking script requires the VRTK_PlayerPresence script to be attached to the CameraRig");
                return;
            }

            touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
            touchpadUntouched   = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);

            controllerLeftHand  = VRTK_SDK_Bridge.GetControllerLeftHand();
            controllerRightHand = VRTK_SDK_Bridge.GetControllerRightHand();
        }
Esempio n. 17
0
    public void OnEvent(StartInteractionConceptEvent e)
    {
        if (e.newConcept == InteractionConcept.ScaleRotate)
        {
            VRTK_ControllerEvents leftController = VRTK.VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>();

            showScaleRotateMenu = new ControllerInteractionEventHandler(UpdateScaleRotateMenu);
            leftController.TriggerAxisChanged += showScaleRotateMenu;

            startIdle = new ControllerInteractionEventHandler(StartIdle);
            leftController.TriggerTouchEnd += startIdle;

            // set inital animation progress and show menu
            scaleRotateMenu.SetActive(true);
            scaleRotateMenu.gameObject.GetComponent <ScaleAnimator>().SetAnimationProgress(leftController.GetTriggerAxis());

            Hint.Display("HowToScaleTranslate1Hint");
            Hint.Display("HowToScaleTranslate2Hint");
        }
    }
Esempio n. 18
0
        protected virtual void OnEnable()
        {
            touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
            touchpadUntouched   = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);
            playArea            = VRTK_DeviceFinder.PlayAreaTransform();
            controllerLeftHand  = VRTK_DeviceFinder.GetControllerLeftHand();
            controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand();
            if (!playArea)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "PlayArea", "Boundaries SDK"));
            }

            VRTK_PlayerObject.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.CameraRig);

            SetControllerListeners(controllerLeftHand, leftController, ref leftSubscribed);
            SetControllerListeners(controllerRightHand, rightController, ref rightSubscribed);
            bodyPhysics   = GetComponent <VRTK_BodyPhysics>();
            movementSpeed = 0f;
            strafeSpeed   = 0f;
            multiplySpeed = false;
        }
Esempio n. 19
0
        protected virtual void OnEnable()
        {
            touchpadAxisChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
            touchpadUntouched   = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);

            controllerLeftHand  = VRTK_DeviceFinder.GetControllerLeftHand();
            controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand();

            playArea = VRTK_DeviceFinder.PlayAreaTransform();
            if (!playArea)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "PlayArea", "Boundaries SDK"));
            }

            headset = VRTK_DeviceFinder.HeadsetTransform();
            if (!headset)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "HeadsetTransform", "Headset SDK"));
            }

            VRTK_PlayerObject.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.CameraRig);

            SetControllerListeners(controllerLeftHand, leftController, ref leftSubscribed);
            SetControllerListeners(controllerRightHand, rightController, ref rightSubscribed);
            bodyPhysics = GetComponent <VRTK_BodyPhysics>();

            movementSpeed    = 0f;
            strafeSpeed      = 0f;
            blinkFadeInTime  = 0f;
            lastWarp         = 0f;
            lastFlip         = 0f;
            lastSnapRotate   = 0f;
            multiplyMovement = false;

            bodyCollider = playArea.GetComponentInChildren <CapsuleCollider>();
            if (!bodyCollider)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_FROM_GAMEOBJECT, "VRTK_TouchpadMovement", "CapsuleCollider", "the PlayArea"));
            }
        }
Esempio n. 20
0
        protected virtual void SetDirectionListener(bool state, VRTK_ControllerEvents.ButtonAlias directionButton, ref VRTK_ControllerEvents.ButtonAlias subscribedDirectionButton, ControllerInteractionEventHandler pressCallback, ControllerInteractionEventHandler releaseCallback)
        {
            if (controllerEvents)
            {
                if (subscribedDirectionButton != VRTK_ControllerEvents.ButtonAlias.Undefined && (!state || directionButton == VRTK_ControllerEvents.ButtonAlias.Undefined || directionButton != subscribedDirectionButton))
                {
                    controllerEvents.UnsubscribeToButtonAliasEvent(subscribedDirectionButton, true, pressCallback);
                    controllerEvents.UnsubscribeToButtonAliasEvent(subscribedDirectionButton, false, releaseCallback);
                    subscribedDirectionButton = VRTK_ControllerEvents.ButtonAlias.Undefined;
                }

                if (state && directionButton != VRTK_ControllerEvents.ButtonAlias.Undefined && directionButton != subscribedDirectionButton)
                {
                    controllerEvents.SubscribeToButtonAliasEvent(directionButton, true, pressCallback);
                    controllerEvents.SubscribeToButtonAliasEvent(directionButton, false, releaseCallback);
                    subscribedDirectionButton = directionButton;
                }
            }
        }
Esempio n. 21
0
 // Use this for initialization
 void Start()
 {
     touchStart   = new ControllerInteractionEventHandler(DoTouchpadTouchStart);
     touchChanged = new ControllerInteractionEventHandler(DoTouchpadAxisChanged);
     touchEnd     = new ControllerInteractionEventHandler(DoTouchpadTouchEnd);
 }
Esempio n. 22
0
 /// <summary>
 ///  Trigger Button Press Event UnBind
 /// </summary>
 /// <param name="eventHandler"></param>
 public void TriggerPressEventUnBind(ControllerInteractionEventHandler eventHandler)
 {
     GetComponent <VRTK_ControllerEvents>().TriggerPressed -= eventHandler;
 }
Esempio n. 23
0
 /// <summary>
 /// Trigger Button Release Event Bind
 /// </summary>
 public void TriggerReleaseEventBind(ControllerInteractionEventHandler eventHandler)
 {
     GetComponent <VRTK_ControllerEvents>().TriggerReleased += eventHandler;
 }
Esempio n. 24
0
        protected virtual void ManageActivationListener(bool state, ref VRTK_ControllerEvents.ButtonAlias activationButton, ref VRTK_ControllerEvents.ButtonAlias subscribedActivationButton, ControllerInteractionEventHandler buttonPressedCallback, ControllerInteractionEventHandler buttonReleasedCallback)
        {
            if (subscribedActivationButton == VRTK_ControllerEvents.ButtonAlias.Undefined && (!state || activationButton != subscribedActivationButton))
            {
                if (leftControllerEvents != null)
                {
                    leftControllerEvents.UnsubscribeToButtonAliasEvent(subscribedActivationButton, true, buttonPressedCallback);
                    leftControllerEvents.UnsubscribeToButtonAliasEvent(subscribedActivationButton, false, buttonReleasedCallback);
                    leftControllerEvents.ControllerModelAvailable -= ControllerModelAvailable;
                }
                if (rightControllerEvents != null)
                {
                    rightControllerEvents.UnsubscribeToButtonAliasEvent(subscribedActivationButton, true, buttonPressedCallback);
                    rightControllerEvents.UnsubscribeToButtonAliasEvent(subscribedActivationButton, false, buttonReleasedCallback);
                    rightControllerEvents.ControllerModelAvailable -= ControllerModelAvailable;
                }
                subscribedActivationButton = VRTK_ControllerEvents.ButtonAlias.Undefined;
            }

            if (state && subscribedActivationButton == VRTK_ControllerEvents.ButtonAlias.Undefined && activationButton != VRTK_ControllerEvents.ButtonAlias.Undefined)
            {
                bool subscribed = false;
                if (leftControllerEvents != null)
                {
                    leftControllerEvents.SubscribeToButtonAliasEvent(activationButton, true, buttonPressedCallback);
                    leftControllerEvents.SubscribeToButtonAliasEvent(activationButton, false, buttonReleasedCallback);
                    leftControllerEvents.ControllerModelAvailable += ControllerModelAvailable;
                    subscribed = true;
                }

                if (rightControllerEvents != null)
                {
                    rightControllerEvents.SubscribeToButtonAliasEvent(activationButton, true, buttonPressedCallback);
                    rightControllerEvents.SubscribeToButtonAliasEvent(activationButton, false, buttonReleasedCallback);
                    rightControllerEvents.ControllerModelAvailable += ControllerModelAvailable;
                    subscribed = true;
                }

                if (subscribed)
                {
                    subscribedActivationButton = activationButton;
                }
            }
        }
 private void OnDisable()
 {
     engageButtonPressed -= DoTouchpadDown;
     engageButtonUp      -= DoTouchpadUp;
 }
 private void OnEnable()
 {
     engageButtonPressed += DoTouchpadDown;
     engageButtonUp      += DoTouchpadUp;
 }
Esempio n. 27
0
 /// <summary>
 /// Touchpad Button Press Event Bind
 /// </summary>
 public void TouchpadPressedEventBind(ControllerInteractionEventHandler eventHandler)
 {
     GetComponent <VRTK_ControllerEvents>().TouchpadPressed += eventHandler;
 }
Esempio n. 28
0
 protected virtual void UnsubscribeButtonAxisEvent(SDK_BaseController.ButtonTypes buttonType, VRTK_ControllerEvents.AxisType axisType, ControllerInteractionEventHandler eventHandler)
 {
     controllerEvents.UnsubscribeToAxisAliasEvent(buttonType, axisType, eventHandler);
 }
Esempio n. 29
0
 protected virtual void SubscribeButtonEvent(VRTK_ControllerEvents.ButtonAlias buttonType, ref VRTK_ControllerEvents.ButtonAlias saveType, ControllerInteractionEventHandler eventHandler)
 {
     if (buttonType != VRTK_ControllerEvents.ButtonAlias.Undefined)
     {
         saveType = buttonType;
         controllerEvents.SubscribeToButtonAliasEvent(buttonType, true, eventHandler);
         controllerEvents.SubscribeToButtonAliasEvent(buttonType, false, eventHandler);
     }
 }
Esempio n. 30
0
 /// <summary>
 ///  Touchpad Button Release Event UnBind
 /// </summary>
 /// <param name="eventHandler"></param>
 public void TouchpadReleaseEventUnBind(ControllerInteractionEventHandler eventHandler)
 {
     GetComponent <VRTK_ControllerEvents>().TouchpadReleased -= eventHandler;
 }
Esempio n. 31
0
 public virtual void SubscribeMenuButton(ControllerInteractionEventHandler cieh)
 {
     controllers[0].GetComponent <VRTK_ControllerEvents>().SubscribeToButtonAliasEvent(VRTK_ControllerEvents.ButtonAlias.ButtonTwoPress, false, cieh);
     controllers[1].GetComponent <VRTK_ControllerEvents>().SubscribeToButtonAliasEvent(VRTK_ControllerEvents.ButtonAlias.ButtonTwoPress, false, cieh);
 }
Esempio n. 32
0
 /// <summary>
 /// ButtonOne Button Release Event UnBind
 /// </summary>
 public void ButtonOnePressEventUnBind(ControllerInteractionEventHandler eventHandler)
 {
     GetComponent <VRTK_ControllerEvents>().ButtonOnePressed -= eventHandler;
 }