Class WPIGamepad

java.lang.Object
com.stuypulse.stuylib.input.Gamepad
com.stuypulse.stuylib.input.WPIGamepad
All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable
Direct Known Subclasses:
Logitech, PS4

public class WPIGamepad extends Gamepad
WPI Gamepad extends Gamepad and adds functions that makes interacting with the underlying Joystick class easy. The WPI joystick class is kept in a separate class to make it easy to update if WPI updates.

If you would like to get a button id that is not defined, or an axis id that is not defined, use getRawButton(int) or getRawAxis(int). If you want it to return a button for an unimplemented button, type getButton(int).

To initialize this class, pass in a Joystick or an int set to the port number. This will be the Joystick that the Gamepad class will interact with.

If you do not initialize with a Joystick, everything will still work except for - getRawButton(int) - getRawAxis(int) - getButton(int) which will return either false or 0.0

The difference between the implementations of the Gamepad class is how it interacts with the underlying Joystick class.

  • Constructor Details

    • WPIGamepad

      public WPIGamepad(edu.wpi.first.wpilibj.Joystick joystick)
      Parameters:
      joystick - WPI Joystick that will be stored in this class
    • WPIGamepad

      public WPIGamepad(int port)
      Parameters:
      port - The port that the gamepad is plugged into
  • Method Details

    • getGamepadName

      public String getGamepadName()
      Overrides:
      getGamepadName in class Gamepad
      Returns:
      The name of the gamepad being used
    • hasJoystick

      public final boolean hasJoystick()
      Returns:
      if Gamepad has a Joystick
    • getJoystick

      public final edu.wpi.first.wpilibj.Joystick getJoystick()
      Returns:
      Underlying joystick
    • getRawButton

      public final boolean getRawButton(int button)
      Parameters:
      button - Joystick button id
      Returns:
      The value of the button
    • getButton

      public final edu.wpi.first.wpilibj2.command.button.Trigger getButton(int button)
      Parameters:
      button - Joystick button id
      Returns:
      Trigger that activates with getRawButton(int)
    • getRawAxis

      public final double getRawAxis(int axis)
      Parameters:
      axis - Joystick axis id
      Returns:
      The value of the axis
    • setRumble

      public final void setRumble(double intensity)
      Overrides:
      setRumble in class Gamepad
      Parameters:
      intensity - amount to make the gamepad rumble