241 enum Axis { kX, kY, kZ, kTwist, kThrottle, kNumAxes };
242 enum Button { kTrigger = 1, kTop = 2 };
244 std::array<int, Axis::kNumAxes> m_axes;
This class provides an easy way to link actions to inputs.
Definition: BooleanEvent.h:31
The loop polling BooleanEvent objects and executing the actions bound to them.
Definition: EventLoop.h:15
Handle input from standard HID devices connected to the Driver Station.
Definition: GenericHID.h:24
Handle input from standard Joysticks connected to the Driver Station.
Definition: Joystick.h:21
int GetYChannel() const
Get the channel currently associated with the Y axis.
double GetDirectionDegrees() const
Get the direction of the vector formed by the joystick and its origin in degrees.
void SetTwistChannel(int channel)
Set the channel associated with the twist axis.
bool GetTrigger() const
Read the state of the trigger on the joystick.
double GetTwist() const
Get the twist value of the current joystick.
int GetTwistChannel() const
Get the channel currently associated with the twist axis.
ButtonType
Definition: Joystick.h:30
@ kTopButton
Definition: Joystick.h:30
@ kTriggerButton
Definition: Joystick.h:30
bool GetTriggerReleased()
Whether the trigger was released since the last check.
static constexpr int kDefaultThrottleChannel
Definition: Joystick.h:27
bool GetTopPressed()
Whether the top button was pressed since the last check.
void SetThrottleChannel(int channel)
Set the channel associated with the throttle axis.
bool GetTriggerPressed()
Whether the trigger was pressed since the last check.
BooleanEvent Top(EventLoop *loop) const
Constructs an event instance around the top button's digital signal.
~Joystick() override=default
int GetZChannel() const
Get the channel currently associated with the Z axis.
static constexpr int kDefaultXChannel
Definition: Joystick.h:23
double GetX() const
Get the X value of the current joystick.
Joystick(int port)
Construct an instance of a joystick.
int GetXChannel() const
Get the channel currently associated with the X axis.
double GetThrottle() const
Get the throttle value of the current joystick.
double GetZ() const
Get the Z value of the current joystick.
bool GetTop() const
Read the state of the top button on the joystick.
bool GetTopReleased()
Whether the top button was released since the last check.
static constexpr int kDefaultTwistChannel
Definition: Joystick.h:26
static constexpr int kDefaultYChannel
Definition: Joystick.h:24
Joystick & operator=(Joystick &&)=default
void SetYChannel(int channel)
Set the channel associated with the Y axis.
double GetDirectionRadians() const
Get the direction of the vector formed by the joystick and its origin in radians.
double GetY() const
Get the Y value of the current joystick.
Joystick(Joystick &&)=default
int GetThrottleChannel() const
Get the channel currently associated with the throttle axis.
BooleanEvent Trigger(EventLoop *loop) const
Constructs an event instance around the trigger button's digital signal.
void SetZChannel(int channel)
Set the channel associated with the Z axis.
AxisType
Definition: Joystick.h:29
@ kThrottleAxis
Definition: Joystick.h:29
@ kTwistAxis
Definition: Joystick.h:29
@ kXAxis
Definition: Joystick.h:29
@ kYAxis
Definition: Joystick.h:29
@ kZAxis
Definition: Joystick.h:29
static constexpr int kDefaultZChannel
Definition: Joystick.h:25
double GetMagnitude() const
Get the magnitude of the direction vector formed by the joystick's current position relative to its o...
void SetXChannel(int channel)
Set the channel associated with the X axis.
Definition: AprilTagFieldLayout.h:22