wiiremotej
Class NunchukExtension

java.lang.Object
  extended by wiiremotej.WiiRemoteExtension
      extended by wiiremotej.NunchukExtension

public class NunchukExtension
extends WiiRemoteExtension

A class representing a Nintendo (R) Wii Remote (TM) Nunchuk extension. It has information about the extension and can create WRNunchukExtensionEvents.


Constructor Summary
NunchukExtension(int payload)
          Creates a new NunchukExtension with the given payload.
 
Method Summary
 WRNunchukExtensionEvent createWRExtensionEvent(WiiRemote source, byte[] input, int offset)
          Creates and returns a new WRNunchukExtensionEvent from the given input.
 void decryptExtensionInput(byte[] bytes, int firstIndex, int len)
          Applies any necessary transformation to the specified byte array to decrypt extension input.
 NunchukCalibrationData getCalibrationData()
          Returns the calibration information for the Nunchuk.
 short getCode()
          Returns the extension code for this extension, used by WRExtensionFactories in determining what kind of extension this is.
 boolean isPayloadValid(int payload)
          Checks if the given payload is valid for this extension.
 
Methods inherited from class wiiremotej.WiiRemoteExtension
getPayload
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NunchukExtension

public NunchukExtension(int payload)
Creates a new NunchukExtension with the given payload.

Parameters:
payload - the number of bytes needed to create an event with this extension.
Method Detail

getCalibrationData

public NunchukCalibrationData getCalibrationData()
Returns the calibration information for the Nunchuk.

Returns:
the calibration information for the Nunchuk.

createWRExtensionEvent

public WRNunchukExtensionEvent createWRExtensionEvent(WiiRemote source,
                                                      byte[] input,
                                                      int offset)
Creates and returns a new WRNunchukExtensionEvent from the given input. Note, this synchronizes on an internal object to prevent nunchuk events from being created simultaneously.

Specified by:
createWRExtensionEvent in class WiiRemoteExtension
Parameters:
source - the WiiRemote triggering this event.
input - the data input from the Nunchuk.
offset - the position of the first byte of extension data in input.
Returns:
a new WRNunchukExtensionEvent.

isPayloadValid

public boolean isPayloadValid(int payload)
Checks if the given payload is valid for this extension. The Nunchuk only accepts a payload of 6.

Specified by:
isPayloadValid in class WiiRemoteExtension
Parameters:
payload - the payload to check.
Returns:
true if this extension will accept the given payload; otherwise, false.

decryptExtensionInput

public void decryptExtensionInput(byte[] bytes,
                                  int firstIndex,
                                  int len)
Applies any necessary transformation to the specified byte array to decrypt extension input.

Specified by:
decryptExtensionInput in class WiiRemoteExtension
Parameters:
bytes - the byte array to decrypt.
firstIndex - the first index to decrypt.
len - the number of bytes to decrypt.

getCode

public short getCode()
Returns the extension code for this extension, used by WRExtensionFactories in determining what kind of extension this is. Note this is the decrypted code.

Specified by:
getCode in class WiiRemoteExtension
Returns:
the extension code for this extension.