mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
Added XboxController class (#140)
Joystick and Gamepad functionality was separated into cleaner interfaces.
This commit is contained in:
committed by
Peter Johnson
parent
8c93ceb728
commit
140c365e4b
@@ -9,30 +9,67 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace frc {
|
||||
|
||||
class DriverStation;
|
||||
|
||||
/**
|
||||
* GenericHID Interface.
|
||||
*/
|
||||
class GenericHID {
|
||||
public:
|
||||
typedef enum { kLeftRumble, kRightRumble } RumbleType;
|
||||
|
||||
typedef enum {
|
||||
kUnknown = -1,
|
||||
kXInputUnknown = 0,
|
||||
kXInputGamepad = 1,
|
||||
kXInputWheel = 2,
|
||||
kXInputArcadeStick = 3,
|
||||
kXInputFlightStick = 4,
|
||||
kXInputDancePad = 5,
|
||||
kXInputGuitar = 6,
|
||||
kXInputGuitar2 = 7,
|
||||
kXInputDrumKit = 8,
|
||||
kXInputGuitar3 = 11,
|
||||
kXInputArcadePad = 19,
|
||||
kHIDJoystick = 20,
|
||||
kHIDGamepad = 21,
|
||||
kHIDDriving = 22,
|
||||
kHIDFlight = 23,
|
||||
kHID1stPerson = 24
|
||||
} HIDType;
|
||||
|
||||
enum JoystickHand { kLeftHand = 0, kRightHand = 1 };
|
||||
|
||||
explicit GenericHID(int port);
|
||||
virtual ~GenericHID() = default;
|
||||
|
||||
virtual float GetX(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual float GetY(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual float GetZ() const = 0;
|
||||
virtual float GetTwist() const = 0;
|
||||
virtual float GetThrottle() const = 0;
|
||||
virtual float GetRawAxis(int axis) const = 0;
|
||||
virtual float GetRawAxis(int axis) const;
|
||||
|
||||
virtual bool GetTrigger(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual bool GetTop(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual bool GetBumper(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual bool GetRawButton(int button) const = 0;
|
||||
bool GetRawButton(int button) const;
|
||||
|
||||
virtual int GetPOV(int pov = 0) const = 0;
|
||||
int GetPOV(int pov = 0) const;
|
||||
int GetPOVCount() const;
|
||||
|
||||
int GetPort() const;
|
||||
GenericHID::HIDType GetType() const;
|
||||
std::string GetName() const;
|
||||
|
||||
void SetOutput(int outputNumber, bool value);
|
||||
void SetOutputs(int value);
|
||||
void SetRumble(RumbleType type, double value);
|
||||
|
||||
private:
|
||||
DriverStation& m_ds;
|
||||
int m_port;
|
||||
int m_outputs = 0;
|
||||
uint16_t m_leftRumble = 0;
|
||||
uint16_t m_rightRumble = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
Reference in New Issue
Block a user