예제 #1
0
		public XnaGamePad(GamePadNumber number)
			: base(number)
		{
			states = new State[GamePadButton.A.GetCount()];
			for (int i = 0; i < states.Length; i++)
				states[i] = State.Released;
		}
 public ThumbStickStateEventArgs(GamePadNumber controllerNum, GamePadThumbSticks thumbStick, float xValue, float yValue)
     : base(controllerNum)
 {
     this.ThumbStick = thumbStick;
     this.XValue = xValue;
     this.YValue = yValue;
 }
예제 #3
0
		public SharpDXGamePad(GamePadNumber number = GamePadNumber.Any)
			: base(number)
		{
			controller = new Controller(GetUserIndexFromNumber());
			states = new State[GamePadButton.A.GetCount()];
			for (int i = 0; i < states.Length; i++)
				states[i] = State.Released;
		}
예제 #4
0
		public WindowsGamePad(GamePadNumber number)
			: base(number)
		{
			joyCapsSize = Marshal.SizeOf(typeof(JoyCaps));
			states = new State[GamePadButton.A.GetCount()];
			for (int i = 0; i < states.Length; i++)
				states[i] = State.Released;
		}
예제 #5
0
 public XnaGamePad(GamePadNumber number)
     : base(number)
 {
     states = new State[GamePadButton.A.GetCount()];
     for (int i = 0; i < states.Length; i++)
     {
         states[i] = State.Released;
     }
 }
예제 #6
0
 public SlimDXGamePad(GamePadNumber number = GamePadNumber.Any)
     : base(number)
 {
     controller = new Controller(GetUserIndexFromNumber());
     states     = new State[GamePadButton.A.GetCount()];
     for (int i = 0; i < states.Length; i++)
     {
         states[i] = State.Released;
     }
 }
예제 #7
0
 public WindowsGamePad(GamePadNumber number)
     : base(number)
 {
     joyCapsSize = Marshal.SizeOf(typeof(JoyCaps));
     states      = new State[GamePadButton.A.GetCount()];
     for (int i = 0; i < states.Length; i++)
     {
         states[i] = State.Released;
     }
 }
예제 #8
0
 public GLFWGamePad(Window window, GamePadNumber number = GamePadNumber.Any)
     : base(number)
 {
     if (window.Handle == null)
     {
         throw new CannotCreateGamePadWithoutWindow();
     }
     states = new State[GamePadButton.A.GetCount()];
     for (int i = 0; i < states.Length; i++)
     {
         states[i] = State.Released;
     }
 }
예제 #9
0
 /// <summary>
 /// Sets the controller vibration to the values specified
 /// </summary>
 /// <param name="ControllerNum">The controller to receive the vibration change</param>
 /// <param name="LeftMotor">Amount of the vibration of the left motor</param>
 /// <param name="RightMotor">Amount of the vibration of the right motor</param>
 public void SetControllerVibration(GamePadNumber ControllerNum, float LeftMotor, float RightMotor)
 {
     LeftMotor = MathHelper.Clamp(LeftMotor, 0.0f, 1.0f);
     RightMotor = MathHelper.Clamp(RightMotor, 0.0f, 1.0f);
     GamePad.SetVibration(GetPlayerIndexFromControllerNumber(ControllerNum), LeftMotor, RightMotor);
 }
 public ButtonStateEventArgs(GamePadNumber controllerNum, GamePadButtons button, bool pressed)
     : base(controllerNum)
 {
     this.Button = button;
     this.Pressed = pressed;
 }
예제 #11
0
 protected GamePad(GamePadNumber number)
 {
     Number = number;
 }
예제 #12
0
 protected GamePad(GamePadNumber number)
 {
     Number = number;
 }
 public TriggerStateEventArgs(GamePadNumber controllerNum, GamePadTriggers trigger, float triggerValue)
     : base(controllerNum)
 {
     this.Trigger = trigger;
     this.TriggerValue = triggerValue;
 }
예제 #14
0
 private void radioButton4_CheckedChanged(object sender, EventArgs e)
 {
     _currentController = GamePadNumber.Four;
 }
 public MockWindowsGamePad(GamePadNumber number)
     : base(number)
 {
 }
예제 #16
0
 public GamePadEventArgs(GamePadNumber controllerNum)
 {
     this.ControllerNum = controllerNum;
 }
예제 #17
0
 /// <summary>
 /// Get the XNA enumerated player index from local mapping
 /// </summary>
 /// <param name="ControllerNumber">Local enumerated controller number type</param>
 /// <returns>XNA enumerated player index type</returns>
 private PlayerIndex GetPlayerIndexFromControllerNumber(GamePadNumber ControllerNumber)
 {
     PlayerIndex pi = PlayerIndex.One;
     switch (ControllerNumber)
     {
         case GamePadNumber.One:
             pi = PlayerIndex.One;
             break;
         case GamePadNumber.Two:
             pi = PlayerIndex.Two;
             break;
         case GamePadNumber.Three:
             pi = PlayerIndex.Three;
             break;
         case GamePadNumber.Four:
             pi = PlayerIndex.Four;
             break;
         default:
             break;
     }
     return pi;
 }
