wiiusej
Class WiiUseApi

java.lang.Object
  extended by wiiusej.WiiUseApi

public class WiiUseApi
extends java.lang.Object

Singleton used to manipulate WiiUse Api.

Author:
guiguito

Field Summary
private static WiiUseApi instance
           
 
Constructor Summary
WiiUseApi()
           
 
Method Summary
(package private)  void activateContinuous(int id)
          Make the wiimote generate an event each time we poll.
(package private)  void activateIRTracking(int id)
          Activate IR Tracking on the wiimote with the given id.
(package private)  void activateMotionSensing(int id)
          Activate motion sensing on the wiimote with the given id.
(package private)  void activateRumble(int id)
          Activate rumble on the wiimote with the given id.
(package private)  void activateSmoothing(int id)
          Make the the accelerometers give smoother results.
(package private)  void cleanUp()
          CleanUp Wiiuse API.
(package private)  void closeConnection(int id)
          Close connection to the wiimote with the given id.
(package private)  int connect(int nbWiimotes)
          Connect to a wiimote or wiimotes once an address is known.
(package private)  void deactivateContinuous(int id)
          Make the wiimote generate an event only when there is one.
(package private)  void deactivateIRTracking(int id)
          Deactivate IR Tracking on the wiimote with the given id.
(package private)  void deactivateMotionSensing(int id)
          Deactivate motion sensing on the wiimote with the given id.
(package private)  void deactivateRumble(int id)
          Deactivate rumble on the wiimote with the given id.
(package private)  void deactivateSmoothing(int id)
          Make the the accelerometers give raw results.
(package private)  int find(int nbMaxWiimotes, int timeout)
          Find a wiimote or wiimotes.
protected static WiiUseApi getInstance()
          Get the only instance of WiiUseApi.
(package private)  void getStatus(int id)
          Get status and values from the wiimotes and send it through callbacks.
(package private)  int getUnId(int index)
          Get unique id of a wiimote in the wiimotes array.
(package private)  void init(int nbPossibleWiimotes)
          Initialize an array of wiimote structures (for the C side of the library).
(package private)  void reSync(int id)
          Try to resync with the wiimote by starting a new handshake.
(package private)  void setAccelThreshold(int id, int value)
          Set how much acceleration must change to generate an event.
(package private)  void setAlphaSmoothing(int id, float value)
          Set alpha smoothing parameter for the given id.
(package private)  void setIrSensitivity(int id, int level)
          Set the IR sensitivity.
(package private)  void setLeds(int id, boolean led1, boolean led2, boolean led3, boolean led4)
          Set wiimote leds status.
(package private)  void setNunchukAccelerationThreshold(int id, int value)
          Set how much acceleration must change to generate an event for the nunchuk.
(package private)  void setNunchukOrientationThreshold(int id, float angle)
          Set how many degrees an angle must change to generate an event for the nunchuk.
(package private)  void setOrientThreshold(int id, float angle)
          Set how many degrees an angle must change to generate an event.
(package private)  void setScreenRatio169(int id)
          Notify wiiuse that your screen has an aspect ratio of 16/9.
(package private)  void setScreenRatio43(int id)
          Notify wiiuse that your screen has an aspect ratio of 4/3.
(package private)  void setSensorBarAboveScreen(int id)
          Notify wiiuse that the sensor bar is above your screen.
(package private)  void setSensorBarBelowScreen(int id)
          Notify wiiuse that the sensor bar is below your screen.
(package private)  void setTimeout(int id, short normalTimeout, short expansionTimeout)
          Set the normal and expansion handshake timeouts.
(package private)  void setVirtualScreenResolution(int id, int x, int y)
          Set virtual screen resolution.
(package private)  void specialPoll(EventsGatherer gath)
          Check for new Events and Get it.
(package private)  void windowsSetBluetoothStack(int bluetoothStackType)
          Force the bluetooth stack type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static WiiUseApi instance
Constructor Detail

WiiUseApi

public WiiUseApi()
Method Detail

getInstance

protected static WiiUseApi getInstance()
Get the only instance of WiiUseApi.

Returns:
the only instace of WiiUseApi.

connect

int connect(int nbWiimotes)
Connect to a wiimote or wiimotes once an address is known.

Parameters:
nbWiimotes - The number of wiimotes.
Returns:
The number of wiimotes that successfully connected.

find

int find(int nbMaxWiimotes,
         int timeout)
Find a wiimote or wiimotes.

Parameters:
nbMaxWiimotes - The number of wiimotes.
timeout - The number of seconds before the search times out.
Returns:
The number of wiimotes found.

init

void init(int nbPossibleWiimotes)
Initialize an array of wiimote structures (for the C side of the library).

Parameters:
nbPossibleWiimotes - size of the array.

closeConnection

void closeConnection(int id)
Close connection to the wiimote with the given id.


getUnId

int getUnId(int index)
Get unique id of a wiimote in the wiimotes array. Please make sure you call an existing index with a wiimote initialized at this index, other wise you'll get a wrong value.

Parameters:
index - index of the wiimote in the wiimotes array.
Returns:
the unid of the wiimote, or a wrong value if the index was false.

cleanUp

void cleanUp()
CleanUp Wiiuse API.


activateRumble

