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.GetTouchDown(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); } }
void Update() { controller = SteamVR_Controller.Input((int)trackedobject.index); //Single Shot if (controller.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger) && playerEquipSystem.gunonlefthand == true) { Shoot(); //controller.TriggerHapticPulse (500); } if (controller.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger) && playerEquipSystem.gunonrighthand == true) { Shoot(); } //Burst Shot /*if (trackcontroller.triggerPressed)) * { * Shoot (); * } */ else { isshooting = false; } }
// Update is called once per frame void Update() { // Reset trigger touches leftTriggerTouch = false; rightTriggerTouch = false; leftPadTouch = false; rightPadTouch = false; SteamVR_Controller.Device deviceLeft = null; SteamVR_Controller.Device deviceRight = null; try { deviceLeft = SteamVR_Controller.Input((int)LeftControllerTrackedObj.index); deviceRight = SteamVR_Controller.Input((int)RightControllerTrackedObj.index); } catch (System.IndexOutOfRangeException) { // Not sure what to do with this yet, only happens on first update //Debug.Log("IndexOutOfRangeException"); return; } //if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger)) { // Debug.Log("Holding 'Touch' on Trigger"); //} if (deviceLeft.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger)) { Debug.Log("Did 'TouchDown' on left Trigger"); leftTriggerTouch = true; } if (deviceRight.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger)) { Debug.Log("Did 'TouchDown' on right Trigger"); rightTriggerTouch = true; } if (deviceLeft.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad)) { Debug.Log("Did 'TouchDown' on left Touchpad"); leftPadTouch = true; } if (deviceRight.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad)) { Debug.Log("Did 'TouchDown' on right Touchpad"); rightPadTouch = true; } if (deviceLeft.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { Debug.Log("Did 'PressDown' on left Touchpad"); } if (deviceRight.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { Debug.Log("Did 'PressDown' on right Touchpad"); } }
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 RecallPreviousGrabbedObject() { if (previousGrabbedObject != null && device.GetTouchDown(SteamVR_Controller.ButtonMask.ApplicationMenu)) { previousGrabbedObject.transform.position = controllerAttachPoint.transform.position; previousGrabbedObject.transform.rotation = controllerAttachPoint.transform.rotation; var rb = previousGrabbedObject.GetComponent <Rigidbody>(); rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; rb.maxAngularVelocity = 0f; } }
void Update() { if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger)) { Debug.Log("按下了扳机!"); } if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Axis0)) { Debug.Log("按下了AXIS0!"); } if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Axis1)) { Debug.Log("按下了AXIS1!"); } }
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); } } }
void Update() { controller = SteamVR_Controller.Input((int)trackedObj.index); // right hand functions if (controller.GetTouch(SteamVR_Controller.ButtonMask.Touchpad)) { Debug.Log("right touched!"); } // setting initial touch position for swiping if (controller.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad)) { touchLast = controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x; } // activate/deactivate objectMenu on touchpad press if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad)) { Debug.Log("right tp pressed down!"); objectMenu.SetActive(!objectMenu.activeSelf); } // if objectMenu is active and player is touching touchpad, // rotate the objectMenu based on swiping left/right on touchpad. if (objectMenu.activeSelf && controller.GetTouch(SteamVR_Controller.ButtonMask.Touchpad)) { touchCurrent = controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x; distance = touchCurrent - touchLast; touchLast = touchCurrent; objectMenu.transform.Rotate(Vector3.forward * distance * swipeSpeed); } }
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); } }
// 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"); } }
// 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(); } }
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; } }
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"); } }
void Update() { device1 = SteamVR_Controller.Input((int)controller1.index); device2 = SteamVR_Controller.Input((int)controller2.index); if (device2.GetTouch(SteamVR_Controller.ButtonMask.Touchpad)) { Vector3 move = controller2.transform.forward; move = new Vector3(move.x * device2.GetAxis().y, 0f, move.z * device2.GetAxis().y); Vector3 move2 = controller2.transform.right; move2 = new Vector3(move2.x * device2.GetAxis().x, 0f, move2.z * device2.GetAxis().x); _rb.MovePosition(transform.position + ((move + move2) / 2) * speed * Time.deltaTime); } if (device1.GetTouchDown(SteamVR_Controller.ButtonMask.Grip)) { if (!_OnHand) { _OnHand = Instantiate(pistol, controller1.transform.position, controller1.transform.rotation) as GameObject; _OnHand.transform.SetParent(controller1.transform); } } if (device1.GetPressDown(SteamVR_Controller.ButtonMask.Trigger)) { if (_OnHand) { _OnHand.GetComponent <PistolScript>().Shoot(); } } }
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; } }
// Update is called once per frame void Update() { Ray ray = new Ray(GunPoint.position, GunPoint.forward); Line.SetPosition(0, ray.origin); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100)) { RayPoint.SetActive(true); RayPoint.transform.position = hit.point; Line.SetPosition(1, hit.point); if (hit.transform.tag == "Cube") { SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObj.index); if (device.GetTouchDown((SteamVR_Controller.ButtonMask.Trigger))) { hit.transform.GetComponent <Rigidbody>().AddForce(ray.direction * 8000); } } } else { RayPoint.SetActive(false); Line.SetPosition(1, ray.direction * 100); } }
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)) { //Debug.LogError("Yip it works!"); GameObject go = new GameObject(); go.AddComponent <MeshFilter>(); go.AddComponent <MeshRenderer>(); currLine = go.AddComponent <PropperLineRenderer>(); currLine.SetWidth(.1f); numClicks = 0; } else if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger)) { //currLine.SetVertexCount(numClicks + 1); //currLine.SetPosition(numClicks, trackedObj.transform.position); currLine.AddPoint(trackedObj.transform.position); numClicks++; } }
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); } }
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; } }
// 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; } } }
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; } } }
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; } }
// 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 } }
// 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); } }
// 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)) { //Debug.LogError("Got here."); GameObject go = new GameObject(); go.transform.SetParent(parentObject.transform); curLine = go.AddComponent <LineRenderer>(); curLine.material = newMat; curLine.material.color = cm.color; curLine.SetWidth(lineThickness, lineThickness); curLine.useWorldSpace = false; numClicks = 0; } else if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger)) { curLine.positionCount = numClicks + 1; curLine.SetPosition(numClicks, trackedObj.transform.position); numClicks++; } //DISABLE ANY LINE THAT COLLIDES WITH THE CONTROLLER IF THE APP MENU BUTTON IS HELD if (device.GetTouch(SteamVR_Controller.ButtonMask.ApplicationMenu)) { //need to add colliders and tags to the lines as they're generated. } }
// 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); } }
/// <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(); } }
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); } }
// Change in Unity: Edit -> Project Settings -> Time -> Fixed Timestep -> 1/90fps void FixedUpdate() { dev = SteamVR_Controller.Input((int)trackedObj.index); if (dev.GetTouch(SteamVR_Controller.ButtonMask.Trigger)) { Debug.Log("You are holding down the trigger"); } if (dev.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger)) { Debug.Log("TouchDown the trigger"); } if (dev.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger)) { Debug.Log("TouchUp the trigger"); } if (dev.GetPressUp(SteamVR_Controller.ButtonMask.Trigger)) { Debug.Log("PressUp the trigger"); } if (dev.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad)) { Debug.Log("PressUp the touchpad"); Debug.Log("Reset sphere position and velocity..."); sphere.transform.position = Vector3.zero; sphere.GetComponent <Rigidbody>().velocity = Vector3.zero; sphere.GetComponent <Rigidbody>().angularVelocity = Vector3.zero; } }
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); }
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; } } }