RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
org.wpilib.driverstation.Joystick Class Reference
Inheritance diagram for org.wpilib.driverstation.Joystick:
org.wpilib.driverstation.HIDDevice

Classes

enum  AxisType
enum  ButtonType

Public Member Functions

GenericHID getHID ()
 Joystick (final int port)
 Joystick (final GenericHID hid)
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 ()
boolean getRawButton (int button)
boolean getRawButtonPressed (int button)
boolean getRawButtonReleased (int button)
double getRawAxis (int axis)
POVDirection getPOV (int pov)
POVDirection getPOV ()
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 DEFAULT_X_CHANNEL = 0
static final byte DEFAULT_Y_CHANNEL = 1
static final byte DEFAULT_Z_CHANNEL = 2
static final byte DEFAULT_TWIST_CHANNEL = 2
static final byte DEFAULT_THROTTLE_CHANNEL = 3

Additional Inherited Members

Public Attributes inherited from org.wpilib.driverstation.HIDDevice
int MAX_DEVICES = DriverStationBackend.JOYSTICK_PORTS

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.

Definition at line 19 of file Joystick.java.

Constructor & Destructor Documentation

◆ Joystick() [1/2]

org.wpilib.driverstation.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.

Definition at line 90 of file Joystick.java.

◆ Joystick() [2/2]

org.wpilib.driverstation.Joystick.Joystick ( final GenericHID hid)

Construct an instance of a joystick with a GenericHID object.

Parameters
hidThe GenericHID object to use for this joystick.

Definition at line 99 of file Joystick.java.

Member Function Documentation

◆ getDirectionDegrees()

double org.wpilib.driverstation.Joystick.getDirectionDegrees ( )

Get the direction of the vector formed by the joystick and its origin in degrees. 0 is forward and clockwise is positive. (Straight right is 90.)

Returns
The direction of the vector in degrees

Definition at line 427 of file Joystick.java.

◆ getDirectionRadians()

double org.wpilib.driverstation.Joystick.getDirectionRadians ( )

Get the direction of the vector formed by the joystick and its origin in radians. 0 is forward and clockwise is positive. (Straight right is π/2.)

Returns
The direction of the vector in radians

Definition at line 409 of file Joystick.java.

◆ getHID()

GenericHID org.wpilib.driverstation.Joystick.getHID ( )

Get the underlying GenericHID object.

Returns
the wrapped GenericHID object

Implements org.wpilib.driverstation.HIDDevice.

Definition at line 81 of file Joystick.java.

◆ getMagnitude()

double org.wpilib.driverstation.Joystick.getMagnitude ( )

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

Returns
The magnitude of the direction vector

Definition at line 399 of file Joystick.java.

◆ getPOV() [1/2]

POVDirection org.wpilib.driverstation.Joystick.getPOV ( )

Get the angle in degrees of the default POV on the HID.

The POV angles start at 0 in the up direction, and increase clockwise (e.g. right is 90, upper-left is 315).

Returns
the angle of the POV

Definition at line 264 of file Joystick.java.

◆ getPOV() [2/2]

POVDirection org.wpilib.driverstation.Joystick.getPOV ( int pov)

Get the angle in degrees of a POV on the HID.

The POV angles start at 0 in the up direction, and increase clockwise (e.g. right is 90, upper-left is 315).

Parameters
povThe index of the POV to read, starting at 0.
Returns
the angle of the POV

Definition at line 252 of file Joystick.java.

◆ getRawAxis()

double org.wpilib.driverstation.Joystick.getRawAxis ( int axis)

Get the value of the axis.

Parameters
axisThe axis to read, starting at 0.
Returns
The value of the axis.

Definition at line 239 of file Joystick.java.

◆ getRawButton()

boolean org.wpilib.driverstation.Joystick.getRawButton ( int button)

Get the button value (starting at button 1).

The buttons are returned in a single 16 bit value with one bit representing the state of each button. The appropriate button is returned as a boolean value.

Parameters
buttonThe button number to be read (starting at 1)
Returns
The state of the button

Definition at line 209 of file Joystick.java.

◆ getRawButtonPressed()

boolean org.wpilib.driverstation.Joystick.getRawButtonPressed ( int button)

Whether the button was pressed since the last check. Button indexes begin at 1.

Parameters
buttonThe button index, beginning at 1.
Returns
Whether the button was pressed since the last check.

Definition at line 219 of file Joystick.java.

◆ getRawButtonReleased()

boolean org.wpilib.driverstation.Joystick.getRawButtonReleased ( int button)

Whether the button was released since the last check. Button indexes begin at 1.

Parameters
buttonThe button index, beginning at 1.
Returns
Whether the button was released since the last check.

Definition at line 229 of file Joystick.java.

◆ getThrottle()

final double org.wpilib.driverstation.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.

Definition at line 313 of file Joystick.java.

◆ getThrottleChannel()

int org.wpilib.driverstation.Joystick.getThrottleChannel ( )

Get the channel currently associated with the throttle axis.

Returns
The channel for the axis.

Definition at line 196 of file Joystick.java.

◆ getTop()

boolean org.wpilib.driverstation.Joystick.getTop ( )

Read the state of the top button on the joystick.

Returns
The state of the top button.

Definition at line 360 of file Joystick.java.

◆ getTopPressed()

boolean org.wpilib.driverstation.Joystick.getTopPressed ( )

