GetActiveController() public static method

Returns the current active controller type.
public static GetActiveController ( ) : Controller,
return Controller,
Beispiel #1
0
    ControllerPose GetControllerPose(OVRInput.Controller controller)
    {
        ovrAvatarButton buttons = 0:
        if (OVRInput.Get(OVRInput.Button.One, controller)) buttons |= ovrAvatarButton.One:
        if (OVRInput.Get(OVRInput.Button.Two, controller)) buttons |= ovrAvatarButton.Two:
        if (OVRInput.Get(OVRInput.Button.Start, controller)) buttons |= ovrAvatarButton.Three:
        if (OVRInput.Get(OVRInput.Button.PrimaryThumbstick, controller)) buttons |= ovrAvatarButton.Joystick:

        ovrAvatarTouch touches = 0:
        if (OVRInput.Get(OVRInput.Touch.One, controller)) touches |= ovrAvatarTouch.One:
        if (OVRInput.Get(OVRInput.Touch.Two, controller)) touches |= ovrAvatarTouch.Two:
        if (OVRInput.Get(OVRInput.Touch.PrimaryThumbstick, controller)) touches |= ovrAvatarTouch.Joystick:
        if (OVRInput.Get(OVRInput.Touch.PrimaryThumbRest, controller)) touches |= ovrAvatarTouch.ThumbRest:
        if (OVRInput.Get(OVRInput.Touch.PrimaryIndexTrigger, controller)) touches |= ovrAvatarTouch.Index:
        if (!OVRInput.Get(OVRInput.NearTouch.PrimaryIndexTrigger, controller)) touches |= ovrAvatarTouch.Pointing:
        if (!OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, controller)) touches |= ovrAvatarTouch.ThumbUp:

        return new ControllerPose
        {
            buttons = buttons,
            touches = touches,
            joystickPosition = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, controller),
            indexTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, controller),
            handTrigger = OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, controller),
            isActive = (OVRInput.GetActiveController() & controller) != 0,
        }:
    }
Beispiel #2
0
        public VR_Controller GetActiveController()
        {
#if SDK_OCULUS
            return(OVRInput.GetActiveController() == OVRInput.Controller.RTouch ? rightController : leftController);
#endif
            return(rightController);
        }
Beispiel #3
0
    bool ShouldToggleMenu()
    {
        OVRInput.Button     showButton       = OVRInput.Button.Start;
        OVRInput.Controller activeController = OVRInput.GetActiveController();

        if ((activeController == OVRInput.Controller.Remote) ||
            (activeController == OVRInput.Controller.Touchpad) ||
            (activeController == OVRInput.Controller.LTrackedRemote) ||
            (activeController == OVRInput.Controller.RTrackedRemote)
            )
        {
            showButton = OVRInput.Button.Two;
        }

        if (OVRInput.GetDown(showButton)
#if !UNITY_ANDROID || UNITY_EDITOR
            || (IsMenuActive() && Input.GetKeyDown(hideKey)) ||
            (!IsMenuActive() && Input.GetKeyDown(showKey))
#endif
            )
        {
            return(true);
        }

        return(false);
    }
