GetTouchUp() public method

public GetTouchUp ( EVRButtonId buttonId ) : bool
buttonId EVRButtonId
return bool
Ejemplo n.º 1
0
    //Runs every frame and handles the animation for the controllers when certain buttons are pressed.

    void Update()
    {
        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            SetAnimation("Grab", false, true);
        }
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            SetAnimation("Grab", true, false);
        }
        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            SetAnimation("Pinch", false, true);
        }
        if (device.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            SetAnimation("Pinch", true, false);
        }

        if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))
        {
            Debug.Log("you touched the touchpad");
            if (pointer != null)
            {
                pointer.SetActive(true);
            }
        }
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
        {
            if (pointer != null)
            {
                pointer.SetActive(false);
            }
        }
    }
Ejemplo n.º 2
0
    void FixedUpdate()
    {
        if (!preGrab && !grabbing)
        {
            RegulationController();
        }

        if (preGrab)
        {
            if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                preGrab  = false;
                grabbing = false;
            }
            PreGrabController();
        }

        if (grabbing)
        {
            if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                preGrab  = false;
                grabbing = false;
            }
            GrabbingController();
        }
    }
Ejemplo n.º 3
0
    void OnTriggerStay(Collider col)
    {
        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger) && !hold)
        {
            if ("Interactable".Equals(col.gameObject.tag))
            {
                col.attachedRigidbody.isKinematic = true;
                col.gameObject.transform.SetParent(this.gameObject.transform);
            }
        }
        else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger) && !hold)
        {
            if ("Interactable".Equals(col.gameObject.tag))
            {
                hold = true;
            }
        }
        else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger) && hold)
        {
            col.gameObject.transform.SetParent(null);
            col.attachedRigidbody.isKinematic = false;

            tossObject(col.attachedRigidbody);

            hold = false;
        }
    }
Ejemplo n.º 4
0
    private void Update()
    {
        //var device = SteamVR_Controller.Input((int) trackedObj.index);

        resetButtons();
        checkTriggerVal();
        checkPadDir();

        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            triggerPressed = true;
            triggerDown    = true;
            startPos       = transform.position;
        }
        else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            triggerPressed = false;
            triggerUp      = true;
            endPos         = transform.position;
        }

        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
        {
            padPressed = true;
            padDown    = true;
        }
        else if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
        {
            padPressed = false;
            padUp      = true;
        }

        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Grip))
        {
            gripped  = true;
            gripDown = true;
        }
        else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Grip))
        {
            gripped = false;
            gripUp  = true;
        }

        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
        {
            menuPressed = true;
            menuDown    = true;
        }
        else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.ApplicationMenu))
        {
            menuPressed = false;
            menuUp      = true;
        }
    }
    void Update()
    {
        device = SteamVR_Controller.Input((int)trackedObject.index);
        if (isLeftHanded)
        {
            if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))
            {
                laser.gameObject.SetActive(true);
                laser.SetPosition(0, gameObject.transform.position);
                RaycastHit hit;

                if (Physics.Raycast(transform.position, transform.forward, out hit, 10, laserMask))
                {
                    teleportAimer.SetActive(true);
                    teleportLocation = hit.point;
                    laser.SetPosition(1, teleportLocation);
                    teleportAimer.transform.position = new Vector3(teleportLocation.x, teleportLocation.y + yNudge, teleportLocation.z);
                }
            }

            if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                laser.gameObject.SetActive(false);
                teleportAimer.SetActive(false);
                Player.transform.position = teleportLocation;
            }
        }
        else
        {
            if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))
            {
                laser.gameObject.SetActive(true);
                laser.SetPosition(0, gameObject.transform.position);
                RaycastHit hit;

                if (Physics.Raycast(transform.position, transform.forward, out hit, 10, laserMask))
                {
                    teleportLocation = hit.point;
                    laser.SetPosition(1, teleportLocation);

                    float zSize = hit.point.z - laser.GetPosition(0).z + 0.5f;
                    laser.GetComponent <BoxCollider> ().size   = new Vector3(0, 0, zSize);
                    laser.GetComponent <BoxCollider> ().center = new Vector3(0, 0, zSize / 2);
                }
            }
            if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                laser.gameObject.SetActive(false);
            }
        }
    }
    void OnTriggerStay(Collider col)
    {
        Debug.Log("You have collided with " + col.name + " and activated OnTriggerStay");
        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You have collided with " + col.name + " while holding down Touch");
            col.attachedRigidbody.isKinematic = true;
            col.gameObject.transform.SetParent(gameObject.transform);

            PickUpableObject tempPickUpObject;
            tempPickUpObject            = col.GetComponent <PickUpableObject>();
            tempPickUpObject.b_PickedUp = true;
        }
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You have released Touch while colliding with " + col.name);
            col.gameObject.transform.SetParent(null);
            col.attachedRigidbody.isKinematic = false;

            tossObject(col.attachedRigidbody);

            PickUpableObject tempPickUpObject;
            tempPickUpObject            = col.GetComponent <PickUpableObject>();
            tempPickUpObject.b_PickedUp = false;
        }
    }
