java.lang.ObjectGamePad
public class GamePad
A high-level wrapper to a controller. This is a singleton class that returns all of the controllers found connected to this machine.
Note that this is designed to work with DualShock Playstation-like controllers (but without rumble).
These are controllers with 4 action buttons, 6 L and R buttons (3 for left and 3 for right), 2 middle buttons (select and start), a d-pad (the direction buttons) and 2 analogue sticks.
Nested Class Summary | |
---|---|
static class |
GamePad.Axis
The different types of axis on the joypad. |
static class |
GamePad.Button
An enum of all of the different buttons most commonly supported. |
Field Summary | |
---|---|
static int |
NO_ANGLE
Methods that return an angle often also need to return that there is no angle at all. |
Method Summary | |
---|---|
Direction |
getAxis(GamePad.Axis axis)
This returns a Direction describing the current angle and strength of the Axis polled. |
static GamePad |
getGamePad()
If no game pad is plugged in then this will throw an exception. |
static GamePad |
getGamePad(int index)
The index given should be from 0 to the number of game pads on this machine, exclusive. |
static GamePad[] |
getGamePads()
If no pads are found then an empty array is returned. |
static int |
getNumGamePads()
|
boolean |
isAxisSupported(GamePad.Axis axis)
|
boolean |
isButtonSupported(GamePad.Button button)
|
boolean |
isDown(GamePad.Button button)
The button given must already be supported. |
static void |
refreshGamePads()
Rescans the PC for all GamePads connected. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int NO_ANGLE
Method Detail |
---|
public Direction getAxis(GamePad.Axis axis)
axis
- The Axis to poll.
public static GamePad getGamePad()
java.lang.IllegalStateException
- if there is no real game pad found.public static GamePad getGamePad(int index)
index
- The index of the GamePad to find.
public static GamePad[] getGamePads()
public static int getNumGamePads()
public boolean isAxisSupported(GamePad.Axis axis)
public boolean isButtonSupported(GamePad.Button button)
public boolean isDown(GamePad.Button button)
button
- The button to check.
public static void refreshGamePads()