WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
GenericHID.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-2016. 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 <stdint.h>
11 
12 #include <string>
13 
14 namespace frc {
15 
16 class DriverStation;
17 
21 class GenericHID {
22  public:
23  typedef enum { kLeftRumble, kRightRumble } RumbleType;
24 
25  typedef enum {
26  kUnknown = -1,
27  kXInputUnknown = 0,
28  kXInputGamepad = 1,
29  kXInputWheel = 2,
30  kXInputArcadeStick = 3,
31  kXInputFlightStick = 4,
32  kXInputDancePad = 5,
33  kXInputGuitar = 6,
34  kXInputGuitar2 = 7,
35  kXInputDrumKit = 8,
36  kXInputGuitar3 = 11,
37  kXInputArcadePad = 19,
38  kHIDJoystick = 20,
39  kHIDGamepad = 21,
40  kHIDDriving = 22,
41  kHIDFlight = 23,
42  kHID1stPerson = 24
43  } HIDType;
44 
45  enum JoystickHand { kLeftHand = 0, kRightHand = 1 };
46 
47  explicit GenericHID(int port);
48  virtual ~GenericHID() = default;
49 
50  virtual double GetX(JoystickHand hand = kRightHand) const = 0;
51  virtual double GetY(JoystickHand hand = kRightHand) const = 0;
52  virtual double GetRawAxis(int axis) const;
53 
54  bool GetRawButton(int button) const;
55 
56  int GetPOV(int pov = 0) const;
57  int GetPOVCount() const;
58 
59  int GetPort() const;
60  GenericHID::HIDType GetType() const;
61  std::string GetName() const;
62 
63  void SetOutput(int outputNumber, bool value);
64  void SetOutputs(int value);
65  void SetRumble(RumbleType type, double value);
66 
67  private:
68  DriverStation& m_ds;
69  int m_port;
70  int m_outputs = 0;
71  uint16_t m_leftRumble = 0;
72  uint16_t m_rightRumble = 0;
73 };
74 
75 } // namespace frc
int GetPort() const
Get the port number of the HID.
Definition: GenericHID.cpp:68
std::string GetName() const
Get the name of the HID.
Definition: GenericHID.cpp:84
int GetPOV(int pov=0) const
Get the angle in degrees of a POV on the HID.
Definition: GenericHID.cpp:52
Provide access to the network communication data to / from the Driver Station.
Definition: DriverStation.h:28
void SetOutput(int outputNumber, bool value)
Set a single HID output value for the HID.
Definition: GenericHID.cpp:93
int GetPOVCount() const
Get the number of POVs for the HID.
Definition: GenericHID.cpp:61
virtual double GetRawAxis(int axis) const
Get the value of the axis.
Definition: GenericHID.cpp:25
bool GetRawButton(int button) const
Get the button value (starting at button 1)
Definition: GenericHID.cpp:39
void SetOutputs(int value)
Set all output values for the HID.
Definition: GenericHID.cpp:105
GenericHID Interface.
Definition: GenericHID.h:21
GenericHID::HIDType GetType() const
Get the type of the HID.
Definition: GenericHID.cpp:75
void SetRumble(RumbleType type, double value)
Set the rumble output for the HID.
Definition: GenericHID.cpp:118