wiiusej.wiiusejevents.utils
Class EventsGatherer

java.lang.Object
  extended by wiiusej.wiiusejevents.utils.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  WiimoteEvent 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 ar, float ap, float x, float y, float z, short xx, short yy, short zz)
          Set orientation and gravity force of the prepared event.
 void addNunchukInsertedEvent(int id)
          Add a NunchukInsertedEvent to the gatherer.
 void addNunchukRemovedEvent(int id)
          Add a NunchukRemovedEvent to the gatherer.
 void addNunchunkEventToPreparedWiimoteEvent(short buttonsJustPressed, short buttonsJustReleased, short buttonsHeld, float orientationThreshold, int accelerationThreshold, boolean smoothingState, float alphaSmooth, float r, float p, float ya, float ar, float ap, float x, float y, float z, short xx, short yy, short zz, float angle, float magnitude, short max1, short max2, short min1, short min2, short center1, short center2)
          Set a NunchukEvent to the prepared .
 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, float z, int ax, int ay, int xVRes, int yVRes, int xOffset, int yOffset, short sensorBarPostion, short screenAsPectRatio, short irSensitivity, float distance)
          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 WiimoteEvent 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,
                           float z,
                           int ax,
                           int ay,
                           int xVRes,
                           int yVRes,
                           int xOffset,
                           int yOffset,
                           short sensorBarPostion,
                           short screenAsPectRatio,
                           short irSensitivity,
                           float distance)
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.
irSensitivity - Sensitivity of the infrared camera.
distance - Pixel Distance between first two dots.

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 ar,
                                   float ap,
                                   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.
ar - absolute roll.
ap - absolute pitch.
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.

addNunchunkEventToPreparedWiimoteEvent

public void addNunchunkEventToPreparedWiimoteEvent(short buttonsJustPressed,
                                                   short buttonsJustReleased,
                                                   short buttonsHeld,
                                                   float orientationThreshold,
                                                   int accelerationThreshold,
                                                   boolean smoothingState,
                                                   float alphaSmooth,
                                                   float r,
                                                   float p,
                                                   float ya,
                                                   float ar,
                                                   float ap,
                                                   float x,
                                                   float y,
                                                   float z,
                                                   short xx,
                                                   short yy,
                                                   short zz,
                                                   float angle,
                                                   float magnitude,
                                                   short max1,
                                                   short max2,
                                                   short min1,
                                                   short min2,
                                                   short center1,
                                                   short center2)
Set a NunchukEvent to the prepared .

Parameters:
buttonsJustPressed - buttons just pressed.
buttonsJustReleased - buttons just released.
buttonsHeld - buttons just pressed.
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.
ar - absolute roll.
ap - absolute pitch.
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.
angle - angle the joystick is being held.
magnitude - magnitude of the joystick (range 0-1).
max1 - maximum joystick value 1.
max2 - maximum joystick value 2.
min1 - minimum joystick value 1.
min2 - minimum joystick value 2.
center1 - center joystick value 1.
center2 - center joystick value 2.

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.

addNunchukInsertedEvent

public void addNunchukInsertedEvent(int id)
Add a NunchukInsertedEvent to the gatherer.

Parameters:
id - id of the wiimote.

addNunchukRemovedEvent

public void addNunchukRemovedEvent(int id)
Add a NunchukRemovedEvent 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.