wiiusej 0.12 clean1 before release

git-svn-id: http://wiiusej.googlecode.com/svn/trunk@158 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
guilhem.duche
2008-06-01 09:50:30 +00:00
parent 2fb184eda3
commit b2c8a6d87d
35 changed files with 1219 additions and 1080 deletions

View File

@@ -20,28 +20,34 @@ import wiiusej.wiiusejevents.GenericEvent;
/**
* Class which represents a buttons event.
*
* @author guiguito
*/
public abstract class ButtonsEvent extends GenericEvent{
public abstract class ButtonsEvent extends GenericEvent {
/* Buttons */
private short buttonsJustPressed = 0;
private short buttonsJustReleased = 0;
private short buttonsHeld = 0;
/**
* Constructor of the button Event.
* @param id id of the wiimote concerned.
* @param buttonsJustPressed buttons just pressed.
* @param buttonsJustReleased buttons just released.
* @param buttonsHeld buttons just held.
*
* @param id
* id of the wiimote concerned.
* @param buttonsJustPressed
* buttons just pressed.
* @param buttonsJustReleased
* buttons just released.
* @param buttonsHeld
* buttons just held.
*/
public ButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld){
short buttonsJustReleased, short buttonsHeld) {
super(id);
setAllButtons(buttonsJustPressed, buttonsJustReleased, buttonsHeld);
}
/**
* Set all buttons in one method.
*
@@ -55,7 +61,7 @@ public abstract class ButtonsEvent extends GenericEvent{
this.buttonsJustReleased = buttonsJustReleased;
this.buttonsHeld = buttonsHeld;
}
/**
* Get the short storing the buttons just pressed
*
@@ -82,7 +88,7 @@ public abstract class ButtonsEvent extends GenericEvent{
public short getButtonsHeld() {
return buttonsHeld;
}
/** **************** BUTTONS Methods ***************** */
/* generic button functions */
@@ -102,11 +108,12 @@ public abstract class ButtonsEvent extends GenericEvent{
protected boolean isButtonHeld(short buttonBitsDefinition) {
return buttonTest(buttonBitsDefinition, buttonsHeld);
}
protected boolean isButtonPressed(short buttonBitsDefinition) {
return isButtonHeld(buttonBitsDefinition)||isButtonJustPressed(buttonBitsDefinition);
}
return isButtonHeld(buttonBitsDefinition)
|| isButtonJustPressed(buttonBitsDefinition);
}
@Override
public String toString() {
String out = "";

View File

@@ -18,19 +18,20 @@ package wiiusej.wiiusejevents.physicalevents;
import wiiusej.wiiusejevents.GenericEvent;
/**
* Mother Class of all expansions.
* Mother Class of all expansions event.
*
* @author guiguito
*/
public abstract class ExpansionEvent extends GenericEvent {
/**
* Constructor of an ExpansionEvent.
* @param id id of the wiimote to which the expansion is connected.
*
* @param id
* id of the wiimote to which the expansion is connected.
*/
public ExpansionEvent(int id){
public ExpansionEvent(int id) {
super(id);
}

View File

@@ -27,19 +27,24 @@ public class NunchukButtonsEvent extends ButtonsEvent {
private static short NUNCHUK_BUTTON_Z = 0x01;
private static short NUNCHUK_BUTTON_C = 0x02;
private static short NUNCHUK_BUTTON_ALL = 0x03;
/**
* Constructor of the nunchuk button Event.
* @param id id of the wiimote.
* @param buttonsJustPressed buttons just pressed.
* @param buttonsJustReleased buttons just released.
* @param buttonsHeld buttons just pressed.
*
* @param id
* id of the wiimote.
* @param buttonsJustPressed
* buttons just pressed.
* @param buttonsJustReleased
* buttons just released.
* @param buttonsHeld
* buttons just pressed.
*/
public NunchukButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) {
super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld);
}
/* Button Z */
public boolean isButtonZJustPressed() {
@@ -57,7 +62,7 @@ public class NunchukButtonsEvent extends ButtonsEvent {
public boolean isButtonZPressed() {
return isButtonPressed(NUNCHUK_BUTTON_Z);
}
/* Button Z */
public boolean isButtonCJustPressed() {
@@ -82,5 +87,4 @@ public class NunchukButtonsEvent extends ButtonsEvent {
+ super.toString();
}
}

View File

@@ -103,9 +103,7 @@ public class NunchukEvent extends ExpansionEvent {
nunchukJoystickEvent = new JoystickEvent(id, angle, magnitude, max1,
max2, min1, min2, center1, center2);
}
/**
* Tell if there is a nunchuk motion sensing Event.
*
@@ -114,7 +112,7 @@ public class NunchukEvent extends ExpansionEvent {
public boolean isThereMotionSensingEvent() {
return nunchukMotionSensingEvent != null;
}
/**
* Tell if there is a nunchuk joystick event.
*

View File

@@ -45,10 +45,15 @@ public class WiimoteButtonsEvent extends ButtonsEvent {
/**
* Constructor of the wiimote button Event.
* @param id id of the wiimote.
* @param buttonsJustPressed buttons just pressed.
* @param buttonsJustReleased buttons just released.
* @param buttonsHeld buttons held.
*
* @param id
* id of the wiimote.
* @param buttonsJustPressed
* buttons just pressed.
* @param buttonsJustReleased
* buttons just released.
* @param buttonsHeld
* buttons held.
*/
public WiimoteButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) {

View File

@@ -103,9 +103,10 @@ public class EventsGatherer {
* @param distance
* Pixel Distance between first two dots.
*/
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) {
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) {
genericEvent.prepareIRevent(x, y, z, ax, ay, xVRes, yVRes, xOffset,
yOffset, sensorBarPostion, screenAsPectRatio, irSensitivity,
distance);
@@ -179,7 +180,7 @@ public class EventsGatherer {
ya, ar, ap, x, y, z, xx, yy, zz);
}
}
/**
* Set a NunchukEvent to the prepared .
*
@@ -238,19 +239,20 @@ public class EventsGatherer {
* @param center2
* center joystick value 2.
*/
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){
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) {
if (genericEvent != null) {
genericEvent.setNunchukEvent(buttonsJustPressed,
buttonsJustReleased, buttonsHeld, orientationThreshold,
accelerationThreshold, smoothingState, alphaSmooth, r, p, ya,
ar, ap, x, y, z, xx, yy, zz, angle, magnitude, max1, max2,
min1, min2, center1, center2);
buttonsJustReleased, buttonsHeld, orientationThreshold,
accelerationThreshold, smoothingState, alphaSmooth, r, p,
ya, ar, ap, x, y, z, xx, yy, zz, angle, magnitude, max1,
max2, min1, min2, center1, center2);
}
}
@@ -307,7 +309,7 @@ public class EventsGatherer {
DisconnectionEvent evt = new DisconnectionEvent(id);
addEvent(evt);
}
/**
* Add a NunchukInsertedEvent to the gatherer.
*
@@ -318,7 +320,7 @@ public class EventsGatherer {
NunchukInsertedEvent evt = new NunchukInsertedEvent(id);
addEvent(evt);
}
/**
* Add a NunchukRemovedEvent to the gatherer.
*

View File

@@ -18,24 +18,20 @@ package wiiusej.wiiusejevents.utils;
import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
/**
* This is the interface to implement to listen to events from the wiiuse API.
*
* @author guiguito
*/
public interface WiiUseApiListener extends java.util.EventListener {
/**
* Method called when a WiiUseApiEvent occurs.
* A WiiUseApiEvent can be :
* - WiimoteEvent (Storing ButtonsEvent and
* eventually IREvent and MotionSensingEvent)
* - StatusEvent
* - DisconnectionEvent
* Method called when a WiiUseApiEvent occurs. A WiiUseApiEvent can be : -
* WiimoteEvent (Storing ButtonsEvent and eventually IREvent and
* MotionSensingEvent) - StatusEvent - DisconnectionEvent
*
* @param e
*/
void onWiiUseApiEvent(WiiUseApiEvent e);
}

View File

@@ -26,9 +26,10 @@ import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/**
* This is the interface to implement to listen to events from wiimotes.
* The differents methods are called in this order :
* onButtonsEvent, onIrEvent, onMotionSensingEvent, onStatusEvent, onDisconnectionEvent.
* This is the interface to implement to listen to events from wiimotes. The
* differents methods are called in this order : onButtonsEvent, onIrEvent,
* onMotionSensingEvent, onExpansionEvent, onStatusEvent, onDisconnectionEvent
* onNunchukInsertedEvent, onNunchukRemovedEvent.
*
* @author guiguito
*/
@@ -36,60 +37,71 @@ public interface WiimoteListener extends java.util.EventListener {
/**
* Method called on a button Event.
* @param e the buttonEvent with the last informations
* about the buttons of the wiimote.
*
* @param e
* the buttonEvent with the last informations about the buttons
* of the wiimote.
*/
void onButtonsEvent(WiimoteButtonsEvent e);
/**
* Method called when an IR event occurs.
* @param e the IREvent with the IR points seen.
*
* @param e
* the IREvent with the IR points seen.
*/
void onIrEvent(IREvent e);
/**
* Method called when a motion sensing event occurs.
* @param e the motion sensing event with orientation and acceleration.
*
* @param e
* the motion sensing event with orientation and acceleration.
*/
void onMotionSensingEvent(MotionSensingEvent e);
/**
* Method called when an expansion event occurs.
* @param e the expansion event occured.
*
* @param e
* the expansion event occured.
*/
void onExpansionEvent(ExpansionEvent e);
/**
* Method called on a status event.
* A status event occurs when :
* - we ask it
* - an expansion controller has been plugged
* - an expansion controller has been unplugged
* This is where you can get the different values of
* the parameters setup on your wiimote.
* @param e the status event.
* Method called on a status event. A status event occurs when : - we ask it -
* an expansion controller has been plugged - an expansion controller has
* been unplugged This is where you can get the different values of the
* parameters setup on your wiimote.
*
* @param e
* the status event.
*/
void onStatusEvent(StatusEvent e);
/**
* This is the method called when a disconnection event occurs.
* A disconnection event happens when :
* - there are no battery left
* - the wiimote has just been turned off
* - the connection is dropped
* @param e the disconnection event.
* This is the method called when a disconnection event occurs. A
* disconnection event happens when : - there are no battery left - the
* wiimote has just been turned off - the connection is dropped
*
* @param e
* the disconnection event.
*/
void onDisconnectionEvent(DisconnectionEvent e);
/**
* This is the method called when a NunchukInsertedEvent occurs.
* @param e the NunchukInsertedEvent.
*
* @param e
* the NunchukInsertedEvent.
*/
void onNunchukInsertedEvent(NunchukInsertedEvent e);
/**
* This is the method called when a NunchukRemovedEvent occurs.
* @param e the NunchukRemovedEvent.
*
* @param e
* the NunchukRemovedEvent.
*/
void onNunchukRemovedEvent(NunchukRemovedEvent e);
}

View File

@@ -16,9 +16,9 @@
*/
package wiiusej.wiiusejevents.wiiuseapievents;
/**
* Class representing a disconnection event.
*
* @author guiguito
*/
public class DisconnectionEvent extends WiiUseApiEvent {
@@ -30,14 +30,15 @@ public class DisconnectionEvent extends WiiUseApiEvent {
* the Wiimote id
*/
public DisconnectionEvent(int id) {
super(id,WiiUseApiEvent.DISCONNECTION_EVENT);
super(id, WiiUseApiEvent.DISCONNECTION_EVENT);
}
@Override
public String toString() {
String out = "";
/* Status */
out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :" + super.getWiimoteId() + " ********/\n";
out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n";
return out;
}

View File

@@ -16,30 +16,35 @@
*/
package wiiusej.wiiusejevents.wiiuseapievents;
/**
* Event that represents the connection of a nunchuk to a wiimote.
*
* @author guiguito
*
*
*/
public class NunchukInsertedEvent extends WiiUseApiEvent {
/**
* Construct the NunchukInsertedEvent setting up the id.
* @param id id of the wiimote.
*
* @param id
* id of the wiimote.
*/
public NunchukInsertedEvent(int id) {
super(id, WIIUSE_NUNCHUK_INSERTED);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see wiiusej.wiiusejevents.WiiUseApiEvent#toString()
*/
@Override
public String toString() {
String out = "";
/* Status */
out += "/*********** NUNCHUK INSERTED EVENT : WIIMOTE ID :" + super.getWiimoteId() + " ********/\n";
out += "/*********** NUNCHUK INSERTED EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n";
return out;
}

View File

@@ -16,29 +16,34 @@
*/
package wiiusej.wiiusejevents.wiiuseapievents;
/**
* Event that represents the connection of a nunchuk to a wiimote.
*
* @author guiguito
*/
public class NunchukRemovedEvent extends WiiUseApiEvent {
/**
* Construct the NunchukInsertedEvent setting up the id.
* @param id id of the wiimote.
*
* @param id
* id of the wiimote.
*/
public NunchukRemovedEvent(int id) {
super(id, WIIUSE_NUNCHUK_REMOVED);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see wiiusej.wiiusejevents.WiiUseApiEvent#toString()
*/
@Override
public String toString() {
String out = "";
/* Status */
out += "/*********** NUNCHUK REMOVED EVENT : WIIMOTE ID :" + super.getWiimoteId() + " ********/\n";
out += "/*********** NUNCHUK REMOVED EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n";
return out;
}

View File

@@ -157,9 +157,10 @@ public class WiimoteEvent extends WiiUseApiEvent {
* @param distance
* Pixel Distance between first two dots
*/
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) {
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) {
if (infraredEvent == null) {
infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes,
yVRes, xOffset, yOffset, sensorBarPostion,