diff --git a/WiiUseJ_0.11/.classpath b/WiiUseJ_0.11/.classpath
new file mode 100644
index 0000000..d171cd4
--- /dev/null
+++ b/WiiUseJ_0.11/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/WiiUseJ_0.11/.project b/WiiUseJ_0.11/.project
new file mode 100644
index 0000000..9485f4a
--- /dev/null
+++ b/WiiUseJ_0.11/.project
@@ -0,0 +1,17 @@
+
+
+ WiiUseJava
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/WiiUseJ_0.11/README.TXT b/WiiUseJ_0.11/README.TXT
new file mode 100644
index 0000000..268d31d
--- /dev/null
+++ b/WiiUseJ_0.11/README.TXT
@@ -0,0 +1,38 @@
+/**
+ * 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 .
+ */
+
+
+WiiuseJ is a java API to use wiimotes on your computer. This API is built on top of an excellent API call Wiiuse using JNI.
+
+WiiuseJ intent to be a very simple, easy to use and lightweight java API for wiimotes.
+
+Some of the great aspects of this API are :
+
+ * The compatibility which is as large as Wiiuse's API compatibility
+
+ * Cross-platform : Windows and linux (like Wiiuse)
+
+ * Easy to use
+
+
+WiiuseJ is made by Guilhem Duché : guiguito1@hotmail.com.
+You can contact me if you need more information.
+
+Go to : http://wiiusej.googlecode.com/ for further documentations.
+
+
+
diff --git a/WiiUseJ_0.11/WiiUseJ.dll b/WiiUseJ_0.11/WiiUseJ.dll
new file mode 100644
index 0000000..6999b85
Binary files /dev/null and b/WiiUseJ_0.11/WiiUseJ.dll differ
diff --git a/WiiUseJ_0.11/img/wiimote.png b/WiiUseJ_0.11/img/wiimote.png
new file mode 100644
index 0000000..3f26f52
Binary files /dev/null and b/WiiUseJ_0.11/img/wiimote.png differ
diff --git a/WiiUseJ_0.11/libWiiuseJ.so b/WiiUseJ_0.11/libWiiuseJ.so
new file mode 100644
index 0000000..47ab1f2
Binary files /dev/null and b/WiiUseJ_0.11/libWiiuseJ.so differ
diff --git a/WiiUseJ_0.11/libwiiuse.so b/WiiUseJ_0.11/libwiiuse.so
new file mode 100644
index 0000000..2f9247b
Binary files /dev/null and b/WiiUseJ_0.11/libwiiuse.so differ
diff --git a/WiiUseJ_0.11/src/img/wiimote.png b/WiiUseJ_0.11/src/img/wiimote.png
new file mode 100644
index 0000000..3f26f52
Binary files /dev/null and b/WiiUseJ_0.11/src/img/wiimote.png differ
diff --git a/WiiUseJ_0.11/src/wiiusej/WiiUseApi.java b/WiiUseJ_0.11/src/wiiusej/WiiUseApi.java
new file mode 100644
index 0000000..3f169e6
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/WiiUseApi.java
@@ -0,0 +1,265 @@
+/**
+ * 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;
+
+import wiiusej.wiiuseapievents.EventsGatherer;
+
+/**
+ * Singleton used to manipulate WiiUse Api.
+ *
+ * @author guiguito
+ */
+public class WiiUseApi {
+
+ static {
+ System.loadLibrary("WiiuseJ");
+ }
+
+ private static WiiUseApi instance = new WiiUseApi();
+
+ /**
+ * Get the only instance of WiiUseApi.
+ *
+ * @return the only instace of WiiUseApi.
+ */
+ static WiiUseApi getInstance() {
+ return instance;
+ }
+
+ /**
+ * Try to connect to 2 wiimotes. Make them rumble to show they are
+ * connected.
+ *
+ * @param nb
+ * number of wiimotes to connect
+ * @param rumble
+ * make the connected wiimotes rumble
+ * @return 0 if there is an error otherwise it returns the number of
+ * wiimotes connected.
+ */
+ native int doConnections(int nb, boolean rumble);
+
+ /**
+ * Close connection to the wiimote with the given id.
+ *
+ */
+ native void closeConnection(int id);
+
+ /**
+ * Shutdown Wiiuse API.
+ */
+ native void shutdownApi();
+
+ /**
+ * Activate rumble on the wiimote with the given id.
+ *
+ * @param id
+ * the id of the wiimote.
+ */
+ native void activateRumble(int id);
+
+ /**
+ * Deactivate rumble on the wiimote with the given id.
+ *
+ * @param id
+ * the id of the wiimote.
+ */
+ native void deactivateRumble(int id);
+
+ /**
+ * Activate IR Tracking on the wiimote with the given id.
+ *
+ * @param id
+ * the id of the wiimote.
+ */
+ native void activateIRTracking(int id);
+
+ /**
+ * Deactivate IR Tracking on the wiimote with the given id.
+ *
+ * @param id
+ * the id of the wiimote.
+ */
+ native void deactivateIRTracking(int id);
+
+ /**
+ * Activate motion sensing on the wiimote with the given id.
+ *
+ * @param id
+ * the id of the wiimote.
+ */
+ native void activateMotionSensing(int id);
+
+ /**
+ * Deactivate motion sensing on the wiimote with the given id.
+ *
+ * @param id
+ * the id of the wiimote.
+ */
+ native void deactivateMotionSensing(int id);
+
+ /**
+ * Set wiimote leds status.
+ *
+ * @param id
+ * the id of the wiimote concerned
+ * @param led1
+ * status of led1: True=ON, False=OFF
+ * @param led2
+ * status of led2: True=ON, False=OFF
+ * @param led3
+ * status of led3: True=ON, False=OFF
+ * @param led4
+ * status of led4: True=ON, False=OFF
+ */
+ native void setLeds(int id, boolean led1, boolean led2, boolean led3,
+ boolean led4);
+
+ /**
+ * Set how many degrees an angle must change to generate an event.
+ *
+ * @param id
+ * id of the wiimote concerned
+ * @param angle
+ * minimum angle detected by an event
+ */
+ native void setOrientThreshold(int id, float angle);
+
+ /**
+ * Set how much acceleration must change to generate an event.
+ *
+ * @param id
+ * id of the wiimote concerned
+ * @param value
+ * minimum value detected by an event
+ */
+ native void setAccelThreshold(int id, int value);
+
+ /**
+ * Set alpha smoothing parameter for the given id.
+ *
+ * @param id
+ * id of the wiimote concerned
+ * @param value
+ * alpha smoothing value
+ */
+ native void setAlphaSmoothing(int id, float value);
+
+ /**
+ * Try to resync with the wiimote by starting a new handshake.
+ *
+ * @param id
+ * id of the wiimote concerned
+ */
+ native void reSync(int id);
+
+ /**
+ * Make the the accelerometers give smoother results. This is set by
+ * default.
+ *
+ * @param id
+ * the id of the wiimote concerned
+ */
+ native void activateSmoothing(int id);
+
+ /**
+ * Make the the accelerometers give raw results.
+ *
+ * @param id
+ * the id of the wiimote concerned
+ */
+ native void deactivateSmoothing(int id);
+
+ /**
+ * Make the wiimote generate an event each time we poll. Not set by default.
+ *
+ * @param id
+ * the id of the wiimote concerned
+ */
+ native void activateContinuous(int id);
+
+ /**
+ * Make the wiimote generate an event only when there is one.
+ *
+ * @param id
+ * the id of the wiimote concerned
+ */
+ native void deactivateContinuous(int id);
+
+ /**
+ * Notify wiiuse that your screen has an aspect ratio of 4/3.
+ *
+ * @param id
+ * the id of the wiimote of which we want the status.
+ */
+ native void setScreenRatio43(int id);
+
+ /**
+ * Notify wiiuse that your screen has an aspect ratio of 16/9.
+ *
+ * @param id
+ * the id of the wiimote of which we want the status.
+ */
+ native void setScreenRatio169(int id);
+
+ /**
+ * Notify wiiuse that the sensor bar is above your screen.
+ *
+ * @param id
+ * the id of the wiimote of which we want the status.
+ */
+ native void setSensorBarAboveScreen(int id);
+
+ /**
+ * Notify wiiuse that the sensor bar is below your screen.
+ *
+ * @param id
+ * the id of the wiimote of which we want the status.
+ */
+ native void setSensorBarBelowScreen(int id);
+
+ /**
+ * Set virtual screen resolution. It is used to automatically compute the
+ * position of a cursor on this virtual screen using the sensor bar. These
+ * results come in the IREvent.
+ *
+ * @param id
+ * the id of the wiimote of which we want the status.
+ * @param x
+ * x resolution.
+ * @param y
+ * y resolution.
+ */
+ native void setVirtualScreenResolution(int id, int x, int y);
+
+ /**
+ * Get status and values from the wiimotes and send it through callbacks.
+ *
+ * @param id
+ * the id of the wiimote of which we want the status.
+ */
+ native void getStatus(int id);
+
+ /**
+ * Check for new Events and Get it.
+ *
+ * @param gath
+ * the object where we store all the new events.
+ */
+ native void specialPoll(EventsGatherer gath);
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/WiiUseApiManager.java b/WiiUseJ_0.11/src/wiiusej/WiiUseApiManager.java
new file mode 100644
index 0000000..2d258d5
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/WiiUseApiManager.java
@@ -0,0 +1,571 @@
+/**
+ * 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;
+
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.swing.event.EventListenerList;
+
+import wiiusej.wiiuseapievents.EventsGatherer;
+import wiiusej.wiiuseapievents.WiiUseApiEvent;
+import wiiusej.wiiuseapievents.WiiUseApiListener;
+import wiiusej.wiiuseapirequest.FloatValueRequest;
+import wiiusej.wiiuseapirequest.IntValueRequest;
+import wiiusej.wiiuseapirequest.LedsRequest;
+import wiiusej.wiiuseapirequest.TwoIntValueRequest;
+import wiiusej.wiiuseapirequest.WiiUseApiRequest;
+
+/**
+ * Class that manages the use of Wiiuse API.
+ *
+ * @author guiguito
+ */
+public class WiiUseApiManager extends Thread {
+
+ private static WiiUseApiManager instance = new WiiUseApiManager();
+
+ private final EventListenerList listeners = new EventListenerList();
+
+ private Wiimote[] wiimotes;
+
+ private WiiUseApi wiiuse = WiiUseApi.getInstance();
+
+ private int connected = -1;
+
+ private int nbMaxWiimotes = -1;
+
+ private AtomicBoolean running = new AtomicBoolean(false);
+
+ private ConcurrentLinkedQueue requests = new ConcurrentLinkedQueue();
+
+ public static WiiUseApiManager getInstance() {
+ return instance;
+ }
+
+ /**
+ * Get wiimotes. Load library if necessary. Connect to wiimotes if
+ * necessary. Start polling if necessary. Return an array with the connected
+ * wiimotes.
+ *
+ * @param nb
+ * try to connect nb wiimotes
+ * @param rumble
+ * make the connected wiimotes rumble
+ * @return an array with connected wiimotes or NULL.
+ */
+ public synchronized static Wiimote[] getWiimotes(int nb, boolean rumble) {
+ WiiUseApiManager manager = getInstance();
+ if (manager.connected < 0) {
+ int nbWiimotes = manager.connectWiimotes(nb, rumble);
+ manager.wiimotes = new Wiimote[nbWiimotes];
+ for (int i = 1; i <= nbWiimotes; i++) {
+ Wiimote wim = new Wiimote(i, manager);
+ manager.wiimotes[i - 1] = wim;
+ manager.addWiiUseApiListener(wim);
+ }
+ }
+
+ if (manager.connected == 0) {
+ return new Wiimote[0];
+ }
+
+ if (!manager.isAlive())
+ manager.start();
+
+ return manager.wiimotes;
+ }
+
+ /**
+ * Connect wiimote and get the number of wiimotes connected. Supposed to be
+ * used once.
+ *
+ * @param nb
+ * try to connect nb wiimotes
+ * @param rumble
+ * make the connected wiimotes rumble
+ * @return 0 if nothing connected or the number of wiimotes connected.
+ */
+ private int connectWiimotes(int nb, boolean rumble) {
+ nbMaxWiimotes = nb;
+ if (connected < 0) {
+ connected = wiiuse.doConnections(nb, rumble);
+ return connected;
+ } else {// library not loaded, no wiimotes connected
+ return 0;
+ }
+ }
+
+ /**
+ * Ask the thread to close a connection.
+ *
+ * @param id
+ * id of the wiimote to disconnect.
+ */
+ public void closeConnection(int id) {
+ removeWiiUseApiListener(wiimotes[id - 1]);
+ wiimotes[id - 1] = null;
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_CLOSE_CONNECTION_REQUEST));
+ // System.out.println("Wiimote " + id + " disconnected !");
+ }
+
+ /**
+ * Get the number of wiimotes connected.
+ *
+ * @return the number of wiimotes connected.
+ */
+ public int getNbConnectedWiimotes() {
+ return connected;
+ }
+
+ /**
+ * Stop thread and shutdown wiiuse Api.
+ */
+ public void shutdown() {
+ if (connected > 0) {
+ for (Wiimote wim : wiimotes) {
+ if (wim != null)
+ wim.disconnect();
+ }
+ }
+ running.set(false);
+ wiiuse.shutdownApi();
+ }
+
+ /**
+ * Activate the rumble for the wiimote with the given id.
+ *
+ * @param id
+ * id of the wiimote.
+ */
+ public void activateRumble(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_ACTIVATE_RUMBLE_REQUEST));
+ }
+
+ /**
+ * Deactivate the rumble for the wiimote with the given id.
+ *
+ * @param id
+ * id of the wiimote.
+ */
+ public void deactivateRumble(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_DEACTIVATE_RUMBLE_REQUEST));
+ }
+
+ /**
+ * Activate IR Tracking for the wiimote with the given id.
+ *
+ * @param id
+ * id of the wiimote.
+ */
+ public void activateIRTRacking(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_ACTIVATE_IR_TRACKING_REQUEST));
+ }
+
+ /**
+ * Deactivate IR Tracking for the wiimote with the given id.
+ *
+ * @param id
+ * id of the wiimote.
+ */
+ public void deactivateIRTRacking(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST));
+ }
+
+ /**
+ * Activate motion sensing for the wiimote with the given id.
+ *
+ * @param id
+ * id of the wiimote.
+ */
+ public void activateMotionSensing(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST));
+ }
+
+ /**
+ * Deactivate motion sensing for the wiimoter with the given id.
+ *
+ * @param id
+ * id of the wiimote.
+ */
+ public void deactivateMotionSensing(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST));
+ }
+
+ /**
+ * Activate smoothing the wiimotes with the given id.
+ *
+ * @param id
+ * id of the wiimote.
+ */
+ public void activateSmoothing(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_ACTIVATE_SMOOTHING_REQUEST));
+ }
+
+ /**
+ * Deactivate smoothing the wiimotes with the given id.
+ *
+ * @param id
+ * id of the wiimote.
+ */
+ public void deactivateSmoothing(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_DEACTIVATE_SMOOTHING_REQUEST));
+ }
+
+ /**
+ * Activate continuous for the wiimotes with the given id.
+ *
+ * @param id
+ * id of the wiimote.
+ */
+ public void activateContinuous(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_ACTIVATE_CONTINUOUS_REQUEST));
+ }
+
+ /**
+ * Deactivate continuous for the wiimotes with the given id.
+ *
+ * @param id
+ * id of the wiimote
+ */
+ public void deactivateContinuous(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST));
+ }
+
+ /**
+ * Set leds for the wiimotes with the given id.
+ *
+ * @param id
+ * id of the wiimote
+ * @param l1
+ * status of led1. True : ON, False : OFF
+ * @param l2
+ * status of led2. True : ON, False : OFF
+ * @param l3
+ * status of led3. True : ON, False : OFF
+ * @param l4
+ * status of led4. True : ON, False : OFF
+ */
+ public void setLeds(int id, boolean l1, boolean l2, boolean l3, boolean l4) {
+ requests.add(new LedsRequest(id, WiiUseApiRequest.WIIUSE_LEDS_REQUEST,
+ l1, l2, l3, l4));
+ }
+
+ /**
+ * Set the orientation threshold for the given id.
+ *
+ * @param id
+ * id of the wiimote
+ * @param th
+ * threshold in degrees
+ */
+ public void setOrientationThreshold(int id, float th) {
+ requests.add(new FloatValueRequest(id,
+ WiiUseApiRequest.WIIUSE_ORIENT_THRESHOLHD_REQUEST, th));
+ }
+
+ /**
+ * Set the acceleration threshold for the given id.
+ *
+ * @param id
+ * id of the wiimote
+ * @param th
+ * threshold
+ */
+ public void setAccelerationThreshold(int id, int th) {
+ requests.add(new IntValueRequest(id,
+ WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST, th));
+ }
+
+ /**
+ * Set alpha smoothing for the given id.
+ *
+ * @param id
+ * id of the wiimote
+ * @param th
+ * threshold
+ */
+ public void setAlphaSmoothing(int id, float th) {
+ requests.add(new FloatValueRequest(id,
+ WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST, th));
+ }
+
+ /**
+ * Try to resync with the wiimote by starting a new handshake.
+ *
+ * @param id
+ * id of the wiimote
+ */
+ public void reSync(int id) {
+ requests.add(new WiiUseApiRequest(id, WiiUseApiRequest.WIIUSE_RESYNC));
+ }
+
+ /**
+ * Set screen aspect ratio to 4/3 for the given id.
+ *
+ * @param id
+ * id of the wiimote
+ */
+ public void setScreenAspectRatio43(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_ASPECT_RATIO_4_3));
+ }
+
+ /**
+ * Set screen aspect ratio to 16/9 for the given id.
+ *
+ * @param id
+ * id of the wiimote
+ */
+ public void setScreenAspectRatio169(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_ASPECT_RATIO_16_9));
+ }
+
+ /**
+ * Set the sensor bar to be above the screen.
+ *
+ * @param id
+ * id of the wiimote
+ */
+ public void setSensorBarAboveScreen(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_SENSOR_BAR_ABOVE));
+ }
+
+ /**
+ * Set the sensor bar to be below the screen.
+ *
+ * @param id
+ * id of the wiimote
+ */
+ public void setSensorBarBelowScreen(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_SENSOR_BAR_BELOW));
+ }
+
+ /**
+ * Set virtual resolution. It is used to automatically compute the position
+ * of a cursor on this virtual screen using the sensor bar. These results
+ * come in the IREvent.
+ *
+ * @param id
+ * id of the wiimote
+ * @param x
+ * x resolution
+ * @param y
+ * y resolution
+ */
+ public void setVirtualResolution(int id, int x, int y) {
+ requests.add(new TwoIntValueRequest(id,
+ WiiUseApiRequest.WIIUSE_SET_VIRTUAL_RESOLUTION, x, y));
+ }
+
+ /**
+ * Get Status for the wiimote for the given id.
+ *
+ * @param id
+ * id of the wiimote
+ */
+ public void getStatus(int id) {
+ requests.add(new WiiUseApiRequest(id,
+ WiiUseApiRequest.WIIUSE_STATUS_REQUEST));
+ }
+
+ @Override
+ public void run() {
+
+ if (connected > 0) {
+ running.set(true);
+
+ EventsGatherer gather = new EventsGatherer(nbMaxWiimotes);
+
+ // Start polling and tell the observers when there Wiimote events
+ while (running.get() && connected > 0) {
+
+ /* Polling */
+ wiiuse.specialPoll(gather);
+
+ /* deal with events gathered in Wiiuse API */
+ for (WiiUseApiEvent evt : gather.getEvents()) {
+ if (evt.getWiimoteId() != -1) {// event filled
+ // there is an event notify observers
+ notifyWiiUseApiListener(evt);
+ if (evt.getEventType() == WiiUseApiEvent.DISCONNECTION_EVENT) {
+ // check if it was a disconnection
+ // in this case disconnect the wiimote
+ closeConnection(evt.getWiimoteId());
+ }
+ } else {
+ System.out
+ .println("There is an event with id == -1 ??? there is a problem !!! : "
+ + evt);
+ }
+ }
+ gather.clearEvents();
+
+ /* deal with request done to wiiuse API */
+ WiiUseApiRequest req = requests.poll();
+ if (req != null) {// there is a request for the wiiuse api
+ int id = req.getId();
+ if (req.getRequestType() == WiiUseApiRequest.WIIUSE_CLOSE_CONNECTION_REQUEST) {
+ /* Close connections requests */
+ wiiuse.closeConnection(id);
+
+ connected--;
+ if (connected == 0) {// stop this thread if there is
+ // no more wiimotes connected.
+ // System.out.println("No more wiimotes connected
+ // !!!");
+ shutdown();
+ }
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_STATUS_REQUEST) {
+ /* Status requests */
+ wiiuse.getStatus(id);
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_RUMBLE_REQUEST) {
+ /* Activate Rumble requests */
+ wiiuse.activateRumble(id);
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_RUMBLE_REQUEST) {
+ /* Deactivate Rumble requests */
+ wiiuse.deactivateRumble(id);
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_IR_TRACKING_REQUEST) {
+ /* Activate IR Tracking requests */
+ wiiuse.activateIRTracking(id);
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST) {
+ /* Deactivate IR Tracking requests */
+ wiiuse.deactivateIRTracking(id);
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST) {
+ /* Activate Motion sensing requests */
+ wiiuse.activateMotionSensing(id);
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST) {
+ /* Deactivate Motion sensing requests */
+ wiiuse.deactivateMotionSensing(id);
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_LEDS_REQUEST) {
+ /* leds requests */
+ LedsRequest reqLed = (LedsRequest) req;
+ wiiuse.setLeds(id, reqLed.isLed1(), reqLed.isLed2(),
+ reqLed.isLed3(), reqLed.isLed4());
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_SMOOTHING_REQUEST) {
+ /* Activate smoothing requests */
+ wiiuse.activateSmoothing(id);
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_SMOOTHING_REQUEST) {
+ /* Deactivate smoothing requests */
+ wiiuse.deactivateSmoothing(id);
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACTIVATE_CONTINUOUS_REQUEST) {
+ /* Activate continuous requests */
+ wiiuse.activateContinuous(id);
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST) {
+ /* Deactivate continuous requests */
+ wiiuse.deactivateContinuous(id);
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ORIENT_THRESHOLHD_REQUEST) {
+ /* set orientation threshold request */
+ wiiuse.setOrientThreshold(req.getId(),
+ ((FloatValueRequest) req).getFloatValue());
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ACCEL_THRESHOLHD_REQUEST) {
+ /* set acceleration threshold request */
+ wiiuse.setAccelThreshold(req.getId(),
+ ((IntValueRequest) req).getIntValue());
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ALPHA_SMOOTHING_REQUEST) {
+ /* set alpha smoothing request */
+ wiiuse.setAlphaSmoothing(req.getId(),
+ ((FloatValueRequest) req).getFloatValue());
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_RESYNC) {
+ /* set resync request */
+ wiiuse.reSync(req.getId());
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ASPECT_RATIO_4_3) {
+ /* set screen aspect ratio to 4/3 */
+ wiiuse.setScreenRatio43(req.getId());
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_ASPECT_RATIO_16_9) {
+ /* set screen aspect ratio to 16/9 */
+ wiiuse.setScreenRatio169(req.getId());
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_SENSOR_BAR_ABOVE) {
+ /* set sensor bar above the screen */
+ wiiuse.setSensorBarAboveScreen(req.getId());
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_SENSOR_BAR_BELOW) {
+ /* set sensor bar above the screen */
+ wiiuse.setSensorBarBelowScreen(req.getId());
+ } else if (req.getRequestType() == WiiUseApiRequest.WIIUSE_SET_VIRTUAL_RESOLUTION) {
+ /* set virtual resolution */
+ wiiuse.setVirtualScreenResolution(req.getId(),
+ ((TwoIntValueRequest) req).getIntValue(),
+ ((TwoIntValueRequest) req).getSecondIntValue());
+ } else {
+ System.out.println("Bad request to Wiiuse API !!!!!");
+ }
+ }
+ }
+ } else {
+ if (connected <= 0) {
+ System.out.println("No wiimotes connected !");
+ }
+ }
+
+ }
+
+ /**
+ * Add WiiUseApiListener to the listeners list.
+ *
+ * @param listener
+ * a WiiUseApiListener
+ */
+ public void addWiiUseApiListener(WiiUseApiListener listener) {
+ listeners.add(WiiUseApiListener.class, listener);
+ }
+
+ /**
+ * Remove WiiUseApiListener from the listeners list.
+ *
+ * @param listener
+ * a WiiUseApiListener
+ */
+ public void removeWiiUseApiListener(WiiUseApiListener listener) {
+ listeners.remove(WiiUseApiListener.class, listener);
+ }
+
+ /**
+ * Get the list of WiiUseApiListeners.
+ *
+ * @return the list of WiiUseApiListeners.
+ */
+ public WiiUseApiListener[] getWiiUseApiListeners() {
+ return listeners.getListeners(WiiUseApiListener.class);
+ }
+
+ /**
+ * Notify WiiUseApiListeners that an event occured.
+ *
+ * @param evt
+ * WiimoteEvent occured
+ */
+ private void notifyWiiUseApiListener(WiiUseApiEvent evt) {
+ for (WiiUseApiListener listener : getWiiUseApiListeners()) {
+ listener.onWiiUseApiEvent(evt);
+ }
+ }
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/Wiimote.java b/WiiUseJ_0.11/src/wiiusej/Wiimote.java
new file mode 100644
index 0000000..f04e66c
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/Wiimote.java
@@ -0,0 +1,323 @@
+/**
+ * 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;
+
+import javax.swing.event.EventListenerList;
+
+import wiiusej.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiuseapievents.StatusEvent;
+import wiiusej.wiiuseapievents.GenericEvent;
+import wiiusej.wiiuseapievents.WiiUseApiEvent;
+import wiiusej.wiiuseapievents.WiiUseApiListener;
+import wiiusej.wiiuseapievents.WiimoteListener;
+import wiiusej.wiiuseapirequest.WiiUseApiRequest;
+
+/**
+ * Class that represents a wiimote.
+ * You can register as an observer of this wiimote to listen events from it.
+ * You manage it.
+ * @author guiguito
+ */
+public class Wiimote implements WiiUseApiListener {
+
+ private int id = -1;//wiimote id
+
+ private EventListenerList listeners = new EventListenerList();
+
+ private WiiUseApiManager manager;
+
+
+ /**
+ * Constructor.
+ * @param idd id of the wiimote
+ * @param manager manager wo built it.
+ */
+ public Wiimote(int idd, WiiUseApiManager manager){
+ id = idd;
+ this.manager = manager;
+ }
+
+ /**
+ * Disconnect this wiimote.
+ */
+ public void disconnect(){
+ deactivateIRTRacking();
+ deactivateMotionSensing();
+ deactivateRumble();
+ manager.closeConnection(id);
+ }
+
+ /**
+ * Activate the rumble.
+ */
+ public void activateRumble() {
+ manager.activateRumble(id);
+ }
+
+ /**
+ * Deactivate the rumble.
+ */
+ public void deactivateRumble() {
+ manager.deactivateRumble(id);
+ }
+
+ /**
+ * Activate IR Tracking.
+ */
+ public void activateIRTRacking() {
+ manager.activateIRTRacking(id);
+ }
+
+ /**
+ * Deactivate IR Tracking.
+ */
+ public void deactivateIRTRacking() {
+ manager.deactivateIRTRacking(id);
+ }
+
+ /**
+ * Activate motion sensing.
+ */
+ public void activateMotionSensing() {
+ manager.activateMotionSensing(id);
+ }
+
+ /**
+ * Deactivate motion sensing.
+ */
+ public void deactivateMotionSensing() {
+ manager.deactivateMotionSensing(id);
+ }
+
+ /**
+ * Activate smoothing.
+ */
+ public void activateSmoothing() {
+ manager.activateSmoothing(id);
+ }
+
+ /**
+ * Deactivate smoothing.
+ */
+ public void deactivateSmoothing() {
+ manager.deactivateSmoothing(id);
+ }
+
+ /**
+ * Activate continuous.
+ */
+ public void activateContinuous() {
+ manager.activateContinuous(id);
+ }
+
+ /**
+ * Deactivate continuous.
+ */
+ public void deactivateContinuous() {
+ manager.deactivateContinuous(id);
+
+ }
+
+ /**
+ * Set leds status.
+ *
+ * @param l1
+ * status of led1. True : ON, False : OFF
+ * @param l2
+ * status of led2. True : ON, False : OFF
+ * @param l3
+ * status of led3. True : ON, False : OFF
+ * @param l4
+ * status of led4. True : ON, False : OFF
+ */
+ public void setLeds(boolean l1, boolean l2, boolean l3, boolean l4) {
+ manager.setLeds(id, l1, l2, l3, l4);
+ }
+
+ /**
+ * Set the orientation threshold (minimum angle between two degrees with accelerometer).
+ * @param th
+ * threshold in degrees
+ */
+ public void setOrientationThreshold(float th) {
+ manager.setOrientationThreshold(id,th);
+ }
+
+ /**
+ * Set the acceleration threshold .
+ * @param th
+ * threshold
+ */
+ public void setAccelerationThreshold(int th) {
+ manager.setAccelerationThreshold(id,th);
+ }
+
+ /**
+ * Set the alpha smoothing value.
+ * @param th
+ * threshold
+ */
+ public void setAlphaSmoothingValue(float th) {
+ manager.setAlphaSmoothing(id,th);
+ }
+
+ /**
+ * Set the screen aspect ratio to be considered as 4/3.
+ */
+ public void setScreenAspectRatio43() {
+ manager.setScreenAspectRatio43(id);
+ }
+
+ /**
+ * Set the screen aspect ratio to be considered as 16/9.
+ */
+ public void setScreenAspectRatio169() {
+ manager.setScreenAspectRatio169(id);
+ }
+
+ /**
+ * Set the sensor bar to be considered above the screen.
+ */
+ public void setSensorBarAboveScreen() {
+ manager.setSensorBarAboveScreen(id);
+ }
+
+ /**
+ * Set the sensor bar to be considered below the screen.
+ */
+ public void setSensorBarBelowScreen() {
+ manager.setSensorBarBelowScreen(id);
+ }
+
+ /**
+ * Set the screen resolution of the you are pointing at
+ * with your wiimote.
+ *
+ * @param x x resolution.
+ * @param y y resolution.
+ */
+ public void setVirtualResolution(int x, int y) {
+ manager.setVirtualResolution(id, x ,y);
+ }
+
+ /**
+ * Try to resync the wiimote by starting a new handshake.
+ */
+ public void reSync() {
+ manager.reSync(id);
+ }
+
+ /**
+ * Ask for the status of the wiimote.
+ * The result will be received in a status event object.
+ * Implements onStatusEvent on wiimote listener to get it.
+ */
+ public void getStatus() {
+ manager.getStatus(id);
+ }
+
+ /**
+ * Method called when a WiiUseApiEvent occurs.
+ * @param e the WiiUseApiEvent.
+ */
+ public void onWiiUseApiEvent(WiiUseApiEvent e) {
+ if (e.getWiimoteId() == id){
+ if (e.getEventType() == WiiUseApiEvent.GENERIC_EVENT){
+ notifyWiiMoteEventListeners((GenericEvent)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){
+ notifyStatusEventListeners((StatusEvent)e);
+ }else if (e.getEventType() == WiiUseApiEvent.DISCONNECTION_EVENT){
+ notifyDisconnectionEventListeners((DisconnectionEvent)e);
+ }
+ }
+ }
+
+ /**
+ * Add a WiimoteListener to the listeners list.
+ * @param listener a WiimoteListener
+ */
+ public void addWiiMoteEventListeners(WiimoteListener listener) {
+ listeners.add(WiimoteListener.class, listener);
+ }
+
+ /**
+ * Remove a WiimoteListener from the listeners list.
+ * @param listener a WiimoteListener
+ */
+ public void removeWiiMoteEventListeners(WiimoteListener listener) {
+ listeners.remove(WiimoteListener.class, listener);
+ }
+
+ /**
+ * Get the list of WiimoteListener.
+ * @return the list of WiimoteListener.
+ */
+ public WiimoteListener[] getWiiMoteEventListeners() {
+ return listeners.getListeners(WiimoteListener.class);
+ }
+
+ /**
+ * Notify WiimoteListeners that an event occured.
+ * Notify in first the listeners for Buttons Events.
+ * In second the listeners for IR Events.
+ * In third the listeners for Motion sensing events.
+ * @param evt WiimoteEvent occured
+ */
+ private void notifyWiiMoteEventListeners(GenericEvent evt) {
+ for (WiimoteListener listener : getWiiMoteEventListeners()) {
+ listener.onButtonsEvent(evt.getButtonsEvent());
+ if (evt.isThereIrEvent()){
+ listener.onIrEvent(evt.getIREvent());
+ }
+ if (evt.isThereMotionSensingEvent()){
+ listener.onMotionSensingEvent(evt.getMotionSensingEvent());
+ }
+ }
+ }
+
+ /**
+ * Notify WiimoteListener that a status event occured.
+ * @param evt status event occured
+ */
+ private void notifyStatusEventListeners(StatusEvent evt) {
+ for (WiimoteListener listener : getWiiMoteEventListeners()) {
+ listener.onStatusEvent(evt);
+ }
+ }
+
+ /**
+ * Notify WiimoteListener that a status event occured.
+ * @param evt status event occured
+ */
+ private void notifyDisconnectionEventListeners(DisconnectionEvent evt) {
+ for (WiimoteListener listener : getWiiMoteEventListeners()) {
+ listener.onDisconnectionEvent(evt);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Wiimote with ID : "+id;
+ }
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/test/CloseGuiTestCleanly.java b/WiiUseJ_0.11/src/wiiusej/test/CloseGuiTestCleanly.java
new file mode 100644
index 0000000..ae136bf
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/test/CloseGuiTestCleanly.java
@@ -0,0 +1,65 @@
+/**
+ * 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.test;
+
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import wiiusej.WiiUseApiManager;
+import wiiusej.Wiimote;
+
+/**
+ * This class is used to close wiiusej cleanly.
+ * @author guiguito
+ */
+public class CloseGuiTestCleanly implements WindowListener{
+
+ Wiimote wiimote;
+
+
+ public CloseGuiTestCleanly(Wiimote wim) {
+ wiimote = wim;
+ }
+
+ public void windowOpened(WindowEvent e) {
+ //nothing
+ }
+
+ public void windowClosing(WindowEvent e) {
+ WiiUseApiManager.getInstance().shutdown();
+ }
+
+ public void windowClosed(WindowEvent e) {
+ //nothing
+ }
+
+ public void windowIconified(WindowEvent e) {
+ //nothing
+ }
+
+ public void windowDeiconified(WindowEvent e) {
+ //nothing
+ }
+
+ public void windowActivated(WindowEvent e) {
+ //nothing
+ }
+
+ public void windowDeactivated(WindowEvent e) {
+ //nothing
+ }
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/test/Main.java b/WiiUseJ_0.11/src/wiiusej/test/Main.java
new file mode 100644
index 0000000..daaca2a
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/test/Main.java
@@ -0,0 +1,40 @@
+/**
+ * This file is part of WiiuseJ.
+ *
+ * WiiuseJ is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * WiiuseJ is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with WiiuseJ. If not, see .
+ */
+package wiiusej.test;
+
+import wiiusej.WiiUseApiManager;
+import wiiusej.Wiimote;
+
+/**
+ * Main Class to launch WiiuseJ GUI Test.
+ * @author guiguito
+ */
+public class Main {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
+ if (wiimotes.length>0){
+ WiiuseJGuiTest gui = new WiiuseJGuiTest(wiimotes[0]);
+ gui.setDefaultCloseOperation(gui.EXIT_ON_CLOSE);
+ gui.setVisible(true);
+ }
+ }
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/test/Tests.java b/WiiUseJ_0.11/src/wiiusej/test/Tests.java
new file mode 100644
index 0000000..1a82547
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/test/Tests.java
@@ -0,0 +1,354 @@
+/**
+ * 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.test;
+
+import java.awt.AWTException;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+
+import wiiusej.WiiUseApiManager;
+import wiiusej.Wiimote;
+import wiiusej.values.IRSource;
+import wiiusej.wiiuseapievents.ButtonsEvent;
+import wiiusej.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiuseapievents.IREvent;
+import wiiusej.wiiuseapievents.MotionSensingEvent;
+import wiiusej.wiiuseapievents.StatusEvent;
+import wiiusej.wiiuseapievents.GenericEvent;
+import wiiusej.wiiuseapievents.WiimoteListener;
+
+/**
+ * This class used to test WiiuseJ.
+ *
+ * @author guiguito
+ */
+public class Tests implements WiimoteListener {
+
+ Robot robot;
+
+ private static int DISPLAY_EACH_VALUE = 1;
+ private static int DUMP = 2;
+ private static int MOVE_MOUSE = 3;
+ private static int TEST_LEDS = 5;
+
+ private Wiimote wiimote;
+
+ int dump = DISPLAY_EACH_VALUE;
+
+ public Tests(Wiimote wim) {
+ wiimote = wim;
+ wiimote.addWiiMoteEventListeners(this);
+ try {
+ robot = new Robot();
+ } catch (AWTException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static int nb = 0;
+
+ public void onButtonsEvent(ButtonsEvent e) {
+ if (dump == DISPLAY_EACH_VALUE) {
+ // System.out.println("*********** WIIMOTE ID : "+
+ // e.getWiimoteId() + " **************");
+ /* button ONE */
+ if (e.isButtonOneJustPressed()) {
+ System.out.println("button one pressed");
+ }
+ if (e.isButtonOneHeld()) {
+ System.out.println("button one held");
+ }
+ if (e.isButtonOneJustReleased()) {
+ System.out.println("button one released");
+ }
+
+ /* button TWO */
+ if (e.isButtonTwoJustPressed()) {
+ System.out.println("button two pressed");
+ }
+ if (e.isButtonTwoHeld()) {
+ System.out.println("button two held");
+ }
+ if (e.isButtonTwoJustReleased()) {
+ System.out.println("button two released");
+ }
+
+ /* button A */
+ if (e.isButtonAJustPressed()) {
+ System.out.println("button A pressed");
+ }
+ if (e.isButtonAHeld()) {
+ System.out.println("button A held");
+ }
+ if (e.isButtonAJustReleased()) {
+ System.out.println("button A released");
+ }
+
+ /* button B */
+ if (e.isButtonBJustPressed()) {
+ System.out.println("button B pressed");
+ }
+ if (e.isButtonBHeld()) {
+ System.out.println("button B held");
+ }
+ if (e.isButtonBJustReleased()) {
+ System.out.println("button B released");
+ }
+
+ /* button LEFT */
+ if (e.isButtonLeftJustPressed()) {
+ System.out.println("button Left pressed");
+ }
+ if (e.isButtonLeftHeld()) {
+ System.out.println("button Left held");
+ }
+ if (e.isButtonLeftJustReleased()) {
+ System.out.println("button Left released");
+ }
+
+ /* button RIGHT */
+ if (e.isButtonRightJustPressed()) {
+ System.out.println("button Right pressed");
+ }
+ if (e.isButtonRightHeld()) {
+ System.out.println("button Right held");
+ }
+ if (e.isButtonRightJustReleased()) {
+ System.out.println("button Right released");
+ }
+
+ /* button UP */
+ if (e.isButtonUpJustPressed()) {
+ System.out.println("button UP pressed");
+ }
+ if (e.isButtonUpHeld()) {
+ System.out.println("button UP held");
+ }
+ if (e.isButtonUpJustReleased()) {
+ System.out.println("button UP released");
+ }
+
+ /* button DOWN */
+ if (e.isButtonDownJustPressed()) {
+ System.out.println("button DOWN pressed");
+ }
+ if (e.isButtonDownHeld()) {
+ System.out.println("button DOWN held");
+ }
+ if (e.isButtonDownJustReleased()) {
+ System.out.println("button DOWN released");
+ }
+
+ /* button MINUS */
+ if (e.isButtonMinusJustPressed()) {
+ System.out.println("button MINUS pressed");
+ }
+ if (e.isButtonMinusHeld()) {
+ System.out.println("button MINUS held");
+ }
+ if (e.isButtonMinusJustReleased()) {
+ System.out.println("button MINUS released");
+ }
+
+ /* button PLUS */
+ if (e.isButtonPlusJustPressed()) {
+ System.out.println("button PLUS pressed");
+ }
+ if (e.isButtonPlusHeld()) {
+ System.out.println("button PLUS held");
+ }
+ if (e.isButtonPlusJustReleased()) {
+ System.out.println("button PLUS released");
+ }
+
+ /* button HOME */
+ if (e.isButtonHomeJustPressed()) {
+ System.out.println("button HOME pressed");
+ }
+ if (e.isButtonHomeHeld()) {
+ System.out.println("button HOME held");
+ }
+ if (e.isButtonHomeJustReleased()) {
+ System.out.println("button HOME released");
+ }
+
+ /* get status */
+ if (e.isButtonUpJustPressed()) {
+ wiimote.getStatus();
+ }
+
+ /* Activate rumble */
+ if (e.isButtonOneJustPressed()) {
+ System.out.println("Rumble Activated");
+ wiimote.activateRumble();
+ }
+ if (e.isButtonTwoJustPressed()) {
+ System.out.println("Rumble Deactivated");
+ wiimote.deactivateRumble();
+ }
+
+ /* Activate IR Tracking */
+ if (e.isButtonAJustPressed()) {
+ System.out.println("IR Activated");
+ wiimote.activateIRTRacking();
+ }
+ if (e.isButtonBJustPressed()) {
+ System.out.println("IR Deactivated");
+ wiimote.deactivateIRTRacking();
+ }
+
+ /* Activate Motion sensing */
+ if (e.isButtonPlusJustPressed()) {
+ System.out.println("Motion sensing Activated");
+ wiimote.activateMotionSensing();
+ }
+ if (e.isButtonMinusJustPressed()) {
+ System.out.println("Motion sensing Deactivated");
+ wiimote.deactivateMotionSensing();
+ }
+
+ /* leave test */
+ if (e.isButtonHomeJustPressed()) {
+ System.out.println("LEAVING TEST");
+ wiimote.disconnect();
+ }
+
+ } else if (dump == DUMP) {
+ System.out.println(e);
+ /* Activate all */
+ if (e.isButtonAJustPressed()) {
+ System.out.println("IR, rumble and motion sensing Activated");
+ wiimote.activateIRTRacking();
+ wiimote.activateMotionSensing();
+ wiimote.activateRumble();
+ }
+ if (e.isButtonBJustPressed()) {
+ System.out.println("IR, rumble and motion sensing Deactivated");
+ wiimote.deactivateIRTRacking();
+ wiimote.deactivateMotionSensing();
+ wiimote.deactivateRumble();
+ }
+
+ /* leave test */
+ if (e.isButtonHomeJustPressed()) {
+ System.out.println("LEAVING TEST");
+ wiimote.disconnect();
+ }
+ } else if (dump == MOVE_MOUSE) {
+ /* Activate IR Tracking */
+ if (e.isButtonOneJustPressed()) {
+ System.out.println("IR Activated");
+ wiimote.activateIRTRacking();
+ }
+ if (e.isButtonTwoJustPressed()) {
+ System.out.println("IR Deactivated");
+ wiimote.deactivateIRTRacking();
+ }
+
+ /* button A */
+ if (e.isButtonAJustPressed()) {
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ }
+ if (e.isButtonAJustReleased()) {
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ }
+
+ /* button B */
+ if (e.isButtonBJustPressed()) {
+ robot.mousePress(InputEvent.BUTTON2_MASK);
+ }
+ if (e.isButtonBJustReleased()) {
+ robot.mouseRelease(InputEvent.BUTTON2_MASK);
+ }
+
+ /* leave test */
+ if (e.isButtonHomeJustPressed()) {
+ System.out.println("LEAVING TEST");
+ wiimote.disconnect();
+ }
+ } else if (dump == TEST_LEDS) {
+ wiimote.activateMotionSensing();
+ if (e.isButtonUpJustPressed()) {
+ wiimote.setLeds(true, false, false, false);
+ }
+ if (e.isButtonDownJustPressed()) {
+ wiimote.setLeds(false, true, false, false);
+ }
+ if (e.isButtonLeftJustPressed()) {
+ wiimote.setLeds(false, false, true, false);
+ }
+ if (e.isButtonRightJustPressed()) {
+ wiimote.setLeds(false, false, false, true);
+ }
+
+ /* leave test */
+ if (e.isButtonHomeJustPressed()) {
+ System.out.println("LEAVING TEST");
+ wiimote.disconnect();
+ }
+ }
+
+ }
+
+ public void onIrEvent(IREvent e) {
+ if (dump == MOVE_MOUSE) {
+ IRSource[] list = e.getIRPoints();
+ if (list.length > 0) {
+ int x1 = (int) list[0].getX();
+ int y1 = (int) list[0].getY();
+
+ int mousex = (int) Math.round(((double) x1 / 1024.0) * 1280.0);
+ int mousey = (int) Math.round(((double) y1 / 768.0) * 1024.0);
+ robot.mouseMove(mousex, mousey);
+ }
+ } else {
+ System.out.println(e);
+ }
+ }
+
+ public void onMotionSensingEvent(MotionSensingEvent e) {
+ /* display motion sensing */
+ System.out.println(e);
+ }
+
+ public void onStatusEvent(StatusEvent e) {
+ // Display status variables
+ System.out.println(e);
+ }
+
+ public void onDisconnectionEvent(DisconnectionEvent e) {
+ System.out.println(" wiimote " + e.getWiimoteId()
+ + "has been disconnected !!");
+ }
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(4, true);
+ if (wiimotes.length > 0) {
+ System.out.println(wiimotes[0]);
+ Tests tests = new Tests(wiimotes[0]);
+ } else {
+ System.out.println("No wiimotes found !!!");
+ }
+
+ // java.util.Timer timer = new java.util.Timer();
+ // timer.scheduleAtFixedRate(new LedsTask(), 0, 100);
+
+ }
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/test/WiiuseJGuiTest.java b/WiiUseJ_0.11/src/wiiusej/test/WiiuseJGuiTest.java
new file mode 100644
index 0000000..8bac8ae
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/test/WiiuseJGuiTest.java
@@ -0,0 +1,836 @@
+/**
+ * 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.test;
+
+import java.awt.AWTException;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import wiiusej.utils.IRPanel;
+import wiiusej.Wiimote;
+import wiiusej.utils.AccelerationPanel;
+import wiiusej.utils.GForcePanel;
+import wiiusej.utils.ButtonsEventPanel;
+import wiiusej.utils.OrientationPanel;
+import wiiusej.wiiuseapievents.ButtonsEvent;
+import wiiusej.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiuseapievents.IREvent;
+import wiiusej.wiiuseapievents.MotionSensingEvent;
+import wiiusej.wiiuseapievents.StatusEvent;
+import wiiusej.wiiuseapievents.WiimoteListener;
+
+/**
+ * Gui class to test WiiuseJ.
+ * @author guiguito
+ */
+public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListener {
+
+ private Wiimote wiimote;
+ private Robot robot = null;
+ private boolean statusMotionRequested = false;
+ private boolean statusIRRequested = false;
+
+ /** Creates new form WiiuseJGuiTest */
+ public WiiuseJGuiTest(Wiimote wiimote) {
+ initComponents();
+ this.wiimote = wiimote;
+ wiimote.addWiiMoteEventListeners((IRPanel) irViewPanel);
+ wiimote.addWiiMoteEventListeners((ButtonsEventPanel) buttonsPanel);
+ wiimote.addWiiMoteEventListeners((OrientationPanel) motionSensingPanel);
+ wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel);
+ wiimote.addWiiMoteEventListeners((AccelerationPanel) accelerationPanel);
+ wiimote.addWiiMoteEventListeners(this);
+ wiimote.deactivateContinuous();
+ wiimote.deactivateSmoothing();
+ wiimote.setScreenAspectRatio169();
+ wiimote.setSensorBarBelowScreen();
+ getStatusButtonMousePressed(null);
+ this.addWindowListener(new CloseGuiTestCleanly(wiimote));
+ }
+
+ public void onButtonsEvent(ButtonsEvent arg0) {
+ if (robot != null) {
+ if (arg0.isButtonAPressed()) {
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+
+ }
+ if (arg0.isButtonBPressed()) {
+ robot.mousePress(InputEvent.BUTTON2_MASK);
+
+ }
+ if (arg0.isButtonOnePressed()) {
+ robot.mousePress(InputEvent.BUTTON3_MASK);
+
+ }
+ if (arg0.isButtonAJustReleased()) {
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ }
+ if (arg0.isButtonBJustReleased()) {
+ robot.mouseRelease(InputEvent.BUTTON2_MASK);
+
+ }
+ if (arg0.isButtonOneJustReleased()) {
+ robot.mouseRelease(InputEvent.BUTTON3_MASK);
+
+ }
+ if (arg0.isButtonUpPressed()) {//mouse wheel up
+ robot.mouseWheel(-1);
+ }
+ if (arg0.isButtonDownPressed()) {//mouse wheel down
+ robot.mouseWheel(1);
+ }
+
+ if (arg0.isButtonTwoPressed()) {//stop mouse control
+ mouseIRControlButtonMousePressed(null);
+ }
+ }
+ }
+
+ public void onIrEvent(IREvent arg0) {
+ if (robot != null) {//if mouse control activated
+ robot.mouseMove(arg0.getX(), arg0.getY());
+ }
+ if (statusIRRequested){
+ xResolutionTextField.setText(""+arg0.getXVRes());
+ yResolutionTextField.setText(""+arg0.getYVRes());
+ statusIRRequested = false;
+ }
+ }
+
+ public void onMotionSensingEvent(MotionSensingEvent arg0) {
+ if (statusMotionRequested){//Status requested
+ accelerationThresholdTextField.setText(""+arg0.getAccelerationThreshold());
+ orientationThresholdTextField.setText(""+arg0.getOrientationThreshold());
+ alphaSmoothingTextField.setText(""+arg0.getAlphaSmoothing());
+ statusMotionRequested = false;
+ }
+ }
+
+ public void onStatusEvent(StatusEvent arg0) {
+ messageText.setText("Status received !");
+ batteryLevelText.setText(arg0.getBatteryLevel() + " %");
+ led1Button.setEnabled(arg0.isLed1Set());
+ led2Button.setEnabled(arg0.isLed2Set());
+ led3Button.setEnabled(arg0.isLed3Set());
+ led4Button.setEnabled(arg0.isLed4Set());
+ //attachments
+ int eventType = arg0.getEventType();
+ if (eventType == StatusEvent.WIIUSE_CLASSIC_CTRL_INSERTED){
+ expansionText.setText("Classic control connected.");
+ }else
+ if (eventType == StatusEvent.WIIUSE_CLASSIC_CTRL_REMOVED){
+ expansionText.setText("Classic control removed.");
+ }else
+ if (eventType == StatusEvent.WIIUSE_NUNCHUK_INSERTED){
+ expansionText.setText("Nunchuk connected.");
+ }else
+ if (eventType == StatusEvent.WIIUSE_NUNCHUK_REMOVED){
+ expansionText.setText("Nunchuk removed.");
+ }else
+ if (eventType == StatusEvent.WIIUSE_GUITAR_HERO_3_CTRL_INSERTED){
+ expansionText.setText("Guitar Hero 3 control connected.");
+ }else
+ if (eventType == StatusEvent.WIIUSE_GUITAR_HERO_3_CTRL_REMOVED){
+ expansionText.setText("Guitar Hero 3 control removed.");
+ }
+ }
+
+ public void onDisconnectionEvent(DisconnectionEvent arg0) {
+ messageText.setText("Wiimote Disconnected !");
+ }
+
+ /** 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.
+ */
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ leftPanel = new javax.swing.JPanel();
+ irViewPanel = new IRPanel();
+ jTabbedPane1 = new javax.swing.JTabbedPane();
+ motionSensingPanel = new OrientationPanel();
+ gForcePanel = new wiiusej.utils.GForcePanel();
+ accelerationPanel = new AccelerationPanel();
+ rightPanel = new javax.swing.JPanel();
+ fixedWiimotePanel = new javax.swing.JPanel();
+ buttonsPanel = new ButtonsEventPanel();
+ controlsPanel = new javax.swing.JPanel();
+ activateRumblePanel = new javax.swing.JPanel();
+ toggleRumbleButton = new javax.swing.JButton();
+ deactivateRumblePanel = new javax.swing.JPanel();
+ toggleIRTrackingButton = new javax.swing.JButton();
+ activateIRtrackingPanel = new javax.swing.JPanel();
+ toggleMotionSensingTrackingButton = new javax.swing.JButton();
+ deactivateIRTrackingPanel = new javax.swing.JPanel();
+ toggleSmoothingButton = new javax.swing.JButton();
+ activateMotionSensingTrackingPanel = new javax.swing.JPanel();
+ toggleContinuousButton = new javax.swing.JButton();
+ deactivateMotionSensingTrackingPanel = new javax.swing.JPanel();
+ led1Button = new javax.swing.JButton();
+ led2Button = new javax.swing.JButton();
+ led3Button = new javax.swing.JButton();
+ led4Button = new javax.swing.JButton();
+ setLedsButton = new javax.swing.JButton();
+ activateSmoothingPanel = new javax.swing.JPanel();
+ alphaSmoothingTextField = new javax.swing.JTextField();
+ alphaSmoothingButton = new javax.swing.JButton();
+ deactivateSmoothingPanel = new javax.swing.JPanel();
+ orientationThresholdTextField = new javax.swing.JTextField();
+ orientationThresholdButton = new javax.swing.JButton();
+ activateContinuousPanel = new javax.swing.JPanel();
+ accelerationThresholdTextField = new javax.swing.JTextField();
+ accelerationThresholdButton = new javax.swing.JButton();
+ deactivateContinuousPanel = new javax.swing.JPanel();
+ getStatusButton = new javax.swing.JButton();
+ batteryText = new javax.swing.JLabel();
+ batteryLevelText = new javax.swing.JLabel();
+ ledsPanel = new javax.swing.JPanel();
+ toggleSensorBarPositionButton = new javax.swing.JButton();
+ alphaSmoothingPanel = new javax.swing.JPanel();
+ toggleScreenAspectRatioButton = new javax.swing.JButton();
+ orientationThresholdPanel = new javax.swing.JPanel();
+ xLabel = new javax.swing.JLabel();
+ xResolutionTextField = new javax.swing.JTextField();
+ yLabel = new javax.swing.JLabel();
+ yResolutionTextField = new javax.swing.JTextField();
+ setVirtualResolutionButton = new javax.swing.JButton();
+ accelerationThresholdPanel = new javax.swing.JPanel();
+ mouseIRControlButton = new javax.swing.JButton();
+ batteryPanel = new javax.swing.JPanel();
+ expansionText = new javax.swing.JLabel();
+ messagesPanel = new javax.swing.JPanel();
+ messageLabelText = new javax.swing.JLabel();
+ messageText = new javax.swing.JLabel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ setTitle("WiiuseJ Test GUI");
+ setName("WiiuseJ Test GUI"); // NOI18N
+
+ leftPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
+
+ irViewPanel.setBackground(new java.awt.Color(0, 0, 0));
+ irViewPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 153, 153), 2, true), "IR View", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 0, 51)));
+
+ javax.swing.GroupLayout irViewPanelLayout = new javax.swing.GroupLayout(irViewPanel);
+ irViewPanel.setLayout(irViewPanelLayout);
+ irViewPanelLayout.setHorizontalGroup(
+ irViewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 272, Short.MAX_VALUE)
+ );
+ irViewPanelLayout.setVerticalGroup(
+ irViewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 299, Short.MAX_VALUE)
+ );
+
+ javax.swing.GroupLayout motionSensingPanelLayout = new javax.swing.GroupLayout(motionSensingPanel);
+ motionSensingPanel.setLayout(motionSensingPanelLayout);
+ motionSensingPanelLayout.setHorizontalGroup(
+ motionSensingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 279, Short.MAX_VALUE)
+ );
+ motionSensingPanelLayout.setVerticalGroup(
+ motionSensingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 213, Short.MAX_VALUE)
+ );
+
+ jTabbedPane1.addTab("Orientation", motionSensingPanel);
+
+ javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(gForcePanel);
+ gForcePanel.setLayout(gForcePanelLayout);
+ gForcePanelLayout.setHorizontalGroup(
+ gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 279, Short.MAX_VALUE)
+ );
+ gForcePanelLayout.setVerticalGroup(
+ gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 213, Short.MAX_VALUE)
+ );
+
+ jTabbedPane1.addTab("GForce", gForcePanel);
+
+ javax.swing.GroupLayout accelerationPanelLayout = new javax.swing.GroupLayout(accelerationPanel);
+ accelerationPanel.setLayout(accelerationPanelLayout);
+ accelerationPanelLayout.setHorizontalGroup(
+ accelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 279, Short.MAX_VALUE)
+ );
+ accelerationPanelLayout.setVerticalGroup(
+ accelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 213, Short.MAX_VALUE)
+ );
+
+ jTabbedPane1.addTab("Raw Acceleration", accelerationPanel);
+
+ javax.swing.GroupLayout leftPanelLayout = new javax.swing.GroupLayout(leftPanel);
+ leftPanel.setLayout(leftPanelLayout);
+ leftPanelLayout.setHorizontalGroup(
+ leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(irViewPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
+ );
+ leftPanelLayout.setVerticalGroup(
+ leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, leftPanelLayout.createSequentialGroup()
+ .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(irViewPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ jTabbedPane1.getAccessibleContext().setAccessibleName("Orientation");
+
+ rightPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
+ rightPanel.setLayout(new javax.swing.BoxLayout(rightPanel, javax.swing.BoxLayout.LINE_AXIS));
+
+ fixedWiimotePanel.setMaximumSize(new java.awt.Dimension(120, 32767));
+ fixedWiimotePanel.setMinimumSize(new java.awt.Dimension(120, 100));
+ fixedWiimotePanel.setPreferredSize(new java.awt.Dimension(120, 100));
+ fixedWiimotePanel.setRequestFocusEnabled(false);
+ fixedWiimotePanel.setLayout(null);
+
+ buttonsPanel.setMaximumSize(new java.awt.Dimension(120, 484));
+ buttonsPanel.setMinimumSize(new java.awt.Dimension(120, 484));
+ buttonsPanel.setOpaque(false);
+ buttonsPanel.setPreferredSize(new java.awt.Dimension(120, 484));
+
+ javax.swing.GroupLayout buttonsPanelLayout = new javax.swing.GroupLayout(buttonsPanel);
+ buttonsPanel.setLayout(buttonsPanelLayout);
+ buttonsPanelLayout.setHorizontalGroup(
+ buttonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 120, Short.MAX_VALUE)
+ );
+ buttonsPanelLayout.setVerticalGroup(
+ buttonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 484, Short.MAX_VALUE)
+ );
+
+ fixedWiimotePanel.add(buttonsPanel);
+ buttonsPanel.setBounds(0, 0, 120, 484);
+
+ rightPanel.add(fixedWiimotePanel);
+
+ controlsPanel.setMinimumSize(new java.awt.Dimension(100, 264));
+ controlsPanel.setPreferredSize(new java.awt.Dimension(190, 264));
+ controlsPanel.setLayout(new java.awt.GridLayout(16, 1));
+
+ toggleRumbleButton.setText("Activate Rumble");
+ toggleRumbleButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ toggleRumbleButtonMousePressed(evt);
+ }
+ });
+ activateRumblePanel.add(toggleRumbleButton);
+
+ controlsPanel.add(activateRumblePanel);
+
+ toggleIRTrackingButton.setText("Activate IR Tracking");
+ toggleIRTrackingButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ toggleIRTrackingButtonMousePressed(evt);
+ }
+ });
+ deactivateRumblePanel.add(toggleIRTrackingButton);
+
+ controlsPanel.add(deactivateRumblePanel);
+
+ toggleMotionSensingTrackingButton.setText("Activate motion sensing Tracking");
+ toggleMotionSensingTrackingButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ toggleMotionSensingTrackingButtonMousePressed(evt);
+ }
+ });
+ activateIRtrackingPanel.add(toggleMotionSensingTrackingButton);
+
+ controlsPanel.add(activateIRtrackingPanel);
+
+ toggleSmoothingButton.setText("Activate Smoothing");
+ toggleSmoothingButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ toggleSmoothingButtonMousePressed(evt);
+ }
+ });
+ deactivateIRTrackingPanel.add(toggleSmoothingButton);
+
+ controlsPanel.add(deactivateIRTrackingPanel);
+
+ toggleContinuousButton.setText("Activate Continuous");
+ toggleContinuousButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ toggleContinuousButtonMousePressed(evt);
+ }
+ });
+ activateMotionSensingTrackingPanel.add(toggleContinuousButton);
+
+ controlsPanel.add(activateMotionSensingTrackingPanel);
+
+ led1Button.setText("Led1");
+ led1Button.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ led1ButtonMousePressed(evt);
+ }
+ });
+ deactivateMotionSensingTrackingPanel.add(led1Button);
+
+ led2Button.setText("Led2");
+ led2Button.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ led2ButtonMousePressed(evt);
+ }
+ });
+ deactivateMotionSensingTrackingPanel.add(led2Button);
+
+ led3Button.setText("Led3");
+ led3Button.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ led3ButtonMousePressed(evt);
+ }
+ });
+ deactivateMotionSensingTrackingPanel.add(led3Button);
+
+ led4Button.setText("Led4");
+ led4Button.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ led4ButtonMousePressed(evt);
+ }
+ });
+ deactivateMotionSensingTrackingPanel.add(led4Button);
+
+ setLedsButton.setText("Set leds");
+ setLedsButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ setLedsButtonMousePressed(evt);
+ }
+ });
+ deactivateMotionSensingTrackingPanel.add(setLedsButton);
+
+ controlsPanel.add(deactivateMotionSensingTrackingPanel);
+
+ alphaSmoothingTextField.setMinimumSize(new java.awt.Dimension(100, 20));
+ alphaSmoothingTextField.setPreferredSize(new java.awt.Dimension(100, 20));
+ activateSmoothingPanel.add(alphaSmoothingTextField);
+
+ alphaSmoothingButton.setText("Set alpha smoothing");
+ alphaSmoothingButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ alphaSmoothingButtonMousePressed(evt);
+ }
+ });
+ activateSmoothingPanel.add(alphaSmoothingButton);
+
+ controlsPanel.add(activateSmoothingPanel);
+
+ orientationThresholdTextField.setMinimumSize(new java.awt.Dimension(100, 20));
+ orientationThresholdTextField.setPreferredSize(new java.awt.Dimension(100, 20));
+ deactivateSmoothingPanel.add(orientationThresholdTextField);
+
+ orientationThresholdButton.setText("Set orientation threshold");
+ orientationThresholdButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ orientationThresholdButtonMousePressed(evt);
+ }
+ });
+ deactivateSmoothingPanel.add(orientationThresholdButton);
+
+ controlsPanel.add(deactivateSmoothingPanel);
+
+ accelerationThresholdTextField.setPreferredSize(new java.awt.Dimension(100, 20));
+ activateContinuousPanel.add(accelerationThresholdTextField);
+
+ accelerationThresholdButton.setText("Set acceleration threshold");
+ accelerationThresholdButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ accelerationThresholdButtonMousePressed(evt);
+ }
+ });
+ activateContinuousPanel.add(accelerationThresholdButton);
+
+ controlsPanel.add(activateContinuousPanel);
+
+ getStatusButton.setText("Get status");
+ getStatusButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ getStatusButtonMousePressed(evt);
+ }
+ });
+ deactivateContinuousPanel.add(getStatusButton);
+
+ batteryText.setFont(new java.awt.Font("Tahoma", 0, 14));
+ batteryText.setText("Battery level :");
+ deactivateContinuousPanel.add(batteryText);
+
+ batteryLevelText.setFont(new java.awt.Font("Arial", 0, 14));
+ batteryLevelText.setText(" %");
+ deactivateContinuousPanel.add(batteryLevelText);
+
+ controlsPanel.add(deactivateContinuousPanel);
+
+ toggleSensorBarPositionButton.setText("Set sensor bar above");
+ toggleSensorBarPositionButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ toggleSensorBarPositionButtonMousePressed(evt);
+ }
+ });
+ ledsPanel.add(toggleSensorBarPositionButton);
+
+ controlsPanel.add(ledsPanel);
+
+ toggleScreenAspectRatioButton.setText("Set screen aspect ratio 4/3");
+ toggleScreenAspectRatioButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ toggleScreenAspectRatioButtonMousePressed(evt);
+ }
+ });
+ alphaSmoothingPanel.add(toggleScreenAspectRatioButton);
+
+ controlsPanel.add(alphaSmoothingPanel);
+
+ xLabel.setText("X");
+ orientationThresholdPanel.add(xLabel);
+
+ xResolutionTextField.setMinimumSize(new java.awt.Dimension(40, 20));
+ xResolutionTextField.setPreferredSize(new java.awt.Dimension(40, 20));
+ orientationThresholdPanel.add(xResolutionTextField);
+
+ yLabel.setText("Y");
+ orientationThresholdPanel.add(yLabel);
+
+ yResolutionTextField.setFocusTraversalPolicyProvider(true);
+ yResolutionTextField.setMinimumSize(new java.awt.Dimension(40, 20));
+ yResolutionTextField.setPreferredSize(new java.awt.Dimension(40, 20));
+ orientationThresholdPanel.add(yResolutionTextField);
+
+ setVirtualResolutionButton.setText("Set virtual resolution");
+ setVirtualResolutionButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ setVirtualResolutionButtonMousePressed(evt);
+ }
+ });
+ orientationThresholdPanel.add(setVirtualResolutionButton);
+
+ controlsPanel.add(orientationThresholdPanel);
+
+ mouseIRControlButton.setText("Start infrared mouse control");
+ mouseIRControlButton.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mousePressed(java.awt.event.MouseEvent evt) {
+ mouseIRControlButtonMousePressed(evt);
+ }
+ });
+ accelerationThresholdPanel.add(mouseIRControlButton);
+
+ controlsPanel.add(accelerationThresholdPanel);
+
+ expansionText.setText("No expansion connected");
+ batteryPanel.add(expansionText);
+
+ controlsPanel.add(batteryPanel);
+
+ messageLabelText.setFont(new java.awt.Font("Tahoma", 0, 14));
+ messageLabelText.setText("Message : ");
+ messagesPanel.add(messageLabelText);
+
+ messageText.setFont(new java.awt.Font("Arial", 0, 14));
+ messageText.setText("None");
+ messagesPanel.add(messageText);
+
+ controlsPanel.add(messagesPanel);
+
+ rightPanel.add(controlsPanel);
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(leftPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(leftPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE)
+ );
+
+ java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
+ setBounds((screenSize.width-800)/2, (screenSize.height-600)/2, 800, 600);
+ }// //GEN-END:initComponents
+ private void toggleRumbleButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleRumbleButtonMousePressed
+ if (toggleRumbleButton.isEnabled()) {
+ wiimote.activateRumble();
+ toggleRumbleButton.setEnabled(false);
+ toggleRumbleButton.setText("Deactivate Rumble");
+ messageText.setText("Rumble activated");
+ } else {
+ wiimote.deactivateRumble();
+ toggleRumbleButton.setEnabled(true);
+ toggleRumbleButton.setText("Activate Rumble");
+ messageText.setText("Rumble deactivated");
+ }
+ }//GEN-LAST:event_toggleRumbleButtonMousePressed
+
+ private void toggleIRTrackingButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleIRTrackingButtonMousePressed
+ if (toggleIRTrackingButton.isEnabled()) {
+ wiimote.activateIRTRacking();
+ toggleIRTrackingButton.setEnabled(false);
+ toggleIRTrackingButton.setText("Deactivate IR Tracking");
+ messageText.setText("IR Tracking activated");
+ } else {
+ wiimote.deactivateIRTRacking();
+ toggleIRTrackingButton.setEnabled(true);
+ toggleIRTrackingButton.setText("Activate IR Tracking");
+ ((IRPanel) irViewPanel).onDisconnectionEvent(null);
+ messageText.setText("IR Tracking deactivated");
+ }
+ }//GEN-LAST:event_toggleIRTrackingButtonMousePressed
+
+ private void toggleMotionSensingTrackingButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleMotionSensingTrackingButtonMousePressed
+ if (toggleMotionSensingTrackingButton.isEnabled()) {
+ wiimote.activateMotionSensing();
+ toggleMotionSensingTrackingButton.setEnabled(false);
+ toggleMotionSensingTrackingButton.setText("Deactivate Motion Sensing");
+ messageText.setText("Motion Sensing activated");
+ } else {
+ wiimote.deactivateMotionSensing();
+ toggleMotionSensingTrackingButton.setEnabled(true);
+ toggleMotionSensingTrackingButton.setText("Activate Motion Sensing");
+ ((OrientationPanel) motionSensingPanel).onDisconnectionEvent(null);
+ ((GForcePanel) gForcePanel).onDisconnectionEvent(null);
+ messageText.setText("Motion Sensing deactivated");
+ }
+ }//GEN-LAST:event_toggleMotionSensingTrackingButtonMousePressed
+
+ private void toggleSmoothingButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleSmoothingButtonMousePressed
+ if (toggleSmoothingButton.isEnabled()) {
+ wiimote.activateSmoothing();
+ toggleSmoothingButton.setEnabled(false);
+ toggleSmoothingButton.setText("Deactivate Alpha Smoothing");
+ messageText.setText("Alpha Smoothing activated");
+ } else {
+ wiimote.deactivateSmoothing();
+ toggleSmoothingButton.setEnabled(true);
+ toggleSmoothingButton.setText("Activate Alpha Smoothing");
+ messageText.setText("Alpha Smoothing deactivated");
+ }
+ }//GEN-LAST:event_toggleSmoothingButtonMousePressed
+
+ private void toggleContinuousButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleContinuousButtonMousePressed
+ if (toggleContinuousButton.isEnabled()) {
+ wiimote.activateContinuous();
+ toggleContinuousButton.setEnabled(false);
+ toggleContinuousButton.setText("Deactivate Continuous");
+ messageText.setText("Continuous activated");
+ } else {
+ wiimote.deactivateContinuous();
+ toggleContinuousButton.setEnabled(true);
+ toggleContinuousButton.setText("Activate Continuous");
+ messageText.setText("Continuous deactivated");
+ }
+ }//GEN-LAST:event_toggleContinuousButtonMousePressed
+
+ private void led1ButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_led1ButtonMousePressed
+ if (led1Button.isEnabled()) {
+ led1Button.setEnabled(false);
+ } else {
+ led1Button.setEnabled(true);
+ }
+ }//GEN-LAST:event_led1ButtonMousePressed
+
+ private void led2ButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_led2ButtonMousePressed
+ if (led2Button.isEnabled()) {
+ led2Button.setEnabled(false);
+ } else {
+ led2Button.setEnabled(true);
+ }
+ }//GEN-LAST:event_led2ButtonMousePressed
+
+ private void led3ButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_led3ButtonMousePressed
+ if (led3Button.isEnabled()) {
+ led3Button.setEnabled(false);
+ } else {
+ led3Button.setEnabled(true);
+ }
+ }//GEN-LAST:event_led3ButtonMousePressed
+
+ private void led4ButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_led4ButtonMousePressed
+ if (led4Button.isEnabled()) {
+ led4Button.setEnabled(false);
+ } else {
+ led4Button.setEnabled(true);
+ }
+ }//GEN-LAST:event_led4ButtonMousePressed
+
+ private void setLedsButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_setLedsButtonMousePressed
+ wiimote.setLeds(led1Button.isEnabled(), led2Button.isEnabled(),
+ led3Button.isEnabled(), led4Button.isEnabled());
+ messageText.setText("Leds set");
+ }//GEN-LAST:event_setLedsButtonMousePressed
+
+ private void alphaSmoothingButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_alphaSmoothingButtonMousePressed
+ try {
+ float nb = Float.parseFloat(alphaSmoothingTextField.getText());
+ wiimote.setAlphaSmoothingValue(nb);
+ messageText.setText("Alpha smoothing set to " + nb);
+ } catch (NumberFormatException e) {
+ messageText.setText("Number is not a float, alpha smoothing not set !");
+ }
+ }//GEN-LAST:event_alphaSmoothingButtonMousePressed
+
+ private void orientationThresholdButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_orientationThresholdButtonMousePressed
+ try {
+ float nb = Float.parseFloat(orientationThresholdTextField.getText());
+ wiimote.setOrientationThreshold(nb);
+ messageText.setText("Orientation threshold set to " + nb);
+ } catch (NumberFormatException e) {
+ messageText.setText("Number is not a float, orientation threshold not set !");
+ }
+ }//GEN-LAST:event_orientationThresholdButtonMousePressed
+
+ private void accelerationThresholdButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_accelerationThresholdButtonMousePressed
+ try {
+ int nb = Integer.parseInt(accelerationThresholdTextField.getText());
+ wiimote.setAccelerationThreshold(nb);
+ messageText.setText("Acceleration threshold set to " + nb);
+ } catch (NumberFormatException e) {
+ messageText.setText("Number is not an integer, acceleration threshold not set !");
+ }
+ }//GEN-LAST:event_accelerationThresholdButtonMousePressed
+
+ private void getStatusButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_getStatusButtonMousePressed
+ wiimote.getStatus();
+ statusMotionRequested = true;
+ statusIRRequested = true;
+ }//GEN-LAST:event_getStatusButtonMousePressed
+
+ private void toggleSensorBarPositionButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleSensorBarPositionButtonMousePressed
+ if (toggleSensorBarPositionButton.isEnabled()) {
+ wiimote.setSensorBarBelowScreen();
+ toggleSensorBarPositionButton.setEnabled(false);
+ toggleSensorBarPositionButton.setText("Set sensor bar below");
+ messageText.setText("Sensor bar set above");
+ } else {
+ wiimote.setSensorBarAboveScreen();
+ toggleSensorBarPositionButton.setEnabled(true);
+ toggleSensorBarPositionButton.setText("Set sensor bar above");
+ messageText.setText("Sensor bar set below");
+ }
+ }//GEN-LAST:event_toggleSensorBarPositionButtonMousePressed
+
+ private void toggleScreenAspectRatioButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleScreenAspectRatioButtonMousePressed
+ if (toggleScreenAspectRatioButton.isEnabled()) {
+ wiimote.setScreenAspectRatio43();
+ toggleScreenAspectRatioButton.setEnabled(false);
+ toggleScreenAspectRatioButton.setText("Set screen aspect ratio 16/9");
+ messageText.setText("creen aspect ratio to 4/3");
+ } else {
+ wiimote.setScreenAspectRatio169();
+ toggleScreenAspectRatioButton.setEnabled(true);
+ toggleScreenAspectRatioButton.setText("Set screen aspect ratio 4/3");
+ messageText.setText("Screen aspect ratio to 16/9");
+ }
+ }//GEN-LAST:event_toggleScreenAspectRatioButtonMousePressed
+
+ private void setVirtualResolutionButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_setVirtualResolutionButtonMousePressed
+ try {
+ int xres = Integer.parseInt(xResolutionTextField.getText());
+ int yres = Integer.parseInt(yResolutionTextField.getText());
+ wiimote.setVirtualResolution(xres, yres);
+ messageText.setText("Virtual resolution set to " + xres + "X" + yres);
+ } catch (NumberFormatException e) {
+ messageText.setText("A number in the virtual resolution is not an integer. Virtual resolution not set!");
+ }
+ }//GEN-LAST:event_setVirtualResolutionButtonMousePressed
+
+ private void mouseIRControlButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mouseIRControlButtonMousePressed
+ if (mouseIRControlButton.isEnabled()) {
+ try {
+ mouseIRControlButton.setEnabled(false);
+ mouseIRControlButton.setText("Stop infrared mouse control");
+ robot = new Robot();
+ messageText.setText("Infrared mouse control started");
+ } catch (AWTException ex) {
+ Logger.getLogger(WiiuseJGuiTest.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ } else {
+ mouseIRControlButton.setEnabled(true);
+ mouseIRControlButton.setText("Start infrared mouse control");
+ robot = null;
+ messageText.setText("Infrared mouse control stopped");
+ }
+ }//GEN-LAST:event_mouseIRControlButtonMousePressed
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPanel accelerationPanel;
+ private javax.swing.JButton accelerationThresholdButton;
+ private javax.swing.JPanel accelerationThresholdPanel;
+ private javax.swing.JTextField accelerationThresholdTextField;
+ private javax.swing.JPanel activateContinuousPanel;
+ private javax.swing.JPanel activateIRtrackingPanel;
+ private javax.swing.JPanel activateMotionSensingTrackingPanel;
+ private javax.swing.JPanel activateRumblePanel;
+ private javax.swing.JPanel activateSmoothingPanel;
+ private javax.swing.JButton alphaSmoothingButton;
+ private javax.swing.JPanel alphaSmoothingPanel;
+ private javax.swing.JTextField alphaSmoothingTextField;
+ private javax.swing.JLabel batteryLevelText;
+ private javax.swing.JPanel batteryPanel;
+ private javax.swing.JLabel batteryText;
+ private javax.swing.JPanel buttonsPanel;
+ private javax.swing.JPanel controlsPanel;
+ private javax.swing.JPanel deactivateContinuousPanel;
+ private javax.swing.JPanel deactivateIRTrackingPanel;
+ private javax.swing.JPanel deactivateMotionSensingTrackingPanel;
+ private javax.swing.JPanel deactivateRumblePanel;
+ private javax.swing.JPanel deactivateSmoothingPanel;
+ private javax.swing.JLabel expansionText;
+ private javax.swing.JPanel fixedWiimotePanel;
+ private javax.swing.JPanel gForcePanel;
+ private javax.swing.JButton getStatusButton;
+ private javax.swing.JPanel irViewPanel;
+ private javax.swing.JTabbedPane jTabbedPane1;
+ private javax.swing.JButton led1Button;
+ private javax.swing.JButton led2Button;
+ private javax.swing.JButton led3Button;
+ private javax.swing.JButton led4Button;
+ private javax.swing.JPanel ledsPanel;
+ private javax.swing.JPanel leftPanel;
+ private javax.swing.JLabel messageLabelText;
+ private javax.swing.JLabel messageText;
+ private javax.swing.JPanel messagesPanel;
+ private javax.swing.JPanel motionSensingPanel;
+ private javax.swing.JButton mouseIRControlButton;
+ private javax.swing.JButton orientationThresholdButton;
+ private javax.swing.JPanel orientationThresholdPanel;
+ private javax.swing.JTextField orientationThresholdTextField;
+ private javax.swing.JPanel rightPanel;
+ private javax.swing.JButton setLedsButton;
+ private javax.swing.JButton setVirtualResolutionButton;
+ private javax.swing.JButton toggleContinuousButton;
+ private javax.swing.JButton toggleIRTrackingButton;
+ private javax.swing.JButton toggleMotionSensingTrackingButton;
+ private javax.swing.JButton toggleRumbleButton;
+ private javax.swing.JButton toggleScreenAspectRatioButton;
+ private javax.swing.JButton toggleSensorBarPositionButton;
+ private javax.swing.JButton toggleSmoothingButton;
+ private javax.swing.JLabel xLabel;
+ private javax.swing.JTextField xResolutionTextField;
+ private javax.swing.JLabel yLabel;
+ private javax.swing.JTextField yResolutionTextField;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/utils/AccelerationPanel.java b/WiiUseJ_0.11/src/wiiusej/utils/AccelerationPanel.java
new file mode 100644
index 0000000..0403255
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/utils/AccelerationPanel.java
@@ -0,0 +1,182 @@
+/**
+ * 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.utils;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.util.ArrayList;
+import wiiusej.values.RawAcceleration;
+import wiiusej.wiiuseapievents.ButtonsEvent;
+import wiiusej.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiuseapievents.IREvent;
+import wiiusej.wiiuseapievents.MotionSensingEvent;
+import wiiusej.wiiuseapievents.StatusEvent;
+import wiiusej.wiiuseapievents.WiimoteListener;
+
+/**
+ * This panel is used to watch raw acceleration values from a MotionSensingEvent.
+ * @author guiguito
+ */
+public class AccelerationPanel extends javax.swing.JPanel implements WiimoteListener {
+
+ private Image mImage;//image for double buffering
+ private Color xColor = Color.RED;
+ private Color yColor = Color.GREEN;
+ private Color zColor = Color.BLUE;
+ private Color backgroundColor = Color.WHITE;
+ private Color lineColor = Color.BLACK;
+ private ArrayList values = new ArrayList();
+
+ /** Creates new form AccelerationPanel */
+ public AccelerationPanel() {
+ initComponents();
+ }
+
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Dimension d = getSize();
+ checkOffScreenImage();
+ Graphics offG = mImage.getGraphics();
+ 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);
+
+ //draw medium line
+ int yLine = getHeight() - 25;
+
+ g2.setPaint(lineColor);
+ g2.drawLine(0, yLine, getWidth(), yLine);
+
+ RawAcceleration[] valuesArray = values.toArray(new RawAcceleration[0]);
+
+ double unit = yLine / 255.0;
+ int previousX = 0;
+ int previousY = 0;
+ int previousZ = 0;
+ //draw curves
+ for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
+ RawAcceleration acceleration = valuesArray[i];
+ //draw X
+ g2.setPaint(xColor);
+ int yDelta = (int) Math.round(unit * acceleration.getX());
+ int y = -1 * yDelta + yLine;
+ g2.drawLine(i - 1, previousX, i, y);
+ g2.setTransform(new AffineTransform());
+ previousX = y;
+ //draw Y
+ g2.setPaint(yColor);
+ yDelta = (int) Math.round(unit * acceleration.getY());
+ y = -1 * yDelta + yLine;
+ g2.drawLine(i - 1, previousY, i, y);
+ g2.setTransform(new AffineTransform());
+ previousY = y;
+ //draw Z
+ g2.setPaint(zColor);
+ yDelta = (int) Math.round(unit * acceleration.getZ());
+ y = -1 * yDelta + yLine;
+ g2.drawLine(i - 1, previousZ, i, y);
+ g2.setTransform(new AffineTransform());
+ previousZ = y;
+ }
+
+ //draw legend
+ g2.setPaint(xColor);
+ g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
+ g2.setPaint(yColor);
+ g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
+ g2.setPaint(zColor);
+ g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
+
+ g2.setPaint(lineColor);
+ g2.drawString("X", 30, getHeight() - 5);
+ g2.drawString("Y", 85, getHeight() - 5);
+ g2.drawString("Z", 145, getHeight() - 5);
+ g2.drawString("0", 2, yLine - 5);
+ g2.drawString("255", 2, 15);
+ //put offscreen image on the screen
+ g.drawImage(mImage, 0, 0, null);
+ }
+
+ /**
+ * 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) {
+ mImage = createImage(d.width, d.height);
+ }
+ }
+
+ public void onButtonsEvent(ButtonsEvent arg0) {
+ //nothing
+ }
+
+ public void onIrEvent(IREvent arg0) {
+ //nothing
+ }
+
+ public void onMotionSensingEvent(MotionSensingEvent arg0) {
+ if (values.size() >= getWidth()) {
+ //if there are as many values as pixels in the width
+ //clear points
+ values.clear();
+ }
+ values.add(arg0.getRawAcceleration());
+ repaint();
+ }
+
+ public void onStatusEvent(StatusEvent arg0) {
+ //nothing
+ }
+
+ public void onDisconnectionEvent(DisconnectionEvent arg0) {
+ //Clear points.
+ values.clear();
+ repaint();
+ }
+
+ /** 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.
+ */
+ // //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)
+ );
+ }// //GEN-END:initComponents
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/utils/ButtonsEventPanel.java b/WiiUseJ_0.11/src/wiiusej/utils/ButtonsEventPanel.java
new file mode 100644
index 0000000..2a4a48f
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/utils/ButtonsEventPanel.java
@@ -0,0 +1,297 @@
+/**
+ * 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.utils;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.Toolkit;
+import java.awt.geom.AffineTransform;
+import wiiusej.wiiuseapievents.ButtonsEvent;
+import wiiusej.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiuseapievents.IREvent;
+import wiiusej.wiiuseapievents.MotionSensingEvent;
+import wiiusej.wiiuseapievents.StatusEvent;
+import wiiusej.wiiuseapievents.WiimoteListener;
+
+/**
+ * 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 {
+
+ private Image mImage;//image for double buffering
+ private Image wiimoteImage;//image for double buffering
+ private ButtonsEvent buttons;
+ private Color pressedColor = Color.RED;
+ private Color heldColor = Color.ORANGE;
+ private Color releasedColor = Color.YELLOW;
+ private Shape shape;
+
+ /**
+ * 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");
+ wiimoteImage = toolkit.createImage(url);
+ shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13);
+ initComponents();
+ }
+
+ /**
+ * 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.
+ */
+ public ButtonsEventPanel(Color pressColor, Color hColor, Color relColor, Shape sh) {
+ pressedColor = pressColor;
+ heldColor = hColor;
+ releasedColor = relColor;
+ shape = sh;
+ Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
+ wiimoteImage = toolkit.createImage("img\\wiimote.png");
+ shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13);
+ initComponents();
+ }
+
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Dimension d = getSize();
+ checkOffScreenImage();
+ Graphics offG = mImage.getGraphics();
+ //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);
+
+ //draw buttons pushed
+ g2.drawImage(wiimoteImage, 0, 0, this);
+ g2.setTransform(new AffineTransform());
+
+ if (buttons != null) {
+ /* button ONE */
+ if (buttons.isButtonOneJustPressed()) {
+ drawFunction(g2,pressedColor,53,353);
+ }
+ if (buttons.isButtonOneHeld()) {
+ drawFunction(g2,heldColor,53,353);
+ }
+ if (buttons.isButtonOneJustReleased()) {
+ drawFunction(g2, releasedColor, 53, 353);
+ }
+
+ /* button TWO */
+ if (buttons.isButtonTwoJustPressed()) {
+ drawFunction(g2,pressedColor,53,395);
+ }
+ if (buttons.isButtonTwoHeld()) {
+ drawFunction(g2,heldColor,53,395);
+ }
+ if (buttons.isButtonTwoJustReleased()) {
+ drawFunction(g2,releasedColor,53,395);
+ }
+
+ /* button A */
+ if (buttons.isButtonAJustPressed()) {
+ drawFunction(g2,pressedColor,53,150);
+ }
+ if (buttons.isButtonAHeld()) {
+ drawFunction(g2,heldColor,53,150);
+ }
+ if (buttons.isButtonAJustReleased()) {
+ drawFunction(g2,releasedColor,53,150);
+ }
+
+ /* button B */
+ if (buttons.isButtonBJustPressed()) {
+ drawFunction(g2,pressedColor,16,149);
+ }
+ if (buttons.isButtonBHeld()) {
+ drawFunction(g2,heldColor,16,149);
+ }
+ if (buttons.isButtonBJustReleased()) {
+ drawFunction(g2,releasedColor,16,149);
+ }
+
+ /* button LEFT */
+ if (buttons.isButtonLeftJustPressed()) {
+ drawFunction(g2,pressedColor,33,77);
+ }
+ if (buttons.isButtonLeftHeld()) {
+ drawFunction(g2,heldColor,33,77);
+ }
+ if (buttons.isButtonLeftJustReleased()) {
+ drawFunction(g2,releasedColor,33,77);
+ }
+
+ /* button RIGHT */
+ if (buttons.isButtonRightJustPressed()) {
+ drawFunction(g2,pressedColor,73,77);
+ }
+ if (buttons.isButtonRightHeld()) {
+ drawFunction(g2,heldColor,73,77);
+ }
+ if (buttons.isButtonRightJustReleased()) {
+ drawFunction(g2,releasedColor,73,77);
+ }
+
+ /* button UP */
+ if (buttons.isButtonUpJustPressed()) {
+ drawFunction(g2,pressedColor,54,60);
+ }
+ if (buttons.isButtonUpHeld()) {
+ drawFunction(g2,heldColor,54,60);
+ }
+ if (buttons.isButtonUpJustReleased()) {
+ drawFunction(g2,releasedColor,54,60);
+ }
+
+ /* button DOWN */
+ if (buttons.isButtonDownJustPressed()) {
+ drawFunction(g2,pressedColor,54,97);
+ }
+ if (buttons.isButtonDownHeld()) {
+ drawFunction(g2,heldColor,54,97);
+ }
+ if (buttons.isButtonDownJustReleased()) {
+ drawFunction(g2,releasedColor,54,97);
+ }
+
+ /* button MINUS */
+ if (buttons.isButtonMinusJustPressed()) {
+ drawFunction(g2,pressedColor,20,230);
+ }
+ if (buttons.isButtonMinusHeld()) {
+ drawFunction(g2,heldColor,20,230);
+ }
+ if (buttons.isButtonMinusJustReleased()) {
+ drawFunction(g2,releasedColor,20,230);
+ }
+
+ /* button PLUS */
+ if (buttons.isButtonPlusJustPressed()) {
+ drawFunction(g2,pressedColor,86,230);
+ }
+ if (buttons.isButtonPlusHeld()) {
+ drawFunction(g2,heldColor,86,230);
+ }
+ if (buttons.isButtonPlusJustReleased()) {
+ drawFunction(g2,releasedColor,86,230);
+ }
+
+ /* button HOME */
+ if (buttons.isButtonHomeJustPressed()) {
+ drawFunction(g2,pressedColor,53,230);
+ }
+ if (buttons.isButtonHomeHeld()) {
+ drawFunction(g2,heldColor,53,230);
+ }
+ if (buttons.isButtonHomeJustReleased()) {
+ drawFunction(g2,releasedColor,53,230);
+ }
+
+ 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.
+ */
+ private void drawFunction(Graphics2D g2, Color col, int x, int y) {
+ g2.setPaint(col);
+ g2.translate(x, y);
+ g2.draw(shape);
+ g2.fill(shape);
+ g2.setTransform(new AffineTransform());
+ }
+
+ /**
+ * 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) {
+ mImage = createImage(d.width, d.height);
+ }
+ }
+
+ public void onButtonsEvent(ButtonsEvent arg0) {
+ setSize(wiimoteImage.getWidth(this), wiimoteImage.getHeight(this));
+ buttons = arg0;
+ repaint();
+ }
+
+ public void onIrEvent(IREvent arg0) {
+ //nothing
+ }
+
+ public void onMotionSensingEvent(MotionSensingEvent arg0) {
+ //nothing
+ }
+
+ public void onStatusEvent(StatusEvent arg0) {
+ //nothing
+ }
+
+ public void onDisconnectionEvent(DisconnectionEvent arg0) {
+ buttons = null;
+ repaint();
+ }
+
+ /** 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.
+ */
+ // //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)
+ );
+ }// //GEN-END:initComponents
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/utils/GForcePanel.java b/WiiUseJ_0.11/src/wiiusej/utils/GForcePanel.java
new file mode 100644
index 0000000..9802688
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/utils/GForcePanel.java
@@ -0,0 +1,201 @@
+/**
+ * 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.utils;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.util.ArrayList;
+import wiiusej.values.GForce;
+import wiiusej.wiiuseapievents.ButtonsEvent;
+import wiiusej.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiuseapievents.IREvent;
+import wiiusej.wiiuseapievents.MotionSensingEvent;
+import wiiusej.wiiuseapievents.StatusEvent;
+import wiiusej.wiiuseapievents.WiimoteListener;
+
+/**
+ * This panel is used to watch gravity force values from a MotionSensingEvent.
+ * @author guiguito
+ */
+public class GForcePanel extends javax.swing.JPanel implements WiimoteListener {
+
+ private Image mImage;//image for double buffering
+ private Color xColor = Color.RED;
+ private Color yColor = Color.GREEN;
+ private Color zColor = Color.BLUE;
+ private Color backgroundColor = Color.WHITE;
+ private Color lineColor = Color.BLACK;
+ private ArrayList values = new ArrayList();
+
+ /**
+ * Default constructor of the AccelerationPanel.
+ */
+ public GForcePanel() {
+ initComponents();
+ }
+
+ /**
+ * 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.
+ */
+ public GForcePanel(Color bgColor, Color xxColor, Color yyColor, Color zzColor, Color lColor) {
+ backgroundColor = bgColor;
+ xColor = xxColor;
+ yColor = yyColor;
+ zColor = zzColor;
+ lineColor = lColor;
+ initComponents();
+ }
+
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Dimension d = getSize();
+ checkOffScreenImage();
+ Graphics offG = mImage.getGraphics();
+ 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);
+
+ //draw medium line
+ double yMiddleFloat = getHeight() / 2.0;
+ int yMiddle = (int) Math.round(yMiddleFloat);
+
+ g2.setPaint(lineColor);
+ g2.drawLine(0, yMiddle, getWidth(), yMiddle);
+
+ GForce[] valuesArray = values.toArray(new GForce[0]);
+ double unit = yMiddleFloat / 5.0;
+ int previousX = 0;
+ int previousY = 0;
+ int previousZ = 0;
+ //draw curves
+ for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
+ GForce gforce = valuesArray[i];
+ //draw X
+ g2.setPaint(xColor);
+ int yDelta = (int) Math.round(unit * gforce.getX());
+ int y = -1 * yDelta + yMiddle;
+ g2.drawLine(i - 1, previousX, i, y);
+ g2.setTransform(new AffineTransform());
+ previousX = y;
+ //draw Y
+ g2.setPaint(yColor);
+ yDelta = (int) Math.round(unit * gforce.getY());
+ y = -1 * yDelta + yMiddle;
+ g2.drawLine(i - 1, previousY, i, y);
+ g2.setTransform(new AffineTransform());
+ previousY = y;
+ //draw Z
+ g2.setPaint(zColor);
+ yDelta = (int) Math.round(unit * gforce.getZ());
+ y = -1 * yDelta + yMiddle;
+ g2.drawLine(i - 1, previousZ, i, y);
+ g2.setTransform(new AffineTransform());
+ previousZ = y;
+ }
+
+ //draw legend
+ g2.setPaint(xColor);
+ g2.drawLine(5, getHeight() - 10, 25, getHeight() - 10);
+ g2.setPaint(yColor);
+ g2.drawLine(60, getHeight() - 10, 80, getHeight() - 10);
+ g2.setPaint(zColor);
+ g2.drawLine(120, getHeight() - 10, 140, getHeight() - 10);
+
+ g2.setPaint(lineColor);
+ g2.drawString("X", 30, getHeight() - 5);
+ g2.drawString("Y", 85, getHeight() - 5);
+ g2.drawString("Z", 145, getHeight() - 5);
+ g2.drawString("0", 2, yMiddle-5);
+ g2.drawString("5", 2, 10);
+ g2.drawString("-5", 2, getHeight()-15);
+ //put offscreen image on the screen
+ g.drawImage(mImage, 0, 0, null);
+ }
+
+ /**
+ * 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) {
+ mImage = createImage(d.width, d.height);
+ }
+ }
+
+ public void onButtonsEvent(ButtonsEvent arg0) {
+ //nothing
+ }
+
+ public void onIrEvent(IREvent arg0) {
+ //nothing
+ }
+
+ public void onMotionSensingEvent(MotionSensingEvent arg0) {
+ if (values.size() >= getWidth()) {
+ //if there are as many values as pixels in the width
+ //clear points
+ values.clear();
+ }
+ values.add(arg0.getGforce());
+ repaint();
+ }
+
+ public void onStatusEvent(StatusEvent arg0) {
+ //nothing
+ }
+
+ public void onDisconnectionEvent(DisconnectionEvent arg0) {
+ //Clear points.
+ values.clear();
+ repaint();
+ }
+
+ /** 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.
+ */
+ // //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)
+ );
+ }// //GEN-END:initComponents
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/utils/IRPanel.java b/WiiUseJ_0.11/src/wiiusej/utils/IRPanel.java
new file mode 100644
index 0000000..3352e66
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/utils/IRPanel.java
@@ -0,0 +1,193 @@
+/**
+ * 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.utils;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import wiiusej.wiiuseapievents.ButtonsEvent;
+import wiiusej.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiuseapievents.IREvent;
+import wiiusej.wiiuseapievents.MotionSensingEvent;
+import wiiusej.wiiuseapievents.StatusEvent;
+import wiiusej.wiiuseapievents.WiimoteListener;
+
+/**
+ * This panel is used to see what the IR camera of the wiimote sees.
+ * @author guiguito
+ */
+public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
+
+ private static int MAX_NB_POINTS = 4;
+ private Color color = Color.YELLOW;
+ private Color backgroundColor = Color.BLACK;
+ private Color borderColor = Color.BLUE;
+ private Shape shape;
+ private Image mImage;//image for double buffering
+ private int[] xCoordinates;
+ private int[] yCoordinates;
+ private int nbPoints=-1;
+
+ /**
+ * Default constructor for IR Panel.
+ * Background color : black.
+ * IR sources color : yellow.
+ * Border color of IR sources : blue.
+ * Shape of the IR sources : circle with a diameter of 10.
+ */
+ public IRPanel() {
+ shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10);
+ initArrays();
+ initComponents();
+ }
+
+ /**
+ * Constructor used to parameterize the IR panel.
+ * @param bgColor color.
+ * @param ptColor IR sources color.
+ * @param bdColor border color of IR sources.
+ * @param sh Shape of the IR sources.
+ */
+ public IRPanel(Color bgColor, Color ptColor, Color bdColor, Shape sh) {
+ backgroundColor = bgColor;
+ color = ptColor;
+ borderColor = bdColor;
+ shape = sh;
+ initArrays();
+ initComponents();
+ }
+
+ private void initArrays(){
+ xCoordinates = new int[MAX_NB_POINTS];
+ yCoordinates = new int[MAX_NB_POINTS];
+ for (int i = 0; i < MAX_NB_POINTS; i++) {
+ xCoordinates[i] = -1;
+ yCoordinates[i] = -1;
+ }
+ }
+
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Dimension d = getSize();
+ checkOffScreenImage();
+ Graphics offG = mImage.getGraphics();
+ 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);
+
+ //draw points
+ int i = 0;
+ while (xCoordinates[i] != -1 && yCoordinates[i] != -1 && i < nbPoints) {
+ double x = xCoordinates[i];
+ double y = yCoordinates[i];
+
+ long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0);
+ long yy = getHeight() - Math.round((double) getHeight() * y / 768.0);
+ g2.translate(xx, yy);
+
+ g2.setPaint(borderColor);
+ g2.draw(shape);
+ g2.setPaint(color);
+ g2.fill(shape);
+
+ g2.setTransform(new AffineTransform());
+ i++;
+ }
+ //put offscreen image on the screen
+ g.drawImage(mImage, 0, 0, null);
+ }
+
+ /**
+ * 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) {
+ mImage = createImage(d.width, d.height);
+ }
+ }
+
+ public void onButtonsEvent(ButtonsEvent arg0) {
+ //nothing
+ repaint();
+ }
+
+ public void onIrEvent(IREvent arg0) {
+ //transfer points
+ wiiusej.values.IRSource[] points = arg0.getIRPoints();
+ nbPoints = points.length;
+ for (int i = 0; i < points.length; i++) {
+ xCoordinates[i] = (int) points[i].getRx();
+ yCoordinates[i] = (int) points[i].getRy();
+ }
+ for (int i = points.length; i < MAX_NB_POINTS; i++) {
+ xCoordinates[i] = -1;
+ yCoordinates[i] = -1;
+ }
+
+ //redraw panel
+ repaint();
+ }
+
+ public void onMotionSensingEvent(MotionSensingEvent arg0) {
+ //nothing
+ }
+
+ public void onStatusEvent(StatusEvent arg0) {
+ //nothing
+ }
+
+ public void onDisconnectionEvent(DisconnectionEvent arg0) {
+ //clear previous points
+ for (int i = 0; i < MAX_NB_POINTS; i++) {
+ xCoordinates[i] = -1;
+ yCoordinates[i] = -1;
+ }
+ //redraw panel
+ repaint();
+ }
+
+ /** 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.
+ */
+ // //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)
+ );
+ }// //GEN-END:initComponents
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/utils/OrientationPanel.java b/WiiUseJ_0.11/src/wiiusej/utils/OrientationPanel.java
new file mode 100644
index 0000000..b50a2ce
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/utils/OrientationPanel.java
@@ -0,0 +1,205 @@
+/**
+ * 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.utils;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.RenderingHints;
+import java.awt.geom.AffineTransform;
+import java.util.ArrayList;
+import wiiusej.values.Orientation;
+import wiiusej.wiiuseapievents.ButtonsEvent;
+import wiiusej.wiiuseapievents.DisconnectionEvent;
+import wiiusej.wiiuseapievents.IREvent;
+import wiiusej.wiiuseapievents.MotionSensingEvent;
+import wiiusej.wiiuseapievents.StatusEvent;
+import wiiusej.wiiuseapievents.WiimoteListener;
+
+/**
+ * This panel is used to watch orientation values from a MotionSensingEvent.
+ * @author guiguito
+ */
+public class OrientationPanel extends javax.swing.JPanel implements WiimoteListener {
+
+ private Image mImage;//image for double buffering
+ private Color rollColor = Color.RED;
+ private Color pitchColor = Color.GREEN;
+ private Color yawColor = Color.BLUE;
+ private Color backgroundColor = Color.WHITE;
+ private Color lineColor = Color.BLACK;
+ private ArrayList values = new ArrayList();
+
+ /**
+ * Default constructor.
+ * Background color : White.
+ * Roll color : Red.
+ * Pitch color : Green.
+ * Yaw color : Blue.
+ */
+ public OrientationPanel() {
+ initComponents();
+ }
+
+ /**
+ * 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.
+ */
+ public OrientationPanel(Color bgColor, Color rColor, Color pColor, Color yColor, Color lColor) {
+ backgroundColor = bgColor;
+ rollColor = rColor;
+ pitchColor = pColor;
+ yawColor = yColor;
+ lineColor = lColor;
+ initComponents();
+ }
+
+ @Override
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ Dimension d = getSize();
+ checkOffScreenImage();
+ Graphics offG = mImage.getGraphics();
+ 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);
+
+ //draw medium line
+ double yMiddleFloat = getHeight() / 2.0;
+ int yMiddle = (int) Math.round(yMiddleFloat);
+
+ g2.setPaint(lineColor);
+ g2.drawLine(0, yMiddle, getWidth(), yMiddle);
+
+ Orientation[] valuesArray = values.toArray(new Orientation[0]);
+ double unit = yMiddleFloat / 180.0;
+ int previousRoll = 0;
+ int previousPitch = 0;
+ int previousYaw = 0;
+ //draw curves
+ for (int i = 0; i < valuesArray.length && i < getWidth(); i++) {
+ Orientation orientation = valuesArray[i];
+ //draw roll
+ g2.setPaint(rollColor);
+ int yDelta = (int) Math.round(unit * orientation.getRoll());
+ int y = -1 * yDelta + yMiddle;
+ g2.drawLine(i-1, previousRoll, i, y);
+ g2.setTransform(new AffineTransform());
+ previousRoll = y;
+ //draw pitch
+ g2.setPaint(pitchColor);
+ yDelta = (int) Math.round(unit * orientation.getPitch());
+ y = -1 * yDelta + yMiddle;
+ g2.drawLine(i-1, previousPitch, i, y);
+ g2.setTransform(new AffineTransform());
+ previousPitch = y;
+ //draw yaw
+ g2.setPaint(yawColor);
+ yDelta = (int) Math.round(unit * orientation.getYaw());
+ y = -1 * yDelta + yMiddle;
+ g2.drawLine(i-1, previousYaw, i, y);
+ g2.setTransform(new AffineTransform());
+ previousYaw = y;
+ }
+
+ //draw legend
+ g2.setPaint(rollColor);
+ g2.drawLine(5, getHeight()-10, 25, getHeight()-10);
+ g2.setPaint(pitchColor);
+ g2.drawLine(60, getHeight()-10, 80, getHeight()-10);
+ g2.setPaint(yawColor);
+ g2.drawLine(120, getHeight()-10, 140, getHeight()-10);
+
+ g2.setPaint(lineColor);
+ g2.drawString("Roll", 30, getHeight()-5);
+ g2.drawString("Pitch", 85, getHeight()-5);
+ g2.drawString("Yaw", 145, getHeight()-5);
+ g2.drawString("0", 2, yMiddle-5);
+ g2.drawString("180", 2, 10);
+ g2.drawString("-180", 2, getHeight()-15);
+ //put offscreen image on the screen
+ g.drawImage(mImage, 0, 0, null);
+ }
+
+ /**
+ * 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) {
+ mImage = createImage(d.width, d.height);
+ }
+ }
+
+ public void onButtonsEvent(ButtonsEvent arg0) {
+ //nothing
+ }
+
+ public void onIrEvent(IREvent arg0) {
+ //nothing
+ }
+
+ public void onMotionSensingEvent(MotionSensingEvent arg0) {
+ if (values.size() >= getWidth()) {
+ //if there are as many values as pixels in the width
+ //clear points
+ values.clear();
+ }
+ values.add(arg0.getOrientation());
+ repaint();
+ }
+
+ public void onStatusEvent(StatusEvent arg0) {
+ //nothing
+ }
+
+ public void onDisconnectionEvent(DisconnectionEvent arg0) {
+ //Clear points.
+ values.clear();
+ repaint();
+ }
+
+ /** 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.
+ */
+ // //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)
+ );
+ }// //GEN-END:initComponents
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/values/GForce.java b/WiiUseJ_0.11/src/wiiusej/values/GForce.java
new file mode 100644
index 0000000..9732121
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/values/GForce.java
@@ -0,0 +1,75 @@
+/**
+ * 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.values;
+
+/**
+ * Represents gravity force on each axis.
+ * @author guiguito
+ */
+public class GForce {
+
+ private float x;
+ private float y;
+ private float z;
+
+ /**
+ * Default constructor;
+ */
+ public GForce(){
+ x = 0;
+ y = 0;
+ z = 0;
+ }
+
+ /**
+ * Constructor with gravity force on each axis.
+ * @param xx x value
+ * @param yy x value
+ * @param zz x value
+ */
+ public GForce(float xx, float yy, float zz){
+ x = xx;
+ y = yy;
+ z = zz;
+ }
+
+ /**
+ * @return the x
+ */
+ public float getX() {
+ return x;
+ }
+
+ /**
+ * @return the y
+ */
+ public float getY() {
+ return y;
+ }
+
+ /**
+ * @return the z
+ */
+ public float getZ() {
+ return z;
+ }
+
+ @Override
+ public String toString() {
+ return "Gravity force : ("+x+", "+y+","+z+")";
+ }
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/values/IRSource.java b/WiiUseJ_0.11/src/wiiusej/values/IRSource.java
new file mode 100644
index 0000000..7caef55
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/values/IRSource.java
@@ -0,0 +1,109 @@
+/**
+ * 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.values;
+
+/**
+ * Class used for IR sources.
+ * @author guiguito
+ */
+public class IRSource{
+
+ private int x;
+ private int y;
+ private short rx;
+ private short ry;
+ private short size;
+
+ /**
+ * Build an IR source with all details.
+ *
+ * @param xx
+ * xx interpolated coordinates.
+ * @param yy
+ * yy interpolated coordinates.
+ * @param rxx
+ * raw X coordinate (0-1023).
+ * @param ryy
+ * raw Y coordinate (0-1023).
+ * @param si
+ * size of the IR dot (0-15).
+ */
+ public IRSource(int xx, int yy, short rxx, short ryy, short si) {
+ x = xx;
+ y = yy;
+ rx = rxx;
+ ry = ryy;
+ size = si;
+ }
+
+
+ /**
+ * Return x interpolated coordinates.
+ * @return the x
+ */
+ public int getX() {
+ return x;
+ }
+
+
+
+ /**
+ * Return y interpolated coordinates.
+ * @return the y
+ */
+ public int getY() {
+ return y;
+ }
+
+
+
+ /**
+ * Return raw X coordinate (0-1023).
+ * @return the rx
+ */
+ public short getRx() {
+ return rx;
+ }
+
+
+
+ /**
+ * Return raw Y coordinate (0-1023).
+ * @return the ry
+ */
+ public short getRy() {
+ return ry;
+ }
+
+
+
+ /**
+ * Return size of the IR dot (0-15).
+ * @return the size
+ */
+ public short getSize() {
+ return size;
+ }
+
+
+
+ @Override
+ public String toString() {
+ return "Interpolated coordinates ("+x+","+y+"), Raw coordinates("+rx+","+ry+"), source size : "+size+")";
+ }
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/values/Orientation.java b/WiiUseJ_0.11/src/wiiusej/values/Orientation.java
new file mode 100644
index 0000000..4c4f741
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/values/Orientation.java
@@ -0,0 +1,76 @@
+/**
+ * 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.values;
+
+/**
+ * Class that represents the orientation of the wiimote.
+ * @author guiguito
+ */
+public class Orientation {
+
+ private float roll;
+ private float pitch;
+ private float yaw;
+
+ /**
+ * Default constructor.
+ */
+ public Orientation(){
+ roll = 0;
+ pitch = 0;
+ yaw = 0;
+ }
+
+ /**
+ * Contructor with raw, pitch , yaw.
+ * @param r raw
+ * @param p pitch
+ * @param y yaw
+ */
+ public Orientation(float r, float p, float y){
+ roll = r;
+ pitch = p;
+ yaw = y;
+ }
+
+ /**
+ * @return the roll
+ */
+ public float getRoll() {
+ return roll;
+ }
+
+ /**
+ * @return the pitch
+ */
+ public float getPitch() {
+ return pitch;
+ }
+
+ /**
+ * @return the yaw
+ */
+ public float getYaw() {
+ return yaw;
+ }
+
+ @Override
+ public String toString() {
+ return "Orientation : (roll: "+roll+", pitch: "+pitch+", yaw: "+yaw+")";
+ }
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/values/RawAcceleration.java b/WiiUseJ_0.11/src/wiiusej/values/RawAcceleration.java
new file mode 100644
index 0000000..903a51c
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/values/RawAcceleration.java
@@ -0,0 +1,75 @@
+/**
+ * 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.values;
+
+/**
+ * Represents raw acceleration on each axis.
+ * @author guiguito
+ */
+public class RawAcceleration {
+
+ private short x;
+ private short y;
+ private short z;
+
+ /**
+ * Default constructor;
+ */
+ public RawAcceleration() {
+ x = 0;
+ y = 0;
+ z = 0;
+ }
+
+ /**
+ * Constructor with raw acceleration on each axis.
+ * @param xx x value
+ * @param yy x value
+ * @param zz x value
+ */
+ public RawAcceleration(short xx, short yy, short zz) {
+ x = xx;
+ y = yy;
+ z = zz;
+ }
+
+ /**
+ * @return the x
+ */
+ public short getX() {
+ return x;
+ }
+ /**
+ * @return the y
+ */
+ public short getY() {
+ return y;
+ }
+
+ /**
+ * @return the z
+ */
+ public short getZ() {
+ return z;
+ }
+
+ @Override
+ public String toString() {
+ return "Raw acceleration : ("+x+", "+y+","+z+")";
+ }
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/ButtonsEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/ButtonsEvent.java
new file mode 100644
index 0000000..ce78551
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/ButtonsEvent.java
@@ -0,0 +1,335 @@
+/**
+ * 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.wiiuseapievents;
+
+/**
+ * Class which represents a buttons event.
+ * @author guiguito
+ */
+public class ButtonsEvent extends WiimoteEvent{
+
+ /* Buttons MACRO */
+ private static short WIIMOTE_BUTTON_TWO = 0x0001;
+ private static short WIIMOTE_BUTTON_ONE = 0x0002;
+ private static short WIIMOTE_BUTTON_B = 0x0004;
+ private static short WIIMOTE_BUTTON_A = 0x0008;
+ private static short WIIMOTE_BUTTON_MINUS = 0x0010;
+ private static short WIIMOTE_BUTTON_ZACCEL_BIT6 = 0x0020;
+ private static short WIIMOTE_BUTTON_ZACCEL_BIT7 = 0x0040;
+ private static short WIIMOTE_BUTTON_HOME = 0x0080;
+ private static short WIIMOTE_BUTTON_LEFT = 0x0100;
+ private static short WIIMOTE_BUTTON_RIGHT = 0x0200;
+ private static short WIIMOTE_BUTTON_DOWN = 0x0400;
+ private static short WIIMOTE_BUTTON_UP = 0x0800;
+ private static short WIIMOTE_BUTTON_PLUS = 0x1000;
+ private static short WIIMOTE_BUTTON_ZACCEL_BIT4 = 0x2000;
+ private static short WIIMOTE_BUTTON_ZACCEL_BIT5 = 0x4000;
+ private static int WIIMOTE_BUTTON_UNKNOWN = 0x8000;
+ private static short WIIMOTE_BUTTON_ALL = 0x1F9F;
+
+ /* Buttons */
+ private short buttonsJustPressed = 0;
+ private short buttonsJustReleased = 0;
+ private short buttonsHeld = 0;
+
+ /**
+ * Constructor of the button Event.
+ * @param id id of the wiimote concerned.
+ * @param buttonsJustPressed buttons just pressed.
+ * @param buttonsJustReleased buttons just released.
+ * @param buttonsHeld buttons just held.
+ */
+ public ButtonsEvent(int id, short buttonsJustPressed,
+ short buttonsJustReleased, short buttonsHeld){
+ super(id);
+ setAllButtons(buttonsJustPressed, buttonsJustReleased, buttonsHeld);
+ }
+
+ /**
+ * Set all buttons in one method.
+ *
+ * @param buttonsJustPressed
+ * @param buttonsJustReleased
+ * @param buttonsHeld
+ */
+ private void setAllButtons(short buttonsJustPressed,
+ short buttonsJustReleased, short buttonsHeld) {
+ this.buttonsJustPressed = buttonsJustPressed;
+ this.buttonsJustReleased = buttonsJustReleased;
+ this.buttonsHeld = buttonsHeld;
+ }
+
+ /**
+ * Get the short storing the buttons just pressed
+ *
+ * @return the short storing the buttons just pressed
+ */
+ public short getButtonsJustPressed() {
+ return buttonsJustPressed;
+ }
+
+ /**
+ * Get the short storing the buttons just released
+ *
+ * @return the short storing the buttons just released
+ */
+ public short getButtonsJustReleased() {
+ return buttonsJustReleased;
+ }
+
+ /**
+ * get the short storing the buttons held
+ *
+ * @return the short storing the buttons held
+ */
+ public short getButtonsHeld() {
+ return buttonsHeld;
+ }
+
+ /** **************** BUTTONS Methods ***************** */
+ /* generic button functions */
+
+ private boolean buttonTest(short buttonBitsDefinition, short buttons) {
+ return (buttons & buttonBitsDefinition) == buttonBitsDefinition;
+ }
+
+ private boolean isButtonJustPressed(short buttonBitsDefinition) {
+ return buttonTest(buttonBitsDefinition, buttonsJustPressed)
+ && !isButtonHeld(buttonBitsDefinition);
+ }
+
+ private boolean isButtonJustReleased(short buttonBitsDefinition) {
+ return buttonTest(buttonBitsDefinition, buttonsJustReleased);
+ }
+
+ private boolean isButtonHeld(short buttonBitsDefinition) {
+ return buttonTest(buttonBitsDefinition, buttonsHeld);
+ }
+
+ private boolean isButtonPressed(short buttonBitsDefinition) {
+ return isButtonHeld(buttonBitsDefinition)||isButtonJustPressed(buttonBitsDefinition);
+ }
+ /* Button ONE */
+
+ public boolean isButtonOneJustPressed() {
+ return isButtonJustPressed(WIIMOTE_BUTTON_ONE);
+ }
+
+ public boolean isButtonOneJustReleased() {
+ return isButtonJustReleased(WIIMOTE_BUTTON_ONE);
+ }
+
+ public boolean isButtonOneHeld() {
+ return isButtonHeld(WIIMOTE_BUTTON_ONE);
+ }
+
+ public boolean isButtonOnePressed() {
+ return isButtonPressed(WIIMOTE_BUTTON_ONE);
+ }
+
+ /* Button TWO */
+
+ public boolean isButtonTwoJustPressed() {
+ return isButtonJustPressed(WIIMOTE_BUTTON_TWO);
+ }
+
+ public boolean isButtonTwoJustReleased() {
+ return isButtonJustReleased(WIIMOTE_BUTTON_TWO);
+ }
+
+ public boolean isButtonTwoHeld() {
+ return isButtonHeld(WIIMOTE_BUTTON_TWO);
+ }
+
+ public boolean isButtonTwoPressed() {
+ return isButtonPressed(WIIMOTE_BUTTON_TWO);
+ }
+
+ /* Button A */
+
+ public boolean isButtonAJustPressed() {
+ return isButtonJustPressed(WIIMOTE_BUTTON_A);
+ }
+
+ public boolean isButtonAJustReleased() {
+ return isButtonJustReleased(WIIMOTE_BUTTON_A);
+ }
+
+ public boolean isButtonAHeld() {
+ return isButtonHeld(WIIMOTE_BUTTON_A);
+ }
+
+ public boolean isButtonAPressed() {
+ return isButtonPressed(WIIMOTE_BUTTON_A);
+ }
+
+ /* Button B */
+
+ public boolean isButtonBJustPressed() {
+ return isButtonJustPressed(WIIMOTE_BUTTON_B);
+ }
+
+ public boolean isButtonBJustReleased() {
+ return isButtonJustReleased(WIIMOTE_BUTTON_B);
+ }
+
+ public boolean isButtonBHeld() {
+ return isButtonHeld(WIIMOTE_BUTTON_B);
+ }
+
+ public boolean isButtonBPressed() {
+ return isButtonPressed(WIIMOTE_BUTTON_B);
+ }
+
+ /* Button LEFT */
+
+ public boolean isButtonLeftJustPressed() {
+ return isButtonJustPressed(WIIMOTE_BUTTON_LEFT);
+ }
+
+ public boolean isButtonLeftJustReleased() {
+ return isButtonJustReleased(WIIMOTE_BUTTON_LEFT);
+ }
+
+ public boolean isButtonLeftHeld() {
+ return isButtonHeld(WIIMOTE_BUTTON_LEFT);
+ }
+
+ public boolean isButtonLeftPressed() {
+ return isButtonPressed(WIIMOTE_BUTTON_LEFT);
+ }
+
+ /* Button RIGHT */
+
+ public boolean isButtonRightJustPressed() {
+ return isButtonJustPressed(WIIMOTE_BUTTON_RIGHT);
+ }
+
+ public boolean isButtonRightJustReleased() {
+ return isButtonJustReleased(WIIMOTE_BUTTON_RIGHT);
+ }
+
+ public boolean isButtonRightHeld() {
+ return isButtonHeld(WIIMOTE_BUTTON_RIGHT);
+ }
+
+ public boolean isButtonRightPressed() {
+ return isButtonPressed(WIIMOTE_BUTTON_RIGHT);
+ }
+
+ /* Button UP */
+
+ public boolean isButtonUpJustPressed() {
+ return isButtonJustPressed(WIIMOTE_BUTTON_UP);
+ }
+
+ public boolean isButtonUpJustReleased() {
+ return isButtonJustReleased(WIIMOTE_BUTTON_UP);
+ }
+
+ public boolean isButtonUpHeld() {
+ return isButtonHeld(WIIMOTE_BUTTON_UP);
+ }
+
+ public boolean isButtonUpPressed() {
+ return isButtonPressed(WIIMOTE_BUTTON_UP);
+ }
+
+ /* Button DOWN */
+
+ public boolean isButtonDownJustPressed() {
+ return isButtonJustPressed(WIIMOTE_BUTTON_DOWN);
+ }
+
+ public boolean isButtonDownJustReleased() {
+ return isButtonJustReleased(WIIMOTE_BUTTON_DOWN);
+ }
+
+ public boolean isButtonDownHeld() {
+ return isButtonHeld(WIIMOTE_BUTTON_DOWN);
+ }
+
+ public boolean isButtonDownPressed() {
+ return isButtonPressed(WIIMOTE_BUTTON_DOWN);
+ }
+
+ /* Button - */
+
+ public boolean isButtonMinusJustPressed() {
+ return isButtonJustPressed(WIIMOTE_BUTTON_MINUS);
+ }
+
+ public boolean isButtonMinusJustReleased() {
+ return isButtonJustReleased(WIIMOTE_BUTTON_MINUS);
+ }
+
+ public boolean isButtonMinusHeld() {
+ return isButtonHeld(WIIMOTE_BUTTON_MINUS);
+ }
+
+ public boolean isButtonMinusPressed() {
+ return isButtonPressed(WIIMOTE_BUTTON_MINUS);
+ }
+
+ /* Button + */
+
+ public boolean isButtonPlusJustPressed() {
+ return isButtonJustPressed(WIIMOTE_BUTTON_PLUS);
+ }
+
+ public boolean isButtonPlusJustReleased() {
+ return isButtonJustReleased(WIIMOTE_BUTTON_PLUS);
+ }
+
+ public boolean isButtonPlusHeld() {
+ return isButtonHeld(WIIMOTE_BUTTON_PLUS);
+ }
+
+ public boolean isButtonPlusPressed() {
+ return isButtonPressed(WIIMOTE_BUTTON_PLUS);
+ }
+
+ /* Button HOME */
+
+ public boolean isButtonHomeJustPressed() {
+ return isButtonJustPressed(WIIMOTE_BUTTON_HOME);
+ }
+
+ public boolean isButtonHomeJustReleased() {
+ return isButtonJustReleased(WIIMOTE_BUTTON_HOME);
+ }
+
+ public boolean isButtonHomeHeld() {
+ return isButtonHeld(WIIMOTE_BUTTON_HOME);
+ }
+
+ public boolean isButtonHomePressed() {
+ return isButtonPressed(WIIMOTE_BUTTON_HOME);
+ }
+
+ @Override
+ public String toString() {
+ String out = "";
+ /* Display buttons */
+ out += "/******** Buttons ********/\n";
+ out += "--- Buttons just pressed : " + buttonsJustPressed + "\n";
+ out += "--- Buttons just released : " + buttonsJustReleased + "\n";
+ out += "--- Buttons held : " + buttonsHeld + "\n";
+ return out;
+ }
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/DisconnectionEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/DisconnectionEvent.java
new file mode 100644
index 0000000..341b626
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/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.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_0.11/src/wiiusej/wiiuseapievents/EventsGatherer.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/EventsGatherer.java
new file mode 100644
index 0000000..5c83d78
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/EventsGatherer.java
@@ -0,0 +1,241 @@
+/**
+ * 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.wiiuseapievents;
+
+/**
+ * This class is used to gather events during a call to the Wiiuse API.
+ *
+ * @author guiguito
+ */
+public class EventsGatherer {
+
+ private WiiUseApiEvent[] events;
+ private int index = 0;
+ private GenericEvent genericEvent = null;
+
+ /**
+ * Create EventsGatherer.
+ *
+ * @param nbWiimotes
+ * nb wiimotes (nb a of events possible in a call to Wiiuse API)
+ */
+ public EventsGatherer(int nbWiimotes) {
+ events = new WiiUseApiEvent[nbWiimotes];
+ }
+
+ /**
+ * Add an event to the array.
+ *
+ * @param e
+ * the event to add.
+ */
+ private void addEvent(WiiUseApiEvent e) {
+ events[index] = e;
+ index++;
+ }
+
+ /**
+ * Prepare a wiimote event to add.
+ *
+ * @param id
+ * id of the wiimote.
+ * @param buttonsJustPressed
+ * buttons just pressed
+ * @param buttonsJustReleased
+ * buttons just released
+ * @param buttonsHeld
+ * buttons held
+ */
+ public void prepareWiiMoteEvent(int id, short buttonsJustPressed,
+ short buttonsJustReleased, short buttonsHeld) {
+ genericEvent = new GenericEvent(id, buttonsJustPressed,
+ buttonsJustReleased, buttonsHeld);
+ }
+
+ /**
+ * Prepare an IR event to populate.
+ *
+ * @param x
+ * calculated X coordinate.
+ * @param y
+ * calculated Y coordinate.
+ * @param z
+ * calculated distance.
+ * @param ax
+ * absolute X coordinate.
+ * @param ay
+ * absolute Y coordinate
+ * @param xVRes
+ * IR virtual screen x resolution.
+ * @param yVRes
+ * IR virtual screen y resolution.
+ * @param xOffset
+ * IR X correction offset.
+ * @param yOffset
+ * IR Y correction offset.
+ * @param sensorBarPostion
+ * aspect ratio of the screen.
+ * @param screenAsPectRatio
+ * IR sensor bar position.
+ */
+ public void prepareIRevent(int x, int y, int z, int ax, int ay, int xVRes,
+ int yVRes, int xOffset, int yOffset, short sensorBarPostion,
+ short screenAsPectRatio) {
+ genericEvent.prepareIRevent(x, y, z, ax, ay, xVRes, yVRes, xOffset,
+ yOffset, sensorBarPostion, screenAsPectRatio);
+
+ }
+
+ /**
+ * Add an IR point to the WiiMoteEvent prepared
+ *
+ * @param x
+ * x coordinates
+ * @param y
+ * y coordinates
+ * @param rx
+ * raw X coordinate (0-1023).
+ * @param ry
+ * raw Y coordinate (0-1023).
+ * @param size
+ * size of the IR dot (0-15).
+ */
+ public void addIRPointToPreparedWiiMoteEvent(int x, int y, short rx,
+ short ry, short size) {
+ if (genericEvent != null) {
+ genericEvent.addIRpoint(x, y, rx, ry, size);
+ }
+ }
+
+ /**
+ * Set orientation and gravity force of the prepared event.
+ *
+ * @param orientationThreshold
+ * value of the minimum angle between two events with the
+ * accelerometer
+ * @param accelerationThreshold
+ * value of the value variation between two events with the
+ * accelerometer
+ * @param smoothingState
+ * true if smoothing flag is activated
+ * @param alphaSmooth
+ * value of the alpha smoothing parameter
+ * @param r
+ * roll
+ * @param p
+ * pitch
+ * @param ya
+ * yaw
+ * @param x
+ * gravity force on x axis
+ * @param y
+ * gravity force on y axis
+ * @param z
+ * gravity force on z axis
+ * @param xx
+ * raw acceleration on x axis
+ * @param yy
+ * raw acceleration on y axis
+ * @param zz
+ * raw acceleration on z axis
+ */
+ public void addMotionSensingValues(float orientationThreshold,
+ int accelerationThreshold, boolean smoothingState,
+ float alphaSmooth, float r, float p, float ya, float x, float y,
+ float z, short xx, short yy, short zz) {
+ if (genericEvent != null) {
+ genericEvent.setMotionSensingEvent(orientationThreshold,
+ accelerationThreshold, smoothingState, alphaSmooth, r, p,
+ ya, x, y, z, xx, yy, zz);
+ }
+ }
+
+ /**
+ * Add the prepared WiimoteEvent to the gatherer.
+ */
+ public void addWiimoteEvent() {
+ if (genericEvent != null) {
+ addEvent(genericEvent);
+ genericEvent = null;
+ }
+ }
+
+ /**
+ * Add a StatusEvent to the gatherer.
+ *
+ * @param id
+ * id of the wiimote
+ * @param connect
+ * true if the wiimote is connected
+ * @param batt
+ * battery level
+ * @param led
+ * status of leds
+ * @param speak
+ * speakers status
+ * @param attach
+ * attachment status
+ * @param rumbleState
+ * true if rumble is active
+ * @param continuousState
+ * true if continuous flag is activated
+ * @param irState
+ * true if ir is active
+ * @param motionSensingState
+ * true if accelerometer is active
+ */
+ public void addStatusEvent(int id, boolean connect, float batt, short led,
+ boolean speak, int attach, boolean rumbleState,
+ boolean continuousState, boolean irState, boolean motionSensingState) {
+ StatusEvent evt = new StatusEvent(id, connect, batt, led, speak,
+ attach, rumbleState, continuousState, irState,
+ motionSensingState);
+ addEvent(evt);
+ }
+
+ /**
+ * Add a DisconnectionEvent to the gatherer.
+ *
+ * @param id
+ * id of the wiimote
+ */
+ public void addDisconnectionEvent(int id) {
+ DisconnectionEvent evt = new DisconnectionEvent(id);
+ addEvent(evt);
+ }
+
+ /**
+ * Return an array containing the events.
+ *
+ * @return events received
+ */
+ public WiiUseApiEvent[] getEvents() {
+ return java.util.Arrays.copyOfRange(events, 0, index);
+ }
+
+ /**
+ * Clear the gatherer and remove objects.
+ */
+ public void clearEvents() {
+ for (int i = 0; i < events.length; i++) {
+ events[i] = null;
+ }
+ genericEvent = null;
+ index = 0;
+ }
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/GenericEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/GenericEvent.java
new file mode 100644
index 0000000..e8ea39b
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/GenericEvent.java
@@ -0,0 +1,227 @@
+/**
+ * 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.wiiuseapievents;
+
+/**
+ * Class that is a bean to be filled by the wiiuse API.
+ *
+ * @author guiguito
+ */
+public class GenericEvent extends WiiUseApiEvent {
+
+ ButtonsEvent buttonsEvent = null;
+ IREvent infraredEvent = null;
+ MotionSensingEvent motionSensingEvent = null;
+
+ /**
+ * Construct the Wiimote setting up the id.
+ *
+ * @param id
+ * the Wiimote id
+ */
+ public GenericEvent(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 GenericEvent(int id, short buttonsJustPressed,
+ short buttonsJustReleased, short buttonsHeld) {
+ super(id, WiiUseApiEvent.GENERIC_EVENT);
+ buttonsEvent = new ButtonsEvent(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;
+ }
+
+ /**
+ * Get buttons event.
+ *
+ * @return the buttons event.
+ */
+ public ButtonsEvent getButtonsEvent() {
+ return buttonsEvent;
+ }
+
+ /**
+ * Get IR event.
+ *
+ * @return the IR event if there is one or null.
+ */
+ public IREvent getIREvent() {
+ return infraredEvent;
+ }
+
+ /**
+ * Get motion sensing event.
+ *
+ * @return the motion sensing event if there is one or null.
+ */
+ public MotionSensingEvent getMotionSensingEvent() {
+ return motionSensingEvent;
+ }
+
+ /**
+ * Prepare an IR event to populate.
+ *
+ * @param x
+ * calculated X coordinate.
+ * @param y
+ * calculated Y coordinate.
+ * @param z
+ * calculated distance.
+ * @param ax
+ * absolute X coordinate.
+ * @param ay
+ * absolute Y coordinate
+ * @param xVRes
+ * IR virtual screen x resolution.
+ * @param yVRes
+ * IR virtual screen y resolution.
+ * @param xOffset
+ * IR X correction offset.
+ * @param yOffset
+ * IR Y correction offset.
+ * @param sensorBarPostion
+ * aspect ratio of the screen.
+ * @param screenAsPectRatio
+ * IR sensor bar position.
+ */
+ public void prepareIRevent(int x, int y, int z, int ax, int ay, int xVRes,
+ int yVRes, int xOffset, int yOffset, short sensorBarPostion,
+ short screenAsPectRatio) {
+ if (infraredEvent == null) {
+ infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes,
+ yVRes, xOffset, yOffset, sensorBarPostion,
+ screenAsPectRatio);
+ }
+ }
+
+ /**
+ * 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 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 x, float y,
+ float z, short xx, short yy, short zz) {
+ motionSensingEvent = new MotionSensingEvent(getWiimoteId(),
+ orientationThreshold, accelerationThreshold, smoothingState,
+ alphaSmooth, r, p, ya, x, y, z, xx, yy, zz);
+ }
+
+ @Override
+ public String toString() {
+ String out = "";
+ /* Status */
+ out += "/*********** GENERIC EVENT : WIIMOTE ID :"
+ + super.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";
+ }
+
+ return out;
+ }
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/IREvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/IREvent.java
new file mode 100644
index 0000000..6007e97
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/IREvent.java
@@ -0,0 +1,285 @@
+/**
+ * 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.wiiuseapievents;
+
+import wiiusej.values.IRSource;
+
+/**
+ * Class which represents an IR event.
+ *
+ * @author guiguito
+ */
+public class IREvent extends WiimoteEvent {
+
+ /* IR Tracking */
+ private IRSource[] IRPoints;
+ private short indexPoints = 0;
+ private int x;
+ private int y;
+ private int z;// distance from the sensor bar
+ private int ax;
+ private int ay;
+ private int xVRes;
+ private int yVRes;
+ private int xOffset;
+ private int yOffset;
+ private short sensorBarPostion;
+ private short screenAsPectRatio;
+
+ static private short WIIUSE_IR_ABOVE = 0;
+ static private short WIIUSE_IR_BELOW = 1;
+ static private short WIIUSE_SCREEN_RATIO_4_3 = 0;
+ static private short WIIUSE_SCREEN_RATIO_16_9 = 1;
+
+ private static short NB_POINTS = 4;// number of points IR can track
+
+ /**
+ * Constructor of IREvent with full infos.
+ *
+ * @param id
+ * d of the wiimote concerned.
+ * @param x
+ * calculated X coordinate.
+ * @param y
+ * calculated Y coordinate.
+ * @param z
+ * calculated distance.
+ * @param ax
+ * absolute X coordinate.
+ * @param ay
+ * absolute Y coordinate
+ * @param xVRes
+ * IR virtual screen x resolution.
+ * @param yVRes
+ * IR virtual screen y resolution.
+ * @param xOffset
+ * IR X correction offset.
+ * @param yOffset
+ * IR Y correction offset.
+ * @param sensorBarPostion
+ * aspect ratio of the screen.
+ * @param screenAsPectRatio
+ * IR sensor bar position.
+ */
+ public IREvent(int id, int x, int y, int z, int ax, int ay, int xVRes,
+ int yVRes, int xOffset, int yOffset, short sensorBarPostion,
+ short screenAsPectRatio) {
+ super(id);
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.ax = ax;
+ this.ay = ay;
+ this.xVRes = xVRes;
+ this.yVRes = yVRes;
+ this.xOffset = xOffset;
+ this.yOffset = yOffset;
+ this.sensorBarPostion = sensorBarPostion;
+ this.screenAsPectRatio = screenAsPectRatio;
+ IRPoints = new IRSource[NB_POINTS];
+ }
+
+ /**
+ * Get list of IR points.
+ *
+ * @return the list of 2D points
+ */
+ public IRSource[] getIRPoints() {
+ return java.util.Arrays.copyOfRange(IRPoints, 0, indexPoints);
+ }
+
+ /**
+ * Add IR Point in the list (Max 4 points)
+ *
+ * @param x
+ * x value
+ * @param y
+ * y value
+ * @param rx
+ * raw X coordinate (0-1023).
+ * @param ry
+ * raw Y coordinate (0-1023).
+ * @param size
+ * size of the IR dot (0-15).
+ */
+ public void addIRpoint(int x, int y, short rx, short ry, short size) {
+ IRPoints[indexPoints] = new IRSource(x, y, rx, ry, size);
+ indexPoints++;
+ return;
+ }
+
+ /**
+ * Return calculated X coordinate.
+ *
+ * @return the x
+ */
+ public int getX() {
+ return x;
+ }
+
+ /**
+ * Return calculated Y coordinate.
+ *
+ * @return the y
+ */
+ public int getY() {
+ return y;
+ }
+
+ /**
+ * Return calculated distance.
+ *
+ * @return the z
+ */
+ public int getZ() {
+ return z;
+ }
+
+ /**
+ * Return absolute X coordinate.
+ *
+ * @return the ax
+ */
+ public int getAx() {
+ return ax;
+ }
+
+ /**
+ * Return absolute Y coordinate.
+ *
+ * @return the ay
+ */
+ public int getAy() {
+ return ay;
+ }
+
+ /**
+ * Return IR virtual screen x resolution.
+ *
+ * @return the xVRes
+ */
+ public int getXVRes() {
+ return xVRes;
+ }
+
+ /**
+ * Return IR virtual screen y resolution.
+ *
+ * @return the yVRes
+ */
+ public int getYVRes() {
+ return yVRes;
+ }
+
+ /**
+ * Return IR X correction offset.
+ *
+ * @return the xOffset
+ */
+ public int getXOffset() {
+ return xOffset;
+ }
+
+ /**
+ * Return IR Y correction offset.
+ *
+ * @return the yOffset
+ */
+ public int getYOffset() {
+ return yOffset;
+ }
+
+ /**
+ * Return true if the sensor bar is above.
+ *
+ * @return true if the sensor bar is above.
+ */
+ public boolean isSensorBarAbove() {
+ return sensorBarPostion == WIIUSE_IR_ABOVE;
+ }
+
+ /**
+ * Return true if the sensor bar is below.
+ *
+ * @return true if the sensor bar is below.
+ */
+ public boolean isSensorBarBelow() {
+ return sensorBarPostion == WIIUSE_IR_BELOW;
+ }
+
+ /**
+ * Return true if screen aspect ratio set is 4/3.
+ *
+ * @return true if screen aspect ratio set is 4/3.
+ */
+ public boolean isScreenAspectRatio43() {
+ return screenAsPectRatio == WIIUSE_SCREEN_RATIO_4_3;
+ }
+
+ /**
+ * Return true if screen aspect ratio set is 16/9.
+ *
+ * @return true if screen aspect ratio set is 16/9.
+ */
+ public boolean isScreenAspectRatio169() {
+ return screenAsPectRatio == WIIUSE_SCREEN_RATIO_16_9;
+ }
+
+ /**
+ * Return aspect ratio of the screen.
+ *
+ * @return the screenAsPectRatio
+ */
+ public short getScreenAsPectRatio() {
+ return screenAsPectRatio;
+ }
+
+ @Override
+ public String toString() {
+ String out = "";
+ /* Display IR Tracking */
+ out += "/******** IR Tracking ********/\n";
+ out += "--- Active : true\n";
+ out += "--- calculated X coordinate : " + x + "\n";
+ out += "--- calculated Y coordinate : " + y + "\n";
+ out += "--- calculated distance : " + z + "\n";
+ out += "--- absolute X coordinate : " + ax + "\n";
+ out += "--- absolute Y coordinate : " + ay + "\n";
+ out += "--- IR virtual screen x resolution : " + xVRes + "\n";
+ out += "--- IR virtual screen y resolution : " + yVRes + "\n";
+ out += "--- IR X correction offset : " + xOffset + "\n";
+ out += "--- IR Y correction offset : " + yOffset + "\n";
+ if (isScreenAspectRatio43()) {
+ out += "--- aspect ratio of the screen : 4/3\n";
+ } else if (isScreenAspectRatio169()) {
+ out += "--- aspect ratio of the screen : 16/9\n";
+ }
+ if (isSensorBarAbove()) {
+ out += "--- IR sensor bar position. : Above\n";
+ } else if (isSensorBarBelow()) {
+ out += "--- IR sensor bar position. : Below\n";
+ }
+ out += "--- Seen points\n";
+ for (int i = 0; i < IRPoints.length; i++) {
+ if (IRPoints[i] != null) {
+ out += IRPoints[i].toString();
+ }
+ }
+ out += "\n";
+ return out;
+ }
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/MotionSensingEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/MotionSensingEvent.java
new file mode 100644
index 0000000..6ec7712
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/MotionSensingEvent.java
@@ -0,0 +1,194 @@
+/**
+ * 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.wiiuseapievents;
+
+import wiiusej.values.GForce;
+import wiiusej.values.Orientation;
+import wiiusej.values.RawAcceleration;
+
+/**
+ * Class which represents a motion sensing event.
+ *
+ * @author guiguito
+ */
+public class MotionSensingEvent extends WiimoteEvent {
+
+ /* Motion Sensing */
+ private Orientation orientation;
+ private GForce gforce;
+ private RawAcceleration acceleration;
+
+ private float orientationThreshold = 0;
+ private int accelerationThreshold = 0;
+ private float alphaSmoothing = 0;
+ private boolean isSmoothingActive = false;
+
+ /**
+ * Constructor for a Motion Sensing Event.
+ *
+ * @param id
+ * id of the wiimote concerned.
+ * @param orientationThreshold
+ * value of the minimum angle between two events with the
+ * accelerometer
+ * @param accelerationThreshold
+ * value of the value variation between two events with the
+ * accelerometer
+ * @param smoothingState
+ * true if smoothing flag is activated
+ * @param alphaSmooth
+ * value of the alpha smoothing parameter
+ * @param r
+ * roll
+ * @param p
+ * pitch
+ * @param ya
+ * yaw
+ * @param x
+ * gravity force on x axis
+ * @param y
+ * gravity force on y axis
+ * @param z
+ * gravity force on z axis
+ * @param xx
+ * raw acceleration on x axis
+ * @param yy
+ * raw acceleration on y axis
+ * @param zz
+ * raw acceleration on z axis
+ */
+ public MotionSensingEvent(int id, float orientationThreshold,
+ int accelerationThreshold, boolean smoothingState,
+ float alphaSmooth, float r, float p, float ya, float x, float y,
+ float z, short xx, short yy, short zz) {
+ super(id);
+ this.orientationThreshold = orientationThreshold;
+ this.accelerationThreshold = accelerationThreshold;
+ this.isSmoothingActive = smoothingState;
+ this.alphaSmoothing = alphaSmooth;
+ setOrientationAndGforce(r, p, ya, x, y, z, xx, yy, zz);
+ }
+
+ /**
+ * Set orientation, gravity force and raw acceleration.
+ *
+ * @param r
+ * roll
+ * @param p
+ * pitch
+ * @param ya
+ * yaw
+ * @param x
+ * gravity force on x axis
+ * @param y
+ * gravity force on y axis
+ * @param z
+ * gravity force on z axis
+ * @param xx
+ * raw acceleration on x axis
+ * @param yy
+ * raw acceleration on y axis
+ * @param zz
+ * raw acceleration on z axis
+ */
+ private void setOrientationAndGforce(float r, float p, float ya, float x,
+ float y, float z, short xx, short yy, short zz) {
+ this.orientation = new Orientation(r, p, ya);
+ this.gforce = new GForce(x, y, z);
+ this.acceleration = new RawAcceleration(xx, yy, zz);
+ }
+
+ /**
+ * @return the orientation
+ */
+ public Orientation getOrientation() {
+ return orientation;
+ }
+
+ /**
+ * Get the gravity force.
+ *
+ * @return the gforce
+ */
+ public GForce getGforce() {
+ return gforce;
+ }
+
+ /**
+ * Get the raw acceleration.
+ *
+ * @return the raw acceleration
+ */
+ public RawAcceleration getRawAcceleration() {
+ return acceleration;
+ }
+
+ /**
+ * Get orientation threshold.
+ *
+ * @return the orientationThreshold
+ */
+ public float getOrientationThreshold() {
+ return orientationThreshold;
+ }
+
+ /**
+ * Get acceleration threshold.
+ *
+ * @return the accelerationThreshold
+ */
+ public int getAccelerationThreshold() {
+ return accelerationThreshold;
+ }
+
+ /**
+ * Get alpha smoothing.
+ *
+ * @return the alphaSmoothing
+ */
+ public float getAlphaSmoothing() {
+ return alphaSmoothing;
+ }
+
+ /**
+ * Tell if the option SMOOTHING is activated.
+ *
+ * @return the isSmoothingActive
+ */
+ public boolean isSmoothingActive() {
+ return isSmoothingActive;
+ }
+
+ @Override
+ public String toString() {
+ String out = "";
+ /* Motion sensing */
+ out += "/******** Motion sensing ********/\n";
+ out += "--- Motion sensing : true \n";
+ out += "--- Orientation threshold value ? : " + orientationThreshold
+ + "\n";
+ out += "--- Acceleration threshold value ? : " + accelerationThreshold
+ + "\n";
+ out += "--- Alpha smoothing threshold value ? : " + alphaSmoothing
+ + "\n";
+ out += "--- Smoothing ? : " + isSmoothingActive + "\n";
+ out += "--- " + orientation + "\n";
+ out += "--- " + gforce + "\n";
+ out += "--- " + acceleration + "\n";
+ return out;
+ }
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/StatusEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/StatusEvent.java
new file mode 100644
index 0000000..7a365fc
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/StatusEvent.java
@@ -0,0 +1,258 @@
+/**
+ * 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.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 {
+
+ private static short WIIMOTE_LED_1 = 1;
+ private static short WIIMOTE_LED_2 = 2;
+ private static short WIIMOTE_LED_3 = 4;
+ private 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;
+ }
+
+ /**
+ * Get led1 status.
+ *
+ * @return true if the led is set.
+ */
+ public boolean isLed1Set() {
+ if ((leds & WIIMOTE_LED_1) > 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Get led2 status.
+ *
+ * @return true if the led is set.
+ */
+ public boolean isLed2Set() {
+ if ((leds & WIIMOTE_LED_2) > 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Get led3 status.
+ *
+ * @return true if the led is set.
+ */
+ public boolean isLed3Set() {
+ if ((leds & WIIMOTE_LED_3) > 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Get led4 status.
+ *
+ * @return true if the led is set.
+ */
+ public boolean isLed4Set() {
+ if ((leds & WIIMOTE_LED_4) > 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Tell if the speaker is enable for this wiimote
+ *
+ * @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_0.11/src/wiiusej/wiiuseapievents/WiiUseApiEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiiUseApiEvent.java
new file mode 100644
index 0000000..880c632
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiiUseApiEvent.java
@@ -0,0 +1,62 @@
+/**
+ * This file is part of WiiuseJ.
+ *
+ * WiiuseJ is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * WiiuseJ is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with WiiuseJ. If not, see .
+ */
+package wiiusej.wiiuseapievents;
+
+/**
+ * This class describes the structure of an event from the WiiUse API event.
+ *
+ * @author guiguito
+ */
+public abstract class WiiUseApiEvent extends WiimoteEvent{
+
+ public static int GENERIC_EVENT = 1;
+ public static int STATUS_EVENT = 2;
+ public static int DISCONNECTION_EVENT = 3;
+ public static int WIIUSE_NUNCHUK_INSERTED = 4;
+ public static int WIIUSE_NUNCHUK_REMOVED = 5;
+ public static int WIIUSE_CLASSIC_CTRL_INSERTED = 6;
+ public static int WIIUSE_CLASSIC_CTRL_REMOVED = 7;
+ public static int WIIUSE_GUITAR_HERO_3_CTRL_INSERTED = 8;
+ public static int WIIUSE_GUITAR_HERO_3_CTRL_REMOVED = 9;
+
+ /* Event Type */
+ private int eventType;
+
+ /**
+ * 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_0.11/src/wiiusej/wiiuseapievents/WiiUseApiListener.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiiUseApiListener.java
new file mode 100644
index 0000000..3f6bb22
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiiUseApiListener.java
@@ -0,0 +1,39 @@
+/**
+ * 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.wiiuseapievents;
+
+
+
+/**
+ * This is the interface to implement to listen to events from the wiiuse API.
+ *
+ * @author guiguito
+ */
+public interface WiiUseApiListener extends java.util.EventListener {
+
+ /**
+ * Method called when a WiiUseApiEvent occurs.
+ * A WiiUseApiEvent can be :
+ * - GenericEvent (Storing ButtonsEvent and
+ * eventually IREvent and MotionSensingEvent)
+ * - StatusEvent
+ * - DisconnectionEvent
+ * @param e
+ */
+ void onWiiUseApiEvent(WiiUseApiEvent e);
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiimoteEvent.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiimoteEvent.java
new file mode 100644
index 0000000..1504a37
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiimoteEvent.java
@@ -0,0 +1,59 @@
+/**
+ * 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.wiiuseapievents;
+
+/**
+ * Abstract mother class representing an event with a wiimote id.
+ *
+ * @author guiguito
+ */
+public abstract class WiimoteEvent {
+
+ /* ID */
+ private int wiimoteId = -1;
+
+ /**
+ * Construct the WiiUseApiEvent setting up the id.
+ *
+ * @param id
+ * the Wiimote id
+ */
+ public WiimoteEvent(int id) {
+ wiimoteId = id;
+ }
+
+ /**
+ * Get Wiimote ID
+ *
+ * @return the wiimote id.
+ */
+ public int getWiimoteId() {
+ return wiimoteId;
+ }
+
+ /**
+ * Set Wiimote ID
+ *
+ * @param wiimoteId
+ * id of the wiimote
+ */
+ void setWiimoteId(int wiimoteId) {
+ this.wiimoteId = wiimoteId;
+ }
+
+ public abstract String toString();
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiimoteListener.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiimoteListener.java
new file mode 100644
index 0000000..3ea3c05
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapievents/WiimoteListener.java
@@ -0,0 +1,69 @@
+/**
+ * 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.wiiuseapievents;
+
+/**
+ * This is the interface to implement to listen to events from wiimotes.
+ * The differents methods are called in this order :
+ * onButtonsEvent, onIrEvent, onMotionSensingEvent, onStatusEvent, onDisconnectionEvent.
+ *
+ * @author guiguito
+ */
+public interface WiimoteListener extends java.util.EventListener {
+
+ /**
+ * Method called on a button Event.
+ * @param e the buttonEvent with the last informations
+ * about the buttons of the wiimote.
+ */
+ void onButtonsEvent(ButtonsEvent e);
+
+ /**
+ * Method called when an IR event occurs.
+ * @param e the IREvent with the IR points seen.
+ */
+ void onIrEvent(IREvent e);
+
+ /**
+ * Method called when a motion sensing event occurs.
+ * @param e the motion sensing event with orientation and acceleration.
+ */
+ void onMotionSensingEvent(MotionSensingEvent e);
+
+ /**
+ * Method called on a status event.
+ * A status event occurs when :
+ * - we ask it
+ * - an expansion controller has been plugged
+ * - an expansion controller has been unplugged
+ * This is where you can get the different values of
+ * the parameters setup on your wiimote.
+ * @param e the status event.
+ */
+ void onStatusEvent(StatusEvent e);
+
+ /**
+ * This is the method called when a disconnection event occurs.
+ * A disconnection event happens when :
+ * - there are no battery left
+ * - the wiimote has just been turned off
+ * - the connection is dropped
+ * @param e the disconnection event.
+ */
+ void onDisconnectionEvent(DisconnectionEvent e);
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/FloatValueRequest.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/FloatValueRequest.java
new file mode 100644
index 0000000..a003239
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/FloatValueRequest.java
@@ -0,0 +1,71 @@
+/**
+ * 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.wiiuseapirequest;
+
+/**
+ * Represents a request with a float value to pass to wiiuse API.
+ *
+ * @author guiguito
+ */
+public class FloatValueRequest extends WiiUseApiRequest {
+
+ private float floatValue;
+
+ /**
+ * Constructor setting the id of the wiimote concerned.
+ *
+ * @param id
+ * the id of the wiimote concerned.
+ */
+ public FloatValueRequest(int id, int type) {
+ super(id, type);
+ }
+
+ /**
+ * Constructor setting the id of the wiimote concerned.
+ *
+ * @param id
+ * the id of the wiimote concerned.
+ * @param type
+ * type of the request
+ * @param th
+ * threshold in degrees
+ */
+ public FloatValueRequest(int id, int type, float th) {
+ super(id, type);
+ floatValue = th;
+ }
+
+ /**
+ * Get the float value.
+ * @return the float value
+ */
+ public float getFloatValue() {
+ return floatValue;
+ }
+
+ /**
+ * Set the float value.
+ * @param val the value to set
+ */
+ public void setFloatValue(float val) {
+ this.floatValue = val;
+ }
+
+
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/IntValueRequest.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/IntValueRequest.java
new file mode 100644
index 0000000..801093d
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/IntValueRequest.java
@@ -0,0 +1,74 @@
+/**
+ * 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.wiiuseapirequest;
+
+/**
+ * Represents a request with an int value to pass to wiiuse API.
+ *
+ * @author guiguito
+ */
+public class IntValueRequest extends WiiUseApiRequest {
+
+ private int intValue;
+
+ /**
+ * Constructor setting the id of the wiimote
+ * concerned and the type of the request.
+ *
+ * @param id
+ * the id of the wiimote concerned.
+ */
+ public IntValueRequest(int id, int type) {
+ super(id, type);
+ }
+
+ /**
+ * Constructor setting the id of the wiimote
+ * concerned, the type of the request
+ * and the int value.
+ *
+ * @param id
+ * the id of the wiimote concerned.
+ * @param type
+ * type of the request
+ * @param th
+ * the int value.
+ */
+ public IntValueRequest(int id, int type, int th) {
+ super(id, type);
+ intValue = th;
+ }
+
+ /**
+ * Get the int value.
+ * @return the int value
+ */
+ public int getIntValue() {
+ return intValue;
+ }
+
+ /**
+ * Set the int value.
+ * @param val the value to set
+ */
+ public void setIntValue(int val) {
+ this.intValue = val;
+ }
+
+
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/LedsRequest.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/LedsRequest.java
new file mode 100644
index 0000000..1a21024
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/LedsRequest.java
@@ -0,0 +1,125 @@
+/**
+ * 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.wiiuseapirequest;
+
+/**
+ * Represents a request to set leds of the wiimote with WiiUse API.
+ *
+ * @author guiguito
+ */
+public class LedsRequest extends wiiusej.wiiuseapirequest.WiiUseApiRequest {
+
+ private boolean led1, led2, led3, led4;
+
+ /**
+ * Constructor setting the id of the wiimote concerned.
+ *
+ * @param id
+ * id of the wiimote concerned
+ * @param type
+ * type of the request
+ */
+ public LedsRequest(int id, int type) {
+ super(id, type);
+ }
+
+ /**
+ * Constructor setting the id of the wiimote concerned.
+ *
+ * @param id
+ * id of the wiimote concerned
+ * @param type
+ * type of the request
+ * @param l1
+ * led1 status. True=ON, False=OFF
+ * @param l2
+ * led2 status. True=ON, False=OFF
+ * @param l3
+ * led3 status. True=ON, False=OFF
+ * @param l4
+ * led4 status. True=ON, False=OFF
+ */
+ public LedsRequest(int id, int type, boolean l1, boolean l2, boolean l3,
+ boolean l4) {
+ super(id, type);
+ led1 = l1;
+ led2 = l2;
+ led3 = l3;
+ led4 = l4;
+ }
+
+ /**
+ * @return the led1
+ */
+ public boolean isLed1() {
+ return led1;
+ }
+
+ /**
+ * @param led1
+ * the led1 to set
+ */
+ public void setLed1(boolean led1) {
+ this.led1 = led1;
+ }
+
+ /**
+ * @return the led2
+ */
+ public boolean isLed2() {
+ return led2;
+ }
+
+ /**
+ * @param led2
+ * the led2 to set
+ */
+ public void setLed2(boolean led2) {
+ this.led2 = led2;
+ }
+
+ /**
+ * @return the led3
+ */
+ public boolean isLed3() {
+ return led3;
+ }
+
+ /**
+ * @param led3
+ * the led3 to set
+ */
+ public void setLed3(boolean led3) {
+ this.led3 = led3;
+ }
+
+ /**
+ * @return the led4
+ */
+ public boolean isLed4() {
+ return led4;
+ }
+
+ /**
+ * @param led4
+ * the led4 to set
+ */
+ public void setLed4(boolean led4) {
+ this.led4 = led4;
+ }
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/TwoIntValueRequest.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/TwoIntValueRequest.java
new file mode 100644
index 0000000..98e907e
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/TwoIntValueRequest.java
@@ -0,0 +1,73 @@
+/**
+ * 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.wiiuseapirequest;
+
+
+/**
+ * Represents a request with two int values to pass to wiiuse API.
+ *
+ * @author guiguito
+ */
+public class TwoIntValueRequest extends IntValueRequest {
+
+ private int secondIntValue;
+
+ /**
+ * Constructor setting the id of the wiimote
+ * concerned and the type of the request.
+ *
+ * @param id the id of the wiimote concerned.
+ * @param type type of the request
+ */
+ public TwoIntValueRequest(int id, int type) {
+ super(id, type);
+ }
+
+ /**
+ * Constructor setting the id of the wiimote
+ * concerned, the type of the request
+ * and the two int values.
+ *
+ * @param id the id of the wiimote concerned.
+ * @param type type of the request
+ * @param x first int value.
+ * @param y second int value.
+ */
+ public TwoIntValueRequest(int id, int type, int x, int y) {
+ super(id, type, x);
+ secondIntValue = y;
+ }
+
+ /**
+ * Get the second int value.
+ * @return the secondIntValue
+ */
+ public int getSecondIntValue() {
+ return secondIntValue;
+ }
+
+ /**
+ * Set the second int value.
+ * @param secondIntValue the secondIntValue to set.
+ */
+ public void setSecondIntValue(int secondIntValue) {
+ this.secondIntValue = secondIntValue;
+ }
+
+
+
+}
diff --git a/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/WiiUseApiRequest.java b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/WiiUseApiRequest.java
new file mode 100644
index 0000000..1f4525b
--- /dev/null
+++ b/WiiUseJ_0.11/src/wiiusej/wiiuseapirequest/WiiUseApiRequest.java
@@ -0,0 +1,112 @@
+/**
+ * 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.wiiuseapirequest;
+
+/**
+ * Represents a request we could do to the WiiUse API.
+ *
+ * @author guiguito
+ */
+public class WiiUseApiRequest {
+
+ public static int WIIUSE_STATUS_REQUEST = 1;
+ public static int WIIUSE_ACTIVATE_SMOOTHING_REQUEST = 2;
+ public static int WIIUSE_DEACTIVATE_SMOOTHING_REQUEST = -2;
+ public static int WIIUSE_ACTIVATE_IR_TRACKING_REQUEST = 3;
+ public static int WIIUSE_DEACTIVATE_IR_TRACKING_REQUEST = -3;
+ public static int WIIUSE_ACTIVATE_MOTION_SENSING_REQUEST = 4;
+ public static int WIIUSE_DEACTIVATE_MOTION_SENSING_REQUEST = -4;
+ public static int WIIUSE_CLOSE_CONNECTION_REQUEST = 5;
+ public static int WIIUSE_ACTIVATE_CONTINUOUS_REQUEST = 6;
+ public static int WIIUSE_DEACTIVATE_CONTINUOUS_REQUEST = -6;
+ public static int WIIUSE_ACTIVATE_RUMBLE_REQUEST = 7;
+ public static int WIIUSE_DEACTIVATE_RUMBLE_REQUEST = -7;
+ public static int WIIUSE_LEDS_REQUEST = 8;
+ public static int WIIUSE_ORIENT_THRESHOLHD_REQUEST = 9;
+ public static int WIIUSE_ACCEL_THRESHOLHD_REQUEST = 10;
+ public static int WIIUSE_ALPHA_SMOOTHING_REQUEST = 11;
+ public static int WIIUSE_RESYNC = 12;
+ public static int WIIUSE_ASPECT_RATIO_4_3 = 13;
+ public static int WIIUSE_ASPECT_RATIO_16_9 = 14;
+ public static int WIIUSE_SENSOR_BAR_ABOVE = 15;
+ public static int WIIUSE_SENSOR_BAR_BELOW = 16;
+ public static int WIIUSE_SET_VIRTUAL_RESOLUTION = 17;
+
+ private int wiimoteId = 0;
+ private int requestType = 0;
+
+ /**
+ * Constructor setting the id of the wiimote concerned.
+ *
+ * @param id
+ * the id of the wiimote concerned.
+ */
+ public WiiUseApiRequest(int id) {
+ wiimoteId = id;
+ }
+
+ /**
+ * Constructor setting the id of the wiimote concerned.
+ *
+ * @param id
+ * the id of the wiimote concerned.
+ *
+ */
+ public WiiUseApiRequest(int id, int type) {
+ wiimoteId = id;
+ requestType = type;
+ }
+
+ /**
+ * Get id of the wiimote concerned by this request.
+ *
+ * @return id of the wiimote concerned
+ */
+ public int getId() {
+ return wiimoteId;
+ }
+
+ /**
+ * Set id of the wiimote concerned by this request.
+ *
+ * @param id
+ * id fh the wiimote concernet
+ */
+ public void setId(int id) {
+ wiimoteId = id;
+ }
+
+ /**
+ * Get the request type.
+ *
+ * @return the requestType
+ */
+ public int getRequestType() {
+ return requestType;
+ }
+
+ /**
+ * Set the request type.
+ *
+ * @param requestType
+ * the requestType to set
+ */
+ public void setRequestType(int requestType) {
+ this.requestType = requestType;
+ }
+
+}
diff --git a/WiiUseJ_0.11/wiiuse.dll b/WiiUseJ_0.11/wiiuse.dll
new file mode 100644
index 0000000..6855619
Binary files /dev/null and b/WiiUseJ_0.11/wiiuse.dll differ