示例#1
0
    /// <summary>
    /// Converts string representation of CustomInput to CustomInput.
    /// </summary>
    /// <returns>CustomInput from string.</returns>
    /// <param name="value">String representation of CustomInput.</param>
    private static CustomInput CustomInputFromString(string value)
    {
        DebugEx.VerboseFormat("Controls.CustomInputFromString(value = {0})", value);

        CustomInput res;

        res = JoystickInput.FromString(value);

        if (res != null)
        {
            return(res);
        }

        res = MouseInput.FromString(value);

        if (res != null)
        {
            return(res);
        }

        res = KeyboardInput.FromString(value);

        if (res != null)
        {
            return(res);
        }

        return(null);
    }
示例#2
0
    public JoystickInput CreateDefaultJoystickBindings()
    {
        JoystickInput newJoystickInput = new JoystickInput();

        newJoystickInput.MoveUp.AddDefaultBinding(InputControlType.LeftStickUp);
        newJoystickInput.MoveDown.AddDefaultBinding(InputControlType.LeftStickDown);
        newJoystickInput.MoveLeft.AddDefaultBinding(InputControlType.LeftStickLeft);
        newJoystickInput.MoveRight.AddDefaultBinding(InputControlType.LeftStickRight);

        newJoystickInput.LookUp.AddDefaultBinding(InputControlType.RightStickUp);
        newJoystickInput.LookDown.AddDefaultBinding(InputControlType.RightStickDown);
        newJoystickInput.LookLeft.AddDefaultBinding(InputControlType.RightStickLeft);
        newJoystickInput.LookRight.AddDefaultBinding(InputControlType.RightStickRight);

        newJoystickInput.ActionButton.AddDefaultBinding(InputControlType.Action1);
        newJoystickInput.Start.AddDefaultBinding(InputControlType.Command);


        newJoystickInput.ListenOptions.OnBindingFound = (action, binding) => {
            if (binding == new KeyBindingSource(Key.Escape))
            {
                action.StopListeningForBinding();
                return(false);
            }
            return(true);
        };

        return(newJoystickInput);
    }
示例#3
0
 public Vector2 LeftAnalog()
 {
     if (keyboardEnabled)
     {
         int xValue = 0;
         if (Input.GetKey(KeyCode.A))
         {
             xValue--;
         }
         if (Input.GetKey(KeyCode.D))
         {
             xValue++;
         }
         int yValue = 0;
         if (Input.GetKey(KeyCode.S))
         {
             yValue--;
         }
         if (Input.GetKey(KeyCode.W))
         {
             yValue++;
         }
         return(new Vector2(xValue, yValue));
     }
     return(JoystickInput.LeftAnalog(state));
 }
示例#4
0
 private void Awake()
 {
     if (Hand == JoystickHand.Left)
     {
         if (Left == null)
         {
             Left = this;
         }
         else
         {
             Destroy(gameObject);
         }
     }
     else
     {
         if (Right == null)
         {
             Right = this;
         }
         else
         {
             Destroy(gameObject);
         }
     }
 }
示例#5
0
    /// <summary>
    /// Converts string representation of CustomInput to CustomInput.
    /// </summary>
    /// <returns>CustomInput from string.</returns>
    /// <param name="value">String representation of CustomInput.</param>
    private static CustomInput customInputFromString(string value)
    {
        CustomInput res;

        res = JoystickInput.FromString(value);

        if (res != null)
        {
            return(res);
        }

        res = MouseInput.FromString(value);

        if (res != null)
        {
            return(res);
        }

        res = KeyboardInput.FromString(value);

        if (res != null)
        {
            return(res);
        }

        return(null);
    }
示例#6
0
    public void SaveControlLayout(int joystickNum, int controlType)
    {
        GamePad gamepad = null;

        if (controlType == 0)
        {
            gamepad = controlA;
        }
        else if (controlType == 1)
        {
            gamepad = controlB;
        }

        KeyCode acceptKey     = GetJoystickButton(joystickNum, gamepad.accept);
        KeyCode backKey       = GetJoystickButton(joystickNum, gamepad.back);
        KeyCode returnDefault = GetJoystickButton(joystickNum, gamepad.returnDefault);
        KeyCode fireKey       = GetJoystickButton(joystickNum, gamepad.fire);
        KeyCode bombKey       = GetJoystickButton(joystickNum, gamepad.bomb);
        KeyCode reviveKey     = GetJoystickButton(joystickNum, gamepad.revive);
        KeyCode slowMoveKey   = GetJoystickButton(joystickNum, gamepad.slowMove);
        KeyCode pauseKey      = GetJoystickButton(joystickNum, gamepad.start);
        KeyCode skipConvoKey  = GetJoystickButton(joystickNum, gamepad.skipConvo);
        KeyCode languageKey   = GetJoystickButton(joystickNum, gamepad.languageChange);

        JoystickInput input = new JoystickInput(acceptKey, backKey, returnDefault, fireKey, bombKey, reviveKey, slowMoveKey, pauseKey, skipConvoKey, languageKey);

        if (joystickNum == 1)
        {
            p1_joystick = input;
        }
        else if (joystickNum == 2)
        {
            p2_joystick = input;
        }
    }