Ejemplo n.º 7
0
 void OnTriggerStay(Collider col)
 {
     if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
     {
         Object.Destroy(fixedJoint);
         fixedJoint = null;
         col.gameObject.transform.position = new Vector3(0, .2F, -1);
         col.gameObject.GetComponent <Rigidbody>().velocity        = Vector3.zero;
         col.gameObject.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
     }
     if (fixedJoint == null && device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
     {
         fixedJoint           = col.gameObject.AddComponent <FixedJoint>();
         rigidBodyAttachPoint = this.gameObject.GetComponent <Rigidbody>();
         //added the above myself, dont need because its public so we will pull it in
         //would be better for just any general rigidbody instead of having to fix one
         fixedJoint.connectedBody = rigidBodyAttachPoint;
     }
     else if (fixedJoint != null && device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
     {
         GameObject go        = fixedJoint.gameObject;
         Rigidbody  rigidBody = go.GetComponent <Rigidbody>();
         Object.Destroy(fixedJoint);
         fixedJoint = null;
         tossObject(col.attachedRigidbody);
     }
     else if (fixedJoint != null && device.GetTouch(SteamVR_Controller.ButtonMask.Trigger) != true)
     {
         GameObject go        = fixedJoint.gameObject;
         Rigidbody  rigidBody = go.GetComponent <Rigidbody>();
         Object.Destroy(fixedJoint);
         fixedJoint = null;
         tossObject(col.attachedRigidbody);
     }
 }
Ejemplo n.º 8
0
 // Update is called once per frame
 void Update()
 {
     device = SteamVR_Controller.Input((int)controller.index);
     if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
     {
         if (heldObject == null)
         {
             Collider[] inRange = Physics.OverlapSphere(transform.position, radius);
             int        i       = 0;
             while (i < inRange.Length)
             {
                 //if(inRange[i].GetComponent<Rigidbody>() != null) {
                 inRange[i].SendMessage("GetPickedUp", transform);
                 heldObject = inRange[i].gameObject;
                 //}
                 i++;
             }
         }
     }
     if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
     {
         if (heldObject != null)
         {
             heldObject.SendMessage("GetReleased");
             heldObject = null;
         }
     }
 }
Ejemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObj.index);
        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger) && BrushManager.canpaint == true)
        {
            GameObject go = new GameObject();
            go.AddComponent <MeshFilter> ();
            go.AddComponent <MeshRenderer> ();
            currLine = go.AddComponent <MeshLineRenderer> ();

            currLine.setWidth(BrushManager.cursorsize);
            currLine.lmat = new Material(matter);
        }
        else if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger) && BrushManager.canpaint == true)
        {
            //	currLine.setVertexCount(numClicks +1);
            currLine.setWidth(BrushManager.cursorsize);
            currLine.AddPoint(trackedObj.transform.position);
            numClicks++;
        }
        else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            //	currLine.setVertexCount(numClicks +1);
            UndoManager.GetComponent <UndoManager>().strokes.Add(currLine.gameObject);
            numClicks = 0;
            currLine.transform.SetParent(meshparent);
            currLine = null;
        }

        if (currLine != null)
        {
            currLine.lmat.color = ColorManager.Instance.GetCurrentColor();
        }
    }