Beispiel #4
0
        public void Update()
        {
            // Manually update the Touch input
            OVRInput.Update();

            if ((OVRInput.GetActiveController() & OVRInput.Controller.Touch) == 0)
            {
                active = false;
                return;
            }
            active = true;

            for (VRInputDevice.Handedness hand = VRInputDevice.Handedness.Left;
                 (int)hand <= (int)VRInputDevice.Handedness.Right;
                 hand++)
            {
                OVRInput.Controller controller = hand == VRInputDevice.Handedness.Left
                                        ? OVRInput.Controller.LTouch
                                        : OVRInput.Controller.RTouch;
                int ovrIndex    = controller == OVRInput.Controller.LTouch ? 0 : 1;
                int deviceIndex = hand == VRInputDevice.Handedness.Left ? 3 : 4;

                // TODO change 3 and 4 based on virtual devices defined in InputDeviceManager (using actual hardware available)
                SendButtonEvents(controller, deviceIndex);
                SendAxisEvents(controller, ovrIndex, deviceIndex);
                SendTrackingEvents(controller, ovrIndex, deviceIndex);
            }
        }
    // Update is called once per frame
    void Update()
    {
        inputModule.rayTransform = OVRGazePointer.instance.rayTransform =
            (OVRInput.GetActiveController() == OVRInput.Controller.Touch) ? cameraRig.rightHandAnchor :
            (OVRInput.GetActiveController() == OVRInput.Controller.RTouch) ? cameraRig.rightHandAnchor :
            (OVRInput.GetActiveController() == OVRInput.Controller.LTouch) ? cameraRig.leftHandAnchor :
            cameraRig.centerEyeAnchor;

        UpdateFramerate();
        if (menuActive)
        {
            if (ShouldToggleMenu())
            {
                //Hide fully, including getting rid of the warning
                Hide();
            }

            //Lock cursor to window on mouse press
            if (Input.GetMouseButtonDown(0))
            {
                LockCursor();
            }
#if !UNITY_ANDROID || UNITY_EDITOR
            UpdateMousePointer();
#endif
        }
        else
        {
            if (ShouldToggleMenu())
            {
                // Show inspector
                Show();
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     if (OVRInput.GetActiveController() != OVRInput.Controller.Touch)
     {
         Debug.Log("Incompatible controller " + OVRInput.GetActiveController());
     }
 }
Beispiel #7
0
 public void CheckTriggerStatus()
 {
     //Debug.Log("<b>Check trigger status: </b>");
     /*** Define trigger key to fire events for different platforms ***/
     activeController = OVRInput.GetActiveController();
     // Check if Oculus Rift is being used, then we need to check if button is pressed on target pointer.
     if (activeController == OVRInput.Controller.Touch ||
         activeController == OVRInput.Controller.LTouch || activeController == OVRInput.Controller.RTouch)
     {
         if (pointer == Pointer.LeftHand)
         {
             triggerPressed = OVRInput.Get(trigger, OVRInput.Controller.LTouch);
             //Debug.Log("Trigger pressed Left? : " + triggerPressed);
         }
         else if (pointer == Pointer.RightHand)
         {
             triggerPressed = OVRInput.Get(trigger, OVRInput.Controller.RTouch);
             //Debug.Log("Trigger pressed right? : " + triggerPressed);
         }
     }
     else
     {
         //triggerPressed = OVRInput.Get(trigger);
     }
 }
Beispiel #8
0
        void Update()
        {
            bool isEyePointer = LaserInputModule.instance.pointer == Pointer.Eye;

            if (temp != LaserInputModule.instance.pointer)
            {
                gazePointer.SetActive(isEyePointer);
                laser.SetActive(!isEyePointer);
#if UIKIT_OCULUS || UIKIT_VIVE_STEAM_2
                SetPointer(LaserInputModule.instance.pointer);
#endif
                temp = LaserInputModule.instance.pointer;
            }

#if UIKIT_OCULUS
            activeController = OVRInput.GetActiveController();
            /********* Oculus Go and Gear VR **********/
            if (activeController == OVRInput.Controller.LTrackedRemote &&
                LaserInputModule.instance.pointer != Pointer.LeftHand)
            {
                SetPointer(Pointer.LeftHand);
            }
            else if (activeController == OVRInput.Controller.RTrackedRemote &&
                     LaserInputModule.instance.pointer != Pointer.RightHand)
            {
                SetPointer(Pointer.RightHand);
            }

            if (allowAutoSwitchHand)
            {
                /********* Oculus Rift **********/
                if (OVRInput.GetDown(LaserInputModule.instance.trigger, OVRInput.Controller.RTouch) &&
                    LaserInputModule.instance.pointer != Pointer.RightHand)
                {
                    SetPointer(Pointer.RightHand);
                }
                else if (OVRInput.GetDown(LaserInputModule.instance.trigger, OVRInput.Controller.LTouch) &&
                         LaserInputModule.instance.pointer != Pointer.LeftHand)
                {
                    SetPointer(Pointer.LeftHand);
                }
            }
#endif

#if UIKIT_VIVE_STEAM_2
            if (allowAutoSwitchHand)
            {
                if (LaserInputModule.instance.triggerAction.GetStateDown(SteamVR_Input_Sources.RightHand) &&
                    LaserInputModule.instance.pointer != Pointer.RightHand)
                {
                    SetPointer(Pointer.RightHand);
                }
                else if (LaserInputModule.instance.triggerAction.GetStateDown(SteamVR_Input_Sources.LeftHand) &&
                         LaserInputModule.instance.pointer != Pointer.LeftHand)
                {
                    SetPointer(Pointer.LeftHand);
                }
            }
#endif
        }
Beispiel #9
0
    public static Transform GetController()
    {
        // init
        if (_rightController == null)
        {
            GameObject rightAnchor = GameObject.Find("RightHandAnchor");
            _rightController = rightAnchor.transform.Find("TrackedRemote");

            GameObject leftAnchor = GameObject.Find("LeftHandAnchor");
            _leftController = leftAnchor.transform.Find("TrackedRemote");

            _centerEyeAnchor = GameObject.Find("OVRCameraRig").transform;
        }

        // get controller
        var controller = OVRInput.GetActiveController();

        if (controller == OVRInput.Controller.RTrackedRemote)
        {
            return(_rightController);
        }
        if (controller == OVRInput.Controller.LTrackedRemote)
        {
            return(_leftController);
        }
        return(_centerEyeAnchor);
    }
Beispiel #10
0
 // Update is called once per frame
 void Update()
 {
     controllerDirection = OVRInput.GetLocalControllerRotation(OVRInput.GetActiveController()).eulerAngles.y;
     if (controllerDirection < 180)
     {
         if (!currentAnswer)
         {
             popMaker.Play();
         }
         YesAnswer.faceColor = new Color32((byte)255, (byte)255, (byte)255, (byte)255);
         NoAnswer.faceColor  = new Color32((byte)128, (byte)128, (byte)128, (byte)255);
         currentAnswer       = true;
         if (OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger))
         {
             Application.Quit();
         }
     }
     else
     {
         if (currentAnswer)
         {
             popMaker.Play();
         }
         NoAnswer.faceColor  = new Color32((byte)255, (byte)255, (byte)255, (byte)255);
         YesAnswer.faceColor = new Color32((byte)128, (byte)128, (byte)128, (byte)255);
         currentAnswer       = false;
         if (OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger))
         {
             ControllerScript.CancelledQuit();
         }
     }
 }
