wiiremotej.event
Class WRNunchuckExtensionEvent

java.lang.Object
  extended by java.util.EventObject
      extended by wiiremotej.event.WREvent
          extended by wiiremotej.event.WRExtensionEvent
              extended by wiiremotej.event.WRNunchuckExtensionEvent
All Implemented Interfaces:
java.io.Serializable

public class WRNunchuckExtensionEvent
extends WRExtensionEvent

Nunchuck extension event for Nintendo (R) Wii Remote (TM). Contains data from the nunchuck extension.

See Also:
Serialized Form

Field Summary
static int C
          Constant representing the C button of the nunchuck.
static int Z
          Constant representing the Z button of the nunchuck.
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
WRNunchuckExtensionEvent(WiiRemote source, byte[] input, int offset, WRNunchuckExtensionEvent lastEvent)
          Creates a new WRNunchuckExtensionEvent from an array of input data.
 
Method Summary
static WRNunchuckExtensionEvent createBlankEvent()
          Returns a WRNunchuckExtensionEvent with all the values cleared.
 AnalogStickData getAnalogStickData()
          Returns AnalogStickData representing the current state of the analog stick on the nunchuck.
 double getPitch()
          Returns the pitch of the nunchuck, in radians from 0 to 2PI.
 double getRoll()
          Returns the roll of the nunchuck, in radians from 0 to 2PI.
 double getXAcceleration()
          Returns the X-Acceleration of the nunchuck, in terms of G's.
 double getYAcceleration()
          Returns the Y-Acceleration of the nunchuck, in terms of G's.
 double getZAcceleration()
          Returns the Z-Acceleration of the nunchuck, in terms of G's.
 boolean isPressed(int button)
          Returns true if the given button is pressed; otherwise false.
 boolean isStill()
          Returns true if the nunchuck is not being moved; otherwise false.
 boolean wasPressed(int button)
          Returns true if the given button was pressed; otherwise false.
 boolean wasReleased(int button)
          Returns true if the given button was released; otherwise false.
 
Methods inherited from class wiiremotej.event.WREvent
getSource
 
Methods inherited from class java.util.EventObject
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

C

public static final int C
Constant representing the C button of the nunchuck.

See Also:
Constant Field Values

Z

public static final int Z
Constant representing the Z button of the nunchuck.

See Also:
Constant Field Values
Constructor Detail

WRNunchuckExtensionEvent

public WRNunchuckExtensionEvent(WiiRemote source,
                                byte[] input,
                                int offset,
                                WRNunchuckExtensionEvent lastEvent)
Creates a new WRNunchuckExtensionEvent from an array of input data.

Parameters:
source - the WiiRemote triggering this event.
input - data received from the extension port.
offset - the position of the first byte of extension data in the array.
lastEvent - the last received WRNunchuckExtensionEvent. Used for button-press information.
Method Detail

createBlankEvent

public static WRNunchuckExtensionEvent createBlankEvent()
Returns a WRNunchuckExtensionEvent with all the values cleared. This means that all acceleration and analog values read are 0 and all buttons are not pressed.

Returns:
a WRNunchuckExtensionEvent with all the values cleared.

isStill

public boolean isStill()
Returns true if the nunchuck is not being moved; otherwise false. This method checks the magnitude of the acceleration against 1 G. If it is close to 1G, then the nunchuck is considered still. Therefore, the nunchuck could actually be moving, when isStill returns true, however, this would be unlikely.

Returns:
true if the nunchuck is not being moved; otherwise false.

getXAcceleration

public double getXAcceleration()
Returns the X-Acceleration of the nunchuck, in terms of G's.

Returns:
the X-Acceleration of the nunchuck, in terms of G's.

getYAcceleration

public double getYAcceleration()
Returns the Y-Acceleration of the nunchuck, in terms of G's.

Returns:
the Y-Acceleration of the nunchuck, in terms of G's.

getZAcceleration

public double getZAcceleration()
Returns the Z-Acceleration of the nunchuck, in terms of G's.

Returns:
the Z-Acceleration of the nunchuck, in terms of G's.

getPitch

public double getPitch()
Returns the pitch of the nunchuck, in radians from 0 to 2PI.

Returns:
the pitch of the nunchuck, in radians from 0 to 2PI. Returns Double.NaN if unknown (because the WiiRemote is in motion).

getRoll

public double getRoll()
Returns the roll of the nunchuck, in radians from 0 to 2PI.

Returns:
the roll of the nunchuck, in radians from 0 to 2PI. Returns Double.NaN if unknown (because the WiiRemote is in motion).

getAnalogStickData

public AnalogStickData getAnalogStickData()
Returns AnalogStickData representing the current state of the analog stick on the nunchuck.

Returns:
AnalogStickData representing the current state of the analog stick on the nunchuck.

isPressed

public boolean isPressed(int button)
Returns true if the given button is pressed; otherwise false. "isPressed" means that the button is currently depressed; it may have just been depressed this event, or it may have been depressed previously. Buttons are specified using the field constants in this class.

Parameters:
button - the button to check if is pressed. You may specify either a single button or a button mask (multiple buttons added together).
Returns:
true if the given button is pressed; otherwise false.

wasPressed

public boolean wasPressed(int button)
Returns true if the given button was pressed; otherwise false. "wasPressed" means that the button was not depressed before, and was just depressed this event. Buttons are specified using the field constants in this class.

Parameters:
button - the button to check if was pressed. You may specify either a single button or a button mask (multiple buttons added together).
Returns:
true if the given button was pressed; otherwise false.

wasReleased

public boolean wasReleased(int button)
Returns true if the given button was released; otherwise false. "wasReleased" means that the button was previously depressed, but was just released this event. Buttons are specified using the field constants in this class.

Parameters:
button - the button to check if was released. You may specify either a single button or a button mask (multiple buttons added together).
Returns:
true if the given button was released; otherwise false.