public void KeyboardButtonsTheory(Keys[] keys, Keys key, bool expected) { KeyboardState state = new KeyboardState(keys); string actionName = "Action" + _counter++; InputManager.CreateAction(actionName, key); InputManager.KeyboardState = state; InputManager.ActionUpdate(); Assert.Equal(expected, InputManager.GetDown(actionName)); }
public void MouseButtonsTheory(ButtonState leftButton, ButtonState middleButton, ButtonState rightButton, ButtonState xButton1, ButtonState xButton2, MouseButton mouseButton, bool expected) { MouseState state = new MouseState(0, 0, 0, leftButton, middleButton, rightButton, xButton1, xButton2); string actionName = "Action" + _counter++; InputManager.CreateAction(actionName, mouseButton); InputManager.MouseState = state; InputManager.ActionUpdate(); Assert.Equal(expected, InputManager.GetDown(actionName)); }
public void GamePadButtonsTheory(Buttons[] buttons, Buttons gamePadButton, bool expected) { GamePadState state = new GamePadState(Vector2.Zero, Vector2.Zero, 0, 0, buttons); string actionName = "Action" + _counter++; InputManager.CreateAction(actionName, PlayerIndex.One, gamePadButton); InputManager.GamePadStates = new GamePadState[] { state }; InputManager.ActionUpdate(); Assert.Equal(expected, InputManager.GetDown(actionName)); }
public void KeyboardAxesTheoty(Keys[] keys, Keys left, Keys right, float expected) { KeyboardState state = new KeyboardState(keys); InputManager.KeyboardState = state; string actionName = "Action" + _counter++; InputManager.CreateAction(actionName, left, right); InputManager.ActionUpdate(); Assert.Equal(expected, InputManager.GetAxis(actionName)); }
public void GamePadAxesTheory(float leftThumbSticksX, float leftThumbSticksY, float rightThumbSticksX, float rightThumbSticksY, float leftTrigger, float rightTrigger, GamePadAxes gamePadAxes, float expected) { GamePadState state = new GamePadState( new Vector2(leftThumbSticksX, leftThumbSticksY), new Vector2(rightThumbSticksX, rightThumbSticksY), leftTrigger, rightTrigger, new Buttons[0]); string actionName = "Action" + _counter++; InputManager.CreateAction(actionName, PlayerIndex.One, gamePadAxes); InputManager.GamePadStates = new GamePadState[] { state }; InputManager.ActionUpdate(); Assert.Equal(expected, InputManager.GetAxis(actionName)); }
public void MouseAxesTheory(int x, int prevX, int y, int prevY, int scrollWheel, int prevScrollWheel, int horizontalScrollWheel, int prevHorizontalScrollWheel, MouseAxes mouseAxes) { MouseState state = new MouseState(x, y, scrollWheel, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released, horizontalScrollWheel); MouseState prevState = new MouseState(prevX, prevY, prevScrollWheel, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released, ButtonState.Released, prevHorizontalScrollWheel); string actionName = "Action" + _counter++; InputManager.CreateAction(actionName, mouseAxes); InputManager.PrevMouseState = prevState; InputManager.MouseState = state; InputManager.ActionUpdate(); float expected = 0; switch (mouseAxes) { case MouseAxes.Horizontal: expected = MathHelper.Clamp((x - prevX) * InputManager.MOUSE_MODIFIER, -1, 1); break; case MouseAxes.Vertical: expected = MathHelper.Clamp((y - prevY) * InputManager.MOUSE_MODIFIER, -1, 1); break; case MouseAxes.ScrollWheel: expected = MathHelper.Clamp((scrollWheel - prevScrollWheel) * InputManager.MOUSE_MODIFIER, -1, 1); break; case MouseAxes.HorizontalScrollWheel: expected = MathHelper.Clamp((horizontalScrollWheel - prevHorizontalScrollWheel) * InputManager.MOUSE_MODIFIER, -1, 1); break; } Assert.Equal(expected, InputManager.GetAxis(actionName), 4); }