public XboxGamepadBackInterfaceButton Bind(XboxInputLabel.Buttons label) { XboxGamepadButtonInputSource source = Device.CreateButtonSource(label); _sources.Add(source); SourceAdded(source); return(this); }
public bool HasButton(XboxInputLabel.Buttons button) { return((AvailableButtons & button) == button); }
public GamepadCapabilities(int gamepadIndex) { if (gamepadIndex < 0 || gamepadIndex >= Input.MaxGamePads) { throw new System.ArgumentException($"Gamepad index '{gamepadIndex}' is out of valid range [0, {Input.MaxGamePads - 1}]"); } Microsoft.Xna.Framework.Input.GamePadCapabilities capabilities = Microsoft.Xna.Framework.Input.GamePad.GetCapabilities((Microsoft.Xna.Framework.PlayerIndex)gamepadIndex); Id = gamepadIndex; IsGamepadConnected = capabilities.IsConnected; Kind = (GamepadKind)((int)capabilities.GamePadType + ((int)GamepadKind.Unknown - (int)Microsoft.Xna.Framework.Input.GamePadType.Unknown)); #region Buttons AvailableButtons = XboxInputLabel.Buttons.None; if (capabilities.HasAButton) { AvailableButtons |= XboxInputLabel.Buttons.A; } if (capabilities.HasBButton) { AvailableButtons |= XboxInputLabel.Buttons.B; } if (capabilities.HasXButton) { AvailableButtons |= XboxInputLabel.Buttons.X; } if (capabilities.HasYButton) { AvailableButtons |= XboxInputLabel.Buttons.Y; } if (capabilities.HasLeftShoulderButton) { AvailableButtons |= XboxInputLabel.Buttons.LB; } if (capabilities.HasRightShoulderButton) { AvailableButtons |= XboxInputLabel.Buttons.RB; } if (capabilities.HasDPadUpButton) { AvailableButtons |= XboxInputLabel.Buttons.DUp; } if (capabilities.HasDPadRightButton) { AvailableButtons |= XboxInputLabel.Buttons.DRight; } if (capabilities.HasDPadDownButton) { AvailableButtons |= XboxInputLabel.Buttons.DDown; } if (capabilities.HasDPadLeftButton) { AvailableButtons |= XboxInputLabel.Buttons.DLeft; } if (capabilities.HasBackButton) { AvailableButtons |= XboxInputLabel.Buttons.Back; } if (capabilities.HasStartButton) { AvailableButtons |= XboxInputLabel.Buttons.Start; } if (capabilities.HasBigButton) { AvailableButtons |= XboxInputLabel.Buttons.BigButton; } #endregion Buttons #region Triggers AvailableTriggers = XboxInputLabel.Triggers.None; if (capabilities.HasLeftTrigger) { AvailableTriggers |= XboxInputLabel.Triggers.LT; } if (capabilities.HasRightTrigger) { AvailableTriggers |= XboxInputLabel.Triggers.RT; } #endregion Triggers #region Features AvailableFeatures = GamepadFeature.None; if (capabilities.HasLeftXThumbStick) { AvailableFeatures |= GamepadFeature.LeftThumbStickHorizontalAxis; } if (capabilities.HasLeftYThumbStick) { AvailableFeatures |= GamepadFeature.LeftThumbStickVerticalAxis; } if (capabilities.HasRightXThumbStick) { AvailableFeatures |= GamepadFeature.RightThumbStickHorizontalAxis; } if (capabilities.HasRightYThumbStick) { AvailableFeatures |= GamepadFeature.RightThumbStickVerticalAxis; } if (capabilities.HasLeftVibrationMotor) { AvailableFeatures |= GamepadFeature.LeftVibrationMotor; } if (capabilities.HasRightVibrationMotor) { AvailableFeatures |= GamepadFeature.RightVibrationMotor; } if (capabilities.HasVoiceSupport) { AvailableFeatures |= GamepadFeature.VoiceSupport; } if (capabilities.HasLightBarEXT) { AvailableFeatures |= GamepadFeature.LightBar; } if (capabilities.HasTriggerVibrationMotorsEXT) { AvailableFeatures |= GamepadFeature.TriggerVibrationMotors; } if (capabilities.HasMisc1EXT) { AvailableFeatures |= GamepadFeature.Misc1; } if (capabilities.HasPaddle1EXT) { AvailableFeatures |= GamepadFeature.Paddle1; } if (capabilities.HasPaddle2EXT) { AvailableFeatures |= GamepadFeature.Paddle2; } if (capabilities.HasPaddle3EXT) { AvailableFeatures |= GamepadFeature.Paddle3; } if (capabilities.HasPaddle4EXT) { AvailableFeatures |= GamepadFeature.Paddle4; } if (capabilities.HasTouchPadEXT) { AvailableFeatures |= GamepadFeature.TouchPad; } if (capabilities.HasGyroEXT) { AvailableFeatures |= GamepadFeature.Gyro; } if (capabilities.HasAccelerometerEXT) { AvailableFeatures |= GamepadFeature.Accelerometer; } #endregion Features }
public XboxGamepadButtons(XboxInputLabel.Buttons buttons) { Buttons = buttons; }
internal XboxGamepadButtons(Microsoft.Xna.Framework.Input.GamePadState xnaState) { XboxInputLabel.Buttons buttons = XboxInputLabel.Buttons.None; if (xnaState.Buttons.A == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.A; } if (xnaState.Buttons.B == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.B; } if (xnaState.Buttons.X == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.X; } if (xnaState.Buttons.Y == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.Y; } if (xnaState.Buttons.LeftShoulder == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.LB; } if (xnaState.Buttons.RightShoulder == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.RB; } if (xnaState.Buttons.LeftStick == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.LeftStick; } if (xnaState.Buttons.RightStick == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.RightStick; } if (xnaState.Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.Back; } if (xnaState.Buttons.Start == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.Start; } if (xnaState.Buttons.BigButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.BigButton; } if (xnaState.DPad.Up == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.DUp; } if (xnaState.DPad.Right == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.DRight; } if (xnaState.DPad.Down == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.DDown; } if (xnaState.DPad.Left == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.DLeft; } Buttons = buttons; }
public bool IsUp(XboxInputLabel.Buttons inputLabel) { return((Buttons & inputLabel) != inputLabel); }
public bool IsDown(XboxInputLabel.Buttons inputLabel) { return((Buttons & inputLabel) == inputLabel); }
public XboxGamepadButtonInputSource(XboxGamepadDevice device, XboxInputLabel.Buttons inputLabel) : base(device) { ButtonId = (int)inputLabel; InputLabel = inputLabel; }
public override void Update(int delta) { base.Update(delta); if (!RawState.HasValue || !IsConnected) { return; } bool hasReceivedInput = false; // buttons XboxInputLabel.Buttons buttons = XboxInputLabel.Buttons.None; if (RawState.HasValue) { if (RawState.Value.Buttons.A == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.A; } if (RawState.Value.Buttons.B == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.B; } if (RawState.Value.Buttons.X == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.X; } if (RawState.Value.Buttons.Y == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.Y; } if (RawState.Value.Buttons.LeftShoulder == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.LB; } if (RawState.Value.Buttons.RightShoulder == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.RB; } if (RawState.Value.Buttons.LeftStick == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.LeftStick; } if (RawState.Value.Buttons.RightStick == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.RightStick; } if (RawState.Value.Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.Back; } if (RawState.Value.Buttons.Start == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.Start; } if (RawState.Value.Buttons.BigButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.BigButton; } if (RawState.Value.DPad.Up == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.DUp; } if (RawState.Value.DPad.Right == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.DRight; } if (RawState.Value.DPad.Down == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.DDown; } if (RawState.Value.DPad.Left == Microsoft.Xna.Framework.Input.ButtonState.Pressed) { buttons |= XboxInputLabel.Buttons.DLeft; } if ((ulong)buttons != 0UL) { hasReceivedInput = true; } // triggers Triggers = new XboxGamepadTriggers(RawState.Value.Triggers); // thumbsticks ThumbSticks = new XboxGamepadThumbSticks(RawState.Value.ThumbSticks); } else { // triggers Triggers = new XboxGamepadTriggers(); // thumbsticks ThumbSticks = new XboxGamepadThumbSticks(); } Buttons = new XboxGamepadButtons(buttons); if (hasReceivedInput) { ReceiveAnyInput(); } }
public XboxGamepadButtonInputSource CreateButtonSource(XboxInputLabel.Buttons label) { return(new XboxGamepadButtonInputSource(this, label)); }