Ejemplo n.º 1
0
        private void UpdateFromGamepad(Transform referenceObj, GamepadInput gamepad)
        {
            float referenceAngle = (referenceObj != null) ? referenceObj.Angle : 0.0f;

            if (gamepad.LeftThumbstick.Length > 0.25f)
            {
                float mappedLength = (gamepad.LeftThumbstick.Length - 0.25f) / 0.75f;
                this.controlMovement = gamepad.LeftThumbstick * mappedLength / gamepad.LeftThumbstick.Length;
            }
            else
            {
                this.controlMovement = Vector2.Zero;
            }

            if (gamepad.RightThumbstick.Length > 0.5f)
            {
                this.controlLookAngle = gamepad.RightThumbstick.Angle;
                this.controlLookSpeed = (gamepad.RightThumbstick.Length - 0.5f) / 0.5f;
            }
            else if (gamepad.LeftThumbstick.Length > 0.25f)
            {
                this.controlLookAngle = gamepad.LeftThumbstick.Angle;
                this.controlLookSpeed = (gamepad.LeftThumbstick.Length - 0.25f) / 0.75f;
            }

            bool targetAimed = MathF.CircularDist(referenceAngle, this.controlLookAngle) < MathF.RadAngle1 * 10;

            this.controlFireWeapon =
                (targetAimed && gamepad.RightThumbstick.Length > 0.9f) ||
                gamepad[GamepadAxis.RightTrigger] > 0.5f ||
                gamepad[GamepadButton.RightShoulder] ||
                gamepad[GamepadButton.A];
            this.controlQuit  = gamepad.ButtonHit(GamepadButton.Back);
            this.controlStart = gamepad.ButtonHit(GamepadButton.Start);
        }
Ejemplo n.º 2
0
    public void Update()
    {
        if (GamepadInput.GetDown(InputOption.Y_BUTTON) && CAVECameraRig.instance != null)
        {
            CAVECameraRig.instance.Toggle3D();
        }

        if (GamepadInput.GetDown(InputOption.B_BUTTON))
        {
            Debug.Log("HOME PRESSED");
            // Loads the first scene. Assumed to be the home scene.
            StartCoroutine(GoHome());
        }

        if (GamepadInput.GetDown(InputOption.X_BUTTON))
        {
            if (InfoCanvas.infoText == "")
            {
                InfoCanvas.infoText = SiteManager.activeSiteElement.GetDescription();
            }
            else
            {
                InfoCanvas.infoText = "";
            }
        }

        if (GamepadInput.GetDown(InputOption.A_BUTTON))
        {
            if (SiteManager.activeSiteElementSet != null)
            {
                SiteManager.activeSiteElementSet.NextElement();
            }
        }
    }
Ejemplo n.º 3
0
 private void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
 }
        public static bool GetFretInput(this GamepadInput gamepad, Note.GuitarFret fret)
        {
            switch (fret)
            {
            case (Note.GuitarFret.Green):
                return(gamepad.GetButton(GamepadInput.Button.A));

            case (Note.GuitarFret.Red):
                return(gamepad.GetButton(GamepadInput.Button.B));

            case (Note.GuitarFret.Yellow):
                return(gamepad.GetButton(GamepadInput.Button.Y));

            case (Note.GuitarFret.Blue):
                return(gamepad.GetButton(GamepadInput.Button.X));

            case (Note.GuitarFret.Orange):
                return(gamepad.GetButton(GamepadInput.Button.LB));

            case (Note.GuitarFret.Open):
                return(false);

            default:
                Debug.LogError("Unhandled note type for guitar input: " + fret);
                break;
            }

            return(false);
        }
Ejemplo n.º 5
0
    public void CheckForInput()
    {
        if (GamepadInput.GetDown(InputOption.B_BUTTON))
        {
            Debug.Log("B button was pressed down! Going back one level.");

            SceneManager.LoadScene("Main");
        }

        if (GamepadInput.GetDown(InputOption.START_BUTTON))
        {
            Debug.Log("The start button was pressed down! Going back to Main Menu");

            SceneManager.LoadScene("Main");
        }

        if (GamepadInput.Get(InputOption.LEFT_STICK_HORIZONTAL))
        {
            float stickValue = GamepadInput.GetInputValue(InputOption.LEFT_STICK_HORIZONTAL);

            if (stickValue > 0)
            {
                Debug.Log("Left analog stick pushed to the right!");
            }
            else if (stickValue < 0)
            {
                Debug.Log("Left analog stick pushed to the left!");
            }
        }
    }
