[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:
Starlight220
2021-08-14 20:00:46 +03:00
committed by GitHub
parent 25f6f478a5
commit 031962608b
82 changed files with 2548 additions and 934 deletions

View File

@@ -16,9 +16,8 @@ RobotContainer::RobotContainer() {
// Set up default drive command
m_drive.SetDefaultCommand(frc2::RunCommand(
[this] {
m_drive.ArcadeDrive(
m_driverController.GetY(frc::GenericHID::kLeftHand),
m_driverController.GetX(frc::GenericHID::kRightHand));
m_drive.ArcadeDrive(m_driverController.GetLeftY(),
m_driverController.GetRightX());
},
{&m_drive}));
}
@@ -27,18 +26,21 @@ void RobotContainer::ConfigureButtonBindings() {
// Configure your button bindings here
// Spin up the shooter when the 'A' button is pressed
frc2::JoystickButton(&m_driverController, 1).WhenPressed(&m_spinUpShooter);
frc2::JoystickButton(&m_driverController, frc::XboxController::Button::kA)
.WhenPressed(&m_spinUpShooter);
// Turn off the shooter when the 'B' button is pressed
frc2::JoystickButton(&m_driverController, 2).WhenPressed(&m_stopShooter);
frc2::JoystickButton(&m_driverController, frc::XboxController::Button::kB)
.WhenPressed(&m_stopShooter);
// Shoot when the 'X' button is held
frc2::JoystickButton(&m_driverController, 3)
frc2::JoystickButton(&m_driverController, frc::XboxController::Button::kX)
.WhenPressed(&m_shoot)
.WhenReleased(&m_stopFeeder);
// While holding the shoulder button, drive at half speed
frc2::JoystickButton(&m_driverController, 6)
frc2::JoystickButton(&m_driverController,
frc::XboxController::Button::kRightBumper)
.WhenPressed(&m_driveHalfSpeed)
.WhenReleased(&m_driveFullSpeed);
}