somme fixes on new version. Acceleration threshold is an int.

git-svn-id: http://wiiusej.googlecode.com/svn/trunk@54 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
guilhem.duche
2008-02-15 14:26:50 +00:00
parent f2829ca27f
commit dc13f8feee
5 changed files with 96 additions and 54 deletions

View File

@@ -103,14 +103,14 @@ public class WiiUseApi {
* @param id id of the wiimote concerned * @param id id of the wiimote concerned
* @param value minimum value detected by an event * @param value minimum value detected by an event
*/ */
native void setAccelThreshold(int id, float value); native void setAccelThreshold(int id, int value);
/** /**
* Set alpha smoothing parameter for the given id. * Set alpha smoothing parameter for the given id.
* @param id id of the wiimote concerned * @param id id of the wiimote concerned
* @param value alpha smoothing value * @param value alpha smoothing value
*/ */
native void setSmoothAlpha(int id, float value); native void setAlphaSmoothing(int id, float value);
/** /**
* Try to resync with the wiimote by starting a new handshake. * Try to resync with the wiimote by starting a new handshake.

View File

@@ -1,6 +1,5 @@
package wiiusej; package wiiusej;
import java.util.ArrayList;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@@ -10,6 +9,7 @@ import wiiusej.wiiuseapievents.EventsGatherer;
import wiiusej.wiiuseapievents.WiiUseApiEvent; import wiiusej.wiiuseapievents.WiiUseApiEvent;
import wiiusej.wiiuseapievents.WiiUseApiListener; import wiiusej.wiiuseapievents.WiiUseApiListener;
import wiiusej.wiiuseapirequest.FloatValueRequest; import wiiusej.wiiuseapirequest.FloatValueRequest;
import wiiusej.wiiuseapirequest.IntValueRequest;
import wiiusej.wiiuseapirequest.LedsRequest; import wiiusej.wiiuseapirequest.LedsRequest;
import wiiusej.wiiuseapirequest.WiiUseApiRequest; import wiiusej.wiiuseapirequest.WiiUseApiRequest;
@@ -273,8 +273,8 @@ public class WiiUseApiManager extends Thread {
* @param th * @param th
* threshold * threshold
*/ */
public void setAccelerationThreshold(int id, float th) { public void setAccelerationThreshold(int id, int th) {
requests.add(new FloatValueRequest(id, requests.add(new IntValueRequest(id,
WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST, th)); WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST, th));
} }
@@ -291,6 +291,16 @@ public class WiiUseApiManager extends Thread {
WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST, th)); WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST, th));
} }
/**
* Try to resync with the wiimote by starting a new handshake.
* @TODO not used yet !!
* @param id
* id of the wiimote
*/
public void reSync(int id) {
requests.add(new WiiUseApiRequest(id, WiiUseApiRequest.WIIUSE_RESYNC));
}
/** /**
* Get Status for the wiimote for the given id. * Get Status for the wiimote for the given id.
* *
@@ -322,7 +332,8 @@ public class WiiUseApiManager extends Thread {
connected--; connected--;
if (connected == 0) {// stop this thread if there is if (connected == 0) {// stop this thread if there is
// no more wiimotes connected. // no more wiimotes connected.
System.out.println("No more wiimotes connected !!!"); System.out
.println("No more wiimotes connected !!!");
shutdown(); shutdown();
} }
} else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_STATUS_REQUEST) { } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_STATUS_REQUEST) {
@@ -369,12 +380,15 @@ public class WiiUseApiManager extends Thread {
((FloatValueRequest) req).getFloatValue()); ((FloatValueRequest) req).getFloatValue());
} else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST) { } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST) {
/* set acceleration threshold request */ /* set acceleration threshold request */
wiiuse.setOrientThreshold(req.getId(), wiiuse.setAccelThreshold(req.getId(),
((FloatValueRequest) req).getFloatValue()); ((IntValueRequest) req).getIntValue());
} else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST) { } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST) {
/* set alpha smoothing request */ /* set alpha smoothing request */
wiiuse.setOrientThreshold(req.getId(), wiiuse.setAlphaSmoothing(req.getId(),
((FloatValueRequest) req).getFloatValue()); ((FloatValueRequest) req).getFloatValue());
} else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_RESYNC) {
/* set resync request */
wiiuse.reSync(req.getId());
} else { } else {
System.out.println("Bad request to Wiiuse API !!!!!"); System.out.println("Bad request to Wiiuse API !!!!!");
} }

View File