Beispiel #11
0
    // Update is called once per frame
    protected virtual void Update()
    {
        OVRInput.Controller activeController = OVRInput.GetActiveController();
        Transform           activeTransform  = cameraRig.centerEyeAnchor;

        if ((activeController == OVRInput.Controller.LTouch) || (activeController == OVRInput.Controller.LTrackedRemote))
        {
            activeTransform = cameraRig.leftHandAnchor;
        }

        if ((activeController == OVRInput.Controller.RTouch) || (activeController == OVRInput.Controller.RTrackedRemote))
        {
            activeTransform = cameraRig.rightHandAnchor;
        }

        if (activeController == OVRInput.Controller.Touch)
        {
            activeTransform = cameraRig.rightHandAnchor;
        }

        OVRGazePointer.instance.rayTransform = activeTransform;
        inputModule.rayTransform             = activeTransform;


        //Lock cursor to window on mouse press
        if (Input.GetMouseButtonDown(0))
        {
            LockCursor();
        }
#if !UNITY_ANDROID || UNITY_EDITOR
        UpdateMousePointer();
#endif
    }
Beispiel #12
0
 bool AreAnyTouchControllersActive_()
 {
     OVRInput.Controller c = OVRInput.GetActiveController();
     return(c == OVRInput.Controller.Touch ||
            c == OVRInput.Controller.LTouch ||
            c == OVRInput.Controller.RTouch);
 }