示例#7
0
        private string GetInputStatsText(JoystickInput input)
        {
            // Determine all pressed joystick buttons
            string activeButtons = "";

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

            // Determine all joystick axis values
            string axisValues = "";

            foreach (JoystickAxis axis in Enum.GetValues(typeof(JoystickAxis)))
            {
                if (input.AxisValue(axis) == 0.0f && (int)axis >= input.AxisCount)
                {
                    break;
                }

                if (axisValues.Length != 0)
                {
                    axisValues += ", ";
                }
                axisValues += string.Format("{0:F}", input.AxisValue(axis));
            }

            // Determine all joystick hat values
            string hatValues = "";

            foreach (JoystickHat hat in Enum.GetValues(typeof(JoystickHat)))
            {
                if (input.HatPosition(hat) == JoystickHatPosition.Centered && (int)hat >= input.HatCount)
                {
                    break;
                }

                if (hatValues.Length != 0)
                {
                    hatValues += ", ";
                }
                hatValues += string.Format("({0})", input.HatPosition(hat));
            }

            return
                (string.Format("Description: /cFF8800FF{0}/cFFFFFFFF/n", input.Description) +
                 string.Format("IsAvailable: /cFF8800FF{0}/cFFFFFFFF/n", input.IsAvailable) +
                 string.Format("ButtonCount: /cFF8800FF{0,2}/cFFFFFFFF | AxisCount: /cFF8800FF{1,2}/cFFFFFFFF | HatCount: /cFF8800FF{2,2}/cFFFFFFFF/n", input.ButtonCount, input.AxisCount, input.HatCount) +
                 string.Format("Buttons: /c44AAFFFF{0}/cFFFFFFFF/n", activeButtons) +
                 string.Format("Axes:    /c44AAFFFF{0}/cFFFFFFFF/n", axisValues) +
                 string.Format("Hats:    /c44AAFFFF{0}/cFFFFFFFF", hatValues));
        }
示例#8
0
        public void When_Created_then_It_isAvailable()
        {
            var joystickInput = new JoystickInput {
                Source = CreateJoystickInputSourceMock().Object
            };

            Assert.True(joystickInput.IsAvailable);
        }
示例#9
0
        public void When_Updating_then_it_does_not_throw()
        {
            var joystickInput = new JoystickInput {
                Source = CreateJoystickInputSourceMock().Object
            };

            Assert.DoesNotThrow(((IUserInput)joystickInput).Update);
        }
示例#10
0
    private JoystickInput CreateJoystickInput(int controllerId)
    {
        JoystickInput ji = ScriptableObject.CreateInstance <JoystickInput>();

        ji.SetControllerNumber(controllerId);

        return(ji);
    }
示例#11
0
        public JoystickViewer(JoystickInput.JoystickDevice device)
        {
            InitializeComponent();

            this.device = device;

            this.cross = new Pen(Color.Red, 2f);
        }
