move files back to src/main
This commit is contained in:
62
src/main/java/wiiusej/wiiusejevents/GenericEvent.java
Normal file
62
src/main/java/wiiusej/wiiusejevents/GenericEvent.java
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Abstract mother class representing an event with a wiimote id.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class GenericEvent implements Serializable {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
/* ID */
|
||||
private int wiimoteId = -1;
|
||||
|
||||
/**
|
||||
* Construct the WiiUseApiEvent setting up the id.
|
||||
*
|
||||
* @param id
|
||||
* the Wiimote id
|
||||
*/
|
||||
public GenericEvent(int id) {
|
||||
wiimoteId = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Wiimote ID
|
||||
*
|
||||
* @return the wiimote id.
|
||||
*/
|
||||
public int getWiimoteId() {
|
||||
return wiimoteId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Wiimote ID
|
||||
*
|
||||
* @param wiimoteId
|
||||
* id of the wiimote
|
||||
*/
|
||||
void setWiimoteId(int wiimoteId) {
|
||||
this.wiimoteId = wiimoteId;
|
||||
}
|
||||
|
||||
public abstract String toString();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
public class BalanceBoardButtonsEvent extends ButtonsEvent {
|
||||
protected static short BALANCE_BOARD_BUTTON = 0x0001;
|
||||
|
||||
public BalanceBoardButtonsEvent(int id, short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld) {
|
||||
super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
public class BalanceBoardEvent extends ExpansionEvent {
|
||||
protected JoystickEvent balanceBoardJoystickEvent;
|
||||
|
||||
public BalanceBoardEvent(int id, float topRight, float bottomRight,
|
||||
float bottomLeft, float topLeft) {
|
||||
super(id);
|
||||
System.out.println(String.format("%f %f %f %f", topRight, bottomRight, bottomLeft, topLeft));
|
||||
/*balanceBoardJoystickEvent = new JoystickEvent(id, angle,
|
||||
magnitude, max1, max2, min1, min2, center1, center2);*/
|
||||
}
|
||||
|
||||
public boolean isThereBalanceBoardJoystickEvent() {
|
||||
return balanceBoardJoystickEvent != null;
|
||||
}
|
||||
|
||||
public JoystickEvent getBalanceBoardJoystickEvent() {
|
||||
return balanceBoardJoystickEvent;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** Balance Board EVENT : WIIMOTE ID :" + getWiimoteId()
|
||||
+ " ********/\n";
|
||||
out += balanceBoardJoystickEvent;
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
import wiiusej.wiiusejevents.GenericEvent;
|
||||
|
||||
/**
|
||||
* Class which represents a buttons event.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class ButtonsEvent extends GenericEvent {
|
||||
|
||||
/* Buttons */
|
||||
private short buttonsJustPressed = 0;
|
||||
private short buttonsJustReleased = 0;
|
||||
private short buttonsHeld = 0;
|
||||
|
||||
/**
|
||||
* Constructor of the button Event.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote concerned.
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons just held.
|
||||
*/
|
||||
public ButtonsEvent(int id, short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld) {
|
||||
super(id);
|
||||
setAllButtons(buttonsJustPressed, buttonsJustReleased, buttonsHeld);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all buttons in one method.
|
||||
*
|
||||
* @param buttonsJustPressed
|
||||
* @param buttonsJustReleased
|
||||
* @param buttonsHeld
|
||||
*/
|
||||
private void setAllButtons(short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld) {
|
||||
this.buttonsJustPressed = buttonsJustPressed;
|
||||
this.buttonsJustReleased = buttonsJustReleased;
|
||||
this.buttonsHeld = buttonsHeld;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short storing the buttons just pressed
|
||||
*
|
||||
* @return the short storing the buttons just pressed
|
||||
*/
|
||||
public short getButtonsJustPressed() {
|
||||
return buttonsJustPressed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short storing the buttons just released
|
||||
*
|
||||
* @return the short storing the buttons just released
|
||||
*/
|
||||
public short getButtonsJustReleased() {
|
||||
return buttonsJustReleased;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the short storing the buttons held
|
||||
*
|
||||
* @return the short storing the buttons held
|
||||
*/
|
||||
public short getButtonsHeld() {
|
||||
return buttonsHeld;
|
||||
}
|
||||
|
||||
/** **************** BUTTONS Methods ***************** */
|
||||
/* generic button functions */
|
||||
|
||||
protected boolean buttonTest(int buttonBitsDefinition, int buttons) {
|
||||
return (buttons & buttonBitsDefinition) == buttonBitsDefinition;
|
||||
}
|
||||
|
||||
protected boolean isButtonJustPressed(int buttonBitsDefinition) {
|
||||
return buttonTest(buttonBitsDefinition, buttonsJustPressed)
|
||||
&& !isButtonHeld(buttonBitsDefinition);
|
||||
}
|
||||
|
||||
protected boolean isButtonJustReleased(int buttonBitsDefinition) {
|
||||
return buttonTest(buttonBitsDefinition, buttonsJustReleased);
|
||||
}
|
||||
|
||||
protected boolean isButtonHeld(int buttonBitsDefinition) {
|
||||
return buttonTest(buttonBitsDefinition, buttonsHeld);
|
||||
}
|
||||
|
||||
protected boolean isButtonPressed(int buttonBitsDefinition) {
|
||||
return isButtonHeld(buttonBitsDefinition)
|
||||
|| isButtonJustPressed(buttonBitsDefinition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Display buttons */
|
||||
out += "/******** Buttons ********/\n";
|
||||
out += "--- Buttons just pressed : " + buttonsJustPressed + "\n";
|
||||
out += "--- Buttons just released : " + buttonsJustReleased + "\n";
|
||||
out += "--- Buttons held : " + buttonsHeld + "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
/* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
/**
|
||||
* Class which represents a buttons event from a Classic controller.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class ClassicControllerButtonsEvent extends ButtonsEvent{
|
||||
|
||||
private static short CLASSIC_CTRL_BUTTON_UP = 0x0001;
|
||||
private static short CLASSIC_CTRL_BUTTON_LEFT = 0x0002;
|
||||
private static short CLASSIC_CTRL_BUTTON_ZR = 0x0004;
|
||||
private static short CLASSIC_CTRL_BUTTON_X = 0x0008;
|
||||
private static short CLASSIC_CTRL_BUTTON_A = 0x0010;
|
||||
private static short CLASSIC_CTRL_BUTTON_Y = 0x0020;
|
||||
private static short CLASSIC_CTRL_BUTTON_B = 0x0040;
|
||||
private static short CLASSIC_CTRL_BUTTON_ZL = 0x0080;
|
||||
private static short CLASSIC_CTRL_BUTTON_FULL_R = 0x0200;
|
||||
private static short CLASSIC_CTRL_BUTTON_PLUS = 0x0400;
|
||||
private static short CLASSIC_CTRL_BUTTON_HOME = 0x0800;
|
||||
private static short CLASSIC_CTRL_BUTTON_MINUS = 0x1000;
|
||||
private static short CLASSIC_CTRL_BUTTON_FULL_L = 0x2000;
|
||||
private static short CLASSIC_CTRL_BUTTON_DOWN = 0x4000;
|
||||
private static int CLASSIC_CTRL_BUTTON_RIGHT = 0x8000;
|
||||
private static int CLASSIC_CTRL_BUTTON_ALL = 0xFEFF;
|
||||
|
||||
/**
|
||||
* Constructor of the classic controller buttons Event.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons just pressed.
|
||||
*/
|
||||
public ClassicControllerButtonsEvent(int id, short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld) {
|
||||
super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld);
|
||||
}
|
||||
|
||||
/* Button LEFT */
|
||||
|
||||
public boolean isButtonLeftJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
public boolean isButtonLeftJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
public boolean isButtonLeftHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
public boolean isButtonLeftPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
/* Button RIGHT */
|
||||
|
||||
public boolean isButtonRightJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_RIGHT);
|
||||
}
|
||||
|
||||
public boolean isButtonRightJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_RIGHT);
|
||||
}
|
||||
|
||||
public boolean isButtonRightHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_RIGHT);
|
||||
}
|
||||
|
||||
public boolean isButtonRightPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_RIGHT);
|
||||
}
|
||||
|
||||
/* Button UP */
|
||||
|
||||
public boolean isButtonUpJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_UP);
|
||||
}
|
||||
|
||||
public boolean isButtonUpJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_UP);
|
||||
}
|
||||
|
||||
public boolean isButtonUpHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_UP);
|
||||
}
|
||||
|
||||
public boolean isButtonUpPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_UP);
|
||||
}
|
||||
|
||||
/* Button DOWN */
|
||||
|
||||
public boolean isButtonDownJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_DOWN);
|
||||
}
|
||||
|
||||
public boolean isButtonDownJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_DOWN);
|
||||
}
|
||||
|
||||
public boolean isButtonDownHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_DOWN);
|
||||
}
|
||||
|
||||
public boolean isButtonDownPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_DOWN);
|
||||
}
|
||||
|
||||
/* Button A */
|
||||
|
||||
public boolean isButtonAJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_A);
|
||||
}
|
||||
|
||||
public boolean isButtonAJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_A);
|
||||
}
|
||||
|
||||
public boolean isButtonAHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_A);
|
||||
}
|
||||
|
||||
public boolean isButtonAPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_A);
|
||||
}
|
||||
|
||||
/* Button B */
|
||||
|
||||
public boolean isButtonBJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_B);
|
||||
}
|
||||
|
||||
public boolean isButtonBJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_B);
|
||||
}
|
||||
|
||||
public boolean isButtonBHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_B);
|
||||
}
|
||||
|
||||
public boolean isButtonBPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_B);
|
||||
}
|
||||
|
||||
/* Button X */
|
||||
|
||||
public boolean isButtonXJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_X);
|
||||
}
|
||||
|
||||
public boolean isButtonXJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_X);
|
||||
}
|
||||
|
||||
public boolean isButtonXHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_X);
|
||||
}
|
||||
|
||||
public boolean isButtonXPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_X);
|
||||
}
|
||||
|
||||
/* Button Y */
|
||||
|
||||
public boolean isButtonYJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_Y);
|
||||
}
|
||||
|
||||
public boolean isButtonYJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_Y);
|
||||
}
|
||||
|
||||
public boolean isButtonYHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_Y);
|
||||
}
|
||||
|
||||
public boolean isButtonYPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_Y);
|
||||
}
|
||||
|
||||
/* Button FullLeft */
|
||||
|
||||
public boolean isButtonFullLeftJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_FULL_L);
|
||||
}
|
||||
|
||||
public boolean isButtonFullLeftJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_FULL_L);
|
||||
}
|
||||
|
||||
public boolean isButtonFullLeftHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_FULL_L);
|
||||
}
|
||||
|
||||
public boolean isButtonFullLeftPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_FULL_L);
|
||||
}
|
||||
|
||||
/* Button FullRight */
|
||||
|
||||
public boolean isButtonFullRightJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_FULL_R);
|
||||
}
|
||||
|
||||
public boolean isButtonFullRightJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_FULL_R);
|
||||
}
|
||||
|
||||
public boolean isButtonFullRightHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_FULL_R);
|
||||
}
|
||||
|
||||
public boolean isButtonFullRightPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_FULL_R);
|
||||
}
|
||||
|
||||
/* Button Home */
|
||||
|
||||
public boolean isButtonHomeJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_HOME);
|
||||
}
|
||||
|
||||
public boolean isButtonHomeJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_HOME);
|
||||
}
|
||||
|
||||
public boolean isButtonHomeHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_HOME);
|
||||
}
|
||||
|
||||
public boolean isButtonHomePressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_HOME);
|
||||
}
|
||||
|
||||
/* Button Minus */
|
||||
|
||||
public boolean isButtonMinusJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
public boolean isButtonMinusJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
public boolean isButtonMinusHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
public boolean isButtonMinusPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
/* Button Plus */
|
||||
|
||||
public boolean isButtonPlusJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
public boolean isButtonPlusJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
public boolean isButtonPlusHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
public boolean isButtonPlusPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
/* Button ZL */
|
||||
|
||||
public boolean isButtonZLJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_ZL);
|
||||
}
|
||||
|
||||
public boolean isButtonZLJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_ZL);
|
||||
}
|
||||
|
||||
public boolean isButtonZLHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_ZL);
|
||||
}
|
||||
|
||||
public boolean isButtonZLPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_ZL);
|
||||
}
|
||||
|
||||
/* Button ZR */
|
||||
|
||||
public boolean isButtonZRJustPressed() {
|
||||
return isButtonJustPressed(CLASSIC_CTRL_BUTTON_ZR);
|
||||
}
|
||||
|
||||
public boolean isButtonZRJustReleased() {
|
||||
return isButtonJustReleased(CLASSIC_CTRL_BUTTON_ZR);
|
||||
}
|
||||
|
||||
public boolean isButtonZRHeld() {
|
||||
return isButtonHeld(CLASSIC_CTRL_BUTTON_ZR);
|
||||
}
|
||||
|
||||
public boolean isButtonZRPressed() {
|
||||
return isButtonPressed(CLASSIC_CTRL_BUTTON_ZR);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
/**
|
||||
* This class represents the values from the classic controller and its events.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class ClassicControllerEvent extends ExpansionEvent {
|
||||
|
||||
private float rightShoulder;
|
||||
private float leftShoulder;
|
||||
private ClassicControllerButtonsEvent buttonsEvent;
|
||||
private JoystickEvent classicControllerRightJoystickEvent;
|
||||
private JoystickEvent classicControllerLeftJoystickEvent;
|
||||
|
||||
/**
|
||||
* Constructor of ClassicControllerEvent.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons just pressed.
|
||||
* @param rightShoulder
|
||||
* right shoulder button (range 0-1).
|
||||
* @param leftShoulder
|
||||
* left shoulder button (range 0-1).
|
||||
* @param langle
|
||||
* angle the left joystick is being held.
|
||||
* @param lmagnitude
|
||||
* magnitude of the left joystick (range 0-1).
|
||||
* @param lmax1
|
||||
* maximum left joystick value 1.
|
||||
* @param lmax2
|
||||
* maximum left joystick value 2.
|
||||
* @param lmin1
|
||||
* minimum left joystick value 1.
|
||||
* @param lmin2
|
||||
* minimum left joystick value 2.
|
||||
* @param lcenter1
|
||||
* center left joystick value 1.
|
||||
* @param lcenter2
|
||||
* center left joystick value 2.
|
||||
* @param rangle
|
||||
* angle the right joystick is being held.
|
||||
* @param rmagnitude
|
||||
* magnitude of the right joystick (range 0-1).
|
||||
* @param rmax1
|
||||
* maximum right joystick value 1.
|
||||
* @param rmax2
|
||||
* maximum right joystick value 2.
|
||||
* @param rmin1
|
||||
* minimum right joystick value 1.
|
||||
* @param rmin2
|
||||
* minimum right joystick value 2.
|
||||
* @param rcenter1
|
||||
* center right joystick value 1.
|
||||
* @param rcenter2
|
||||
* center right joystick value 2.
|
||||
*/
|
||||
public ClassicControllerEvent(int id, short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld, float rightShoulder,
|
||||
float leftShoulder, float langle, float lmagnitude, short lmax1,
|
||||
short lmax2, short lmin1, short lmin2, short lcenter1,
|
||||
short lcenter2, float rangle, float rmagnitude, short rmax1,
|
||||
short rmax2, short rmin1, short rmin2, short rcenter1,
|
||||
short rcenter2) {
|
||||
super(id);
|
||||
this.leftShoulder = leftShoulder;
|
||||
this.rightShoulder = rightShoulder;
|
||||
buttonsEvent = new ClassicControllerButtonsEvent(id,
|
||||
buttonsJustPressed, buttonsJustReleased, buttonsHeld);
|
||||
classicControllerLeftJoystickEvent = new JoystickEvent(id, langle,
|
||||
lmagnitude, lmax1, lmax2, lmin1, lmin2, lcenter1, lcenter2);
|
||||
classicControllerRightJoystickEvent = new JoystickEvent(id, rangle,
|
||||
rmagnitude, rmax1, rmax2, rmin1, rmin2, rcenter1, rcenter2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if there is a classic controller left joystick event.
|
||||
*
|
||||
* @return TRUE if there is a classic controller left joystick event, false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isThereClassicControllerLeftJoystickEvent() {
|
||||
return classicControllerLeftJoystickEvent != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if there is a classic controller right joystick event.
|
||||
*
|
||||
* @return TRUE if there is a classic controller right joystick event, false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isThereClassicControllerRightJoystickEvent() {
|
||||
return classicControllerRightJoystickEvent != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the right shoulder button(range 0-1).
|
||||
*
|
||||
* @return value of the rightShoulder button.
|
||||
*/
|
||||
public float getRightShoulder() {
|
||||
return rightShoulder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the left shoulder button(range 0-1).
|
||||
*
|
||||
* @return value of the leftShoulder button.
|
||||
*/
|
||||
public float getLeftShoulder() {
|
||||
return leftShoulder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get buttons event for the classic controller.
|
||||
*
|
||||
* @return the classic controller buttons event if there is one or null.
|
||||
*/
|
||||
public ClassicControllerButtonsEvent getButtonsEvent() {
|
||||
return buttonsEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get event from the right joystick of the classic controller.
|
||||
*
|
||||
* @return the classic controller right Joystick Event if there is one or null.
|
||||
*/
|
||||
public JoystickEvent getClassicControllerRightJoystickEvent() {
|
||||
return classicControllerRightJoystickEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get event from the left joystick of the classic controller.
|
||||
*
|
||||
* @return the classic controller left Joystick Event if there is one or null.
|
||||
*/
|
||||
public JoystickEvent getClassicControllerLeftJoystickEvent() {
|
||||
return classicControllerLeftJoystickEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** Classic Controller EVENT : WIIMOTE ID :"
|
||||
+ getWiimoteId() + " ********/\n";
|
||||
out += buttonsEvent;
|
||||
out += "Left shoulder : " + leftShoulder + "\n";
|
||||
out += "Right shoulder : " + rightShoulder + "\n";
|
||||
out += classicControllerLeftJoystickEvent;
|
||||
out += classicControllerRightJoystickEvent;
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
import wiiusej.wiiusejevents.GenericEvent;
|
||||
|
||||
/**
|
||||
* Mother Class of all expansions event.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class ExpansionEvent extends GenericEvent {
|
||||
|
||||
/**
|
||||
* Constructor of an ExpansionEvent.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote to which the expansion is connected.
|
||||
*/
|
||||
public ExpansionEvent(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public abstract String toString();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
/* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
/**
|
||||
* Class which represents a buttons event from a Guitar Hero controller.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class GuitarHeroButtonsEvent extends ButtonsEvent {
|
||||
|
||||
private static short GUITAR_HERO_3_BUTTON_STRUM_UP = 0x0001;
|
||||
private static short GUITAR_HERO_3_BUTTON_YELLOW = 0x0008;
|
||||
private static short GUITAR_HERO_3_BUTTON_GREEN = 0x0010;
|
||||
private static short GUITAR_HERO_3_BUTTON_BLUE = 0x0020;
|
||||
private static short GUITAR_HERO_3_BUTTON_RED = 0x0040;
|
||||
private static short GUITAR_HERO_3_BUTTON_ORANGE = 0x0080;
|
||||
private static short GUITAR_HERO_3_BUTTON_PLUS = 0x0400;
|
||||
private static short GUITAR_HERO_3_BUTTON_MINUS = 0x1000;
|
||||
private static short GUITAR_HERO_3_BUTTON_STRUM_DOWN = 0x4000;
|
||||
private static int GUITAR_HERO_3_BUTTON_ALL = 0xFEFF;
|
||||
|
||||
/**
|
||||
* Constructor of the guitar hero buttons Event.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons just pressed.
|
||||
*/
|
||||
public GuitarHeroButtonsEvent(int id, short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld) {
|
||||
super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld);
|
||||
}
|
||||
|
||||
/* Button Strum Up */
|
||||
|
||||
public boolean isButtonStrumUpJustPressed() {
|
||||
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_STRUM_UP);
|
||||
}
|
||||
|
||||
public boolean isButtonStrumUpJustReleased() {
|
||||
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_STRUM_UP);
|
||||
}
|
||||
|
||||
public boolean isButtonStrumUpeHeld() {
|
||||
return isButtonHeld(GUITAR_HERO_3_BUTTON_STRUM_UP);
|
||||
}
|
||||
|
||||
public boolean isButtonStrumUpPressed() {
|
||||
return isButtonPressed(GUITAR_HERO_3_BUTTON_STRUM_UP);
|
||||
}
|
||||
|
||||
/* Button Strum Down */
|
||||
|
||||
public boolean isButtonStrumDownJustPressed() {
|
||||
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_STRUM_DOWN);
|
||||
}
|
||||
|
||||
public boolean isButtonStrumDownJustReleased() {
|
||||
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_STRUM_DOWN);
|
||||
}
|
||||
|
||||
public boolean isButtonStrumDowneHeld() {
|
||||
return isButtonHeld(GUITAR_HERO_3_BUTTON_STRUM_DOWN);
|
||||
}
|
||||
|
||||
public boolean isButtonStrumDownPressed() {
|
||||
return isButtonPressed(GUITAR_HERO_3_BUTTON_STRUM_DOWN);
|
||||
}
|
||||
|
||||
/* Button blue */
|
||||
|
||||
public boolean isButtonBlueJustPressed() {
|
||||
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_BLUE);
|
||||
}
|
||||
|
||||
public boolean isButtonBlueJustReleased() {
|
||||
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_BLUE);
|
||||
}
|
||||
|
||||
public boolean isButtonBlueHeld() {
|
||||
return isButtonHeld(GUITAR_HERO_3_BUTTON_BLUE);
|
||||
}
|
||||
|
||||
public boolean isButtonBluePressed() {
|
||||
return isButtonPressed(GUITAR_HERO_3_BUTTON_BLUE);
|
||||
}
|
||||
|
||||
/* Button Green */
|
||||
|
||||
public boolean isButtonGreenJustPressed() {
|
||||
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_GREEN);
|
||||
}
|
||||
|
||||
public boolean isButtonGreenJustReleased() {
|
||||
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_GREEN);
|
||||
}
|
||||
|
||||
public boolean isButtonGreenHeld() {
|
||||
return isButtonHeld(GUITAR_HERO_3_BUTTON_GREEN);
|
||||
}
|
||||
|
||||
public boolean isButtonGreenPressed() {
|
||||
return isButtonPressed(GUITAR_HERO_3_BUTTON_GREEN);
|
||||
}
|
||||
|
||||
/* Button Minus */
|
||||
|
||||
public boolean isButtonMinusJustPressed() {
|
||||
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
public boolean isButtonMinusJustReleased() {
|
||||
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
public boolean isButtonMinusHeld() {
|
||||
return isButtonHeld(GUITAR_HERO_3_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
public boolean isButtonMinusPressed() {
|
||||
return isButtonPressed(GUITAR_HERO_3_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
/* Button Orange */
|
||||
|
||||
public boolean isButtonOrangeJustPressed() {
|
||||
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_ORANGE);
|
||||
}
|
||||
|
||||
public boolean isButtonOrangeJustReleased() {
|
||||
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_ORANGE);
|
||||
}
|
||||
|
||||
public boolean isButtonOrangeHeld() {
|
||||
return isButtonHeld(GUITAR_HERO_3_BUTTON_ORANGE);
|
||||
}
|
||||
|
||||
public boolean isButtonOrangePressed() {
|
||||
return isButtonPressed(GUITAR_HERO_3_BUTTON_ORANGE);
|
||||
}
|
||||
|
||||
/* Button Plus */
|
||||
|
||||
public boolean isButtonPlusJustPressed() {
|
||||
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
public boolean isButtonPlusJustReleased() {
|
||||
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
public boolean isButtonPlusHeld() {
|
||||
return isButtonHeld(GUITAR_HERO_3_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
public boolean isButtonPlusPressed() {
|
||||
return isButtonPressed(GUITAR_HERO_3_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
/* Button Red */
|
||||
|
||||
public boolean isButtonRedJustPressed() {
|
||||
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_RED);
|
||||
}
|
||||
|
||||
public boolean isButtonRedJustReleased() {
|
||||
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_RED);
|
||||
}
|
||||
|
||||
public boolean isButtonRedHeld() {
|
||||
return isButtonHeld(GUITAR_HERO_3_BUTTON_RED);
|
||||
}
|
||||
|
||||
public boolean isButtonRedPressed() {
|
||||
return isButtonPressed(GUITAR_HERO_3_BUTTON_RED);
|
||||
}
|
||||
|
||||
/* Button Yellow */
|
||||
|
||||
public boolean isButtonYellowJustPressed() {
|
||||
return isButtonJustPressed(GUITAR_HERO_3_BUTTON_YELLOW);
|
||||
}
|
||||
|
||||
public boolean isButtonYellowJustReleased() {
|
||||
return isButtonJustReleased(GUITAR_HERO_3_BUTTON_YELLOW);
|
||||
}
|
||||
|
||||
public boolean isButtonYellowHeld() {
|
||||
return isButtonHeld(GUITAR_HERO_3_BUTTON_YELLOW);
|
||||
}
|
||||
|
||||
public boolean isButtonYellowPressed() {
|
||||
return isButtonPressed(GUITAR_HERO_3_BUTTON_YELLOW);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
/**
|
||||
* This class represents the values from the GuitarHero and its events.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class GuitarHeroEvent extends ExpansionEvent{
|
||||
|
||||
private float whammyBar;
|
||||
private GuitarHeroButtonsEvent buttonsEvent;
|
||||
private JoystickEvent guitarHeroJoystickEvent;
|
||||
|
||||
/**
|
||||
* Constructor of GuitarHeroEvent.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons just pressed.
|
||||
* @param whammyBar
|
||||
* whammy bar (range 0-1).
|
||||
* @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 GuitarHeroEvent(int id, short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld, float whammyBar,
|
||||
float angle, float magnitude, short max1,
|
||||
short max2, short min1, short min2, short center1,
|
||||
short center2) {
|
||||
super(id);
|
||||
this.whammyBar = whammyBar;
|
||||
buttonsEvent = new GuitarHeroButtonsEvent(id,
|
||||
buttonsJustPressed, buttonsJustReleased, buttonsHeld);
|
||||
guitarHeroJoystickEvent = new JoystickEvent(id, angle,
|
||||
magnitude, max1, max2, min1, min2, center1, center2);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if there is a Guitar Hero joystick event.
|
||||
*
|
||||
* @return TRUE if there is a Guitar Hero joystick event, false otherwise.
|
||||
*/
|
||||
public boolean isThereGuitarHeroJoystickEvent() {
|
||||
return guitarHeroJoystickEvent != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whammy bar (range 0-1).
|
||||
* @return the whammyBar value.
|
||||
*/
|
||||
public float getWhammyBar() {
|
||||
return whammyBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get buttons event for the guitar hero controller.
|
||||
* @return the guitar hero controller buttons event if there is one or null.
|
||||
*/
|
||||
public GuitarHeroButtonsEvent getButtonsEvent() {
|
||||
return buttonsEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get event from the joystick of the guitar hero controller.
|
||||
* @return the guitar hero controller joystick Event if there is one or null.
|
||||
*/
|
||||
public JoystickEvent getGuitarHeroJoystickEvent() {
|
||||
return guitarHeroJoystickEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** Guitar Hero 3 EVENT : WIIMOTE ID :" + getWiimoteId()
|
||||
+ " ********/\n";
|
||||
out += buttonsEvent;
|
||||
out += "Whammy Bar : "+whammyBar+"\n";
|
||||
out += guitarHeroJoystickEvent;
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
319
src/main/java/wiiusej/wiiusejevents/physicalevents/IREvent.java
Normal file
319
src/main/java/wiiusej/wiiusejevents/physicalevents/IREvent.java
Normal file
@@ -0,0 +1,319 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
import wiiusej.values.IRSource;
|
||||
import wiiusej.wiiusejevents.GenericEvent;
|
||||
|
||||
/**
|
||||
* Class which represents an IR event.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class IREvent extends GenericEvent {
|
||||
|
||||
/* IR Tracking */
|
||||
private IRSource[] IRPoints;
|
||||
private short indexPoints = 0;
|
||||
private int x;
|
||||
private int y;
|
||||
private float 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;
|
||||
private short irSensitivity;
|
||||
private float distance;
|
||||
|
||||
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 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.
|
||||
* @param irSensitivity
|
||||
* Sensitivity of the infrared camera.
|
||||
* @param distance
|
||||
* Pixel Distance between first two dots
|
||||
*/
|
||||
public IREvent(int id, int x, int y, float z, int ax, int ay, int xVRes,
|
||||
int yVRes, int xOffset, int yOffset, short sensorBarPostion,
|
||||
short screenAsPectRatio, short irSensitivity, float distance) {
|
||||
super(id);
|
||||
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;
|
||||
this.irSensitivity = irSensitivity;
|
||||
this.distance = distance;
|
||||
IRPoints = new IRSource[NB_POINTS];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of IR points.
|
||||
*
|
||||
* @return the list of 2D points
|
||||
*/
|
||||
public IRSource[] getIRPoints() {
|
||||
IRSource[] ir = new IRSource[indexPoints];
|
||||
System.arraycopy(IRPoints, 0, ir, 0, indexPoints);
|
||||
return ir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add IR Point in the list (Max 4 points)
|
||||
*
|
||||
* @param x
|
||||
* x value
|
||||
* @param y
|
||||
* y value
|
||||
* @param rx
|
||||
* raw X coordinate (0-1023).
|
||||
* @param ry
|
||||
* raw Y coordinate (0-1023).
|
||||
* @param size
|
||||
* size of the IR dot (0-15).
|
||||
*/
|
||||
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 float 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* The sensitivity of the IR camera can be turned up or down depending on
|
||||
* your needs. Like the Wii, wiiusej and wiiuse can set the camera
|
||||
* sensitivity to a degree between 1 (lowest) and 5 (highest). The default
|
||||
* is 3.
|
||||
*
|
||||
* @return the irSensitivity
|
||||
*/
|
||||
public short getIrSensitivity() {
|
||||
return irSensitivity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pixel distance between first 2 dots.
|
||||
*
|
||||
* @return the distance between first 2 dots.
|
||||
*/
|
||||
public float getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
@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 Z coordinate : " + z + "\n";
|
||||
out += "--- calculated distance : " + distance + "\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";
|
||||
out += "--- IR Sensitivity (between 1-5) : " + irSensitivity + "\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) {
|
||||
out += IRPoints[i].toString();
|
||||
}
|
||||
}
|
||||
out += "\n";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
import wiiusej.wiiusejevents.GenericEvent;
|
||||
|
||||
/**
|
||||
* Class that stores values on a joystick Event.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class JoystickEvent extends GenericEvent {
|
||||
|
||||
private float angle;
|
||||
private float magnitude;
|
||||
private short[] max;
|
||||
private short[] min;
|
||||
private short[] center;
|
||||
|
||||
/**
|
||||
* Constructor of a JoystickEvent.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote connected.
|
||||
* @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 JoystickEvent(int id, float angle, float magnitude, short max1,
|
||||
short max2, short min1, short min2, short center1, short center2) {
|
||||
super(id);
|
||||
this.angle = angle;
|
||||
this.magnitude = magnitude;
|
||||
max = new short[2];
|
||||
max[0] = max1;
|
||||
max[1] = max2;
|
||||
min = new short[2];
|
||||
min[0] = min1;
|
||||
min[1] = min2;
|
||||
center = new short[2];
|
||||
center[0] = center1;
|
||||
center[1] = center2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get angle the joystick is being held.
|
||||
*
|
||||
* @return the angle angle the joystick.
|
||||
*/
|
||||
public float getAngle() {
|
||||
return angle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get magnitude of the joystick (range 0-1).
|
||||
*
|
||||
* @return the magnitude magnitude of the joystick.
|
||||
*/
|
||||
public float getMagnitude() {
|
||||
return magnitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum joystick values.
|
||||
*
|
||||
* @return the max
|
||||
*/
|
||||
public short[] getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimum joystick values.
|
||||
*
|
||||
* @return the min
|
||||
*/
|
||||
public short[] getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
/**
|
||||
* Center joystick values.
|
||||
*
|
||||
* @return the center
|
||||
*/
|
||||
public short[] getCenter() {
|
||||
return center;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see wiiusej.wiiusejevents.GenericEvent#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Display IR Tracking */
|
||||
out += "/******** Joystick ********/\n";
|
||||
out += "--- angle : " + angle + "\n";
|
||||
out += "--- magnitude : " + magnitude + "\n";
|
||||
out += "--- maximum values : " + max[0] + "," + max[1] + "\n";
|
||||
out += "--- minimum values : " + min[0] + "," + min[1] + "\n";
|
||||
out += "--- center values : " + center[0] + "," + center[1] + "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
import wiiusej.values.GForce;
|
||||
import wiiusej.values.Orientation;
|
||||
import wiiusej.values.RawAcceleration;
|
||||
import wiiusej.wiiusejevents.GenericEvent;
|
||||
|
||||
/**
|
||||
* Class which represents a motion sensing event.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class MotionSensingEvent extends GenericEvent {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
/* 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
|
||||
* 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.
|
||||
*/
|
||||
public MotionSensingEvent(int id, 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) {
|
||||
super(id);
|
||||
this.orientationThreshold = orientationThreshold;
|
||||
this.accelerationThreshold = accelerationThreshold;
|
||||
this.isSmoothingActive = smoothingState;
|
||||
this.alphaSmoothing = alphaSmooth;
|
||||
setOrientationAndGforce(r, p, ya, ar, ap, x, y, z, xx, yy, zz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set orientation, gravity force and raw acceleration.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
private void setOrientationAndGforce(float r, float p, float ya, float ar,
|
||||
float ap, float x, float y, float z, short xx, short yy, short zz) {
|
||||
this.orientation = new Orientation(r, p, ya, ar, ap);
|
||||
this.gforce = new GForce(x, y, z);
|
||||
this.acceleration = new RawAcceleration(xx, yy, zz);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the orientation
|
||||
*/
|
||||
public Orientation getOrientation() {
|
||||
return orientation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the gravity force.
|
||||
*
|
||||
* @return the gforce
|
||||
*/
|
||||
public GForce getGforce() {
|
||||
return gforce;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw acceleration.
|
||||
*
|
||||
* @return the raw acceleration
|
||||
*/
|
||||
public RawAcceleration getRawAcceleration() {
|
||||
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";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
/**
|
||||
* Class which represents a buttons event from a Nunchuk.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class NunchukButtonsEvent extends ButtonsEvent {
|
||||
|
||||
private static short NUNCHUK_BUTTON_Z = 0x01;
|
||||
private static short NUNCHUK_BUTTON_C = 0x02;
|
||||
private static short NUNCHUK_BUTTON_ALL = 0x03;
|
||||
|
||||
/**
|
||||
* Constructor of the nunchuk buttons Event.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons just pressed.
|
||||
*/
|
||||
public NunchukButtonsEvent(int id, short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld) {
|
||||
super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld);
|
||||
}
|
||||
|
||||
/* Button Z */
|
||||
|
||||
public boolean isButtonZJustPressed() {
|
||||
return isButtonJustPressed(NUNCHUK_BUTTON_Z);
|
||||
}
|
||||
|
||||
public boolean isButtonZJustReleased() {
|
||||
return isButtonJustReleased(NUNCHUK_BUTTON_Z);
|
||||
}
|
||||
|
||||
public boolean isButtonZeHeld() {
|
||||
return isButtonHeld(NUNCHUK_BUTTON_Z);
|
||||
}
|
||||
|
||||
public boolean isButtonZPressed() {
|
||||
return isButtonPressed(NUNCHUK_BUTTON_Z);
|
||||
}
|
||||
|
||||
/* Button Z */
|
||||
|
||||
public boolean isButtonCJustPressed() {
|
||||
return isButtonJustPressed(NUNCHUK_BUTTON_C);
|
||||
}
|
||||
|
||||
public boolean isButtonCJustReleased() {
|
||||
return isButtonJustReleased(NUNCHUK_BUTTON_C);
|
||||
}
|
||||
|
||||
public boolean isButtonCHeld() {
|
||||
return isButtonHeld(NUNCHUK_BUTTON_C);
|
||||
}
|
||||
|
||||
public boolean isButtonCPressed() {
|
||||
return isButtonPressed(NUNCHUK_BUTTON_C);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "/******** Buttons for Nunchuk Event ********/\n"
|
||||
+ super.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
/**
|
||||
* This class represents the values from the joystick and its events.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class NunchukEvent extends ExpansionEvent {
|
||||
|
||||
private NunchukButtonsEvent buttonsEvent;
|
||||
private MotionSensingEvent nunchukMotionSensingEvent;
|
||||
private 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, 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, float angle, float magnitude, short max1,
|
||||
short max2, short min1, short min2, short center1, short center2) {
|
||||
super(id);
|
||||
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 nunchuk buttons event.
|
||||
*
|
||||
* @return the nunchuk 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)
|
||||
*
|
||||
* @see wiiusej.wiiusejevents.GenericEvent#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** Nunchuk EVENT : WIIMOTE ID :" + getWiimoteId()
|
||||
+ " ********/\n";
|
||||
out += buttonsEvent;
|
||||
out += nunchukJoystickEvent;
|
||||
out += nunchukMotionSensingEvent;
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.physicalevents;
|
||||
|
||||
/**
|
||||
* Class which represents a buttons event for a generic event. It means buttons
|
||||
* from a wiimote.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class WiimoteButtonsEvent extends ButtonsEvent {
|
||||
|
||||
/* Buttons MACRO */
|
||||
private static short WIIMOTE_BUTTON_TWO = 0x0001;
|
||||
private static short WIIMOTE_BUTTON_ONE = 0x0002;
|
||||
private static short WIIMOTE_BUTTON_B = 0x0004;
|
||||
private static short WIIMOTE_BUTTON_A = 0x0008;
|
||||
private static short WIIMOTE_BUTTON_MINUS = 0x0010;
|
||||
private static short WIIMOTE_BUTTON_ZACCEL_BIT6 = 0x0020;
|
||||
private static short WIIMOTE_BUTTON_ZACCEL_BIT7 = 0x0040;
|
||||
private static short WIIMOTE_BUTTON_HOME = 0x0080;
|
||||
private static short WIIMOTE_BUTTON_LEFT = 0x0100;
|
||||
private static short WIIMOTE_BUTTON_RIGHT = 0x0200;
|
||||
private static short WIIMOTE_BUTTON_DOWN = 0x0400;
|
||||
private static short WIIMOTE_BUTTON_UP = 0x0800;
|
||||
private static short WIIMOTE_BUTTON_PLUS = 0x1000;
|
||||
private static short WIIMOTE_BUTTON_ZACCEL_BIT4 = 0x2000;
|
||||
private static short WIIMOTE_BUTTON_ZACCEL_BIT5 = 0x4000;
|
||||
private static int WIIMOTE_BUTTON_UNKNOWN = 0x8000;
|
||||
private static short WIIMOTE_BUTTON_ALL = 0x1F9F;
|
||||
|
||||
/**
|
||||
* Constructor of the wiimote button Event.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons held.
|
||||
*/
|
||||
public WiimoteButtonsEvent(int id, short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld) {
|
||||
super(id, buttonsJustPressed, buttonsJustReleased, buttonsHeld);
|
||||
}
|
||||
|
||||
/* Button ONE */
|
||||
|
||||
public boolean isButtonOneJustPressed() {
|
||||
return isButtonJustPressed(WIIMOTE_BUTTON_ONE);
|
||||
}
|
||||
|
||||
public boolean isButtonOneJustReleased() {
|
||||
return isButtonJustReleased(WIIMOTE_BUTTON_ONE);
|
||||
}
|
||||
|
||||
public boolean isButtonOneHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_ONE);
|
||||
}
|
||||
|
||||
public boolean isButtonOnePressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_ONE);
|
||||
}
|
||||
|
||||
/* Button TWO */
|
||||
|
||||
public boolean isButtonTwoJustPressed() {
|
||||
return isButtonJustPressed(WIIMOTE_BUTTON_TWO);
|
||||
}
|
||||
|
||||
public boolean isButtonTwoJustReleased() {
|
||||
return isButtonJustReleased(WIIMOTE_BUTTON_TWO);
|
||||
}
|
||||
|
||||
public boolean isButtonTwoHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_TWO);
|
||||
}
|
||||
|
||||
public boolean isButtonTwoPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_TWO);
|
||||
}
|
||||
|
||||
/* Button A */
|
||||
|
||||
public boolean isButtonAJustPressed() {
|
||||
return isButtonJustPressed(WIIMOTE_BUTTON_A);
|
||||
}
|
||||
|
||||
public boolean isButtonAJustReleased() {
|
||||
return isButtonJustReleased(WIIMOTE_BUTTON_A);
|
||||
}
|
||||
|
||||
public boolean isButtonAHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_A);
|
||||
}
|
||||
|
||||
public boolean isButtonAPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_A);
|
||||
}
|
||||
|
||||
/* Button B */
|
||||
|
||||
public boolean isButtonBJustPressed() {
|
||||
return isButtonJustPressed(WIIMOTE_BUTTON_B);
|
||||
}
|
||||
|
||||
public boolean isButtonBJustReleased() {
|
||||
return isButtonJustReleased(WIIMOTE_BUTTON_B);
|
||||
}
|
||||
|
||||
public boolean isButtonBHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_B);
|
||||
}
|
||||
|
||||
public boolean isButtonBPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_B);
|
||||
}
|
||||
|
||||
/* Button LEFT */
|
||||
|
||||
public boolean isButtonLeftJustPressed() {
|
||||
return isButtonJustPressed(WIIMOTE_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
public boolean isButtonLeftJustReleased() {
|
||||
return isButtonJustReleased(WIIMOTE_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
public boolean isButtonLeftHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
public boolean isButtonLeftPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_LEFT);
|
||||
}
|
||||
|
||||
/* Button RIGHT */
|
||||
|
||||
public boolean isButtonRightJustPressed() {
|
||||
return isButtonJustPressed(WIIMOTE_BUTTON_RIGHT);
|
||||
}
|
||||
|
||||
public boolean isButtonRightJustReleased() {
|
||||
return isButtonJustReleased(WIIMOTE_BUTTON_RIGHT);
|
||||
}
|
||||
|
||||
public boolean isButtonRightHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_RIGHT);
|
||||
}
|
||||
|
||||
public boolean isButtonRightPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_RIGHT);
|
||||
}
|
||||
|
||||
/* Button UP */
|
||||
|
||||
public boolean isButtonUpJustPressed() {
|
||||
return isButtonJustPressed(WIIMOTE_BUTTON_UP);
|
||||
}
|
||||
|
||||
public boolean isButtonUpJustReleased() {
|
||||
return isButtonJustReleased(WIIMOTE_BUTTON_UP);
|
||||
}
|
||||
|
||||
public boolean isButtonUpHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_UP);
|
||||
}
|
||||
|
||||
public boolean isButtonUpPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_UP);
|
||||
}
|
||||
|
||||
/* Button DOWN */
|
||||
|
||||
public boolean isButtonDownJustPressed() {
|
||||
return isButtonJustPressed(WIIMOTE_BUTTON_DOWN);
|
||||
}
|
||||
|
||||
public boolean isButtonDownJustReleased() {
|
||||
return isButtonJustReleased(WIIMOTE_BUTTON_DOWN);
|
||||
}
|
||||
|
||||
public boolean isButtonDownHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_DOWN);
|
||||
}
|
||||
|
||||
public boolean isButtonDownPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_DOWN);
|
||||
}
|
||||
|
||||
/* Button - */
|
||||
|
||||
public boolean isButtonMinusJustPressed() {
|
||||
return isButtonJustPressed(WIIMOTE_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
public boolean isButtonMinusJustReleased() {
|
||||
return isButtonJustReleased(WIIMOTE_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
public boolean isButtonMinusHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
public boolean isButtonMinusPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_MINUS);
|
||||
}
|
||||
|
||||
/* Button + */
|
||||
|
||||
public boolean isButtonPlusJustPressed() {
|
||||
return isButtonJustPressed(WIIMOTE_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
public boolean isButtonPlusJustReleased() {
|
||||
return isButtonJustReleased(WIIMOTE_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
public boolean isButtonPlusHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
public boolean isButtonPlusPressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_PLUS);
|
||||
}
|
||||
|
||||
/* Button HOME */
|
||||
|
||||
public boolean isButtonHomeJustPressed() {
|
||||
return isButtonJustPressed(WIIMOTE_BUTTON_HOME);
|
||||
}
|
||||
|
||||
public boolean isButtonHomeJustReleased() {
|
||||
return isButtonJustReleased(WIIMOTE_BUTTON_HOME);
|
||||
}
|
||||
|
||||
public boolean isButtonHomeHeld() {
|
||||
return isButtonHeld(WIIMOTE_BUTTON_HOME);
|
||||
}
|
||||
|
||||
public boolean isButtonHomePressed() {
|
||||
return isButtonPressed(WIIMOTE_BUTTON_HOME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "/******** Buttons for Wiimote generic Event ********/\n"
|
||||
+ super.toString();
|
||||
}
|
||||
|
||||
}
|
||||
529
src/main/java/wiiusej/wiiusejevents/utils/EventsGatherer.java
Normal file
529
src/main/java/wiiusej/wiiusejevents/utils/EventsGatherer.java
Normal file
@@ -0,0 +1,529 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.utils;
|
||||
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.WiimoteEvent;
|
||||
|
||||
/**
|
||||
* This class is used to gather events during a call to the Wiiuse API.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class EventsGatherer {
|
||||
|
||||
private WiiUseApiEvent[] events;
|
||||
private int index = 0;
|
||||
private WiimoteEvent genericEvent = null;
|
||||
|
||||
/**
|
||||
* Create EventsGatherer.
|
||||
*
|
||||
* @param nbWiimotes
|
||||
* nb wiimotes (nb a of events possible in a call to Wiiuse API).
|
||||
*/
|
||||
public EventsGatherer(int nbWiimotes) {
|
||||
events = new WiiUseApiEvent[nbWiimotes];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an event to the array.
|
||||
*
|
||||
* @param e
|
||||
* the event to add.
|
||||
*/
|
||||
private void addEvent(WiiUseApiEvent e) {
|
||||
events[index] = e;
|
||||
index++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare a wiimote event to add.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons held.
|
||||
*/
|
||||
public void prepareWiiMoteEvent(int id, short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld) {
|
||||
genericEvent = new WiimoteEvent(id, buttonsJustPressed,
|
||||
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.
|
||||
* @param irSensitivity
|
||||
* Sensitivity of the infrared camera.
|
||||
* @param distance
|
||||
* Pixel Distance between first two dots.
|
||||
*/
|
||||
public void prepareIRevent(int x, int y, float z, int ax, int ay,
|
||||
int xVRes, int yVRes, int xOffset, int yOffset,
|
||||
short sensorBarPostion, short screenAsPectRatio,
|
||||
short irSensitivity, float distance) {
|
||||
genericEvent.prepareIRevent(x, y, z, ax, ay, xVRes, yVRes, xOffset,
|
||||
yOffset, sensorBarPostion, screenAsPectRatio, irSensitivity,
|
||||
distance);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an IR point to the WiiMoteEvent prepared.
|
||||
*
|
||||
* @param x
|
||||
* x coordinates.
|
||||
* @param y
|
||||
* y coordinates.
|
||||
* @param rx
|
||||
* raw X coordinate (0-1023).
|
||||
* @param ry
|
||||
* raw Y coordinate (0-1023).
|
||||
* @param size
|
||||
* size of the IR dot (0-15).
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
public void addMotionSensingValues(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) {
|
||||
if (genericEvent != null) {
|
||||
genericEvent.setMotionSensingEvent(orientationThreshold,
|
||||
accelerationThreshold, smoothingState, alphaSmooth, r, p,
|
||||
ya, ar, ap, x, y, z, xx, yy, zz);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a NunchukEvent to the prepared WiimoteEvent.
|
||||
*
|
||||
* @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,
|
||||
float angle, float 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a GuitarHeroEvent to the prepared WiimoteEvent.
|
||||
*
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons just pressed.
|
||||
* @param whammyBar
|
||||
* whammy bar (range 0-1).
|
||||
* @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 addGuitarHeroEventToPreparedWiimoteEvent(
|
||||
short buttonsJustPressed, short buttonsJustReleased,
|
||||
short buttonsHeld, float whammyBar, float angle, float magnitude,
|
||||
short max1, short max2, short min1, short min2, short center1,
|
||||
short center2) {
|
||||
if (genericEvent != null) {
|
||||
genericEvent.setGuitarHeroEvent(buttonsJustPressed,
|
||||
buttonsJustReleased, buttonsHeld, whammyBar, angle,
|
||||
magnitude, max1, max2, min1, min2, center1, center2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a ClassicControllerEvent to the prepared WiimoteEvent.
|
||||
*
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons just pressed.
|
||||
* @param rightShoulder
|
||||
* right shoulder button (range 0-1).
|
||||
* @param leftShoulder
|
||||
* left shoulder button (range 0-1).
|
||||
* @param langle
|
||||
* angle the left joystick is being held.
|
||||
* @param lmagnitude
|
||||
* magnitude of the left joystick (range 0-1).
|
||||
* @param lmax1
|
||||
* maximum left joystick value 1.
|
||||
* @param lmax2
|
||||
* maximum left joystick value 2.
|
||||
* @param lmin1
|
||||
* minimum left joystick value 1.
|
||||
* @param lmin2
|
||||
* minimum left joystick value 2.
|
||||
* @param lcenter1
|
||||
* center left joystick value 1.
|
||||
* @param lcenter2
|
||||
* center left joystick value 2.
|
||||
* @param rangle
|
||||
* angle the right joystick is being held.
|
||||
* @param rmagnitude
|
||||
* magnitude of the right joystick (range 0-1).
|
||||
* @param rmax1
|
||||
* maximum right joystick value 1.
|
||||
* @param rmax2
|
||||
* maximum right joystick value 2.
|
||||
* @param rmin1
|
||||
* minimum right joystick value 1.
|
||||
* @param rmin2
|
||||
* minimum right joystick value 2.
|
||||
* @param rcenter1
|
||||
* center right joystick value 1.
|
||||
* @param rcenter2
|
||||
* center right joystick value 2.
|
||||
*/
|
||||
public void addClassicControllerEventToPreparedWiimoteEvent(short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld, float rightShoulder,
|
||||
float leftShoulder, float langle, float lmagnitude, short lmax1,
|
||||
short lmax2, short lmin1, short lmin2, short lcenter1,
|
||||
short lcenter2, float rangle, float rmagnitude, short rmax1,
|
||||
short rmax2, short rmin1, short rmin2, short rcenter1,
|
||||
short rcenter2) {
|
||||
if (genericEvent != null) {
|
||||
genericEvent.setClassicControllerEvent(buttonsJustPressed,
|
||||
buttonsJustReleased, buttonsHeld, rightShoulder,
|
||||
leftShoulder, langle, lmagnitude, lmax1, lmax2, lmin1,
|
||||
lmin2, lcenter1, lcenter2, rangle, rmagnitude, rmax1,
|
||||
rmax2, rmin1, rmin2, rcenter1, rcenter2);
|
||||
}
|
||||
}
|
||||
|
||||
public void addBalanceBoardEventToPreparedWiimoteEvent(float topRight,
|
||||
float bottomRight, float bottomLeft, float topLeft) {
|
||||
if (genericEvent != null) {
|
||||
genericEvent.setBalanceBoardEvent(topRight, bottomRight,
|
||||
bottomLeft, topLeft);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the prepared WiimoteEvent to the gatherer.
|
||||
*/
|
||||
public void addWiimoteEvent() {
|
||||
if (genericEvent != null) {
|
||||
addEvent(genericEvent);
|
||||
genericEvent = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a StatusEvent to the gatherer.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
* @param connect
|
||||
* true if the wiimote is connected.
|
||||
* @param batt
|
||||
* battery level.
|
||||
* @param led
|
||||
* status of leds.
|
||||
* @param speak
|
||||
* speakers status.
|
||||
* @param attach
|
||||
* attachment status.
|
||||
* @param rumbleState
|
||||
* true if rumble is active.
|
||||
* @param continuousState
|
||||
* true if continuous flag is activated.
|
||||
* @param irState
|
||||
* true if ir is active.
|
||||
* @param motionSensingState
|
||||
* true if accelerometer is active.
|
||||
*/
|
||||
public void addStatusEvent(int id, boolean connect, float batt, short led,
|
||||
boolean speak, int attach, boolean rumbleState,
|
||||
boolean continuousState, boolean irState, boolean motionSensingState) {
|
||||
StatusEvent evt = new StatusEvent(id, connect, batt, led, speak,
|
||||
attach, rumbleState, continuousState, irState,
|
||||
motionSensingState);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a DisconnectionEvent to the gatherer.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void addDisconnectionEvent(int id) {
|
||||
DisconnectionEvent evt = new DisconnectionEvent(id);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a NunchukInsertedEvent to the gatherer.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void addNunchukInsertedEvent(int id) {
|
||||
NunchukInsertedEvent evt = new NunchukInsertedEvent(id);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a NunchukRemovedEvent to the gatherer.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void addNunchukRemovedEvent(int id) {
|
||||
NunchukRemovedEvent evt = new NunchukRemovedEvent(id);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a GuitarHeroInsertedEvent to the gatherer.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void addGuitarHeroInsertedEvent(int id) {
|
||||
GuitarHeroInsertedEvent evt = new GuitarHeroInsertedEvent(id);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a GuitarHeroRemovedEvent to the gatherer.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void addGuitarHeroRemovedEvent(int id) {
|
||||
GuitarHeroRemovedEvent evt = new GuitarHeroRemovedEvent(id);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a ClassicControllerInsertedEvent to the gatherer.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void addClassicControllerInsertedEvent(int id) {
|
||||
ClassicControllerInsertedEvent evt = new ClassicControllerInsertedEvent(
|
||||
id);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a ClassicControllerRemovedEvent to the gatherer.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void addClassicControllerRemovedEvent(int id) {
|
||||
ClassicControllerRemovedEvent evt = new ClassicControllerRemovedEvent(
|
||||
id);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
public void addBalanceBoardInsertedEvent(int id) {
|
||||
BalanceBoardInsertedEvent evt = new BalanceBoardInsertedEvent(id);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
public void addBalanceBoardRemovedEvent(int id) {
|
||||
BalanceBoardRemovedEvent evt = new BalanceBoardRemovedEvent(id);
|
||||
addEvent(evt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array containing the events.
|
||||
*
|
||||
* @return events received.
|
||||
*/
|
||||
public WiiUseApiEvent[] getEvents() {
|
||||
WiiUseApiEvent[] ev = new WiiUseApiEvent[index];
|
||||
System.arraycopy(events, 0, ev, 0, index);
|
||||
return ev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the gatherer and remove objects.
|
||||
*/
|
||||
public void clearEvents() {
|
||||
for (int i = 0; i < events.length; i++) {
|
||||
events[i] = null;
|
||||
}
|
||||
genericEvent = null;
|
||||
index = 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.utils;
|
||||
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
|
||||
|
||||
/**
|
||||
* This is the interface to implement to listen to events from the wiiuse API.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public interface WiiUseApiListener extends java.util.EventListener {
|
||||
|
||||
/**
|
||||
* Method called when a WiiUseApiEvent occurs. A WiiUseApiEvent can be : -
|
||||
* WiimoteEvent (Storing ButtonsEvent and eventually IREvent and
|
||||
* MotionSensingEvent) - StatusEvent - DisconnectionEvent
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
void onWiiUseApiEvent(WiiUseApiEvent e);
|
||||
|
||||
}
|
||||
149
src/main/java/wiiusej/wiiusejevents/utils/WiimoteListener.java
Normal file
149
src/main/java/wiiusej/wiiusejevents/utils/WiimoteListener.java
Normal file
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.utils;
|
||||
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.BalanceBoardRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
|
||||
/**
|
||||
* This is the interface to implement to listen to events from wiimotes. The
|
||||
* differents methods are called in this order : onButtonsEvent, onIrEvent,
|
||||
* onMotionSensingEvent, onExpansionEvent, onStatusEvent, onDisconnectionEvent
|
||||
* onNunchukInsertedEvent, onNunchukRemovedEvent.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public interface WiimoteListener extends java.util.EventListener {
|
||||
|
||||
/**
|
||||
* Method called on a button Event.
|
||||
*
|
||||
* @param e
|
||||
* the buttonEvent with the last informations about the buttons
|
||||
* of the wiimote.
|
||||
*/
|
||||
void onButtonsEvent(WiimoteButtonsEvent e);
|
||||
|
||||
/**
|
||||
* Method called when an IR event occurs.
|
||||
*
|
||||
* @param e
|
||||
* the IREvent with the IR points seen.
|
||||
*/
|
||||
void onIrEvent(IREvent e);
|
||||
|
||||
/**
|
||||
* Method called when a motion sensing event occurs.
|
||||
*
|
||||
* @param e
|
||||
* the motion sensing event with orientation and acceleration.
|
||||
*/
|
||||
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 : - we ask it -
|
||||
* an expansion controller has been plugged - an expansion controller has
|
||||
* been unplugged This is where you can get the different values of the
|
||||
* parameters setup on your wiimote.
|
||||
*
|
||||
* @param e
|
||||
* the status event.
|
||||
*/
|
||||
void onStatusEvent(StatusEvent e);
|
||||
|
||||
/**
|
||||
* This is the method called when a disconnection event occurs. A
|
||||
* disconnection event happens when : - there are no battery left - the
|
||||
* wiimote has just been turned off - the connection is dropped
|
||||
*
|
||||
* @param e
|
||||
* the disconnection event.
|
||||
*/
|
||||
void onDisconnectionEvent(DisconnectionEvent e);
|
||||
|
||||
/**
|
||||
* This is the method called when a NunchukInsertedEvent occurs.
|
||||
*
|
||||
* @param e
|
||||
* the NunchukInsertedEvent.
|
||||
*/
|
||||
void onNunchukInsertedEvent(NunchukInsertedEvent e);
|
||||
|
||||
/**
|
||||
* This is the method called when a NunchukRemovedEvent occurs.
|
||||
*
|
||||
* @param e
|
||||
* the NunchukRemovedEvent.
|
||||
*/
|
||||
void onNunchukRemovedEvent(NunchukRemovedEvent e);
|
||||
|
||||
|
||||
/**
|
||||
* This is the method called when a GuitarHeroInsertedEvent occurs.
|
||||
*
|
||||
* @param e
|
||||
* the GuitarHeroInsertedEvent.
|
||||
*/
|
||||
void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e);
|
||||
|
||||
/**
|
||||
* This is the method called when a GuitarHeroRemovedEvent occurs.
|
||||
*
|
||||
* @param e
|
||||
* the GuitarHeroRemovedEvent.
|
||||
*/
|
||||
void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e);
|
||||
|
||||
/**
|
||||
* This is the method called when a ClassicControllerInsertedEvent occurs.
|
||||
*
|
||||
* @param e
|
||||
* the ClassicControllerInsertedEvent.
|
||||
*/
|
||||
void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent e);
|
||||
|
||||
/**
|
||||
* This is the method called when a ClassicControllerRemovedEvent occurs.
|
||||
*
|
||||
* @param e
|
||||
* the ClassicControllerRemovedEvent.
|
||||
*/
|
||||
void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e);
|
||||
|
||||
void onBalanceBoardInsertedEvent(BalanceBoardInsertedEvent e);
|
||||
void onBalanceBoardRemovedEvent(BalanceBoardRemovedEvent e);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
public class BalanceBoardInsertedEvent extends WiiUseApiEvent {
|
||||
public BalanceBoardInsertedEvent(int id) {
|
||||
super(id, WIIUSE_BALANCE_BOARD_CTRL_INSERTED);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** BALANCE BOARD INSERTED EVENT : WIIMOTE ID :"
|
||||
+ super.getWiimoteId() + " ********/\n";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
|
||||
|
||||
public class BalanceBoardRemovedEvent extends WiiUseApiEvent {
|
||||
public BalanceBoardRemovedEvent(int id) {
|
||||
super(id, WIIUSE_BALANCE_BOARD_CTRL_REMOVED);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** BALANCE BOARD INSERTED EVENT : WIIMOTE ID :"
|
||||
+ super.getWiimoteId() + " ********/\n";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
/**
|
||||
* Event that represents the connection of a classic controller to a wiimote.
|
||||
*
|
||||
* @author guiguito
|
||||
*
|
||||
*/
|
||||
public class ClassicControllerInsertedEvent extends WiiUseApiEvent {
|
||||
|
||||
/**
|
||||
* Construct the ClassicControllerInsertedEvent setting up the id.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public ClassicControllerInsertedEvent(int id) {
|
||||
super(id, WIIUSE_CLASSIC_CTRL_INSERTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** CLASSIC CONTROLLER INSERTED EVENT : WIIMOTE ID :"
|
||||
+ super.getWiimoteId() + " ********/\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
/**
|
||||
* Event that represents the disconnection of a classic controller from a
|
||||
* wiimote.
|
||||
*
|
||||
* @author guiguito
|
||||
*
|
||||
*/
|
||||
public class ClassicControllerRemovedEvent extends WiiUseApiEvent {
|
||||
|
||||
/**
|
||||
* Construct the ClassicControllerRemovedEvent setting up the id.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public ClassicControllerRemovedEvent(int id) {
|
||||
super(id, WIIUSE_CLASSIC_CTRL_REMOVED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** CLASSIC CONTROLLER REMOVED EVENT : WIIMOTE ID :"
|
||||
+ super.getWiimoteId() + " ********/\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
/**
|
||||
* Class representing a disconnection event.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class DisconnectionEvent extends WiiUseApiEvent {
|
||||
|
||||
/**
|
||||
* Construct the DisconnectionEvent setting up the id.
|
||||
*
|
||||
* @param id
|
||||
* the Wiimote id
|
||||
*/
|
||||
public DisconnectionEvent(int id) {
|
||||
super(id, WiiUseApiEvent.DISCONNECTION_EVENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :"
|
||||
+ super.getWiimoteId() + " ********/\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
/**
|
||||
* Event that represents the connection of a Guitar hero controller to a
|
||||
* wiimote.
|
||||
*
|
||||
* @author guiguito
|
||||
*
|
||||
*/
|
||||
public class GuitarHeroInsertedEvent extends WiiUseApiEvent {
|
||||
|
||||
/**
|
||||
* Construct the GuitarHeroInsertedEvent setting up the id.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public GuitarHeroInsertedEvent(int id) {
|
||||
super(id, WIIUSE_GUITAR_HERO_3_CTRL_INSERTED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** GUITAR HERO INSERTED EVENT : WIIMOTE ID :"
|
||||
+ super.getWiimoteId() + " ********/\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
/**
|
||||
* Event that represents the disconnection of a guitar hero controller from a
|
||||
* wiimote.
|
||||
*
|
||||
* @author guiguito
|
||||
*
|
||||
*/
|
||||
public class GuitarHeroRemovedEvent extends WiiUseApiEvent {
|
||||
|
||||
/**
|
||||
* Construct the GuitarHeroRemovedEvent setting up the id.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public GuitarHeroRemovedEvent(int id) {
|
||||
super(id, WIIUSE_GUITAR_HERO_3_CTRL_REMOVED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** GUITAR HERO REMOVED EVENT : WIIMOTE ID :"
|
||||
+ super.getWiimoteId() + " ********/\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
/**
|
||||
* Event that represents the connection of a nunchuk to a wiimote.
|
||||
*
|
||||
* @author guiguito
|
||||
*
|
||||
*/
|
||||
public class NunchukInsertedEvent extends WiiUseApiEvent {
|
||||
|
||||
/**
|
||||
* Construct the NunchukInsertedEvent setting up the id.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public NunchukInsertedEvent(int id) {
|
||||
super(id, WIIUSE_NUNCHUK_INSERTED);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see wiiusej.wiiusejevents.WiiUseApiEvent#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** NUNCHUK INSERTED EVENT : WIIMOTE ID :"
|
||||
+ super.getWiimoteId() + " ********/\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
/**
|
||||
* Event that represents the disconnection of a nunchuk from a wiimote.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class NunchukRemovedEvent extends WiiUseApiEvent {
|
||||
|
||||
/**
|
||||
* Construct the NunchukInsertedEvent setting up the id.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public NunchukRemovedEvent(int id) {
|
||||
super(id, WIIUSE_NUNCHUK_REMOVED);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see wiiusej.wiiusejevents.WiiUseApiEvent#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** NUNCHUK REMOVED EVENT : WIIMOTE ID :"
|
||||
+ super.getWiimoteId() + " ********/\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
|
||||
protected static short WIIMOTE_LED_1 = 1;
|
||||
protected static short WIIMOTE_LED_2 = 2;
|
||||
protected static short WIIMOTE_LED_3 = 4;
|
||||
protected 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;
|
||||
private static short EXP_GUITAR_HERO_3 = 3;
|
||||
|
||||
/* Status variables */
|
||||
private boolean connected = false;
|
||||
|
||||
private float batteryLevel = -1;
|
||||
|
||||
private short leds = 0;
|
||||
|
||||
private boolean isSpeakerEnabled = false;
|
||||
|
||||
private int attachment = 0;
|
||||
|
||||
private boolean isRumbleActive = false;
|
||||
|
||||
private boolean isContinuousActive = false;
|
||||
|
||||
private boolean isIrActive = false;
|
||||
|
||||
private boolean isMotionSensingActive = false;
|
||||
|
||||
/**
|
||||
* Construct the StatusEvent setting up the id.
|
||||
*
|
||||
* @param id
|
||||
* the Wiimote id
|
||||
*/
|
||||
public StatusEvent(int id) {
|
||||
super(id, WiiUseApiEvent.STATUS_EVENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a StatusEvent with all fields set.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* @param connect
|
||||
* true if the wiimote is connected
|
||||
* @param batt
|
||||
* battery level
|
||||
* @param led
|
||||
* status of leds
|
||||
* @param speak
|
||||
* speakers status
|
||||
* @param attach
|
||||
* attachment status
|
||||
* @param rumbleState
|
||||
* true if rumble is active
|
||||
* @param continuousState
|
||||
* true if continuous flag is activated
|
||||
* @param irState
|
||||
* true if ir is active
|
||||
* @param motionSensingState
|
||||
* true if accelerometer is active
|
||||
*/
|
||||
public StatusEvent(int id, boolean connect, float batt, short led,
|
||||
boolean speak, int attach, boolean rumbleState,
|
||||
boolean continuousState, boolean irState, boolean motionSensingState) {
|
||||
super(id, WiiUseApiEvent.STATUS_EVENT);
|
||||
connected = connect;
|
||||
this.batteryLevel = batt;
|
||||
this.leds = led;
|
||||
this.isSpeakerEnabled = speak;
|
||||
this.attachment = attach;
|
||||
isRumbleActive = rumbleState;
|
||||
isContinuousActive = continuousState;
|
||||
isIrActive = irState;
|
||||
isMotionSensingActive = motionSensingState;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if the wiimote is connected false otherwise.
|
||||
*
|
||||
* @return return the connected status.
|
||||
*/
|
||||
public boolean isConnected() {
|
||||
return connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get battery level.
|
||||
*
|
||||
* @return battery level. 1 = 100%
|
||||
*/
|
||||
public float getBatteryLevel() {
|
||||
return batteryLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get status of the leds .
|
||||
*
|
||||
* @return a short representing LEDS turned on.
|
||||
*/
|
||||
public short getLeds() {
|
||||
return leds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if the given led is turned on according to the leds status int.
|
||||
*
|
||||
* @param led
|
||||
* the int encoding a led.
|
||||
* @return true if the led is turned on false otherwise.
|
||||
*/
|
||||
private boolean ledStatusCheck(short led) {
|
||||
if ((leds & led) > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get led1 status.
|
||||
*
|
||||
* @return true if the led is set.
|
||||
*/
|
||||
public boolean isLed1Set() {
|
||||
return ledStatusCheck(WIIMOTE_LED_1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get led2 status.
|
||||
*
|
||||
* @return true if the led is set.
|
||||
*/
|
||||
public boolean isLed2Set() {
|
||||
return ledStatusCheck(WIIMOTE_LED_2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get led3 status.
|
||||
*
|
||||
* @return true if the led is set.
|
||||
*/
|
||||
public boolean isLed3Set() {
|
||||
return ledStatusCheck(WIIMOTE_LED_3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get led4 status.
|
||||
*
|
||||
* @return true if the led is set.
|
||||
*/
|
||||
public boolean isLed4Set() {
|
||||
return ledStatusCheck(WIIMOTE_LED_4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the speaker is enable for this wiimote
|
||||
*
|
||||
* @return TRUE if it enabled false otherwise
|
||||
*/
|
||||
public boolean isSpeakerEnabled() {
|
||||
return isSpeakerEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the int representing the attachment type.
|
||||
*
|
||||
* @return value of the Attachment Type
|
||||
*/
|
||||
public int getAttachment() {
|
||||
return attachment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status of rumble.
|
||||
*
|
||||
* @return true if the rumble is active false otherwise
|
||||
*/
|
||||
public boolean isRumbleActive() {
|
||||
return isRumbleActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the CONTINUOUS option is activated.
|
||||
*
|
||||
* @return the isContinuousActive
|
||||
*/
|
||||
public boolean isContinuousActive() {
|
||||
return isContinuousActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if the IR Tracking is active.
|
||||
*
|
||||
* @return TRUE if it is active or false otherwise.
|
||||
*/
|
||||
public boolean isIrActive() {
|
||||
return isIrActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the flag indicating if the motion sensing is active.
|
||||
*
|
||||
* @return true if the motion sensing is active false otherwise
|
||||
*/
|
||||
public boolean isMotionSensingActive() {
|
||||
return isMotionSensingActive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if an attachment is connected.
|
||||
*
|
||||
* @return true if anything is connected to the wiimote false otherwise.
|
||||
*/
|
||||
public boolean isAttachmentConnected() {
|
||||
return attachment == EXP_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if a nunchuk is connected.
|
||||
*
|
||||
* @return true if a nunchuk is connected to the wiimote false otherwise.
|
||||
*/
|
||||
public boolean isNunchukConnected() {
|
||||
return attachment == EXP_NUNCHUK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if a classic controller is connected.
|
||||
*
|
||||
* @return true if a classic controller is connected to the wiimote false otherwise.
|
||||
*/
|
||||
public boolean isClassicControllerConnected() {
|
||||
return attachment == EXP_CLASSIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if a guitar hero controller is connected.
|
||||
*
|
||||
* @return true if a guitar hero controllerr is connected to the wiimote false otherwise.
|
||||
*/
|
||||
public boolean isGuitarHeroConnected() {
|
||||
return attachment == EXP_GUITAR_HERO_3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** STATUS EVENT : WIIMOTE ID :"
|
||||
+ super.getWiimoteId() + " ********/\n";
|
||||
out += "--- connected : " + connected + "\n";
|
||||
out += "--- Battery level : " + batteryLevel + "\n";
|
||||
out += "--- Leds : " + leds + "\n";
|
||||
out += "--- Speaker enabled : " + isSpeakerEnabled + "\n";
|
||||
out += "--- Attachment ? : " + attachment + "\n";
|
||||
out += "--- Rumble ? : " + isRumbleActive + "\n";
|
||||
out += "--- Continuous ? : " + isContinuousActive + "\n";
|
||||
out += "--- IR active ? : " + isIrActive + "\n";
|
||||
out += "--- Motion sensing active ? : " + isMotionSensingActive + "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
import wiiusej.wiiusejevents.GenericEvent;
|
||||
|
||||
/**
|
||||
* This class describes the structure of an event from the WiiUse API event.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public abstract class WiiUseApiEvent extends GenericEvent{
|
||||
public static int NONE_EVENT = 0;
|
||||
public static int GENERIC_EVENT = 1;
|
||||
public static int STATUS_EVENT = 2;
|
||||
public static int DISCONNECTION_EVENT = 3;
|
||||
public static int WIIUSE_READ_DATA = 4;
|
||||
public static int WIIUSE_NUNCHUK_INSERTED = 5;
|
||||
public static int WIIUSE_NUNCHUK_REMOVED = 6;
|
||||
public static int WIIUSE_CLASSIC_CTRL_INSERTED = 7;
|
||||
public static int WIIUSE_CLASSIC_CTRL_REMOVED = 8;
|
||||
public static int WIIUSE_GUITAR_HERO_3_CTRL_INSERTED = 9;
|
||||
public static int WIIUSE_GUITAR_HERO_3_CTRL_REMOVED = 10;
|
||||
public static int WIIUSE_BALANCE_BOARD_CTRL_INSERTED = 11;
|
||||
public static int WIIUSE_BALANCE_BOARD_CTRL_REMOVED = 12;
|
||||
|
||||
/* Event Type */
|
||||
private int eventType;
|
||||
|
||||
/**
|
||||
* Construct the WiiUseApiEvent setting up the id.
|
||||
*
|
||||
* @param id
|
||||
* the Wiimote id
|
||||
* @param type
|
||||
* type of the event
|
||||
*/
|
||||
public WiiUseApiEvent(int id, int type) {
|
||||
super(id);
|
||||
eventType = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event type.
|
||||
* @return the eventType
|
||||
*/
|
||||
public int getEventType() {
|
||||
return eventType;
|
||||
}
|
||||
|
||||
public abstract String toString();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,447 @@
|
||||
/**
|
||||
* This file is part of WiiuseJ.
|
||||
*
|
||||
* WiiuseJ is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* WiiuseJ is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with WiiuseJ. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
|
||||
import wiiusej.wiiusejevents.physicalevents.BalanceBoardEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.ClassicControllerEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
|
||||
/**
|
||||
* Class that is a bean to be filled by the wiiuse API on an event that occurs
|
||||
* on a wiimote.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class WiimoteEvent extends WiiUseApiEvent {
|
||||
|
||||
private WiimoteButtonsEvent buttonsEvent = null;
|
||||
private IREvent infraredEvent = null;
|
||||
private MotionSensingEvent motionSensingEvent = null;
|
||||
private ExpansionEvent expansionEvent = null;
|
||||
|
||||
/**
|
||||
* Construct the Wiimote setting up the id.
|
||||
*
|
||||
* @param id
|
||||
* the Wiimote id
|
||||
*/
|
||||
public WiimoteEvent(int id) {
|
||||
super(id, WiiUseApiEvent.GENERIC_EVENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the Wiimote setting up the id and the buttons.
|
||||
*
|
||||
* @param id
|
||||
* the Wiimote id
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released
|
||||
* @param buttonsHeld
|
||||
* buttons held
|
||||
*/
|
||||
public WiimoteEvent(int id, short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld) {
|
||||
super(id, WiiUseApiEvent.GENERIC_EVENT);
|
||||
buttonsEvent = new WiimoteButtonsEvent(id, buttonsJustPressed,
|
||||
buttonsJustReleased, buttonsHeld);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if there is an IR Event.
|
||||
*
|
||||
* @return TRUE if there is an IR event.
|
||||
*/
|
||||
public boolean isThereIrEvent() {
|
||||
return infraredEvent != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if there is a motion sensing Event.
|
||||
*
|
||||
* @return TRUE if there is a motion sensing event.
|
||||
*/
|
||||
public boolean isThereMotionSensingEvent() {
|
||||
return motionSensingEvent != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell if there is an expansion Event.
|
||||
*
|
||||
* @return TRUE if there is an expansion event.
|
||||
*/
|
||||
public boolean isThereExpansionEvent() {
|
||||
return expansionEvent != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get buttons event.
|
||||
*
|
||||
* @return the buttons event.
|
||||
*/
|
||||
public WiimoteButtonsEvent getButtonsEvent() {
|
||||
return buttonsEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the IR event.
|
||||
*
|
||||
* @return the IR event if there is one or null.
|
||||
*/
|
||||
public IREvent getIREvent() {
|
||||
return infraredEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the motion sensing event.
|
||||
*
|
||||
* @return the motion sensing event if there is one or null.
|
||||
*/
|
||||
public MotionSensingEvent getMotionSensingEvent() {
|
||||
return motionSensingEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the expansion event.
|
||||
*
|
||||
* @return the expansion event if there is one or null.
|
||||
*/
|
||||
public ExpansionEvent getExpansionEvent() {
|
||||
return expansionEvent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param irSensitivity
|
||||
* Sensitivity of the infrared camera.
|
||||
* @param distance
|
||||
* Pixel Distance between first two dots
|
||||
*/
|
||||
public void prepareIRevent(int x, int y, float z, int ax, int ay,
|
||||
int xVRes, int yVRes, int xOffset, int yOffset,
|
||||
short sensorBarPostion, short screenAsPectRatio,
|
||||
short irSensitivity, float distance) {
|
||||
if (infraredEvent == null) {
|
||||
infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes,
|
||||
yVRes, xOffset, yOffset, sensorBarPostion,
|
||||
screenAsPectRatio, irSensitivity, distance);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 rx
|
||||
* raw X coordinate (0-1023).
|
||||
* @param ry
|
||||
* raw Y coordinate (0-1023).
|
||||
* @param size
|
||||
* 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.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
public void setMotionSensingEvent(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) {
|
||||
motionSensingEvent = new MotionSensingEvent(getWiimoteId(),
|
||||
orientationThreshold, accelerationThreshold, smoothingState,
|
||||
alphaSmooth, r, p, ya, ar, ap, x, y, z, xx, yy, zz);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, float angle, float 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a ClassicControllerEvent for the expansionEvent.
|
||||
*
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons just pressed.
|
||||
* @param rightShoulder
|
||||
* right shoulder button (range 0-1).
|
||||
* @param leftShoulder
|
||||
* left shoulder button (range 0-1).
|
||||
* @param langle
|
||||
* angle the left joystick is being held.
|
||||
* @param lmagnitude
|
||||
* magnitude of the left joystick (range 0-1).
|
||||
* @param lmax1
|
||||
* maximum left joystick value 1.
|
||||
* @param lmax2
|
||||
* maximum left joystick value 2.
|
||||
* @param lmin1
|
||||
* minimum left joystick value 1.
|
||||
* @param lmin2
|
||||
* minimum left joystick value 2.
|
||||
* @param lcenter1
|
||||
* center left joystick value 1.
|
||||
* @param lcenter2
|
||||
* center left joystick value 2.
|
||||
* @param rangle
|
||||
* angle the right joystick is being held.
|
||||
* @param rmagnitude
|
||||
* magnitude of the right joystick (range 0-1).
|
||||
* @param rmax1
|
||||
* maximum right joystick value 1.
|
||||
* @param rmax2
|
||||
* maximum right joystick value 2.
|
||||
* @param rmin1
|
||||
* minimum right joystick value 1.
|
||||
* @param rmin2
|
||||
* minimum right joystick value 2.
|
||||
* @param rcenter1
|
||||
* center right joystick value 1.
|
||||
* @param rcenter2
|
||||
* center right joystick value 2.
|
||||
*/
|
||||
public void setClassicControllerEvent(short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld, float rightShoulder,
|
||||
float leftShoulder, float langle, float lmagnitude, short lmax1,
|
||||
short lmax2, short lmin1, short lmin2, short lcenter1,
|
||||
short lcenter2, float rangle, float rmagnitude, short rmax1,
|
||||
short rmax2, short rmin1, short rmin2, short rcenter1,
|
||||
short rcenter2) {
|
||||
expansionEvent = new ClassicControllerEvent(getWiimoteId(),
|
||||
buttonsJustPressed, buttonsJustReleased, buttonsHeld,
|
||||
rightShoulder, leftShoulder, langle, lmagnitude, lmax1, lmax2,
|
||||
lmin1, lmin2, lcenter1, lcenter2, rangle, rmagnitude, rmax1,
|
||||
rmax2, rmin1, rmin2, rcenter1, rcenter2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a GuitarHeroEvent for the expansionEvent.
|
||||
*
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons just pressed.
|
||||
* @param whammyBar
|
||||
* whammy bar (range 0-1).
|
||||
* @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 setGuitarHeroEvent(short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld, float whammyBar,
|
||||
float angle, float magnitude, short max1, short max2, short min1,
|
||||
short min2, short center1, short center2) {
|
||||
expansionEvent = new GuitarHeroEvent(getWiimoteId(),
|
||||
buttonsJustPressed, buttonsJustReleased, buttonsHeld,
|
||||
whammyBar, angle, magnitude, max1, max2, min1, min2, center1,
|
||||
center2);
|
||||
}
|
||||
|
||||
public void setBalanceBoardEvent(float topRight, float bottomRight,
|
||||
float bottomLeft, float topLeft) {
|
||||
expansionEvent = new BalanceBoardEvent(getWiimoteId(), topRight,
|
||||
bottomRight, bottomLeft, topLeft);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
/* Status */
|
||||
out += "/*********** GENERIC EVENT : WIIMOTE ID :" + getWiimoteId()
|
||||
+ " ********/\n";
|
||||
|
||||
out += buttonsEvent;
|
||||
|
||||
if (infraredEvent != null) {
|
||||
out += infraredEvent;
|
||||
} else {
|
||||
out += "/******** IR Tracking ********/\n";
|
||||
out += "--- Active : false\n";
|
||||
}
|
||||
|
||||
if (motionSensingEvent != null) {
|
||||
out += motionSensingEvent;
|
||||
} else {
|
||||
out += "/******** Motion sensing ********/\n";
|
||||
out += "--- Motion sensing : false \n";
|
||||
}
|
||||
|
||||
if (expansionEvent != null) {
|
||||
out += expansionEvent;
|
||||
} else {
|
||||
out += "/******** Expansion ********/\n";
|
||||
out += "--- No expansion connected \n";
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user