Package com.stuypulse.stuylib.input
Class Gamepad
java.lang.Object
com.stuypulse.stuylib.input.Gamepad
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable
- Direct Known Subclasses:
AutoGamepad
,WPIGamepad
,Xbox
An class for using gamepads with different interfaces. You can implement this class in another
file, and then use it with a standard interface.
Any unimplemented buttons will never be triggered, so if a certain controller is missing one, dont worry about it.
The button type that is used in OI.java is automatically generated by this class, as long as
you implement the getRaw...()
function, the getRaw...()
function will work.
This class does not come with a constructor because by itself, the class does not do anything. You need to extend this class in order to use it.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal edu.wpi.first.wpilibj2.command.button.Trigger
final Vector2D
getDPad()
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final double
getDPadX()
final double
getDPadY()
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final Vector2D
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
double
final edu.wpi.first.wpilibj2.command.button.Trigger
final boolean
double
getLeftX()
double
getLeftY()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final Vector2D
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
final edu.wpi.first.wpilibj2.command.button.Trigger
double
final edu.wpi.first.wpilibj2.command.button.Trigger
final boolean
double
double
final edu.wpi.first.wpilibj2.command.button.Trigger
final void
initSendable
(edu.wpi.first.util.sendable.SendableBuilder builder) void
setRumble
(double intensity)
-
Field Details
-
ANALOG_THRESHOLD
public static final double ANALOG_THRESHOLD- See Also:
-
-
Constructor Details
-
Gamepad
public Gamepad()
-
-
Method Details
-
getGamepadName
- Returns:
- The name of the gamepad being used
-
getLeftX
public double getLeftX()- Returns:
- The X position of the left analog stick
-
getLeftY
public double getLeftY()- Returns:
- The Y position of the left analog stick
-
getRightX
public double getRightX()- Returns:
- The X position of the right analog stick
-
getRightY
public double getRightY()- Returns:
- The Y position of the right analog stick
-
getRawDPadUp
public boolean getRawDPadUp()- Returns:
- If the up d-pad button is pressed
-
getRawDPadDown
public boolean getRawDPadDown()- Returns:
- If the down d-pad button is pressed
-
getRawDPadLeft
public boolean getRawDPadLeft()- Returns:
- If the left d-pad button is pressed
-
getRawDPadRight
public boolean getRawDPadRight()- Returns:
- If the right d-pad button is pressed
-
getRawLeftBumper
public boolean getRawLeftBumper()- Returns:
- If the left bumper is pressed
-
getRawRightBumper
public boolean getRawRightBumper()- Returns:
- If the right bumper is pressed
-
getLeftTrigger
public double getLeftTrigger()- Returns:
- The amount that the left trigger is pressed
-
getRightTrigger
public double getRightTrigger()- Returns:
- The amount that the right trigger is pressed
-
getRawTopButton
public boolean getRawTopButton()- Returns:
- If the face button on the top is pressed
-
getRawBottomButton
public boolean getRawBottomButton()- Returns:
- If the face button on the bottom is pressed
-
getRawLeftButton
public boolean getRawLeftButton()- Returns:
- If the face button on the left is pressed
-
getRawRightButton
public boolean getRawRightButton()- Returns:
- If the face button on the right is pressed
-
getRawLeftMenuButton
public boolean getRawLeftMenuButton()- Returns:
- If the left menu button is pressed
-
getRawRightMenuButton
public boolean getRawRightMenuButton()- Returns:
- If the right menu button is pressed
-
getRawLeftStickButton
public boolean getRawLeftStickButton()- Returns:
- If the left analog stick is pressed down
-
getRawRightStickButton
public boolean getRawRightStickButton()- Returns:
- If the right analog stick is pressed down
-
setRumble
public void setRumble(double intensity) - Parameters:
intensity
- amount to make the gamepad rumble
-
getLeftStick
- Returns:
- The position of the left analog stick in a
Vector2D
-
getRightStick
- Returns:
- The position of the right analog stick in a
Vector2D
-
getDPadX
public final double getDPadX()- Returns:
- The x position of the d-pad as if it were a stick
-
getDPadY
public final double getDPadY()- Returns:
- The y position of the d-pad as if it were a stick
-
getDPad
- Returns:
- The position of the d-pad as if it were a stick in a Vector2D
-
getLeftTriggerPressed
public final boolean getLeftTriggerPressed()- Returns:
- If the left trigger is pressed down more than
ANALOG_THRESHOLD
-
getRightTriggerPressed
public final boolean getRightTriggerPressed()- Returns:
- If the left trigger is pressed down more than
ANALOG_THRESHOLD
-
getLeftStickUp
public final edu.wpi.first.wpilibj2.command.button.Trigger getLeftStickUp()- Returns:
- Trigger that activates when
getLeftY()
is greater than +ANALOG_THRESHOLD
-
getLeftStickDown
public final edu.wpi.first.wpilibj2.command.button.Trigger getLeftStickDown()- Returns:
- Trigger that activates when
getLeftY()
is less than -ANALOG_THRESHOLD
-
getLeftStickLeft
public final edu.wpi.first.wpilibj2.command.button.Trigger getLeftStickLeft()- Returns:
- Trigger that activates when
getLeftX()
is less than -ANALOG_THRESHOLD
-
getLeftStickRight
public final edu.wpi.first.wpilibj2.command.button.Trigger getLeftStickRight()- Returns:
- Trigger that activates when
getLeftX()
is greater than +ANALOG_THRESHOLD
-
getRightStickUp
public final edu.wpi.first.wpilibj2.command.button.Trigger getRightStickUp()- Returns:
- Trigger that activates when
getRightY()
is greater than +ANALOG_THRESHOLD
-
getRightStickDown
public final edu.wpi.first.wpilibj2.command.button.Trigger getRightStickDown()- Returns:
- Trigger that activates when
getRightY()
is less than -ANALOG_THRESHOLD
-
getRightStickLeft
public final edu.wpi.first.wpilibj2.command.button.Trigger getRightStickLeft()- Returns:
- Trigger that activates when
getRightX()
is less than -ANALOG_THRESHOLD
-
getRightStickRight
public final edu.wpi.first.wpilibj2.command.button.Trigger getRightStickRight()- Returns:
- Trigger that activates when
getRightX()
is greater than +ANALOG_THRESHOLD
-
getDPadUp
public final edu.wpi.first.wpilibj2.command.button.Trigger getDPadUp()- Returns:
- Trigger that activates with
getRawDPadUp()
-
getDPadDown
public final edu.wpi.first.wpilibj2.command.button.Trigger getDPadDown()- Returns:
- Trigger that activates with
getRawDPadDown()
-
getDPadLeft
public final edu.wpi.first.wpilibj2.command.button.Trigger getDPadLeft()- Returns:
- Trigger that activates with
getRawDPadLeft()
-
getDPadRight
public final edu.wpi.first.wpilibj2.command.button.Trigger getDPadRight()- Returns:
- Trigger that activates with
getRawDPadRight()
-
getLeftBumper
public final edu.wpi.first.wpilibj2.command.button.Trigger getLeftBumper()- Returns:
- Trigger that activates with
getRawLeftBumper()
-
getRightBumper
public final edu.wpi.first.wpilibj2.command.button.Trigger getRightBumper()- Returns:
- Trigger that activates with
getRawRightBumper()
-
getLeftTriggerButton
public final edu.wpi.first.wpilibj2.command.button.Trigger getLeftTriggerButton()- Returns:
- Trigger that activates with
getLeftTriggerPressed()
-
getRightTriggerButton
public final edu.wpi.first.wpilibj2.command.button.Trigger getRightTriggerButton()- Returns:
- Trigger that activates with
getRightTriggerPressed()
-
getTopButton
public final edu.wpi.first.wpilibj2.command.button.Trigger getTopButton()- Returns:
- Trigger that activates with
getRawTopButton()
-
getBottomButton
public final edu.wpi.first.wpilibj2.command.button.Trigger getBottomButton()- Returns:
- Trigger that activates with
getRawBottomButton()
-
getLeftButton
public final edu.wpi.first.wpilibj2.command.button.Trigger getLeftButton()- Returns:
- Trigger that activates with
getRawLeftButton()
-
getRightButton
public final edu.wpi.first.wpilibj2.command.button.Trigger getRightButton()- Returns:
- Trigger that activates with
getRawRightButton()
-
getLeftMenuButton
public final edu.wpi.first.wpilibj2.command.button.Trigger getLeftMenuButton()- Returns:
- Trigger that activates with
getRawLeftMenuButton()
-
getRightMenuButton
public final edu.wpi.first.wpilibj2.command.button.Trigger getRightMenuButton()- Returns:
- Trigger that activates with
getRawRightMenuButton()
-
getLeftStickButton
public final edu.wpi.first.wpilibj2.command.button.Trigger getLeftStickButton()- Returns:
- Trigger that activates with
getRawLeftStickButton()
-
getRightStickButton
public final edu.wpi.first.wpilibj2.command.button.Trigger getRightStickButton()- Returns:
- Trigger that activates with
getRawRightStickButton()
-
initSendable
public final void initSendable(edu.wpi.first.util.sendable.SendableBuilder builder) - Specified by:
initSendable
in interfaceedu.wpi.first.util.sendable.Sendable
-