Ejemplo n.º 6
0
    void Update()
    {
        // Configure collisions and choose to update the hit window or not
        if (Globals.applicationMode == Globals.ApplicationMode.Playing && !GameSettings.bot)
        {
            transform.localScale = new Vector3(transform.localScale.x, initSize, transform.localScale.z);
        }
        else
        {
            transform.localScale = new Vector3(transform.localScale.x, 0, transform.localScale.z);
        }

        // Gameplay
        if (Globals.applicationMode == Globals.ApplicationMode.Playing && !GameSettings.bot)
        {
            float        currentTime = editor.currentVisibleTime;
            GamepadInput gamepad     = editor.inputManager.mainGamepad;

            if (editor.currentChart.gameMode == Chart.GameMode.Guitar)
            {
                guitarGameplayRulestate.Update(currentTime, hitWindowFeeder.guitarHitWindow, gamepad);
                UpdateUIStats(guitarGameplayRulestate);
            }
            else if (editor.currentChart.gameMode == Chart.GameMode.Drums)
            {
                drumsGameplayRulestate.Update(currentTime, hitWindowFeeder.drumsHitWindow, gamepad);
                UpdateUIStats(drumsGameplayRulestate);
            }
            else
            {
                Debug.LogError("Gameplay currently does not support this gamemode.");
            }
        }
    }
Ejemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        // The platform should only move if no POI is selected and the bookmarks aren't being used.
        if (POIManager.selectedPOI == null && !BookmarkController.bookmarkPanelActive)
        {
            // Rotates the platform horizontally.
            if (GamepadInput.Get(horizontalRotationInput))
            {
                RotatePlatformHorizontally(GamepadInput.GetInputValue(horizontalRotationInput));
            }

            // Rotates the platform vertically.
            if (GamepadInput.Get(verticalRotationInput))
            {
                RotatePlatformVertically(GamepadInput.GetInputValue(verticalRotationInput));
            }

            // Moves the platform horizontally.
            if (GamepadInput.Get(horizontalMovementInput))
            {
                MovePlatform(GamepadInput.GetInputValue(horizontalMovementInput), transform.right);
            }

            // Moves the platform forward.
            if (GamepadInput.Get(forwardMovementInput))
            {
                MovePlatform(GamepadInput.GetInputValue(forwardMovementInput), transform.forward);
            }
        }
    }
Ejemplo n.º 8
0
 void Update()
 {
     if (GamepadInput.ColorMixed())
     {
         if (CurrentColorInput != ColorInput.ColorMixed)
         {
             UpdateColors(ColorInput.ColorMixed);
         }
     }
     else if (GamepadInput.Color2())
     {
         if (CurrentColorInput != ColorInput.Color2)
         {
             UpdateColors(ColorInput.Color2);
         }
     }
     else if (GamepadInput.Color1())
     {
         if (CurrentColorInput != ColorInput.Color1)
         {
             UpdateColors(ColorInput.Color1);
         }
     }
     else
     {
         if (CurrentColorInput != ColorInput.None)
         {
             UpdateColors(ColorInput.None);
         }
     }
 }
