Enum Class GamepadLayout
- All Implemented Interfaces:
Serializable, Comparable<GamepadLayout>, Constable
Where an Xbox controller's buttons and axes arrive, which depends on the Driver Station that
sends them, not on the robot controller.
The SystemCore HAL copies the joystick arrays it gets from MrcCommDaemon without remapping
them (allwpilib v2027.0.0-alpha-6 hal/src/main/native/systemcore/FIRSTDriverStation.cpp),
and WPILib ships separate NiDs* controller classes because "the old DS doesn't have the
same mappings as a new DS" (allwpilib PR #8376). So:
NI_DS: the 2026 NI FRC Driver Station, the one the 2026 FMS supports. The legacy XInput order: A B X Y LB RB Back Start LS RS = buttons 0-9; axes LX LY LT RT RX RY = 0-5; the D-pad is POV 0. The same as WPILib alpha-6'sNiDsXboxController. The sim GUI's "Map gamepad" also produces this order for an Xbox controller on Windows.WPILIB_DS: the 2027 WPILib Driver Station (SDL gamepad order). Buttons south east west north back guide start LS RS LB RB = 0-10, the D-pad as buttons 11-14; axes LX LY RX RY LT RT = 0-5. Taken from WPILib'sGamepad.
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum Constants -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal intfinal intfinal intfinal intD-pad buttons, orNO_BUTTONwhen the D-pad is POV 0 (dpadOnPov()).final intD-pad buttons, orNO_BUTTONwhen the D-pad is POV 0 (dpadOnPov()).final intD-pad buttons, orNO_BUTTONwhen the D-pad is POV 0 (dpadOnPov()).final intD-pad buttons, orNO_BUTTONwhen the D-pad is POV 0 (dpadOnPov()).final intfinal intfinal intfinal intfinal intstatic final intA D-pad button index for a layout whose D-pad is POV 0 instead.final intfinal intfinal intfinal intfinal intfinal intfinal intfinal int -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<GamepadLayout> detect(long buttonsAvailable, int povsAvailable, int axesAvailable) detect(GenericHID)on the availability bitmasks.static Optional<GamepadLayout> detect(GenericHID hid) Guesses which Driver Station layout a connected controller's data is in, from what the DS says the controller has (logged by AdvantageKit, so this replays).booleanWhether the D-pad arrives as POV 0 rather than as four buttons.voidMakes a simulated joystick look like an Xbox controller as this Driver Station reports it: the same buttons, axes and POV, sodetect(GenericHID)recognises it.static GamepadLayoutReturns the enum constant of this class with the specified name.static GamepadLayout[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NI_DS
-
WPILIB_DS
-
-
Field Details
-
NO_BUTTON
public static final int NO_BUTTONA D-pad button index for a layout whose D-pad is POV 0 instead.- See Also:
-
a
public final int a -
b
public final int b -
x
public final int x -
y
public final int y -
leftBumper
public final int leftBumper -
rightBumper
public final int rightBumper -
back
public final int back -
start
public final int start -
leftStick
public final int leftStick -
rightStick
public final int rightStick -
dpadUp
public final int dpadUpD-pad buttons, orNO_BUTTONwhen the D-pad is POV 0 (dpadOnPov()). -
dpadDown
public final int dpadDownD-pad buttons, orNO_BUTTONwhen the D-pad is POV 0 (dpadOnPov()). -
dpadLeft
public final int dpadLeftD-pad buttons, orNO_BUTTONwhen the D-pad is POV 0 (dpadOnPov()). -
dpadRight
public final int dpadRightD-pad buttons, orNO_BUTTONwhen the D-pad is POV 0 (dpadOnPov()). -
leftX
public final int leftX -
leftY
public final int leftY -
rightX
public final int rightX -
rightY
public final int rightY -
leftTrigger
public final int leftTrigger -
rightTrigger
public final int rightTrigger
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
dpadOnPov
public boolean dpadOnPov()Whether the D-pad arrives as POV 0 rather than as four buttons. -
detect
Guesses which Driver Station layout a connected controller's data is in, from what the DS says the controller has (logged by AdvantageKit, so this replays). Empty when it can't tell.This is inferred, not documented: a POV means
NI_DS(whatever the button count); button 14 with no POV meansWPILIB_DS, whose D-pad is buttons 11-14. Anything else is unknown. Check it with the bench test in the README before trustingAUTO.- Parameters:
hid- the controller- Returns:
- the layout its data looks like, if it is recognisable
-
detect
public static Optional<GamepadLayout> detect(long buttonsAvailable, int povsAvailable, int axesAvailable) detect(GenericHID)on the availability bitmasks.- Parameters:
buttonsAvailable- bitiset if buttoniis presentpovsAvailable- bitiset if POViis presentaxesAvailable- bitiset if axisiis present- Returns:
- the layout the data looks like, if it is recognisable
-
simulateController
Makes a simulated joystick look like an Xbox controller as this Driver Station reports it: the same buttons, axes and POV, sodetect(GenericHID)recognises it. For the scripted sim and the tests.- Parameters:
sim- the simulated joystick
-