private IEnumerator Start()
        {
            if (TBInput.GetControllerModel(controller) == VRController.None)
            {
                Debug.Log("Input chart was disabled because no controller was found for " + controller + ". This means that the associated ControlType is disabled in TButt's Input Settings, or no compatible controller exists for the current platform.");
                gameObject.SetActive(false);
                yield break;
            }

            controllerLabel.text = controller.ToString() + " | " + TBInput.GetControllerModel(controller).ToString();
            _rect = GetComponent <RectTransform>();

            for (int i = 0; i < buttons.Count; i++)
            {
                if (TBInput.SupportsVirtualButton(buttons[i], controller))
                {
                    CreateDisplayRow(buttons[i]);
                }
            }

            ConformHeights();

            TBInput.ControlType assocaitedControlType = TBInput.ControlType.None;

            switch (controller)
            {
            case TBInput.Controller.LHandController:
            case TBInput.Controller.RHandController:
                assocaitedControlType = TBInput.ControlType.HandControllers;
                break;

            case TBInput.Controller.Mobile3DOFController:
                assocaitedControlType = TBInput.ControlType.Mobile3DOFController;
                break;

            case TBInput.Controller.Gamepad:
                assocaitedControlType = TBInput.ControlType.Gamepad;
                break;

            case TBInput.Controller.ClickRemote:
                assocaitedControlType = TBInput.ControlType.ClickRemote;
                break;
            }

            if (assocaitedControlType != TBInput.GetActiveControlType())
            {
                gameObject.GetComponent <Canvas>().enabled = false;

                while (TBInput.GetActiveControlType() == TBInput.ControlType.None)
                {
                    yield return(null);
                }

                if (assocaitedControlType == TBInput.GetActiveControlType())
                {
                    gameObject.GetComponent <Canvas>().enabled = true;
                }
            }
        }
 void Start()
 {
     if (TBInput.GetActiveControlType() != TBInput.ControlType.None)
     {
         gameObject.SetActive(false);
     }
     else
     {
         StartCoroutine(ChooseController());
     }
 }
Exemplo n.º 3
0
 private void OnEnable()
 {
     if (TBInput.GetActiveControlType() == TBInput.ControlType.None)
     {
         TBInput.Events.OnControlTypeChanged += OnControlTypeChanged;
         _subscribed = true;
     }
     else
     {
         gameObject.SetActive(false);
     }
 }
Exemplo n.º 4
0
 protected virtual IEnumerator RefreshInputRoutine()
 {
     switch (TBInput.GetActiveControlType())
     {
     case TBInput.ControlType.Mobile3DOFController:
         while (Get3DOFHandedness() == TBInput.Mobile3DOFHandedness.Center)
         {
             yield return(null);
         }
         TBInput.Events.Internal.UpdateHandedness(Get3DOFHandedness());
         break;
     }
 }
Exemplo n.º 5
0
 public override TBInput.Controller GetActiveController()
 {
     if (TBInput.GetActiveControlType() == TBInput.ControlType.HandControllers)
     {
         if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).SupportsPositionalTracking)
         {
             return(TBInput.Controller.RHandController);
         }
         else
         {
             return(TBInput.Controller.Mobile3DOFController);
         }
     }
     else
     {
         return(TBInput.Controller.Mobile3DOFController);
     }
 }
        private IEnumerator Start()
        {
            while (TBInput.GetActiveControlType() == TBInput.ControlType.None)
            {
                yield return(null);
            }

            switch (TBInput.GetActiveControlType())
            {
            case TBInput.ControlType.Mobile3DOFController:
                Instantiate(mobile3DOFController).name = "3DOF Controller";
                break;

            case TBInput.ControlType.HandControllers:
                Instantiate(leftHandController).name  = "Left Hand Controller";
                Instantiate(rightHandController).name = "Right Hand Controller";
                break;
            }
        }
Exemplo n.º 7
0
        public virtual TBInput.Controller GetActiveController()
        {
            switch (TBInput.GetActiveControlType())
            {
            case TBInput.ControlType.ClickRemote:
                return(TBInput.Controller.ClickRemote);

            case TBInput.ControlType.Gamepad:
                return(TBInput.Controller.Gamepad);

            case TBInput.ControlType.HandControllers:
                return(TBInput.Controller.RHandController);

            case TBInput.ControlType.Mobile3DOFController:
                return(TBInput.Controller.Mobile3DOFController);

            default:
                return(TBInput.Controller.None);
            }
        }
Exemplo n.º 8
0
        public override void Update()
        {
#if ENABLE_WINMD_SUPPORT
            if (Gamepad.Gamepads == null)
            {
                return;
            }
            if (Gamepad.Gamepads.Count > 0)
            {
                gamepad      = Gamepad.Gamepads[0];
                _prevReading = _reading;
                _reading     = gamepad.GetCurrentReading();
            }
#else
            if (!_playerIndexSet || !_prevState.IsConnected)
            {
                for (int i = 0; i < 4; ++i)
                {
                    PlayerIndex  testPlayerIndex = (PlayerIndex)i;
                    GamePadState testState       = GamePad.GetState(testPlayerIndex);
                    if (testState.IsConnected)
                    {
                        Debug.Log(string.Format("GamePad found {0}", testPlayerIndex));
                        playerIndex     = testPlayerIndex;
                        _playerIndexSet = true;
                    }
                }
            }

            if (TBInput.GetActiveControlType() == TBInput.ControlType.Gamepad)
            {
                GamePad.SetVibration(0, 0, 0);
            }

            _prevState = _state;
            _state     = GamePad.GetState(playerIndex);
#endif
        }
        private IEnumerator ChooseController()
        {
            if (!TBInput.SupportsControlType(controlType))
            {
                disabledImage.gameObject.SetActive(true);
                yield break;
            }

            while (TBInput.GetActiveControlType() == TBInput.ControlType.None)
            {
                switch (controlType)
                {
                case TBInput.ControlType.HandControllers:
                    AnimateHandControllers();
                    break;

                case TBInput.ControlType.ClickRemote:
                    AnimateInput(ref _selectionVal, TBInput.Controller.ClickRemote);
                    break;

                case TBInput.ControlType.Gamepad:
                    AnimateInput(ref _selectionVal, TBInput.Controller.Gamepad);
                    break;

                case TBInput.ControlType.Mobile3DOFController:
                    AnimateInput(ref _selectionVal, TBInput.Controller.Mobile3DOFController);
                    break;
                }

                if (_selectionVal >= 1)
                {
                    TBInput.SetActiveControlType(controlType);
                }

                yield return(null);
            }
        }