Robot Core Documentation
Loading...
Searching...
No Matches
edu.wpi.first.wpilibj.Joystick Class Reference

Classes

enum  AxisType
 
enum  ButtonType
 

Public Member Functions

 Joystick (final int port)
 
void setXChannel (int channel)
 
void setYChannel (int channel)
 
void setZChannel (int channel)
 
void setThrottleChannel (int channel)
 
void setTwistChannel (int channel)
 
int getXChannel ()
 
int getYChannel ()
 
int getZChannel ()
 
int getTwistChannel ()
 
int getThrottleChannel ()
 
final double getX ()
 
final double getY ()
 
final double getZ ()
 
final double getTwist ()
 
final double getThrottle ()
 
boolean getTrigger ()
 
boolean getTriggerPressed ()
 
boolean getTriggerReleased ()
 
BooleanEvent trigger (EventLoop loop)
 
boolean getTop ()
 
boolean getTopPressed ()
 
boolean getTopReleased ()
 
BooleanEvent top (EventLoop loop)
 
double getMagnitude ()
 
double getDirectionRadians ()
 
double getDirectionDegrees ()
 

Static Public Attributes

static final byte kDefaultXChannel = 0
 
static final byte kDefaultYChannel = 1
 
static final byte kDefaultZChannel = 2
 
static final byte kDefaultTwistChannel = 2
 
static final byte kDefaultThrottleChannel = 3
 

Detailed Description

Handle input from Flight Joysticks connected to the Driver Station.

This class handles standard input that comes from the Driver Station. Each time a value is requested the most recent value is returned. There is a single class instance for each joystick and the mapping of ports to hardware buttons depends on the code in the Driver Station.

Constructor & Destructor Documentation

◆ Joystick()

edu.wpi.first.wpilibj.Joystick.Joystick ( final int port)

Construct an instance of a joystick.

Parameters
portThe port index on the Driver Station that the joystick is plugged into.

Member Function Documentation

◆ getDirectionDegrees()

double edu.wpi.first.wpilibj.Joystick.getDirectionDegrees ( )

Get the direction of the vector formed by the joystick and its origin in degrees.

Returns
The direction of the vector in degrees

◆ getDirectionRadians()

double edu.wpi.first.wpilibj.Joystick.getDirectionRadians ( )

Get the direction of the vector formed by the joystick and its origin in radians.

Returns
The direction of the vector in radians

◆ getMagnitude()

double edu.wpi.first.wpilibj.Joystick.getMagnitude ( )

Get the magnitude of the direction vector formed by the joystick's current position relative to its origin.

Returns
The magnitude of the direction vector

◆ getThrottle()

final double edu.wpi.first.wpilibj.Joystick.getThrottle ( )

Get the throttle value of the current joystick. This depends on the mapping of the joystick connected to the current port.

Returns
The Throttle value of the joystick.

◆ getThrottleChannel()

int edu.wpi.first.wpilibj.Joystick.getThrottleChannel ( )

Get the channel currently associated with the throttle axis.

Returns
The channel for the axis.

◆ getTop()

boolean edu.wpi.first.wpilibj.Joystick.getTop ( )

Read the state of the top button on the joystick.

Returns
The state of the top button.

◆ getTopPressed()

boolean edu.wpi.first.wpilibj.Joystick.getTopPressed ( )

Whether the top button was pressed since the last check.

Returns
Whether the button was pressed since the last check.

◆ getTopReleased()

boolean edu.wpi.first.wpilibj.Joystick.getTopReleased ( )

Whether the top button was released since the last check.

Returns
Whether the button was released since the last check.

◆ getTrigger()

boolean edu.wpi.first.wpilibj.Joystick.getTrigger ( )

Read the state of the trigger on the joystick.

Returns
The state of the trigger.

◆ getTriggerPressed()

boolean edu.wpi.first.wpilibj.Joystick.getTriggerPressed ( )

Whether the trigger was pressed since the last check.

Returns
Whether the button was pressed since the last check.

◆ getTriggerReleased()

