Exemple #1
0
        public bool AnalogIsStick(InputManager.ControllerName name)
        {
            var style = VrControls.GetBehavior(name).ControllerGeometry.Style;

            return(style == ControllerStyle.Wmr ||
                   style == ControllerStyle.OculusTouch ||
                   style == ControllerStyle.Knuckles ||
                   style == ControllerStyle.Cosmos);
        }
Exemple #2
0
        // Swap the hand that each ControllerInfo is associated with
        // TODO: if the tracking were associated with the Geometry rather than the Info+Behavior,
        // we wouldn't have to do any swapping. So rather than putting Behaviour_Pose on the Behavior,
        // we should dynamically add it when creating the Geometry. This might make the Behavior
        // prefabs VRAPI-agnostic, too.
        public bool TrySwapLeftRightTracking()
        {
            bool leftRightSwapped = true;

            if (App.Config.m_SdkMode == SdkMode.Oculus)
            {
                VrControls.GetComponent <OculusHandTrackingManager>().SwapLeftRight();
            }
            else if (App.Config.m_SdkMode == SdkMode.SteamVR)
            {
                // Don't swap controller input sources while we're initializing because it screws up
                // the actions when the proper controllers are instantiated.
                // TODO : Figure out why this screws up and fix it.  Note that this is
                // unnecessary unless we support hot-swapping of controller types.
                if (!IsInitializingSteamVr)
                {
                    BaseControllerBehavior[] behaviors = VrControls.GetBehaviors();
                    for (int i = 0; i < behaviors.Length; ++i)
                    {
                        SteamVR_Behaviour_Pose pose = behaviors[i].GetComponent <SteamVR_Behaviour_Pose>();
                        switch (pose.inputSource)
                        {
                        case SteamVR_Input_Sources.LeftHand:
                            pose.inputSource = SteamVR_Input_Sources.RightHand;
                            break;

                        case SteamVR_Input_Sources.RightHand:
                            pose.inputSource = SteamVR_Input_Sources.LeftHand;
                            break;

                        default:
                            Debug.LogWarningFormat(
                                "Controller is configured as {0}.  Should be LeftHand or RightHand.",
                                pose.inputSource);
                            break;
                        }
                    }
                }
                else
                {
                    // Don't commit to swapping controller styles.
                    leftRightSwapped = false;
                }
            }
            else if (App.Config.m_SdkMode == SdkMode.Gvr)
            {
                var tmp = InputManager.Controllers[0];
                InputManager.Controllers[0] = InputManager.Controllers[1];
                InputManager.Controllers[1] = tmp;
            }

            return(leftRightSwapped);
        }