Beispiel #13
0
    // Update is called once per frame
    void Update()
    {
        activeController = OVRInput.GetActiveController();
        Quaternion rot        = OVRInput.GetLocalControllerRotation(activeController);
        bool       isLongSord = false;

        isLongSord |= (240f < rot.eulerAngles.x && rot.eulerAngles.x < 270f);
        isLongSord |= (270f < rot.eulerAngles.y && rot.eulerAngles.y < 300f);
        isLongSord |= (60f < rot.eulerAngles.y && rot.eulerAngles.y < 90f);

        bool isForceShortSord = true;

        isForceShortSord &= (20f < rot.eulerAngles.x && rot.eulerAngles.x < 30f);
        isForceShortSord &= (350f < rot.eulerAngles.y && rot.eulerAngles.y < 360f) ||
                            (0f < rot.eulerAngles.y && rot.eulerAngles.y < 10f);
        isForceShortSord &= this.context.isPlay;

        //Debug.Log(isLongSord.ToString());
        if (isLongSord || isForceShortSord)
        {
            this.context.SetLongSord(isLongSord && !isForceShortSord);
        }

        this.SetLongSord(this.context.isLongSord);
    }
 private void OnCollisionEnter(Collision other)
 {
     if (other.collider.gameObject.layer == 10)
     {
         OVRInput.SetControllerVibration(0.3f, 0.5f, OVRInput.GetActiveController());
     }
 }