Ejemplo n.º 9
0
    float lerpedWhammyVal(GamepadInput gamepad)
    {
        float rawVal = -1;

        if (gamepad.connected)
        {
            rawVal = gamepad.GetWhammyInput();
        }

        if (!canWhammy)
        {
            currentWhammyVal = -1;
        }
        else
        {
            if (rawVal > currentWhammyVal)
            {
                currentWhammyVal += whammyLerpSpeed * Time.deltaTime;
                if (currentWhammyVal > rawVal)
                {
                    currentWhammyVal = rawVal;
                }
            }
            else if (rawVal.Round(2) < currentWhammyVal)
            {
                currentWhammyVal -= whammyLerpSpeed * Time.deltaTime;
                if (currentWhammyVal < rawVal)
                {
                    currentWhammyVal = rawVal;
                }
            }
        }

        return(currentWhammyVal);
    }
    public void Update(float time, GuitarSustainHitKnowledge sustainKnowledge, GamepadInput guitarInput, uint noteStreak)
    {
        var currentSustains = sustainKnowledge.currentSustains;

        int inputMask            = guitarInput.GetFretInputMaskControllerOrKeyboard();
        int extendedSustainsMask = sustainKnowledge.extendedSustainsMask;

        int shiftCount;
        int shiftedExtendedSustainsMask = GameplayInputFunctions.BitshiftToIgnoreLowerUnusedFrets(extendedSustainsMask, out shiftCount);

        foreach (GuitarSustainHitKnowledge.SustainKnowledge sustain in currentSustains.ToArray())     // Take a copy so we can remove as we go
        {
            if (noteStreak == 0)
            {
                BreakSustain(time, sustain);
            }
            else if (extendedSustainsMask != 0)
            {
                int shiftedInputMask = inputMask >> shiftCount;

                if ((shiftedInputMask & ~shiftedExtendedSustainsMask) != 0)
                {
                    BreakSustain(time, sustain);
                }
            }
            else if (!GameplayInputFunctions.ValidateFrets(sustain.note, inputMask, noteStreak))
            {
                BreakSustain(time, sustain);
            }
        }
    }
Ejemplo n.º 11
0
 public void OnInputReceived(GamepadInput input, InputAction.CallbackContext context)
 {
     if (input == GamepadInput.RightStick)
     {
         rawLook = context.action.ReadValue <Vector2>();
     }
 }
Ejemplo n.º 12
0
        public void OnInputReceived(GamepadInput input, InputAction.CallbackContext context)
        {
            switch (input)
            {
            case GamepadInput.LeftStick:
                moveInput = context.action.ReadValue <Vector2>();
                UpdateMoveInput();
                break;

            case GamepadInput.SouthButton:
                if (context.started)
                {
                    interactAbility.Interact();
                }
                break;

            case GamepadInput.NorthButton:
                if (context.started)
                {
                    jumpAbility.StartJump();
                }
                else if (context.canceled)
                {
                    jumpAbility.EndJump();
                }
                break;

            case GamepadInput.RightTrigger:
                moveAbility.SetIsRunning(context.ReadValueAsButton());
                break;
            }
        }
Ejemplo n.º 13
0
        private string GetInputStatsText(GamepadInput input)
        {
            // Determine all pressed gamepad buttons
            string activeButtons = "";

            foreach (GamepadButton button in Enum.GetValues(typeof(GamepadButton)))
            {
                if (input.ButtonPressed(button))
                {
                    if (activeButtons.Length != 0)
                    {
                        activeButtons += ", ";
                    }
                    activeButtons += button.ToString();
                }
            }

            return
                (string.Format("Id: /cFF8800FF{0}/cFFFFFFFF/n", input.Id) +
                 string.Format("ProductId: /cFF8800FF{0}/cFFFFFFFF/n", input.ProductId) +
                 string.Format("ProductName: /cFF8800FF{0}/cFFFFFFFF/n", input.ProductName) +
                 string.Format("IsAvailable: /cFF8800FF{0}/cFFFFFFFF/n", input.IsAvailable) +
                 string.Format("Buttons:          /c44AAFFFF{0}/cFFFFFFFF/n", activeButtons) +
                 string.Format("Left  Trigger:    /c44AAFFFF{0}/cFFFFFFFF/n", input.LeftTrigger) +
                 string.Format("Left  Thumbstick: /c44AAFFFF{0}/cFFFFFFFF/n", input.LeftThumbstick) +
                 string.Format("Right Trigger:    /c44AAFFFF{0}/cFFFFFFFF/n", input.RightTrigger) +
                 string.Format("Right Thumbstick: /c44AAFFFF{0}/cFFFFFFFF/n", input.RightThumbstick) +
                 string.Format("Directional Pad:  /c44AAFFFF{0}/cFFFFFFFF", input.DPad));
        }
