Package com.stuypulse.stuylib.input
Class WPIGamepad
java.lang.Object
com.stuypulse.stuylib.input.Gamepad
com.stuypulse.stuylib.input.WPIGamepad
- All Implemented Interfaces:
edu.wpi.first.util.sendable.Sendable
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.
-
Field Summary
Fields inherited from class com.stuypulse.stuylib.input.Gamepad
ANALOG_THRESHOLD
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal edu.wpi.first.wpilibj2.command.button.Trigger
getButton
(int button) final edu.wpi.first.wpilibj.Joystick
final double
getRawAxis
(int axis) final boolean
getRawButton
(int button) final boolean
final void
setRumble
(double intensity) Methods inherited from class com.stuypulse.stuylib.input.Gamepad
getBottomButton, getDPad, getDPadDown, getDPadLeft, getDPadRight, getDPadUp, getDPadX, getDPadY, getLeftBumper, getLeftButton, getLeftMenuButton, getLeftStick, getLeftStickButton, getLeftStickDown, getLeftStickLeft, getLeftStickRight, getLeftStickUp, getLeftTrigger, getLeftTriggerButton, getLeftTriggerPressed, getLeftX, getLeftY, getRawBottomButton, getRawDPadDown, getRawDPadLeft, getRawDPadRight, getRawDPadUp, getRawLeftBumper, getRawLeftButton, getRawLeftMenuButton, getRawLeftStickButton, getRawRightBumper, getRawRightButton, getRawRightMenuButton, getRawRightStickButton, getRawTopButton, getRightBumper, getRightButton, getRightMenuButton, getRightStick, getRightStickButton, getRightStickDown, getRightStickLeft, getRightStickRight, getRightStickUp, getRightTrigger, getRightTriggerButton, getRightTriggerPressed, getRightX, getRightY, getTopButton, initSendable
-
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
- Overrides:
getGamepadName
in classGamepad
- 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)
-