示例#1
0
        bool SetSteamControllerStyle(SteamControllerInfo steamInfo, out string style)
        {
            SteamVR steamVR = SteamVR.instance;

            style = steamVR.GetStringProperty(ETrackedDeviceProperty.Prop_ControllerType_String,
                                              (uint)steamInfo.TrackedPose.GetDeviceIndex());
            if (style == "oculus_touch")
            {
                App.VrSdk.SetControllerStyle(ControllerStyle.OculusTouch);
            }
            else if (style == "knuckles")
            {
                App.VrSdk.SetControllerStyle(ControllerStyle.Knuckles);
            }
            else if (style == "vive_controller" || style == "vive_pro")
            {
                App.VrSdk.SetControllerStyle(ControllerStyle.Vive);
            }
            else if (style == "vive_cosmos_controller")
            {
                App.VrSdk.SetControllerStyle(ControllerStyle.OculusTouch);
            }
            else if (style == "wmr")
            {
                App.VrSdk.SetControllerStyle(ControllerStyle.Wmr);
            }
            else
            {
                // Not recognized.  This is not necessarily bad.
                return(false);
            }
            return(true);
        }
示例#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());
            }
        }
示例#3
0
 public GetVrInputHelper(SteamControllerInfo owner, bool currentFrame)
 {
     m_index        = owner.TrackedPose.inputSource;
     m_currentFrame = currentFrame;
 }