0.12 going well. Added everything for the nunchuk. Need more testing.

git-svn-id: http://wiiusej.googlecode.com/svn/trunk@141 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
guilhem.duche
2008-05-09 22:22:13 +00:00
parent 732154a82f
commit be56f33b33
16 changed files with 1205 additions and 807 deletions

View File

@@ -124,7 +124,6 @@ public class JoystickEvent extends GenericEvent {
String out = "";
/* Display IR Tracking */
out += "/******** Joystick ********/\n";
out += "--- Active : true\n";
out += "--- angle : " + angle + "\n";
out += "--- magnitude : " + magnitude + "\n";
out += "--- maximum values : " + max[0] + "," + max[1] + "\n";

View File

@@ -45,36 +45,36 @@ public class MotionSensingEvent extends GenericEvent {
* id of the wiimote concerned.
* @param orientationThreshold
* value of the minimum angle between two events with the
* accelerometer
* accelerometer.
* @param accelerationThreshold
* value of the value variation between two events with the
* accelerometer
* accelerometer.
* @param smoothingState
* true if smoothing flag is activated
* true if smoothing flag is activated.
* @param alphaSmooth
* value of the alpha smoothing parameter
* value of the alpha smoothing parameter.
* @param r
* roll
* roll.
* @param p
* pitch
* pitch.
* @param ya
* yaw
* yaw.
* @param ar
* absolute roll
* absolute roll.
* @param ap
* absolute pitch
* absolute pitch.
* @param x
* gravity force on x axis
* gravity force on x axis.
* @param y
* gravity force on y axis
* gravity force on y axis.
* @param z
* gravity force on z axis
* gravity force on z axis.
* @param xx
* raw acceleration on x axis
* raw acceleration on x axis.
* @param yy
* raw acceleration on y axis
* raw acceleration on y axis.
* @param zz
* raw acceleration on z axis
* raw acceleration on z axis.
*/
public MotionSensingEvent(int id, float orientationThreshold,
int accelerationThreshold, boolean smoothingState,

View File

@@ -28,16 +28,129 @@ public class NunchukEvent extends ExpansionEvent {
JoystickEvent nunchukJoystickEvent;
/**
* Constructor of NunchukEvent.
*
* @param id
* id of the wiimote.
* @param buttonsJustPressed
* buttons just pressed.
* @param buttonsJustReleased
* buttons just released.
* @param buttonsHeld
* buttons just pressed.
* @param orientationThreshold
* value of the minimum angle between two events with the
* accelerometer.
* @param accelerationThreshold
* value of the value variation between two events with the
* accelerometer.
* @param smoothingState
* true if smoothing flag is activated.
* @param alphaSmooth
* value of the alpha smoothing parameter.
* @param r
* roll.
* @param p
* pitch.
* @param ya
* yaw.
* @param ar
* absolute roll.
* @param ap
* absolute pitch.
* @param x
* gravity force on x axis.
* @param y
* gravity force on y axis.
* @param z
* gravity force on z axis.
* @param xx
* raw acceleration on x axis.
* @param yy
* raw acceleration on y axis.
* @param zz
* raw acceleration on z axis.
* @param angle
* angle the joystick is being held.
* @param magnitude
* magnitude of the joystick (range 0-1).
* @param max1
* maximum joystick value 1.
* @param max2
* maximum joystick value 2.
* @param min1
* minimum joystick value 1.
* @param min2
* minimum joystick value 2.
* @param center1
* center joystick value 1.
* @param center2
* center joystick value 2.
*/
public NunchukEvent(int id) {
public NunchukEvent(int id, 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, int angle, int magnitude, short max1,
short max2, short min1, short min2, short center1, short center2) {
super(id);
// TODO Auto-generated constructor stub
buttonsEvent = new NunchukButtonsEvent(id, buttonsJustPressed,
buttonsJustReleased, buttonsHeld);
nunchukMotionSensingEvent = new MotionSensingEvent(id,
orientationThreshold, accelerationThreshold, smoothingState,
alphaSmooth, r, p, ya, ar, ap, x, y, z, xx, yy, zz);
nunchukJoystickEvent = new JoystickEvent(id, angle, magnitude, max1,
max2, min1, min2, center1, center2);
}
/**
* Tell if there is a nunchuk motion sensing Event.
*
* @return TRUE if there is a nunchuk motion sensing event, false otherwise.
*/
public boolean isThereMotionSensingEvent() {
return nunchukMotionSensingEvent != null;
}
/**
* Tell if there is a nunchuk joystick event.
*
* @return TRUE if there is a nunchuk joystick event, false otherwise.
*/
public boolean isThereNunchukJoystickEvent() {
return nunchukJoystickEvent != null;
}
/**
* Get joystick buttons event.
*
* @return the joystick buttons event if there is one or null.
*/
public NunchukButtonsEvent getButtonsEvent() {
return buttonsEvent;
}
/**
* Get the nunchuk motion sensing event.
*
* @return the nunchuk motion sensing event if there is one or null.
*/
public MotionSensingEvent getNunchukMotionSensingEvent() {
return nunchukMotionSensingEvent;
}
/**
* Get the nunchuk joystick event.
*
* @return the nunchuk Joystick Event if there is one or null.
*/
public JoystickEvent getNunchukJoystickEvent() {
return nunchukJoystickEvent;
}
/*
* (non-Javadoc)
*

View File

@@ -38,7 +38,7 @@ public class EventsGatherer {
* Create EventsGatherer.
*
* @param nbWiimotes
* nb wiimotes (nb a of events possible in a call to Wiiuse API)
* nb wiimotes (nb a of events possible in a call to Wiiuse API).
*/
public EventsGatherer(int nbWiimotes) {
events = new WiiUseApiEvent[nbWiimotes];
@@ -61,11 +61,11 @@ public class EventsGatherer {
* @param id
* id of the wiimote.
* @param buttonsJustPressed
* buttons just pressed
* buttons just pressed.
* @param buttonsJustReleased
* buttons just released
* buttons just released.
* @param buttonsHeld
* buttons held
* buttons held.
*/
public void prepareWiiMoteEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) {
@@ -85,7 +85,7 @@ public class EventsGatherer {
* @param ax
* absolute X coordinate.
* @param ay
* absolute Y coordinate
* absolute Y coordinate.
* @param xVRes
* IR virtual screen x resolution.
* @param yVRes
@@ -101,7 +101,7 @@ public class EventsGatherer {
* @param irSensitivity
* Sensitivity of the infrared camera.
* @param distance
* Pixel Distance between first two dots
* Pixel Distance between first two dots.
*/
public void prepareIRevent(int x, int y, int z, int ax, int ay, int xVRes,
int yVRes, int xOffset, int yOffset, short sensorBarPostion,
@@ -113,12 +113,12 @@ public class EventsGatherer {
}
/**
* Add an IR point to the WiiMoteEvent prepared
* Add an IR point to the WiiMoteEvent prepared.
*
* @param x
* x coordinates
* x coordinates.
* @param y
* y coordinates
* y coordinates.
* @param rx
* raw X coordinate (0-1023).
* @param ry
@@ -138,36 +138,36 @@ public class EventsGatherer {
*
* @param orientationThreshold
* value of the minimum angle between two events with the
* accelerometer
* accelerometer.
* @param accelerationThreshold
* value of the value variation between two events with the
* accelerometer
* accelerometer.
* @param smoothingState
* true if smoothing flag is activated
* true if smoothing flag is activated.
* @param alphaSmooth
* value of the alpha smoothing parameter
* value of the alpha smoothing parameter.
* @param r
* roll
* roll.
* @param p
* pitch
* pitch.
* @param ya
* yaw
* yaw.
* @param ar
* absolute roll
* absolute roll.
* @param ap
* absolute pitch
* absolute pitch.
* @param x
* gravity force on x axis
* gravity force on x axis.
* @param y
* gravity force on y axis
* gravity force on y axis.
* @param z
* gravity force on z axis
* gravity force on z axis.
* @param xx
* raw acceleration on x axis
* raw acceleration on x axis.
* @param yy
* raw acceleration on y axis
* raw acceleration on y axis.
* @param zz
* raw acceleration on z axis
* raw acceleration on z axis.
*/
public void addMotionSensingValues(float orientationThreshold,
int accelerationThreshold, boolean smoothingState,
@@ -179,6 +179,80 @@ public class EventsGatherer {
ya, ar, ap, x, y, z, xx, yy, zz);
}
}
/**
* Set a NunchukEvent to the prepared .
*
* @param buttonsJustPressed
* buttons just pressed.
* @param buttonsJustReleased
* buttons just released.
* @param buttonsHeld
* buttons just pressed.
* @param orientationThreshold
* value of the minimum angle between two events with the
* accelerometer.
* @param accelerationThreshold
* value of the value variation between two events with the
* accelerometer.
* @param smoothingState
* true if smoothing flag is activated.
* @param alphaSmooth
* value of the alpha smoothing parameter.
* @param r
* roll.
* @param p
* pitch.
* @param ya
* yaw.
* @param ar
* absolute roll.
* @param ap
* absolute pitch.
* @param x
* gravity force on x axis.
* @param y
* gravity force on y axis.
* @param z
* gravity force on z axis.
* @param xx
* raw acceleration on x axis.
* @param yy
* raw acceleration on y axis.
* @param zz
* raw acceleration on z axis.
* @param angle
* angle the joystick is being held.
* @param magnitude
* magnitude of the joystick (range 0-1).
* @param max1
* maximum joystick value 1.
* @param max2
* maximum joystick value 2.
* @param min1
* minimum joystick value 1.
* @param min2
* minimum joystick value 2.
* @param center1
* center joystick value 1.
* @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, int angle, int 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);
}
}
/**
* Add the prepared WiimoteEvent to the gatherer.
@@ -194,25 +268,25 @@ public class EventsGatherer {
* Add a StatusEvent to the gatherer.
*
* @param id
* id of the wiimote
* id of the wiimote.
* @param connect
* true if the wiimote is connected
* true if the wiimote is connected.
* @param batt
* battery level
* battery level.
* @param led
* status of leds
* status of leds.
* @param speak
* speakers status
* speakers status.
* @param attach
* attachment status
* attachment status.
* @param rumbleState
* true if rumble is active
* true if rumble is active.
* @param continuousState
* true if continuous flag is activated
* true if continuous flag is activated.
* @param irState
* true if ir is active
* true if ir is active.
* @param motionSensingState
* true if accelerometer is active
* true if accelerometer is active.
*/
public void addStatusEvent(int id, boolean connect, float batt, short led,
boolean speak, int attach, boolean rumbleState,
@@ -227,7 +301,7 @@ public class EventsGatherer {
* Add a DisconnectionEvent to the gatherer.
*
* @param id
* id of the wiimote
* id of the wiimote.
*/
public void addDisconnectionEvent(int id) {
DisconnectionEvent evt = new DisconnectionEvent(id);
@@ -238,7 +312,7 @@ public class EventsGatherer {
* Add a NunchukInsertedEvent to the gatherer.
*
* @param id
* id of the wiimote
* id of the wiimote.
*/
public void addNunchukInsertedEvent(int id) {
NunchukInsertedEvent evt = new NunchukInsertedEvent(id);
@@ -249,7 +323,7 @@ public class EventsGatherer {
* Add a NunchukRemovedEvent to the gatherer.
*
* @param id
* id of the wiimote
* id of the wiimote.
*/
public void addNunchukRemovedEvent(int id) {
NunchukRemovedEvent evt = new NunchukRemovedEvent(id);
@@ -259,7 +333,7 @@ public class EventsGatherer {
/**
* Return an array containing the events.
*
* @return events received
* @return events received.
*/
public WiiUseApiEvent[] getEvents() {
return java.util.Arrays.copyOfRange(events, 0, index);

View File

@@ -16,6 +16,7 @@
*/
package wiiusej.wiiusejevents.utils;
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
@@ -52,6 +53,12 @@ public interface WiimoteListener extends java.util.EventListener {
*/
void onMotionSensingEvent(MotionSensingEvent e);
/**
* Method called when an expansion event occurs.
* @param e the expansion event occured.
*/
void onExpansionEvent(ExpansionEvent e);
/**
* Method called on a status event.
* A status event occurs when :

View File

@@ -19,6 +19,7 @@ package wiiusej.wiiusejevents.wiiuseapievents;
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
/**
@@ -33,7 +34,7 @@ public class WiimoteEvent extends WiiUseApiEvent {
IREvent infraredEvent = null;
MotionSensingEvent motionSensingEvent = null;
ExpansionEvent expansionEvent = null;
/**
* Construct the Wiimote setting up the id.
*
@@ -80,7 +81,7 @@ public class WiimoteEvent extends WiiUseApiEvent {
public boolean isThereMotionSensingEvent() {
return motionSensingEvent != null;
}
/**
* Tell if there is an expansion Event.
*
@@ -116,7 +117,7 @@ public class WiimoteEvent extends WiiUseApiEvent {
public MotionSensingEvent getMotionSensingEvent() {
return motionSensingEvent;
}
/**
* Get the expansion event.
*
@@ -191,36 +192,36 @@ public class WiimoteEvent extends WiiUseApiEvent {
*
* @param orientationThreshold
* value of the minimum angle between two events with the
* accelerometer
* accelerometer.
* @param accelerationThreshold
* value of the value variation between two events with the
* accelerometer
* accelerometer.
* @param smoothingState
* true if smoothing flag is activated
* true if smoothing flag is activated.
* @param alphaSmooth
* value of the alpha smoothing parameter
* value of the alpha smoothing parameter.
* @param r
* roll
* roll.
* @param p
* pitch
* pitch.
* @param ya
* yaw
* yaw.
* @param ar
* absolute roll
* absolute roll.
* @param ap
* absolute pitch
* absolute pitch.
* @param x
* gravity force on x axis
* gravity force on x axis.
* @param y
* gravity force on y axis
* gravity force on y axis.
* @param z
* gravity force on z axis
* gravity force on z axis.
* @param xx
* raw acceleration on x axis
* raw acceleration on x axis.
* @param yy
* raw acceleration on y axis
* raw acceleration on y axis.
* @param zz
* raw acceleration on z axis
* raw acceleration on z axis.
*/
public void setMotionSensingEvent(float orientationThreshold,
int accelerationThreshold, boolean smoothingState,
@@ -229,14 +230,82 @@ public class WiimoteEvent extends WiiUseApiEvent {
motionSensingEvent = new MotionSensingEvent(getWiimoteId(),
orientationThreshold, accelerationThreshold, smoothingState,
alphaSmooth, r, p, ya, ar, ap, x, y, z, xx, yy, zz);
}
public void setNunchukEvent(){
}
public void setClassicControllerEvent(){
//@TODO
/**
* Set a NunchukEvent for the expansion event.
*
* @param buttonsJustPressed
* buttons just pressed.
* @param buttonsJustReleased
* buttons just released.
* @param buttonsHeld
* buttons just pressed.
* @param orientationThreshold
* value of the minimum angle between two events with the
* accelerometer.
* @param accelerationThreshold
* value of the value variation between two events with the
* accelerometer.
* @param smoothingState
* true if smoothing flag is activated.
* @param alphaSmooth
* value of the alpha smoothing parameter.
* @param r
* roll.
* @param p
* pitch.
* @param ya
* yaw.
* @param ar
* absolute roll.
* @param ap
* absolute pitch.
* @param x
* gravity force on x axis.
* @param y
* gravity force on y axis.
* @param z
* gravity force on z axis.
* @param xx
* raw acceleration on x axis.
* @param yy
* raw acceleration on y axis.
* @param zz
* raw acceleration on z axis.
* @param angle
* angle the joystick is being held.
* @param magnitude
* magnitude of the joystick (range 0-1).
* @param max1
* maximum joystick value 1.
* @param max2
* maximum joystick value 2.
* @param min1
* minimum joystick value 1.
* @param min2
* minimum joystick value 2.
* @param center1
* center joystick value 1.
* @param center2
* center joystick value 2.
*/
public void setNunchukEvent(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, int angle, int magnitude, short max1,
short max2, short min1, short min2, short center1, short center2) {
expansionEvent = new NunchukEvent(getWiimoteId(), 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);
}
public void setClassicControllerEvent() {
// @TODO
}
@Override
@@ -261,7 +330,7 @@ public class WiimoteEvent extends WiiUseApiEvent {
out += "/******** Motion sensing ********/\n";
out += "--- Motion sensing : false \n";
}
if (expansionEvent != null) {
out += expansionEvent;
} else {