blob: 657abe6d301781404acf808a8f6233c706e92d1f [file] [log] [blame]
Brian Silvermanf7f267a2017-02-04 16:16:08 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008-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 <stdint.h>
11
12#include <string>
13
14namespace frc {
15
16class DriverStation;
17
18/**
19 * GenericHID Interface.
20 */
21class 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