Ejemplo n.º 10
0
    // Update is called once per frame
    void FixedUpdate()
    {
        device = SteamVR_Controller.Input((int)trackedObj.index);
        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are holding down");
        }
        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are holding");
        }
        //release trigger
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are holding up");
        }

        if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are pressing");
        }
        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are pressing down");
        }
        //release trigger
        if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are pressing up");
        }
    }
Ejemplo n.º 11
0
 // Update is called once per frame
 void FixedUpdate()
 {
     device = SteamVR_Controller.Input((int)trackedObj.index);
     if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You are holding 'Touch' on the Trigger'");
     }
     if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have activated TouchDown");
     }
     if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have activated TouchUp");
     }
     if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You are holding 'Press' on the Trigger'");
     }
     if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have activated PressDown");
     }
     if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have activated PressUp");
     }
     if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
     {
         Debug.Log("You have activated PressUp on the Touchpad");
         sphere.transform.position = new Vector3(0, 0, 0);
     }
 }
Ejemplo n.º 12
0
    void FixedUpdate()
    {
        SteamVR_Controller.Device device = SteamVR_Controller.Input((int)rightController.index);

        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            dragging = false;
            Ray ray = new Ray(rightController.transform.position, rightController.transform.forward);
            //var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (GetComponent <Collider>().Raycast(ray, out hit, 100))
            {
                dragging = true;
                ColorManager.Instance.cloudLabel = GetComponent <Collider>().gameObject.name;
                thumb.position = GetComponent <Collider>().gameObject.transform.position;
            }
        }
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            dragging = false;
        }
        if (dragging && device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            Ray ray = new Ray(rightController.transform.position, rightController.transform.forward);
            //var point = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            RaycastHit hit;
            if (GetComponent <Collider>().Raycast(ray, out hit, 100))
            {
                ColorManager.Instance.cloudLabel = GetComponent <Collider>().gameObject.name;
                thumb.position = GetComponent <Collider>().gameObject.transform.position;
            }
        }
    }
Ejemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        mdevice = SteamVR_Controller.Input((int)mtrackedobj.index);

        // Jump
        if (mdevice.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            if (grounded)
            {
                rigidbody.AddForce(transform.up * jumpForce);
            }
        }

        // Grounded check
        Ray        ray = new Ray(transform.position, -transform.up);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 1 + .1f, groundedMask))
        {
            grounded = true;
        }
        else
        {
            grounded = false;
        }
    }
Ejemplo n.º 14
0
    void OnTriggerStay(Collider col)
    {
        //checks to see if you are already holding an item
        if (isHolding == false)
        {
            //Debug.Log("you have collided with" + col.name + "and activated on trigger stay");
            //checks to see if your touching an object
            if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
            {
                Debug.Log("you have collided with" + col.name + "while holding down touch");
                //rigidbody is no longer affected by physics system
                col.attachedRigidbody.isKinematic = true;
                //sets the sphere to this objects transform
                col.gameObject.transform.SetParent(this.gameObject.transform);
                model.GetComponent <MeshRenderer>().enabled = false;
                isHolding = true;
            }
        }

        //checks to see if triger is up
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("you have released touch while colliding with" + col.name);
            //stops object being a child of the controller
            col.gameObject.transform.SetParent(null);
            //sets the rigidbody to be affected by physics sytem
            col.attachedRigidbody.isKinematic = false;
            TossObject(col.attachedRigidbody);
            model.GetComponent <MeshRenderer>().enabled = true;
            isHolding = false;
        }
    }
        protected void Update()
        {
            if (_onPress != null)
            {
                _onPress.Value = Device.GetPress(ButtonMask);
            }
            if (_onTouch != null && Device.GetTouch(ButtonMask))
            {
                _onTouch.Value = Device.GetTouch(ButtonMask);
            }


            if (_onTouchDown != null && Device.GetTouchDown(ButtonMask))
            {
                _onTouchDown.OnNext(Unit.Default);
            }

            if (_onTouchUp != null && Device.GetTouchUp(ButtonMask))
            {
                _onTouchUp.OnNext(Unit.Default);
            }

            if (_onPressDown != null && Device.GetPressDown(ButtonMask))
            {
                _onPressDown.OnNext(Unit.Default);
            }

            if (_onPressUp != null && Device.GetPressUp(ButtonMask))
            {
                _onPressUp.OnNext(Unit.Default);
            }
        }
