public class JInputJoystick
/** * * JInput Joystick * * * @author TheUzo007 * http://theuzo007.wordpress.com * * * To use this you need JInput libraries and its files. http://java.net/projects/jinput * * This class is intended for use with joysticks of stick or gamepad type (JInput type), * like Logitech Dual Action which is a stick type or Xbox MadCatz which is a gamepad type. * It can be used with other types to, but each controller has different components, therefore, * some methods that I wrote are not useful with other types of controller. But * you can always use getComponentValue method and specify controller component * identifier that you need or add your own methods. * * JInput javadoc: http://www.newdawnsoftware.com/resources/jinput/apidocs * * * More on the blog: http://theuzo007.wordpress.com/2012/09/02/joystick-in-java-with-jinput * */
| Constructor and Description |
|---|
JInputJoystick(net.java.games.input.Controller.Type controllerType)
Creates a controller, of type that has been given.
|
JInputJoystick(net.java.games.input.Controller.Type controllerType_1,
net.java.games.input.Controller.Type controllerType_2)
Creates a controller, of one of the types that has been given.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
componentExists(net.java.games.input.Component.Identifier identifier)
Checks if component with given identifier exists.
|
java.util.ArrayList<java.lang.Boolean> |
getButtonsValues()
Controller buttons states.
|
boolean |
getButtonValue(int index)
Gets value of required button.
|
float |
getComponentValue(net.java.games.input.Component.Identifier identifier)
Gets value of component with given identifier.
|
java.lang.String |
getControllerName()
Gets the human readable controller name.
|
net.java.games.input.Controller.Type |
getControllerType()
Gets the controller type.
|
float |
getHatSwitchPosition()
Gets position of the Hat Switch.
|
int |
getNumberOfButtons()
How many buttons does controller have?
|
int |
getX_LeftJoystick_Percentage()
X position, in percentages, of left controller joystick.
|
float |
getX_LeftJoystick_Value()
X position of left controller joystick.
|
int |
getX_RightJoystick_Percentage()
X position, in percentages, of right controller joystick.
|
float |
getX_RightJoystick_Value()
X position of right controller joystick.
|
int |
getXAxisPercentage()
Value of axis named X Axis in percentage.
|
float |
getXAxisValue()
Value of axis named X Axis.
|
int |
getXRotationPercentage()
Value of axis named X Rotation in percentage.
|
float |
getXRotationValue()
Value of axis named X Rotation.
|
int |
getY_LeftJoystick_Percentage()
Y position, in percentages, of left controller joystick.
|
float |
getY_LeftJoystick_Value()
Y position of left controller joystick.
|
int |
getY_RightJoystick_Percentage()
Y position, in percentages, of right controller joystick.
|
float |
getY_RightJoystick_Value()
Y position of right controller joystick.
|
int |
getYAxisPercentage()
Value of axis named Y Axis in percentage.
|
float |
getYAxisValue()
Value of axis named Y Axis.
|
int |
getYRotationPercentage()
Value of axis named Y Rotation in percentage.
|
float |
getYRotationValue()
Value of axis named Y Rotation.
|
int |
getZAxisPercentage()
Value of axis named Z Axis in percentage.
|
float |
getZAxisValue()
Value of axis named Z Axis.
|
int |
getZRotationPercentage()
Value of axis named Z Rotation in percentage.
|
float |
getZRotationValue()
Value of axis named Z Rotation.
|
boolean |
isControllerConnected()
Checks if the controller is connected/valid.
|
boolean |
pollController()
Check and save current controller state (controller components values).
|
public JInputJoystick(net.java.games.input.Controller.Type controllerType)
controllerType - Desired controller type.public JInputJoystick(net.java.games.input.Controller.Type controllerType_1,
net.java.games.input.Controller.Type controllerType_2)
controllerType_1 - Desired controller type.controllerType_2 - Desired controller type.public boolean isControllerConnected()
pollController()public net.java.games.input.Controller.Type getControllerType()
public java.lang.String getControllerName()
public boolean pollController()
public boolean componentExists(net.java.games.input.Component.Identifier identifier)
identifier - Identifier that correspond to component.public float getComponentValue(net.java.games.input.Component.Identifier identifier)
identifier - Identifier that correspond to component from which we need value.public int getNumberOfButtons()
public java.util.ArrayList<java.lang.Boolean> getButtonsValues()
public boolean getButtonValue(int index)
index - Index of a button in array list.public float getXAxisValue()
public int getXAxisPercentage()
public float getYAxisValue()
public int getYAxisPercentage()
public float getZRotationValue()
public int getZRotationPercentage()
public float getZAxisValue()
public int getZAxisPercentage()
public float getXRotationValue()
public int getXRotationPercentage()
public float getYRotationValue()
public int getYRotationPercentage()
public float getHatSwitchPosition()
public float getX_LeftJoystick_Value()
getXAxisValue()public int getX_LeftJoystick_Percentage()
getXAxisPercentage()public float getY_LeftJoystick_Value()
getYAxisValue()public int getY_LeftJoystick_Percentage()
getYAxisPercentage()public float getX_RightJoystick_Value()
getZAxisValue(),
getXRotationValue()public int getX_RightJoystick_Percentage()
getZAxisPercentage(),
getXRotationPercentage()public float getY_RightJoystick_Value()
getZRotationValue(),
getYRotationValue()public int getY_RightJoystick_Percentage()
getZRotationPercentage(),
getYRotationPercentage()