WPILibC++  2019.1.1-beta-1-31-g81d10bc
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
XboxController.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2018 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  private:
236  enum class Button {
237  kBumperLeft = 5,
238  kBumperRight = 6,
239  kStickLeft = 9,
240  kStickRight = 10,
241  kA = 1,
242  kB = 2,
243  kX = 3,
244  kY = 4,
245  kBack = 7,
246  kStart = 8
247  };
248 };
249 
250 } // namespace frc
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
bool GetStartButton() const
Read the value of the start button on the controller.
bool GetYButtonPressed()
Whether the Y button was pressed since the last check.
Handle input from Xbox 360 or Xbox One controllers connected to the Driver Station.
Definition: XboxController.h:23
bool GetBButtonReleased()
Whether the B button was released since the last check.
bool GetYButtonReleased()
Whether the Y button was released since the last check.
bool GetStartButtonReleased()
Whether the start button was released since the last check.
double GetX(JoystickHand hand) const override
Get the X axis value of the controller.
bool GetStickButton(JoystickHand hand) const
Read the value of the stick button on the controller.
bool GetBackButton() const
Whether the Y button was released since the last check.
bool GetStickButtonPressed(JoystickHand hand)
Whether the stick button was pressed since the last check.
bool GetStartButtonPressed()
Whether the start button was pressed since the last check.
bool GetBackButtonPressed()
Whether the back button was pressed since the last check.
bool GetBButtonPressed()
Whether the B button was pressed since the last check.
double GetTriggerAxis(JoystickHand hand) const
Get the trigger axis value of the controller.
double GetY(JoystickHand hand) const override
Get the Y axis value of the controller.
bool GetBButton() const
Read the value of the B button on the controller.
bool GetAButtonPressed()
Whether the A button was pressed since the last check.
bool GetBumperPressed(JoystickHand hand)
Whether the bumper was pressed since the last check.
bool GetXButton() const
Read the value of the X button on the controller.
bool GetBumper(JoystickHand hand) const
Read the value of the bumper button on the controller.
bool GetAButton() const
Read the value of the A button on the controller.
bool GetBumperReleased(JoystickHand hand)
Whether the bumper was released since the last check.
bool GetAButtonReleased()
Whether the A button was released since the last check.
bool GetXButtonPressed()
Whether the X button was pressed since the last check.
bool GetBackButtonReleased()
Whether the back button was released since the last check.
bool GetXButtonReleased()
Whether the X button was released since the last check.
GenericHID Interface.
Definition: GenericHID.h:23
bool GetYButton() const
Read the value of the Y button on the controller.
bool GetStickButtonReleased(JoystickHand hand)
Whether the stick button was released since the last check.
XboxController(int port)
Construct an instance of an Xbox controller.