mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpilib] Add PS4Controller, remove Hand from GenericHID/XboxController (#3345)
- GenericHID is now concrete, and has only getRawAxis/Button(int) functionality - getXxx() has been moved into Joystick as that's the only place where it makes sense - Hand (and therefore getXxx(Hand)) has been removed, replaced by specific getLeft/RightXxx() methods in XboxController and the new PS4Controller class - C++ ::Button:: and ::Axis:: enums have been converted to identically-namespaced static constexpr ints
This commit is contained in:
@@ -27,9 +27,8 @@ RobotContainer::RobotContainer() {
|
||||
|
||||
// Set up default drive command
|
||||
m_drive.SetDefaultCommand(DefaultDrive(
|
||||
&m_drive,
|
||||
[this] { return m_driverController.GetY(frc::GenericHID::kLeftHand); },
|
||||
[this] { return m_driverController.GetX(frc::GenericHID::kRightHand); }));
|
||||
&m_drive, [this] { return m_driverController.GetLeftY(); },
|
||||
[this] { return m_driverController.GetRightX(); }));
|
||||
}
|
||||
|
||||
void RobotContainer::ConfigureButtonBindings() {
|
||||
@@ -41,13 +40,14 @@ void RobotContainer::ConfigureButtonBindings() {
|
||||
// stack-allocated and declared as members of RobotContainer.
|
||||
|
||||
// Grab the hatch when the 'A' button is pressed.
|
||||
frc2::JoystickButton(&m_driverController, 1)
|
||||
frc2::JoystickButton(&m_driverController, frc::XboxController::Button::kA)
|
||||
.WhenPressed(new GrabHatch(&m_hatch));
|
||||
// Release the hatch when the 'B' button is pressed.
|
||||
frc2::JoystickButton(&m_driverController, 2)
|
||||
frc2::JoystickButton(&m_driverController, frc::XboxController::Button::kB)
|
||||
.WhenPressed(new ReleaseHatch(&m_hatch));
|
||||
// While holding the shoulder button, drive at half speed
|
||||
frc2::JoystickButton(&m_driverController, 6)
|
||||
frc2::JoystickButton(&m_driverController,
|
||||
frc::XboxController::Button::kRightBumper)
|
||||
.WhenHeld(new HalveDriveSpeed(&m_drive));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user