public final class Joystick extends Object
Window.pollEvents()
method instead.Modifier and Type | Class and Description |
---|---|
static class |
Joystick.Axis
Enumeration of supported joystick and gamepad axes.
|
Modifier and Type | Field and Description |
---|---|
static int |
BUTTON_COUNT
The maximum amount of supported joystick and gamepad buttons.
|
static int |
JOYSTICK_COUNT
The maximum amount of supported joysticks and gamepads.
|
Modifier and Type | Method and Description |
---|---|
static float |
getAxisPosition(int joystick,
Joystick.Axis axis)
Retrieves the current position of the specified axis of a joystick or gamepad.
|
static int |
getButtonCount(int joystick)
Retrieves the amount of buttons of a joystick or gamepad.
|
static boolean |
hasAxis(int joystick,
Joystick.Axis axis)
Checks whether a joystick or gamepad supports the specified axis.
|
static boolean |
isButtonPressed(int joystick,
int button)
Checks whether the specified button is currently pressed on a joystick or gamepad.
|
static boolean |
isConnected(int joystick)
Checks if a joystick or gamepad is currently connected.
|
static void |
update()
Forces an update of the states of all joysticks and gamepads.
|
public static final int JOYSTICK_COUNT
public static final int BUTTON_COUNT
public static boolean isConnected(int joystick)
joystick
- the index of the joystick to check.
This value must range between 0 (inclusive) and
#JOYSTICK_COUNT
(exclusive).true
if the joystick or gamepad is currently connected,
false
otherwise.public static int getButtonCount(int joystick)
joystick
- the index of the joystick in question.
This value must range between 0 (inclusive) and
#JOYSTICK_COUNT
(exclusive).public static boolean hasAxis(int joystick, Joystick.Axis axis)
joystick
- the index of the joystick in question.
This value must range between 0 (inclusive) and
#JOYSTICK_COUNT
(exclusive).axis
- the axis to look for.true
if the joystick or gamepad supports the given axis,
false
otherwise.public static boolean isButtonPressed(int joystick, int button)
joystick
- the index of the joystick in question.
This value must range between 0 (inclusive) and
#JOYSTICK_COUNT
(exclusive).button
- the index of the button to check.
This value must range between 0 (inclusive) and
#BUTTON_COUNT
(exclusive).true
if the button is currently pressed on the joystick or gamepad,
false
otherwise.public static float getAxisPosition(int joystick, Joystick.Axis axis)
joystick
- the index of the joystick in question.
This value must range between 0 (inclusive) and
#JOYSTICK_COUNT
(exclusive).axis
- the axis in question.public static void update()