Brian Silverman | f7f267a | 2017-02-04 16:16:08 -0800 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2016-2017. 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 "ErrorBase.h" |
| 11 | #include "GamepadBase.h" |
| 12 | |
| 13 | namespace frc { |
| 14 | |
| 15 | class DriverStation; |
| 16 | |
| 17 | /** |
| 18 | * Handle input from Xbox 360 or Xbox One controllers connected to the Driver |
| 19 | * Station. |
| 20 | * |
| 21 | * This class handles Xbox input that comes from the Driver Station. Each time a |
| 22 | * value is requested the most recent value is returend. There is a single class |
| 23 | * instance for each controller and the mapping of ports to hardware buttons |
| 24 | * depends on the code in the Driver Station. |
| 25 | */ |
| 26 | class XboxController : public GamepadBase, public ErrorBase { |
| 27 | public: |
| 28 | explicit XboxController(int port); |
| 29 | virtual ~XboxController() = default; |
| 30 | |
| 31 | XboxController(const XboxController&) = delete; |
| 32 | XboxController& operator=(const XboxController&) = delete; |
| 33 | |
| 34 | double GetX(JoystickHand hand) const override; |
| 35 | double GetY(JoystickHand hand) const override; |
| 36 | |
| 37 | bool GetBumper(JoystickHand hand) const override; |
| 38 | bool GetStickButton(JoystickHand hand) const override; |
| 39 | |
| 40 | virtual double GetTriggerAxis(JoystickHand hand) const; |
| 41 | |
| 42 | bool GetAButton() const; |
| 43 | bool GetBButton() const; |
| 44 | bool GetXButton() const; |
| 45 | bool GetYButton() const; |
| 46 | bool GetBackButton() const; |
| 47 | bool GetStartButton() const; |
| 48 | |
| 49 | private: |
| 50 | DriverStation& m_ds; |
| 51 | }; |
| 52 | |
| 53 | } // namespace frc |