Beispiel #15
0
    // Update is called once per frame
    void Update()
    {
        bool trigger = OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger) || Input.GetKeyDown(KeyCode.A);

        if (trigger)
        {
            Instantiate(skinedmesh, transform.position + transform.forward * 5, transform.rotation);
        }
        bool touchpad = OVRInput.Get(OVRInput.Touch.PrimaryTouchpad);

        if (touchpad)
        {
            OVRInput.Controller activeController = OVRInput.GetActiveController();
            Quaternion          rot = OVRInput.GetLocalControllerRotation(activeController);
            // data.AppendFormat("Orientation: ({0:F2}, {1:F2}, {2:F2}, {3:F2})\n", rot.x, rot.y, rot.z, rot.w);
            Vector2 primaryTouchpad = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);
            // data.AppendFormat("PrimaryTouchpad: ({0:F2}, {1:F2})\n", primaryTouchpad.x, primaryTouchpad.y);
            if (primaryTouchpad.y > 0.5)
            {
                transform.position += speed * (rot * Vector3.forward);
            }
            else if (primaryTouchpad.y < -0.5)
            {
                transform.position -= speed * (rot * Vector3.forward);
            }
            if (primaryTouchpad.x > 0.5)
            {
                transform.position += speed * (rot * Vector3.right);
            }
            else if (primaryTouchpad.x < -0.5)
            {
                transform.position -= speed * (rot * Vector3.right);
            }
        }
    }
 private bool ControllerIsActive()
 {
     // コンストラクタ内で設定するとうまくいかない。
     // MonoBehaviour の Start 内で呼び出すと、必ず(?) None になるっぽい。
     OVRInput.Controller activeController = OVRInput.GetActiveController();
     return(activeController != OVRInput.Controller.None);
 }
        private void UpdateInputDevices()
        {
            mCachedActiveController = OVRInput.GetActiveController();

            var hasController = OVRUtils.IsOculusQuest ?
                                OVRUtils.IsQuestControllerConnected :
                                (mCachedActiveController & GearVRController.AllHandControllersMask) != 0;

            // TODO Introduce ActiveInputDevice, presently PrimaryInputDevice is treated as Active and it should be Left or Right, not Primary or Secondary.
            if (hasController)
            {
                if (OVRUtils.IsOculusQuest)
                {
                    PrimaryInputDevice   = mPrimaryController;
                    SecondaryInputDevice = mSecondaryController;
                }
                else
                {
                    PrimaryInputDevice   = OVRInput.GetActiveController() == OVRInput.Controller.RTrackedRemote ? mPrimaryController : mSecondaryController;
                    SecondaryInputDevice = Headset as GearVRInputDevice;
                }
            }
            else
            {
                PrimaryInputDevice   = Headset as GearVRInputDevice;
                SecondaryInputDevice = null;
            }

            PrimaryInputDeviceChanged?.Invoke(this);
        }
    void CheckForHands()
    {
        bool handsActive = (
            OVRInput.GetActiveController() == OVRInput.Controller.Hands ||
            OVRInput.GetActiveController() == OVRInput.Controller.LHand ||
            OVRInput.GetActiveController() == OVRInput.Controller.RHand);

        if (transform.GetChild(0).gameObject.activeSelf)
        {
            if (!handsActive)
            {
                transform.GetChild(0).gameObject.SetActive(false);
                leftHeldKnob  = -1;
                rightHeldKnob = -1;
            }
        }
        else
        {
            if (handsActive)
            {
                transform.GetChild(0).gameObject.SetActive(true);
                transform.position  = (rightHand.Bones[20].Transform.position + rightHand.Bones[20].Transform.position) * 0.5f;
                transform.position += (transform.position - Camera.main.transform.position).normalized * 0.1f;
                transform.rotation  = Quaternion.LookRotation(new Vector3(Camera.main.transform.forward.x, 0, Camera.main.transform.forward.z));
            }
        }
    }
    protected virtual void ProcessOculusVRController()
    {
#if CURVEDUI_TOUCH
        //find if we're using Rift with touch. Hand differentiation will only be used for those.
        bool touchControllersUsed = OVRInput.GetActiveController() == OVRInput.Controller.Touch ||
                                    OVRInput.GetActiveController() == OVRInput.Controller.LTouch ||
                                    OVRInput.GetActiveController() == OVRInput.Controller.RTouch;


        // check the state of the interaction button
        if (usedHand == Hand.Both || !touchControllersUsed)
        {
            CustomControllerButtonDown = OVRInput.Get(InteractionButton);
        }
        else if (usedHand == Hand.Right)
        {
            CustomControllerButtonDown = OVRInput.Get(InteractionButton, OVRInput.Controller.RTouch);
        }
        else if (usedHand == Hand.Left)
        {
            CustomControllerButtonDown = OVRInput.Get(InteractionButton, OVRInput.Controller.LTouch);
        }

        //set direction ray
        CustomControllerRay = new Ray(OculusTouchUsedControllerTransform.position, OculusTouchUsedControllerTransform.forward);

        //process all events based on this data
        ProcessOculusTouchEventData();
    }
