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:
@@ -103,14 +103,14 @@ public class WiiUseApi {
|
||||
* @param id id of the wiimote concerned
|
||||
* @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.
|
||||
* @param id id of the wiimote concerned
|
||||
* @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.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package wiiusej;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@@ -10,6 +9,7 @@ import wiiusej.wiiuseapievents.EventsGatherer;
|
||||
import wiiusej.wiiuseapievents.WiiUseApiEvent;
|
||||
import wiiusej.wiiuseapievents.WiiUseApiListener;
|
||||
import wiiusej.wiiuseapirequest.FloatValueRequest;
|
||||
import wiiusej.wiiuseapirequest.IntValueRequest;
|
||||
import wiiusej.wiiuseapirequest.LedsRequest;
|
||||
import wiiusej.wiiuseapirequest.WiiUseApiRequest;
|
||||
|
||||
@@ -273,8 +273,8 @@ public class WiiUseApiManager extends Thread {
|
||||
* @param th
|
||||
* threshold
|
||||
*/
|
||||
public void setAccelerationThreshold(int id, float th) {
|
||||
requests.add(new FloatValueRequest(id,
|
||||
public void setAccelerationThreshold(int id, int th) {
|
||||
requests.add(new IntValueRequest(id,
|
||||
WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST, th));
|
||||
}
|
||||
|
||||
@@ -291,6 +291,16 @@ public class WiiUseApiManager extends Thread {
|
||||
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.
|
||||
*
|
||||
@@ -322,7 +332,8 @@ public class WiiUseApiManager extends Thread {
|
||||
connected--;
|
||||
if (connected == 0) {// stop this thread if there is
|
||||
// no more wiimotes connected.
|
||||
System.out.println("No more wiimotes connected !!!");
|
||||
System.out
|
||||
.println("No more wiimotes connected !!!");
|
||||
shutdown();
|
||||
}
|
||||
} else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_STATUS_REQUEST) {
|
||||
@@ -369,12 +380,15 @@ public class WiiUseApiManager extends Thread {
|
||||
((FloatValueRequest) req).getFloatValue());
|
||||
} else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST) {
|
||||
/* set acceleration threshold request */
|
||||
wiiuse.setOrientThreshold(req.getId(),
|
||||
((FloatValueRequest) req).getFloatValue());
|
||||
wiiuse.setAccelThreshold(req.getId(),
|
||||
((IntValueRequest) req).getIntValue());
|
||||
} else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST) {
|
||||
/* set alpha smoothing request */
|
||||
wiiuse.setOrientThreshold(req.getId(),
|
||||
wiiuse.setAlphaSmoothing(req.getId(),
|
||||
((FloatValueRequest) req).getFloatValue());
|
||||
} else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_RESYNC) {
|
||||
/* set resync request */
|
||||
wiiuse.reSync(req.getId());
|
||||
} else {
|
||||
System.out.println("Bad request to Wiiuse API !!!!!");
|
||||
}
|
||||
|
||||
@@ -141,6 +141,24 @@ public class Wiimote implements WiiUseApiListener {
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package wiiusej.wiiuseapirequest;
|
||||
|
||||
/**
|
||||
* Represents a request to set orientation Threshold in Wiiuse API.
|
||||
* Orientation Threshold is the minimum angle (in degrees) between two events.
|
||||
* Represents a request with a float value to pass to wiiuse API.
|
||||
* @author gduche
|
||||
*
|
||||
*/
|
||||
@@ -36,6 +35,7 @@ public class FloatValueRequest extends WiiUseApiRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the float value.
|
||||
* @return the float value
|
||||
*/
|
||||
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) {
|
||||
this.floatValue = val;
|
||||
|
||||
@@ -2,6 +2,7 @@ package wiiusej.wiiuseapirequest;
|
||||
|
||||
/**
|
||||
* Represents a request we could do to the WiiUse API.
|
||||
*
|
||||
* @author gduche
|
||||
*
|
||||
*/
|
||||
@@ -23,13 +24,16 @@ public class WiiUseApiRequest {
|
||||
public static int WIIUSE_ORIENT_THRESHOLHD_REQUEST = 9;
|
||||
public static int WIIUSE_ACCEL_THRESHOLHD_REQUEST = 10;
|
||||
public static int WIIUSE_ALPHA_SMOOTHING_REQUEST = 11;
|
||||
public static int WIIUSE_RESYNC = 12;
|
||||
|
||||
private int wiimoteId = 0;
|
||||
private int requestType = 0;
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
wiimoteId = id;
|
||||
@@ -37,7 +41,9 @@ public class WiiUseApiRequest {
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
@@ -47,6 +53,7 @@ public class WiiUseApiRequest {
|
||||
|
||||
/**
|
||||
* Get id of the wiimote concerned by this request.
|
||||
*
|
||||
* @return id of the wiimote concerned
|
||||
*/
|
||||
public int getId() {
|
||||
@@ -55,7 +62,9 @@ public class WiiUseApiRequest {
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
wiimoteId = id;
|
||||
@@ -63,6 +72,7 @@ public class WiiUseApiRequest {
|
||||
|
||||
/**
|
||||
* Get the request type.
|
||||
*
|
||||
* @return the requestType
|
||||
*/
|
||||
public int getRequestType() {
|
||||
@@ -71,13 +81,12 @@ public class WiiUseApiRequest {
|
||||
|
||||
/**
|
||||
* Set the request type.
|
||||
* @param requestType the requestType to set
|
||||
*
|
||||
* @param requestType
|
||||
* the requestType to set
|
||||
*/
|
||||
public void setRequestType(int requestType) {
|
||||
this.requestType = requestType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user