示例#12
0
 public BuzzWheelViewModel(IEventAggregator eventAggregator)
 {
     m_EventAggregator = eventAggregator;
     StartWheelCommand = new DelegateCommand(StartWheel, CanStartWheel);
     SubscribeToEventAggregator();
     m_WheelLoopSound = new SoundPlayer(AppDomain.CurrentDomain.BaseDirectory + @"/Resources/Sound/LoopSound.wav");
     m_WheelEndSound  = new SoundPlayer(AppDomain.CurrentDomain.BaseDirectory + @"/Resources/Sound/EndSound.wav");
     m_JoystickInput  = new JoystickInput();
     m_JoystickInput.InputDeviceButton0DownEvent += OnJoystickInputButton0Down;
 }
    private void SetPlayerSettings(GameObject _pl, bool IsFirstPlayer)
    {
        JoystickInput _ji = _pl.GetComponent <JoystickInput>();

        FinalScore.Instance.CurrentCamera = MainCamera;
        if (IsFirstPlayer)
        {
            FinalScore.Instance.PlayerOne = _pl;
            _pl.transform.position        = PlayerOneSpawnPoint.position;
            FirstTestLevelManager.FirstPlayerWeaponController = _pl.GetComponent <PlayerWeaponController>();


            JoystickSaver.Instanse.Joystick1 = _ji;
            _ji.Jump          = JumpPl1;
            _ji.Fire1         = Fire1Pl1;
            _ji.Fire2         = Fire2Pl1;
            _ji.Fire1T        = Fire1TPl1;
            _ji.Fire2T        = Fire2TPl1;
            _ji.Horizontal    = HorizontalPl1;
            _ji.Vertical      = VerticalPl1;
            _ji.AimHorizontal = AimHorizontalPl1;
            _ji.AimVertical   = AimVerticalPl1;

            GameManager.Players[0] = _pl.GetComponent <PlayerController>();
            PlayerStatsDisplayerPl1.PlayerStateController = _pl.GetComponent <PlayerStateController>();
            _pl.GetComponent <PlayerStateController>().PlayerStatsDisplayer = PlayerStatsDisplayerPl1;
        }
        else
        {
            FinalScore.Instance.PlayerTwo = _pl;
            _pl.transform.position        = PlayerTwoSpawnPoint.position;
            FirstTestLevelManager.SecondPlayerWeaponController = _pl.GetComponent <PlayerWeaponController>();
            JoystickSaver.Instanse.Joystick2 = _ji;

            _ji.Jump          = JumpPl2;
            _ji.Fire1         = Fire1Pl2;
            _ji.Fire2         = Fire2Pl2;
            _ji.Fire1T        = Fire1TPl2;
            _ji.Fire2T        = Fire2TPl2;
            _ji.Horizontal    = HorizontalPl2;
            _ji.Vertical      = VerticalPl2;
            _ji.AimHorizontal = AimHorizontalPl2;
            _ji.AimVertical   = AimVerticalPl2;

            GameManager.Players[1] = _pl.GetComponent <PlayerController>();
            PlayerStatsDisplayerPl2.PlayerStateController = _pl.GetComponent <PlayerStateController>();
            _pl.GetComponent <PlayerStateController>().PlayerStatsDisplayer = PlayerStatsDisplayerPl2;
        }
        _pl.GetComponent <PlayerController>().IsFirstPlayer                = IsFirstPlayer;
        _pl.GetComponent <PlayerWeaponController>().IsFirstPlayer          = IsFirstPlayer;
        _pl.GetComponentInChildren <ArrowTargetController>().IsFirstPlayer = IsFirstPlayer;
        _pl.GetComponentInChildren <HandsIKMover>().IsFirstPlayer          = IsFirstPlayer;
        _pl.SetActive(true);
    }
示例#14
0
 public Vector2 RightAnalog()
 {
     if (keyboardEnabled)
     {
         return(new Vector2(Input.GetAxis("Mouse X") * mouseSensitivity, 0));
     }
     else
     {
         return(JoystickInput.RightAnalog(state));
     }
 }
示例#15
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(this.gameObject);
     }
 }
示例#16
0
 public JoystickData Get()
 {
     SpiRxBuffer[0] = 0;
     SpiRxBuffer[1] = 0;
     while (SpiRxBuffer[0] != 'O' && SpiRxBuffer[1] != 'K')
     {
         Spi.WriteRead(SpiTxBuffer, SpiRxBuffer);
         Thread.Sleep(10);
     }
     ReceiveContext.Bind(SpiRxBuffer, BasicTypeDeSerializerContext.BufferStartOffsetDefault);
     JoystickInput.Get(ReceiveContext);
     return(JoystickInput);
 }
示例#17
0
    public void InitializePlayerController(Player player, GameManager gameManager)
    {
        _player      = player;
        _gameManager = gameManager;

        input = new JoystickInput();
        input.CreateDefaultJoystickBindings();

        circleCombo = new JoystickCombo("Circle");
        circleCombo.lowerDeadZoneX = -.2f;
        circleCombo.upperDeadZoneX = .2f;
        circleCombo.lowerDeadZoneY = -.2f;
        circleCombo.upperDeadZoneY = .2f;

        isComboCoroutineRunning = false;
    }
示例#18
0
    void Start()
    {
        int max = Input.GetJoystickNames().Length;

        for (int i = 0; i < max; i++)
        {
//            Debug.Log(Input.GetJoystickNames()[1]);
            // Check out with Input Manager....
            if (Input.GetJoystickNames()[i].Length == 19)
            {
                connectedGamepadCount++;
            }
        }

        if (JoystickManager.sSingleton.connectedGamepadCount > 0)
        {
            mIsP1KeybInput = false;
        }

        // Set up joystick 1 input.
        KeyCode acceptKey     = GetJoystickButton(1, controlA.accept);
        KeyCode backKey       = GetJoystickButton(1, controlA.back);
        KeyCode returnDefault = GetJoystickButton(1, controlA.returnDefault);
        KeyCode fireKey       = GetJoystickButton(1, controlA.fire);
        KeyCode bombKey       = GetJoystickButton(1, controlA.bomb);
        KeyCode reviveKey     = GetJoystickButton(1, controlA.revive);
        KeyCode slowMoveKey   = GetJoystickButton(1, controlA.slowMove);
        KeyCode pauseKey      = GetJoystickButton(1, controlA.start);
        KeyCode skipConvoKey  = GetJoystickButton(1, controlA.skipConvo);
        KeyCode languageKey   = GetJoystickButton(1, controlA.languageChange);

        p1_joystick = new JoystickInput(acceptKey, backKey, returnDefault, fireKey, bombKey, reviveKey, slowMoveKey, pauseKey, skipConvoKey, languageKey);

        // Set up joystick 2 input.
        acceptKey     = GetJoystickButton(2, controlA.accept);
        backKey       = GetJoystickButton(2, controlA.back);
        returnDefault = GetJoystickButton(2, controlA.returnDefault);
        fireKey       = GetJoystickButton(2, controlA.fire);
        bombKey       = GetJoystickButton(2, controlA.bomb);
        reviveKey     = GetJoystickButton(2, controlA.revive);
        slowMoveKey   = GetJoystickButton(2, controlA.slowMove);
        pauseKey      = GetJoystickButton(2, controlA.start);
        skipConvoKey  = GetJoystickButton(2, controlA.skipConvo);
        languageKey   = GetJoystickButton(2, controlA.languageChange);
        p2_joystick   = new JoystickInput(acceptKey, backKey, returnDefault, fireKey, bombKey, reviveKey, slowMoveKey, pauseKey, skipConvoKey, languageKey);
    }
示例#19
0
 public void Update(GameTime gameTime)
 {
     JoystickInput.Update(gameTime);
     KeyboardInput.Update(gameTime);
     MouseScreenInput.Update(gameTime);
 }
示例#20
0
		private string GetInputStatsText(JoystickInput input)
		{
			// Determine all pressed joystick buttons
			string activeButtons = "";
			foreach (JoystickButton button in Enum.GetValues(typeof(JoystickButton)))
			{
				if (input.ButtonPressed(button))
				{
					if (activeButtons.Length != 0)
						activeButtons += ", ";
					activeButtons += button.ToString();
				}
			}

			// Determine all joystick axis values
			string axisValues = "";
			foreach (JoystickAxis axis in Enum.GetValues(typeof(JoystickAxis)))
			{
				if (input.AxisValue(axis) == 0.0f && (int)axis >= input.AxisCount) 
					break;

				if (axisValues.Length != 0)
					axisValues += ", ";
				axisValues += string.Format("{0:F}", input.AxisValue(axis));
			}

			// Determine all joystick hat values
			string hatValues = "";
			foreach (JoystickHat hat in Enum.GetValues(typeof(JoystickHat)))
			{
				if (input.HatPosition(hat) == JoystickHatPosition.Centered && (int)hat >= input.HatCount) 
					break;

				if (hatValues.Length != 0)
					hatValues += ", ";
				hatValues += string.Format("({0})", input.HatPosition(hat));
			}

			return 
				string.Format("Description: /cFF8800FF{0}/cFFFFFFFF/n", input.Description) +
				string.Format("IsAvailable: /cFF8800FF{0}/cFFFFFFFF/n", input.IsAvailable) +
				string.Format("ButtonCount: /cFF8800FF{0,2}/cFFFFFFFF | AxisCount: /cFF8800FF{1,2}/cFFFFFFFF | HatCount: /cFF8800FF{2,2}/cFFFFFFFF/n", input.ButtonCount, input.AxisCount, input.HatCount) +
				string.Format("Buttons: /c44AAFFFF{0}/cFFFFFFFF/n", activeButtons) +
				string.Format("Axes:    /c44AAFFFF{0}/cFFFFFFFF/n", axisValues) +
				string.Format("Hats:    /c44AAFFFF{0}/cFFFFFFFF", hatValues);
		}
        public void When_Created_then_It_isAvailable()
        {
            var joystickInput = new JoystickInput { Source = CreateJoystickInputSourceMock().Object };

            Assert.True(joystickInput.IsAvailable);
        }
        public void When_Updating_then_it_does_not_throw()
        {
            var joystickInput = new JoystickInput {Source = CreateJoystickInputSourceMock().Object};

            Assert.DoesNotThrow(((IUserInput)joystickInput).Update);
        }