Ejemplo n.º 14
0
    public void MovePhotosOnInput(GamepadInput.InputOption input)
    {
        float stickValue = GamepadInput.GetInputValue(input);

        if (input == GamepadInput.InputOption.LEFT_STICK_HORIZONTAL || input == GamepadInput.InputOption.RIGHT_STICK_HORIZONTAL)
        {
            if (stickValue < 0)
            {
                MoveLeft();
            }
            else
            {
                MoveRight();
            }
        }
        else if (input == GamepadInput.InputOption.LEFT_STICK_VERTICAL || input == GamepadInput.InputOption.RIGHT_STICK_VERTICAL)
        {
            if (stickValue < 0)
            {
                MoveDown();
            }
            else
            {
                MoveUp();
            }
        }
    }
Ejemplo n.º 15
0
        public void Update()
        {
            lock (_lock)
            {
                List <GamepadInput> hleInputStates  = new List <GamepadInput>();
                List <SixAxisInput> hleMotionStates = new List <SixAxisInput>(NpadDevices.MaxControllers);

                KeyboardInput?hleKeyboardInput = null;

                foreach (InputConfig inputConfig in _inputConfig)
                {
                    GamepadInput inputState  = default;
                    SixAxisInput motionState = default;

                    NpadController controller = _controllers[(int)inputConfig.PlayerIndex];

                    // Do we allow input updates and is a controller connected?
                    if (!_blockInputUpdates && controller != null)
                    {
                        DriverConfigurationUpdate(ref controller, inputConfig);

                        controller.UpdateUserConfiguration(inputConfig);
                        controller.Update();

                        inputState = controller.GetHLEInputState();

                        inputState.Buttons |= _device.Hid.UpdateStickButtons(inputState.LStick, inputState.RStick);

                        motionState = controller.GetHLEMotionState();

                        if (_enableKeyboard)
                        {
                            hleKeyboardInput = controller.GetHLEKeyboardInput();
                        }
                    }
                    else
                    {
                        // Ensure that orientation isn't null
                        motionState.Orientation = new float[9];
                    }

                    inputState.PlayerId  = (Ryujinx.HLE.HOS.Services.Hid.PlayerIndex)inputConfig.PlayerIndex;
                    motionState.PlayerId = (Ryujinx.HLE.HOS.Services.Hid.PlayerIndex)inputConfig.PlayerIndex;

                    hleInputStates.Add(inputState);
                    hleMotionStates.Add(motionState);
                }

                _device.Hid.Npads.Update(hleInputStates);
                _device.Hid.Npads.UpdateSixAxis(hleMotionStates);

                if (hleKeyboardInput.HasValue)
                {
                    _device.Hid.Keyboard.Update(hleKeyboardInput.Value);
                }

                _device.TamperMachine.UpdateInput(hleInputStates);
            }
        }
    // Update is called once per frame
    void Update()
    {
        if (Globals.applicationMode == Globals.ApplicationMode.Playing && !GameSettings.bot)
        {
            ChartEditor    editor   = ChartEditor.Instance;
            GamepadInput   input    = editor.inputManager.mainGamepad;
            Chart.GameMode gameMode = editor.currentChart.gameMode;
            LaneInfo       laneInfo = editor.laneInfo;

            if (gameMode == Chart.GameMode.Drums)
            {
                foreach (Note.DrumPad drumPad in System.Enum.GetValues(typeof(Note.DrumPad)))
                {
                    if (bannedDrumPadInputs.ContainsKey(drumPad))
                    {
                        continue;
                    }

                    if (input.GetPadInputControllerOrKeyboard(drumPad, laneInfo))
                    {
                        animations[(int)drumPad].Press();
                    }
                    else
                    {
                        animations[(int)drumPad].Release();
                    }
                }
            }
            else
            {
                foreach (Note.GuitarFret fret in System.Enum.GetValues(typeof(Note.GuitarFret)))
                {
                    if (bannedFretInputs.ContainsKey(fret))
                    {
                        continue;
                    }

                    if (input.GetFretInputControllerOrKeyboard(fret))
                    {
                        animations[(int)fret].Press();
                    }
                    else
                    {
                        animations[(int)fret].Release();
                    }
                }
            }
        }
        else
        {
            for (int i = 0; i < animations.Length; ++i)
            {
                if (!animations[i].running)
                {
                    animations[i].Release();
                }
            }
        }
    }
