Class Gamepad

java.lang.Object
frc.spectrumLib.gamepads.Gamepad
All Implemented Interfaces:
edu.wpi.first.wpilibj2.command.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 edu.wpi.first.wpilibj2.command.Subsystem
    • configure

      public void configure()
    • resetConfig

      public void resetConfig()
    • getLeftStickDirection

      public edu.wpi.first.math.geometry.Rotation2d getLeftStickDirection()
    • getRightStickDirection

      public edu.wpi.first.math.geometry.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 edu.wpi.first.wpilibj2.command.Command rumbleCommand(double leftIntensity, double rightIntensity, double durationSeconds)
      Command that can be used to rumble the pilot controller
    • rumbleCommand

      public edu.wpi.first.wpilibj2.command.Command rumbleCommand(double intensity, double durationSeconds)
    • rumbleCommand

      public edu.wpi.first.wpilibj2.command.Command rumbleCommand(edu.wpi.first.wpilibj2.command.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 edu.wpi.first.wpilibj.GenericHID getHID()
    • getRumbleHID

      protected edu.wpi.first.wpilibj.GenericHID getRumbleHID()
    • rumbleController

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

      public ExpCurve getLeftStickCurve()
    • getRightStickCurve

      public ExpCurve getRightStickCurve()
    • getTriggersCurve

      public ExpCurve getTriggersCurve()