added infos on IR event
motion sensing event (raw acceleration) and support for more wiiuse functions git-svn-id: http://wiiusej.googlecode.com/svn/trunk@75 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
@@ -119,7 +119,10 @@ public class ButtonsEvent extends WiimoteEvent{
|
||||
private boolean isButtonHeld(short buttonBitsDefinition) {
|
||||
return buttonTest(buttonBitsDefinition, buttonsHeld);
|
||||
}
|
||||
|
||||
|
||||
private boolean isButtonPressed(short buttonBitsDefinition) {
|
||||
return isButtonHeld(buttonBitsDefinition)||isButtonJustPressed(buttonBitsDefinition);
|
||||
}
|
||||
/* Button ONE */
|
||||
|
||||
public boolean isButtonOneJustPressed() {
|
||||
@@ -133,6 +136,10 @@ public class ButtonsEvent extends WiimoteEvent{
|
||||
public boolean isButtonOneHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_ONE);
|
||||
}
|
||||
|
||||
public boolean isButtonOnePressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_ONE);
|
||||
}
|
||||
|
||||
/* Button TWO */
|
||||
|
||||
@@ -147,6 +154,10 @@ public class ButtonsEvent extends WiimoteEvent{
|
||||
public boolean isButtonTwoHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_TWO);
|
||||
}
|
||||
|
||||
public boolean isButtonTwoPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_TWO);
|
||||
}
|
||||
|
||||
/* Button A */
|
||||
|
||||
@@ -161,6 +172,10 @@ public class ButtonsEvent extends WiimoteEvent{
|
||||
public boolean isButtonAHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_A);
|
||||
}
|
||||
|
||||
public boolean isButtonAPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_A);
|
||||
}
|
||||
|
||||
/* Button B */
|
||||
|
||||
@@ -175,6 +190,10 @@ public class ButtonsEvent extends WiimoteEvent{
|
||||
public boolean isButtonBHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_B);
|
||||
}
|
||||
|
||||
public boolean isButtonBPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_B);
|
||||
}
|
||||
|
||||
/* Button LEFT */
|
||||
|
||||
@@ -189,6 +208,10 @@ public class ButtonsEvent extends WiimoteEvent{
|
||||
public boolean isButtonLeftHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
public boolean isButtonLeftPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
/* Button RIGHT */
|
||||
|
||||
@@ -203,6 +226,10 @@ public class ButtonsEvent extends WiimoteEvent{
|
||||
public boolean isButtonRightHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_RIGHT);
|
||||
}
|
||||
|
||||
public boolean isButtonRightPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_RIGHT);
|
||||
}
|
||||
|
||||
/* Button UP */
|
||||
|
||||
@@ -217,6 +244,10 @@ public class ButtonsEvent extends WiimoteEvent{
|
||||
public boolean isButtonUpHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_UP);
|
||||
}
|
||||
|
||||
public boolean isButtonUpPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_UP);
|
||||
}
|
||||
|
||||
/* Button DOWN */
|
||||
|
||||
@@ -231,6 +262,10 @@ public class ButtonsEvent extends WiimoteEvent{
|
||||
public boolean isButtonDownHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_DOWN);
|
||||
}
|
||||
|
||||
public boolean isButtonDownPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_DOWN);
|
||||
}
|
||||
|
||||
/* Button - */
|
||||
|
||||
@@ -245,6 +280,10 @@ public class ButtonsEvent extends WiimoteEvent{
|
||||
public boolean isButtonMinusHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
public boolean isButtonMinusPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
/* Button + */
|
||||
|
||||
@@ -259,6 +298,10 @@ public class ButtonsEvent extends WiimoteEvent{
|
||||
public boolean isButtonPlusHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
public boolean isButtonPlusPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
/* Button HOME */
|
||||
|
||||
@@ -274,6 +317,10 @@ public class ButtonsEvent extends WiimoteEvent{
|
||||
return isButtonHeld(WIIMOTE_BUTTON_HOME);
|
||||
}
|
||||
|
||||
public boolean isButtonHomePressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_HOME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package wiiusej.wiiuseapievents;
|
||||
|
||||
|
||||
/**
|
||||
* This class is used to gather events during a call to the Wiiuse API.
|
||||
*
|
||||
@@ -44,7 +43,7 @@ public class EventsGatherer {
|
||||
* @param e
|
||||
* the event to add.
|
||||
*/
|
||||
private void addEvent(WiiUseApiEvent e) {
|
||||
private void addEvent(WiiUseApiEvent e) {
|
||||
events[index] = e;
|
||||
index++;
|
||||
}
|
||||
@@ -67,6 +66,39 @@ public class EventsGatherer {
|
||||
buttonsJustReleased, buttonsHeld);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare an IR event to populate.
|
||||
*
|
||||
* @param x
|
||||
* calculated X coordinate.
|
||||
* @param y
|
||||
* calculated Y coordinate.
|
||||
* @param z
|
||||
* calculated distance.
|
||||
* @param ax
|
||||
* absolute X coordinate.
|
||||
* @param ay
|
||||
* absolute Y coordinate
|
||||
* @param xVRes
|
||||
* IR virtual screen x resolution.
|
||||
* @param yVRes
|
||||
* IR virtual screen y resolution.
|
||||
* @param xOffset
|
||||
* IR X correction offset.
|
||||
* @param yOffset
|
||||
* IR Y correction offset.
|
||||
* @param sensorBarPostion
|
||||
* aspect ratio of the screen.
|
||||
* @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);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an IR point to the WiiMoteEvent prepared
|
||||
@@ -75,13 +107,20 @@ public class EventsGatherer {
|
||||
* x coordinates
|
||||
* @param y
|
||||
* y coordinates
|
||||
* @param rxx
|
||||
* raw X coordinate (0-1023).
|
||||
* @param ryy
|
||||
* raw Y coordinate (0-1023).
|
||||
* @param si
|
||||
* size of the IR dot (0-15).
|
||||
*/
|
||||
public void addIRPointToPreparedWiiMoteEvent(int x, int y) {
|
||||
if (genericEvent != null) {
|
||||
genericEvent.addIRpoint(x, y);
|
||||
public void addIRPointToPreparedWiiMoteEvent(int x, int y, short rx,
|
||||
short ry, short size) {
|
||||
if (genericEvent != null) {
|
||||
genericEvent.addIRpoint(x, y, rx, ry, size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set orientation and gravity force of the prepared event.
|
||||
*
|
||||
@@ -97,11 +136,17 @@ public class EventsGatherer {
|
||||
* 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
|
||||
*/
|
||||
public void addMotionSensingValues(float r, float p, float ya, float x,
|
||||
float y, float z) {
|
||||
float y, float z, short xx, short yy, short zz) {
|
||||
if (genericEvent != null) {
|
||||
genericEvent.setMotionSensingEvent(r, p, ya, x, y, z);
|
||||
genericEvent.setMotionSensingEvent(r, p, ya, x, y, z, xx, yy, zz);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package wiiusej.wiiuseapievents;
|
||||
|
||||
|
||||
/**
|
||||
* Class that is a bean to be filled by the wiiuse API.
|
||||
*
|
||||
@@ -77,6 +76,7 @@ public class GenericEvent extends WiiUseApiEvent {
|
||||
|
||||
/**
|
||||
* Get buttons event.
|
||||
*
|
||||
* @return the buttons event.
|
||||
*/
|
||||
public ButtonsEvent getButtonsEvent() {
|
||||
@@ -85,6 +85,7 @@ public class GenericEvent extends WiiUseApiEvent {
|
||||
|
||||
/**
|
||||
* Get IR event.
|
||||
*
|
||||
* @return the IR event if there is one or null.
|
||||
*/
|
||||
public IREvent getIREvent() {
|
||||
@@ -93,6 +94,7 @@ public class GenericEvent extends WiiUseApiEvent {
|
||||
|
||||
/**
|
||||
* Get motion sensing event.
|
||||
*
|
||||
* @return the motion sensing event if there is one or null.
|
||||
*/
|
||||
public MotionSensingEvent getMotionSensingEvent() {
|
||||
@@ -100,19 +102,61 @@ public class GenericEvent extends WiiUseApiEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an IR point to the generic event.
|
||||
* Create an IR Event if it's not created yet.
|
||||
* @param x x coordinates.
|
||||
* @param y y coordinates
|
||||
* Prepare an IR event to populate.
|
||||
*
|
||||
* @param x
|
||||
* calculated X coordinate.
|
||||
* @param y
|
||||
* calculated Y coordinate.
|
||||
* @param z
|
||||
* calculated distance.
|
||||
* @param ax
|
||||
* absolute X coordinate.
|
||||
* @param ay
|
||||
* absolute Y coordinate
|
||||
* @param xVRes
|
||||
* IR virtual screen x resolution.
|
||||
* @param yVRes
|
||||
* IR virtual screen y resolution.
|
||||
* @param xOffset
|
||||
* IR X correction offset.
|
||||
* @param yOffset
|
||||
* IR Y correction offset.
|
||||
* @param sensorBarPostion
|
||||
* aspect ratio of the screen.
|
||||
* @param screenAsPectRatio
|
||||
* IR sensor bar position.
|
||||
*/
|
||||
public void addIRpoint(int x,int y){
|
||||
//@TODO add points size
|
||||
if (infraredEvent == null){
|
||||
infraredEvent = new IREvent(getWiimoteId());
|
||||
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) {
|
||||
if (infraredEvent == null) {
|
||||
infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes,
|
||||
yVRes, xOffset, yOffset, sensorBarPostion,
|
||||
screenAsPectRatio);
|
||||
}
|
||||
infraredEvent.addIRpoint(x, y);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add an IR point to the generic event. Create an IR Event if it's not
|
||||
* created yet.
|
||||
*
|
||||
* @param x
|
||||
* x coordinates.
|
||||
* @param y
|
||||
* y coordinates
|
||||
* @param rxx
|
||||
* raw X coordinate (0-1023).
|
||||
* @param ryy
|
||||
* raw Y coordinate (0-1023).
|
||||
* @param si
|
||||
* size of the IR dot (0-15).
|
||||
*/
|
||||
public void addIRpoint(int x, int y, short rx, short ry, short size) {
|
||||
if (infraredEvent != null)
|
||||
infraredEvent.addIRpoint(x, y, rx, ry, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Motion Sensing Event.
|
||||
*
|
||||
@@ -128,13 +172,18 @@ public class GenericEvent extends WiiUseApiEvent {
|
||||
* 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
|
||||
*/
|
||||
public void setMotionSensingEvent(float r, float p, float ya, float x, float y,
|
||||
float z){
|
||||
motionSensingEvent = new MotionSensingEvent(getWiimoteId(), r, p, ya, x, y, z);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -147,19 +196,19 @@ public class GenericEvent extends WiiUseApiEvent {
|
||||
|
||||
if (infraredEvent != null) {
|
||||
out += infraredEvent;
|
||||
}else{
|
||||
} else {
|
||||
out += "/******** IR Tracking ********/\n";
|
||||
out += "--- Active : false\n";
|
||||
}
|
||||
|
||||
if (motionSensingEvent != null) {
|
||||
out += motionSensingEvent;
|
||||
}else{
|
||||
} else {
|
||||
out += "/******** Motion sensing ********/\n";
|
||||
out += "--- Motion sensing : false \n";
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,28 +16,81 @@
|
||||
*/
|
||||
package wiiusej.wiiuseapievents;
|
||||
|
||||
import wiiusej.values.Point2DInteger;
|
||||
import wiiusej.values.IRSource;
|
||||
|
||||
/**
|
||||
* Class which represents an IR event.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class IREvent extends WiimoteEvent{
|
||||
public class IREvent extends WiimoteEvent {
|
||||
|
||||
/* IR Tracking */
|
||||
private Point2DInteger[] IRPoints;
|
||||
private IRSource[] IRPoints;
|
||||
private short indexPoints = 0;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;// distance from the sensor bar
|
||||
private int ax;
|
||||
private int ay;
|
||||
private int xVRes;
|
||||
private int yVRes;
|
||||
private int xOffset;
|
||||
private int yOffset;
|
||||
private short sensorBarPostion;
|
||||
private short screenAsPectRatio;
|
||||
|
||||
static private short WIIUSE_IR_ABOVE = 0;
|
||||
static private short WIIUSE_IR_BELOW = 1;
|
||||
static private short WIIUSE_SCREEN_RATIO_4_3 = 0;
|
||||
static private short WIIUSE_SCREEN_RATIO_16_9 = 1;
|
||||
|
||||
private static short NB_POINTS = 4;// number of points IR can track
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for an infrared event.
|
||||
* @param id id of the wiimote concerned.
|
||||
* Constructor of IREvent with full infos.
|
||||
*
|
||||
* @param id
|
||||
* d of the wiimote concerned.
|
||||
* @param x
|
||||
* calculated X coordinate.
|
||||
* @param y
|
||||
* calculated Y coordinate.
|
||||
* @param z
|
||||
* calculated distance.
|
||||
* @param ax
|
||||
* absolute X coordinate.
|
||||
* @param ay
|
||||
* absolute Y coordinate
|
||||
* @param xVRes
|
||||
* IR virtual screen x resolution.
|
||||
* @param yVRes
|
||||
* IR virtual screen y resolution.
|
||||
* @param xOffset
|
||||
* IR X correction offset.
|
||||
* @param yOffset
|
||||
* IR Y correction offset.
|
||||
* @param sensorBarPostion
|
||||
* aspect ratio of the screen.
|
||||
* @param screenAsPectRatio
|
||||
* IR sensor bar position.
|
||||
*/
|
||||
public IREvent(int id) {
|
||||
public IREvent(int id, int x, int y, int z, int ax, int ay, int xVRes,
|
||||
int yVRes, int xOffset, int yOffset, short sensorBarPostion,
|
||||
short screenAsPectRatio) {
|
||||
super(id);
|
||||
IRPoints = new Point2DInteger[NB_POINTS];
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.ax = ax;
|
||||
this.ay = ay;
|
||||
this.xVRes = xVRes;
|
||||
this.yVRes = yVRes;
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
this.sensorBarPostion = sensorBarPostion;
|
||||
this.screenAsPectRatio = screenAsPectRatio;
|
||||
IRPoints = new IRSource[NB_POINTS];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +98,7 @@ public class IREvent extends WiimoteEvent{
|
||||
*
|
||||
* @return the list of 2D points
|
||||
*/
|
||||
public Point2DInteger[] getIRPoints() {
|
||||
public IRSource[] getIRPoints() {
|
||||
return java.util.Arrays.copyOfRange(IRPoints, 0, indexPoints);
|
||||
}
|
||||
|
||||
@@ -56,19 +109,170 @@ public class IREvent extends WiimoteEvent{
|
||||
* x value
|
||||
* @param y
|
||||
* y value
|
||||
* @param rxx
|
||||
* raw X coordinate (0-1023).
|
||||
* @param ryy
|
||||
* raw Y coordinate (0-1023).
|
||||
* @param si
|
||||
* size of the IR dot (0-15).
|
||||
*/
|
||||
public void addIRpoint(int x, int y) {
|
||||
IRPoints[indexPoints] = new Point2DInteger(x, y);
|
||||
public void addIRpoint(int x, int y, short rx, short ry, short size) {
|
||||
IRPoints[indexPoints] = new IRSource(x, y, rx, ry, size);
|
||||
indexPoints++;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return calculated X coordinate.
|
||||
*
|
||||
* @return the x
|
||||
*/
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return calculated Y coordinate.
|
||||
*
|
||||
* @return the y
|
||||
*/
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return calculated distance.
|
||||
*
|
||||
* @return the z
|
||||
*/
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return absolute X coordinate.
|
||||
*
|
||||
* @return the ax
|
||||
*/
|
||||
public int getAx() {
|
||||
return ax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return absolute Y coordinate.
|
||||
*
|
||||
* @return the ay
|
||||
*/
|
||||
public int getAy() {
|
||||
return ay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return IR virtual screen x resolution.
|
||||
*
|
||||
* @return the xVRes
|
||||
*/
|
||||
public int getXVRes() {
|
||||
return xVRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return IR virtual screen y resolution.
|
||||
*
|
||||
* @return the yVRes
|
||||
*/
|
||||
public int getYVRes() {
|
||||
return yVRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return IR X correction offset.
|
||||
*
|
||||
* @return the xOffset
|
||||
*/
|
||||
public int getXOffset() {
|
||||
return xOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return IR Y correction offset.
|
||||
*
|
||||
* @return the yOffset
|
||||
*/
|
||||
public int getYOffset() {
|
||||
return yOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the sensor bar is above.
|
||||
*
|
||||
* @return true if the sensor bar is above.
|
||||
*/
|
||||
public boolean isSensorBarAbove() {
|
||||
return sensorBarPostion == WIIUSE_IR_ABOVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the sensor bar is below.
|
||||
*
|
||||
* @return true if the sensor bar is below.
|
||||
*/
|
||||
public boolean isSensorBarBelow() {
|
||||
return sensorBarPostion == WIIUSE_IR_BELOW;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if screen aspect ratio set is 4/3.
|
||||
*
|
||||
* @return true if screen aspect ratio set is 4/3.
|
||||
*/
|
||||
public boolean isScreenAspectRatio43() {
|
||||
return screenAsPectRatio == WIIUSE_SCREEN_RATIO_4_3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if screen aspect ratio set is 16/9.
|
||||
*
|
||||
* @return true if screen aspect ratio set is 16/9.
|
||||
*/
|
||||
public boolean isScreenAspectRatio169() {
|
||||
return screenAsPectRatio == WIIUSE_SCREEN_RATIO_16_9;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return aspect ratio of the screen.
|
||||
*
|
||||
* @return the screenAsPectRatio
|
||||
*/
|
||||
public short getScreenAsPectRatio() {
|
||||
return screenAsPectRatio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Display IR Tracking */
|
||||
out += "/******** IR Tracking ********/\n";
|
||||
out += "--- Active : true\n";
|
||||
out += "--- calculated X coordinate : " + x + "\n";
|
||||
out += "--- calculated Y coordinate : " + y + "\n";
|
||||
out += "--- calculated distance : " + z + "\n";
|
||||
out += "--- absolute X coordinate : " + ax + "\n";
|
||||
out += "--- absolute Y coordinate : " + ay + "\n";
|
||||
out += "--- IR virtual screen x resolution : " + xVRes + "\n";
|
||||
out += "--- IR virtual screen y resolution : " + yVRes + "\n";
|
||||
out += "--- IR X correction offset : " + xOffset + "\n";
|
||||
out += "--- IR Y correction offset : " + yOffset + "\n";
|
||||
if (isScreenAspectRatio43()) {
|
||||
out += "--- aspect ratio of the screen : 4/3\n";
|
||||
} else if (isScreenAspectRatio169()) {
|
||||
out += "--- aspect ratio of the screen : 16/9\n";
|
||||
}
|
||||
if (isSensorBarAbove()) {
|
||||
out += "--- IR sensor bar position. : Above\n";
|
||||
} else if (isSensorBarBelow()) {
|
||||
out += "--- IR sensor bar position. : Below\n";
|
||||
}
|
||||
out += "--- Seen points\n";
|
||||
for (int i = 0; i < IRPoints.length; i++) {
|
||||
if (IRPoints[i] != null) {
|
||||
@@ -77,5 +281,4 @@ public class IREvent extends WiimoteEvent{
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package wiiusej.wiiuseapievents;
|
||||
|
||||
import wiiusej.values.GForce;
|
||||
import wiiusej.values.Orientation;
|
||||
import wiiusej.values.RawAcceleration;
|
||||
|
||||
/**
|
||||
* Class which represents a motion sensing event.
|
||||
@@ -29,6 +30,7 @@ public class MotionSensingEvent extends WiimoteEvent{
|
||||
/* Motion Sensing */
|
||||
private Orientation orientation;
|
||||
private GForce gforce;
|
||||
private RawAcceleration acceleration;
|
||||
|
||||
/**
|
||||
* Constructor for a Motion Sensing Event.
|
||||
@@ -47,15 +49,21 @@ public class MotionSensingEvent extends WiimoteEvent{
|
||||
* 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
|
||||
*/
|
||||
public MotionSensingEvent(int id, float r, float p, float ya, float x, float y,
|
||||
float z) {
|
||||
float z, short xx, short yy, short zz) {
|
||||
super(id);
|
||||
setOrientationAndGforce(r, p, ya, x, y, z);
|
||||
setOrientationAndGforce(r, p, ya, x, y, z, xx, yy, zz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set orientation and gravity force.
|
||||
* Set orientation, gravity force and raw acceleration.
|
||||
*
|
||||
* @param r
|
||||
* roll
|
||||
@@ -69,11 +77,18 @@ public class MotionSensingEvent extends WiimoteEvent{
|
||||
* 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
|
||||
*/
|
||||
private void setOrientationAndGforce(float r, float p, float ya, float x,
|
||||
float y, float z) {
|
||||
float y, float z, short xx, short yy, short zz) {
|
||||
this.orientation = new Orientation(r, p, ya);
|
||||
this.gforce = new GForce(x, y, z);
|
||||
this.acceleration = new RawAcceleration(xx, yy, zz);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,6 +106,15 @@ public class MotionSensingEvent extends WiimoteEvent{
|
||||
public GForce getGforce() {
|
||||
return gforce;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw acceleration.
|
||||
*
|
||||
* @return the raw acceleration
|
||||
*/
|
||||
public RawAcceleration getRawAcceleration() {
|
||||
return acceleration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -100,6 +124,7 @@ public class MotionSensingEvent extends WiimoteEvent{
|
||||
out += "--- Motion sensing : true \n";
|
||||
out += "--- " + orientation + "\n";
|
||||
out += "--- " + gforce + "\n";
|
||||
out += "--- " + acceleration + "\n";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +153,54 @@ 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){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get led2 status.
|
||||
* @return true if the led is set.
|
||||
*/
|
||||
public boolean isLed2Set(){
|
||||
if ((leds & WIIMOTE_LED_2) > 0){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get led3 status.
|
||||
* @return true if the led is set.
|
||||
*/
|
||||
public boolean isLed3Set(){
|
||||
if ((leds & WIIMOTE_LED_3) > 0){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get led4 status.
|
||||
* @return true if the led is set.
|
||||
*/
|
||||
public boolean isLed4Set(){
|
||||
if ((leds & WIIMOTE_LED_4) > 0){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the speaker is enable for this wiimote
|
||||
|
||||
@@ -25,7 +25,13 @@ public abstract class WiiUseApiEvent extends WiimoteEvent{
|
||||
|
||||
public static int GENERIC_EVENT = 1;
|
||||
public static int STATUS_EVENT = 2;
|
||||
public static int DISCONNECTION_EVENT = 3;
|
||||
public static int DISCONNECTION_EVENT = 3;
|
||||
public static int WIIUSE_NUNCHUK_INSERTED = 4;
|
||||
public static int WIIUSE_NUNCHUK_REMOVED = 5;
|
||||
public static int WIIUSE_CLASSIC_CTRL_INSERTED = 6;
|
||||
public static int WIIUSE_CLASSIC_CTRL_REMOVED = 7;
|
||||
public static int WIIUSE_GUITAR_HERO_3_CTRL_INSERTED = 8;
|
||||
public static int WIIUSE_GUITAR_HERO_3_CTRL_REMOVED = 9;
|
||||
|
||||
/* Event Type */
|
||||
private int eventType;
|
||||
|
||||
Reference in New Issue
Block a user