// Update is called once per frame void Update() { if (!Enabled) { return; } List <string> status = new List <string>(); var controllers = OVRInput.GetConnectedControllers(); foreach (OVRInput.Button input in Enum.GetValues(typeof(OVRInput.Button))) { if (OVRInput.GetDown(input, controllers) || OVRInput.GetUp(input, controllers)) { status.Add(input.ToString() + " (" + (OVRInput.GetDown(input, controllers) ? "Down" : "Up") + ")"); } } foreach (OVRInput.RawButton input in Enum.GetValues(typeof(OVRInput.RawButton))) { if (OVRInput.GetDown(input, controllers) || OVRInput.GetUp(input, controllers)) { status.Add(input.ToString() + " (" + (OVRInput.GetDown(input, controllers) ? "down" : "up") + ")"); } } foreach (OVRInput.Button input in Enum.GetValues(typeof(OVRInput.Button))) { if (OVRInput.Get(input, controllers)) { status.Add(input.ToString() + " (" + OVRInput.Get(input, controllers).ToString() + ")"); } } foreach (OVRInput.RawButton input in Enum.GetValues(typeof(OVRInput.RawButton))) { if (OVRInput.Get(input, controllers)) { status.Add(input.ToString() + " (" + OVRInput.Get(input, controllers).ToString() + ")"); } } foreach (OVRInput.Axis1D input in Enum.GetValues(typeof(OVRInput.Axis1D))) { if (OVRInput.Get(input, controllers) > 0.2) { status.Add(input.ToString() + " (" + OVRInput.Get(input, controllers).ToString() + ")"); } } if (status.Count > 0) { Debug.Log(string.Join(", ", status)); if (TextField != null) { TextField.text = string.Join(", ", status); } } }
//Gear Controller code snippet at end of this Update() function void Update() { string status = "" + "<b>Active: </b>" + OVRInput.GetActiveController() + "\n" + "<b>Connected: </b>" + OVRInput.GetConnectedControllers() + "\n"; status += "Orientation: " + OVRInput.GetLocalControllerRotation(OVRInput.GetActiveController()) + "\n"; status += "AngVel: " + OVRInput.GetLocalControllerAngularVelocity(OVRInput.GetActiveController()) + "\n"; status += "AngAcc: " + OVRInput.GetLocalControllerAngularAcceleration(OVRInput.GetActiveController()) + "\n"; status += "Position: " + OVRInput.GetLocalControllerPosition(OVRInput.GetActiveController()) + "\n"; status += "Vel: " + OVRInput.GetLocalControllerVelocity(OVRInput.GetActiveController()) + "\n"; status += "Acc: " + OVRInput.GetLocalControllerAcceleration(OVRInput.GetActiveController()) + "\n"; status += "PrimaryTouchPad: " + OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad) + "\n"; status += "SecondaryTouchPad: " + OVRInput.Get(OVRInput.Axis2D.SecondaryTouchpad) + "\n"; for (int i = 0; i < monitors.Count; i++) { monitors[i].Update(); status += monitors[i].ToString() + "\n"; } if (uiText != null) { uiText.text = status; } // This queries if the trigger button of the primary hand has just been released if (OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger)) { //if released, shoot projectile shootProjectile(); } }
//private GameObject test; // Use this for initialization void Start() { shapeindicator.SetActive(false); colorsphere.SetActive(false); MODE = "None"; if (inputModule != null) { inputModule.OnSelectionRayHit += RayHitSomething; joyPadClickButton = inputModule.joyPadClickButton; } OVRInput.Controller controller = OVRInput.GetConnectedControllers(); if ((controller & OVRInput.Controller.RTouch) == OVRInput.Controller.RTouch) { activeController = OVRInput.Controller.RTouch; } if ((controller & OVRInput.Controller.LTouch) == OVRInput.Controller.LTouch) { activeController = OVRInput.Controller.LTouch; } if ((controller & OVRInput.Controller.RTrackedRemote) == OVRInput.Controller.RTrackedRemote) { activeController = OVRInput.Controller.RTrackedRemote; } if ((controller & OVRInput.Controller.LTrackedRemote) == OVRInput.Controller.LTrackedRemote) { activeController = OVRInput.Controller.LTrackedRemote; } }
private void Update() { if (OVRInput.GetConnectedControllers() != currentConnectedController) { currentConnectedController = OVRInput.GetConnectedControllers(); if (currentConnectedController.HasFlag(OVRInput.Controller.Hands)) { onHands.Invoke(); } else if (currentConnectedController.HasFlag(OVRInput.Controller.Touch)) { onControllers.Invoke(); } } if (tmpro) { tmpro.text = log + "\n"; if (currentIdp) { tmpro.text += "IDP: " + currentIdp.log; } else { tmpro.text += "IDP: No IDP!"; } } }
/*--------------------------------------------------------------------------------------------*/ protected virtual ControlState GetControllerState(OVRInput.Controller pType) { OVRInput.Controller contTypes = OVRInput.GetConnectedControllers(); bool isValid = ((contTypes & pType) != 0); var state = new ControlState(); state.ControllerType = pType; state.IsValid = isValid; if (!state.IsValid) { return(state); } state.LocalPos = OVRInput.GetLocalControllerPosition(pType); state.LocalRot = OVRInput.GetLocalControllerRotation(pType); state.ThumbstickAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, pType); state.IndexTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, pType); state.HandTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, pType); state.Button1Press = OVRInput.Get(OVRInput.Button.One, pType); state.Button2Press = OVRInput.Get(OVRInput.Button.Two, pType); state.StartPress = OVRInput.Get(OVRInput.Button.Start, pType); state.ThumbstickPress = OVRInput.Get(OVRInput.Button.PrimaryThumbstick, pType); return(state); }
void Awake() { if (inputModule != null) { inputModule.OnSelectionRayHit += RayHitSomething; joyPadClickButton = inputModule.joyPadClickButton; } OVRInput.Controller controller = OVRInput.GetConnectedControllers(); if ((controller & OVRInput.Controller.RTouch) == OVRInput.Controller.RTouch) { activeController = OVRInput.Controller.RTouch; } if ((controller & OVRInput.Controller.LTouch) == OVRInput.Controller.LTouch) { activeController = OVRInput.Controller.LTouch; } if ((controller & OVRInput.Controller.RTrackedRemote) == OVRInput.Controller.RTrackedRemote) { activeController = OVRInput.Controller.RTrackedRemote; } if ((controller & OVRInput.Controller.LTrackedRemote) == OVRInput.Controller.LTrackedRemote) { activeController = OVRInput.Controller.LTrackedRemote; } }
void DetermineActiveController() { OVRInput.Controller controller = OVRInput.GetConnectedControllers(); if ((controller & OVRInput.Controller.RTouch) == OVRInput.Controller.RTouch) { if (OVRInput.Get(triggerButton, OVRInput.Controller.RTouch)) { activeController = OVRInput.Controller.RTouch; return; } } if ((controller & OVRInput.Controller.LTouch) == OVRInput.Controller.LTouch) { if (OVRInput.Get(triggerButton, OVRInput.Controller.LTouch)) { activeController = OVRInput.Controller.LTouch; return; } } if ((controller & activeController) != activeController) { activeController = OVRInput.Controller.None; } if (inputModule != null) { inputModule.activeController = activeController; } }
void Update() { string status = "" + "<b>Active: </b>" + OVRInput.GetActiveController() + "\n" + "<b>Connected: </b>" + OVRInput.GetConnectedControllers() + "\n"; status += "Orientation: " + OVRInput.GetLocalControllerRotation(OVRInput.GetActiveController()) + "\n"; status += "AngVel: " + OVRInput.GetLocalControllerAngularVelocity(OVRInput.GetActiveController()) + "\n"; status += "AngAcc: " + OVRInput.GetLocalControllerAngularAcceleration(OVRInput.GetActiveController()) + "\n"; status += "Position: " + OVRInput.GetLocalControllerPosition(OVRInput.GetActiveController()) + "\n"; status += "Vel: " + OVRInput.GetLocalControllerVelocity(OVRInput.GetActiveController()) + "\n"; status += "Acc: " + OVRInput.GetLocalControllerAcceleration(OVRInput.GetActiveController()) + "\n"; status += "PrimaryTouchPad: " + OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad) + "\n"; status += "SecondaryTouchPad: " + OVRInput.Get(OVRInput.Axis2D.SecondaryTouchpad) + "\n"; for (int i = 0; i < monitors.Count; i++) { monitors[i].Update(); status += monitors[i].ToString() + "\n"; } if (uiText != null) { uiText.text = status; } }
/// <summary> /// Returns if this script is bound to an Oculus Touch controller that is currently not connected. /// For example, if it's a Right Controller but only the left is connected, it returns false. /// If not bound to a controller, returns true. /// </summary> /// <returns></returns> private bool IsConnectedController() { if (!objecttracker) { return(true); //Not attached to a tracker. Return true since it doesn't depend on a controller to be alive. } if (objecttracker.deviceToTrack != ZEDControllerTracker.Devices.LeftController && objecttracker.deviceToTrack != ZEDControllerTracker.Devices.RightController) { return(true); //Not bound to a left or right controller, so let it live. } string connectedcontrollers = OVRInput.GetConnectedControllers().ToString().ToLower(); if (connectedcontrollers == "touch") { return(true); //Both controllers are connected, so } if (objecttracker.deviceToTrack == ZEDControllerTracker.Devices.LeftController && connectedcontrollers == "ltouch") { return(true); //Left controller only. } if (objecttracker.deviceToTrack == ZEDControllerTracker.Devices.RightController && connectedcontrollers == "rtouch") { return(true); //Right controller only. } return(false); }
void FixedUpdate() { OVRInput.FixedUpdate(); grip = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger); controller.SetFloat("Grip", grip); print("" + OVRInput.GetConnectedControllers()); }
protected override void UpdateData() { _controllerDataAsset.Config = Config; var worldToTrackingSpace = CameraRigRef.CameraRig.transform.worldToLocalMatrix; Transform ovrController = _ovrControllerAnchor; _controllerDataAsset.IsDataValid = true; _controllerDataAsset.IsConnected = (OVRInput.GetConnectedControllers() & _ovrController) > 0; if (!_controllerDataAsset.IsConnected) { // revert state fields to their defaults _controllerDataAsset.IsTracked = default; _controllerDataAsset.ButtonUsageMask = default; _controllerDataAsset.RootPoseOrigin = default; return; } _controllerDataAsset.IsTracked = true; // Update button usages _controllerDataAsset.ButtonUsageMask = ControllerButtonUsage.None; OVRInput.Controller controllerMask = _ovrController; foreach (UsageMapping mapping in ControllerUsageMappings) { bool usageActive; if (mapping.IsTouch) { usageActive = OVRInput.Get(mapping.Touch, controllerMask); } else { Assert.IsTrue(mapping.IsButton); usageActive = OVRInput.Get(mapping.Button, controllerMask); } if (usageActive) { _controllerDataAsset.ButtonUsageMask |= mapping.Usage; } } // Update poses // Convert controller pose from world to tracking space. Pose worldRoot = new Pose(ovrController.position, ovrController.rotation); _controllerDataAsset.RootPose.position = worldToTrackingSpace.MultiplyPoint3x4(worldRoot.position); _controllerDataAsset.RootPose.rotation = worldToTrackingSpace.rotation * worldRoot.rotation; _controllerDataAsset.RootPoseOrigin = PoseOrigin.RawTrackedPose; // Convert controller pointer pose from local to tracking space. Pose pointerPose = PoseUtils.Multiply(worldRoot, _pointerPoseSelector.LocalPointerPose); _controllerDataAsset.PointerPose.position = worldToTrackingSpace.MultiplyPoint3x4(pointerPose.position); _controllerDataAsset.PointerPose.rotation = worldToTrackingSpace.rotation * pointerPose.rotation; _controllerDataAsset.PointerPoseOrigin = PoseOrigin.RawTrackedPose; }
void Update() { if (OVRInput.GetConnectedControllers() == OVRInput.Controller.Hands) { hand.handInterface = handTrackingInterface; } else { hand.handInterface = touchControllersInterface; } }
private void checkForController() { OVRInput.Controller currentController = OVRInput.GetConnectedControllers(); // return if no controller found if (currentController == OVRInput.Controller.None) { return; } controllerFound = true; showErrorWindow(false); if (UnityEngine.XR.XRDevice.model == "Oculus Quest") { // make sure both controllers are connected if (((currentController & OVRInput.Controller.LTouch) == OVRInput.Controller.LTouch) && ((currentController & OVRInput.Controller.RTouch) == OVRInput.Controller.RTouch)) { // deactivate both ElectroGrabbers rightHandAnchor.transform.Find("RightControllerAnchor").Find("ElectroGrabber").gameObject.SetActive(false); leftHandAnchor.transform.Find("LeftControllerAnchor").Find("ElectroGrabber").gameObject.SetActive(false); return; } } else { // in this case it's a Go or Gear // hide Quest hands rightHandAnchor.transform.Find("HandRight").gameObject.SetActive(false); leftHandAnchor.transform.Find("HandLeft").gameObject.SetActive(false); OVRInput.Controller activeController = OVRInput.GetActiveController(); if (activeController == OVRInput.Controller.LTrackedRemote) { rightHandAnchor.SetActive(false); leftHandAnchor.SetActive(true); return; } if (activeController == OVRInput.Controller.RTrackedRemote) { leftHandAnchor.SetActive(false); rightHandAnchor.SetActive(true); return; } } // in this case, no Oculus Go remote has been found // show error message controllerFound = false; showErrorWindow(true); return; }
// Update is called once per frame void Update() { transform.position = right_hand.transform.position; Debug.Log("DATA SecondaryHandTrigger " + OVRInput.Get(OVRInput.Axis1D.SecondaryHandTrigger)); Debug.Log("DATA SecondaryThumbstickButton " + OVRInput.GetDown(OVRInput.Button.SecondaryThumbstick)); Debug.Log("DATA SecondaryThumbstick " + OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick).ToString("0.000")); Debug.Log("DATA ButtonTwo " + OVRInput.Get(OVRInput.Button.Two)); Debug.Log("DATA ButtonOne " + OVRInput.Get(OVRInput.Button.One)); Debug.Log("DATA SecondaryIndexTrigger " + OVRInput.Get(OVRInput.Axis1D.SecondaryIndexTrigger)); Debug.Log("DATA RightCoords " + right_hand.transform.position.ToString("0.000")); Debug.Log("DATA LeftCoords " + left_hand.transform.position.ToString("0.000")); Debug.Log("DATA ActiveControllers " + OVRInput.GetConnectedControllers()); }
void DetermineActiveController() { OVRInput.Controller controller = OVRInput.GetConnectedControllers(); if (controller == OVRInput.Controller.LTouch || controller == OVRInput.Controller.LTrackedRemote) { inputModule.rayTransform = leftRayAnchor; } else { inputModule.rayTransform = rightRayAnchor; } }
// Update is called once per frame void Update() { text.text = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad, OVRInput.Controller.RTrackedRemote).ToString() + "\nC=" + OVRInput.GetActiveController().ToString() + "<<" + OVRInput.GetConnectedControllers() + "<<"; Debug.Log("JJJJJJJJJJJJJJ" + text.text + "JJJJJJJJ"); if (birdsEye.isOn) { c1.enabled = true; c2.enabled = false; if (Input.GetKey("up") || OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad, OVRInput.Controller.RTrackedRemote).x < 0) { camera1.transform.Translate(Vector3.forward * Time.deltaTime * 100); } if (Input.GetKey("down")) { camera1.transform.Translate(Vector3.back * Time.deltaTime * 100); } if (Input.GetKey("left")) { camera1.transform.Translate(Vector3.left * Time.deltaTime * 100); } if (Input.GetKey("right")) { camera1.transform.Translate(Vector3.right * Time.deltaTime * 100); } } else { c1.enabled = false; c2.enabled = true; if (Input.GetKey("up") || OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad, OVRInput.Controller.RTrackedRemote).x < 0) { camera2.transform.Translate(Vector3.forward * Time.deltaTime * 100); Debug.Log("hi"); } if (Input.GetKey("down")) { camera2.transform.Translate(Vector3.back * Time.deltaTime * 100); } if (Input.GetKey("left")) { camera2.transform.Rotate(Vector3.down * Time.deltaTime * 100); } if (Input.GetKey("right")) { camera2.transform.Rotate(Vector3.up * Time.deltaTime * 100); } } }
void DetermineActiveController() { OVRInput.Controller controller = OVRInput.GetConnectedControllers(); if ((controller & OVRInput.Controller.RTouch) == OVRInput.Controller.RTouch) { if (OVRInput.Get(joyPadClickButton, OVRInput.Controller.RTouch)) { activeController = OVRInput.Controller.RTouch; return; } } if ((controller & OVRInput.Controller.LTouch) == OVRInput.Controller.LTouch) { if (OVRInput.Get(joyPadClickButton, OVRInput.Controller.LTouch)) { activeController = OVRInput.Controller.LTouch; return; } } if ((controller & OVRInput.Controller.RTrackedRemote) == OVRInput.Controller.RTrackedRemote) { if (OVRInput.Get(joyPadClickButton, OVRInput.Controller.RTrackedRemote)) { activeController = OVRInput.Controller.RTrackedRemote; return; } } if ((controller & OVRInput.Controller.LTrackedRemote) == OVRInput.Controller.LTrackedRemote) { if (OVRInput.Get(joyPadClickButton, OVRInput.Controller.LTrackedRemote)) { activeController = OVRInput.Controller.LTrackedRemote; return; } } if ((controller & activeController) != activeController) { activeController = OVRInput.Controller.None; } if (inputModule != null) { inputModule.activeController = activeController; } }
private void Update() { if (OVRInput.GetConnectedControllers() != currentConnectedController) { currentConnectedController = OVRInput.GetConnectedControllers(); if (currentConnectedController.HasFlag(OVRInput.Controller.Hands)) { onHands.Invoke(); } else if (currentConnectedController.HasFlag(OVRInput.Controller.Touch)) { onControllers.Invoke(); } } }
/// Updates IsTrackedObjectValid and Behavior.transform public void UpdatePosesAndValidity() { // OVRInput.Controller.Touch checks both (LTouch | RTouch) bool bothTouchControllersConnected = (OVRInput.GetConnectedControllers() & OVRInput.Controller.Touch) == OVRInput.Controller.Touch; OVRInput.Controller input = m_ControllerType; IsTrackedObjectValid = OVRInput.GetControllerOrientationTracked(input) || OVRInput.GetControllerPositionTracked(input) && bothTouchControllersConnected; Transform t = Behavior.transform; t.localRotation = OVRInput.GetLocalControllerRotation(input); t.localPosition = OVRInput.GetLocalControllerPosition(input); }
//Updates once per Tick from VRDeviceMonitor (const 0.5 seconds) void IVRDevice.Update() { if (mConnectedControllerMask != OVRInput.GetConnectedControllers()) { // Connected controller mask has changed UpdateConnectedControllers(); } if (mCachedActiveController != OVRInput.GetActiveController()) { // Active controller has changed UpdateInputDevices(); } CheckUsedRenderPipeline(); }
protected override void UpdateData() { _handDataAsset.Config = Config; _handDataAsset.IsDataValid = true; _handDataAsset.IsConnected = (OVRInput.GetConnectedControllers() & _ovrController) > 0; if (_ovrHand != null) { IOVRSkeletonDataProvider skeletonProvider = _ovrHand; SkeletonPoseData poseData = skeletonProvider.GetSkeletonPoseData(); if (poseData.IsDataValid && poseData.RootScale <= 0.0f) { if (_lastHandScale <= 0.0f) { poseData.IsDataValid = false; } else { poseData.RootScale = _lastHandScale; } } else { _lastHandScale = poseData.RootScale; } if (poseData.IsDataValid && _handDataAsset.IsConnected) { UpdateDataPoses(poseData); return; } } // revert state fields to their defaults _handDataAsset.IsConnected = default; _handDataAsset.IsTracked = default; _handDataAsset.RootPoseOrigin = default; _handDataAsset.PointerPoseOrigin = default; _handDataAsset.IsHighConfidence = default; for (var fingerIdx = 0; fingerIdx < Constants.NUM_FINGERS; fingerIdx++) { _handDataAsset.IsFingerPinching[fingerIdx] = default; _handDataAsset.IsFingerHighConfidence[fingerIdx] = default; } }
private IEnumerator Start() { isMoving = false; //Find the left camera object if we didn't assign it at start. if (!LeftCamera) { zManager = ZEDManager.Instance; LeftCamera = zManager.GetLeftCameraTransform().gameObject.GetComponent <Camera>(); } //Finding the available VR controllers and assigning them to our List. yield return(new WaitForSeconds(1f)); var trackers = FindObjectsOfType <ZEDControllerTracker>(); foreach (ZEDControllerTracker tracker in trackers) { objectTrackers.Add(tracker); } #if ZED_STEAM_VR if (objectTrackers.Count > 0) { for (int i = 0; i < objectTrackers.Count; i++) { if (objectTrackers[i].index >= 0) { VRControls = true; } } } #endif #if ZED_OCULUS if (OVRManager.isHmdPresent) { if (OVRInput.GetConnectedControllers().ToString() == "Touch") { VRControls = true; } } #endif }
// Find the current active controller, based on last time a certain button was hit. Needs to know the previous active controller. public static OVRInput.Controller GetControllerForButton(OVRInput.Button joyPadClickButton, OVRInput.Controller oldController) { OVRInput.Controller controller = OVRInput.GetConnectedControllers(); if ((controller & OVRInput.Controller.RTouch) == OVRInput.Controller.RTouch) { if (OVRInput.Get(joyPadClickButton, OVRInput.Controller.RTouch) || oldController == OVRInput.Controller.None) { return(OVRInput.Controller.RTouch); } } if ((controller & OVRInput.Controller.LTouch) == OVRInput.Controller.LTouch) { if (OVRInput.Get(joyPadClickButton, OVRInput.Controller.LTouch) || oldController == OVRInput.Controller.None) { return(OVRInput.Controller.LTouch); } } if ((controller & OVRInput.Controller.RTrackedRemote) == OVRInput.Controller.RTrackedRemote) { if (OVRInput.Get(joyPadClickButton, OVRInput.Controller.RTrackedRemote) || oldController == OVRInput.Controller.None) { return(OVRInput.Controller.RTrackedRemote); } } if ((controller & OVRInput.Controller.LTrackedRemote) == OVRInput.Controller.LTrackedRemote) { if (OVRInput.Get(joyPadClickButton, OVRInput.Controller.LTrackedRemote) || oldController == OVRInput.Controller.None) { return(OVRInput.Controller.LTrackedRemote); } } if ((controller & oldController) != oldController) { return(OVRInput.Controller.None); } return(oldController); }
/// <summary> /// Returns connected controllers /// </summary> /// <param name="filter"></param> /// <returns></returns> public static OVRInput.Controller GetConnectedControllers(HandFilter filter = HandFilter.Both) { OVRInput.Controller controller = OVRInput.GetConnectedControllers(); if (((filter & HandFilter.Right) == HandFilter.Right) && (controller & OVRInput.Controller.RTouch) == OVRInput.Controller.RTouch) { return(OVRInput.Controller.RTouch); } if (((filter & HandFilter.Left) == HandFilter.Left) && (controller & OVRInput.Controller.LTouch) == OVRInput.Controller.LTouch) { return(OVRInput.Controller.LTouch); } if (((filter & HandFilter.Right) == HandFilter.Right) && (controller & OVRInput.Controller.RTrackedRemote) == OVRInput.Controller.RTrackedRemote) { return(OVRInput.Controller.RTrackedRemote); } if (((filter & HandFilter.Left) == HandFilter.Left) && (controller & OVRInput.Controller.LTrackedRemote) == OVRInput.Controller.LTrackedRemote) { return(OVRInput.Controller.LTrackedRemote); } controller = OVRInput.Controller.None; if (OVRPlugin.GetHandTrackingEnabled()) { if ((filter & HandFilter.Both) == HandFilter.Both) { return(OVRInput.Controller.Hands); } else if ((filter & HandFilter.Right) == HandFilter.Right) { return(OVRInput.Controller.RHand); } else { return(OVRInput.Controller.LHand); } } return(OVRInput.Controller.None); }
void Awake() { if (inputModule != null) { inputModule.OnSelectionRayHit += RayHitSomething; joyPadClickButton = inputModule.joyPadClickButton; } OVRInput.Controller controller = OVRInput.GetConnectedControllers(); if ((controller & OVRInput.Controller.RTouch) == OVRInput.Controller.RTouch) { activeController = OVRInput.Controller.RTouch; } if ((controller & OVRInput.Controller.LTouch) == OVRInput.Controller.LTouch) { activeController = OVRInput.Controller.LTouch; } if ((controller & OVRInput.Controller.RTrackedRemote) == OVRInput.Controller.RTrackedRemote) { activeController = OVRInput.Controller.RTrackedRemote; } if ((controller & OVRInput.Controller.LTrackedRemote) == OVRInput.Controller.LTrackedRemote) { activeController = OVRInput.Controller.LTrackedRemote; } //set defaultPos DefaultPos = new Vector3(0, 0, 0); DefaultPos = transform.position; //set active state of point for the raycast from centre eye //if(testPoint != null) // testPoint.SetActive(!isController); lineReference = lineRenderer; testPoint.SetActive(false); }
void FixedUpdate() { // Seems Oculus inputs are usually fetched in Update, not Fixed Update // FixedUpdate I think seems to be a more reliable source of deltaTime if (Input.GetKey(KeyCode.LeftArrow)) { rb.AddForce(-10000 * Time.deltaTime, 0, 0); } if (Input.GetKey(KeyCode.RightArrow)) { rb.AddForce(10000 * Time.deltaTime, 0, 0); } // This is the unity input capture. //float horizontalInput = Input.GetAxis("Horizontal"); // The Update is needed for OVR input capture, if we arent using the OVRManager //OVRInput.Update(); OVRInput.Controller ctrl = OVRInput.GetConnectedControllers(); Vector2 horizontalAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick); bool xPressed = OVRInput.GetUp(OVRInput.RawButton.X); if (xPressed) { Debug.Log("X Pressed"); // Never triggered. } if (horizontalAxis.x < -0.5f) { //rb.AddForce(-10000 * Time.deltaTime, 0, 0); } if (horizontalAxis.x > 0.5f) { //rb.AddForce(10000 * Time.deltaTime, 0, 0); } }
//void Update () //{ // if (SceneManager.GetActiveScene().name == "main") // { // // Move the gaze cursor to keep it in the middle of the view // if (rayTransform != null) // transform.position = rayTransform.position + rayTransform.forward * depth; // } // // Should we show or hide the gaze cursor? // if (SceneManager.GetActiveScene().name != "main") // { // //ShowUIPointer(); // if (visibilityStrength == 0 && !hidden) // { // Hide(); // HideUIPointer(); // Debug.Log("Hide"); // } // else // if (visibilityStrength > 0 && hidden) // { // Show(); // Debug.Log("Show"); // } // // Hide(); //не показывать указатель Oculus Gaze // //HideUIPointer(); //не показывать указатель UI // } // else // { // Hide(); // } //} #endregion #region GearVRController void Update() { if (OVRInput.GetConnectedControllers() != OVRInput.Controller.None) { transform.position = worldStartPoint + worldOrientation * depth; } //if (rayTransform != null) // transform.position = rayTransform.position + rayTransform.forward * depth; if (visibilityStrength == 0 && !hidden) { Hide(); Debug.Log("Hide" + visibilityStrength + hidden); } else if (visibilityStrength > 0 && hidden) { Show(); Debug.Log("Show" + visibilityStrength + hidden); } }
void Update() { bool controllerConnected = OVRInput.IsControllerConnected(m_controller); Debug.Log(controllerConnected); OVRInput.Controller controller = OVRInput.GetConnectedControllers(); Debug.Log(controller); if ((controllerConnected != m_prevControllerConnected) || !m_prevControllerConnectedCached) { // m_model.SetActive(controllerConnected); m_prevControllerConnected = controllerConnected; m_prevControllerConnectedCached = true; } if (!controllerConnected) { return; } }
// Token: 0x06005707 RID: 22279 RVA: 0x001DF8C8 File Offset: 0x001DDCC8 private void RefreshTrackerState() { if (this.ovrManager != null) { this.ovrManager.enabled = (VRSettings.enabled && this.IsInVRMode()); } if (this.ovrCameraRig != null) { this.ovrCameraRig.enabled = (VRSettings.enabled && this.IsInVRMode()); if (this.ovrCameraRig.enabled) { OVRInput.Controller connectedControllers = OVRInput.GetConnectedControllers(); if (this.ovrCameraRig.leftHandAnchor != null) { this.ovrCameraRig.leftHandAnchor.gameObject.SetActive((connectedControllers & OVRInput.Controller.LTouch) != OVRInput.Controller.None); } if (this.ovrCameraRig.rightHandAnchor != null) { this.ovrCameraRig.rightHandAnchor.gameObject.SetActive((connectedControllers & OVRInput.Controller.RTouch) != OVRInput.Controller.None); } } } }
protected override void PendInputs(AirVRInputStream inputStream) { bool leftHanded = (OVRInput.GetConnectedControllers() & OVRInput.Controller.LTrackedRemote) != 0; OVRInput.Controller controller = OVRInput.Controller.LTrackedRemote | OVRInput.Controller.RTrackedRemote; inputStream.PendTransform(this, (byte)AirVRTrackedControllerKey.Transform, OVRInput.GetLocalControllerPosition(leftHanded ? OVRInput.Controller.LTrackedRemote : OVRInput.Controller.RTrackedRemote), OVRInput.GetLocalControllerRotation(leftHanded ? OVRInput.Controller.LTrackedRemote : OVRInput.Controller.RTrackedRemote)); inputStream.PendTouch(this, (byte)AirVRTrackedControllerKey.Touchpad, OVRInput.Get(leftHanded ? OVRInput.RawAxis2D.LTouchpad : OVRInput.RawAxis2D.RTouchpad, controller), OVRInput.Get(leftHanded ? OVRInput.RawTouch.LTouchpad : OVRInput.RawTouch.RTouchpad, controller)); inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonTouchpad, OVRInput.Get(leftHanded ? OVRInput.RawButton.LTouchpad : OVRInput.RawButton.RTouchpad, controller)); // workaround : avoid bugs in OVRInput for important inputs inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonBack, OVRInput.Get(OVRInput.Button.Back)); inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonIndexTrigger, OVRInput.Get(leftHanded ? OVRInput.RawButton.LIndexTrigger : OVRInput.RawButton.RIndexTrigger, controller)); inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonUp, OVRInput.Get(OVRInput.RawButton.DpadUp, controller)); inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonDown, OVRInput.Get(OVRInput.RawButton.DpadDown, controller)); inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonLeft, OVRInput.Get(OVRInput.RawButton.DpadLeft, controller)); inputStream.PendButton(this, (byte)AirVRTrackedControllerKey.ButtonRight, OVRInput.Get(OVRInput.RawButton.DpadRight, controller)); }