Ejemplo n.º 16
0
 ButtonState getButtonState(SteamVR_Controller.Device device, EVRButtonId id)
 {
     if (device.GetPressDown(id))
     {
         return(ButtonState.PressDown);
     }
     else if (device.GetPress(id))
     {
         return(ButtonState.Pressed);
     }
     else if (device.GetPressUp(id))
     {
         return(ButtonState.PressUp);
     }
     else if (device.GetTouchDown(id))
     {
         return(ButtonState.TouchDown);
     }
     else if (device.GetTouch(id))
     {
         return(ButtonState.Touched);
     }
     else if (device.GetTouchUp(id))
     {
         return(ButtonState.TouchUp);
     }
     else
     {
         return(ButtonState.Inactive);
     }
 }
Ejemplo n.º 17
0
 int GetTouchButtonInt(SteamVR_Controller.Device device, EVRButtonId id)
 {
     if (device.GetPressDown(id))
     {
         return(1);
     }
     else if (device.GetPress(id))
     {
         return(1);
     }
     else if (device.GetPressUp(id))
     {
         return(1);
     }
     else if (device.GetTouchDown(id))
     {
         return(2);
     }
     else if (device.GetTouch(id))
     {
         return(1);
     }
     else if (device.GetTouchUp(id))
     {
         return(-1);
     }
     else
     {
         return(0);
     }
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Handle the Gaze click button, in the simulator case, the mouse wheel
        /// </summary>
        void CheckGazeInputs()
        {
            // Checking Click event
            if (!InputContainer.GazeIsCliking.Value && _GazeController.GetPressDown(_GazeClick.GazeButtonMask[GazeParameters.GazeButtonOpenVR]))
            {
                InputContainer.GazeIsCliking.SetValue(true);
                InputContainer.GazeClickDown.Raise();
            }
            else if (InputContainer.GazeIsCliking.Value && _GazeController.GetPressUp(_GazeClick.GazeButtonMask[GazeParameters.GazeButtonOpenVR]))
            {
                InputContainer.GazeIsCliking.SetValue(false);
                InputContainer.GazeClickUp.Raise();
            }

            // Checking Touch event
            if (!InputContainer.GazeIsTouching.Value && _GazeController.GetTouchDown(_GazeClick.GazeButtonMask[GazeParameters.GazeButtonOpenVR]))
            {
                InputContainer.GazeIsTouching.SetValue(true);
                InputContainer.GazeStartTouching.Raise();
            }
            else if (InputContainer.GazeIsTouching.Value && _GazeController.GetTouchUp(_GazeClick.GazeButtonMask[GazeParameters.GazeButtonOpenVR]))
            {
                InputContainer.GazeIsTouching.SetValue(false);
                InputContainer.GazeStopTouching.Raise();
            }
        }
Ejemplo n.º 19
0
    void Update()
    {
        _drawRadius = BrushManager.cursorsize * .5f;
        SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObj.index);
        //		if (device.GetTouchDown (SteamVR_Controller.ButtonMask.Trigger) && canpaint == true) {

        //   var detector = _pinchDetectors[i];
        var drawState = _drawStates[0];

        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger) && BrushManager.canpaint == true)
        {
            strokes = drawState.BeginNewLine() as GameObject;
            UndoManager.GetComponent <UndoManager>().strokes.Add(strokes);
            strokes.transform.SetParent(meshparent);
        }

        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger) && BrushManager.canpaint == true)
        {
            drawState.FinishLine();
        }

        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger) && BrushManager.canpaint == true)
        {
            drawState.UpdateLine(con.transform.position);
        }
    }
