0.12 going well. Added everything for the nunchuk. Need more testing.
git-svn-id: http://wiiusej.googlecode.com/svn/trunk@141 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
@@ -144,15 +144,15 @@ public class WiiUseApi {
|
||||
* Set wiimote leds status.
|
||||
*
|
||||
* @param id
|
||||
* the id of the wiimote concerned
|
||||
* the id of the wiimote concerned.
|
||||
* @param led1
|
||||
* status of led1: True=ON, False=OFF
|
||||
* status of led1: True=ON, False=OFF.
|
||||
* @param led2
|
||||
* status of led2: True=ON, False=OFF
|
||||
* status of led2: True=ON, False=OFF.
|
||||
* @param led3
|
||||
* status of led3: True=ON, False=OFF
|
||||
* status of led3: True=ON, False=OFF.
|
||||
* @param led4
|
||||
* status of led4: True=ON, False=OFF
|
||||
* status of led4: True=ON, False=OFF.
|
||||
*/
|
||||
synchronized native void setLeds(int id, boolean led1, boolean led2,
|
||||
boolean led3, boolean led4);
|
||||
@@ -161,9 +161,9 @@ public class WiiUseApi {
|
||||
* Set how many degrees an angle must change to generate an event.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote concerned
|
||||
* id of the wiimote concerned.
|
||||
* @param angle
|
||||
* minimum angle detected by an event
|
||||
* minimum angle detected by an event.
|
||||
*/
|
||||
synchronized native void setOrientThreshold(int id, float angle);
|
||||
|
||||
@@ -171,9 +171,9 @@ public class WiiUseApi {
|
||||
* Set how much acceleration must change to generate an event.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote concerned
|
||||
* id of the wiimote concerned.
|
||||
* @param value
|
||||
* minimum value detected by an event
|
||||
* minimum value detected by an event.
|
||||
*/
|
||||
synchronized native void setAccelThreshold(int id, int value);
|
||||
|
||||
@@ -181,9 +181,9 @@ public class WiiUseApi {
|
||||
* Set alpha smoothing parameter for the given id.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote concerned
|
||||
* id of the wiimote concerned.
|
||||
* @param value
|
||||
* alpha smoothing value
|
||||
* alpha smoothing value.
|
||||
*/
|
||||
synchronized native void setAlphaSmoothing(int id, float value);
|
||||
|
||||
@@ -191,7 +191,7 @@ public class WiiUseApi {
|
||||
* Try to resync with the wiimote by starting a new handshake.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote concerned
|
||||
* id of the wiimote concerned.
|
||||
*/
|
||||
synchronized native void reSync(int id);
|
||||
|
||||
@@ -200,7 +200,7 @@ public class WiiUseApi {
|
||||
* default.
|
||||
*
|
||||
* @param id
|
||||
* the id of the wiimote concerned
|
||||
* the id of the wiimote concerned.
|
||||
*/
|
||||
synchronized native void activateSmoothing(int id);
|
||||
|
||||
@@ -208,7 +208,7 @@ public class WiiUseApi {
|
||||
* Make the the accelerometers give raw results.
|
||||
*
|
||||
* @param id
|
||||
* the id of the wiimote concerned
|
||||
* the id of the wiimote concerned.
|
||||
*/
|
||||
synchronized native void deactivateSmoothing(int id);
|
||||
|
||||
@@ -216,7 +216,7 @@ public class WiiUseApi {
|
||||
* Make the wiimote generate an event each time we poll. Not set by default.
|
||||
*
|
||||
* @param id
|
||||
* the id of the wiimote concerned
|
||||
* the id of the wiimote concerned.
|
||||
*/
|
||||
synchronized native void activateContinuous(int id);
|
||||
|
||||
@@ -224,7 +224,7 @@ public class WiiUseApi {
|
||||
* Make the wiimote generate an event only when there is one.
|
||||
*
|
||||
* @param id
|
||||
* the id of the wiimote concerned
|
||||
* the id of the wiimote concerned.
|
||||
*/
|
||||
synchronized native void deactivateContinuous(int id);
|
||||
|
||||
@@ -308,6 +308,27 @@ public class WiiUseApi {
|
||||
*/
|
||||
synchronized native void setIrSensitivity(int id, int level);
|
||||
|
||||
/**
|
||||
* Set how many degrees an angle must change to generate an event for the nunchuk.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote concerned.
|
||||
* @param angle
|
||||
* minimum angle detected by an event.
|
||||
*/
|
||||
synchronized native void setNunchukOrientationThreshold(int id, float angle);
|
||||
|
||||
/**
|
||||
* Set how much acceleration must change to generate an event for the nunchuk.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote concerned.
|
||||
* @param value
|
||||
* minimum value detected by an event.
|
||||
*/
|
||||
synchronized native void setNunchukAccelerationThreshold(int id, int value);
|
||||
|
||||
|
||||
/**
|
||||
* Check for new Events and Get it.
|
||||
*
|
||||
|
||||
@@ -54,9 +54,9 @@ public class WiiUseApiManager extends Thread {
|
||||
* wiimotes.
|
||||
*
|
||||
* @param nb
|
||||
* try to connect nb wiimotes
|
||||
* try to connect nb wiimotes.
|
||||
* @param rumble
|
||||
* make the connected wiimotes rumble
|
||||
* make the connected wiimotes rumble.
|
||||
* @return an array with connected wiimotes or NULL.
|
||||
*/
|
||||
public synchronized static Wiimote[] getWiimotes(int nb, boolean rumble) {
|
||||
@@ -277,7 +277,7 @@ public class WiiUseApiManager extends Thread {
|
||||
* Deactivate continuous for the wiimotes with the given id.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void deactivateContinuous(int id) {
|
||||
wiiuse.deactivateContinuous(id);
|
||||
@@ -289,13 +289,13 @@ public class WiiUseApiManager extends Thread {
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* @param l1
|
||||
* status of led1. True : ON, False : OFF
|
||||
* status of led1. True : ON, False : OFF.
|
||||
* @param l2
|
||||
* status of led2. True : ON, False : OFF
|
||||
* status of led2. True : ON, False : OFF.
|
||||
* @param l3
|
||||
* status of led3. True : ON, False : OFF
|
||||
* status of led3. True : ON, False : OFF.
|
||||
* @param l4
|
||||
* status of led4. True : ON, False : OFF
|
||||
* status of led4. True : ON, False : OFF.
|
||||
*/
|
||||
public void setLeds(int id, boolean l1, boolean l2, boolean l3, boolean l4) {
|
||||
wiiuse.setLeds(id, l1, l2, l3, l4);
|
||||
@@ -303,11 +303,12 @@ public class WiiUseApiManager extends Thread {
|
||||
|
||||
/**
|
||||
* Set the orientation threshold for the given id.
|
||||
* (minimum angle between two events)
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
* @param th
|
||||
* threshold in degrees
|
||||
* threshold in degrees.
|
||||
*/
|
||||
public void setOrientationThreshold(int id, float th) {
|
||||
wiiuse.setOrientThreshold(id, th);
|
||||
@@ -315,11 +316,12 @@ public class WiiUseApiManager extends Thread {
|
||||
|
||||
/**
|
||||
* Set the acceleration threshold for the given id.
|
||||
* (minimum angle between two events)
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
* @param th
|
||||
* threshold
|
||||
* threshold.
|
||||
*/
|
||||
public void setAccelerationThreshold(int id, int th) {
|
||||
wiiuse.setAccelThreshold(id, th);
|
||||
@@ -329,9 +331,9 @@ public class WiiUseApiManager extends Thread {
|
||||
* Set alpha smoothing for the given id.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
* @param th
|
||||
* threshold
|
||||
* threshold.
|
||||
*/
|
||||
public void setAlphaSmoothing(int id, float th) {
|
||||
wiiuse.setAlphaSmoothing(id, th);
|
||||
@@ -341,7 +343,7 @@ public class WiiUseApiManager extends Thread {
|
||||
* Try to resync with the wiimote by starting a new handshake.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void reSync(int id) {
|
||||
wiiuse.reSync(id);
|
||||
@@ -351,7 +353,7 @@ public class WiiUseApiManager extends Thread {
|
||||
* Set screen aspect ratio to 4/3 for the given id.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void setScreenAspectRatio43(int id) {
|
||||
wiiuse.setScreenRatio43(id);
|
||||
@@ -361,7 +363,7 @@ public class WiiUseApiManager extends Thread {
|
||||
* Set screen aspect ratio to 16/9 for the given id.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void setScreenAspectRatio169(int id) {
|
||||
wiiuse.setScreenRatio169(id);
|
||||
@@ -371,7 +373,7 @@ public class WiiUseApiManager extends Thread {
|
||||
* Set the sensor bar to be above the screen.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void setSensorBarAboveScreen(int id) {
|
||||
wiiuse.setSensorBarAboveScreen(id);
|
||||
@@ -381,7 +383,7 @@ public class WiiUseApiManager extends Thread {
|
||||
* Set the sensor bar to be below the screen.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void setSensorBarBelowScreen(int id) {
|
||||
wiiuse.setSensorBarBelowScreen(id);
|
||||
@@ -393,11 +395,11 @@ public class WiiUseApiManager extends Thread {
|
||||
* come in the IREvent.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
* @param x
|
||||
* x resolution
|
||||
* x resolution.
|
||||
* @param y
|
||||
* y resolution
|
||||
* y resolution.
|
||||
*/
|
||||
public void setVirtualResolution(int id, int x, int y) {
|
||||
wiiuse.setVirtualScreenResolution(id, x, y);
|
||||
@@ -407,7 +409,7 @@ public class WiiUseApiManager extends Thread {
|
||||
* Get Status for the wiimote for the given id.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void getStatus(int id) {
|
||||
wiiuse.getStatus(id);
|
||||
@@ -442,6 +444,32 @@ public class WiiUseApiManager extends Thread {
|
||||
wiiuse.setIrSensitivity(id, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the nunchuk orientation threshold for the given id.
|
||||
* (minimum angle between two events)
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
* @param th
|
||||
* threshold in degrees.
|
||||
*/
|
||||
public void setNunchukOrientationThreshold(int id, float th){
|
||||
wiiuse.setNunchukOrientationThreshold(id, th);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the nunchuk acceleration threshold for the given id.
|
||||
* (minimum angle between two events)
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
* @param th
|
||||
* threshold.
|
||||
*/
|
||||
public void setNunchukAccelerationThreshold(int id, int th){
|
||||
wiiuse.setNunchukAccelerationThreshold(id, th);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
|
||||
@@ -172,7 +172,8 @@ public class Wiimote implements WiiUseApiListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the acceleration threshold .
|
||||
* Set the acceleration threshold(minimum angle between two degrees with
|
||||
* accelerometer).
|
||||
*
|
||||
* @param th
|
||||
* threshold
|
||||
@@ -231,6 +232,28 @@ public class Wiimote implements WiiUseApiListener {
|
||||
manager.setVirtualResolution(id, x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the nunchuk orientation threshold for the given id.
|
||||
* (minimum angle between two events)
|
||||
*
|
||||
* @param th
|
||||
* threshold in degrees.
|
||||
*/
|
||||
public void setNunchukOrientationThreshold(float th){
|
||||
manager.setNunchukOrientationThreshold(id, th);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the nunchuk acceleration threshold for the given id.
|
||||
* (minimum angle between two events)
|
||||
*
|
||||
* @param th
|
||||
* threshold.
|
||||
*/
|
||||
public void setNunchukAccelerationThreshold(int th){
|
||||
manager.setNunchukAccelerationThreshold(id, th);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to resync the wiimote by starting a new handshake.
|
||||
*/
|
||||
@@ -336,6 +359,9 @@ public class Wiimote implements WiiUseApiListener {
|
||||
if (evt.isThereMotionSensingEvent()) {
|
||||
listener.onMotionSensingEvent(evt.getMotionSensingEvent());
|
||||
}
|
||||
if (evt.isThereExpansionEvent()){
|
||||
listener.onExpansionEvent(evt.getExpansionEvent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.awt.event.InputEvent;
|
||||
import wiiusej.WiiUseApiManager;
|
||||
import wiiusej.Wiimote;
|
||||
import wiiusej.values.IRSource;
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
@@ -326,6 +327,10 @@ public class Tests implements WiimoteListener {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent e) {
|
||||
// Display status variables
|
||||
System.out.println(e);
|
||||
|
||||
@@ -28,6 +28,7 @@ import wiiusej.utils.ButtonsEventPanel;
|
||||
import wiiusej.utils.GForcePanel;
|
||||
import wiiusej.utils.IRPanel;
|
||||
import wiiusej.utils.OrientationPanel;
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
@@ -125,6 +126,10 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
}
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
//nothing yet
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
messageText.setText("Status received !");
|
||||
batteryLevelText.setText(arg0.getBatteryLevel() + " %");
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.awt.geom.AffineTransform;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import wiiusej.values.RawAcceleration;
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
@@ -36,10 +37,13 @@ import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
|
||||
/**
|
||||
* This panel is used to watch raw acceleration values from a MotionSensingEvent.
|
||||
* This panel is used to watch raw acceleration values from a
|
||||
* MotionSensingEvent.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class AccelerationPanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
public class AccelerationPanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Color xColor = Color.RED;
|
||||
@@ -63,7 +67,8 @@ public class AccelerationPanel extends javax.swing.JPanel implements WiimoteList
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw medium line
|
||||
int yLine = getHeight() - 25;
|
||||
@@ -122,12 +127,14 @@ public class AccelerationPanel extends javax.swing.JPanel implements WiimoteList
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case it initializes it
|
||||
* with the dimensions of the panel. mImage is for double buffering.
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) {
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
@@ -150,6 +157,10 @@ public class AccelerationPanel extends javax.swing.JPanel implements WiimoteList
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
@@ -161,33 +172,30 @@ public class AccelerationPanel extends javax.swing.JPanel implements WiimoteList
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// nothing
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.awt.Toolkit;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
import wiiusej.wiiusejevents.physicalevents.ButtonsEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
@@ -37,11 +38,13 @@ import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
|
||||
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
|
||||
/**
|
||||
* This panel is used to see what buttons are pressed.
|
||||
* It displays the result of last ButtonsEvent.
|
||||
* This panel is used to see what buttons are pressed. It displays the result of
|
||||
* last ButtonsEvent.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class ButtonsEventPanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
public class ButtonsEventPanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Image wiimoteImage;// image for double buffering
|
||||
@@ -52,14 +55,13 @@ public class ButtonsEventPanel extends javax.swing.JPanel implements WiimoteList
|
||||
private Shape shape;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
* Red : button just pressed.
|
||||
* Orange : button held.
|
||||
* Default constructor. Red : button just pressed. Orange : button held.
|
||||
* Yellow : button just released.
|
||||
*/
|
||||
public ButtonsEventPanel() {
|
||||
Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
|
||||
java.net.URL url = ButtonsEventPanel.class.getResource("/img/wiimote.png");
|
||||
java.net.URL url = ButtonsEventPanel.class
|
||||
.getResource("/img/wiimote.png");
|
||||
wiimoteImage = toolkit.createImage(url);
|
||||
shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13);
|
||||
initComponents();
|
||||
@@ -67,12 +69,18 @@ public class ButtonsEventPanel extends javax.swing.JPanel implements WiimoteList
|
||||
|
||||
/**
|
||||
* Constructor used to set colors and shape used.
|
||||
* @param pressColor color of a button just pressed.
|
||||
* @param hColor color of a button held.
|
||||
* @param relColor color of a button just released.
|
||||
* @param sh shape draw on the buttons.
|
||||
*
|
||||
* @param pressColor
|
||||
* color of a button just pressed.
|
||||
* @param hColor
|
||||
* color of a button held.
|
||||
* @param relColor
|
||||
* color of a button just released.
|
||||
* @param sh
|
||||
* shape draw on the buttons.
|
||||
*/
|
||||
public ButtonsEventPanel(Color pressColor, Color hColor, Color relColor, Shape sh) {
|
||||
public ButtonsEventPanel(Color pressColor, Color hColor, Color relColor,
|
||||
Shape sh) {
|
||||
pressedColor = pressColor;
|
||||
heldColor = hColor;
|
||||
releasedColor = relColor;
|
||||
@@ -92,7 +100,8 @@ public class ButtonsEventPanel extends javax.swing.JPanel implements WiimoteList
|
||||
// offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw buttons pushed
|
||||
g2.drawImage(wiimoteImage, 0, 0, this);
|
||||
@@ -223,17 +232,21 @@ public class ButtonsEventPanel extends javax.swing.JPanel implements WiimoteList
|
||||
buttons = null;
|
||||
}
|
||||
|
||||
|
||||
// put offscreen image on the screen
|
||||
g.drawImage(mImage, 0, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to factorize code.
|
||||
* @param g2 where to draw a shape.
|
||||
* @param col color to use.
|
||||
* @param x x coordinates.
|
||||
* @param y y coordinates.
|
||||
*
|
||||
* @param g2
|
||||
* where to draw a shape.
|
||||
* @param col
|
||||
* color to use.
|
||||
* @param x
|
||||
* x coordinates.
|
||||
* @param y
|
||||
* y coordinates.
|
||||
*/
|
||||
private void drawFunction(Graphics2D g2, Color col, int x, int y) {
|
||||
g2.setPaint(col);
|
||||
@@ -244,12 +257,14 @@ public class ButtonsEventPanel extends javax.swing.JPanel implements WiimoteList
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case it initializes it
|
||||
* with the dimensions of the panel. mImage is for double buffering.
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) {
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
@@ -268,6 +283,10 @@ public class ButtonsEventPanel extends javax.swing.JPanel implements WiimoteList
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
@@ -278,33 +297,30 @@ public class ButtonsEventPanel extends javax.swing.JPanel implements WiimoteList
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// nothing
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.awt.geom.AffineTransform;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import wiiusej.values.GForce;
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
@@ -37,6 +38,7 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
|
||||
/**
|
||||
* This panel is used to watch gravity force values from a MotionSensingEvent.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class GForcePanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
@@ -58,13 +60,20 @@ public class GForcePanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the AccelerationPanel.
|
||||
* @param bgColor background color.
|
||||
* @param xxColor color of the acceleration on X axis.
|
||||
* @param yyColor color of the acceleration on Y axis.
|
||||
* @param zzColor color of the acceleration on Z axis.
|
||||
* @param lColor line color.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param xxColor
|
||||
* color of the acceleration on X axis.
|
||||
* @param yyColor
|
||||
* color of the acceleration on Y axis.
|
||||
* @param zzColor
|
||||
* color of the acceleration on Z axis.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public GForcePanel(Color bgColor, Color xxColor, Color yyColor, Color zzColor, Color lColor) {
|
||||
public GForcePanel(Color bgColor, Color xxColor, Color yyColor,
|
||||
Color zzColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
xColor = xxColor;
|
||||
yColor = yyColor;
|
||||
@@ -82,7 +91,8 @@ public class GForcePanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw medium line
|
||||
double yMiddleFloat = getHeight() / 2.0;
|
||||
@@ -142,12 +152,14 @@ public class GForcePanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case it initializes it
|
||||
* with the dimensions of the panel. mImage is for double buffering.
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) {
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
@@ -170,6 +182,10 @@ public class GForcePanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
@@ -181,33 +197,30 @@ public class GForcePanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// nothing
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.awt.RenderingHints;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
@@ -158,6 +159,10 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
//nothing
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
//nothing
|
||||
}
|
||||
@@ -173,13 +178,11 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// nothing
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.awt.geom.AffineTransform;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import wiiusej.values.Orientation;
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
@@ -37,9 +38,11 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
|
||||
/**
|
||||
* This panel is used to watch orientation values from a MotionSensingEvent.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class OrientationPanel extends javax.swing.JPanel implements WiimoteListener {
|
||||
public class OrientationPanel extends javax.swing.JPanel implements
|
||||
WiimoteListener {
|
||||
|
||||
private Image mImage;// image for double buffering
|
||||
private Color rollColor = Color.RED;
|
||||
@@ -50,11 +53,8 @@ public class OrientationPanel extends javax.swing.JPanel implements WiimoteListe
|
||||
private ArrayList<Orientation> values = new ArrayList<Orientation>();
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
* Background color : White.
|
||||
* Roll color : Red.
|
||||
* Pitch color : Green.
|
||||
* Yaw color : Blue.
|
||||
* Default constructor. Background color : White. Roll color : Red. Pitch
|
||||
* color : Green. Yaw color : Blue.
|
||||
*/
|
||||
public OrientationPanel() {
|
||||
initComponents();
|
||||
@@ -62,13 +62,20 @@ public class OrientationPanel extends javax.swing.JPanel implements WiimoteListe
|
||||
|
||||
/**
|
||||
* Constructor used to choose the colors used by the OrientationPanel.
|
||||
* @param bgColor background color.
|
||||
* @param rColor roll color.
|
||||
* @param pColor pitch color.
|
||||
* @param yColor yaw color.
|
||||
* @param lColor line color.
|
||||
*
|
||||
* @param bgColor
|
||||
* background color.
|
||||
* @param rColor
|
||||
* roll color.
|
||||
* @param pColor
|
||||
* pitch color.
|
||||
* @param yColor
|
||||
* yaw color.
|
||||
* @param lColor
|
||||
* line color.
|
||||
*/
|
||||
public OrientationPanel(Color bgColor, Color rColor, Color pColor, Color yColor, Color lColor) {
|
||||
public OrientationPanel(Color bgColor, Color rColor, Color pColor,
|
||||
Color yColor, Color lColor) {
|
||||
backgroundColor = bgColor;
|
||||
rollColor = rColor;
|
||||
pitchColor = pColor;
|
||||
@@ -86,7 +93,8 @@ public class OrientationPanel extends javax.swing.JPanel implements WiimoteListe
|
||||
offG.setColor(backgroundColor);
|
||||
offG.fillRect(0, 0, d.width, d.height);
|
||||
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
// draw medium line
|
||||
double yMiddleFloat = getHeight() / 2.0;
|
||||
@@ -146,12 +154,14 @@ public class OrientationPanel extends javax.swing.JPanel implements WiimoteListe
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the mImage variable has been initialized. If it's not the case it initializes it
|
||||
* with the dimensions of the panel. mImage is for double buffering.
|
||||
* check if the mImage variable has been initialized. If it's not the case
|
||||
* it initializes it with the dimensions of the panel. mImage is for double
|
||||
* buffering.
|
||||
*/
|
||||
private void checkOffScreenImage() {
|
||||
Dimension d = getSize();
|
||||
if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) {
|
||||
if (mImage == null || mImage.getWidth(null) != d.width
|
||||
|| mImage.getHeight(null) != d.height) {
|
||||
mImage = createImage(d.width, d.height);
|
||||
}
|
||||
}
|
||||
@@ -174,6 +184,10 @@ public class OrientationPanel extends javax.swing.JPanel implements WiimoteListe
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void onExpansionEvent(ExpansionEvent e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onStatusEvent(StatusEvent arg0) {
|
||||
// nothing
|
||||
}
|
||||
@@ -185,33 +199,30 @@ public class OrientationPanel extends javax.swing.JPanel implements WiimoteListe
|
||||
}
|
||||
|
||||
public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// nothing
|
||||
}
|
||||
|
||||
public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
// nothing
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated
|
||||
// Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setHorizontalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
|
||||
Short.MAX_VALUE));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
|
||||
Short.MAX_VALUE));
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@@ -124,7 +124,6 @@ public class JoystickEvent extends GenericEvent {
|
||||
String out = "";
|
||||
/* Display IR Tracking */
|
||||
out += "/******** Joystick ********/\n";
|
||||
out += "--- Active : true\n";
|
||||
out += "--- angle : " + angle + "\n";
|
||||
out += "--- magnitude : " + magnitude + "\n";
|
||||
out += "--- maximum values : " + max[0] + "," + max[1] + "\n";
|
||||
|
||||
@@ -45,36 +45,36 @@ public class MotionSensingEvent extends GenericEvent {
|
||||
* id of the wiimote concerned.
|
||||
* @param orientationThreshold
|
||||
* value of the minimum angle between two events with the
|
||||
* accelerometer
|
||||
* accelerometer.
|
||||
* @param accelerationThreshold
|
||||
* value of the value variation between two events with the
|
||||
* accelerometer
|
||||
* accelerometer.
|
||||
* @param smoothingState
|
||||
* true if smoothing flag is activated
|
||||
* true if smoothing flag is activated.
|
||||
* @param alphaSmooth
|
||||
* value of the alpha smoothing parameter
|
||||
* value of the alpha smoothing parameter.
|
||||
* @param r
|
||||
* roll
|
||||
* roll.
|
||||
* @param p
|
||||
* pitch
|
||||
* pitch.
|
||||
* @param ya
|
||||
* yaw
|
||||
* yaw.
|
||||
* @param ar
|
||||
* absolute roll
|
||||
* absolute roll.
|
||||
* @param ap
|
||||
* absolute pitch
|
||||
* absolute pitch.
|
||||
* @param x
|
||||
* gravity force on x axis
|
||||
* gravity force on x axis.
|
||||
* @param y
|
||||
* gravity force on y axis
|
||||
* gravity force on y axis.
|
||||
* @param z
|
||||
* gravity force on z axis
|
||||
* gravity force on z axis.
|
||||
* @param xx
|
||||
* raw acceleration on x axis
|
||||
* raw acceleration on x axis.
|
||||
* @param yy
|
||||
* raw acceleration on y axis
|
||||
* raw acceleration on y axis.
|
||||
* @param zz
|
||||
* raw acceleration on z axis
|
||||
* raw acceleration on z axis.
|
||||
*/
|
||||
public MotionSensingEvent(int id, float orientationThreshold,
|
||||
int accelerationThreshold, boolean smoothingState,
|
||||
|
||||
@@ -28,15 +28,128 @@ public class NunchukEvent extends ExpansionEvent {
|
||||
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) {
|
||||
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, int angle, int magnitude, short max1,
|
||||
short max2, short min1, short min2, short center1, short center2) {
|
||||
super(id);
|
||||
// TODO Auto-generated constructor stub
|
||||
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 joystick buttons event.
|
||||
*
|
||||
* @return the joystick 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)
|
||||
|
||||
@@ -38,7 +38,7 @@ public class EventsGatherer {
|
||||
* Create EventsGatherer.
|
||||
*
|
||||
* @param nbWiimotes
|
||||
* nb wiimotes (nb a of events possible in a call to Wiiuse API)
|
||||
* nb wiimotes (nb a of events possible in a call to Wiiuse API).
|
||||
*/
|
||||
public EventsGatherer(int nbWiimotes) {
|
||||
events = new WiiUseApiEvent[nbWiimotes];
|
||||
@@ -61,11 +61,11 @@ public class EventsGatherer {
|
||||
* @param id
|
||||
* id of the wiimote.
|
||||
* @param buttonsJustPressed
|
||||
* buttons just pressed
|
||||
* buttons just pressed.
|
||||
* @param buttonsJustReleased
|
||||
* buttons just released
|
||||
* buttons just released.
|
||||
* @param buttonsHeld
|
||||
* buttons held
|
||||
* buttons held.
|
||||
*/
|
||||
public void prepareWiiMoteEvent(int id, short buttonsJustPressed,
|
||||
short buttonsJustReleased, short buttonsHeld) {
|
||||
@@ -85,7 +85,7 @@ public class EventsGatherer {
|
||||
* @param ax
|
||||
* absolute X coordinate.
|
||||
* @param ay
|
||||
* absolute Y coordinate
|
||||
* absolute Y coordinate.
|
||||
* @param xVRes
|
||||
* IR virtual screen x resolution.
|
||||
* @param yVRes
|
||||
@@ -101,7 +101,7 @@ public class EventsGatherer {
|
||||
* @param irSensitivity
|
||||
* Sensitivity of the infrared camera.
|
||||
* @param distance
|
||||
* Pixel Distance between first two dots
|
||||
* Pixel Distance between first two dots.
|
||||
*/
|
||||
public void prepareIRevent(int x, int y, int z, int ax, int ay, int xVRes,
|
||||
int yVRes, int xOffset, int yOffset, short sensorBarPostion,
|
||||
@@ -113,12 +113,12 @@ public class EventsGatherer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an IR point to the WiiMoteEvent prepared
|
||||
* Add an IR point to the WiiMoteEvent prepared.
|
||||
*
|
||||
* @param x
|
||||
* x coordinates
|
||||
* x coordinates.
|
||||
* @param y
|
||||
* y coordinates
|
||||
* y coordinates.
|
||||
* @param rx
|
||||
* raw X coordinate (0-1023).
|
||||
* @param ry
|
||||
@@ -138,36 +138,36 @@ public class EventsGatherer {
|
||||
*
|
||||
* @param orientationThreshold
|
||||
* value of the minimum angle between two events with the
|
||||
* accelerometer
|
||||
* accelerometer.
|
||||
* @param accelerationThreshold
|
||||
* value of the value variation between two events with the
|
||||
* accelerometer
|
||||
* accelerometer.
|
||||
* @param smoothingState
|
||||
* true if smoothing flag is activated
|
||||
* true if smoothing flag is activated.
|
||||
* @param alphaSmooth
|
||||
* value of the alpha smoothing parameter
|
||||
* value of the alpha smoothing parameter.
|
||||
* @param r
|
||||
* roll
|
||||
* roll.
|
||||
* @param p
|
||||
* pitch
|
||||
* pitch.
|
||||
* @param ya
|
||||
* yaw
|
||||
* yaw.
|
||||
* @param ar
|
||||
* absolute roll
|
||||
* absolute roll.
|
||||
* @param ap
|
||||
* absolute pitch
|
||||
* absolute pitch.
|
||||
* @param x
|
||||
* gravity force on x axis
|
||||
* gravity force on x axis.
|
||||
* @param y
|
||||
* gravity force on y axis
|
||||
* gravity force on y axis.
|
||||
* @param z
|
||||
* gravity force on z axis
|
||||
* gravity force on z axis.
|
||||
* @param xx
|
||||
* raw acceleration on x axis
|
||||
* raw acceleration on x axis.
|
||||
* @param yy
|
||||
* raw acceleration on y axis
|
||||
* raw acceleration on y axis.
|
||||
* @param zz
|
||||
* raw acceleration on z axis
|
||||
* raw acceleration on z axis.
|
||||
*/
|
||||
public void addMotionSensingValues(float orientationThreshold,
|
||||
int accelerationThreshold, boolean smoothingState,
|
||||
@@ -180,6 +180,80 @@ public class EventsGatherer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a NunchukEvent to the prepared .
|
||||
*
|
||||
* @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, int angle, int 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the prepared WiimoteEvent to the gatherer.
|
||||
*/
|
||||
@@ -194,25 +268,25 @@ public class EventsGatherer {
|
||||
* Add a StatusEvent to the gatherer.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
* @param connect
|
||||
* true if the wiimote is connected
|
||||
* true if the wiimote is connected.
|
||||
* @param batt
|
||||
* battery level
|
||||
* battery level.
|
||||
* @param led
|
||||
* status of leds
|
||||
* status of leds.
|
||||
* @param speak
|
||||
* speakers status
|
||||
* speakers status.
|
||||
* @param attach
|
||||
* attachment status
|
||||
* attachment status.
|
||||
* @param rumbleState
|
||||
* true if rumble is active
|
||||
* true if rumble is active.
|
||||
* @param continuousState
|
||||
* true if continuous flag is activated
|
||||
* true if continuous flag is activated.
|
||||
* @param irState
|
||||
* true if ir is active
|
||||
* true if ir is active.
|
||||
* @param motionSensingState
|
||||
* true if accelerometer is active
|
||||
* true if accelerometer is active.
|
||||
*/
|
||||
public void addStatusEvent(int id, boolean connect, float batt, short led,
|
||||
boolean speak, int attach, boolean rumbleState,
|
||||
@@ -227,7 +301,7 @@ public class EventsGatherer {
|
||||
* Add a DisconnectionEvent to the gatherer.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void addDisconnectionEvent(int id) {
|
||||
DisconnectionEvent evt = new DisconnectionEvent(id);
|
||||
@@ -238,7 +312,7 @@ public class EventsGatherer {
|
||||
* Add a NunchukInsertedEvent to the gatherer.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void addNunchukInsertedEvent(int id) {
|
||||
NunchukInsertedEvent evt = new NunchukInsertedEvent(id);
|
||||
@@ -249,7 +323,7 @@ public class EventsGatherer {
|
||||
* Add a NunchukRemovedEvent to the gatherer.
|
||||
*
|
||||
* @param id
|
||||
* id of the wiimote
|
||||
* id of the wiimote.
|
||||
*/
|
||||
public void addNunchukRemovedEvent(int id) {
|
||||
NunchukRemovedEvent evt = new NunchukRemovedEvent(id);
|
||||
@@ -259,7 +333,7 @@ public class EventsGatherer {
|
||||
/**
|
||||
* Return an array containing the events.
|
||||
*
|
||||
* @return events received
|
||||
* @return events received.
|
||||
*/
|
||||
public WiiUseApiEvent[] getEvents() {
|
||||
return java.util.Arrays.copyOfRange(events, 0, index);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package wiiusej.wiiusejevents.utils;
|
||||
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
@@ -52,6 +53,12 @@ public interface WiimoteListener extends java.util.EventListener {
|
||||
*/
|
||||
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 :
|
||||
|
||||
@@ -19,6 +19,7 @@ package wiiusej.wiiusejevents.wiiuseapievents;
|
||||
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.IREvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
|
||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
|
||||
/**
|
||||
@@ -191,36 +192,36 @@ public class WiimoteEvent extends WiiUseApiEvent {
|
||||
*
|
||||
* @param orientationThreshold
|
||||
* value of the minimum angle between two events with the
|
||||
* accelerometer
|
||||
* accelerometer.
|
||||
* @param accelerationThreshold
|
||||
* value of the value variation between two events with the
|
||||
* accelerometer
|
||||
* accelerometer.
|
||||
* @param smoothingState
|
||||
* true if smoothing flag is activated
|
||||
* true if smoothing flag is activated.
|
||||
* @param alphaSmooth
|
||||
* value of the alpha smoothing parameter
|
||||
* value of the alpha smoothing parameter.
|
||||
* @param r
|
||||
* roll
|
||||
* roll.
|
||||
* @param p
|
||||
* pitch
|
||||
* pitch.
|
||||
* @param ya
|
||||
* yaw
|
||||
* yaw.
|
||||
* @param ar
|
||||
* absolute roll
|
||||
* absolute roll.
|
||||
* @param ap
|
||||
* absolute pitch
|
||||
* absolute pitch.
|
||||
* @param x
|
||||
* gravity force on x axis
|
||||
* gravity force on x axis.
|
||||
* @param y
|
||||
* gravity force on y axis
|
||||
* gravity force on y axis.
|
||||
* @param z
|
||||
* gravity force on z axis
|
||||
* gravity force on z axis.
|
||||
* @param xx
|
||||
* raw acceleration on x axis
|
||||
* raw acceleration on x axis.
|
||||
* @param yy
|
||||
* raw acceleration on y axis
|
||||
* raw acceleration on y axis.
|
||||
* @param zz
|
||||
* raw acceleration on z axis
|
||||
* raw acceleration on z axis.
|
||||
*/
|
||||
public void setMotionSensingEvent(float orientationThreshold,
|
||||
int accelerationThreshold, boolean smoothingState,
|
||||
@@ -231,8 +232,76 @@ public class WiimoteEvent extends WiiUseApiEvent {
|
||||
alphaSmooth, r, p, ya, ar, ap, x, y, z, xx, yy, zz);
|
||||
}
|
||||
|
||||
public void setNunchukEvent(){
|
||||
|
||||
/**
|
||||
* 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, int angle, int 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);
|
||||
}
|
||||
|
||||
public void setClassicControllerEvent() {
|
||||
|
||||
Reference in New Issue
Block a user