Beispiel #1
0
        void Update()
        {
            // Set controller style from input profile
            if (App.VrSdk.VrControls == null)
            {
                App.VrSdk.SetControllerStyle(ProfileLoader.Instance.GetControllerStyle());
            }

            // Update controller infos.
            for (int i = 0; i < m_ControllerInfos.Length; ++i)
            {
                m_ControllerInfos[i].Update();
            }

            //cache touch inputs so we can control their usage
            m_Touch.m_Valid = (Input.touchCount > 0) && (Input.GetTouch(0).phase == TouchPhase.Began);
            if (m_Touch.m_Valid)
            {
                m_Touch.m_Pos = Input.GetTouch(0).position;
            }

            // Update touch locators.
            // Controller pad touch locator should be active if thumb is on the pad.
            // For the brush controller, tools can override this, unless we're in the intro tutorial.
            Brush.Behavior.SetTouchLocatorActive(Brush.GetPadTouch() &&
                                                 (SketchSurfacePanel.m_Instance.ActiveTool.ShouldShowTouch() ||
                                                  TutorialManager.m_Instance.TutorialActive()));
            Wand.Behavior.SetTouchLocatorActive(Wand.GetPadTouch());
            Wand.Behavior.SetTouchLocatorPosition(Wand.GetPadValue());
            Brush.Behavior.SetTouchLocatorPosition(Brush.GetPadValue());
        }
Beispiel #2
0
        void Update()
        {
            // If we're initializing our controllers, continue to look for them.
            if (App.VrSdk.IsInitializingSteamVr)
            {
                if (m_ControllerInfos[0].IsTrackedObjectValid && m_ControllerInfos[1].IsTrackedObjectValid)
                {
                    SteamVR steamVR = SteamVR.instance;

                    // Determine controllers from the 0 controller.  If that isn't recognized,
                    // try the 1 controller.  If *that* isn't recognized, default to Vive.
                    string controllerStyle0        = "";
                    SteamControllerInfo steamInfo0 = m_ControllerInfos[0] as SteamControllerInfo;
                    if (!SetSteamControllerStyle(steamInfo0, out controllerStyle0))
                    {
                        string controllerStyle1        = "";
                        SteamControllerInfo steamInfo1 = m_ControllerInfos[1] as SteamControllerInfo;
                        if (!SetSteamControllerStyle(steamInfo1, out controllerStyle1))
                        {
                            Debug.LogWarningFormat(
                                "Controller styles {0} and {1} not recognized.  Defaulting to Vive.",
                                controllerStyle0, controllerStyle1);
                            App.VrSdk.SetControllerStyle(ControllerStyle.Vive);
                        }
                    }

                    // Null out controller infos to start fresh.
                    for (int i = 0; i < m_ControllerInfos.Length; ++i)
                    {
                        m_ControllerInfos[i] = null;
                    }

                    // Create new one controller infos.
                    CreateControllerInfos();

                    // Swap geometry if any of our controllers is a logipen.
                    bool foundLogipen = false;
                    for (int i = 0; i < m_ControllerInfos.Length; ++i)
                    {
                        SteamControllerInfo info = m_ControllerInfos[i] as SteamControllerInfo;
                        DetectLogitechVrPen pen  = info.Behavior.GetComponent <DetectLogitechVrPen>();
                        if (pen != null)
                        {
                            pen.Initialize(info.TrackedPose.GetDeviceIndex());
                            foundLogipen = foundLogipen || pen.IsPen;
                        }
                    }

                    // Initialize handedness.
                    // The logitech pen stomps handedness because it is a handed controller, so don't
                    // respect this if we've got a pen.
                    if (!foundLogipen)
                    {
                        WandOnRight = (PlayerPrefs.GetInt(PLAYER_PREF_WAND_ON_RIGHT, 0) != 0);
                    }

                    // Refresh pointer angle and rendering.
                    PointerManager.m_Instance.RefreshFreePaintPointerAngle();
                    PointerManager.m_Instance.RequestPointerRendering(true);
                }
            }
            else
            {
                // Update controller infos.
                for (int i = 0; i < m_ControllerInfos.Length; ++i)
                {
                    m_ControllerInfos[i].Update();
                }

                //cache touch inputs so we can control their usage
                m_Touch.m_Valid = (Input.touchCount > 0) && (Input.GetTouch(0).phase == TouchPhase.Began);
                if (m_Touch.m_Valid)
                {
                    m_Touch.m_Pos = Input.GetTouch(0).position;
                }

                // Update touch locators.
                // Controller pad touch locator should be active if thumb is on the pad.
                // For the brush controller, tools can override this, unless we're in the intro tutorial.
                Brush.Behavior.SetTouchLocatorActive(Brush.GetPadTouch() &&
                                                     (SketchSurfacePanel.m_Instance.ActiveTool.ShouldShowTouch() ||
                                                      TutorialManager.m_Instance.TutorialActive()));
                Wand.Behavior.SetTouchLocatorActive(Wand.GetPadTouch());
                Wand.Behavior.SetTouchLocatorPosition(Wand.GetPadValue());
                Brush.Behavior.SetTouchLocatorPosition(Brush.GetPadValue());
            }
        }