Ejemplo n.º 20
0
 void FixedUpdate()
 {
     SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObj.index);
     if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
     {
         dragging = false;
         Ray ray = new Ray(trackedObj.transform.position, trackedObj.transform.forward);
         //var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;
         if (GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity))
         {
             dragging = true;
         }
     }
     if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
     {
         dragging = false;
     }
     if (dragging && device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
     {
         Ray        ray = new Ray(trackedObj.transform.position, trackedObj.transform.forward);
         RaycastHit hit;
         if (GetComponent <Collider>().Raycast(ray, out hit, Mathf.Infinity))
         {
             var point = hit.point;
             point = GetComponent <Collider>().ClosestPointOnBounds(point);
             SetThumbPosition(point);
             SendMessage("OnDrag", Vector3.one - (thumb.position - GetComponent <Collider>().bounds.min) / GetComponent <Collider>().bounds.size.x);
         }
     }
 }
Ejemplo n.º 21
0
    private void FixedUpdate()
    {
        this.device = SteamVR_Controller.Input((int)attachedTrackedObject.index);
        if (attachedObjectJoint != null && device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            GameObject objectToUpdate = attachedObjectJoint.gameObject;
            DestroyImmediate(attachedObjectJoint);
            attachedObjectJoint = null;

            Transform origin = (attachedTrackedObject.origin) ? attachedTrackedObject.origin : attachedTrackedObject.transform.parent;

            if (origin != null)
            {
                Vector3 velocity = device.velocity;
                velocity.x *= HorizontalSpeedMagnifier;
                velocity.z *= HorizontalSpeedMagnifier;
                objectToUpdate.GetComponent <Rigidbody>().velocity        = velocity;
                objectToUpdate.GetComponent <Rigidbody>().angularVelocity = origin.TransformVector(device.angularVelocity);
            }
            else
            {
                Vector3 velocity = device.velocity;
                velocity.x *= HorizontalSpeedMagnifier;
                velocity.z *= HorizontalSpeedMagnifier;
                objectToUpdate.GetComponent <Rigidbody>().velocity        = velocity;
                objectToUpdate.GetComponent <Rigidbody>().angularVelocity = device.angularVelocity;
            }

            objectToUpdate.GetComponent <Rigidbody>().maxAngularVelocity = objectToUpdate.GetComponent <Rigidbody>().angularVelocity.magnitude;
        }
    }
Ejemplo n.º 22
0
 private void FixedUpdate()
 {
     SteamVR_Controller.Device device = SteamVR_Controller.Input((int)this.trackedObj.index);
     if (this.joint == null && device.GetTouchDown(8589934592uL))
     {
         GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.prefab);
         gameObject.transform.position = this.attachPoint.transform.position;
         this.joint = gameObject.AddComponent <FixedJoint>();
         this.joint.connectedBody = this.attachPoint;
     }
     else if (this.joint != null && device.GetTouchUp(8589934592uL))
     {
         GameObject gameObject2 = this.joint.gameObject;
         Rigidbody  component   = gameObject2.GetComponent <Rigidbody>();
         UnityEngine.Object.DestroyImmediate(this.joint);
         this.joint = null;
         UnityEngine.Object.Destroy(gameObject2, 15f);
         Transform transform = (!this.trackedObj.origin) ? this.trackedObj.transform.parent : this.trackedObj.origin;
         if (transform != null)
         {
             component.velocity        = transform.TransformVector(device.velocity);
             component.angularVelocity = transform.TransformVector(device.angularVelocity);
         }
         else
         {
             component.velocity        = device.velocity;
             component.angularVelocity = device.angularVelocity;
         }
         component.maxAngularVelocity = component.angularVelocity.magnitude;
     }
 }
