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; }
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; }
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; }
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 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; } }
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; } }
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; } }
/// <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; }
protected GamePad(GamePadNumber number) { Number = number; }
public TriggerStateEventArgs(GamePadNumber controllerNum, GamePadTriggers trigger, float triggerValue) : base(controllerNum) { this.Trigger = trigger; this.TriggerValue = triggerValue; }
private void radioButton4_CheckedChanged(object sender, EventArgs e) { _currentController = GamePadNumber.Four; }
public MockWindowsGamePad(GamePadNumber number) : base(number) { }
public GamePadEventArgs(GamePadNumber controllerNum) { this.ControllerNum = controllerNum; }
/// <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; }
/// <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)); }
/// <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)); } }
public MockWindowsGamePad(GamePadNumber number) : base(number) {}