wiiremotej
Class AnalogStickData

java.lang.Object
  extended by wiiremotej.AnalogStickData

public class AnalogStickData
extends java.lang.Object

Represents a simple XY analog stick. AnalogSticks are immutable. The value of the x and y positions should be between -1 and 1, with -1 being tilted all the way left (for the X direction) or down (for the Y direction), 1 being tilted all the way right (for the X direction) or up (for the Y direction), and with 0 being the center. Unfortunately, the calibration data in the various devices that use analog sticks is not perfect, so some variation does occur. If precise accuracy is important to your code, you may wish to calibrate manually (i.e. have the user push the stick all the way to the left, record this as the minimum X, have the user push the stick all the way to the right, record this as the maximum X, and finally have the user leave the stick in the center and record this as the center value. Then just parse the values returned from this event to get accurate values). The calibration values are pretty good, though, so for most applications this should not be an issue.


Constructor Summary
AnalogStickData(double x, double y)
          Creates a new AnalogStickData with the given X and Y values.
 
Method Summary
 boolean equals(java.lang.Object object)
          Returns true if the given object is the same as this AnalogStick; otherwise false.
 double getAngle()
          Returns the angle of the analog stick, measured in radians from the positive X-axis towards the positive Y-axis.
 double getX()
          Returns the X position of the analog stick, should be between -1 and 1.
 double getY()
          Returns the Y position of the analog stick, should be between -1 and 1.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnalogStickData

public AnalogStickData(double x,
                       double y)
Creates a new AnalogStickData with the given X and Y values.

Parameters:
x - the X position of the analog stick. Should be between -1 and 1.
y - the Y position of the analog stick. Should be between -1 and 1.
Method Detail

getX

public double getX()
Returns the X position of the analog stick, should be between -1 and 1.

Returns:
the X position of the analog stick, should be between -1 and 1.

getY

public double getY()
Returns the Y position of the analog stick, should be between -1 and 1.

Returns:
the Y position of the analog stick, should be between -1 and 1.

getAngle

public double getAngle()
Returns the angle of the analog stick, measured in radians from the positive X-axis towards the positive Y-axis.

Returns:
the angle of the analog stick.

equals

public boolean equals(java.lang.Object object)
Returns true if the given object is the same as this AnalogStick; otherwise false. Both X and Y must match.

Overrides:
equals in class java.lang.Object
Parameters:
object - the object to compare to for equality.
Returns:
true if the given object is the same as this AnalogStick; otherwise false.