How can I program the bumper left and right, and trigger left and right in the Generic HID java WPILIB?
private final GenericHID control = new GenericHID(0);
How can I program the bumper left and right, and trigger left and right in the Generic HID java WPILIB?
private final GenericHID control = new GenericHID(0);
If you use one of its controller-specific derived classes instead, e.g. XBoxController, there are specific functions for those. If you want to use GenericHID, fundamentally all controls are mapped to either a button, an axis, or a POV. You can use the DS joystick indicators to help you find which (they show live views of what’s being pressed).
Triggers (for most controllers) are analog, so you can use GenericHID’s .getRawAxis(int axis)
method.
Bumpers are read the same as traditional buttons: .getRawButton(int button)
, .getRawButtonPressed(int button)
, etc.
The IDs themselves will differ depending on the controller you are using:
PS5 Controllers:
Xbox Controllers:
(If you are using one of these controllers, maybe consider using the WPILIB wrapper for it instead, such as PS5Controller
or XboxController
.
If you are using a different type of controller, you may have to figure out the IDs manually, which can be done online or possibly through driverstation.