diff --git a/WiiUseJ/WiiUseJ.dll b/WiiUseJ/WiiUseJ.dll
index 3824937..944cd8c 100644
Binary files a/WiiUseJ/WiiUseJ.dll and b/WiiUseJ/WiiUseJ.dll differ
diff --git a/WiiUseJ/src/wiiusej/WiiUseApiManager.java b/WiiUseJ/src/wiiusej/WiiUseApiManager.java
index ad0b83a..c7ca24f 100644
--- a/WiiUseJ/src/wiiusej/WiiUseApiManager.java
+++ b/WiiUseJ/src/wiiusej/WiiUseApiManager.java
@@ -22,8 +22,8 @@ import javax.swing.event.EventListenerList;
import wiiusej.wiiusejevents.utils.EventsGatherer;
import wiiusej.wiiusejevents.utils.WiiUseApiListener;
-import wiiusej.wiiusejevents.wiiusejapievents.StatusEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.WiiUseApiEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
/**
* Class that manages the use of Wiiuse API.
diff --git a/WiiUseJ/src/wiiusej/Wiimote.java b/WiiUseJ/src/wiiusej/Wiimote.java
index 639ca99..6ad70ef 100644
--- a/WiiUseJ/src/wiiusej/Wiimote.java
+++ b/WiiUseJ/src/wiiusej/Wiimote.java
@@ -20,10 +20,12 @@ import javax.swing.event.EventListenerList;
import wiiusej.wiiusejevents.utils.WiiUseApiListener;
import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiusejapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.StatusEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.WiiUseApiEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.WiimoteEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
+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;
/**
* Class that represents a wiimote. You can register as an observer of this
@@ -54,6 +56,7 @@ public class Wiimote implements WiiUseApiListener {
/**
* Get the unique id of the wiimote.
+ *
* @return the id
*/
public int getId() {
@@ -243,7 +246,7 @@ public class Wiimote implements WiiUseApiListener {
public void getStatus() {
manager.getStatus(id);
}
-
+
/**
* Set the IR sensitivity.
*
@@ -266,17 +269,24 @@ public class Wiimote implements WiiUseApiListener {
if (e.getWiimoteId() == id) {
if (e.getEventType() == WiiUseApiEvent.GENERIC_EVENT) {
notifyWiiMoteEventListeners((WiimoteEvent) e);
- } else if (e.getEventType() == WiiUseApiEvent.STATUS_EVENT
- || e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_INSERTED
- || e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_REMOVED
- || e.getEventType() == WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED
- || e.getEventType() == WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_REMOVED
- || e.getEventType() == WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED
- || e.getEventType() == WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED) {
+ } else if (e.getEventType() == WiiUseApiEvent.STATUS_EVENT) {
notifyStatusEventListeners((StatusEvent) e);
} else if (e.getEventType() == WiiUseApiEvent.DISCONNECTION_EVENT) {
notifyDisconnectionEventListeners((DisconnectionEvent) e);
+ } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_INSERTED) {
+ notifyNunchukInsertedEventListeners((NunchukInsertedEvent)e);
+ } else if (e.getEventType() == WiiUseApiEvent.WIIUSE_NUNCHUK_REMOVED) {
+ notifyNunchukRemovedEventListeners((NunchukRemovedEvent)e);
}
+ /*
+ * events not managed yet
+ * || e.getEventType() == WIIUSE_READ_DATA
+ * WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_INSERTED || e.getEventType() ==
+ * WiiUseApiEvent.WIIUSE_CLASSIC_CTRL_REMOVED || e.getEventType() ==
+ * WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED ||
+ * e.getEventType() ==
+ * WiiUseApiEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED
+ */
}
}
@@ -342,10 +352,10 @@ public class Wiimote implements WiiUseApiListener {
}
/**
- * Notify WiimoteListener that a status event occured.
+ * Notify WiimoteListener that a disconnection event occured.
*
* @param evt
- * status event occured
+ * disconnection event occured
*/
private void notifyDisconnectionEventListeners(DisconnectionEvent evt) {
for (WiimoteListener listener : getWiiMoteEventListeners()) {
@@ -353,6 +363,30 @@ public class Wiimote implements WiiUseApiListener {
}
}
+ /**
+ * Notify WiimoteListener that a NunchukInserted Event occured.
+ *
+ * @param evt
+ * NunchukInserted Event occured
+ */
+ private void notifyNunchukInsertedEventListeners(NunchukInsertedEvent evt) {
+ for (WiimoteListener listener : getWiiMoteEventListeners()) {
+ listener.onNunchukInsertedEvent(evt);
+ }
+ }
+
+ /**
+ * Notify WiimoteListener that a NunchukRemoved Event occured.
+ *
+ * @param evt
+ * NunchukRemoved Event occured
+ */
+ private void notifyNunchukRemovedEventListeners(NunchukRemovedEvent evt) {
+ for (WiimoteListener listener : getWiiMoteEventListeners()) {
+ listener.onNunchukRemovedEvent(evt);
+ }
+ }
+
@Override
public String toString() {
return "Wiimote with ID : " + id;
diff --git a/WiiUseJ/src/wiiusej/test/Tests.java b/WiiUseJ/src/wiiusej/test/Tests.java
index 2f05773..87157e7 100644
--- a/WiiUseJ/src/wiiusej/test/Tests.java
+++ b/WiiUseJ/src/wiiusej/test/Tests.java
@@ -27,8 +27,10 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiusejapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.StatusEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/**
* This class used to test WiiuseJ.
@@ -333,6 +335,14 @@ public class Tests implements WiimoteListener {
System.out.println(" wiimote " + e.getWiimoteId()
+ "has been disconnected !!");
}
+
+ public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
+ System.out.println(e);
+ }
+
+ public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
+ System.out.println(e);
+ }
/**
* @param args
@@ -350,4 +360,5 @@ public class Tests implements WiimoteListener {
// timer.scheduleAtFixedRate(new LedsTask(), 0, 100);
}
+
}
diff --git a/WiiUseJ/src/wiiusej/test/WiiuseJGuiTest.java b/WiiUseJ/src/wiiusej/test/WiiuseJGuiTest.java
index 060eb93..2c5c9a3 100644
--- a/WiiUseJ/src/wiiusej/test/WiiuseJGuiTest.java
+++ b/WiiUseJ/src/wiiusej/test/WiiuseJGuiTest.java
@@ -32,8 +32,10 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiusejapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.StatusEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/**
* Gui class to test WiiuseJ.
@@ -155,7 +157,17 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
public void onDisconnectionEvent(DisconnectionEvent arg0) {
messageText.setText("Wiimote Disconnected !");
}
+
+ public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
diff --git a/WiiUseJ/src/wiiusej/utils/AccelerationPanel.java b/WiiUseJ/src/wiiusej/utils/AccelerationPanel.java
index 6f14b74..ccb5941 100644
--- a/WiiUseJ/src/wiiusej/utils/AccelerationPanel.java
+++ b/WiiUseJ/src/wiiusej/utils/AccelerationPanel.java
@@ -30,8 +30,10 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiusejapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.StatusEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/**
* This panel is used to watch raw acceleration values from a MotionSensingEvent.
@@ -157,6 +159,16 @@ public class AccelerationPanel extends javax.swing.JPanel implements WiimoteList
values.clear();
repaint();
}
+
+ public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
+ // TODO Auto-generated method stub
+
+ }
/** This method is called from within the constructor to
* initialize the form.
diff --git a/WiiUseJ/src/wiiusej/utils/ButtonsEventPanel.java b/WiiUseJ/src/wiiusej/utils/ButtonsEventPanel.java
index e4456fa..41cb115 100644
--- a/WiiUseJ/src/wiiusej/utils/ButtonsEventPanel.java
+++ b/WiiUseJ/src/wiiusej/utils/ButtonsEventPanel.java
@@ -31,8 +31,10 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiusejapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.StatusEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/**
* This panel is used to see what buttons are pressed.
@@ -275,6 +277,16 @@ public class ButtonsEventPanel extends javax.swing.JPanel implements WiimoteList
repaint();
}
+ public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
diff --git a/WiiUseJ/src/wiiusej/utils/GForcePanel.java b/WiiUseJ/src/wiiusej/utils/GForcePanel.java
index 880c332..2bc4213 100644
--- a/WiiUseJ/src/wiiusej/utils/GForcePanel.java
+++ b/WiiUseJ/src/wiiusej/utils/GForcePanel.java
@@ -30,8 +30,10 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiusejapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.StatusEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/**
* This panel is used to watch gravity force values from a MotionSensingEvent.
@@ -178,6 +180,16 @@ public class GForcePanel extends javax.swing.JPanel implements WiimoteListener {
repaint();
}
+ public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
diff --git a/WiiUseJ/src/wiiusej/utils/IRPanel.java b/WiiUseJ/src/wiiusej/utils/IRPanel.java
index ef2a576..9f4fa7a 100644
--- a/WiiUseJ/src/wiiusej/utils/IRPanel.java
+++ b/WiiUseJ/src/wiiusej/utils/IRPanel.java
@@ -29,8 +29,10 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiusejapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.StatusEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/**
* This panel is used to see what the IR camera of the wiimote sees.
@@ -169,6 +171,16 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
//redraw panel
repaint();
}
+
+ public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
+ // TODO Auto-generated method stub
+
+ }
/** This method is called from within the constructor to
* initialize the form.
diff --git a/WiiUseJ/src/wiiusej/utils/OrientationPanel.java b/WiiUseJ/src/wiiusej/utils/OrientationPanel.java
index 3adf387..14f2360 100644
--- a/WiiUseJ/src/wiiusej/utils/OrientationPanel.java
+++ b/WiiUseJ/src/wiiusej/utils/OrientationPanel.java
@@ -30,8 +30,10 @@ import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiusejapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.StatusEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/**
* This panel is used to watch orientation values from a MotionSensingEvent.
@@ -181,6 +183,16 @@ public class OrientationPanel extends javax.swing.JPanel implements WiimoteListe
values.clear();
repaint();
}
+
+ public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
+ // TODO Auto-generated method stub
+
+ }
/** This method is called from within the constructor to
* initialize the form.
diff --git a/WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/NunchukButtonsEvent.java b/WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/NunchukButtonsEvent.java
index fb8a2da..14866f2 100644
--- a/WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/NunchukButtonsEvent.java
+++ b/WiiUseJ/src/wiiusej/wiiusejevents/physicalevents/NunchukButtonsEvent.java
@@ -78,7 +78,7 @@ public class NunchukButtonsEvent extends ButtonsEvent {
@Override
public String toString() {
- return "/******** Buttons for Nunchhuk Event ********/\n"
+ return "/******** Buttons for Nunchuk Event ********/\n"
+ super.toString();
}
diff --git a/WiiUseJ/src/wiiusej/wiiusejevents/utils/EventsGatherer.java b/WiiUseJ/src/wiiusej/wiiusejevents/utils/EventsGatherer.java
index 641df9f..f48b75a 100644
--- a/WiiUseJ/src/wiiusej/wiiusejevents/utils/EventsGatherer.java
+++ b/WiiUseJ/src/wiiusej/wiiusejevents/utils/EventsGatherer.java
@@ -16,12 +16,12 @@
*/
package wiiusej.wiiusejevents.utils;
-import wiiusej.wiiusejevents.wiiusejapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.StatusEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.WiiUseApiEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.WiimoteEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
+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.
diff --git a/WiiUseJ/src/wiiusej/wiiusejevents/utils/WiiUseApiListener.java b/WiiUseJ/src/wiiusej/wiiusejevents/utils/WiiUseApiListener.java
index c73e9dc..fb4b3b2 100644
--- a/WiiUseJ/src/wiiusej/wiiusejevents/utils/WiiUseApiListener.java
+++ b/WiiUseJ/src/wiiusej/wiiusejevents/utils/WiiUseApiListener.java
@@ -16,7 +16,7 @@
*/
package wiiusej.wiiusejevents.utils;
-import wiiusej.wiiusejevents.wiiusejapievents.WiiUseApiEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
diff --git a/WiiUseJ/src/wiiusej/wiiusejevents/utils/WiimoteListener.java b/WiiUseJ/src/wiiusej/wiiusejevents/utils/WiimoteListener.java
index 7a38faf..d8b643d 100644
--- a/WiiUseJ/src/wiiusej/wiiusejevents/utils/WiimoteListener.java
+++ b/WiiUseJ/src/wiiusej/wiiusejevents/utils/WiimoteListener.java
@@ -19,8 +19,10 @@ package wiiusej.wiiusejevents.utils;
import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiusejapievents.StatusEvent;
+import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
+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.
@@ -71,5 +73,16 @@ public interface WiimoteListener extends java.util.EventListener {
* @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);
}
diff --git a/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/DisconnectionEvent.java b/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/DisconnectionEvent.java
new file mode 100644
index 0000000..4662d61
--- /dev/null
+++ b/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/DisconnectionEvent.java
@@ -0,0 +1,44 @@
+/**
+ * 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 .
+ */
+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;
+ }
+
+}
diff --git a/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/NunchukInsertedEvent.java b/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/NunchukInsertedEvent.java
new file mode 100644
index 0000000..ce53fe7
--- /dev/null
+++ b/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/NunchukInsertedEvent.java
@@ -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 .
+ */
+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;
+ }
+
+}
diff --git a/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/NunchukRemovedEvent.java b/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/NunchukRemovedEvent.java
new file mode 100644
index 0000000..50306bf
--- /dev/null
+++ b/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/NunchukRemovedEvent.java
@@ -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 .
+ */
+package wiiusej.wiiusejevents.wiiuseapievents;
+
+
+/**
+ * Event that represents the connection of a nunchuk to 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;
+ }
+
+}
diff --git a/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/StatusEvent.java b/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/StatusEvent.java
new file mode 100644
index 0000000..9c2a6d4
--- /dev/null
+++ b/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/StatusEvent.java
@@ -0,0 +1,256 @@
+/**
+ * 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 .
+ */
+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;
+ }
+
+ @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;
+ }
+
+}
diff --git a/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/WiiUseApiEvent.java b/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/WiiUseApiEvent.java
new file mode 100644
index 0000000..0527b13
--- /dev/null
+++ b/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/WiiUseApiEvent.java
@@ -0,0 +1,66 @@
+/**
+ * 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 .
+ */
+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;
+
+ /* 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();
+
+}
diff --git a/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/WiimoteEvent.java b/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/WiimoteEvent.java
new file mode 100644
index 0000000..1975eb8
--- /dev/null
+++ b/WiiUseJ/src/wiiusej/wiiusejevents/wiiuseapievents/WiimoteEvent.java
@@ -0,0 +1,275 @@
+/**
+ * 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 .
+ */
+package wiiusej.wiiusejevents.wiiuseapievents;
+
+import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
+import wiiusej.wiiusejevents.physicalevents.IREvent;
+import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
+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 {
+
+ WiimoteButtonsEvent buttonsEvent = null;
+ IREvent infraredEvent = null;
+ MotionSensingEvent motionSensingEvent = null;
+ 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, int 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);
+ }
+
+ public void setNunchukEvent(){
+
+ }
+
+ public void setClassicControllerEvent(){
+ //@TODO
+ }
+
+ @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;
+ }
+
+}