Esempio n. 1
0
        private void MapKeyboardMouse(Keyboard keyboard)
        {
            var mouse = Mouse.current;

            if (keyboard == null || mouse == null)
            {
                return;
            }

            Left_Axis?.Invoke(_keyboardMove);
            _keyboardMove = Vector2.zero;
            Right_Axis?.Invoke(mouse.position.ReadValue());

            if (mouse.leftButton.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_LT);
            }
            if (mouse.leftButton.wasReleasedThisFrame)
            {
                EnqueueInput(InputKey.Button_LT, false);
            }

            if (mouse.rightButton.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_RT);
            }
            if (mouse.rightButton.wasReleasedThisFrame)
            {
                EnqueueInput(InputKey.Button_RT, false);
            }
        }
Esempio n. 2
0
        protected virtual void GetInputs(Gamepad gamepad)
        {
            IsKeyboardMouse = gamepad == null;
            if (gamepad == null)
            {
                MapKeyboardMouse(Keyboard.current);

                return;
            }


            if (gamepad.aButton.wasPressedThisFrame || gamepad.buttonSouth.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_A);
            }
            if (gamepad.aButton.wasReleasedThisFrame || gamepad.buttonSouth.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_A, false);
            }

            if (gamepad.bButton.wasPressedThisFrame || gamepad.buttonEast.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_B);
            }
            if (gamepad.bButton.wasReleasedThisFrame || gamepad.buttonEast.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_B, false);
            }

            if (gamepad.xButton.wasPressedThisFrame || gamepad.buttonWest.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_X);
            }
            if (gamepad.xButton.wasReleasedThisFrame || gamepad.buttonWest.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_X, false);
            }

            if (gamepad.yButton.wasPressedThisFrame || gamepad.buttonNorth.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_Y);
            }
            if (gamepad.yButton.wasReleasedThisFrame || gamepad.buttonNorth.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_Y, false);
            }


            if (gamepad.rightShoulder.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_RB);
            }
            if (gamepad.rightShoulder.wasReleasedThisFrame)
            {
                EnqueueInput(InputKey.Button_RB, false);
            }

            if (gamepad.rightTrigger.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_RT);
            }
            if (gamepad.rightTrigger.wasReleasedThisFrame)
            {
                EnqueueInput(InputKey.Button_RT, false);
            }

            if (gamepad.leftShoulder.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_LB);
            }
            if (gamepad.leftShoulder.wasReleasedThisFrame)
            {
                EnqueueInput(InputKey.Button_LB, false);
            }

            if (gamepad.leftTrigger.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_LT);
            }
            if (gamepad.leftTrigger.wasReleasedThisFrame)
            {
                EnqueueInput(InputKey.Button_LT, false);
            }


            if (gamepad.startButton.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_Start);
            }
            if (gamepad.startButton.wasReleasedThisFrame)
            {
                EnqueueInput(InputKey.Button_Start, false);
            }

            if (gamepad.selectButton.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_Select);
            }
            if (gamepad.selectButton.wasReleasedThisFrame)
            {
                EnqueueInput(InputKey.Button_Select, false);
            }


            if (gamepad.dpad.down.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_DPad_Down);
            }
            if (gamepad.dpad.down.wasReleasedThisFrame)
            {
                EnqueueInput(InputKey.Button_DPad_Down, false);
            }

            if (gamepad.dpad.up.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_DPad_Up);
            }
            if (gamepad.dpad.up.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_DPad_Up, false);
            }

            if (gamepad.dpad.left.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_DPad_Left);
            }
            if (gamepad.dpad.left.wasReleasedThisFrame)
            {
                EnqueueInput(InputKey.Button_DPad_Left, false);
            }

            if (gamepad.dpad.right.wasPressedThisFrame)
            {
                EnqueueInput(InputKey.Button_DPad_Right);
            }
            if (gamepad.dpad.right.wasReleasedThisFrame)
            {
                EnqueueInput(InputKey.Button_DPad_Right, false);
            }


            Left_Axis?.Invoke(gamepad.leftStick.ReadValue());
            Right_Axis?.Invoke(gamepad.rightStick.ReadValue());
        }