WPILibC++  2020.3.2-60-g3011ebe
XboxController.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2020 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include "frc/GenericHID.h"
11 
12 namespace frc {
13 
23 class XboxController : public GenericHID {
24  public:
33  explicit XboxController(int port);
34 
35  virtual ~XboxController() = default;
36 
37  XboxController(XboxController&&) = default;
38  XboxController& operator=(XboxController&&) = default;
39 
45  double GetX(JoystickHand hand) const override;
46 
52  double GetY(JoystickHand hand) const override;
53 
59  double GetTriggerAxis(JoystickHand hand) const;
60 
66  bool GetBumper(JoystickHand hand) const;
67 
74  bool GetBumperPressed(JoystickHand hand);
75 
82  bool GetBumperReleased(JoystickHand hand);
83 
90  bool GetStickButton(JoystickHand hand) const;
91 
98  bool GetStickButtonPressed(JoystickHand hand);
99 
106  bool GetStickButtonReleased(JoystickHand hand);
107 
113  bool GetAButton() const;
114 
120  bool GetAButtonPressed();
121 
127  bool GetAButtonReleased();
128 
134  bool GetBButton() const;
135 
141  bool GetBButtonPressed();
142 
148  bool GetBButtonReleased();
149 
155  bool GetXButton() const;
156 
162  bool GetXButtonPressed();
163 
169  bool GetXButtonReleased();
170 
176  bool GetYButton() const;
177 
183  bool GetYButtonPressed();
184 
190  bool GetYButtonReleased();
191 
197  bool GetBackButton() const;
198 
204  bool GetBackButtonPressed();
205 
211  bool GetBackButtonReleased();
212 
219  bool GetStartButton() const;
220 
226  bool GetStartButtonPressed();
227 
233  bool GetStartButtonReleased();
234 
235  enum class Button {
236  kBumperLeft = 5,
237  kBumperRight = 6,
238  kStickLeft = 9,
239  kStickRight = 10,
240  kA = 1,
241  kB = 2,
242  kX = 3,
243  kY = 4,
244  kBack = 7,
245  kStart = 8
246  };
247 
248  enum class Axis {
249  kLeftX = 0,
250  kRightX = 4,
251  kLeftY = 1,
252  kRightY = 5,
253  kLeftTrigger = 2,
254  kRightTrigger = 3
255  };
256 };
257 
258 } // namespace frc
frc::XboxController::GetBButtonPressed
bool GetBButtonPressed()
Whether the B button was pressed since the last check.
frc::XboxController::GetYButtonReleased
bool GetYButtonReleased()
Whether the Y button was released since the last check.
frc::XboxController::GetBackButton
bool GetBackButton() const
Whether the Y button was released since the last check.
frc::XboxController::GetY
double GetY(JoystickHand hand) const override
Get the Y axis value of the controller.
frc::XboxController::GetStickButton
bool GetStickButton(JoystickHand hand) const
Read the value of the stick button on the controller.
frc::XboxController::GetStickButtonReleased
bool GetStickButtonReleased(JoystickHand hand)
Whether the stick button was released since the last check.
frc::XboxController::GetBumperReleased
bool GetBumperReleased(JoystickHand hand)
Whether the bumper was released since the last check.
frc::XboxController::GetStartButtonReleased
bool GetStartButtonReleased()
Whether the start button was released since the last check.
frc::XboxController::XboxController
XboxController(int port)
Construct an instance of an Xbox controller.
frc::XboxController::GetBackButtonReleased
bool GetBackButtonReleased()
Whether the back button was released since the last check.
frc::XboxController::GetBumper
bool GetBumper(JoystickHand hand) const
Read the value of the bumper button on the controller.
frc::XboxController::GetAButtonPressed
bool GetAButtonPressed()
Whether the A button was pressed since the last check.
frc::XboxController::GetBackButtonPressed
bool GetBackButtonPressed()
Whether the back button was pressed since the last check.
frc::XboxController::GetStickButtonPressed
bool GetStickButtonPressed(JoystickHand hand)
Whether the stick button was pressed since the last check.
frc::XboxController::GetTriggerAxis
double GetTriggerAxis(JoystickHand hand) const
Get the trigger axis value of the controller.
frc::XboxController::GetXButton
bool GetXButton() const
Read the value of the X button on the controller.
frc::XboxController::GetBButtonReleased
bool GetBButtonReleased()
Whether the B button was released since the last check.
frc::XboxController::GetX
double GetX(JoystickHand hand) const override
Get the X axis value of the controller.
frc::XboxController::GetAButtonReleased
bool GetAButtonReleased()
Whether the A button was released since the last check.
frc::XboxController::GetStartButton
bool GetStartButton() const
Read the value of the start button on the controller.
frc::XboxController::GetBButton
bool GetBButton() const
Read the value of the B button on the controller.
frc::XboxController::GetStartButtonPressed
bool GetStartButtonPressed()
Whether the start button was pressed since the last check.
frc::XboxController::GetYButton
bool GetYButton() const
Read the value of the Y button on the controller.
frc
A class that enforces constraints on the differential drive kinematics.
Definition: PDPSim.h:16
frc::XboxController::GetBumperPressed
bool GetBumperPressed(JoystickHand hand)
Whether the bumper was pressed since the last check.
frc::XboxController::GetAButton
bool GetAButton() const
Read the value of the A button on the controller.
frc::GenericHID
GenericHID Interface.
Definition: GenericHID.h:23
frc::XboxController::GetYButtonPressed
bool GetYButtonPressed()
Whether the Y button was pressed since the last check.
frc::XboxController
Handle input from Xbox 360 or Xbox One controllers connected to the Driver Station.
Definition: XboxController.h:23
frc::XboxController::GetXButtonReleased
bool GetXButtonReleased()
Whether the X button was released since the last check.
frc::XboxController::GetXButtonPressed
bool GetXButtonPressed()
Whether the X button was pressed since the last check.