public class Joystick extends GenericHID
| Modifier and Type | Class and Description |
|---|---|
static class |
Joystick.AxisType
Represents an analog axis on a joystick.
|
static class |
Joystick.ButtonType
Represents a digital button on the JoyStick
|
static class |
Joystick.RumbleType
Represents a rumble output on the JoyStick
|
GenericHID.Hand| 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
|
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
uses acos(-1) to represent Pi due to absence of readily accessable Pi
constant in C++
|
double |
getDirectionRadians()
Get the direction of the vector formed by the joystick and its origin
in radians
|
double |
getMagnitude()
Get the magnitude of the direction vector formed by the joystick's
current position relative to its origin
|
int |
getPOV(int pov)
Get the state of a POV on the joystick.
|
int |
getPOVCount()
For the current joystick, 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)
The appropriate button is returned as a boolean value.
|
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.
|
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 value of the joystick.
|
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 joystick.
|
void |
setOutputs(int value)
Set all HID output values for the joystick.
|
void |
setRumble(Joystick.RumbleType type,
float value)
Set the rumble output for the joystick.
|
getBumper, getPOV, getTop, getTrigger, getX, getY, getZpublic Joystick(int port)
port - The port on the driver station that the joystick is plugged into.protected Joystick(int port,
int numAxisTypes,
int numButtonTypes)
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 double getX(GenericHID.Hand hand)
getX in class GenericHIDhand - Unusedpublic double getY(GenericHID.Hand hand)
getY in class GenericHIDhand - Unusedpublic double getZ(GenericHID.Hand hand)
getZ in class GenericHIDhand - Unusedpublic double getTwist()
getTwist in class GenericHIDpublic double getThrottle()
getThrottle in class GenericHIDpublic double getRawAxis(int axis)
getRawAxis in class GenericHIDaxis - The axis to read, starting at 0.public double getAxis(Joystick.AxisType axis)
axis - The axis to read.public int getAxisCount()
public boolean getTrigger(GenericHID.Hand hand)
getTrigger in class GenericHIDhand - This parameter is ignored for the Joystick class and is only here to complete the GenericHID interface.public boolean getTop(GenericHID.Hand hand)
getTop in class GenericHIDhand - This parameter is ignored for the Joystick class and is only here to complete the GenericHID interface.public boolean getBumper(GenericHID.Hand hand)
getBumper in class GenericHIDhand - This parameter is ignored for the Joystick class and is only here to complete the GenericHID interface.public boolean getRawButton(int button)
getRawButton in class GenericHIDbutton - The button number to be read (starting at 1).public int getButtonCount()
public int getPOV(int pov)
getPOV in class GenericHIDpov - The index of the POV to read (starting at 0)public int getPOVCount()
public boolean getButton(Joystick.ButtonType button)
button - The type of button to read.public double getMagnitude()
public double getDirectionRadians()
public double getDirectionDegrees()
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 void setRumble(Joystick.RumbleType type, float value)
type - Which rumble value to setvalue - The normalized value (0 to 1) to set the rumble topublic void setOutput(int outputNumber,
boolean value)
outputNumber - The index of the output to set (1-32)value - The value to set the output topublic void setOutputs(int value)
value - The 32 bit output value (1 bit for each output)Copyright © 2015. All rights reserved.