net.jinx.action.input
Class ControlID

java.lang.Object
  extended by net.jinx.action.input.ControlID

public final class ControlID
extends java.lang.Object

Represents a particular control attached to an InputDevice.

Each ControlID is composed of three values: a device index, a control index, and a control type constant. The device index indicates, given an array of InputDevices, which of the devices should be used. The type constant indicates what kind of control on the InputDevice should be used and how to use it. This will be one of the TYPE_* constants in this class. The control index indicates which of the controls of the given type to use.

API Stability: Beta; I'm going to add TYPE_ constants for the mouse axes.


Field Summary
static int TYPE_BUTTON
          Use a button; pressed will be one, unpressed will be zero.
static int TYPE_FUZZY
          Use a fuzzy axis' full range.
static int TYPE_FUZZY_NEGETIVE
          Use absolute value of a fuzzy axis' negetive range.
static int TYPE_FUZZY_POSITIVE
          Use a fuzzy axis' positive range.
static int TYPE_FUZZY_THROTTLE
          Use a fuzzy axis as a throttle slider.
static int TYPE_HAT_CENTER
          Use a POV hat; center will be one and anything else will be zero.
static int TYPE_HAT_DOWN
          Use a POV hat; down will be one and center will be zero.
static int TYPE_HAT_DOWN_UP
          Use a POV hat; down will be negetive one, center will be zero, up will be one.
static int TYPE_HAT_LEFT
          Use a POV hat; left will be one and center will be zero.
static int TYPE_HAT_LEFT_RIGHT
          Use a POV hat; left will be negetive one, center will be zero, right will be one.
static int TYPE_HAT_RIGHT
          Use a POV hat; right will be one and center will be zero.
static int TYPE_HAT_RIGHT_LEFT
          Use a POV hat; right will be negetive one, center will be zero, left will be one.
static int TYPE_HAT_UP
          Use a POV hat; up will be one and center will be zero.
static int TYPE_HAT_UP_DOWN
          Use a POV hat; up will be negetive one, center will be zero, down will be one.
 
Constructor Summary
ControlID(int device, int control, int controlType)
          Constructs a ControlID.
 
Method Summary
 java.lang.String controlString()
          Returns a String representing the control.
 boolean equals(java.lang.Object obj)
           
 int getControlIndex()
          Returns the control index.
 int getControlType()
          Returns the control type constant.
 int getDeviceIndex()
          Returns the device index.
 int hashCode()
           
 boolean isButton()
          Is this refering to a button?
 boolean isFuzzy()
          Is this refering to a fuzzy axis?
 boolean isPOVHat()
          Is this refering to a POV hat?
 java.lang.String toString()
          Returns the following: getDeviceIndex() + ":" + controlString();
 java.lang.String toString(InputDevice dev)
          Returns the following: getDeviceIndex() + ":" + dev.getName() + ":" + controlString();
 java.lang.String typeString()
          Returns a short text representation of the type constant.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_FUZZY

public static final int TYPE_FUZZY
Use a fuzzy axis' full range.

See Also:
Constant Field Values

TYPE_FUZZY_POSITIVE

public static final int TYPE_FUZZY_POSITIVE
Use a fuzzy axis' positive range.

See Also:
Constant Field Values

TYPE_FUZZY_NEGETIVE

public static final int TYPE_FUZZY_NEGETIVE
Use absolute value of a fuzzy axis' negetive range.

See Also:
Constant Field Values

TYPE_FUZZY_THROTTLE

public static final int TYPE_FUZZY_THROTTLE
Use a fuzzy axis as a throttle slider. This will produce a range of zero to one.

See Also:
Constant Field Values

TYPE_BUTTON

public static final int TYPE_BUTTON
Use a button; pressed will be one, unpressed will be zero.

See Also:
Constant Field Values

TYPE_HAT_UP

public static final int TYPE_HAT_UP
Use a POV hat; up will be one and center will be zero.

See Also:
Constant Field Values

TYPE_HAT_DOWN

public static final int TYPE_HAT_DOWN
Use a POV hat; down will be one and center will be zero.

See Also:
Constant Field Values

TYPE_HAT_LEFT

public static final int TYPE_HAT_LEFT
Use a POV hat; left will be one and center will be zero.

See Also:
Constant Field Values

TYPE_HAT_RIGHT

public static final int TYPE_HAT_RIGHT
Use a POV hat; right will be one and center will be zero.

See Also:
Constant Field Values

TYPE_HAT_CENTER

public static final int TYPE_HAT_CENTER
Use a POV hat; center will be one and anything else will be zero.

See Also:
Constant Field Values

TYPE_HAT_LEFT_RIGHT

public static final int TYPE_HAT_LEFT_RIGHT
Use a POV hat; left will be negetive one, center will be zero, right will be one.

See Also:
Constant Field Values

TYPE_HAT_RIGHT_LEFT

public static final int TYPE_HAT_RIGHT_LEFT
Use a POV hat; right will be negetive one, center will be zero, left will be one.

See Also:
Constant Field Values

TYPE_HAT_UP_DOWN

public static final int TYPE_HAT_UP_DOWN
Use a POV hat; up will be negetive one, center will be zero, down will be one.

See Also:
Constant Field Values

TYPE_HAT_DOWN_UP

public static final int TYPE_HAT_DOWN_UP
Use a POV hat; down will be negetive one, center will be zero, up will be one.

See Also:
Constant Field Values
Constructor Detail

ControlID

public ControlID(int device,
                 int control,
                 int controlType)
Constructs a ControlID.

Parameters:
device - the device index.
control - the control index.
controlType - the control type constant.
Throws:
java.lang.IllegalArgumentException - if controlType is invalid, or if one of device or control is less than zero.
Method Detail

isFuzzy

public boolean isFuzzy()
Is this refering to a fuzzy axis?

Returns:
true if it is.

isButton

public boolean isButton()
Is this refering to a button?

Returns:
true if it is.

isPOVHat

public boolean isPOVHat()
Is this refering to a POV hat?

Returns:
true if it is.

getDeviceIndex

public int getDeviceIndex()
Returns the device index.

Returns:
the index.

getControlType

public int getControlType()
Returns the control type constant.

Returns:
the constant.

getControlIndex

public int getControlIndex()
Returns the control index.

Returns:
the index.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

typeString

public java.lang.String typeString()
Returns a short text representation of the type constant. This is for display purposes and does not necessarily correspond to how the API looks at things. The API uses strange terms, because JInput calls everything an Axis (Grumble, grumble!). This method calls fuzzy axes just plain "Axis", POV Hats are "POV", and buttons are "Button".

Returns:
the String. This will be one of the following forms: "Axis", "Axis(X)" where X = +/-/T, "Button", or "POV(X)" where X = U/D/L/R/C/LR/RL/UD/DU.

controlString

public java.lang.String controlString()
Returns a String representing the control. This is the same as: typeString() + " " + getControlIndex();

Returns:
the String.

toString

public java.lang.String toString()
Returns the following: getDeviceIndex() + ":" + controlString();

Overrides:
toString in class java.lang.Object
Returns:
the String.

toString

public java.lang.String toString(InputDevice dev)
Returns the following: getDeviceIndex() + ":" + dev.getName() + ":" + controlString();

Returns:
the String.