示例#23
0
 public JoystickAxisEventArgs(JoystickInput inputChannel, int axisIndex, float axisValue, float axisDelta) : base(inputChannel)
 {
     this.axisIndex = axisIndex;
     this.axisValue = axisValue;
     this.axisDelta = axisDelta;
 }
 private void Start()
 {
     leftStick = GetComponent <JoystickInput>();
 }
示例#25
0
        private string GetInputStatsText(JoystickInput input)
        {
            // Determine all pressed joystick buttons
            string activeButtons = "";

            for (int i = 0; i < input.ButtonCount; i++)
            {
                if (input.ButtonPressed(i))
                {
                    if (activeButtons.Length != 0)
                    {
                        activeButtons += ", ";
                    }
                    activeButtons += string.Format("Button #{0}", i).ToString();
                }
            }

            // Determine all joystick axis values
            string axisValues = "";

            for (int i = 0; i < input.AxisCount; i++)
            {
                if (input.AxisValue(i) == 0.0f)
                {
                    break;
                }

                if (axisValues.Length != 0)
                {
                    axisValues += ", ";
                }
                axisValues += string.Format("{0:F}", input.AxisValue(i));
            }

            // Determine all joystick hat values
            string hatValues = "";

            for (int i = 0; i < input.HatCount; i++)
            {
                if (input.HatPosition(i) == JoystickHatPosition.Centered)
                {
                    break;
                }

                if (hatValues.Length != 0)
                {
                    hatValues += ", ";
                }
                hatValues += string.Format("({0})", input.HatPosition(i));
            }

            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("ButtonCount: /cFF8800FF{0,2}/cFFFFFFFF | AxisCount: /cFF8800FF{1,2}/cFFFFFFFF | HatCount: /cFF8800FF{2,2}/cFFFFFFFF/n", input.ButtonCount, input.AxisCount, input.HatCount) +
                 string.Format("Buttons: /c44AAFFFF{0}/cFFFFFFFF/n", activeButtons) +
                 string.Format("Axes:    /c44AAFFFF{0}/cFFFFFFFF/n", axisValues) +
                 string.Format("Hats:    /c44AAFFFF{0}/cFFFFFFFF", hatValues));
        }
示例#26
0
 public JoystickButtonEventArgs(JoystickInput inputChannel, int buttonIndex, bool pressed) : base(inputChannel)
 {
     this.buttonIndex = buttonIndex;
     this.pressed     = pressed;
 }
示例#27
0
 private void Start()
 {
     actingCamera = transform.GetChild(3).GetComponent <PlayerCamera>();
     camRoot      = actingCamera.transform.GetChild(0);
     newLeftStick = LeftJoystickPass.instance.LeftJoystickLocator();
 }
 public void Update(GameTime gameTime)
 {
     JoystickInput.Update(gameTime);
 }
示例#29
0
 // Start is called before the first frame update
 void Awake()
 {
     _input        = Hand == JoystickInput.JoystickHand.Left ? JoystickInput.Left : JoystickInput.Right;
     _defaultColor = Foreground.material.color;
 }
示例#30
0
 public JoystickAxisEventArgs(JoystickInput inputChannel, JoystickAxis axis, float axisValue, float axisDelta) : base(inputChannel)
 {
     this.axis      = axis;
     this.axisValue = axisValue;
     this.axisDelta = axisDelta;
 }
示例#31
0
 public JoystickButtonEventArgs(JoystickInput inputChannel, JoystickButton button, bool pressed) : base(inputChannel)
 {
     this.button  = button;
     this.pressed = pressed;
 }
示例#32
0
 public JoystickHatEventArgs(JoystickInput inputChannel, JoystickHat hat, JoystickHatPosition hatPos, JoystickHatPosition lastHatPos) : base(inputChannel)
 {
     this.hat        = hat;
     this.hatPos     = hatPos;
     this.lastHatPos = lastHatPos;
 }
 public void Update(GameTime gameTime)
 {
     JoystickInput.Update(gameTime);
     TouchScreenInput.Update(gameTime);
 }