Ejemplo n.º 17
0
 // Start is called before the first frame update
 void Start()
 {
     animator     = GetComponent <Animator>();
     player       = GetComponent <Player>();
     gamepadInput = GetComponent <GamepadInput>();
     controller   = GetComponent <Controller2D>();
     renderers    = GetComponentsInChildren <SpriteRenderer>();
 }
Ejemplo n.º 18
0
 // Start is called before the first frame update
 void Start()
 {
     Input       = GetComponent <GamepadInput>();
     ZoomIn      = true;
     ZoomOut     = false;
     RotateLeft  = true;
     RotateRight = false;
 }
Ejemplo n.º 19
0
 private bool DetectGamepad(GamepadInput gamepad)
 {
     return
         (gamepad.LeftThumbstick.Length > 0.5f ||
          gamepad.RightThumbstick.Length > 0.5f ||
          gamepad[GamepadAxis.RightTrigger] > 0.5f ||
          gamepad[GamepadButton.RightShoulder]);
 }
Ejemplo n.º 20
0
 public MainMenu(GameManager game, KeyboardInput keyboardInput, GamepadInput gamepadInput)
 {
     this.game          = game;
     selectionBox       = new Rectangle(x, y, 60, 40);
     this.keyboardInput = keyboardInput;
     this.gamepadInput  = gamepadInput;
     text = new Text(game.getGame1(), game.SCALE * 2);
 }
Ejemplo n.º 21
0
 public bool GetButtonUp(int joystick, GamepadInput button)
 {
     if (!inputMap.ContainsKey(button))
     {
         return(false);
     }
     return(Input.GetKeyUp(GetMappedKeyCode(joystick, button)));
 }
Ejemplo n.º 22
0
 public void SetGamepadInput(GamepadInput gamepadInput)
 {
     _gamepadInput = gamepadInput;
     _playerCharacterGameObject = Instantiate(playerCharacterPrefab, transform);
     _playerCharacter           = _playerCharacterGameObject.GetComponent <PlayerCharacter>();
     // Hide A button
     transform.GetChild(0).gameObject.SetActive(false);
     _audioSource.PlayOneShot(audioClipSelectCharacter, 1f);
 }
Ejemplo n.º 23
0
    private void Update()
    {
        CheckIfPOISelected();

        if (selectedPOI != null && GamepadInput.GetDown(GamepadInput.InputOption.B_BUTTON))
        {
            selectedPOI.Deactivate();
        }
    }
Ejemplo n.º 24
0
        protected override void Start()
        {
            base.Start();

            gamepadInput    = GetComponent <GamepadInput>();
            mouseInput      = GetComponent <MouseInput>();
            playerAnimation = GetComponent <PlayerAnimation3D>();
            checkInputMode();
        }
        private void SelectSlot(GamepadInput gamepadInput)
        {
            CharacterSelect characterSelect = GameState.Instance.characterSelects[_slots.Count + 1];

            characterSelect.SetGamepadInput(gamepadInput);
            _slots.Add(new PlayerSlot {
                GamepadInput = gamepadInput, CharacterSelect = characterSelect
            });
        }
