WPILibC++  unspecified
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 "GenericHID.h"
11 
12 namespace frc {
13 
23 class XboxController : public GenericHID {
24  public:
25  explicit XboxController(int port);
26  virtual ~XboxController() = default;
27 
28  XboxController(const XboxController&) = delete;
29  XboxController& operator=(const XboxController&) = delete;
30 
31  double GetX(JoystickHand hand) const override;
32  double GetY(JoystickHand hand) const override;
33  double GetTriggerAxis(JoystickHand hand) const;
34 
35  bool GetBumper(JoystickHand hand) const;
36  bool GetBumperPressed(JoystickHand hand);
37  bool GetBumperReleased(JoystickHand hand);
38 
39  bool GetStickButton(JoystickHand hand) const;
40  bool GetStickButtonPressed(JoystickHand hand);
41  bool GetStickButtonReleased(JoystickHand hand);
42 
43  bool GetAButton() const;
44  bool GetAButtonPressed();
45  bool GetAButtonReleased();
46 
47  bool GetBButton() const;
48  bool GetBButtonPressed();
49  bool GetBButtonReleased();
50 
51  bool GetXButton() const;
52  bool GetXButtonPressed();
53  bool GetXButtonReleased();
54 
55  bool GetYButton() const;
56  bool GetYButtonPressed();
57  bool GetYButtonReleased();
58 
59  bool GetBackButton() const;
60  bool GetBackButtonPressed();
61  bool GetBackButtonReleased();
62 
63  bool GetStartButton() const;
64  bool GetStartButtonPressed();
66 
67  private:
68  enum class Button {
69  kBumperLeft = 5,
70  kBumperRight = 6,
71  kStickLeft = 9,
72  kStickRight = 10,
73  kA = 1,
74  kB = 2,
75  kX = 3,
76  kY = 4,
77  kBack = 7,
78  kStart = 8
79  };
80 };
81 
82 } // namespace frc
bool GetStartButton() const
Read the value of the start button on the controller.
Definition: XboxController.cpp:291
bool GetAButtonReleased()
Whether the A button was released since the last check.
Definition: XboxController.cpp:172
Definition: RobotController.cpp:14
bool GetBButton() const
Read the value of the B button on the controller.
Definition: XboxController.cpp:181
bool GetBButtonPressed()
Whether the B button was pressed since the last check.
Definition: XboxController.cpp:190
bool GetStartButtonPressed()
Whether the start button was pressed since the last check.
Definition: XboxController.cpp:300
Handle input from Xbox 360 or Xbox One controllers connected to the Driver Station.
Definition: XboxController.h:23
double GetX(JoystickHand hand) const override
Get the X axis value of the controller.
Definition: XboxController.cpp:32
bool GetBButtonReleased()
Whether the B button was released since the last check.
Definition: XboxController.cpp:199
bool GetXButtonPressed()
Whether the X button was pressed since the last check.
Definition: XboxController.cpp:217
double GetTriggerAxis(JoystickHand hand) const
Get the trigger axis value of the controller.
Definition: XboxController.cpp:58
bool GetYButton() const
Read the value of the Y button on the controller.
Definition: XboxController.cpp:235
XboxController(int port)
Construct an instance of an Xbox controller.
Definition: XboxController.cpp:22
bool GetBumper(JoystickHand hand) const
Read the value of the bumper button on the controller.
Definition: XboxController.cpp:71
double GetY(JoystickHand hand) const override
Get the Y axis value of the controller.
Definition: XboxController.cpp:45
bool GetStickButtonPressed(JoystickHand hand)
Whether the stick button was pressed since the last check.
Definition: XboxController.cpp:127
bool GetYButtonPressed()
Whether the Y button was pressed since the last check.
Definition: XboxController.cpp:244
bool GetXButtonReleased()
Whether the X button was released since the last check.
Definition: XboxController.cpp:226
bool GetStartButtonReleased()
Whether the start button was released since the last check.
Definition: XboxController.cpp:309
bool GetBackButtonPressed()
Whether the back button was pressed since the last check.
Definition: XboxController.cpp:272
bool GetStickButtonReleased(JoystickHand hand)
Whether the stick button was released since the last check.
Definition: XboxController.cpp:141
bool GetXButton() const
Read the value of the X button on the controller.
Definition: XboxController.cpp:208
bool GetBumperReleased(JoystickHand hand)
Whether the bumper was released since the last check.
Definition: XboxController.cpp:99
bool GetStickButton(JoystickHand hand) const
Read the value of the stick button on the controller.
Definition: XboxController.cpp:113
bool GetBumperPressed(JoystickHand hand)
Whether the bumper was pressed since the last check.
Definition: XboxController.cpp:85
bool GetBackButton() const
Read the value of the back button on the controller.
Definition: XboxController.cpp:263
bool GetBackButtonReleased()
Whether the back button was released since the last check.
Definition: XboxController.cpp:281
GenericHID Interface.
Definition: GenericHID.h:23
bool GetAButton() const
Read the value of the A button on the controller.
Definition: XboxController.cpp:154
bool GetYButtonReleased()
Whether the Y button was released since the last check.
Definition: XboxController.cpp:253
bool GetAButtonPressed()
Whether the A button was pressed since the last check.
Definition: XboxController.cpp:163