View Javadoc
1   package org.newdawn.slick.command;
2   
3   /**
4    * A control indicating that a particular direction must be pressed or released
5    * on a controller to cause the command to fire.
6    *
7    * @author kevin
8    */
9   public class ControllerDirectionControl extends ControllerControl {
10      /** The direction indicating we're waiting for the user to press left. */
11      public static final Direction LEFT = new Direction(LEFT_EVENT);
12      /** The direction indicating we're waiting for the user to press up. */
13      public static final Direction UP = new Direction(UP_EVENT);
14      /** The direction indicating we're waiting for the user to press down. */
15      public static final Direction DOWN = new Direction(DOWN_EVENT);
16      /** The direction indicating we're waiting for the user to press right. */
17      public static final Direction RIGHT = new Direction(RIGHT_EVENT);
18  
19      /**
20       * Create a new input that indicates a directional control must be pressed.
21       *
22       * @param controllerIndex The index of the controller to listen to
23       * @param dir The direction to wait for
24       */
25      public ControllerDirectionControl(int controllerIndex, Direction dir) {
26          super(controllerIndex, dir.event, 0);
27      }
28  
29      /**
30       * Create a new input that indicates a directional control must be pressed.
31       *
32       * @param controllerIndex The index of the controller to listen to
33       * @param dir The direction to wait for
34       * @param leftControllerButton leftControllerButton
35       */
36      public ControllerDirectionControl(int controllerIndex, Direction dir, int leftControllerButton) {
37          super(controllerIndex, dir.event, leftControllerButton);
38      }
39  
40      /**
41       * Enum pretender.
42       *
43       * @author kevin
44       */
45      private static class Direction {
46          /** The event to be fired for this direction. */
47          private final int event;
48  
49          /**
50           * Create a new direction indicator/enum value.
51           *
52           * @param event The event to fire when this direction is used
53           */
54          public Direction(int event) {
55              this.event = event;
56          }
57      }
58  }