Ejemplo n.º 26
0
        public void Update(float aspectRatio = 0)
        {
            lock (_lock)
            {
                List <GamepadInput> hleInputStates  = new List <GamepadInput>();
                List <SixAxisInput> hleMotionStates = new List <SixAxisInput>(NpadDevices.MaxControllers);

                KeyboardInput?hleKeyboardInput = null;

                foreach (InputConfig inputConfig in _inputConfig)
                {
                    GamepadInput inputState = default;
                    (SixAxisInput, SixAxisInput)motionState = default;

                    NpadController controller = _controllers[(int)inputConfig.PlayerIndex];
                    Ryujinx.HLE.HOS.Services.Hid.PlayerIndex playerIndex = (Ryujinx.HLE.HOS.Services.Hid.PlayerIndex)inputConfig.PlayerIndex;

                    bool isJoyconPair = false;

                    // Do we allow input updates and is a controller connected?
                    if (!_blockInputUpdates && controller != null)
                    {
                        DriverConfigurationUpdate(ref controller, inputConfig);

                        controller.UpdateUserConfiguration(inputConfig);
                        controller.Update();
                        controller.UpdateRumble(_device.Hid.Npads.GetRumbleQueue(playerIndex));

                        inputState = controller.GetHLEInputState();

                        inputState.Buttons |= _device.Hid.UpdateStickButtons(inputState.LStick, inputState.RStick);

                        isJoyconPair = inputConfig.ControllerType == Common.Configuration.Hid.ControllerType.JoyconPair;

                        var altMotionState = isJoyconPair ? controller.GetHLEMotionState(true) : default;

                        motionState = (controller.GetHLEMotionState(), altMotionState);

                        if (_enableKeyboard)
                        {
                            hleKeyboardInput = controller.GetHLEKeyboardInput();
                        }
                    }
                    else
                    {
                        // Ensure that orientation isn't null
                        motionState.Item1.Orientation = new float[9];
                    }

                    inputState.PlayerId        = playerIndex;
                    motionState.Item1.PlayerId = playerIndex;

                    hleInputStates.Add(inputState);
                    hleMotionStates.Add(motionState.Item1);

                    if (isJoyconPair && !motionState.Item2.Equals(default))
Ejemplo n.º 27
0
    void Update()
    {
        if (_currentGamepads != null)
        {
            for (int i = 0; i < _currentGamepads.Length; i++)
            {
                float h = GamepadInput.GetAxis("Horizontal", _currentGamepads[i].Type, _currentGamepads[i].Id);
                float v = GamepadInput.GetAxis("Vertical", _currentGamepads[i].Type, _currentGamepads[i].Id);

                playerPanels[i].h.text  = "H = " + h.ToString("0.00");
                playerPanels[i].h.color = (h == 0f ? Color.black : Color.red);

                playerPanels[i].v.text  = "V = " + v.ToString("0.00");
                playerPanels[i].v.color = (v == 0f ? Color.black : Color.red);

                bool f1 = GamepadInput.GetButton("Fire1", _currentGamepads[i].Type, _currentGamepads[i].Id);
                bool f2 = GamepadInput.GetButton("Fire2", _currentGamepads[i].Type, _currentGamepads[i].Id);
                bool f3 = GamepadInput.GetButton("Fire3", _currentGamepads[i].Type, _currentGamepads[i].Id);
                bool f4 = GamepadInput.GetButton("Fire4", _currentGamepads[i].Type, _currentGamepads[i].Id);
                bool f5 = GamepadInput.GetButton("Fire5", _currentGamepads[i].Type, _currentGamepads[i].Id);
                bool f6 = GamepadInput.GetButton("Fire6", _currentGamepads[i].Type, _currentGamepads[i].Id);

                playerPanels[i].f1.color = (f1 ? Color.red : Color.black);
                playerPanels[i].f2.color = (f2 ? Color.red : Color.black);
                playerPanels[i].f3.color = (f3 ? Color.red : Color.black);
                playerPanels[i].f4.color = (f4 ? Color.red : Color.black);
                playerPanels[i].f5.color = (f5 ? Color.red : Color.black);
                playerPanels[i].f6.color = (f6 ? Color.red : Color.black);

                if (_currentGamepads[i].Player == Player.One)
                {
                    string submit = GamepadInput.GetButtonForUI("Submit", _currentGamepads[i].Type, _currentGamepads[i].Id);
                    string cancel = GamepadInput.GetButtonForUI("Cancel", _currentGamepads[i].Type, _currentGamepads[i].Id);

                    bool sValue = Input.GetButtonDown(submit);
                    bool cValue = Input.GetButtonDown(cancel);

                    playerPanels[i].submit.color = (sValue ? Color.red : Color.black);
                    playerPanels[i].cancel.color = (cValue ? Color.red : Color.black);

                    bool start = GamepadInput.GetButton("Start", _currentGamepads[i].Type, _currentGamepads[i].Id);

                    if (f5 && f6 && start)
                    {
                        gameObject.SetActive(false);
                        prevScreen.SetActive(true);

                        if (_prevButton != null)
                        {
                            EventSystem.current.SetSelectedGameObject(_prevButton);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 28
0
    // Update is called once per frame
    void Update()
    {
        // If the A button is pressed, select the active button.
        if (GamepadInput.GetDown(InputOption.A_BUTTON))
        {
            // If there's no selected element, we first must choose a site. Otherwise, select the data type.
            if (selectedElementIndex < 0)
            {
                SelectSiteButton(siteButtons[selectedSiteIndex]);
            }
            else
            {
                SelectSiteSetButton(siteElementButtons[selectedElementIndex]);
            }
        }

        // If B is pressed, go back and deselect the active element.
        if (GamepadInput.GetDown(InputOption.B_BUTTON))
        {
            ClearElementButtons();
        }

        // If the right stick is pushed, move buttons left or right.
        if (GamepadInput.GetDown(InputOption.LEFT_STICK_HORIZONTAL))
        {
            // The direction of the stick. Helps us determine what direction it was pushed.
            float stickValue = GamepadInput.GetInputValue(InputOption.LEFT_STICK_HORIZONTAL);

            // If pushed to the right, move selected button to the right.
            if (stickValue > 0)
            {
                // If there's no selected element, move the site buttons. Otherwise move the data type buttons.
                if (selectedElementIndex < 0)
                {
                    MoveSiteButtons(1);
                }
                else
                {
                    MoveElementButtons(1);
                }
            }

            // If pushed to the left, move selected button to the left.
            else if (stickValue < 0)
            {
                if (selectedElementIndex < 0)
                {
                    MoveSiteButtons(-1);
                }
                else
                {
                    MoveElementButtons(-1);
                }
            }
        }
    }
Ejemplo n.º 29
0
 // Update is called once per frame
 void Update()
 {
     if (GamepadInput.Pause())
     {
         if (TutorialMenu.activeSelf || LevelMenu.activeSelf)
         {
             GoToMainMenu();
         }
     }
 }
            public ParticleTestManager(State stateref)
                : base(stateref, "ParticleTestManager")
            {
                _controlHandler = stateref.GetService <ControlHandler>();
                _body           = new Body(this, "EmitterBody");
                Spawner         = new TestSpawner(this, "Spawner");

                _moveCursor = new GamePadAnalog(this, "MoveCursor", Sticks.Left, PlayerIndex.One);
                _emitButton = new GamepadInput(this, "EmitButton", Buttons.B, PlayerIndex.One);
            }
    public GamepadAxisControlSignal(
		GamepadInput.GamePad.Index gamepadIndex,
		GamepadInput.GamePad.Axis axis,
		Dimension dimension,
		float factor,
		bool circularBoundary = false)
        : base()
    {
        mGamepadIndex = gamepadIndex;
        mAxis = axis;
        mDimension = dimension;
        mFactor = factor;
        mCircularBoundary = circularBoundary;
    }
Ejemplo n.º 32
0
 public static ButtonState GetButton(this GamePadState state, GamepadInput.GamePad.Button button)
 {
     ButtonState ret;
     switch (button)
     {
         case GamePad.Button.A:
             ret = state.Buttons.A;
             break;
         case GamePad.Button.B:
             ret = state.Buttons.B;
             break;
         case GamePad.Button.Back:
             ret = state.Buttons.Back;
             break;
         case GamePad.Button.LeftShoulder:
             ret = state.Buttons.LeftShoulder;
             break;
         case GamePad.Button.LeftStick:
             ret = state.Buttons.LeftStick;
             break;
         case GamePad.Button.RightShoulder:
             ret = state.Buttons.RightShoulder;
             break;
         case GamePad.Button.RightStick:
             ret = state.Buttons.RightStick;
             break;
         case GamePad.Button.Start:
             ret = state.Buttons.Start;
             break;
         case GamePad.Button.X:
             ret = state.Buttons.X;
             break;
         case GamePad.Button.Y:
             ret = state.Buttons.Y;
             break;
         default:
             ret = ButtonState.Released;
             Debug.LogError("ButtonNotFound");
             break;
     }
     return ret;
 }
Ejemplo n.º 33
0
		private bool DetectGamepad(GamepadInput gamepad)
		{
			return 
				gamepad.LeftThumbstick.Length > 0.5f || 
				gamepad.RightThumbstick.Length > 0.5f ||
				gamepad[GamepadAxis.RightTrigger] > 0.5f ||
				gamepad[GamepadButton.RightShoulder];
		}
Ejemplo n.º 34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GamepadBinding"/> class.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="input">The input.</param>
 public GamepadBinding(ICommand command, GamepadInput input)
     : this(command, new GamepadGesture(input))
 {
 }        
Ejemplo n.º 35
0
		private void UpdateFromGamepad(Transform referenceObj, GamepadInput gamepad)
		{
			float referenceAngle = (referenceObj != null) ? referenceObj.Angle : 0.0f;

			if (gamepad.LeftThumbstick.Length > 0.25f)
			{
				float mappedLength = (gamepad.LeftThumbstick.Length - 0.25f) / 0.75f;
				this.controlMovement = gamepad.LeftThumbstick * mappedLength / gamepad.LeftThumbstick.Length;
			}
			else
			{
				this.controlMovement = Vector2.Zero;
			}

			if (gamepad.RightThumbstick.Length > 0.5f)
			{
				this.controlLookAngle = gamepad.RightThumbstick.Angle;
				this.controlLookSpeed = (gamepad.RightThumbstick.Length - 0.5f) / 0.5f;
			}
			else if (gamepad.LeftThumbstick.Length > 0.25f)
			{
				this.controlLookAngle = gamepad.LeftThumbstick.Angle;
				this.controlLookSpeed = (gamepad.LeftThumbstick.Length - 0.25f) / 0.75f;
			}

			bool targetAimed = MathF.CircularDist(referenceAngle, this.controlLookAngle) < MathF.RadAngle1 * 10;
			this.controlFireWeapon = 
				(targetAimed && gamepad.RightThumbstick.Length > 0.9f) ||
				gamepad[GamepadAxis.RightTrigger] > 0.5f ||
				gamepad[GamepadButton.RightShoulder] ||
				gamepad[GamepadButton.A];
			this.controlQuit = gamepad.ButtonHit(GamepadButton.Back);
			this.controlStart = gamepad.ButtonHit(GamepadButton.Start);
		}
Ejemplo n.º 36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GamepadGesture"/> class.
 /// </summary>
 /// <param name="gamepadInput">The game pad input.</param>
 public GamepadGesture(GamepadInput gamepadInput)
 {
     GamepadInput = gamepadInput;
 }
Ejemplo n.º 37
0
		private string GetInputStatsText(GamepadInput input)
		{
			// Determine all pressed gamepad buttons
			string activeButtons = "";
			foreach (GamepadButton button in Enum.GetValues(typeof(GamepadButton)))
			{
				if (input.ButtonPressed(button))
				{
					if (activeButtons.Length != 0)
						activeButtons += ", ";
					activeButtons += button.ToString();
				}
			}

			return
				string.Format("Description: /cFF8800FF{0}/cFFFFFFFF/n", input.Description) +
				string.Format("IsAvailable: /cFF8800FF{0}/cFFFFFFFF/n", input.IsAvailable) +
				string.Format("Buttons:          /c44AAFFFF{0}/cFFFFFFFF/n", activeButtons) +
				string.Format("Left  Trigger:    /c44AAFFFF{0}/cFFFFFFFF/n", input.LeftTrigger) +
				string.Format("Left  Thumbstick: /c44AAFFFF{0}/cFFFFFFFF/n", input.LeftThumbstick) +
				string.Format("Right Trigger:    /c44AAFFFF{0}/cFFFFFFFF/n", input.RightTrigger) +
				string.Format("Right Thumbstick: /c44AAFFFF{0}/cFFFFFFFF/n", input.RightThumbstick) +
				string.Format("Directional Pad:  /c44AAFFFF{0}/cFFFFFFFF", input.DPad);
		}