Beispiel #20
0
        protected override void Update()
        {
            base.Update();
            if (IsUsing() && timer < Time.time)
            {
                timer = Time.time + 0.1f;
                FireBullet();
            }

            if (OVRInput.GetActiveController() == OVRInput.Controller.Touchpad)             //Code For GearVR controls
            {
                RightHandAvatar.transform.position           = RightHand.transform.position;
                RightHandControllerAvatar.transform.position = RightHand.transform.position;

                LineRenderer lineRenderer = GetComponent <LineRenderer>();
                lineRenderer.SetPosition(0, RightHand.transform.position);
                lineRenderer.SetPosition(1, RightHand.transform.position + Vector3.forward);

                if (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
                {
                    if (timer < Time.time)
                    {
                        timer = Time.time + 0.1f;
                        FireBullet();
                    }
                }

                if (OVRInput.Get(OVRInput.Button.PrimaryTouchpad))
                {
                    GameManager.instance.StartGame();
                }
            }
        }
 private void Update()
 {
     if (!showed3Message && Time.timeSinceLevelLoad > 180)
     {
         showed3Message = true;
         StartCoroutine(Show3Message());
     }
     if (!showed5Message && Time.timeSinceLevelLoad > 300)
     {
         showed5Message = true;
         StartCoroutine(Show5Message());
     }
     if (paused)
     {
         var activeControl = OVRInput.GetActiveController();
         if (activeControl == OVRInput.Controller.Hands || activeControl == OVRInput.Controller.LHand || activeControl == OVRInput.Controller.RHand)
         {
             m_laserPointerRenderer.enabled = false;
         }
         else if (activeControl == OVRInput.Controller.RTouch || activeControl == OVRInput.Controller.LTouch)
         {
             m_laserPointerRenderer.enabled = true;
         }
     }
 }
    void Update()
    {
        // is player using a controller?
        if (OVRInput.GetActiveController() == OVRInput.Controller.LTrackedRemote ||
            OVRInput.GetActiveController() == OVRInput.Controller.RTrackedRemote)
        {
            // Touchpad button
            if (OVRInput.GetDown(OVRInput.Button.PrimaryTouchpad))
            {
                Grab();
            }

            if (OVRInput.GetUp(OVRInput.Button.PrimaryTouchpad))
            {
                Release();
            }

            if (Anim)
            {
                animVal = OVRInput.Get(OVRInput.Button.PrimaryTouchpad) ? 1.0f : 0.0f;
                Anim.SetFloat(HAND_ANIM, animVal);
            }
        }

        // editor debug keys
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Grab();
        }

        if (Input.GetKeyUp(KeyCode.Space))
        {
            Release();
        }
    }
 public override void TriggerHapticPulse(ushort durationMicroSec = 500, NVRButtons button = NVRButtons.Touchpad)
 {
     if (OVRInput.GetActiveController() == OVRInput.Controller.Touch)
     {
         StartCoroutine(DoHapticPulse(durationMicroSec));
     }
 }
Beispiel #24
0
    void Update()
    {
        OVRInput.Controller activeController = OVRInput.GetActiveController();

        data.Length = 0;

        /*
         *      byte recenterCount = OVRInput.GetControllerRecenterCount();
         *      data.AppendFormat("RecenterCount: {0}\n", recenterCount);
         *
         *      byte battery = OVRInput.GetControllerBatteryPercentRemaining();
         *      data.AppendFormat("Battery: {0}\n", battery);
         */
        float framerate = OVRPlugin.GetAppFramerate();

        data.AppendFormat("fps: {0:F2}\n", framerate);

        /*
         *      string activeControllerName = activeController.ToString();
         *      data.AppendFormat("Active: {0}\n", activeControllerName);
         *
         *      string connectedControllerNames = OVRInput.GetConnectedControllers().ToString();
         *      data.AppendFormat("Connected: {0}\n", connectedControllerNames);
         *
         *      Quaternion rot = OVRInput.GetLocalControllerRotation(activeController);
         *      data.AppendFormat("Orientation: ({0:F2}, {1:F2}, {2:F2}, {3:F2})\n", rot.x, rot.y, rot.z, rot.w);
         *
         *      Vector3 angVel = OVRInput.GetLocalControllerAngularVelocity(activeController);
         *      data.AppendFormat("AngVel: ({0:F2}, {1:F2}, {2:F2})\n", angVel.x, angVel.y, angVel.z);
         *
         *      Vector3 angAcc = OVRInput.GetLocalControllerAngularAcceleration(activeController);
         *      data.AppendFormat("AngAcc: ({0:F2}, {1:F2}, {2:F2})\n", angAcc.x, angAcc.y, angAcc.z);
         *
         *      Vector3 pos = OVRInput.GetLocalControllerPosition(activeController);
         *      data.AppendFormat("Position: ({0:F2}, {1:F2}, {2:F2})\n", pos.x, pos.y, pos.z);
         *
         *      Vector3 vel = OVRInput.GetLocalControllerVelocity(activeController);
         *      data.AppendFormat("Vel: ({0:F2}, {1:F2}, {2:F2})\n", vel.x, vel.y, vel.z);
         *
         *      Vector3 acc = OVRInput.GetLocalControllerAcceleration(activeController);
         *      data.AppendFormat("Acc: ({0:F2}, {1:F2}, {2:F2})\n", acc.x, acc.y, acc.z);
         *
         *      Vector2 primaryTouchpad = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);
         *      data.AppendFormat("PrimaryTouchpad: ({0:F2}, {1:F2})\n", primaryTouchpad.x, primaryTouchpad.y);
         *
         *      Vector2 secondaryTouchpad = OVRInput.Get(OVRInput.Axis2D.SecondaryTouchpad);
         *      data.AppendFormat("SecondaryTouchpad: ({0:F2}, {1:F2})\n", secondaryTouchpad.x, secondaryTouchpad.y);
         *
         *      for (int i = 0; i < monitors.Count; i++)
         *      {
         *              monitors[i].Update();
         *              monitors[i].AppendToStringBuilder(ref data);
         *      }
         */

        if (uiText != null)
        {
            uiText.text = data.ToString();
        }
    }
