0
GamePads feature lots of buttons, but most commonly A, B, X, Y are used for Triggers.
View code on GitHub
Namespace: DeltaEngine.InputAssembly: DeltaEngine.Input (in DeltaEngine.Input.dll) Version: 1.1.1.0 (1.1.1)
Syntax
Members
Member name | Value | Description | |
---|---|---|---|
A | 0 | Green A Button on the Xbox 360 controller, Blue Cross (X) on the PS3 controller. View code on GitHub | |
B | 1 | Red B Button on the Xbox 360 controller, Orange Circle (O) on the PS3 controller. View code on GitHub | |
X | 2 | Blue X Button on the Xbox 360 controller, Pink Square ([]) on the PS3 controller. View code on GitHub | |
Y | 3 | Yellow Y Button on the Xbox 360 controller, Green Triangle (/\) the PS3 controller. View code on GitHub | |
Left | 4 | Left Button on the D-Pad (Digital Pad), the same for Xbox 360 and PS3 View code on GitHub | |
Right | 5 | Right Button on the D-Pad (Digital Pad), the same for Xbox 360 and PS3 View code on GitHub | |
Up | 6 | Up Button on the D-Pad (Digital Pad), the same for Xbox 360 and PS3 View code on GitHub | |
Down | 7 | Down Button on the D-Pad (Digital Pad), the same for Xbox 360 and PS3 View code on GitHub | |
LeftStick | 8 | Left thumb stick, which is usually used for movement, but can also be pressed. View code on GitHub | |
RightStick | 9 | right thumb stick, which is used often for looking around, but can also be pressed. View code on GitHub | |
Start | 10 | Start Button on the Xbox 360 and PS3 controller (to start the game or level). View code on GitHub | |
Back | 11 | Back Button on the Xbox 360 controller, Select Button on the PS3 controller. View code on GitHub | |
LeftShoulder | 12 | Left Shoulder button on the Xbox 360 controller, L1 Button on the PS3. View code on GitHub | |
RightShoulder | 13 | Right Shoulder button on the Xbox 360 controller, R1 Button on the PS3. View code on GitHub | |
BigButton | 14 | Big Button if supported on a Xbox 360 controller. Not supported on a standard controller. View code on GitHub |
Remarks
Examples
[Test] public void PressGamePadButtonsToShowCircles() { var circleA = new Ellipse(new Rectangle(0.1f, 0.1f, 0.1f, 0.1f), Color.Green); var circleB = new Ellipse(new Rectangle(0.1f, 0.1f, 0.1f, 0.1f), Color.Red); var circleX = new Ellipse(new Rectangle(0.1f, 0.1f, 0.1f, 0.1f), Color.Blue); var circleY = new Ellipse(new Rectangle(0.1f, 0.1f, 0.1f, 0.1f), Color.Yellow); new Command(() => circleA.Center = new Vector2D(0.5f, 0.75f)).Add( new GamePadButtonTrigger(GamePadButton.A, State.Pressed)); new Command(() => circleA.Center = Vector2D.Zero).Add(new GamePadButtonTrigger( GamePadButton.A, State.Released)); new Command(() => circleB.Center = new Vector2D(0.75f, 0.5f)).Add( new GamePadButtonTrigger(GamePadButton.B, State.Pressed)); new Command(() => circleB.Center = Vector2D.Zero).Add(new GamePadButtonTrigger( GamePadButton.B, State.Released)); new Command(() => circleX.Center = new Vector2D(0.25f, 0.5f)).Add( new GamePadButtonTrigger(GamePadButton.X, State.Pressed)); new Command(() => circleX.Center = Vector2D.Zero).Add(new GamePadButtonTrigger( GamePadButton.X, State.Released)); new Command(() => circleY.Center = new Vector2D(0.5f, 0.25f)).Add( new GamePadButtonTrigger(GamePadButton.Y, State.Pressed)); new Command(() => circleY.Center = Vector2D.Zero).Add(new GamePadButtonTrigger( GamePadButton.Y, State.Released)); }
[Test, CloseAfterFirstFrame] public void Create() { var trigger = new GamePadButtonTrigger(GamePadButton.Y, State.Pressed); Assert.AreEqual(GamePadButton.Y, trigger.Button); Assert.AreEqual(State.Pressed, trigger.State); }
[Test, CloseAfterFirstFrame] public void CreateFromAttributes() { var trigger = new GamePadButtonTrigger(new Dictionary<string, string> { { "Button", "Y" }, { "State", " Pressed" } }); Assert.AreEqual(GamePadButton.Y, trigger.Button); Assert.AreEqual(State.Pressed, trigger.State); Assert.Throws<GamePadButtonTrigger.CannotCreateGamePadTriggerWithoutKey>( () => new GamePadButtonTrigger(new Dictionary<string, string>())); } }
See Also