Whether the top button was pressed since the last check.

Returns
Whether the button was pressed since the last check.

Definition at line 369 of file Joystick.java.

◆ getTopReleased()

boolean org.wpilib.driverstation.Joystick.getTopReleased ( )

Whether the top button was released since the last check.

Returns
Whether the button was released since the last check.

Definition at line 378 of file Joystick.java.

◆ getTrigger()

boolean org.wpilib.driverstation.Joystick.getTrigger ( )

Read the state of the trigger on the joystick.

Returns
The state of the trigger.

Definition at line 322 of file Joystick.java.

◆ getTriggerPressed()

boolean org.wpilib.driverstation.Joystick.getTriggerPressed ( )

Whether the trigger was pressed since the last check.

Returns
Whether the button was pressed since the last check.

Definition at line 331 of file Joystick.java.

◆ getTriggerReleased()

boolean org.wpilib.driverstation.Joystick.getTriggerReleased ( )

Whether the trigger was released since the last check.

Returns
Whether the button was released since the last check.

Definition at line 340 of file Joystick.java.

◆ getTwist()

final double org.wpilib.driverstation.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.

Definition at line 303 of file Joystick.java.

◆ getTwistChannel()

int org.wpilib.driverstation.Joystick.getTwistChannel ( )

Get the channel currently associated with the twist axis.

Returns
The channel for the axis.

Definition at line 187 of file Joystick.java.

◆ getX()

final double org.wpilib.driverstation.Joystick.getX ( )

Get the X value of the joystick. This depends on the mapping of the joystick connected to the current port. On most joysticks, positive is to the right.

Returns
The X value of the joystick.

Definition at line 274 of file Joystick.java.

◆ getXChannel()

int org.wpilib.driverstation.Joystick.getXChannel ( )

Get the channel currently associated with the X axis.

Returns
The channel for the axis.

Definition at line 160 of file Joystick.java.

◆ getY()

final double org.wpilib.driverstation.Joystick.getY ( )

Get the Y value of the joystick. This depends on the mapping of the joystick connected to the current port. On most joysticks, positive is to the back.

Returns
The Y value of the joystick.

Definition at line 284 of file Joystick.java.

◆ getYChannel()

int org.wpilib.driverstation.Joystick.getYChannel ( )

Get the channel currently associated with the Y axis.

Returns
The channel for the axis.

Definition at line 169 of file Joystick.java.

◆ getZ()

final double org.wpilib.driverstation.Joystick.getZ ( )

Get the z position of the HID.

Returns
the z position

Definition at line 293 of file Joystick.java.

◆ getZChannel()

int org.wpilib.driverstation.Joystick.getZChannel ( )

Get the channel currently associated with the Z axis.

Returns
The channel for the axis.

Definition at line 178 of file Joystick.java.

◆ setThrottleChannel()

void org.wpilib.driverstation.Joystick.setThrottleChannel ( int channel)

Set the channel associated with the throttle axis.

Parameters
channelThe channel to set the axis to.

Definition at line 142 of file Joystick.java.

◆ setTwistChannel()

void org.wpilib.driverstation.Joystick.setTwistChannel ( int channel)

Set the channel associated with the twist axis.

Parameters
channelThe channel to set the axis to.

Definition at line 151 of file Joystick.java.

◆ setXChannel()

void org.wpilib.driverstation.Joystick.setXChannel ( int channel)

Set the channel associated with the X axis.

Parameters
channelThe channel to set the axis to.

Definition at line 115 of file Joystick.java.

◆ setYChannel()

void org.wpilib.driverstation.Joystick.setYChannel ( int channel)

Set the channel associated with the Y axis.

Parameters
channelThe channel to set the axis to.

Definition at line 124 of file Joystick.java.

◆ setZChannel()

void org.wpilib.driverstation.Joystick.setZChannel ( int channel)

Set the channel associated with the Z axis.

Parameters
channelThe channel to set the axis to.

Definition at line 133 of file Joystick.java.

◆ top()

BooleanEvent org.wpilib.driverstation.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.

Definition at line 389 of file Joystick.java.

◆ trigger()

BooleanEvent org.wpilib.driverstation.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.

Definition at line 351 of file Joystick.java.

Member Data Documentation

◆ DEFAULT_THROTTLE_CHANNEL

final byte org.wpilib.driverstation.Joystick.DEFAULT_THROTTLE_CHANNEL = 3
static

Default throttle axis channel.

Definition at line 33 of file Joystick.java.

◆ DEFAULT_TWIST_CHANNEL

final byte org.wpilib.driverstation.Joystick.DEFAULT_TWIST_CHANNEL = 2
static

Default twist axis channel.

Definition at line 30 of file Joystick.java.

◆ DEFAULT_X_CHANNEL

final byte org.wpilib.driverstation.Joystick.DEFAULT_X_CHANNEL = 0
static

Default X axis channel.

Definition at line 21 of file Joystick.java.

◆ DEFAULT_Y_CHANNEL

final byte org.wpilib.driverstation.Joystick.DEFAULT_Y_CHANNEL = 1
static

Default Y axis channel.

Definition at line 24 of file Joystick.java.

◆ DEFAULT_Z_CHANNEL

final byte org.wpilib.driverstation.Joystick.DEFAULT_Z_CHANNEL = 2
static

Default Z axis channel.

Definition at line 27 of file Joystick.java.


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