Beispiel #25
0
    void Update()
    {
        Camera.main.depthTextureMode = DepthTextureMode.Depth;

        bool controllersActive = (OVRInput.GetActiveController() == OVRInput.Controller.LTouch ||
                                  OVRInput.GetActiveController() == OVRInput.Controller.RTouch ||
                                  OVRInput.GetActiveController() == OVRInput.Controller.Touch);

        leftMaskObject.SetActive(controllersActive);
        rightMaskObject.SetActive(controllersActive);

        // controller masks are giant circles attached to controllers
        if (controllersActive)
        {
            Vector3 Lpos = OVRInput.GetLocalControllerPosition(OVRInput.Controller.LTouch) + OVRInput.GetLocalControllerRotation(OVRInput.Controller.LTouch) * Vector3.forward * 0.1f;
            Vector3 Rpos = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch) + OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch) * Vector3.forward * 0.1f;

            leftMaskObject.transform.position  = Lpos;
            rightMaskObject.transform.position = Rpos;
        }
        // hand masks are an inflated hands shader, with alpha fading at wrists and edges
        else if (OVRInput.GetActiveController() == OVRInput.Controller.LHand ||
                 OVRInput.GetActiveController() == OVRInput.Controller.RHand ||
                 OVRInput.GetActiveController() == OVRInput.Controller.Hands)
        {
        }
    }
    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;
        }
    }
Beispiel #27
0
    protected virtual void ProcessOculusVRController()
    {
#if CURVEDUI_TOUCH
        activeCont = OVRInput.GetActiveController();


        //Find the currently used HandAnchor----------------------//
        //and set direction ray using its transform
        switch (activeCont)
        {
        //Oculus Touch
        case OVRInput.Controller.RTouch: CustomControllerRay = new Ray(oculusRig.rightHandAnchor.position, oculusRig.rightHandAnchor.forward); break;

        case OVRInput.Controller.LTouch: CustomControllerRay = new Ray(oculusRig.leftHandAnchor.position, oculusRig.leftHandAnchor.forward); break;

        //GearVR touchpad
        case OVRInput.Controller.Touchpad: CustomControllerRay = new Ray(oculusRig.centerEyeAnchor.position, oculusRig.centerEyeAnchor.forward); break;

        //GearVR controller / Oculus Go controller
        case OVRInput.Controller.RTrackedRemote: goto case OVRInput.Controller.RTouch;

        case OVRInput.Controller.LTrackedRemote: goto case OVRInput.Controller.LTouch;

        //edge cases
        default: CustomControllerRay = new Ray(OculusTouchUsedControllerTransform.position, OculusTouchUsedControllerTransform.forward); break;
        }



        //Check if interaction button is pressed ---------------//

        //find if we're using Rift with touch. If yes, we'll have to check if the interaction button is pressed on the proper hand.
        bool touchControllersUsed = (activeCont == OVRInput.Controller.Touch || activeCont == OVRInput.Controller.LTouch || activeCont == OVRInput.Controller.RTouch);

        if (usedHand == Hand.Both || !touchControllersUsed)
        {
            //check if this button is pressed on any controller. Handles GearVR controller and Oculus Go controller.
            CustomControllerButtonDown = OVRInput.Get(InteractionButton);

            //on GearVR, also check touchpad, as a secondary, optional input.
            if (activeCont == OVRInput.Controller.Touchpad)
            {
                CustomControllerButtonDown = CustomControllerButtonDown || OVRInput.Get(OVRInput.Button.PrimaryTouchpad);
            }
        }
        else if (usedHand == Hand.Right) // Right Oculus Touch
        {
            CustomControllerButtonDown = OVRInput.Get(InteractionButton, OVRInput.Controller.RTouch);
        }
        else if (usedHand == Hand.Left)  // Left Oculus Touch
        {
            CustomControllerButtonDown = OVRInput.Get(InteractionButton, OVRInput.Controller.LTouch);
        }



        //process all events based on this data--------------//
        ProcessCustomRayController();
#endif // END OF CURVEDUI_TOUCH IF
    }
Beispiel #28
0
    // Update is called once per frame
    void Update()
    {
        switch (OVRInput.GetActiveController())
        {
        case OVRInput.Controller.LTouch:
        {
            _logic.SetPrimaryHand(LeftHand);
        }
        break;

        case OVRInput.Controller.RTouch:
        {
            _logic.SetPrimaryHand(RightHand);
        }
        break;

        case OVRInput.Controller.Touch:
        {
            _logic.SetPrimaryHand(RightHand);
        }
        break;

        case OVRInput.Controller.None:
        {
            _logic.SetPrimaryHand(null);
        }
        break;
        }

        //Update Event & Logic
        _event.Update(Time.deltaTime);

        transform.position = _logic.Position;
    }
Beispiel #29
0
 // Update is called once per frame
 void Update()
 {
     // If we are running on a Go.
     if (OVRPlugin.GetSystemHeadsetType() == OVRPlugin.SystemHeadset.Oculus_Go)
     {
         UpdateHand(0, OVRInput.GetActiveController(), OVRInput.Button.PrimaryIndexTrigger, OVRInput.Button.PrimaryHandTrigger, 3.0f, (hand[0].transform.position - lastPosition) / Time.deltaTime);
         // Use the touchpad to move.
         if (OVRInput.Get(OVRInput.Button.PrimaryTouchpad))
         {
             Vector2 thumb   = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);
             Vector3 forward = hand[0].transform.forward;
             Vector3 right   = hand[0].transform.right;
             forward.y           = 0.0f;
             right.y             = 0.0f;
             transform.position += (forward.normalized * thumb.y + right.normalized * thumb.x) * Time.deltaTime * 1.5f;
         }
         lastPosition = hand[0].transform.position;
     }
     else
     {
         // Update both left and right hands for Rift or Quest.
         UpdateHand(0, OVRInput.Controller.LTouch, OVRInput.Button.PrimaryIndexTrigger, OVRInput.Button.PrimaryHandTrigger, 0, Vector3.zero);
         UpdateHand(1, OVRInput.Controller.RTouch, OVRInput.Button.SecondaryIndexTrigger, OVRInput.Button.SecondaryHandTrigger, 0, Vector3.zero);
     }
 }
    //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();
        }
    }