Ejemplo n.º 23
0
 void FixedUpdate()
 {
     SteamVR_Controller.Device device = SteamVR_Controller.Input((int)rightController.index);
     if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Grip))
     {
         dragging = false;
         //var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         Ray        ray = new Ray(rightController.transform.position, rightController.transform.forward);
         RaycastHit hit;
         if (GetComponent <Collider>().Raycast(ray, out hit, 100))
         {
             dragging = true;
         }
     }
     if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Grip))
     {
         dragging = false;
     }
     if (dragging && device.GetTouch(SteamVR_Controller.ButtonMask.Grip))
     {
         Ray        ray = new Ray(rightController.transform.position, rightController.transform.forward);
         RaycastHit hit;
         if (GetComponent <Collider> ().Raycast(ray, out hit, 100))
         {
             var point = hit.point;                //Camera.main.ScreenToWorldPoint(Input.mousePosition);
             point = GetComponent <Collider> ().ClosestPointOnBounds(point);
             SetThumbPosition(point);
             SendMessage("OnDrag", Vector3.one - (thumb.localPosition - minBound.localPosition) / GetComponent <BoxCollider> ().size.x);
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObj.index);
        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            // this logic is taken from the MeshLineRenderer script
            GameObject go = new GameObject();
            go.AddComponent <MeshFilter>();
            go.AddComponent <MeshRenderer>();
            currLine = go.AddComponent <MeshLineRenderer>();

            //set the material to use when the trigger is touched
            currLine.lmat = lMat;
        }
        else if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            // currLine.SetVertexCount (numClicks + 1);
            // currLine.SetPosition(numClicks, trackedObj.transform.position);

            currLine.AddPoint(trackedObj.transform.position);
            numClicks++;
        }
        else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger)) //if trigger is held
        {
            numClicks = 0;
            currLine  = null;
        }
        if (currLine != null)                                              //if current line does not equal null
        {
            currLine.lmat.color = ColorManager.Instance.GetCurrentColor(); //current line material color equals color manager's current color
        }
    }
    void FixedUpdate()
    {
        device = SteamVR_Controller.Input ((int)trackedObj.index);

        if (device.GetTouch (SteamVR_Controller.ButtonMask.Trigger)) {
            Debug.Log ("You are holding 'touch' on the trigger");
        }
        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated TouchDown on the trigger");
        }
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated TouchUp on the trigger");
        }

        if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are holding 'press' on the trigger");
        }
        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated PressDown on the trigger");
        }
        if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
        {
            Debug.Log("You activated PressUp on the touchpad");
            sphere.transform.position = Vector3.zero;
            sphere.GetComponent<Rigidbody>().velocity = Vector3.zero;
            sphere.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
        }
    }
Ejemplo n.º 26
0
    void FixedUpdate()
    {
        device = SteamVR_Controller.Input((int)trackedObj.index);

        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("Trigger held");
        }
        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
        {
            touchpadDown = true;
        }

        if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
        {
            touchpadDown = false;
        }

        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            triggerUp = true;
        }
        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            triggerUp = false;
        }
    }
