Enum Class GamepadLayout

java.lang.Object
java.lang.Enum<GamepadLayout>
frc.spectrumLib.gamepads.GamepadLayout
All Implemented Interfaces:
Serializable, Comparable<GamepadLayout>, Constable

public enum GamepadLayout extends Enum<GamepadLayout>
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's NiDsXboxController. 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's Gamepad.
  • Enum Constant Details

  • Field Details

    • NO_BUTTON

      public static final int NO_BUTTON
      A 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 dpadUp
      D-pad buttons, or NO_BUTTON when the D-pad is POV 0 (dpadOnPov()).
    • dpadDown

      public final int dpadDown
      D-pad buttons, or NO_BUTTON when the D-pad is POV 0 (dpadOnPov()).
    • dpadLeft

      public final int dpadLeft
      D-pad buttons, or NO_BUTTON when the D-pad is POV 0 (dpadOnPov()).
    • dpadRight

      public final int dpadRight
      D-pad buttons, or NO_BUTTON when 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

      public static GamepadLayout[] 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

      public static GamepadLayout valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • dpadOnPov

      public boolean dpadOnPov()
      Whether the D-pad arrives as POV 0 rather than as four buttons.
    • detect

      public 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). 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 means WPILIB_DS, whose D-pad is buttons 11-14. Anything else is unknown. Check it with the bench test in the README before trusting AUTO.

      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 - bit i set if button i is present
      povsAvailable - bit i set if POV i is present
      axesAvailable - bit i set if axis i is present
      Returns:
      the layout the data looks like, if it is recognisable
    • simulateController

      public void simulateController(GenericHIDSim sim)
      Makes a simulated joystick look like an Xbox controller as this Driver Station reports it: the same buttons, axes and POV, so detect(GenericHID) recognises it. For the scripted sim and the tests.
      Parameters:
      sim - the simulated joystick