@@ -141,6 +141,24 @@ public class Wiimote implements WiiUseApiListener {
manager.setOrientationThreshold(id,th); manager.setOrientationThreshold(id,th);
} }
/**
* Set the acceleration threshold .
* @param th
* threshold
*/
public void setAccelerationThreshold(int th) {
manager.setAccelerationThreshold(id,th);
}
/**
* Set the alpha smoothing value.
* @param th
* threshold
*/
public void setAlphaSmoothingValue(int th) {
manager.setAlphaSmoothing(id,th);
}
/** /**
* Get Status of the wiimote. * Get Status of the wiimote.
*/ */

View File

@@ -1,8 +1,7 @@
package wiiusej.wiiuseapirequest; package wiiusej.wiiuseapirequest;
/** /**
* Represents a request to set orientation Threshold in Wiiuse API. * Represents a request with a float value to pass to wiiuse API.
* Orientation Threshold is the minimum angle (in degrees) between two events.
* @author gduche * @author gduche
* *
*/ */
@@ -36,6 +35,7 @@ public class FloatValueRequest extends WiiUseApiRequest {
} }
/** /**
* Get the float value.
* @return the float value * @return the float value
*/ */
public float getFloatValue() { public float getFloatValue() {
@@ -43,7 +43,8 @@ public class FloatValueRequest extends WiiUseApiRequest {
} }
/** /**
* @param val the thresholhd to set * Set the float value.
* @param val the value to set
*/ */
public void setFloatValue(float val) { public void setFloatValue(float val) {
this.floatValue = val; this.floatValue = val;

View File

@@ -2,6 +2,7 @@ package wiiusej.wiiuseapirequest;
/** /**
* Represents a request we could do to the WiiUse API. * Represents a request we could do to the WiiUse API.
*
* @author gduche * @author gduche
* *
*/ */
@@ -23,13 +24,16 @@ public class WiiUseApiRequest {
public static int WIIUSE_ORIENT_THRESHOLHD_REQUEST = 9; public static int WIIUSE_ORIENT_THRESHOLHD_REQUEST = 9;
public static int WIIUSE_ACCEL_THRESHOLHD_REQUEST = 10; public static int WIIUSE_ACCEL_THRESHOLHD_REQUEST = 10;
public static int WIIUSE_ALPHA_SMOOTHING_REQUEST = 11; public static int WIIUSE_ALPHA_SMOOTHING_REQUEST = 11;
public static int WIIUSE_RESYNC = 12;
private int wiimoteId = 0; private int wiimoteId = 0;
private int requestType = 0; private int requestType = 0;
/** /**
* Constructor setting the id of the wiimote concerned. * Constructor setting the id of the wiimote concerned.
* @param id the id of the wiimote concerned. *
* @param id
* the id of the wiimote concerned.
*/ */
public WiiUseApiRequest(int id) { public WiiUseApiRequest(int id) {
wiimoteId = id; wiimoteId = id;
@@ -37,7 +41,9 @@ public class WiiUseApiRequest {
/** /**
* Constructor setting the id of the wiimote concerned. * Constructor setting the id of the wiimote concerned.
* @param id the id of the wiimote concerned. *
* @param id
* the id of the wiimote concerned.
* *
*/ */
public WiiUseApiRequest(int id, int type) { public WiiUseApiRequest(int id, int type) {
@@ -47,6 +53,7 @@ public class WiiUseApiRequest {
/** /**
* Get id of the wiimote concerned by this request. * Get id of the wiimote concerned by this request.
*
* @return id of the wiimote concerned * @return id of the wiimote concerned
*/ */
public int getId() { public int getId() {
@@ -55,7 +62,9 @@ public class WiiUseApiRequest {
/** /**
* Set id of the wiimote concerned by this request. * Set id of the wiimote concerned by this request.
* @param id id fh the wiimote concernet *
* @param id
* id fh the wiimote concernet
*/ */
public void setId(int id) { public void setId(int id) {
wiimoteId = id; wiimoteId = id;
@@ -63,6 +72,7 @@ public class WiiUseApiRequest {
/** /**
* Get the request type. * Get the request type.
*
* @return the requestType * @return the requestType
*/ */
public int getRequestType() { public int getRequestType() {
@@ -71,13 +81,12 @@ public class WiiUseApiRequest {
/** /**
* Set the request type. * Set the request type.
* @param requestType the requestType to set *
* @param requestType
* the requestType to set
*/ */
public void setRequestType(int requestType) { public void setRequestType(int requestType) {
this.requestType = requestType; this.requestType = requestType;
} }
} }