Ejemplo n.º 27
0
        void ManipulateObject(Collider col)
        {
            // Pickup
            if (Device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
            {
                col.attachedRigidbody.isKinematic = true;
                col.gameObject.transform.SetParent(this.gameObject.transform);
                if (col.gameObject.GetComponent <Equipable>())
                {
                    EquippedObject = col.gameObject;
                    Transform equipable = ItemTransforms.GetDefaultTransform(col.name);
                    EquippedObject.transform.localRotation = equipable.rotation;
                    EquippedObject.transform.localPosition = equipable.position;

                    EquippedObject.GetComponent <Equipable>().EquippedByPlayer(Device);
                }
            }

            // Let Go
            else if (Device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                col.gameObject.transform.SetParent(null);
                col.attachedRigidbody.isKinematic = false;

                TossObject(col.attachedRigidbody);
            }
        }
Ejemplo n.º 28
0
        // Token: 0x0600133E RID: 4926 RVA: 0x0006BB3C File Offset: 0x00069D3C
        protected virtual bool IsButtonPressed(uint index, SDK_BaseController.ButtonPressTypes type, ulong button)
        {
            if (index >= 4294967295U)
            {
                return(false);
            }
            SteamVR_Controller.Device device = SteamVR_Controller.Input((int)index);
            switch (type)
            {
            case SDK_BaseController.ButtonPressTypes.Press:
                return(device.GetPress(button));

            case SDK_BaseController.ButtonPressTypes.PressDown:
                return(device.GetPressDown(button));

            case SDK_BaseController.ButtonPressTypes.PressUp:
                return(device.GetPressUp(button));

            case SDK_BaseController.ButtonPressTypes.Touch:
                return(device.GetTouch(button));

            case SDK_BaseController.ButtonPressTypes.TouchDown:
                return(device.GetTouchDown(button));

            case SDK_BaseController.ButtonPressTypes.TouchUp:
                return(device.GetTouchUp(button));

            default:
                return(false);
            }
        }
Ejemplo n.º 29
0
    void FixedUpdate()
    {
        device = SteamVR_Controller.Input((int)trackedObj.index);
        //Touch
        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("you are touching");
        }
        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("you are touching trigger all the way down");
        }
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("you let it up");
        }

        //Press
        if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("you are pressing");
        }
        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            //GetComponent<Animation>().Play("bars");
            Debug.Log("you are pressing trigger all the way down");
        }
        if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("you let press up");
        }
    }
Ejemplo n.º 30
0
 void FixedUpdate()
 {
     device = SteamVR_Controller.Input((int)trackedObj.index);
     if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You are holding touch on the trigger!");
     }
     if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have activated touch down on the trigger!");
     }
     if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have activated touch up on the trigger!");
     }
     if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You are holding press on the trigger!");
     }
     if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have activated press down on the trigger!");
     }
     if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have activated press up on the trigger!");
     }
     if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
     {
         Debug.Log("You have activated press up on the Touchpad!");
         sphere.transform.position = new Vector3(0f, 0f, 0f);
         sphere.GetComponent <Rigidbody>().velocity        = Vector3.zero;
         sphere.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
     }
 }
