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:
@@ -17,9 +17,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}));
|
||||
}
|
||||
@@ -28,7 +27,7 @@ void RobotContainer::ConfigureButtonBindings() {
|
||||
// Configure your button bindings here
|
||||
|
||||
// Move the arm to 2 radians above horizontal when the 'A' button is pressed.
|
||||
frc2::JoystickButton(&m_driverController, 1)
|
||||
frc2::JoystickButton(&m_driverController, frc::XboxController::Button::kA)
|
||||
.WhenPressed(
|
||||
[this] {
|
||||
m_arm.SetGoal(2_rad);
|
||||
@@ -37,7 +36,7 @@ void RobotContainer::ConfigureButtonBindings() {
|
||||
{&m_arm});
|
||||
|
||||
// Move the arm to neutral position when the 'B' button is pressed.
|
||||
frc2::JoystickButton(&m_driverController, 2)
|
||||
frc2::JoystickButton(&m_driverController, frc::XboxController::Button::kB)
|
||||
.WhenPressed(
|
||||
[this] {
|
||||
m_arm.SetGoal(ArmConstants::kArmOffset);
|
||||
@@ -46,11 +45,12 @@ void RobotContainer::ConfigureButtonBindings() {
|
||||
{&m_arm});
|
||||
|
||||
// Disable the arm controller when Y is pressed.
|
||||
frc2::JoystickButton(&m_driverController, 4)
|
||||
frc2::JoystickButton(&m_driverController, frc::XboxController::Button::kY)
|
||||
.WhenPressed([this] { m_arm.Disable(); }, {&m_arm});
|
||||
|
||||
// While holding the shoulder button, drive at half speed
|
||||
frc2::JoystickButton(&m_driverController, 6)
|
||||
frc2::JoystickButton(&m_driverController,
|
||||
frc::XboxController::Button::kRightBumper)
|
||||
.WhenPressed([this] { m_drive.SetMaxOutput(0.5); })
|
||||
.WhenReleased([this] { m_drive.SetMaxOutput(1); });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user