예제 #18
0
 /// <summary>
 /// Checks if the buttons have changed and if so triggers the event
 /// </summary>
 /// <param name="ControllerNum">The currently polling controller</param>
 /// <param name="button">The local enum button being checked</param>
 /// <param name="current">The current value of the button being checked</param>
 /// <param name="previous">The previous value of the button being checked</param>
 private void CheckButtonsChanged(GamePadNumber ControllerNum, GamePadButtons button, ButtonState current, ButtonState previous)
 {
     if (current != previous)
         OnButtonStateChanged(this, new ButtonStateEventArgs(ControllerNum, button, current == ButtonState.Pressed));
 }
예제 #19
0
        /// <summary>
        /// Update the controller state and fire off any events related to changed state
        /// </summary>
        /// <param name="ControllerNum">The controller to poll</param>
        public void UpdateControllerState(GamePadNumber ControllerNum)
        {
            PlayerIndex pi = GetPlayerIndexFromControllerNumber(ControllerNum);

            // Get the current gamepad state.
            GamePadState currentState = GamePad.GetState(pi);

            GamePadState previousState = _previousState[ControllerNum];

            if (previousState.IsConnected != currentState.IsConnected)
            {
                // connected state changed
                if (currentState.IsConnected) OnControllerConnected(this, new GamePadEventArgs(ControllerNum));
                else OnControllerDisconnected(this, new GamePadEventArgs(ControllerNum));
            }

            // Process input only if connected.
            if (currentState.IsConnected)
            {
                // Check buttons vs previous state
                CheckButtonsChanged(ControllerNum, GamePadButtons.A, currentState.Buttons.A, previousState.Buttons.A);
                CheckButtonsChanged(ControllerNum, GamePadButtons.B, currentState.Buttons.B, previousState.Buttons.B);
                CheckButtonsChanged(ControllerNum, GamePadButtons.X, currentState.Buttons.X, previousState.Buttons.X);
                CheckButtonsChanged(ControllerNum, GamePadButtons.Y, currentState.Buttons.Y, previousState.Buttons.Y);
                CheckButtonsChanged(ControllerNum, GamePadButtons.Back, currentState.Buttons.Back, previousState.Buttons.Back);
                CheckButtonsChanged(ControllerNum, GamePadButtons.LeftShoulder, currentState.Buttons.LeftShoulder, previousState.Buttons.LeftShoulder);
                CheckButtonsChanged(ControllerNum, GamePadButtons.LeftStick, currentState.Buttons.LeftStick, previousState.Buttons.LeftStick);
                CheckButtonsChanged(ControllerNum, GamePadButtons.RightShoulder, currentState.Buttons.RightShoulder, previousState.Buttons.RightShoulder);
                CheckButtonsChanged(ControllerNum, GamePadButtons.RightStick, currentState.Buttons.RightStick, previousState.Buttons.RightStick);
                CheckButtonsChanged(ControllerNum, GamePadButtons.Start, currentState.Buttons.Start, previousState.Buttons.Start);
                CheckButtonsChanged(ControllerNum, GamePadButtons.BigButton, currentState.Buttons.BigButton, previousState.Buttons.BigButton);
                CheckButtonsChanged(ControllerNum, GamePadButtons.DPadDown, currentState.DPad.Down, previousState.DPad.Down);
                CheckButtonsChanged(ControllerNum, GamePadButtons.DPadLeft, currentState.DPad.Left, previousState.DPad.Left);
                CheckButtonsChanged(ControllerNum, GamePadButtons.DPadRight, currentState.DPad.Right, previousState.DPad.Right);
                CheckButtonsChanged(ControllerNum, GamePadButtons.DPadUp, currentState.DPad.Up, previousState.DPad.Up);

                // Update previous gamepad state.
                _previousState[ControllerNum] = currentState;

                // Check Analog controls
                OnTriggerStateUpdated(this, new TriggerStateEventArgs(ControllerNum, GamePadTriggers.Left, currentState.Triggers.Left));
                OnTriggerStateUpdated(this, new TriggerStateEventArgs(ControllerNum, GamePadTriggers.Right, currentState.Triggers.Right));
                OnThumbStickStateUpdated(this, new ThumbStickStateEventArgs(ControllerNum, GamePadThumbSticks.Left, currentState.ThumbSticks.Left.X, currentState.ThumbSticks.Left.Y));
                OnThumbStickStateUpdated(this, new ThumbStickStateEventArgs(ControllerNum, GamePadThumbSticks.Right, currentState.ThumbSticks.Right.X, currentState.ThumbSticks.Right.Y));
            }
        }
예제 #20
0
			public MockWindowsGamePad(GamePadNumber number)
				: base(number) {}