wiiusej.wiiuseapievents
Class EventsGatherer

java.lang.Object
  extended by wiiusej.wiiuseapievents.EventsGatherer

public class EventsGatherer
extends java.lang.Object

This class is used to gather events during a call to the Wiiuse API.

Author:
guiguito

Field Summary
private  WiiUseApiEvent[] events
           
private  GenericEvent genericEvent
           
private  int index
           
 
Constructor Summary
EventsGatherer(int nbWiimotes)
          Create EventsGatherer.
 
Method Summary
 void addDisconnectionEvent(int id)
          Add a DisconnectionEvent to the gatherer.
private  void addEvent(WiiUseApiEvent e)
          Add an event to the array.
 void addIRPointToPreparedWiiMoteEvent(int x, int y, short rx, short ry, short size)
          Add an IR point to the WiiMoteEvent prepared
 void addMotionSensingValues(float orientationThreshold, int accelerationThreshold, boolean smoothingState, float alphaSmooth, float r, float p, float ya, float x, float y, float z, short xx, short yy, short zz)
          Set orientation and gravity force of the prepared event.
 void addStatusEvent(int id, boolean connect, float batt, short led, boolean speak, int attach, boolean rumbleState, boolean continuousState, boolean irState, boolean motionSensingState)
          Add a StatusEvent to the gatherer.
 void addWiimoteEvent()
          Add the prepared WiimoteEvent to the gatherer.
 void clearEvents()
          Clear the gatherer and remove objects.
 WiiUseApiEvent[] getEvents()
          Return an array containing the events.
 void prepareIRevent(int x, int y, int z, int ax, int ay, int xVRes, int yVRes, int xOffset, int yOffset, short sensorBarPostion, short screenAsPectRatio)
          Prepare an IR event to populate.
 void prepareWiiMoteEvent(int id, short buttonsJustPressed, short buttonsJustReleased, short buttonsHeld)
          Prepare a wiimote event to add.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

events

private WiiUseApiEvent[] events

index

private int index

genericEvent

private GenericEvent genericEvent
Constructor Detail

EventsGatherer

public EventsGatherer(int nbWiimotes)
Create EventsGatherer.

Parameters:
nbWiimotes - nb wiimotes (nb a of events possible in a call to Wiiuse API)
Method Detail

addEvent

private void addEvent(WiiUseApiEvent e)
Add an event to the array.

Parameters:
e - the event to add.

prepareWiiMoteEvent

public void prepareWiiMoteEvent(int id,
                                short buttonsJustPressed,
                                short buttonsJustReleased,
                                short buttonsHeld)
Prepare a wiimote event to add.

Parameters:
id - id of the wiimote.
buttonsJustPressed - buttons just pressed
buttonsJustReleased - buttons just released
buttonsHeld - buttons held

prepareIRevent

public void prepareIRevent(int x,
                           int y,
                           int z,
                           int ax,
                           int ay,
                           int xVRes,
                           int yVRes,
                           int xOffset,
                           int yOffset,
                           short sensorBarPostion,
                           short screenAsPectRatio)
Prepare an IR event to populate.

Parameters:
x - calculated X coordinate.
y - calculated Y coordinate.
z - calculated distance.
ax - absolute X coordinate.
ay - absolute Y coordinate
xVRes - IR virtual screen x resolution.
yVRes - IR virtual screen y resolution.
xOffset - IR X correction offset.
yOffset - IR Y correction offset.
sensorBarPostion - aspect ratio of the screen.
screenAsPectRatio - IR sensor bar position.

addIRPointToPreparedWiiMoteEvent

public void addIRPointToPreparedWiiMoteEvent(int x,
                                             int y,
                                             short rx,
                                             short ry,
                                             short size)
Add an IR point to the WiiMoteEvent prepared

Parameters:
x - x coordinates
y - y coordinates
rx - raw X coordinate (0-1023).
ry - raw Y coordinate (0-1023).
size - size of the IR dot (0-15).

addMotionSensingValues

public void addMotionSensingValues(float orientationThreshold,
                                   int accelerationThreshold,
                                   boolean smoothingState,
                                   float alphaSmooth,
                                   float r,
                                   float p,
                                   float ya,
                                   float x,
                                   float y,
                                   float z,
                                   short xx,
                                   short yy,
                                   short zz)
Set orientation and gravity force of the prepared event.

Parameters:
orientationThreshold - value of the minimum angle between two events with the accelerometer
accelerationThreshold - value of the value variation between two events with the accelerometer
smoothingState - true if smoothing flag is activated
alphaSmooth - value of the alpha smoothing parameter
r - roll
p - pitch
ya - yaw
x - gravity force on x axis
y - gravity force on y axis
z - gravity force on z axis
xx - raw acceleration on x axis
yy - raw acceleration on y axis
zz - raw acceleration on z axis

addWiimoteEvent

public void addWiimoteEvent()
Add the prepared WiimoteEvent to the gatherer.


addStatusEvent

public void addStatusEvent(int id,
                           boolean connect,
                           float batt,
                           short led,
                           boolean speak,
                           int attach,
                           boolean rumbleState,
                           boolean continuousState,
                           boolean irState,
                           boolean motionSensingState)
Add a StatusEvent to the gatherer.

Parameters:
id - id of the wiimote
connect - true if the wiimote is connected
batt - battery level
led - status of leds
speak - speakers status
attach - attachment status
rumbleState - true if rumble is active
continuousState - true if continuous flag is activated
irState - true if ir is active
motionSensingState - true if accelerometer is active

addDisconnectionEvent

public void addDisconnectionEvent(int id)
Add a DisconnectionEvent to the gatherer.

Parameters:
id - id of the wiimote

getEvents

public WiiUseApiEvent[] getEvents()
Return an array containing the events.

Returns:
events received

clearEvents

public void clearEvents()
Clear the gatherer and remove objects.