Ejemplo n.º 31
0
    void Update()
    {
        SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObj.index);
        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            GameObject go = new GameObject();

            go.AddComponent <MeshFilter>();
            go.AddComponent <MeshRenderer>();
            currLine = go.AddComponent <GraphicsLineRenderer>();

            currLine.lmat = new Material(lMat);

            currLine.SetWidth(.1f);
        }
        else if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            currLine.AddPoint(trackedObj.transform.position);
            numClicks++;
        }
        else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            numClicks = 0;
            currLine  = null;
        }

        if (currLine != null)
        {
            currLine.lmat.color = ColorManager.Instance.GetCurrentColor();
        }
    }
        private void Update()
        {
            controllerIndex = (uint)trackedController.index;
            device = SteamVR_Controller.Input((int)controllerIndex);

            Vector2 currentTriggerAxis = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger);
            Vector2 currentTouchpadAxis = device.GetAxis();

            //Trigger
            if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
            {
                OnTriggerPressed(SetButtonEvent(ref triggerPressed, true, currentTriggerAxis.x));
                EmitAlias(ButtonAlias.Trigger, true, currentTriggerAxis.x, ref triggerPressed);
            }
            else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                OnTriggerReleased(SetButtonEvent(ref triggerPressed, false, 0f));
                EmitAlias(ButtonAlias.Trigger, false, 0f, ref triggerPressed);
            }
            else
            {
                if (Vector2ShallowEquals(triggerAxis, currentTriggerAxis))
                {
                    triggerAxisChanged = false;
                }
                else
                {
                    OnTriggerAxisChanged(SetButtonEvent(ref triggerAxisChanged, true, currentTriggerAxis.x));
                }
            }

            //ApplicationMenu
            if (device.GetTouchDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                OnApplicationMenuPressed(SetButtonEvent(ref applicationMenuPressed, true, 1f));
                EmitAlias(ButtonAlias.Application_Menu, true, 1f, ref applicationMenuPressed);
            }
            else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {

                OnApplicationMenuReleased(SetButtonEvent(ref applicationMenuPressed, false, 0f));
                EmitAlias(ButtonAlias.Application_Menu, false, 0f, ref applicationMenuPressed);
            }

            //Grip
            if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Grip))
            {
                OnGripPressed(SetButtonEvent(ref gripPressed, true, 1f));
                EmitAlias(ButtonAlias.Grip, true, 1f, ref gripPressed);
            }
            else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Grip))
            {
                OnGripReleased(SetButtonEvent(ref gripPressed, false, 0f));
                EmitAlias(ButtonAlias.Grip, false, 0f, ref gripPressed);
            }

            //Touchpad Pressed
            if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                OnTouchpadPressed(SetButtonEvent(ref touchpadPressed, true, 1f));
                EmitAlias(ButtonAlias.Touchpad_Press, true, 1f, ref touchpadPressed);
            }
            else if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                OnTouchpadReleased(SetButtonEvent(ref touchpadPressed, false, 0f));
                EmitAlias(ButtonAlias.Touchpad_Press, false, 0f, ref touchpadPressed);
            }

            //Touchpad Touched
            if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                OnTouchpadTouchStart(SetButtonEvent(ref touchpadTouched, true, 1f));
                EmitAlias(ButtonAlias.Touchpad_Touch, true, 1f, ref touchpadTouched);
            }
            else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                OnTouchpadTouchEnd(SetButtonEvent(ref touchpadTouched, false, 0f));
                EmitAlias(ButtonAlias.Touchpad_Touch, false, 0f, ref touchpadTouched);
            }
            else
            {
                if (Vector2ShallowEquals(touchpadAxis, currentTouchpadAxis))
                {
                    touchpadAxisChanged = false;
                }
                else {
                    OnTouchpadAxisChanged(SetButtonEvent(ref touchpadTouched, true, 1f));
                    touchpadAxisChanged = true;
                }
            }

            // Save current touch and trigger settings to detect next change.
            touchpadAxis = new Vector2(currentTouchpadAxis.x, currentTouchpadAxis.y);
            triggerAxis = new Vector2(currentTriggerAxis.x, currentTriggerAxis.y);
        }
Ejemplo n.º 33
0
        public override void OnUpdate()
        {
            var i = -1;
            if ((int)trackedObj.index > i++)
            {
                device = SteamVR_Controller.Input((int)trackedObj.index);
                switch (menuType)
                {
                    case setMenuType.getPress:
                        var padDown = device.GetTouchUp(SteamVR_Controller.ButtonMask.ApplicationMenu);
                        if (padDown)
                        {
                            Fsm.Event(sendEvent);
                        }
                        storeResult.Value = padDown;
                        break;
                    case setMenuType.getPressUp:
                        var padDownUp = device.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu);

                        if (padDownUp)
                        {
                            Fsm.Event(sendEvent);
                        }
                        storeResult.Value = padDownUp;
                        break;
                    case setMenuType.getPressDown:
                        var padDownDown = device.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu);

                        if (padDownDown)
                        {
                            Fsm.Event(sendEvent);
                        }
                        storeResult.Value = padDownDown;
                        break;
                    case setMenuType.getTouch:
                        var padTouch = device.GetTouch(SteamVR_Controller.ButtonMask.ApplicationMenu);

                        if (padTouch)
                        {
                            Fsm.Event(sendEvent);
                        }
                        storeResult.Value = padTouch;
                        break;
                    case setMenuType.getTouchUp:
                        var padTouchUp = device.GetTouchUp(SteamVR_Controller.ButtonMask.ApplicationMenu);

                        if (padTouchUp)
                        {
                            Fsm.Event(sendEvent);
                        }
                        storeResult.Value = padTouchUp;
                        break;
                    case setMenuType.getTouchDown:
                        var padTouchDown = device.GetTouchDown(SteamVR_Controller.ButtonMask.ApplicationMenu);

                        if (padTouchDown)
                        {
                            Fsm.Event(sendEvent);
                        }
                        storeResult.Value = padTouchDown;
                        break;
                }
            }
        }