wiiremotej
Class WiiRemoteExtensionFactory

java.lang.Object
  extended by wiiremotej.WiiRemoteExtensionFactory

public class WiiRemoteExtensionFactory
extends java.lang.Object

A class representing a Nintendo (R) Wii Remote (TM) extension factory. It is used to obtain object-references to extensions based on their numeric codes.


Method Summary
 WiiRemoteExtension createWiiRemoteExtension(short code)
          Creates and returns a new WiiRemoteExtension based on the given extension code.
static WiiRemoteExtensionFactory getDefault()
          Returns the default WiiRemoteExtensionFactory.
 boolean isExtensionRegistered(short code)
          Returns true if the given extension code has already been registered or is WiiRemoteExtension.NOTHING_INSERTED or WiiRemoteExtension.PARTIALLY_INSERTED; otherwise false.
 void registerWiiRemoteExtension(WiiRemoteExtension extensionType)
          Registers the given extension with this WRExtensionFactory.
 void removeExtension(short code)
          Removes the extension specified by the given code from this factory's list of registered extensions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createWiiRemoteExtension

public WiiRemoteExtension createWiiRemoteExtension(short code)
Creates and returns a new WiiRemoteExtension based on the given extension code.

Parameters:
code - the code indicating what kind of extension to return. If the code is unknown, null is returned.
Returns:
a new WiiRemoteExtension matching code.

registerWiiRemoteExtension

public void registerWiiRemoteExtension(WiiRemoteExtension extensionType)
                                throws java.lang.NullPointerException,
                                       java.lang.IllegalArgumentException
Registers the given extension with this WRExtensionFactory. The provided WRExtension is used in two ways: 1. The getCode() method is used to identify this type of extension. 2. The getPayload() method is used to get the default payload for all extensions of this type created by the factory. Note that some extensions--particularly the Nunchuk, the Classic Controller, and the Guitar--are registered by default. Also note that WiiRemoteExtension.NOTHING_INSERTED and WiiRemoteExtension.PARTIALLY_INSERTED are reserved codes (and can not be removed).

Parameters:
extensionType - an instance of the type of WRExtension to be added.
Throws:
java.lang.NullPointerException - if extensionType is null.
java.lang.IllegalArgumentException - if the given extension (or another with the same code) is already registered with the current WRExtensionFactory.

removeExtension

public void removeExtension(short code)
Removes the extension specified by the given code from this factory's list of registered extensions. If the specified extension is not registered with this factory, then no action is taken. Note that you can not remove reserved codes WiiRemoteExtension.NOTHING_INSERTED and WiiRemoteExtension.PARTIALLY_INSERTED. If you try to remove these, no action will be taken.

Parameters:
code - the code of the extension to remove.

isExtensionRegistered

public boolean isExtensionRegistered(short code)
Returns true if the given extension code has already been registered or is WiiRemoteExtension.NOTHING_INSERTED or WiiRemoteExtension.PARTIALLY_INSERTED; otherwise false.

Returns:
true if the given extension code has already been registered; otherwise false.

getDefault

public static WiiRemoteExtensionFactory getDefault()
Returns the default WiiRemoteExtensionFactory. Supports Nunchuk, Guitar, and Classic Controller.

Returns:
the default WiiRemoteExtensionFactory.