Class Gamepad

java.lang.Object
frc.spectrumLib.gamepads.Gamepad
All Implemented Interfaces:
Subsystem, SpectrumSubsystem
Direct Known Subclasses:
Operator, Pilot

public abstract class Gamepad extends Object implements SpectrumSubsystem
  • Field Details

    • kFalse

      public static final Trigger kFalse
    • A

      protected Trigger A
    • B

      protected Trigger B
    • X

      protected Trigger X
    • Y

      protected Trigger Y
    • leftBumper

      protected Trigger leftBumper
    • rightBumper

      protected Trigger rightBumper
    • leftTrigger

      protected Trigger leftTrigger
    • rightTrigger

      protected Trigger rightTrigger
    • leftStickClick

      protected Trigger leftStickClick
    • rightStickClick

      protected Trigger rightStickClick
    • start

      protected Trigger start
    • select

      protected Trigger select
    • upDpad

      protected Trigger upDpad
    • downDpad

      protected Trigger downDpad
    • leftDpad

      protected Trigger leftDpad
    • rightDpad

      protected Trigger rightDpad
    • leftStickY

      protected Trigger leftStickY
    • leftStickX

      protected Trigger leftStickX
    • rightStickY

      protected Trigger rightStickY
    • rightStickX

      protected Trigger rightStickX
    • noBumpers

      public Trigger noBumpers
    • leftBumperOnly

      public Trigger leftBumperOnly
    • rightBumperOnly

      public Trigger rightBumperOnly
    • bothBumpers

      public Trigger bothBumpers
    • noTriggers

      public Trigger noTriggers
    • leftTriggerOnly

      public Trigger leftTriggerOnly
    • rightTriggerOnly

      public Trigger rightTriggerOnly
    • bothTriggers

      public Trigger bothTriggers
    • noModifiers

      public Trigger noModifiers
    • leftStickCurve

      protected final ExpCurve leftStickCurve
    • rightStickCurve

      protected final ExpCurve rightStickCurve
    • triggersCurve

      protected final ExpCurve triggersCurve
    • teleop

      protected Trigger teleop
    • autoMode

      protected Trigger autoMode
    • testMode

      protected Trigger testMode
    • disabled

      protected Trigger disabled
  • Constructor Details

    • Gamepad

      protected Gamepad(Gamepad.Config config)
      Constructs a Gamepad object with the specified configuration.
      Parameters:
      config - the configuration object containing settings for the gamepad

      The constructor initializes the following: - Superclass with port and attachment status from the configuration. - Curve objects for left stick, right stick, and triggers using exponential curves. - If the gamepad is attached, initializes the Xbox controller and its buttons, triggers, sticks, and D-pad.

  • Method Details

    • periodic

      public void periodic()
      Specified by:
      periodic in interface Subsystem
    • configure

      public void configure()
    • resetConfig

      public void resetConfig()
    • getLeftStickDirection

      public Rotation2d getLeftStickDirection()
    • getRightStickDirection

      public Rotation2d getRightStickDirection()
    • getLeftStickCardinals

      public double getLeftStickCardinals()
    • getRightStickCardinals

      public double getRightStickCardinals()
    • getLeftStickMagnitude

      public double getLeftStickMagnitude()
    • getRightStickMagnitude

      public double getRightStickMagnitude()
    • chooseCardinalDirections

      public double chooseCardinalDirections()
      Get proper stick angles for each alliance
      Returns:
    • getBlueAllianceStickCardinals

      public double getBlueAllianceStickCardinals()
    • getRedAllianceStickCardinals

      public double getRedAllianceStickCardinals()
      Flips the stick direction for the red alliance.
      Returns:
    • leftYTrigger

      public Trigger leftYTrigger(Gamepad.Threshold t, double threshold)
    • leftXTrigger

      public Trigger leftXTrigger(Gamepad.Threshold t, double threshold)
    • rightYTrigger

      public Trigger rightYTrigger(Gamepad.Threshold t, double threshold)
    • rightXTrigger

      public Trigger rightXTrigger(Gamepad.Threshold t, double threshold)
    • rightStick

      public Trigger rightStick(double threshold)
    • leftStick

      public Trigger leftStick(double threshold)
    • rumbleCommand

      public Command rumbleCommand(double leftIntensity, double rightIntensity, double durationSeconds)
      Command that can be used to rumble the pilot controller. The intensity should be a value between 0 and 1, where 0 is no rumble and 1 is full rumble. The duration of the rumble is specified in seconds.
      Parameters:
      leftIntensity - the intensity of the left rumble motor (0 to 1)
      rightIntensity - the intensity of the right rumble motor (0 to 1)
      durationSeconds - the duration of the rumble in seconds
      Returns:
      a Command object that can be used to rumble the controller with the specified intensities and duration
    • rumbleCommand

      public Command rumbleCommand(double intensity, double durationSeconds)
      Overloaded method for rumbleCommand that allows for the same intensity on both rumble motors. The duration of the rumble is specified in seconds. The intensity should be a value between 0 and 1, where 0 is no rumble and 1 is full rumble.
      Parameters:
      intensity - the intensity of the rumble (0 to 1)
      durationSeconds - the duration of the rumble in seconds
      Returns:
      a Command object that can be used to rumble the controller with the specified intensity and duration
    • rumbleCommand

      public Command rumbleCommand(Command command)
      Returns a new Command object that combines the given command with a rumble command. The rumble command has a rumble strength of 1 and a duration of 0.5 seconds. The name of the returned command is set to the name of the given command.
      Parameters:
      command - the command to be combined with the rumble command
      Returns:
      a new Command object with rumble command
    • isConnected

      public boolean isConnected()
    • getRightTriggerAxis

      protected double getRightTriggerAxis()
    • getLeftTriggerAxis

      protected double getLeftTriggerAxis()
    • getTwist

      protected double getTwist()
    • getLeftX

      protected double getLeftX()
    • getLeftY

      protected double getLeftY()
    • getRightX

      protected double getRightX()
    • getRightY

      protected double getRightY()
    • getHID

      protected GenericHID getHID()
    • getRumbleHID

      protected GenericHID getRumbleHID()
    • rumbleController

      public void rumbleController(double leftIntensity, double rightIntensity)
    • getLeftStickCurve

      public ExpCurve getLeftStickCurve()
    • getRightStickCurve

      public ExpCurve getRightStickCurve()
    • getTriggersCurve

      public ExpCurve getTriggersCurve()