void activateRumble(int id)
Activate rumble on the wiimote with the given id.

Parameters:
id - the id of the wiimote.

deactivateRumble

void deactivateRumble(int id)
Deactivate rumble on the wiimote with the given id.

Parameters:
id - the id of the wiimote.

activateIRTracking

void activateIRTracking(int id)
Activate IR Tracking on the wiimote with the given id.

Parameters:
id - the id of the wiimote.

deactivateIRTracking

void deactivateIRTracking(int id)
Deactivate IR Tracking on the wiimote with the given id.

Parameters:
id - the id of the wiimote.

activateMotionSensing

void activateMotionSensing(int id)
Activate motion sensing on the wiimote with the given id.

Parameters:
id - the id of the wiimote.

deactivateMotionSensing

void deactivateMotionSensing(int id)
Deactivate motion sensing on the wiimote with the given id.

Parameters:
id - the id of the wiimote.

setLeds

void setLeds(int id,
             boolean led1,
             boolean led2,
             boolean led3,
             boolean led4)
Set wiimote leds status.

Parameters:
id - the id of the wiimote concerned.
led1 - status of led1: True=ON, False=OFF.
led2 - status of led2: True=ON, False=OFF.
led3 - status of led3: True=ON, False=OFF.
led4 - status of led4: True=ON, False=OFF.

setOrientThreshold

void setOrientThreshold(int id,
                        float angle)
Set how many degrees an angle must change to generate an event.

Parameters:
id - id of the wiimote concerned.
angle - minimum angle detected by an event.

setAccelThreshold

void setAccelThreshold(int id,
                       int value)
Set how much acceleration must change to generate an event.

Parameters:
id - id of the wiimote concerned.
value - minimum value detected by an event.

setAlphaSmoothing

void setAlphaSmoothing(int id,
                       float value)
Set alpha smoothing parameter for the given id.

Parameters:
id - id of the wiimote concerned.
value - alpha smoothing value.

reSync

void reSync(int id)
Try to resync with the wiimote by starting a new handshake.

Parameters:
id - id of the wiimote concerned.

activateSmoothing

void activateSmoothing(int id)
Make the the accelerometers give smoother results. This is set by default.

Parameters:
id - the id of the wiimote concerned.

deactivateSmoothing

void deactivateSmoothing(int id)
Make the the accelerometers give raw results.

Parameters:
id - the id of the wiimote concerned.

activateContinuous

void activateContinuous(int id)
Make the wiimote generate an event each time we poll. Not set by default.

Parameters:
id - the id of the wiimote concerned.

deactivateContinuous

void deactivateContinuous(int id)
Make the wiimote generate an event only when there is one.

Parameters:
id - the id of the wiimote concerned.

setScreenRatio43

void setScreenRatio43(int id)
Notify wiiuse that your screen has an aspect ratio of 4/3.

Parameters:
id - the id of the wiimote of which we want the status.

setScreenRatio169

void setScreenRatio169(int id)
Notify wiiuse that your screen has an aspect ratio of 16/9.

Parameters:
id - the id of the wiimote of which we want the status.

setSensorBarAboveScreen

void setSensorBarAboveScreen(int id)
Notify wiiuse that the sensor bar is above your screen.

Parameters:
id - the id of the wiimote of which we want the status.

setSensorBarBelowScreen

void setSensorBarBelowScreen(int id)
Notify wiiuse that the sensor bar is below your screen.

Parameters:
id - the id of the wiimote of which we want the status.

setVirtualScreenResolution

void setVirtualScreenResolution(int id,
                                int x,
                                int y)
Set virtual screen resolution. It is used to automatically compute the position of a cursor on this virtual screen using the sensor bar. These results come in the IREvent.

Parameters:
id - the id of the wiimote of which we want the status.
x - x resolution.
y - y resolution.

getStatus

void getStatus(int id)
Get status and values from the wiimotes and send it through callbacks.

Parameters:
id - the id of the wiimote of which we want the status.

setTimeout

void setTimeout(int id,
                short normalTimeout,
                short expansionTimeout)
Set the normal and expansion handshake timeouts.

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

setIrSensitivity

void setIrSensitivity(int id,
                      int level)
Set the IR sensitivity.

Parameters:
id - the id of the wiimote concerned.
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.

setNunchukOrientationThreshold

void setNunchukOrientationThreshold(int id,
                                    float angle)
Set how many degrees an angle must change to generate an event for the nunchuk.

Parameters:
id - id of the wiimote concerned.
angle - minimum angle detected by an event.

setNunchukAccelerationThreshold

void setNunchukAccelerationThreshold(int id,
                                     int value)
Set how much acceleration must change to generate an event for the nunchuk.

Parameters:
id - id of the wiimote concerned.
value - minimum value detected by an event.

windowsSetBluetoothStack

void windowsSetBluetoothStack(int bluetoothStackType)
Force the bluetooth stack type.(useful only for windows)

Parameters:
bluetoothStackType - must be WiiUseApi.WIIUSE_STACK_UNKNOWN or WiiUseApi.WIIUSE_STACK_MS or WiiUseApi.WIIUSE_STACK_BLUESOLEIL.

specialPoll

void specialPoll(EventsGatherer gath)
Check for new Events and Get it.

Parameters:
gath - the object where we store all the new events.