moved some stuff from status events to motion sensing events
git-svn-id: http://wiiusej.googlecode.com/svn/trunk@78 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
@@ -92,11 +92,11 @@ public class EventsGatherer {
|
||||
* @param screenAsPectRatio
|
||||
* IR sensor bar position.
|
||||
*/
|
||||
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) {
|
||||
genericEvent.prepareIRevent(x, y, z, ax, ay, xVRes,
|
||||
yVRes, xOffset, yOffset, sensorBarPostion, screenAsPectRatio);
|
||||
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) {
|
||||
genericEvent.prepareIRevent(x, y, z, ax, ay, xVRes, yVRes, xOffset,
|
||||
yOffset, sensorBarPostion, screenAsPectRatio);
|
||||
|
||||
}
|
||||
|
||||
@@ -124,6 +124,16 @@ public class EventsGatherer {
|
||||
/**
|
||||
* Set orientation and gravity force of the prepared event.
|
||||
*
|
||||
* @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
|
||||
@@ -143,10 +153,14 @@ public class EventsGatherer {
|
||||
* @param zz
|
||||
* raw acceleration on z axis
|
||||
*/
|
||||
public void addMotionSensingValues(float r, float p, float ya, float x,
|
||||
float y, float z, short xx, short yy, short zz) {
|
||||
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) {
|
||||
if (genericEvent != null) {
|
||||
genericEvent.setMotionSensingEvent(r, p, ya, x, y, z, xx, yy, zz);
|
||||
genericEvent.setMotionSensingEvent(orientationThreshold,
|
||||
accelerationThreshold, smoothingState, alphaSmooth, r, p,
|
||||
ya, x, y, z, xx, yy, zz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,18 +191,8 @@ public class EventsGatherer {
|
||||
* attachment status
|
||||
* @param rumbleState
|
||||
* true if rumble is active
|
||||
* @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 alphaSmooth
|
||||
* value of the alpha smoothing parameter
|
||||
* @param continuousState
|
||||
* true if continuous flag is activated
|
||||
* @param smoothingState
|
||||
* true if smoothing flag is activated
|
||||
* @param irState
|
||||
* true if ir is active
|
||||
* @param motionSensingState
|
||||
@@ -196,13 +200,10 @@ public class EventsGatherer {
|
||||
*/
|
||||
public void addStatusEvent(int id, boolean connect, float batt, short led,
|
||||
boolean speak, int attach, boolean rumbleState,
|
||||
float orientationThreshold, int accelerationThreshold,
|
||||
float alphaSmooth, boolean continuousState, boolean smoothingState,
|
||||
boolean irState, boolean motionSensingState) {
|
||||
boolean continuousState, boolean irState, boolean motionSensingState) {
|
||||
StatusEvent evt = new StatusEvent(id, connect, batt, led, speak,
|
||||
attach, rumbleState, orientationThreshold,
|
||||
accelerationThreshold, alphaSmooth, continuousState,
|
||||
smoothingState, irState, motionSensingState);
|
||||
attach, rumbleState, continuousState, irState,
|
||||
motionSensingState);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public class GenericEvent extends WiiUseApiEvent {
|
||||
public MotionSensingEvent getMotionSensingEvent() {
|
||||
return motionSensingEvent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare an IR event to populate.
|
||||
*
|
||||
@@ -160,6 +160,16 @@ public class GenericEvent extends WiiUseApiEvent {
|
||||
/**
|
||||
* Set the Motion Sensing Event.
|
||||
*
|
||||
* @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
|
||||
@@ -179,10 +189,13 @@ public class GenericEvent extends WiiUseApiEvent {
|
||||
* @param zz
|
||||
* raw acceleration on z axis
|
||||
*/
|
||||
public void setMotionSensingEvent(float r, float p, float ya, float x,
|
||||
float y, float z, short xx, short yy, short zz) {
|
||||
motionSensingEvent = new MotionSensingEvent(getWiimoteId(), r, p, ya,
|
||||
x, y, z, xx, yy, zz);
|
||||
public void setMotionSensingEvent(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) {
|
||||
motionSensingEvent = new MotionSensingEvent(getWiimoteId(),
|
||||
orientationThreshold, accelerationThreshold, smoothingState,
|
||||
alphaSmooth, r, p, ya, x, y, z, xx, yy, zz);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -279,6 +279,7 @@ public class IREvent extends WiimoteEvent {
|
||||
out += IRPoints[i].toString();
|
||||
}
|
||||
}
|
||||
out += "\n";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,18 +25,33 @@ import wiiusej.values.RawAcceleration;
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class MotionSensingEvent extends WiimoteEvent{
|
||||
public class MotionSensingEvent extends WiimoteEvent {
|
||||
|
||||
/* Motion Sensing */
|
||||
private Orientation orientation;
|
||||
private GForce gforce;
|
||||
private RawAcceleration acceleration;
|
||||
|
||||
private float orientationThreshold = 0;
|
||||
private int accelerationThreshold = 0;
|
||||
private float alphaSmoothing = 0;
|
||||
private boolean isSmoothingActive = false;
|
||||
|
||||
/**
|
||||
* Constructor for a Motion Sensing Event.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote concerned.
|
||||
* @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
|
||||
@@ -56,9 +71,15 @@ public class MotionSensingEvent extends WiimoteEvent{
|
||||
* @param zz
|
||||
* raw acceleration on z axis
|
||||
*/
|
||||
public MotionSensingEvent(int id, float r, float p, float ya, float x, float y,
|
||||
public MotionSensingEvent(int id, 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) {
|
||||
super(id);
|
||||
this.orientationThreshold = orientationThreshold;
|
||||
this.accelerationThreshold = accelerationThreshold;
|
||||
this.isSmoothingActive = smoothingState;
|
||||
this.alphaSmoothing = alphaSmooth;
|
||||
setOrientationAndGforce(r, p, ya, x, y, z, xx, yy, zz);
|
||||
}
|
||||
|
||||
@@ -77,7 +98,7 @@ public class MotionSensingEvent extends WiimoteEvent{
|
||||
* gravity force on y axis
|
||||
* @param z
|
||||
* gravity force on z axis
|
||||
* @param xx
|
||||
* @param xx
|
||||
* raw acceleration on x axis
|
||||
* @param yy
|
||||
* raw acceleration on y axis
|
||||
@@ -106,7 +127,7 @@ public class MotionSensingEvent extends WiimoteEvent{
|
||||
public GForce getGforce() {
|
||||
return gforce;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the raw acceleration.
|
||||
*
|
||||
@@ -116,12 +137,55 @@ public class MotionSensingEvent extends WiimoteEvent{
|
||||
return acceleration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get orientation threshold.
|
||||
*
|
||||
* @return the orientationThreshold
|
||||
*/
|
||||
public float getOrientationThreshold() {
|
||||
return orientationThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get acceleration threshold.
|
||||
*
|
||||
* @return the accelerationThreshold
|
||||
*/
|
||||
public int getAccelerationThreshold() {
|
||||
return accelerationThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alpha smoothing.
|
||||
*
|
||||
* @return the alphaSmoothing
|
||||
*/
|
||||
public float getAlphaSmoothing() {
|
||||
return alphaSmoothing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the option SMOOTHING is activated.
|
||||
*
|
||||
* @return the isSmoothingActive
|
||||
*/
|
||||
public boolean isSmoothingActive() {
|
||||
return isSmoothingActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Motion sensing */
|
||||
out += "/******** Motion sensing ********/\n";
|
||||
out += "--- Motion sensing : true \n";
|
||||
out += "--- Orientation threshold value ? : " + orientationThreshold
|
||||
+ "\n";
|
||||
out += "--- Acceleration threshold value ? : " + accelerationThreshold
|
||||
+ "\n";
|
||||
out += "--- Alpha smoothing threshold value ? : " + alphaSmoothing
|
||||
+ "\n";
|
||||
out += "--- Smoothing ? : " + isSmoothingActive + "\n";
|
||||
out += "--- " + orientation + "\n";
|
||||
out += "--- " + gforce + "\n";
|
||||
out += "--- " + acceleration + "\n";
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
package wiiusej.wiiuseapievents;
|
||||
|
||||
/**
|
||||
* Class used to represent a status event.
|
||||
* This class is used to know what are the settings of the wiimote.
|
||||
* Class used to represent a status event. This class is used to know what are
|
||||
* the settings of the wiimote.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class StatusEvent extends WiiUseApiEvent {
|
||||
@@ -29,7 +30,7 @@ public class StatusEvent extends WiiUseApiEvent {
|
||||
private static short WIIMOTE_LED_4 = 8;
|
||||
|
||||
/* ATTACHMENT CONSTANTS */
|
||||
|
||||
|
||||
private static short EXP_NONE = 0;
|
||||
private static short EXP_NUNCHUK = 1;
|
||||
private static short EXP_CLASSIC = 2;
|
||||
@@ -48,16 +49,8 @@ public class StatusEvent extends WiiUseApiEvent {
|
||||
|
||||
private boolean isRumbleActive = false;
|
||||
|
||||
private float orientationThreshold = 0;
|
||||
|
||||
private int accelerationThreshold = 0;
|
||||
|
||||
private float alphaSmoothing = 0;
|
||||
|
||||
private boolean isContinuousActive = false;
|
||||
|
||||
private boolean isSmoothingActive = false;
|
||||
|
||||
private boolean isIrActive = false;
|
||||
|
||||
private boolean isMotionSensingActive = false;
|
||||
@@ -89,18 +82,8 @@ public class StatusEvent extends WiiUseApiEvent {
|
||||
* attachment status
|
||||
* @param rumbleState
|
||||
* true if rumble is active
|
||||
* @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 alphaSmooth
|
||||
* value of the alpha smoothing parameter
|
||||
* @param continuousState
|
||||
* true if continuous flag is activated
|
||||
* @param smoothingState
|
||||
* true if smoothing flag is activated
|
||||
* @param irState
|
||||
* true if ir is active
|
||||
* @param motionSensingState
|
||||
@@ -108,9 +91,7 @@ public class StatusEvent extends WiiUseApiEvent {
|
||||
*/
|
||||
public StatusEvent(int id, boolean connect, float batt, short led,
|
||||
boolean speak, int attach, boolean rumbleState,
|
||||
float orientationThreshold, int accelerationThreshold,
|
||||
float alphaSmooth, boolean continuousState, boolean smoothingState,
|
||||
boolean irState, boolean motionSensingState) {
|
||||
boolean continuousState, boolean irState, boolean motionSensingState) {
|
||||
super(id, WiiUseApiEvent.STATUS_EVENT);
|
||||
connected = connect;
|
||||
this.batteryLevel = batt;
|
||||
@@ -118,11 +99,7 @@ public class StatusEvent extends WiiUseApiEvent {
|
||||
this.isSpeakerEnabled = speak;
|
||||
this.attachment = attach;
|
||||
isRumbleActive = rumbleState;
|
||||
this.orientationThreshold = orientationThreshold;
|
||||
this.accelerationThreshold = accelerationThreshold;
|
||||
alphaSmoothing = alphaSmooth;
|
||||
isContinuousActive = continuousState;
|
||||
isSmoothingActive = smoothingState;
|
||||
isIrActive = irState;
|
||||
isMotionSensingActive = motionSensingState;
|
||||
}
|
||||
@@ -153,51 +130,55 @@ public class StatusEvent extends WiiUseApiEvent {
|
||||
public short getLeds() {
|
||||
return leds;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get led1 status.
|
||||
*
|
||||
* @return true if the led is set.
|
||||
*/
|
||||
public boolean isLed1Set(){
|
||||
if ((leds & WIIMOTE_LED_1) > 0){
|
||||
public boolean isLed1Set() {
|
||||
if ((leds & WIIMOTE_LED_1) > 0) {
|
||||
return true;
|
||||
}else{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get led2 status.
|
||||
*
|
||||
* @return true if the led is set.
|
||||
*/
|
||||
public boolean isLed2Set(){
|
||||
if ((leds & WIIMOTE_LED_2) > 0){
|
||||
public boolean isLed2Set() {
|
||||
if ((leds & WIIMOTE_LED_2) > 0) {
|
||||
return true;
|
||||
}else{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get led3 status.
|
||||
*
|
||||
* @return true if the led is set.
|
||||
*/
|
||||
public boolean isLed3Set(){
|
||||
if ((leds & WIIMOTE_LED_3) > 0){
|
||||
public boolean isLed3Set() {
|
||||
if ((leds & WIIMOTE_LED_3) > 0) {
|
||||
return true;
|
||||
}else{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get led4 status.
|
||||
*
|
||||
* @return true if the led is set.
|
||||
*/
|
||||
public boolean isLed4Set(){
|
||||
if ((leds & WIIMOTE_LED_4) > 0){
|
||||
public boolean isLed4Set() {
|
||||
if ((leds & WIIMOTE_LED_4) > 0) {
|
||||
return true;
|
||||
}else{
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -229,33 +210,6 @@ public class StatusEvent extends WiiUseApiEvent {
|
||||
return isRumbleActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get orientation threshold.
|
||||
*
|
||||
* @return the orientationThreshold
|
||||
*/
|
||||
public float getOrientationThreshold() {
|
||||
return orientationThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get acceleration threshold.
|
||||
*
|
||||
* @return the accelerationThreshold
|
||||
*/
|
||||
public int getAccelerationThreshold() {
|
||||
return accelerationThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get alpha smoothing.
|
||||
*
|
||||
* @return the alphaSmoothing
|
||||
*/
|
||||
public float getAlphaSmoothing() {
|
||||
return alphaSmoothing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the CONTINUOUS option is activated.
|
||||
*
|
||||
@@ -265,15 +219,6 @@ public class StatusEvent extends WiiUseApiEvent {
|
||||
return isContinuousActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the option SMOOTHING is activated.
|
||||
*
|
||||
* @return the isSmoothingActive
|
||||
*/
|
||||
public boolean isSmoothingActive() {
|
||||
return isSmoothingActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the IR Tracking is active.
|
||||
*
|
||||
@@ -304,14 +249,7 @@ public class StatusEvent extends WiiUseApiEvent {
|
||||
out += "--- Speaker enabled : " + isSpeakerEnabled + "\n";
|
||||
out += "--- Attachment ? : " + attachment + "\n";
|
||||
out += "--- Rumble ? : " + isRumbleActive + "\n";
|
||||
out += "--- Orientation threshold value ? : " + orientationThreshold
|
||||
+ "\n";
|
||||
out += "--- Acceleration threshold value ? : " + accelerationThreshold
|
||||
+ "\n";
|
||||
out += "--- Alpha smoothing threshold value ? : " + alphaSmoothing
|
||||
+ "\n";
|
||||
out += "--- Continuous ? : " + isContinuousActive + "\n";
|
||||
out += "--- Smoothing ? : " + isSmoothingActive + "\n";
|
||||
out += "--- IR active ? : " + isIrActive + "\n";
|
||||
out += "--- Motion sensing active ? : " + isMotionSensingActive + "\n";
|
||||
return out;
|
||||
|
||||
Reference in New Issue
Block a user