public void Create()
        {
            var trigger = new GamePadButtonTrigger(GamePadButton.Y, State.Pressed);

            Assert.AreEqual(GamePadButton.Y, trigger.Button);
            Assert.AreEqual(State.Pressed, trigger.State);
        }
        public void UpdateGamePad()
        {
            var buttonTrigger   = new GamePadButtonTrigger(GamePadButton.A);
            var joyStickTrigger = new GamePadAnalogTrigger(GamePadAnalog.LeftTrigger);

            gamePad.Update(new Trigger[] { buttonTrigger, joyStickTrigger });
        }
 public void ConditionMatched(Type resolver)
 {
     Start(resolver, (InputCommands input) =>
     {
         var trigger = new GamePadButtonTrigger(GamePadButton.Y, State.Pressing);
         Assert.False(trigger.ConditionMatched(input));
     });
 }
Exemplo n.º 4
0
 public void ConditionMatched(Type resolver)
 {
     Start(resolver, (InputCommands input) =>
     {
         var trigger = new GamePadButtonTrigger(GamePadButton.A, State.Released);
         Assert.IsTrue(trigger.ConditionMatched(input));
     });
 }
		public void CreateFromString()
		{
			var trigger = new GamePadButtonTrigger("Y Pressed");
			Assert.AreEqual(GamePadButton.Y, trigger.Button);
			Assert.AreEqual(State.Pressed, trigger.State);
			Assert.Throws<GamePadButtonTrigger.CannotCreateGamePadTriggerWithoutKey>(
				() => new GamePadButtonTrigger(""));
		}
        public void CreateFromString()
        {
            var trigger = new GamePadButtonTrigger("Y Pressed");

            Assert.AreEqual(GamePadButton.Y, trigger.Button);
            Assert.AreEqual(State.Pressed, trigger.State);
            Assert.Throws <GamePadButtonTrigger.CannotCreateGamePadTriggerWithoutKey>(
                () => new GamePadButtonTrigger(""));
        }
Exemplo n.º 7
0
		public void TestUpdateGamePad()
		{
			gamePad = new MockWindowsGamePad(GamePadNumber.Two);
			var buttonTrigger = new GamePadButtonTrigger(GamePadButton.A);
			var joyStickTrigger = new GamePadAnalogTrigger(GamePadAnalog.LeftTrigger);
			gamePad.Update(new Trigger[] { buttonTrigger, joyStickTrigger });
			Assert.AreEqual(0.0f, gamePad.GetLeftTrigger());
			Assert.IsTrue(gamePad.IsAvailable);
			gamePad.Dispose();
		}
        public void TestUpdateGamePad()
        {
            gamePad = new MockWindowsGamePad(GamePadNumber.Two);
            var buttonTrigger   = new GamePadButtonTrigger(GamePadButton.A);
            var joyStickTrigger = new GamePadAnalogTrigger(GamePadAnalog.LeftTrigger);

            gamePad.Update(new Trigger[] { buttonTrigger, joyStickTrigger });
            Assert.AreEqual(0.0f, gamePad.GetLeftTrigger());
            Assert.IsTrue(gamePad.IsAvailable);
            gamePad.Dispose();
        }
Exemplo n.º 9
0
		public void CheckGamePadNumber()
		{
			var mockGamePad = new MockWindowsGamePad(GamePadNumber.Three);
			var buttonTrigger = new GamePadButtonTrigger(GamePadButton.A);
			var joyStickTrigger = new GamePadAnalogTrigger(GamePadAnalog.LeftTrigger);
			mockGamePad.Update(new Trigger[] { buttonTrigger, joyStickTrigger });
			Assert.AreEqual(GamePadNumber.Three, mockGamePad.GetGamePadNumber());
			mockGamePad = new MockWindowsGamePad(GamePadNumber.Four);
			mockGamePad.Update(new Trigger[] { buttonTrigger, joyStickTrigger });
			Assert.AreEqual(GamePadNumber.Four, mockGamePad.GetGamePadNumber());
		}
Exemplo n.º 10
0
        public void CheckForEquility()
        {
            var trigger = new GamePadButtonTrigger(GamePadButton.A, State.Pressing);
            var otherTrigger = new GamePadButtonTrigger(GamePadButton.B, State.Released);
            Assert.AreNotEqual(trigger, otherTrigger);
            Assert.AreNotEqual(trigger.GetHashCode(), otherTrigger.GetHashCode());

            var copyOfTrigger = new GamePadButtonTrigger(GamePadButton.A, State.Pressing);
            Assert.AreEqual(trigger, copyOfTrigger);
            Assert.AreEqual(trigger.GetHashCode(), copyOfTrigger.GetHashCode());
        }
Exemplo n.º 11
0
        public void CheckGamePadNumber()
        {
            var mockGamePad     = new MockWindowsGamePad(GamePadNumber.Three);
            var buttonTrigger   = new GamePadButtonTrigger(GamePadButton.A);
            var joyStickTrigger = new GamePadAnalogTrigger(GamePadAnalog.LeftTrigger);

            mockGamePad.Update(new Trigger[] { buttonTrigger, joyStickTrigger });
            Assert.AreEqual(GamePadNumber.Three, mockGamePad.GetGamePadNumber());
            mockGamePad = new MockWindowsGamePad(GamePadNumber.Four);
            mockGamePad.Update(new Trigger[] { buttonTrigger, joyStickTrigger });
            Assert.AreEqual(GamePadNumber.Four, mockGamePad.GetGamePadNumber());
        }
Exemplo n.º 12
0
        private bool CheckWhichButtonForGamePadTriggerToUse(bool foundFreeKey, GamePadButton button,
                                                            int index)
        {
            if (foundFreeKey)
            {
                return(true);
            }
            bool keyAlreadyUsed = false;

            foreach (Trigger newTrigger in GetTriggersOfCommand())
            {
                keyAlreadyUsed = CheckIfGamePadButtonIsALreadyUsed(newTrigger, button, keyAlreadyUsed);
            }
            if (keyAlreadyUsed)
            {
                return(false);
            }
            var mouseButtonTrigger = new GamePadButtonTrigger(button, State.Pressed);

            GetTriggersOfCommand()[index] = mouseButtonTrigger;
            return(true);
        }
Exemplo n.º 13
0
		public void UpdateGamePad()
		{
			var buttonTrigger = new GamePadButtonTrigger(GamePadButton.A);
			var joyStickTrigger = new GamePadAnalogTrigger(GamePadAnalog.LeftTrigger);
			gamePad.Update(new Trigger[]{buttonTrigger, joyStickTrigger});
		}
		public void Create()
		{
			var trigger = new GamePadButtonTrigger(GamePadButton.Y, State.Pressed);
			Assert.AreEqual(GamePadButton.Y, trigger.Button);
			Assert.AreEqual(State.Pressed, trigger.State);
		}