|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.jinx.action.input.InputDevice
public class InputDevice
Wrapper for net.java.games.input.Controller to make it simpler and easier to
deal with. It does this by categorizing the Axis objects returned from
the Controller and it's sub-controllers. It also allows you to control the
dead zones and whether or not to negate values for each individual Axis. It
will even take care of normalizing arbitrary axes for you.
This class works by first getting all the Axes from all the
sub-controllers. Then it categorizes them into fuzzy axes, POV hats,
buttons, and mouse wheels.
Fuzzy Axes are those whose values can be anything between negetive one
and one (including those values).
POV hats are digital direction pads with either four or eight
directions. This class treats them almost exactly like a direction pad on a
game pad, meaning that if the pad is pressed up-left, up, or up-right, isUp()
will return true. This means the left-right and up-down directions are
independant and can be used seperately if you desire.
Buttons are boolean inputs that are either on or off.
Mouse wheels can't be shoe-horned into any other category, so they're
treated as a category of their own. The mouseWheelClicks() method can be
used to get the direction and number of clicks on the wheel, if it exists.
API Stability: Beta.
Constructor Summary | |
---|---|
InputDevice(net.java.games.input.Controller c)
Constructs a new InputDevice to wrap the given Controller. |
Method Summary | |
---|---|
boolean[] |
buttonsPressed()
Determines which buttons are currently pressed. |
net.java.games.input.Axis[] |
getAxes()
Returns the array containing all of the axes for this InputDevice. |
net.java.games.input.Axis |
getButton(int button)
Returns the button Axis indicated. |
net.java.games.input.Axis[] |
getButtons()
Returns the array containing the button axes for this InputDevice. |
net.java.games.input.Controller |
getController()
Returns the underlying JInput Controller that this InputDevice is wrapping. |
float |
getDeadZone(int axis)
Returns the dead zone for the indicated fuzzy axis. |
float |
getDeadZoneValue(int axis)
Returns the value of the indicated fuzzy axis, using the set dead zone to calculate the value. |
java.lang.String |
getDescription()
Returns a best guess as to the type of this InputDevice. |
static InputDevice[] |
getDevices()
Provides an array of InputDevice objects. |
static InputDevice[] |
getDevices(Hierarchy base)
Provides an array of InputDevice objects. |
static InputDevice[] |
getDevices(InputDevice[] existingDevices)
Provides an array of InputDevice objects. |
static InputDevice[] |
getDevices(InputDevice[] existingDevices,
Hierarchy base)
Provides an array of InputDevice objects. |
net.java.games.input.Axis[] |
getFuzzyAxes()
Returns the array containing the fuzzy axes for this InputDevice. |
net.java.games.input.Axis |
getFuzzyAxis(int axis)
Returns the fuzzy Axis indicated. |
float |
getFuzzyValue(int axis)
Returns the value of the indicated fuzzy axis; dead zone data is ignored and the value is not necessarily normalized. |
java.lang.String |
getID()
Returns a (hopefully) unique identifier String for this InputDevice to ease finding the same InputDevice from one run of a program to the next. |
net.java.games.input.Axis |
getMouseWheel()
Returns the mouse wheel Axis, or null if this is not a mouse. |
int |
getMouseWheelClicks()
Returns the direction and number of clicks that have occured on this mouse's wheel. |
net.java.games.input.Axis |
getMouseXAxis()
Returns the X Axis for a mouse, or null if this is not a mouse. |
net.java.games.input.Axis |
getMouseYAxis()
Returns the Y Axis for a mouse, or null if this is not a mouse. |
java.lang.String |
getName()
Returns the name of this InputDevice. |
float |
getNormalDivider()
Returns the normal divider. |
float |
getNormalValue(int axis)
Returns the value of the indicated fuzzy axis; dead zone data is ignored, but the return value is guaranteed to be normalized from -1 to 1. |
net.java.games.input.Axis |
getPOVHat(int hat)
Returns the POV Hat Axis indicated. |
net.java.games.input.Axis[] |
getPOVHats()
Returns the array containing the POV hat axes for this InputDevice. |
java.lang.StringBuffer |
getReport()
Gets a report of the current conditions of this InputDevice. |
net.java.games.input.Rumbler |
getRumbler(net.java.games.input.Axis.Identifier axid)
Returns a Rumbler that matches the given identifier, or null if there isn't one. |
net.java.games.input.Rumbler[] |
getRumblers()
Gets the array of all Rumblers attached to this InputDevice. |
float |
getThrottleValue(int axis)
Returns the value of the indicated fuzzy axis, using the set dead zone to calculate the value. |
boolean |
isButtonPressed(int button)
Determines if the indicated button is pressed. |
boolean |
isHeadTracker()
Returns true if this InputDevice is a head tracker. |
boolean |
isKeyboard()
Returns true if this InputDevice is a keyboard. |
boolean |
isKeypad()
Returns true if this InputDevice is a keypad. |
boolean |
isMouse()
Returns true if this InputDevice is a mouse. |
boolean |
isPOVCenter(int hat)
Determines if the indicated POV hat is centered. |
boolean |
isPOVDown(int hat)
Determines if the indicated POV hat is pointed in the down direction. |
boolean |
isPOVLeft(int hat)
Determines if the indicated POV hat is pointed in the left direction. |
boolean |
isPOVRight(int hat)
Determines if the indicated POV hat is pointed in the right direction. |
boolean |
isPOVUp(int hat)
Determines if the indicated POV hat is pointed in the up direction. |
boolean |
isReverseFuzzy(int axis)
Returns the value of the reverse flag for the indicated fuzzy axis. |
boolean |
isRudder()
Returns true if this InputDevice is a rudder control. |
boolean |
isStick()
Returns true if this InputDevice is a stick. |
boolean |
isUseless()
Returns true if this InputDevice has no controls of any kind. |
boolean |
isWheel()
Returns true if this InputDevice is a steering wheel. |
void |
load(Hierarchy h)
Loads the configuration for this InputDevice from h. |
static void |
load(InputDevice[] devices,
Hierarchy base)
Calls load(base) on each InputDevice in the array of devices, using a sub-node named according to the device's unique ID (see the getID() method) and that device's order among those devices with an identical ID. |
static InputDevice |
matchDevice(java.lang.String id,
InputDevice[] devices)
Attempts to match an InputDevice to it's ID string. |
boolean |
poll()
Polls this InputDevice for input. |
void |
rumble(net.java.games.input.Axis.Identifier axid,
float intensity)
Rumbles the Rumbler that matches the given identifier, if it exists. |
void |
rumble(float intensity)
Rumbles all rumblers attached to this InputDevice at the same intensity. |
void |
rumble(float x,
float y)
This should produce a 2D directional rumble if the InputDevice supports it. |
void |
setDeadZone(int axis,
float dz)
Sets the dead zone for the indicated fuzzy axis. |
void |
setNormalDivider(float normalDivider)
Sets the value used to normalize axes that are not normalized. |
void |
setReverseFuzzy(int axis,
boolean reverse)
Sets whether or not the indicated fuzzy axis should be reversed. |
void |
store(Hierarchy h)
Stores the configuration for this InputDevice in h. |
static void |
store(InputDevice[] devices,
Hierarchy base)
Calls store(Hierarchy) on each InputDevice in the array of devices, using a sub-node named according to the device's unique ID (see the getID() method) and that device's order among those devices with an identical ID. |
java.lang.String |
toString()
Returns the ID String for this InputDevice. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public InputDevice(net.java.games.input.Controller c)
c
- the Controller.Method Detail |
---|
public net.java.games.input.Controller getController()
public java.lang.String getName()
public java.lang.String getDescription()
public java.lang.String getID()
public boolean isMouse()
public boolean isKeyboard()
public boolean isKeypad()
public boolean isWheel()
public boolean isRudder()
public boolean isHeadTracker()
public boolean isStick()
public boolean isUseless()
public net.java.games.input.Axis getMouseXAxis()
public net.java.games.input.Axis getMouseYAxis()
public net.java.games.input.Axis getMouseWheel()
public int getMouseWheelClicks()
public net.java.games.input.Axis[] getAxes()
public net.java.games.input.Axis[] getButtons()
public net.java.games.input.Axis getButton(int button)
button
- the number of the button to return.
java.lang.ArrayIndexOutOfBoundsException
- if button is out of bounds.public net.java.games.input.Axis[] getPOVHats()
public net.java.games.input.Axis getPOVHat(int hat)
hat
- the number of the hat to return.
java.lang.ArrayIndexOutOfBoundsException
- if hat is out of bounds.public boolean isPOVCenter(int hat)
hat
- the index of the hat to query.
java.lang.ArrayIndexOutOfBoundsException
- if hat is out of bounds.public boolean isPOVUp(int hat)
hat
- the index of the hat to query.
java.lang.ArrayIndexOutOfBoundsException
- if hat is out of bounds.public boolean isPOVDown(int hat)
hat
- the index of the hat to query.
java.lang.ArrayIndexOutOfBoundsException
- if hat is out of bounds.public boolean isPOVLeft(int hat)
hat
- the index of the hat to query.
java.lang.ArrayIndexOutOfBoundsException
- if hat is out of bounds.public boolean isPOVRight(int hat)
hat
- the index of the hat to query.
java.lang.ArrayIndexOutOfBoundsException
- if hat is out of bounds.public void setDeadZone(int axis, float dz)
axis
- the number of the fuzzy axis to set the dead zone for.dz
- the dead zone value.
java.lang.ArrayIndexOutOfBoundsException
- if axis is out of bounds.public float getDeadZone(int axis)
axis
- the number of the fuzzy axis to query.
java.lang.ArrayIndexOutOfBoundsException
- if axis is out of bounds.public float getFuzzyValue(int axis)
axis
- the number of the fuzzy axis to query.
java.lang.ArrayIndexOutOfBoundsException
- if axis is out of bounds.public float getNormalValue(int axis)
axis
- the number of the fuzzy axis to query.
java.lang.ArrayIndexOutOfBoundsException
- if axis is out of bounds.public float getDeadZoneValue(int axis)
axis
- the number of the fuzzy axis to query.
java.lang.ArrayIndexOutOfBoundsException
- if axis is out of bounds.public float getThrottleValue(int axis)
axis
- the number of the fuzzy axis to query.
java.lang.ArrayIndexOutOfBoundsException
- if axis is out of bounds.public void setReverseFuzzy(int axis, boolean reverse)
axis
- the number of the fuzzy axis to configure.reverse
- true means the axis is reversed, false means it's not.
java.lang.ArrayIndexOutOfBoundsException
- if axis is out of bounds.public boolean isReverseFuzzy(int axis)
axis
- the number of the fuzzy axis to configure.
java.lang.ArrayIndexOutOfBoundsException
- if axis is out of bounds.public net.java.games.input.Axis[] getFuzzyAxes()
public net.java.games.input.Axis getFuzzyAxis(int axis)
axis
- the number of the fuzzy axis to return.
java.lang.ArrayIndexOutOfBoundsException
- if axis is out of bounds.public boolean isButtonPressed(int button)
button
- the index of the button to query.
java.lang.ArrayIndexOutOfBoundsException
- if button is out of bounds.public boolean[] buttonsPressed()
public void setNormalDivider(float normalDivider)
normalDivider
- the divider.
java.lang.IllegalArgumentException
- if normalDivider is less than one.public float getNormalDivider()
public boolean poll()
public net.java.games.input.Rumbler[] getRumblers()
public net.java.games.input.Rumbler getRumbler(net.java.games.input.Axis.Identifier axid)
axid
- the identifier to match.
public void rumble(net.java.games.input.Axis.Identifier axid, float intensity)
axid
- the identifier to match.intensity
- the strength of the rumble.public void rumble(float intensity)
intensity
- the strength of the rumble.public void rumble(float x, float y)
x
- the strength of the rumble in the x direction.y
- the strength of the rumble in the y direction.public java.lang.StringBuffer getReport()
public void store(Hierarchy h)
h
- the Hierarchy to store this InputDevice's configuration in. If
h is null, then nothing is done.public void load(Hierarchy h)
h
- the Hierarchy to search for this InputDevice's configuration in.
If h is null then nothing is done.public java.lang.String toString()
toString
in class java.lang.Object
public static InputDevice[] getDevices(InputDevice[] existingDevices)
existingDevices
- an InputDevice array for the devices that have
already been configured. If one of these matches up to a device in the
new array, it will replace it.public static InputDevice[] getDevices(InputDevice[] existingDevices, Hierarchy base)
existingDevices
- an InputDevice array for the devices that have
already been configured. If one of these matches up to a device in the
new array, it will replace it.base
- the Hierarchy to configure the new InputDevice objects from.public static InputDevice[] getDevices(Hierarchy base)
base
- the Hierarchy to configure the new InputDevice array from.
public static InputDevice[] getDevices()
public static InputDevice matchDevice(java.lang.String id, InputDevice[] devices)
id
- the ID string to search for, as per the getID() method.devices
- the InputDevices to search.
public static void load(InputDevice[] devices, Hierarchy base)
devices
- the array of InputDevice objects.base
- the Hierarchy to use to configure devices from.public static void store(InputDevice[] devices, Hierarchy base)
devices
- the array of InputDevice objects.base
- the Hierarchy to store configuration data for the devices in.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |