wiiusej
Class Wiimote

java.lang.Object
  extended by wiiusej.Wiimote
All Implemented Interfaces:
java.util.EventListener, WiiUseApiListener

public class Wiimote
extends java.lang.Object
implements WiiUseApiListener

Class that represents a wiimote. You can register as an observer of this wiimote to listen events from it. You manage it.

Author:
guiguito

Field Summary
private  int id
           
private  javax.swing.event.EventListenerList listeners
           
private  WiiUseApiManager manager
           
 
Constructor Summary
Wiimote(int idd, WiiUseApiManager manager)
          Constructor.
 
Method Summary
 void activateContinuous()
          Activate continuous.
 void activateIRTRacking()
          Activate IR Tracking.
 void activateMotionSensing()
          Activate motion sensing.
 void activateRumble()
          Activate the rumble.
 void activateSmoothing()
          Activate smoothing.
 void addWiiMoteEventListeners(WiimoteListener listener)
          Add a WiimoteListener to the listeners list.
 void deactivateContinuous()
          Deactivate continuous.
 void deactivateIRTRacking()
          Deactivate IR Tracking.
 void deactivateMotionSensing()
          Deactivate motion sensing.
 void deactivateRumble()
          Deactivate the rumble.
 void deactivateSmoothing()
          Deactivate smoothing.
 void disconnect()
          Disconnect this wiimote.
 int getId()
          Get the unique id of the wiimote.
 void getStatus()
          Ask for the status of the wiimote.
 WiimoteListener[] getWiiMoteEventListeners()
          Get the list of WiimoteListener.
private  void notifyDisconnectionEventListeners(DisconnectionEvent evt)
          Notify WiimoteListener that a disconnection event occured.
private  void notifyNunchukInsertedEventListeners(NunchukInsertedEvent evt)
          Notify WiimoteListener that a NunchukInserted Event occured.
private  void notifyNunchukRemovedEventListeners(NunchukRemovedEvent evt)
          Notify WiimoteListener that a NunchukRemoved Event occured.
private  void notifyStatusEventListeners(StatusEvent evt)
          Notify WiimoteListener that a status event occured.
private  void notifyWiiMoteEventListeners(WiimoteEvent evt)
          Notify WiimoteListeners that an event occured.
 void onWiiUseApiEvent(WiiUseApiEvent e)
          Method called when a WiiUseApiEvent occurs.
 void removeWiiMoteEventListeners(WiimoteListener listener)
          Remove a WiimoteListener from the listeners list.
 void reSync()
          Try to resync the wiimote by starting a new handshake.
 void setAccelerationThreshold(int th)
          Set the acceleration threshold(minimum angle between two degrees with accelerometer).
 void setAlphaSmoothingValue(float th)
          Set the alpha smoothing value.
 void setIrSensitivity(int level)
          Set the IR sensitivity.
 void setLeds(boolean l1, boolean l2, boolean l3, boolean l4)
          Set leds status.
 void setNunchukAccelerationThreshold(int th)
          Set the nunchuk acceleration threshold for the given id.
 void setNunchukOrientationThreshold(float th)
          Set the nunchuk orientation threshold for the given id.
 void setOrientationThreshold(float th)
          Set the orientation threshold (minimum angle between two degrees with accelerometer).
 void setScreenAspectRatio169()
          Set the screen aspect ratio to be considered as 16/9.
 void setScreenAspectRatio43()
          Set the screen aspect ratio to be considered as 4/3.
 void setSensorBarAboveScreen()
          Set the sensor bar to be considered above the screen.
 void setSensorBarBelowScreen()
          Set the sensor bar to be considered below the screen.
 void setTimeout(short normalTimeout, short expansionTimeout)
          Set the normal and expansion handshake timeouts for this wiimote.
 void setVirtualResolution(int x, int y)
          Set the screen resolution of the you are pointing at with your wiimote.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

private int id

listeners

private javax.swing.event.EventListenerList listeners

manager

private WiiUseApiManager manager
Constructor Detail

Wiimote

public Wiimote(int idd,
               WiiUseApiManager manager)
Constructor.

Parameters:
idd - id of the wiimote
manager - manager wo built it.
Method Detail

getId

public int getId()
Get the unique id of the wiimote.

Returns:
the id

disconnect

public void disconnect()
Disconnect this wiimote.


activateRumble

public void activateRumble()
Activate the rumble.


deactivateRumble

public void deactivateRumble()
Deactivate the rumble.


activateIRTRacking

public void activateIRTRacking()
Activate IR Tracking.


deactivateIRTRacking

public void deactivateIRTRacking()
Deactivate IR Tracking.


activateMotionSensing

public void activateMotionSensing()
Activate motion sensing.


deactivateMotionSensing

public void deactivateMotionSensing()
Deactivate motion sensing.


activateSmoothing

public void activateSmoothing()
Activate smoothing.


deactivateSmoothing

public void deactivateSmoothing()
Deactivate smoothing.


activateContinuous

