Added functions for detecting button press and release events (#626)

I also shuffled around the HID interfaces to be more intuitive, deprecated some
Joystick and XboxController member functions, and deprecated the JoystickBase
and GamepadBase classes.

Supersedes #89.
This commit is contained in:
Tyler Veness
2017-10-27 21:45:56 -07:00
committed by Peter Johnson
parent c33fca34e9
commit 21585f70a8
17 changed files with 1334 additions and 724 deletions

View File

@@ -11,6 +11,8 @@
#include <string>
#include "ErrorBase.h"
namespace frc {
class DriverStation;
@@ -18,11 +20,11 @@ class DriverStation;
/**
* GenericHID Interface.
*/
class GenericHID {
class GenericHID : public ErrorBase {
public:
typedef enum { kLeftRumble, kRightRumble } RumbleType;
enum RumbleType { kLeftRumble, kRightRumble };
typedef enum {
enum HIDType {
kUnknown = -1,
kXInputUnknown = 0,
kXInputGamepad = 1,
@@ -40,7 +42,7 @@ class GenericHID {
kHIDDriving = 22,
kHIDFlight = 23,
kHID1stPerson = 24
} HIDType;
};
enum JoystickHand { kLeftHand = 0, kRightHand = 1 };
@@ -49,16 +51,23 @@ class GenericHID {
virtual double GetX(JoystickHand hand = kRightHand) const = 0;
virtual double GetY(JoystickHand hand = kRightHand) const = 0;
virtual double GetRawAxis(int axis) const;
bool GetRawButton(int button) const;
bool GetRawButtonPressed(int button);
bool GetRawButtonReleased(int button);
double GetRawAxis(int axis) const;
int GetPOV(int pov = 0) const;
int GetPOVCount() const;
int GetPort() const;
int GetAxisCount() const;
int GetPOVCount() const;
int GetButtonCount() const;
GenericHID::HIDType GetType() const;
std::string GetName() const;
int GetAxisType(int axis) const;
int GetPort() const;
void SetOutput(int outputNumber, bool value);
void SetOutputs(int value);