Skip to main content

FlixelGamepadButton

View source

class

org.flixelgdx.input.gamepad.FlixelGamepadButton

public final class FlixelGamepadButton

Logical gamepad button and axis identifiers for FlixelGamepadInputManager, resolved to native indices through each Controller.getMapping() (gdx-controllers SDL-style layout).

Important Note for Desktop (LWJGL3) vs Web (TeaVM)

On LWJGL3, gdx-controllers-desktop uses SDL with a large controller database, so many USB pads are remapped to the same logical layout. On web, gdx-controllers-teavm reads the browser Gamepad API and always exposes the W3C standard face-button indices (south, east, west, north) through a fixed ControllerMapping. If a device reports non-standard button ordering but the browser still labels the mapping as standard (or the hardware wires two actions to overlapping reports), logical A and Y can disagree with what you see on desktop for the same physical pad. That is a platform and driver limitation, not something logicalButtonToNative can infer without per-device tables. Games that need perfect parity can offer a remap screen or branch on Application.getType() and Controller.getName().

Fields

NONE

public static final int NONE = -2

ANY

public static final int ANY = -1

A

public static final int A = 96

B

public static final int B = 97

C

public static final int C = 98

X

public static final int X = 99

Y

public static final int Y = 100

Z

public static final int Z = 101

L1

public static final int L1 = 102

R1

public static final int R1 = 103

L2

public static final int L2 = 104

R2

public static final int R2 = 105

THUMBL

public static final int THUMBL = 106

THUMBR

public static final int THUMBR = 107

START

public static final int START = 108

SELECT

public static final int SELECT = 109

MODE

public static final int MODE = 110

CIRCLE

public static final int CIRCLE = 255

DPAD_UP

public static final int DPAD_UP = 200

DPAD_DOWN

public static final int DPAD_DOWN = 201

DPAD_LEFT

public static final int DPAD_LEFT = 202

DPAD_RIGHT

public static final int DPAD_RIGHT = 203

AXIS_LEFT_X

public static final int AXIS_LEFT_X = 0

AXIS_LEFT_Y

public static final int AXIS_LEFT_Y = 1

AXIS_RIGHT_X

public static final int AXIS_RIGHT_X = 2

AXIS_RIGHT_Y

public static final int AXIS_RIGHT_Y = 3

AXIS_TRIGGER_L

public static final int AXIS_TRIGGER_L = 4

AXIS_TRIGGER_R

public static final int AXIS_TRIGGER_R = 5

Methods

logicalButtonToNative(Controller, int)

public static int logicalButtonToNative(Controller controller, int logicalButton)

Resolves a logical button code to the native button index for the given controller.

Parameters:

NameDescription
controllerController whose Controller.getMapping() is used.
logicalButtonValue from this class, except FlixelGamepadButton.ANY and FlixelGamepadButton.NONE.

Returns: Native index, or ControllerMapping.UNDEFINED when unsupported.


logicalAxisToNative(Controller, int)

public static int logicalAxisToNative(Controller controller, int logicalAxis)

Resolves a logical axis constant to the native axis index for the given controller.

Stick axes (FlixelGamepadButton.AXIS_LEFT_X, FlixelGamepadButton.AXIS_LEFT_Y, FlixelGamepadButton.AXIS_RIGHT_X, FlixelGamepadButton.AXIS_RIGHT_Y) are resolved through the controller's ControllerMapping. Trigger axes (FlixelGamepadButton.AXIS_TRIGGER_L, FlixelGamepadButton.AXIS_TRIGGER_R) return fixed SDL ordinals (4 and 5) because ControllerMapping has no axis fields for triggers; this is only meaningful on the Jamepad/SDL desktop backend.

Parameters:

NameDescription
controllerController whose Controller.getMapping() is used.
logicalAxisOne of the AXIS_* constants in this class.

Returns: Native axis index, or ControllerMapping.UNDEFINED when unsupported.


fromString(String)

public static int fromString(String name)

Resolves a button name to a logical button code.

Parameters:

NameDescription
nameHuman-readable name (case-insensitive), for example "A" or "START".

Returns: A logical code from this class, or Keys.UNKNOWN when not recognized.


toString(int)

public static String toString(int logicalButtonCode)

Returns a readable English name for a logical button code.

Parameters:

NameDescription
logicalButtonCodeValue from this class.

Returns: Description, or "?" when unknown.