Class DSGamepadChooser

java.lang.Object
org.wpilib.driverstation.DSGamepadChooser

public class DSGamepadChooser extends Object
A set of selectable options controlled by a Gamepad.

The D-pad up and down buttons select which selectable is active. The D-pad left and right buttons change the selected option in the active selectable.

  • Constructor Details

    • DSGamepadChooser

      public DSGamepadChooser(int port)
      Constructs a DSGamepadChooser.
      Parameters:
      port - The port index on the Driver Station that the gamepad is plugged into (0-5).
    • DSGamepadChooser

      public DSGamepadChooser(Gamepad gamepad)
      Constructs a DSGamepadChooser.
      Parameters:
      gamepad - The gamepad used to change selections.
  • Method Details

    • getGamepad

      public Gamepad getGamepad()
      Get the gamepad used to change selections.
      Returns:
      the gamepad
    • addOptions

      public DSGamepadChooser.GamepadSelectable addOptions(String name, List<String> options)
      Adds a selectable with the given options.

      The first option is selected by default.

      Parameters:
      name - selectable name
      options - available options
      Returns:
      the created selectable
    • addOptions

      public DSGamepadChooser.GamepadSelectable addOptions(String name, String... options)
      Adds a selectable with the given options.

      The first option is selected by default.

      Parameters:
      name - selectable name
      options - available options
      Returns:
      the created selectable
    • addIntegerOptions

      public DSGamepadChooser.GamepadSelectable addIntegerOptions(String name, int min, int max, int delta)
      Adds a selectable with integer options from min to max, inclusive, stepping by delta.

      The first option is selected by default.

      Parameters:
      name - selectable name
      min - minimum option
      max - maximum option
      delta - amount between options
      Returns:
      the created selectable
    • addDoubleOptions

      public DSGamepadChooser.GamepadSelectable addDoubleOptions(String name, double min, double max, double delta)
      Adds a selectable with floating point options from min to max, inclusive, stepping by delta.

      The first option is selected by default.

      Parameters:
      name - selectable name
      min - minimum option
      max - maximum option
      delta - amount between options
      Returns:
      the created selectable
    • update

      public void update()
      Updates selectable selection and adds the current selections to the driver station display.

      The D-pad up and down buttons select which selectable is active. The D-pad left and right buttons change the selected option in the active selectable.

      Call DriverStationDisplay.updateLines() externally to flush display updates.

    • getSelected

      public String getSelected(String name)
      Gets the currently selected option for a selectable.
      Parameters:
      name - selectable name
      Returns:
      the currently selected option
    • getSelectedInteger

      public int getSelectedInteger(String name)
      Gets the currently selected integer option for a selectable.
      Parameters:
      name - selectable name
      Returns:
      the currently selected option
    • getSelectedDouble

      public double getSelectedDouble(String name)
      Gets the currently selected double option for a selectable.
      Parameters:
      name - selectable name
      Returns:
      the currently selected option
    • getSelectedIndex

      public int getSelectedIndex(String name)
      Gets the currently selected option index for a selectable.
      Parameters:
      name - selectable name
      Returns:
      the currently selected option index
    • getSelectableNames

      public List<String> getSelectableNames()
      Gets the names of all selectables.
      Returns:
      selectable names
    • getSelectedSelectable

      public DSGamepadChooser.GamepadSelectable getSelectedSelectable()
      Gets the selectable currently controlled by D-pad left and right.
      Returns:
      the selected selectable