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:
@@ -23,9 +23,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}));
|
||||
}
|
||||
@@ -33,12 +32,14 @@ RobotContainer::RobotContainer() {
|
||||
void RobotContainer::ConfigureButtonBindings() {
|
||||
// Configure your button bindings here
|
||||
|
||||
// Grab the hatch when the 'A' button is pressed.
|
||||
frc2::JoystickButton(&m_driverController, 1).WhenPressed(&m_grabHatch);
|
||||
// Release the hatch when the 'B' button is pressed.
|
||||
frc2::JoystickButton(&m_driverController, 2).WhenPressed(&m_releaseHatch);
|
||||
// While holding the shoulder button, drive at half speed
|
||||
frc2::JoystickButton(&m_driverController, 6)
|
||||
// Grab the hatch when the 'Circle' button is pressed.
|
||||
frc2::JoystickButton(&m_driverController, frc::PS4Controller::Button::kCircle)
|
||||
.WhenPressed(&m_grabHatch);
|
||||
// Release the hatch when the 'Square' button is pressed.
|
||||
frc2::JoystickButton(&m_driverController, frc::PS4Controller::Button::kSquare)
|
||||
.WhenPressed(&m_releaseHatch);
|
||||
// While holding R1, drive at half speed
|
||||
frc2::JoystickButton(&m_driverController, frc::PS4Controller::Button::kR1)
|
||||
.WhenPressed(&m_driveHalfSpeed)
|
||||
.WhenReleased(&m_driveFullSpeed);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <frc/XboxController.h>
|
||||
#include <frc/PS4Controller.h>
|
||||
#include <frc/smartdashboard/SendableChooser.h>
|
||||
#include <frc2/command/Command.h>
|
||||
#include <frc2/command/FunctionalCommand.h>
|
||||
@@ -35,7 +35,7 @@ class RobotContainer {
|
||||
|
||||
private:
|
||||
// The driver's controller
|
||||
frc::XboxController m_driverController{OIConstants::kDriverControllerPort};
|
||||
frc::PS4Controller m_driverController{OIConstants::kDriverControllerPort};
|
||||
|
||||
// The robot's subsystems and commands are defined here...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user