public void activateContinuous()
Activate continuous.


deactivateContinuous

public void deactivateContinuous()
Deactivate continuous.


setLeds

public void setLeds(boolean l1,
                    boolean l2,
                    boolean l3,
                    boolean l4)
Set leds status.

Parameters:
l1 - status of led1. True : ON, False : OFF
l2 - status of led2. True : ON, False : OFF
l3 - status of led3. True : ON, False : OFF
l4 - status of led4. True : ON, False : OFF

setOrientationThreshold

public void setOrientationThreshold(float th)
Set the orientation threshold (minimum angle between two degrees with accelerometer).

Parameters:
th - threshold in degrees

setAccelerationThreshold

public void setAccelerationThreshold(int th)
Set the acceleration threshold(minimum angle between two degrees with accelerometer).

Parameters:
th - threshold

setAlphaSmoothingValue

public void setAlphaSmoothingValue(float th)
Set the alpha smoothing value.

Parameters:
th - threshold

setScreenAspectRatio43

public void setScreenAspectRatio43()
Set the screen aspect ratio to be considered as 4/3.


setScreenAspectRatio169

public void setScreenAspectRatio169()
Set the screen aspect ratio to be considered as 16/9.


setSensorBarAboveScreen

public void setSensorBarAboveScreen()
Set the sensor bar to be considered above the screen.


setSensorBarBelowScreen

public void setSensorBarBelowScreen()
Set the sensor bar to be considered below the screen.


setVirtualResolution

public void setVirtualResolution(int x,
                                 int y)
Set the screen resolution of the you are pointing at with your wiimote.

Parameters:
x - x resolution.
y - y resolution.

setNunchukOrientationThreshold

public void setNunchukOrientationThreshold(float th)
Set the nunchuk orientation threshold for the given id. (minimum angle between two events)

Parameters:
th - threshold in degrees.

setNunchukAccelerationThreshold

public void setNunchukAccelerationThreshold(int th)
Set the nunchuk acceleration threshold for the given id. (minimum angle between two events)

Parameters:
th - threshold.

reSync

public void reSync()
Try to resync the wiimote by starting a new handshake.


getStatus

public void getStatus()
Ask for the status of the wiimote. The result will be received in a status event object. Implements onStatusEvent on wiimote listener to get it.


setTimeout

public void setTimeout(short normalTimeout,
                       short expansionTimeout)
Set the normal and expansion handshake timeouts for this wiimote. Normal time out is for classic polling. The expansion timeout is used when an expansion is detected until the expansion successfully handshakes.

Parameters:
normalTimeout - The timeout in milliseconds for a normal read.
expansionTimeout - The timeout in millisecondsd to wait for an expansion handshake.

setIrSensitivity

public void setIrSensitivity(int level)
Set the IR sensitivity.

Parameters:
level - 1-5, same as Wii system sensitivity setting. If the level is < 1, then level will be set to 1. If the level is > 5, then level will be set to 5.

onWiiUseApiEvent

public void onWiiUseApiEvent(WiiUseApiEvent e)
Method called when a WiiUseApiEvent occurs.

Specified by:
onWiiUseApiEvent in interface WiiUseApiListener
Parameters:
e - the WiiUseApiEvent.

addWiiMoteEventListeners

public void addWiiMoteEventListeners(WiimoteListener listener)
Add a WiimoteListener to the listeners list.

Parameters:
listener - a WiimoteListener

removeWiiMoteEventListeners

public void removeWiiMoteEventListeners(WiimoteListener listener)
Remove a WiimoteListener from the listeners list.

Parameters:
listener - a WiimoteListener

getWiiMoteEventListeners

public WiimoteListener[] getWiiMoteEventListeners()
Get the list of WiimoteListener.

Returns:
the list of WiimoteListener.

notifyWiiMoteEventListeners

private void notifyWiiMoteEventListeners(WiimoteEvent evt)
Notify WiimoteListeners that an event occured. Notify in first the listeners for Buttons Events. In second the listeners for IR Events. In third the listeners for Motion sensing events.

Parameters:
evt - GenericEvent occured

notifyStatusEventListeners

private void notifyStatusEventListeners(StatusEvent evt)
Notify WiimoteListener that a status event occured.

Parameters:
evt - status event occured

notifyDisconnectionEventListeners

private void notifyDisconnectionEventListeners(DisconnectionEvent evt)
Notify WiimoteListener that a disconnection event occured.

Parameters:
evt - disconnection event occured

notifyNunchukInsertedEventListeners

private void notifyNunchukInsertedEventListeners(NunchukInsertedEvent evt)
Notify WiimoteListener that a NunchukInserted Event occured.

Parameters:
evt - NunchukInserted Event occured

notifyNunchukRemovedEventListeners

private void notifyNunchukRemovedEventListeners(NunchukRemovedEvent evt)
Notify WiimoteListener that a NunchukRemoved Event occured.

Parameters:
evt - NunchukRemoved Event occured

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object