GamePadButtonTrigger ClassDelta Engine Documentation
Trigger implementation for GamePad Button events. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Entities Entity
    DeltaEngine.Commands Trigger
      DeltaEngine.Commands InputTrigger
        DeltaEngine.Input GamePadButtonTrigger

Namespace: DeltaEngine.Input
Assembly: DeltaEngine.Input (in DeltaEngine.Input.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class GamePadButtonTrigger : InputTrigger

The GamePadButtonTrigger type exposes the following members.

Constructors

  NameDescription
Public methodGamePadButtonTrigger(Dictionary String, String )
Initializes a new instance of the GamePadButtonTrigger class
Public methodGamePadButtonTrigger(GamePadButton, State)
Initializes a new instance of the GamePadButtonTrigger class
Top
Methods

  NameDescription
Public methodAdd T  (Inherited from Entity.)
Public methodAddTag (Inherited from Entity.)
Public methodClearTags (Inherited from Entity.)
Public methodContains T  (Inherited from Entity.)
Public methodContainsBehavior T  (Inherited from Entity.)
Public methodContainsTag (Inherited from Entity.)
Protected methodDeactivate (Inherited from Entity.)
Public methodDispose (Inherited from Entity.)
Public methodGet T 
Gets a specific component, derived classes can return faster cached values (e.g. Entity2D) View code on GitHub
(Inherited from Entity.)
Protected methodGetActiveBehaviors (Inherited from Entity.)
Protected methodGetComponentsForSaving (Inherited from Entity.)
Public methodGetOrDefault T  (Inherited from Entity.)
Public methodGetTags (Inherited from Entity.)
Public methodInvoke (Inherited from Trigger.)
Public methodRemove T  (Inherited from Entity.)
Public methodRemoveTag (Inherited from Entity.)
Public methodSet (Inherited from Entity.)
Public methodSetComponents (Inherited from Entity.)
Public methodStart T  (Inherited from Entity.)
Protected methodStartInputDevice (Overrides InputTrigger StartInputDevice .)
Public methodStop T  (Inherited from Entity.)
Public methodToString (Inherited from Entity.)
Public methodUpdate (Inherited from Trigger.)
Top
Fields

  NameDescription
Protected fieldcomponents (Inherited from Entity.)
Public fieldInvoked (Inherited from Trigger.)
Top
Properties

  NameDescription
Public propertyButton
Public propertyGamePadNumber
Public propertyIsActive (Inherited from Entity.)
Public propertyIsPauseable (Inherited from Trigger.)
Public propertyNumberOfComponents (Inherited from Entity.)
Public propertyState
Public propertyUpdatePriority (Inherited from Entity.)
Public propertyWasInvokedThisTick (Inherited from Trigger.)
Top
Remarks

Tests: DeltaEngine.Input.Tests.GamePadButtonTriggerTests
Examples

3 unit tests call DeltaEngine.Input.GamePadButtonTrigger
[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