boolean edu.wpi.first.wpilibj.Joystick.getTriggerReleased ( )

Whether the trigger was released since the last check.

Returns
Whether the button was released since the last check.

◆ getTwist()

final double edu.wpi.first.wpilibj.Joystick.getTwist ( )

Get the twist value of the current joystick. This depends on the mapping of the joystick connected to the current port.

Returns
The Twist value of the joystick.

◆ getTwistChannel()

int edu.wpi.first.wpilibj.Joystick.getTwistChannel ( )

Get the channel currently associated with the twist axis.

Returns
The channel for the axis.

◆ getX()

final double edu.wpi.first.wpilibj.Joystick.getX ( )

Get the X value of the joystick. This depends on the mapping of the joystick connected to the current port.

Returns
The X value of the joystick.

◆ getXChannel()

int edu.wpi.first.wpilibj.Joystick.getXChannel ( )

Get the channel currently associated with the X axis.

Returns
The channel for the axis.

◆ getY()

final double edu.wpi.first.wpilibj.Joystick.getY ( )

Get the Y value of the joystick. This depends on the mapping of the joystick connected to the current port.

Returns
The Y value of the joystick.

◆ getYChannel()

int edu.wpi.first.wpilibj.Joystick.getYChannel ( )

Get the channel currently associated with the Y axis.

Returns
The channel for the axis.

◆ getZ()

final double edu.wpi.first.wpilibj.Joystick.getZ ( )

Get the z position of the HID.

Returns
the z position

◆ getZChannel()

int edu.wpi.first.wpilibj.Joystick.getZChannel ( )

Get the channel currently associated with the Z axis.

Returns
The channel for the axis.

◆ setThrottleChannel()

void edu.wpi.first.wpilibj.Joystick.setThrottleChannel ( int channel)

Set the channel associated with the throttle axis.

Parameters
channelThe channel to set the axis to.

◆ setTwistChannel()

void edu.wpi.first.wpilibj.Joystick.setTwistChannel ( int channel)

Set the channel associated with the twist axis.

Parameters
channelThe channel to set the axis to.

◆ setXChannel()

void edu.wpi.first.wpilibj.Joystick.setXChannel ( int channel)

Set the channel associated with the X axis.

Parameters
channelThe channel to set the axis to.

◆ setYChannel()

void edu.wpi.first.wpilibj.Joystick.setYChannel ( int channel)

Set the channel associated with the Y axis.

Parameters
channelThe channel to set the axis to.

◆ setZChannel()

void edu.wpi.first.wpilibj.Joystick.setZChannel ( int channel)

Set the channel associated with the Z axis.

Parameters
channelThe channel to set the axis to.

◆ top()

BooleanEvent edu.wpi.first.wpilibj.Joystick.top ( EventLoop loop)

Constructs an event instance around the top button's digital signal.

Parameters
loopthe event loop instance to attach the event to.
Returns
an event instance representing the top button's digital signal attached to the given loop.

◆ trigger()

BooleanEvent edu.wpi.first.wpilibj.Joystick.trigger ( EventLoop loop)

Constructs an event instance around the trigger button's digital signal.

Parameters
loopthe event loop instance to attach the event to.
Returns
an event instance representing the trigger button's digital signal attached to the given loop.

Member Data Documentation

◆ kDefaultThrottleChannel

final byte edu.wpi.first.wpilibj.Joystick.kDefaultThrottleChannel = 3
static

Default throttle axis channel.

◆ kDefaultTwistChannel

final byte edu.wpi.first.wpilibj.Joystick.kDefaultTwistChannel = 2
static

Default twist axis channel.

◆ kDefaultXChannel

final byte edu.wpi.first.wpilibj.Joystick.kDefaultXChannel = 0
static

Default X axis channel.

◆ kDefaultYChannel

final byte edu.wpi.first.wpilibj.Joystick.kDefaultYChannel = 1
static

Default Y axis channel.

◆ kDefaultZChannel

final byte edu.wpi.first.wpilibj.Joystick.kDefaultZChannel = 2
static

Default Z axis channel.


The documentation for this class was generated from the following file: