public class Joystick extends JoystickBase
| Modifier and Type | Class and Description | 
|---|---|
| static class  | Joystick.AxisTypeRepresents an analog axis on a joystick. | 
| static class  | Joystick.ButtonTypeRepresents a digital button on the JoyStick. | 
GenericHID.Hand, GenericHID.HIDType, GenericHID.RumbleType| Modifier | Constructor and Description | 
|---|---|
|   | Joystick(int port)Construct an instance of a joystick. | 
| protected  | Joystick(int port,
        int numAxisTypes,
        int numButtonTypes)Protected version of the constructor to be called by sub-classes. | 
| Modifier and Type | Method and Description | 
|---|---|
| double | getAxis(Joystick.AxisType axis)For the current joystick, return the axis determined by the argument. | 
| int | getAxisChannel(Joystick.AxisType axis)Get the channel currently associated with the specified axis. | 
| int | getAxisCount()For the current joystick, return the number of axis. | 
| int | getAxisType(int axis)Get the axis type of a joystick axis. | 
| boolean | getBumper(GenericHID.Hand hand)This is not supported for the Joystick. | 
| boolean | getButton(Joystick.ButtonType button)Get buttons based on an enumerated type. | 
| int | getButtonCount()For the current joystick, return the number of buttons. | 
| double | getDirectionDegrees()Get the direction of the vector formed by the joystick and its origin in degrees. | 
| double | getDirectionRadians()Get the direction of the vector formed by the joystick and its origin in radians. | 
| boolean | getIsXbox()Get the value of isXbox for the current joystick. | 
| double | getMagnitude()Get the magnitude of the direction vector formed by the joystick's current position relative to
 its origin. | 
| java.lang.String | getName()Get the name of the HID. | 
| int | getPOV(int pov)Get the angle in degrees of a POV on the HID. | 
| int | getPOVCount()For the current HID, return the number of POVs. | 
| double | getRawAxis(int axis)Get the value of the axis. | 
| boolean | getRawButton(int button)Get the button value (starting at button 1). | 
| double | getThrottle()Get the throttle value of the current joystick. | 
| boolean | getTop(GenericHID.Hand hand)Read the state of the top button on the joystick. | 
| boolean | getTrigger(GenericHID.Hand hand)Read the state of the trigger on the joystick. | 
| double | getTwist()Get the twist value of the current joystick. | 
| GenericHID.HIDType | getType()Get the type of the HID. | 
| double | getX(GenericHID.Hand hand)Get the X value of the joystick. | 
| double | getY(GenericHID.Hand hand)Get the Y value of the joystick. | 
| double | getZ(GenericHID.Hand hand)Get the z position of the HID. | 
| void | setAxisChannel(Joystick.AxisType axis,
              int channel)Set the channel associated with a specified axis. | 
| void | setOutput(int outputNumber,
         boolean value)Set a single HID output value for the HID. | 
| void | setOutputs(int value)Set all HID output values for the HID. | 
| void | setRumble(GenericHID.RumbleType type,
         double value)Set the rumble output for the HID. | 
getTop, getTrigger, getZgetPort, getPOV, getX, getYpublic Joystick(int port)
port - The port on the Driver Station that the joystick is plugged into.protected Joystick(int port, int numAxisTypes, int numButtonTypes)
This constructor allows the subclass to configure the number of constants for axes and buttons.
port - The port on the Driver Station that the joystick is plugged into.numAxisTypes - The number of axis types in the enum.numButtonTypes - The number of button types in the enum.public final double getX(GenericHID.Hand hand)
getX in class GenericHIDhand - Unusedpublic final double getY(GenericHID.Hand hand)
getY in class GenericHIDhand - Unusedpublic final double getZ(GenericHID.Hand hand)
JoystickBasegetZ in class JoystickBasehand - which hand, left or rightpublic double getTwist()
getTwist in class JoystickBasepublic double getThrottle()
getThrottle in class JoystickBasepublic double getRawAxis(int axis)
getRawAxis in class GenericHIDaxis - The axis to read, starting at 0.public double getAxis(Joystick.AxisType axis)
This is for cases where the joystick axis is returned programatically, otherwise one of the previous functions would be preferable (for example getX()).
axis - The axis to read.public int getAxisCount()
public boolean getTrigger(GenericHID.Hand hand)
Look up which button has been assigned to the trigger and read its state.
getTrigger in class JoystickBasehand - This parameter is ignored for the Joystick class and is only here to complete the
             GenericHID interface.public boolean getTop(GenericHID.Hand hand)
Look up which button has been assigned to the top and read its state.
getTop in class JoystickBasehand - This parameter is ignored for the Joystick class and is only here to complete the
             GenericHID interface.public int getPOV(int pov)
GenericHIDThe POV angles start at 0 in the up direction, and increase clockwise (eg right is 90, upper-left is 315).
getPOV in class JoystickBasepov - The index of the POV to read (starting at 0)public int getPOVCount()
GenericHIDgetPOVCount in class JoystickBasepublic boolean getBumper(GenericHID.Hand hand)
hand - This parameter is ignored for the Joystick class and is only here to complete the
             GenericHID interface.public boolean getRawButton(int button)
The appropriate button is returned as a boolean value.
getRawButton in class GenericHIDbutton - The button number to be read (starting at 1).public int getButtonCount()
public boolean getButton(Joystick.ButtonType button)
The button type will be looked up in the list of buttons and then read.
button - The type of button to read.public double getMagnitude()
public double getDirectionRadians()
public double getDirectionDegrees()
Uses acos(-1) to represent Pi due to absence of readily accessable Pi constant in C++
public int getAxisChannel(Joystick.AxisType axis)
axis - The axis to look up the channel for.public void setAxisChannel(Joystick.AxisType axis, int channel)
axis - The axis to set the channel for.channel - The channel to set the axis to.public boolean getIsXbox()
public int getAxisType(int axis)
public GenericHID.HIDType getType()
getType in class JoystickBasepublic java.lang.String getName()
getName in class JoystickBasepublic void setOutput(int outputNumber, boolean value)
GenericHIDsetOutput in class JoystickBaseoutputNumber - The index of the output to set (1-32)value - The value to set the output topublic void setOutputs(int value)
GenericHIDsetOutputs in class JoystickBasevalue - The 32 bit output value (1 bit for each output)public void setRumble(GenericHID.RumbleType type, double value)
GenericHIDsetRumble in class JoystickBasetype - Which rumble value to setvalue - The normalized value (0 to 1) to set the rumble to