10#include "wpi/units/angle.hpp"
265 enum Axis { kX, kY, kZ, kTwist, kThrottle, kNumAxes };
266 enum Button { kTrigger = 1, kTop = 2 };
268 std::array<int, Axis::kNumAxes> m_axes;
This class provides an easy way to link actions to active high logic signals.
Definition BooleanEvent.hpp:28
A declarative way to bind a set of actions to a loop and execute them when the loop is polled.
Definition EventLoop.hpp:15
Joystick & operator=(Joystick &&)=default
bool GetTrigger() const
Read the state of the trigger on the joystick.
void SetTwistChannel(int channel)
Set the channel associated with the twist axis.
double GetX() const
Get the X value of the current joystick.
int GetTwistChannel() const
Get the channel currently associated with the twist axis.
int GetZChannel() const
Get the channel currently associated with the Z axis.
int GetXChannel() const
Get the channel currently associated with the X axis.
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.
BooleanEvent Trigger(EventLoop *loop) const
Constructs an event instance around the trigger button's digital signal.
double GetTwist() const
Get the twist value of the current joystick.
int GetYChannel() const
Get the channel currently associated with the Y axis.
int GetThrottleChannel() const
Get the channel currently associated with the throttle axis.
bool GetTriggerPressed()
Whether the trigger was pressed since the last check.
void SetXChannel(int channel)
Set the channel associated with the X axis.
static constexpr int kDefaultTwistChannel
Default twist axis channel.
Definition Joystick.hpp:31
void SetYChannel(int channel)
Set the channel associated with the Y axis.
ButtonType
Represents a digital button on a joystick.
Definition Joystick.hpp:54
@ kTopButton
kTop.
Definition Joystick.hpp:58
@ kTriggerButton
kTrigger.
Definition Joystick.hpp:56
void SetZChannel(int channel)
Set the channel associated with the Z axis.
BooleanEvent Top(EventLoop *loop) const
Constructs an event instance around the top button's digital signal.
Joystick(Joystick &&)=default
Joystick(int port)
Construct an instance of a joystick.
static constexpr int kDefaultYChannel
Default Y axis channel.
Definition Joystick.hpp:27
double GetThrottle() const
Get the throttle value of the current joystick.
bool GetTriggerReleased()
Whether the trigger was released since the last check.
static constexpr int kDefaultThrottleChannel
Default throttle axis channel.
Definition Joystick.hpp:33
void SetThrottleChannel(int channel)
Set the channel associated with the throttle axis.
AxisType
Represents an analog axis on a joystick.
Definition Joystick.hpp:38
@ kTwistAxis
Twist axis.
Definition Joystick.hpp:46
@ kZAxis
Z axis.
Definition Joystick.hpp:44
@ kYAxis
Y axis.
Definition Joystick.hpp:42
@ kXAxis
X axis.
Definition Joystick.hpp:40
@ kThrottleAxis
Throttle axis.
Definition Joystick.hpp:48
~Joystick() override=default
wpi::units::radian_t GetDirection() const
Get the direction of the vector formed by the joystick and its origin.
static constexpr int kDefaultXChannel
Default X axis channel.
Definition Joystick.hpp:25
bool GetTopPressed()
Whether the top button was pressed since the last check.
double GetZ() const
Get the Z value of the current joystick.
static constexpr int kDefaultZChannel
Default Z axis channel.
Definition Joystick.hpp:29
double GetY() const
Get the Y value of the current joystick.
double GetMagnitude() const
Get the magnitude of the vector formed by the joystick's current position relative to its origin.
Definition CvSource.hpp:15