diff --git a/cpp/wiiuse/.cproject b/cpp/wiiuse/.cproject
index 6ce7a94..a5a7260 100644
--- a/cpp/wiiuse/.cproject
+++ b/cpp/wiiuse/.cproject
@@ -183,4 +183,5 @@
+
diff --git a/cpp/wiiuse/src/definitions.h b/cpp/wiiuse/src/definitions.h
index 8e23ed7..bc44ff5 100644
--- a/cpp/wiiuse/src/definitions.h
+++ b/cpp/wiiuse/src/definitions.h
@@ -54,8 +54,8 @@
char* file = __FILE__; \
int i = strlen(file) - 1; \
for (; i && (file[i] != '\\'); --i); \
- fprintf(stderr, "[DEBUG] %s:%i: " fmt "\n", file+i+1, __LINE__, ##__VA_ARGS__); \
- fflush(stderr); \
+ fprintf(stdout, "[DEBUG] %s:%i: " fmt "\n", file+i+1, __LINE__, ##__VA_ARGS__); \
+ fflush(stdout); \
} while (0)
#else
#define WIIUSE_DEBUG(fmt, ...) fprintf(stderr, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__)
diff --git a/cpp/wiiuse/src/events.c b/cpp/wiiuse/src/events.c
index 26a822c..e80a3d6 100644
--- a/cpp/wiiuse/src/events.c
+++ b/cpp/wiiuse/src/events.c
@@ -640,7 +640,7 @@ void handshake_expansion(struct wiimote_t* wm, byte* data, unsigned short len) {
if (!data) {
byte* handshake_buf;
- byte buf = 0x00;
+ byte buf = 0x55;
if (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP))
disable_expansion(wm);
@@ -651,7 +651,9 @@ void handshake_expansion(struct wiimote_t* wm, byte* data, unsigned short len) {
wm->timeout = wm->exp_timeout;
#endif
- wiiuse_write_data(wm, WM_EXP_MEM_ENABLE, &buf, 1);
+ wiiuse_write_data(wm, WM_EXP_MEM_ENABLE1, &buf, 1);
+ buf = 0x00;
+ wiiuse_write_data(wm, WM_EXP_MEM_ENABLE2, &buf, 1);
/* get the calibration data */
handshake_buf = malloc(EXP_HANDSHAKE_LEN * sizeof(byte));
diff --git a/cpp/wiiuse/src/nunchuk.c b/cpp/wiiuse/src/nunchuk.c
index 48dbe6a..2733174 100644
--- a/cpp/wiiuse/src/nunchuk.c
+++ b/cpp/wiiuse/src/nunchuk.c
@@ -53,7 +53,6 @@ static void nunchuk_pressed_buttons(struct nunchuk_t* nc, byte now);
* @return Returns 1 if handshake was successful, 0 if not.
*/
int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, unsigned short len) {
- int i;
int offset = 0;
nc->btns = 0;
@@ -64,10 +63,6 @@ int nunchuk_handshake(struct wiimote_t* wm, struct nunchuk_t* nc, byte* data, un
nc->flags = &wm->flags;
nc->accel_calib.st_alpha = wm->accel_calib.st_alpha;
- /* decrypt data */
- for (i = 0; i < len; ++i)
- data[i] = (data[i] ^ 0x17) + 0x17;
-
if (data[offset] == 0xFF) {
/*
* Sometimes the data returned here is not correct.
@@ -137,12 +132,6 @@ void nunchuk_disconnected(struct nunchuk_t* nc) {
* @param msg The message specified in the event packet.
*/
void nunchuk_event(struct nunchuk_t* nc, byte* msg) {
- int i;
-
- /* decrypt data */
- for (i = 0; i < 6; ++i)
- msg[i] = (msg[i] ^ 0x17) + 0x17;
-
/* get button states */
nunchuk_pressed_buttons(nc, msg[5]);
diff --git a/cpp/wiiuse/src/wiiuse_internal.h b/cpp/wiiuse/src/wiiuse_internal.h
index 25357a4..fb623e3 100644
--- a/cpp/wiiuse/src/wiiuse_internal.h
+++ b/cpp/wiiuse/src/wiiuse_internal.h
@@ -87,6 +87,7 @@
#define WM_RPT_BTN_ACC_EXP 0x35
#define WM_RPT_BTN_IR_EXP 0x36
#define WM_RPT_BTN_ACC_IR_EXP 0x37
+#define WM_RPT_BALANCE_BOARD 0x40
#define WM_BT_INPUT 0x01
#define WM_BT_OUTPUT 0x02
@@ -104,7 +105,8 @@
/* offsets in wiimote memory */
#define WM_MEM_OFFSET_CALIBRATION 0x16
#define WM_EXP_MEM_BASE 0x04A40000
-#define WM_EXP_MEM_ENABLE 0x04A40040
+#define WM_EXP_MEM_ENABLE1 0x04A400F0
+#define WM_EXP_MEM_ENABLE2 0x04A400FB
#define WM_EXP_MEM_CALIBR 0x04A40020
#define WM_REG_IR 0x04B00030
@@ -149,9 +151,9 @@
*/
/* encrypted expansion id codes (located at 0x04A400FC) */
-#define EXP_ID_CODE_NUNCHUK 0x9A1EFEFE
-#define EXP_ID_CODE_CLASSIC_CONTROLLER 0x9A1EFDFD
-#define EXP_ID_CODE_GUITAR 0x9A1EFDFB
+#define EXP_ID_CODE_NUNCHUK 0xA4200000
+#define EXP_ID_CODE_CLASSIC_CONTROLLER 0xA4200101
+#define EXP_ID_CODE_GUITAR 0xA4200103
#define EXP_ID_CODE_BALANCE_BOARD 0xA4200402
#define EXP_HANDSHAKE_LEN 224
diff --git a/cpp/wiiusej/lib/wiiuse.lib b/cpp/wiiusej/lib/wiiuse.lib
index 906e164..0c6fe6e 100644
Binary files a/cpp/wiiusej/lib/wiiuse.lib and b/cpp/wiiusej/lib/wiiuse.lib differ
diff --git a/java/build.xml b/java/build.xml
index c139385..a901c7b 100644
--- a/java/build.xml
+++ b/java/build.xml
@@ -6,8 +6,8 @@
-
+
@@ -43,15 +43,15 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/java/mimis.exe b/java/mimis.exe
index 3933eaf..d0fb364 100644
Binary files a/java/mimis.exe and b/java/mimis.exe differ
diff --git a/java/src/mimis/Worker.java b/java/src/mimis/Worker.java
index 6da9482..8056362 100644
--- a/java/src/mimis/Worker.java
+++ b/java/src/mimis/Worker.java
@@ -79,7 +79,6 @@ public abstract class Worker implements Runnable {
public final void run() {
while (run || deactivate) {
- //log.debug("run() run=" + run + ", active=" + active + ", activate=" + activate + ", deactivate=" + deactivate);
if (activate && !active) {
try {
activate();
diff --git a/java/src/mimis/application/cmd/windows/WindowsApplication.java b/java/src/mimis/application/cmd/windows/WindowsApplication.java
index 6fff081..292dba6 100644
--- a/java/src/mimis/application/cmd/windows/WindowsApplication.java
+++ b/java/src/mimis/application/cmd/windows/WindowsApplication.java
@@ -38,6 +38,7 @@ public abstract class WindowsApplication extends CMDApplication {
public boolean active() {
if (!active) {
handle = Native.getHandle(window);
+ system(Command.System.MAXIMIZE);
}
return super.active();
}
@@ -64,6 +65,14 @@ public abstract class WindowsApplication extends CMDApplication {
//return Windows.sendMessage(handle, Windows.WM_USER + wParam, 0, 0);
}
+ protected void system(Command.System system) {
+ system(system, 0);
+ }
+
+ protected void system(Command.System system, int lParam) {
+ Native.sendMessage(handle, Windows.WM_SYSCOMMAND, system.getCode(), lParam);
+ }
+
protected void key(Type type, int code) {
int scanCode = Native.mapVirtualKey(code, Windows.MAPVK_VK_TO_VSC);
Native.postMessage(handle, type.getCode(), code, 1 | (scanCode << 16));
diff --git a/java/src/mimis/device/lirc/LircButtonListener.java b/java/src/mimis/device/lirc/LircButtonListener.java
index d37c98e..9bbf826 100644
--- a/java/src/mimis/device/lirc/LircButtonListener.java
+++ b/java/src/mimis/device/lirc/LircButtonListener.java
@@ -2,4 +2,4 @@ package mimis.device.lirc;
public interface LircButtonListener {
public void add(LircButton lircButton);
-}
+}
\ No newline at end of file
diff --git a/java/src/mimis/device/lirc/remote/ColorButton.java b/java/src/mimis/device/lirc/remote/ColorButton.java
new file mode 100644
index 0000000..257bf75
--- /dev/null
+++ b/java/src/mimis/device/lirc/remote/ColorButton.java
@@ -0,0 +1,7 @@
+package mimis.device.lirc.remote;
+
+import mimis.Button;
+
+public enum ColorButton implements Button {
+ RED, GREEN, YELLOW, BLUE;
+}
diff --git a/java/src/mimis/device/wiimote/WiimoteDevice.java b/java/src/mimis/device/wiimote/WiimoteDevice.java
index 8d7d91a..6745821 100644
--- a/java/src/mimis/device/wiimote/WiimoteDevice.java
+++ b/java/src/mimis/device/wiimote/WiimoteDevice.java
@@ -19,6 +19,7 @@ import org.wiigee.event.GestureListener;
import org.wiigee.util.Log;
import wiiusej.Wiimote;
+import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
@@ -27,7 +28,7 @@ public class WiimoteDevice extends Device implements GestureListener {
protected static final int RUMBLE = 50;
protected static final int CONNECTED_TIMEOUT = 500;
protected static final int LED_TIMEOUT = 1000;
- protected static final int LED_SLEEP = 20;
+ protected static final int LED_SLEEP = 50;
protected static WiimoteService wiimoteService;
protected WiimoteEventMapCycle eventMapCycle;
@@ -41,7 +42,7 @@ public class WiimoteDevice extends Device implements GestureListener {
static {
WiimoteDevice.wiimoteService = new WiimoteService();
- Log.setLevel(0);
+ Log.setLevel(Log.DEBUG);
}
public WiimoteDevice() {
@@ -160,8 +161,8 @@ public class WiimoteDevice extends Device implements GestureListener {
public void feedback(Feedback feedback) {
if (wiimote != null && active()) {
- log.debug("Wiimote rumble feedback");
- wiimote.rumble(RUMBLE);
+ //log.debug("Wiimote rumble feedback");
+ //wiimote.rumble(RUMBLE);
}
}
@@ -170,8 +171,8 @@ public class WiimoteDevice extends Device implements GestureListener {
wiimote = wiimoteService.getDevice(this);
//wiimote.activateContinuous();
wiimoteDiscovery.stop();
- //ledWorker.start();
- sleep(10000);
+ ledWorker.start();
+ //sleep(10000);
}
/* Listeners */
@@ -195,6 +196,10 @@ public class WiimoteDevice extends Device implements GestureListener {
gestureDevice.add(event.getGforce());
}
+ public void onIrEvent(IREvent event) {
+
+ }
+
public void gestureReceived(GestureEvent event) {
if (event.isValid()) {
System.out.printf("id #%d, prob %.0f%%, valid %b\n", event.getId(), 100 * event.getProbability(), event.isValid());
diff --git a/java/src/mimis/device/wiimote/WiimoteDiscovery.java b/java/src/mimis/device/wiimote/WiimoteDiscovery.java
index c4eca93..4fb436d 100644
--- a/java/src/mimis/device/wiimote/WiimoteDiscovery.java
+++ b/java/src/mimis/device/wiimote/WiimoteDiscovery.java
@@ -9,7 +9,7 @@ import mimis.exception.worker.ActivateException;
import mimis.exception.worker.DeactivateException;
public class WiimoteDiscovery extends Worker {
- protected static final String WIISCAN = "wiiscan-bb.exe";
+ protected static final String WIISCAN = "wiiscan.exe";
protected static final int TIMEOUT = 1000;
protected WiimoteDevice wiimoteDevice;
protected Process process;
@@ -30,12 +30,13 @@ public class WiimoteDiscovery extends Worker {
}
public boolean execute(String parameters) {
- String command = WIISCAN + " -l none " + parameters;
+ String command = WIISCAN + " -l wiiuse " + parameters;
try {
process = Runtime.getRuntime().exec(command);
Scanner scanner = new Scanner(process.getInputStream());
while (scanner.hasNext()) {
String line = scanner.nextLine();
+ log.error(line);
if (line.contains("error: BluetoothSetServiceState()")) {
disconnect = true;
return false;
diff --git a/java/src/mimis/device/wiimote/WiimoteService.java b/java/src/mimis/device/wiimote/WiimoteService.java
index bfd3771..affa201 100644
--- a/java/src/mimis/device/wiimote/WiimoteService.java
+++ b/java/src/mimis/device/wiimote/WiimoteService.java
@@ -89,7 +89,7 @@ public class WiimoteService extends WiiUseApiManager implements WiimoteListener
}
public void onStatusEvent(StatusEvent event) {
- log.debug(event);
+ //log.debug(event);
if (event.isConnected()) {
WiimoteDevice wiimoteDevice = getWiimoteDevice(event);
wiimoteDevice.connected = true;
@@ -99,7 +99,10 @@ public class WiimoteService extends WiiUseApiManager implements WiimoteListener
}
}
- public void onIrEvent(IREvent event) {}
+ public void onIrEvent(IREvent event) {
+ getWiimoteDevice(event).onIrEvent(event);
+ }
+
public void onExpansionEvent(ExpansionEvent event) {}
public void onDisconnectionEvent(DisconnectionEvent event) {}
public void onNunchukInsertedEvent(NunchukInsertedEvent event) {}
diff --git a/java/src/mimis/event/EventHandler.java b/java/src/mimis/event/EventHandler.java
index db0d093..d64169b 100644
--- a/java/src/mimis/event/EventHandler.java
+++ b/java/src/mimis/event/EventHandler.java
@@ -1,10 +1,16 @@
package mimis.event;
import mimis.Event;
+import mimis.sequence.SequenceParser;
import mimis.value.Action;
public abstract class EventHandler extends EventListener {
protected static EventRouter eventRouter;
+ protected static SequenceParser sequenceParser;
+
+ static {
+ //sequenceParser = new SequenceParser();
+ }
public static void initialise(EventRouter eventRouter) {
EventHandler.eventRouter = eventRouter;
diff --git a/java/src/mimis/util/Ir.java b/java/src/mimis/util/Ir.java
new file mode 100644
index 0000000..7b5efa8
--- /dev/null
+++ b/java/src/mimis/util/Ir.java
@@ -0,0 +1,180 @@
+package mimis.util;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Line2D;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+
+import mimis.device.lirc.LircButton;
+import mimis.device.lirc.LircButtonListener;
+import mimis.device.lirc.LircService;
+import mimis.device.lirc.remote.PhiliphsRCLE011Button;
+import mimis.device.wiimote.WiimoteDevice;
+import mimis.device.wiimote.WiimoteService;
+import mimis.exception.device.DeviceNotFoundException;
+import wiiusej.Wiimote;
+import wiiusej.wiiusejevents.physicalevents.IREvent;
+
+public class Ir extends WiimoteDevice implements LircButtonListener {
+ protected Graph graph;
+ protected Point tl, tr, br, bl, raw, point;
+ protected Line t, r, b, l;
+
+ public Ir() {
+ tl = tr = br = bl = new Point(0, 0);
+ graph = new Graph();
+ /*try {
+ while (true) {
+ graph.draw(new Point(Math.random(), Math.random()));
+ Thread.sleep(100);
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }*/
+ LircService lircService = new LircService();
+ lircService.put(PhiliphsRCLE011Button.NAME,
+ PhiliphsRCLE011Button.values());
+ lircService.add(this);
+ lircService.start();
+ WiimoteService wiimoteService = new WiimoteService();
+ try {
+ Wiimote wiimote = wiimoteService.getDevice(this);
+ wiimote.activateIRTRacking();
+ Thread.sleep(10000000);
+ } catch (DeviceNotFoundException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void add(LircButton lircButton) {
+ if (lircButton instanceof PhiliphsRCLE011Button) {
+ boolean t = false, r = false, b = false, l = false;
+ switch ((PhiliphsRCLE011Button) lircButton) {
+ case RED:
+ tl = raw;
+ l = bl != null;
+ t = tr != null;
+ break;
+ case GREEN:
+ tr = raw;
+ t = tl != null;
+ r = br != null;
+ break;
+ case YELLOW:
+ br = raw;
+ r = tr != null;
+ b = bl != null;
+ break;
+ case BLUE:
+ bl = raw;
+ b = br != null;
+ l = tl != null;
+ break;
+ }
+ if (t) {
+ this.t = new Line(tl, tr);
+ }
+ if (r) {
+ this.r = new Line(tr, br);
+ }
+ if (b) {
+ this.b = new Line(br, bl);
+ }
+ if (l) {
+ this.l = new Line(bl, tl);
+ }
+ }
+ }
+
+ public void onIrEvent(IREvent event) {
+ // log.debug(event);
+ raw = new Point(event.getAx(), event.getAy());
+ log.debug(String.format("%d %d", raw.x, raw.y));
+ if (t != null && r != null && b != null && l != null) {
+ double w = r.getX(raw.y) - l.getX(raw.y);
+ double h = t.getY(raw.x) - b.getY(raw.x);
+ point = new Point((w - l.getX(raw.y)) / w, (h - b.getY(raw.x)) / h);
+ graph.draw(point);
+ }
+ }
+
+ public static void main(String[] args) {
+ new Ir();
+ }
+
+ protected class Point {
+ public double x, y;
+
+ public Point(double x, double y) {
+ this.x = x;
+ this.y = y;
+ }
+ }
+
+ protected class Line {
+ protected double a, b;
+
+ public Line(Point p1, Point p2) {
+ a = (p2.y - p1.y) / (p2.x - p1.x);
+ b = p2.y - a * p2.x;
+ }
+
+ public double getY(double x) {
+ return a * x + b;
+ }
+
+ public double getX(double y) {
+ return (y - b) / a;
+ }
+ }
+
+ public class Graph extends JPanel {
+ protected static final long serialVersionUID = 1L;
+
+ final int PAD = 20;
+ final double X = 1;
+ final double Y = 2;
+ JFrame f;
+ Graphics2D g2;
+ double w, h;
+
+ public Graph() {
+ f = new JFrame();
+ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ f.add(this);
+ f.setSize(400, 400);
+ f.setLocation(200, 200);
+ f.setVisible(true);
+ g2 = (Graphics2D) f.getGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ w = getWidth();
+ h = getHeight();
+ axes();
+ }
+
+ protected void draw(Point point) {
+ g2.clearRect(0, 0, 400, 400);
+ axes();
+ double xInc = (double) (w - 2 * PAD) / X;
+ double scale = (double) (h - 2 * PAD) / Y;
+ // Mark data points.
+ g2.setPaint(Color.blue);
+ double x = PAD + point.x * xInc;
+ double y = h - PAD - scale * point.y;
+ g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4));
+ }
+
+ protected void axes() {
+ // Draw ordinate.
+ g2.draw(new Line2D.Double(PAD, PAD, PAD, h - PAD));
+ // Draw abcissa.
+ g2.draw(new Line2D.Double(PAD, h - PAD, w - PAD, h - PAD));
+ }
+ }
+}
diff --git a/java/src/mimis/util/Sound.java b/java/src/mimis/util/Sound.java
index d3110bc..4f07002 100644
--- a/java/src/mimis/util/Sound.java
+++ b/java/src/mimis/util/Sound.java
@@ -37,8 +37,8 @@ public class Sound {
public static void main(String[] args) {
/*File file = new File("sound.wav");
try {
- AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file);
- AudioFormat au = audioInputStream.getFormat();
+ AudioInputStream inputStream = AudioSystem.getAudioInputStream(file);
+ AudioFormat au = inputStream.getFormat();
System.out.println(au.getSampleRate());// Hz
System.out.println(au.getSampleSizeInBits());// bits
} catch (Exception e) {
@@ -59,7 +59,7 @@ public class Sound {
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(file);
AudioFormat audioFormat = audioInputStream.getFormat();
- // BufferedSound bufferedSound = bufferSound(audioInputStream);
+ // BufferedSound bufferedSound = bufferSound(inputStream);
System.out.println(audioInputStream.getFormat().getSampleRate());
System.out.println(audioInputStream.getFormat().getFrameRate());
diff --git a/java/src/mimis/value/Command.java b/java/src/mimis/value/Command.java
index f5ba3cf..1901135 100644
--- a/java/src/mimis/value/Command.java
+++ b/java/src/mimis/value/Command.java
@@ -65,4 +65,20 @@ public enum Command {
public int getCode() {
return code;
}
+
+ public enum System {
+ MOVE (0xf010),
+ MAXIMIZE (0xf030),
+ MINIMIZE (0xf020);
+
+ protected int code;
+
+ private System(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+ }
}
diff --git a/java/src/mimis/value/Windows.java b/java/src/mimis/value/Windows.java
index 491c041..32c0d9c 100644
--- a/java/src/mimis/value/Windows.java
+++ b/java/src/mimis/value/Windows.java
@@ -3,6 +3,7 @@ package mimis.value;
public enum Windows {
WM_CLOSE (0x0010),
WM_COMMAND (0x0111),
+ WM_SYSCOMMAND (0x0112),
WM_APPCOMMAND (0x0319),
WM_USER (0x0400),
MAPVK_VK_TO_VSC (0);
diff --git a/java/src/mimis/worker/Listener.java b/java/src/mimis/worker/Listener.java
new file mode 100644
index 0000000..9e17294
--- /dev/null
+++ b/java/src/mimis/worker/Listener.java
@@ -0,0 +1,38 @@
+package mimis.worker;
+
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import mimis.Worker;
+
+public abstract class Listener extends Worker {
+ protected Queue queue;
+
+ public Listener() {
+ queue = new ConcurrentLinkedQueue();
+ }
+
+ public void add(E element) {
+ queue.add(element);
+ synchronized (this) {
+ notifyAll();
+ }
+ }
+
+ public final void work() {
+ while (!queue.isEmpty()) {
+ input(queue.poll());
+ }
+ if (!deactivate) {
+ synchronized (this) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ log.info(e);
+ }
+ }
+ }
+ }
+
+ public abstract void input(E element);
+}
\ No newline at end of file
diff --git a/java/src/wiiusej/test/ClassicControllerGuiTest.java b/java/src/wiiusej/test/ClassicControllerGuiTest.java
deleted file mode 100644
index 4e55b90..0000000
--- a/java/src/wiiusej/test/ClassicControllerGuiTest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- * 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;
-import wiiusej.utils.ClassicControllerButtonsEventPanel;
-import wiiusej.wiiusejevents.physicalevents.ClassicControllerEvent;
-import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * This frame is used to display events from a classic controller.
- *
- * @author guiguito
- */
-public class ClassicControllerGuiTest extends javax.swing.JFrame implements WiimoteListener {
-
- private Wiimote wiimote;
- private static int MAX_SHOULDER = 100;
-
- /** Creates new form ClassicControllerGuiTest */
- public ClassicControllerGuiTest(Wiimote wiimote) {
- initComponents();
- this.wiimote = wiimote;
- registerListeners();
- leftShoulderBar.setMaximum(MAX_SHOULDER);
- rightShoulderBar.setMaximum(MAX_SHOULDER);
- }
-
- private void registerListeners() {
- wiimote.addWiiMoteEventListeners(this);
- wiimote.addWiiMoteEventListeners((ClassicControllerButtonsEventPanel) classicControllerPanel);
- }
-
- public void unRegisterListeners() {
- wiimote.removeWiiMoteEventListeners(this);
- wiimote.removeWiiMoteEventListeners((ClassicControllerButtonsEventPanel) classicControllerPanel);
- }
-
- /** 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() {
-
- shouldersPanel = new javax.swing.JPanel();
- leftShoulderBar = new javax.swing.JProgressBar();
- rightShoulderBar = new javax.swing.JProgressBar();
- classicControllerPanel = new wiiusej.utils.ClassicControllerButtonsEventPanel();
-
- setTitle("WiiuseJ Classic Controller Test GUI");
- setResizable(false);
- getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
-
- shouldersPanel.setMaximumSize(new java.awt.Dimension(350, 16));
- shouldersPanel.setMinimumSize(new java.awt.Dimension(350, 16));
- shouldersPanel.setPreferredSize(new java.awt.Dimension(350, 16));
- shouldersPanel.setLayout(new javax.swing.BoxLayout(shouldersPanel, javax.swing.BoxLayout.LINE_AXIS));
- shouldersPanel.add(leftShoulderBar);
- shouldersPanel.add(rightShoulderBar);
-
- getContentPane().add(shouldersPanel);
-
- classicControllerPanel.setMaximumSize(new java.awt.Dimension(350, 182));
- classicControllerPanel.setMinimumSize(new java.awt.Dimension(350, 182));
-
- javax.swing.GroupLayout classicControllerPanelLayout = new javax.swing.GroupLayout(classicControllerPanel);
- classicControllerPanel.setLayout(classicControllerPanelLayout);
- classicControllerPanelLayout.setHorizontalGroup(
- classicControllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 350, Short.MAX_VALUE)
- );
- classicControllerPanelLayout.setVerticalGroup(
- classicControllerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 182, Short.MAX_VALUE)
- );
-
- getContentPane().add(classicControllerPanel);
-
- pack();
- }// //GEN-END:initComponents
- public void onButtonsEvent(WiimoteButtonsEvent arg0) {
- // nothing to do
- }
-
- public void onIrEvent(IREvent arg0) {
- // nothing to do
- }
-
- public void onMotionSensingEvent(MotionSensingEvent arg0) {
- // nothing to do
- }
-
- public void onExpansionEvent(ExpansionEvent arg0) {
- if (arg0 instanceof ClassicControllerEvent) {
- ClassicControllerEvent classicController = (ClassicControllerEvent) arg0;
- float leftShoulder = classicController.getLeftShoulder();
- float rightShoulder = classicController.getRightShoulder();
- leftShoulderBar.setValue(Math.round(leftShoulder * MAX_SHOULDER));
- rightShoulderBar.setValue(Math.round(rightShoulder * MAX_SHOULDER));
- }
- }
-
- public void onStatusEvent(StatusEvent arg0) {
- // nothing to do
- }
-
- public void onDisconnectionEvent(DisconnectionEvent arg0) {
- // nothing to do
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
- // nothing to do
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
- // nothing to do
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
- // nothing to do
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
- // nothing to do
- }
-
- public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent arg0) {
- // nothing to do
- }
-
- public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {
- // nothing to do
- }
-
- public static void main(String[] args) {
- Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
- ClassicControllerGuiTest gui = null;
- if (wiimotes.length > 0) {
- gui = new ClassicControllerGuiTest(wiimotes[0]);
- }
- gui.setDefaultCloseOperation(WiiuseJGuiTest.EXIT_ON_CLOSE);
- gui.setVisible(true);
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JPanel classicControllerPanel;
- private javax.swing.JProgressBar leftShoulderBar;
- private javax.swing.JProgressBar rightShoulderBar;
- private javax.swing.JPanel shouldersPanel;
- // End of variables declaration//GEN-END:variables
-}
diff --git a/java/src/wiiusej/test/CloseGuiTestCleanly.java b/java/src/wiiusej/test/CloseGuiTestCleanly.java
deleted file mode 100644
index 584f2d9..0000000
--- a/java/src/wiiusej/test/CloseGuiTestCleanly.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * 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;
-
-/**
- * This class is used to close wiiusej cleanly.
- *
- * @author guiguito
- */
-public class CloseGuiTestCleanly implements WindowListener {
-
- public void windowOpened(WindowEvent e) {
- // nothing
- }
-
- public void windowClosing(WindowEvent e) {
- WiiUseApiManager.definitiveShutdown();
- }
-
- 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/java/src/wiiusej/test/GuitarHero3GuiTest.java b/java/src/wiiusej/test/GuitarHero3GuiTest.java
deleted file mode 100644
index b0f1dd4..0000000
--- a/java/src/wiiusej/test/GuitarHero3GuiTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * GuitarHeroGUITest.java
- *
- * Created on 12 juin 2008, 23:10
- */
-package wiiusej.test;
-
-import wiiusej.Wiimote;
-import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * This frame is used to display events from a Guitar Hero 3.
- * @author guiguito
- */
-public class GuitarHero3GuiTest extends javax.swing.JFrame implements WiimoteListener {
-
- private Wiimote wiimote;
- private static int MAX_WHAMMY_BAR = 100;
-
- /** Creates new form GuitarHeroGUITest */
- public GuitarHero3GuiTest(Wiimote wiimote) {
- initComponents();
- this.wiimote = wiimote;
- whammyProgressBar.setMaximum(MAX_WHAMMY_BAR);
- registerListeners();
- }
-
- private void registerListeners() {
- wiimote.addWiiMoteEventListeners(this);
- //register panel buttons
- wiimote.addWiiMoteEventListeners(guitarHero3ButtonsEventPanel);
- //register joystick panel
- wiimote.addWiiMoteEventListeners(guitarHero3JoystickPanel);
- }
-
- public void unRegisterListeners() {
- wiimote.removeWiiMoteEventListeners(this);
- wiimote.removeWiiMoteEventListeners(guitarHero3ButtonsEventPanel);
- wiimote.removeWiiMoteEventListeners(guitarHero3JoystickPanel);
- }
-
- /** 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() {
-
- buttonsEventPanel = new javax.swing.JPanel();
- guitarHero3ButtonsEventPanel = new wiiusej.utils.GuitarHero3ButtonsEventPanel();
- bottomPanel = new javax.swing.JPanel();
- guitarHero3JoystickPanel = new wiiusej.utils.GuitarHeroJoystickEventPanel();
- whammyProgressBar = new javax.swing.JProgressBar();
-
- setTitle("WiiuseJ Guitar Hero 3 Test GUI");
- getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS));
-
- buttonsEventPanel.setBackground(new java.awt.Color(0, 0, 0));
-
- javax.swing.GroupLayout buttonsEventPanelLayout = new javax.swing.GroupLayout(buttonsEventPanel);
- buttonsEventPanel.setLayout(buttonsEventPanelLayout);
- buttonsEventPanelLayout.setHorizontalGroup(
- buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 526, Short.MAX_VALUE)
- .addGroup(buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(buttonsEventPanelLayout.createSequentialGroup()
- .addGap(0, 0, Short.MAX_VALUE)
- .addComponent(guitarHero3ButtonsEventPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 0, Short.MAX_VALUE)))
- );
- buttonsEventPanelLayout.setVerticalGroup(
- buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 96, Short.MAX_VALUE)
- .addGroup(buttonsEventPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(buttonsEventPanelLayout.createSequentialGroup()
- .addGap(0, 0, Short.MAX_VALUE)
- .addComponent(guitarHero3ButtonsEventPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 0, Short.MAX_VALUE)))
- );
-
- getContentPane().add(buttonsEventPanel);
-
- bottomPanel.setBackground(new java.awt.Color(0, 0, 0));
- bottomPanel.setLayout(new javax.swing.BoxLayout(bottomPanel, javax.swing.BoxLayout.X_AXIS));
- bottomPanel.add(guitarHero3JoystickPanel);
-
- whammyProgressBar.setBackground(new java.awt.Color(255, 255, 255));
- whammyProgressBar.setForeground(new java.awt.Color(255, 0, 255));
- bottomPanel.add(whammyProgressBar);
-
- getContentPane().add(bottomPanel);
-
- pack();
- }// //GEN-END:initComponents
- public void onButtonsEvent(WiimoteButtonsEvent arg0) {
- // nothing to do
- }
-
- public void onIrEvent(IREvent arg0) {
- // nothing to do
- }
-
- public void onMotionSensingEvent(MotionSensingEvent arg0) {
- // nothing to do
- }
-
- public void onExpansionEvent(ExpansionEvent arg0) {
- if (arg0 instanceof GuitarHeroEvent) {
- GuitarHeroEvent guitar = (GuitarHeroEvent) arg0;
- //move progress bar for whammy bar
- whammyProgressBar.setValue(Math.round(MAX_WHAMMY_BAR*guitar.getWhammyBar()));
- }
-
- }
-
- public void onStatusEvent(StatusEvent arg0) {
- // nothing to do
- }
-
- public void onDisconnectionEvent(DisconnectionEvent arg0) {
- // nothing to do
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
- // nothing to do
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
- // nothing to do
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
- // nothing to do
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
- // nothing to do
- }
-
- public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent arg0) {
- // nothing to do
- }
-
- public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {
- // nothing to do
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JPanel bottomPanel;
- private javax.swing.JPanel buttonsEventPanel;
- private wiiusej.utils.GuitarHero3ButtonsEventPanel guitarHero3ButtonsEventPanel;
- private wiiusej.utils.GuitarHeroJoystickEventPanel guitarHero3JoystickPanel;
- private javax.swing.JProgressBar whammyProgressBar;
- // End of variables declaration//GEN-END:variables
-}
diff --git a/java/src/wiiusej/test/Main.java b/java/src/wiiusej/test/Main.java
deleted file mode 100644
index 67ef279..0000000
--- a/java/src/wiiusej/test/Main.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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);
- WiiuseJGuiTest gui = null;
- if (wiimotes.length > 0) {
- gui = new WiiuseJGuiTest(wiimotes[0]);
- } else {
- gui = new WiiuseJGuiTest();
- }
- gui.setDefaultCloseOperation(WiiuseJGuiTest.EXIT_ON_CLOSE);
- gui.setVisible(true);
- }
-
-}
diff --git a/java/src/wiiusej/test/NunchukGuiTest.java b/java/src/wiiusej/test/NunchukGuiTest.java
deleted file mode 100644
index d7f284f..0000000
--- a/java/src/wiiusej/test/NunchukGuiTest.java
+++ /dev/null
@@ -1,450 +0,0 @@
-/**
- * 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.Wiimote;
-import wiiusej.utils.AccelerationExpansionEventPanel;
-import wiiusej.utils.AccelerationPanel;
-import wiiusej.utils.GForceExpansionEventPanel;
-import wiiusej.utils.GForcePanel;
-import wiiusej.utils.NunchukJoystickEventPanel;
-import wiiusej.utils.OrientationExpansionEventPanel;
-import wiiusej.utils.OrientationPanel;
-import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.NunchukButtonsEvent;
-import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * This frame is used to display events from a nunchuk.
- *
- * @author guiguito
- */
-public class NunchukGuiTest extends javax.swing.JFrame implements
- WiimoteListener {
-
- private Wiimote wiimote;
- private boolean isThresholdsRequested = true;
-
- /** Creates new form NunchukGuiTest */
- public NunchukGuiTest(Wiimote wiimote) {
- initComponents();
- this.wiimote = wiimote;
- registerListeners();
- }
-
- private void registerListeners() {
- wiimote.addWiiMoteEventListeners(this);
- wiimote.addWiiMoteEventListeners((OrientationPanel) orientationPanel);
- wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel);
- wiimote
- .addWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
- wiimote
- .addWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel);
- }
-
- public void unRegisterListeners() {
- wiimote
- .removeWiiMoteEventListeners((OrientationPanel) orientationPanel);
- wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel);
- wiimote
- .removeWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
- wiimote
- .removeWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel);
- wiimote.removeWiiMoteEventListeners(this);
- }
-
- public void requestThresholdsUpdate() {
- isThresholdsRequested = true;
- }
-
- /**
- * 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() {
-
- topPanels = new javax.swing.JPanel();
- joystickEventsPanel = new NunchukJoystickEventPanel();
- motionSensingEventsPanel = new javax.swing.JPanel();
- motionSensingEventsTabbedPanels = new javax.swing.JTabbedPane();
- rawAccelerationPanel = new AccelerationExpansionEventPanel();
- orientationPanel = new OrientationExpansionEventPanel();
- gForcePanel = new GForceExpansionEventPanel();
- setNunchukValuesPanel = new javax.swing.JPanel();
- nunchukButtonsEventPanel = new javax.swing.JPanel();
- cButton = new javax.swing.JButton();
- zButton = new javax.swing.JButton();
- nunchukOrientationPanel = new javax.swing.JPanel();
- nunchukOrientationTextField = new javax.swing.JTextField();
- nunchukOrientationButton = new javax.swing.JButton();
- nunchukAccelerationPanel = new javax.swing.JPanel();
- nunchukAccelerationTextField = new javax.swing.JTextField();
- nunchukAccelerationButton = new javax.swing.JButton();
- messagePanel = new javax.swing.JPanel();
- messageText = new javax.swing.JLabel();
-
- setTitle("WiiuseJ Nunchuk Test GUI");
- setMinimumSize(new java.awt.Dimension(400, 400));
- getContentPane().setLayout(
- new javax.swing.BoxLayout(getContentPane(),
- javax.swing.BoxLayout.Y_AXIS));
-
- topPanels.setMinimumSize(new java.awt.Dimension(400, 200));
- topPanels.setPreferredSize(new java.awt.Dimension(400, 200));
- topPanels.setLayout(new javax.swing.BoxLayout(topPanels,
- javax.swing.BoxLayout.LINE_AXIS));
-
- joystickEventsPanel.setBackground(new java.awt.Color(0, 0, 0));
- joystickEventsPanel.setBorder(javax.swing.BorderFactory
- .createTitledBorder(new javax.swing.border.LineBorder(
- new java.awt.Color(51, 153, 0), 2, true),
- "Joystick View",
- javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
- javax.swing.border.TitledBorder.DEFAULT_POSITION,
- new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(
- 204, 102, 0)));
- joystickEventsPanel.setToolTipText("JoystickEvent");
- joystickEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200));
-
- javax.swing.GroupLayout joystickEventsPanelLayout = new javax.swing.GroupLayout(
- joystickEventsPanel);
- joystickEventsPanel.setLayout(joystickEventsPanelLayout);
- joystickEventsPanelLayout.setHorizontalGroup(joystickEventsPanelLayout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 601, Short.MAX_VALUE));
- joystickEventsPanelLayout.setVerticalGroup(joystickEventsPanelLayout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 174, Short.MAX_VALUE));
-
- topPanels.add(joystickEventsPanel);
- joystickEventsPanel.getAccessibleContext()
- .setAccessibleName("Joystick");
-
- motionSensingEventsPanel
- .setMinimumSize(new java.awt.Dimension(200, 200));
-
- rawAccelerationPanel.setToolTipText("Nunchuk MotionSensingEvent");
-
- javax.swing.GroupLayout rawAccelerationPanelLayout = new javax.swing.GroupLayout(
- rawAccelerationPanel);
- rawAccelerationPanel.setLayout(rawAccelerationPanelLayout);
- rawAccelerationPanelLayout
- .setHorizontalGroup(rawAccelerationPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 597, Short.MAX_VALUE));
- rawAccelerationPanelLayout.setVerticalGroup(rawAccelerationPanelLayout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 175, Short.MAX_VALUE));
-
- motionSensingEventsTabbedPanels.addTab("RawAcceleration",
- rawAccelerationPanel);
-
- javax.swing.GroupLayout orientationPanelLayout = new javax.swing.GroupLayout(
- orientationPanel);
- orientationPanel.setLayout(orientationPanelLayout);
- orientationPanelLayout.setHorizontalGroup(orientationPanelLayout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 597, Short.MAX_VALUE));
- orientationPanelLayout.setVerticalGroup(orientationPanelLayout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 175, Short.MAX_VALUE));
-
- motionSensingEventsTabbedPanels.addTab("Orientation", orientationPanel);
-
- javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(
- gForcePanel);
- gForcePanel.setLayout(gForcePanelLayout);
- gForcePanelLayout.setHorizontalGroup(gForcePanelLayout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 597, Short.MAX_VALUE));
- gForcePanelLayout.setVerticalGroup(gForcePanelLayout
- .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 175, Short.MAX_VALUE));
-
- motionSensingEventsTabbedPanels.addTab("GForce", gForcePanel);
-
- javax.swing.GroupLayout motionSensingEventsPanelLayout = new javax.swing.GroupLayout(
- motionSensingEventsPanel);
- motionSensingEventsPanel.setLayout(motionSensingEventsPanelLayout);
- motionSensingEventsPanelLayout
- .setHorizontalGroup(motionSensingEventsPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(motionSensingEventsTabbedPanels,
- javax.swing.GroupLayout.DEFAULT_SIZE, 602,
- Short.MAX_VALUE));
- motionSensingEventsPanelLayout
- .setVerticalGroup(motionSensingEventsPanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(motionSensingEventsTabbedPanels,
- javax.swing.GroupLayout.DEFAULT_SIZE, 200,
- Short.MAX_VALUE));
-
- topPanels.add(motionSensingEventsPanel);
-
- getContentPane().add(topPanels);
-
- setNunchukValuesPanel.setMinimumSize(new java.awt.Dimension(400, 200));
- setNunchukValuesPanel
- .setPreferredSize(new java.awt.Dimension(400, 200));
- setNunchukValuesPanel.setLayout(new javax.swing.BoxLayout(
- setNunchukValuesPanel, javax.swing.BoxLayout.Y_AXIS));
-
- nunchukButtonsEventPanel.setToolTipText("Nunchuk ButtonsEvent");
- nunchukButtonsEventPanel
- .setMinimumSize(new java.awt.Dimension(100, 100));
- nunchukButtonsEventPanel.setPreferredSize(new java.awt.Dimension(100,
- 100));
- nunchukButtonsEventPanel.setLayout(new javax.swing.BoxLayout(
- nunchukButtonsEventPanel, javax.swing.BoxLayout.LINE_AXIS));
-
- cButton.setText("C");
- cButton.setMaximumSize(new java.awt.Dimension(50, 50));
- cButton.setMinimumSize(new java.awt.Dimension(50, 50));
- cButton.setPreferredSize(new java.awt.Dimension(50, 50));
- nunchukButtonsEventPanel.add(cButton);
-
- zButton.setText("Z");
- zButton.setMaximumSize(new java.awt.Dimension(50, 50));
- zButton.setMinimumSize(new java.awt.Dimension(50, 50));
- zButton.setPreferredSize(new java.awt.Dimension(50, 50));
- nunchukButtonsEventPanel.add(zButton);
-
- setNunchukValuesPanel.add(nunchukButtonsEventPanel);
-
- nunchukOrientationTextField.setPreferredSize(new java.awt.Dimension(60,
- 20));
- nunchukOrientationPanel.add(nunchukOrientationTextField);
-
- nunchukOrientationButton.setText("Set Orientation Threshold");
- nunchukOrientationButton
- .addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- nunchukOrientationButtonMousePressed(evt);
- }
- });
- nunchukOrientationPanel.add(nunchukOrientationButton);
-
- setNunchukValuesPanel.add(nunchukOrientationPanel);
-
- nunchukAccelerationTextField.setPreferredSize(new java.awt.Dimension(
- 60, 20));
- nunchukAccelerationPanel.add(nunchukAccelerationTextField);
-
- nunchukAccelerationButton.setText("Set Acceleration Threshold");
- nunchukAccelerationButton
- .addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- nunchukAccelerationButtonMousePressed(evt);
- }
- });
- nunchukAccelerationPanel.add(nunchukAccelerationButton);
-
- setNunchukValuesPanel.add(nunchukAccelerationPanel);
-
- messageText.setText("Message:");
-
- javax.swing.GroupLayout messagePanelLayout = new javax.swing.GroupLayout(
- messagePanel);
- messagePanel.setLayout(messagePanelLayout);
- messagePanelLayout
- .setHorizontalGroup(messagePanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 1216, Short.MAX_VALUE)
- .addGroup(
- messagePanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- messagePanelLayout
- .createSequentialGroup()
- .addGap(0, 0,
- Short.MAX_VALUE)
- .addComponent(
- messageText)
- .addGap(0, 0,
- Short.MAX_VALUE))));
- messagePanelLayout
- .setVerticalGroup(messagePanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGap(0, 34, Short.MAX_VALUE)
- .addGroup(
- messagePanelLayout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- messagePanelLayout
- .createSequentialGroup()
- .addGap(0, 0,
- Short.MAX_VALUE)
- .addComponent(
- messageText)
- .addGap(0, 0,
- Short.MAX_VALUE))));
-
- setNunchukValuesPanel.add(messagePanel);
-
- getContentPane().add(setNunchukValuesPanel);
-
- pack();
- }// //GEN-END:initComponents
-
- private void nunchukOrientationButtonMousePressed(
- java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukOrientationButtonMousePressed
- try {
- float nb = Float.parseFloat(nunchukOrientationTextField.getText());
- wiimote.setNunchukOrientationThreshold(nb);
- messageText.setText("Nunchuk orientation threshold set to " + nb);
- } catch (NumberFormatException e) {
- messageText
- .setText("Number is not an integer, nunchuk orientation threshold not set !");
- }
- }// GEN-LAST:event_nunchukOrientationButtonMousePressed
-
- private void nunchukAccelerationButtonMousePressed(
- java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukAccelerationButtonMousePressed
- try {
- int nb = Integer.parseInt(nunchukAccelerationTextField.getText());
- wiimote.setNunchukAccelerationThreshold(nb);
- messageText.setText("Nunchuk acceleration threshold set to " + nb);
- } catch (NumberFormatException e) {
- messageText
- .setText("Number is not an integer, nunchuk acceleration threshold not set !");
- }
- }// GEN-LAST:event_nunchukAccelerationButtonMousePressed
-
- public void onButtonsEvent(WiimoteButtonsEvent arg0) {
- // nothing to do
- }
-
- public void onIrEvent(IREvent arg0) {
- // nothing to do
- }
-
- public void onMotionSensingEvent(MotionSensingEvent arg0) {
- // nothing to do
- }
-
- public void onExpansionEvent(ExpansionEvent arg0) {
- if (arg0 instanceof NunchukEvent) {
- NunchukEvent nunchuk = (NunchukEvent) arg0;
- NunchukButtonsEvent buttons = nunchuk.getButtonsEvent();
-
- //C button
- if (buttons.isButtonCJustPressed()) {
- cButton.setEnabled(false);
- }else if (buttons.isButtonCJustReleased()) {
- cButton.setEnabled(true);
- }
-
- //Z button
- if(buttons.isButtonZJustPressed()) {
- zButton.setEnabled(false);
- }else if (buttons.isButtonZJustReleased()) {
- zButton.setEnabled(true);
- }
-
-
- if (isThresholdsRequested) {
- MotionSensingEvent evt = nunchuk.getNunchukMotionSensingEvent();
- nunchukAccelerationTextField.setText(evt
- .getAccelerationThreshold()
- + "");
- nunchukOrientationTextField.setText(evt
- .getOrientationThreshold()
- + "");
- isThresholdsRequested = false;
- }
- }
- }
-
- public void onStatusEvent(StatusEvent arg0) {
- // nothing to do
- }
-
- public void onDisconnectionEvent(DisconnectionEvent arg0) {
- // nothing
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
- // nothing
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
- // nothing
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
- // nothing
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerInsertedEvent(
- ClassicControllerInsertedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerRemovedEvent(
- ClassicControllerRemovedEvent arg0) {
- // nothing
- }
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton cButton;
- private javax.swing.JPanel gForcePanel;
- private javax.swing.JPanel joystickEventsPanel;
- private javax.swing.JPanel messagePanel;
- private javax.swing.JLabel messageText;
- private javax.swing.JPanel motionSensingEventsPanel;
- private javax.swing.JTabbedPane motionSensingEventsTabbedPanels;
- private javax.swing.JButton nunchukAccelerationButton;
- private javax.swing.JPanel nunchukAccelerationPanel;
- private javax.swing.JTextField nunchukAccelerationTextField;
- private javax.swing.JPanel nunchukButtonsEventPanel;
- private javax.swing.JButton nunchukOrientationButton;
- private javax.swing.JPanel nunchukOrientationPanel;
- private javax.swing.JTextField nunchukOrientationTextField;
- private javax.swing.JPanel orientationPanel;
- private javax.swing.JPanel rawAccelerationPanel;
- private javax.swing.JPanel setNunchukValuesPanel;
- private javax.swing.JPanel topPanels;
- private javax.swing.JButton zButton;
- // End of variables declaration//GEN-END:variables
-}
diff --git a/java/src/wiiusej/test/Tests.java b/java/src/wiiusej/test/Tests.java
deleted file mode 100644
index fcd4ef0..0000000
--- a/java/src/wiiusej/test/Tests.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/**
- * 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.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * This class used to test WiiuseJ in text mode.
- *
- * @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();
- }
- }
-
- public void onButtonsEvent(WiimoteButtonsEvent 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();
- WiiUseApiManager.definitiveShutdown();
- }
-
- } 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 onExpansionEvent(ExpansionEvent e) {
- 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 !!");
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
- System.out.println(e);
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
- System.out.println(e);
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent e) {
- System.out.println(e);
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent e) {
- System.out.println(e);
- }
-
- public void onClassicControllerInsertedEvent(
- ClassicControllerInsertedEvent e) {
- System.out.println(e);
- }
-
- public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent e) {
- System.out.println(e);
- }
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
- if (wiimotes.length > 0) {
- System.out.println(wiimotes[0]);
- 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/java/src/wiiusej/test/WiiuseJGuiTest.java b/java/src/wiiusej/test/WiiuseJGuiTest.java
deleted file mode 100644
index 54dc777..0000000
--- a/java/src/wiiusej/test/WiiuseJGuiTest.java
+++ /dev/null
@@ -1,1379 +0,0 @@
-/**
- * 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.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.swing.JFrame;
-import wiiusej.WiiUseApiManager;
-import wiiusej.Wiimote;
-import wiiusej.utils.AccelerationPanel;
-import wiiusej.utils.AccelerationWiimoteEventPanel;
-import wiiusej.utils.ButtonsEventPanel;
-import wiiusej.utils.GForcePanel;
-import wiiusej.utils.IRPanel;
-import wiiusej.utils.OrientationPanel;
-import wiiusej.utils.OrientationWiimoteEventPanel;
-import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * 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;
- private JFrame expansionFrame = null;
- private boolean isFirstStatusGot = false;
- private WindowListener buttonSetter = new WindowListener() {
-
- public void windowOpened(WindowEvent e) {
- // nothing
- }
-
- public void windowClosing(WindowEvent e) {
- // nothing
- }
-
- public void windowClosed(WindowEvent e) {
- // nothing
- }
-
- public void windowIconified(WindowEvent e) {
- // nothing
- }
-
- public void windowDeiconified(WindowEvent e) {
- // nothing
- }
-
- public void windowActivated(WindowEvent e) {
- showExpansionWiimoteButton.setEnabled(false);
- if (expansionFrame instanceof NunchukGuiTest){
- showExpansionWiimoteButton.setText("Hide Nunchuk");
- }else if(expansionFrame instanceof GuitarHero3GuiTest){
- showExpansionWiimoteButton.setText("Hide Guitar");
- }else if(expansionFrame instanceof ClassicControllerGuiTest){
- showExpansionWiimoteButton.setText("Hide Classic Controller");
- }
- }
-
- public void windowDeactivated(WindowEvent e) {
- showExpansionWiimoteButton.setEnabled(true);
- if (expansionFrame instanceof NunchukGuiTest){
- showExpansionWiimoteButton.setText("Show Nunchuk");
- }else if(expansionFrame instanceof GuitarHero3GuiTest){
- showExpansionWiimoteButton.setText("Show Guitar");
- }else if(expansionFrame instanceof ClassicControllerGuiTest){
- showExpansionWiimoteButton.setText("Show Classic controller");
- }
- }
- };
-
- /**
- * default constructor
- */
- public WiiuseJGuiTest() {
- initComponents();
- this.addWindowListener(new CloseGuiTestCleanly());
- }
-
- /**
- * Creates new form WiiuseJGuiTest
- */
- public WiiuseJGuiTest(Wiimote wiimote) {
- initComponents();
- this.addWindowListener(new CloseGuiTestCleanly());
- if (wiimote != null) {
- this.wiimote = wiimote;
- registerListeners();
- initWiimote();
- isFirstStatusGot = false;
- getStatusButtonMousePressed(null);
- }
- }
-
- /**
- * Clear all views
- */
- private void clearViews() {
- ((IRPanel) irViewPanel).clearView();
- ((ButtonsEventPanel) buttonsPanel).clearView();
- ((OrientationPanel) motionSensingPanel).clearView();
- ((GForcePanel) gForcePanel).clearView();
- ((AccelerationPanel) accelerationPanel).clearView();
- }
-
- /**
- * Unregister all listeners.
- */
- private void unregisterListeners() {
- wiimote.removeWiiMoteEventListeners((IRPanel) irViewPanel);
- wiimote.removeWiiMoteEventListeners((ButtonsEventPanel) buttonsPanel);
- wiimote
- .removeWiiMoteEventListeners((OrientationPanel) motionSensingPanel);
- wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel);
- wiimote
- .removeWiiMoteEventListeners((AccelerationPanel) accelerationPanel);
- wiimote.removeWiiMoteEventListeners(this);
- }
-
- private void initWiimote() {
- wiimote.deactivateContinuous();
- wiimote.deactivateSmoothing();
- wiimote.setScreenAspectRatio169();
- wiimote.setSensorBarBelowScreen();
- }
-
- /**
- * Register all listeners
- */
- private void registerListeners() {
- wiimote.addWiiMoteEventListeners((IRPanel) irViewPanel);
- wiimote.addWiiMoteEventListeners((ButtonsEventPanel) buttonsPanel);
- wiimote.addWiiMoteEventListeners((OrientationPanel) motionSensingPanel);
- wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel);
- wiimote.addWiiMoteEventListeners((AccelerationPanel) accelerationPanel);
- wiimote.addWiiMoteEventListeners(this);
-
- }
-
- public void onButtonsEvent(WiimoteButtonsEvent 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 onExpansionEvent(ExpansionEvent e) {
- // nothing yet
- }
-
- public void onStatusEvent(StatusEvent arg0) {
- if (!isFirstStatusGot) {
- if (arg0.isNunchukConnected()) {
- showExpansionWiimoteButton.setEnabled(true);
- showExpansionWiimoteButton.setText("Show Nunchuk");
- expansionFrame = new NunchukGuiTest(wiimote);
- expansionFrame
- .setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
- expansionFrame.addWindowListener(buttonSetter);
- isFirstStatusGot = true;
- }else if(arg0.isClassicControllerConnected()){
- showExpansionWiimoteButton.setEnabled(true);
- showExpansionWiimoteButton.setText("Show Classic Controller");
- expansionFrame = new ClassicControllerGuiTest(wiimote);
- expansionFrame
- .setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
- expansionFrame.addWindowListener(buttonSetter);
- isFirstStatusGot = true;
- }
- else if(arg0.isGuitarHeroConnected()){
- showExpansionWiimoteButton.setEnabled(true);
- showExpansionWiimoteButton.setText("Show Guitar Hero 3 Controller");
- expansionFrame = new GuitarHero3GuiTest(wiimote);
- expansionFrame
- .setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
- expansionFrame.addWindowListener(buttonSetter);
- isFirstStatusGot = true;
- }
- }
- messageText.setText("Status received !");
- batteryLevelText.setText(arg0.getBatteryLevel() + " %");
- led1Button.setEnabled(arg0.isLed1Set());
- led2Button.setEnabled(arg0.isLed2Set());
- led3Button.setEnabled(arg0.isLed3Set());
- led4Button.setEnabled(arg0.isLed4Set());
- if (arg0.isNunchukConnected()) {
- ((NunchukGuiTest) expansionFrame).requestThresholdsUpdate();
- }
- // 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 !");
- unregisterListeners();
- clearViews();
- isFirstStatusGot = false;
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
- messageText.setText("Nunchuk connected !");
- expansionText.setText("Expansion connected : Nunchuk.");
- showExpansionWiimoteButton.setEnabled(true);
- showExpansionWiimoteButton.setText("Show nunchuk");
- expansionFrame = new NunchukGuiTest(wiimote);
- expansionFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
- expansionFrame.addWindowListener(buttonSetter);
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
- messageText.setText("Nunchuk disconnected !");
- expansionText.setText("No expansion connected.");
- showExpansionWiimoteButton.setEnabled(false);
- showExpansionWiimoteButton.setText("No expansion");
- if (expansionFrame != null) {
- if (expansionFrame instanceof NunchukGuiTest) {
- ((NunchukGuiTest) expansionFrame).unRegisterListeners();
- }
- expansionFrame.setEnabled(false);
- expansionFrame.dispose();
- expansionFrame = null;
- }
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
- messageText.setText("Guitar Hero 3 connected !");
- expansionText.setText("Expansion connected : Guitar Hero 3.");
- showExpansionWiimoteButton.setEnabled(true);
- showExpansionWiimoteButton.setText("Show Guitar Hero 3");
- expansionFrame = new GuitarHero3GuiTest(wiimote);
- expansionFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
- expansionFrame.addWindowListener(buttonSetter);
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
- messageText.setText("Guitar Hero 3 disconnected !");
- expansionText.setText("No expansion connected.");
- showExpansionWiimoteButton.setEnabled(false);
- showExpansionWiimoteButton.setText("No expansion");
- if (expansionFrame != null) {
- if (expansionFrame instanceof GuitarHero3GuiTest) {
- ((GuitarHero3GuiTest) expansionFrame).unRegisterListeners();
- }
- expansionFrame.setEnabled(false);
- expansionFrame.dispose();
- expansionFrame = null;
- }
- }
-
- public void onClassicControllerInsertedEvent(
- ClassicControllerInsertedEvent arg0) {
- messageText.setText("Classic controller connected !");
- expansionText.setText("Expansion connected : Classic Controller.");
- showExpansionWiimoteButton.setEnabled(true);
- showExpansionWiimoteButton.setText("Show Classic Controller");
- expansionFrame = new ClassicControllerGuiTest(wiimote);
- expansionFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
- expansionFrame.addWindowListener(buttonSetter);
- }
-
- public void onClassicControllerRemovedEvent(
- ClassicControllerRemovedEvent arg0) {
- messageText.setText("Classic controller disconnected !");
- expansionText.setText("No expansion connected.");
- showExpansionWiimoteButton.setEnabled(false);
- showExpansionWiimoteButton.setText("No expansion");
- if (expansionFrame != null) {
- if (expansionFrame instanceof ClassicControllerGuiTest) {
- ((ClassicControllerGuiTest) expansionFrame).unRegisterListeners();
- }
- expansionFrame.setEnabled(false);
- expansionFrame.dispose();
- expansionFrame = null;
- }
- }
-
- /**
- * 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();
- accelerationPanel = new AccelerationWiimoteEventPanel();
- motionSensingPanel = new OrientationWiimoteEventPanel();
- gForcePanel = new wiiusej.utils.GForceWiimoteEventPanel();
- rightPanel = new javax.swing.JPanel();
- fixedWiimotePanel = new javax.swing.JPanel();
- buttonsPanel = new ButtonsEventPanel();
- controlsPanel = new javax.swing.JPanel();
- activateRumbleIRPanel = new javax.swing.JPanel();
- toggleRumbleButton = new javax.swing.JButton();
- toggleIRTrackingButton = new javax.swing.JButton();
- activateMotionSensingPanel = new javax.swing.JPanel();
- toggleMotionSensingTrackingButton = new javax.swing.JButton();
- activateSmoothingContinuousPanel = new javax.swing.JPanel();
- toggleSmoothingButton = new javax.swing.JButton();
- toggleContinuousButton = new javax.swing.JButton();
- setLedsPanel = 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();
- setAlphaSmoothingPanel = new javax.swing.JPanel();
- alphaSmoothingTextField = new javax.swing.JTextField();
- alphaSmoothingButton = new javax.swing.JButton();
- setOrientationThresholdPanel = new javax.swing.JPanel();
- orientationThresholdTextField = new javax.swing.JTextField();
- orientationThresholdButton = new javax.swing.JButton();
- setAccelerationThresholdPanel = new javax.swing.JPanel();
- accelerationThresholdTextField = new javax.swing.JTextField();
- accelerationThresholdButton = new javax.swing.JButton();
- getStatusPanel = new javax.swing.JPanel();
- getStatusButton = new javax.swing.JButton();
- batteryText = new javax.swing.JLabel();
- batteryLevelText = new javax.swing.JLabel();
- setIrSensitivyPanel = new javax.swing.JPanel();
- setIrSensitivySpinner = new javax.swing.JSpinner();
- setIrSensitivyButton = new javax.swing.JButton();
- setTimeoutButton = new javax.swing.JButton();
- setTimeoutPanel = new javax.swing.JPanel();
- normalTimeoutSpinner = new javax.swing.JSpinner();
- normalTimeoutText = new javax.swing.JLabel();
- expansionHandshakeTimeoutSpinner = new javax.swing.JSpinner();
- expansionHandshakeTimeoutText = new javax.swing.JLabel();
- setIRConfPanel = new javax.swing.JPanel();
- toggleSensorBarPositionButton = new javax.swing.JButton();
- toggleScreenAspectRatioButton = new javax.swing.JButton();
- setVirtualResolutionPanel = 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();
- startMouseControlPanel = new javax.swing.JPanel();
- mouseIRControlButton = new javax.swing.JButton();
- exPansionPanel = new javax.swing.JPanel();
- expansionText = new javax.swing.JLabel();
- expansionButtonPanel = new javax.swing.JPanel();
- showExpansionWiimoteButton = new javax.swing.JButton();
- showExpansionWiimoteButton.setEnabled(false);
- messagesPanel = new javax.swing.JPanel();
- reconnectWiimotesButton = new javax.swing.JButton();
- 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)));
- irViewPanel.setToolTipText("IREvent");
-
- 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)
- );
-
- accelerationPanel.setToolTipText("MotionSensingEvent");
-
- 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("Acceleration", accelerationPanel);
-
- 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 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);
- }
- });
- activateRumbleIRPanel.add(toggleRumbleButton);
-
- toggleIRTrackingButton.setText("Activate IR Tracking");
- toggleIRTrackingButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- toggleIRTrackingButtonMousePressed(evt);
- }
- });
- activateRumbleIRPanel.add(toggleIRTrackingButton);
-
- controlsPanel.add(activateRumbleIRPanel);
-
- toggleMotionSensingTrackingButton.setText("Activate motion sensing Tracking");
- toggleMotionSensingTrackingButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- toggleMotionSensingTrackingButtonMousePressed(evt);
- }
- });
- activateMotionSensingPanel.add(toggleMotionSensingTrackingButton);
-
- controlsPanel.add(activateMotionSensingPanel);
-
- toggleSmoothingButton.setText("Activate Smoothing");
- toggleSmoothingButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- toggleSmoothingButtonMousePressed(evt);
- }
- });
- activateSmoothingContinuousPanel.add(toggleSmoothingButton);
-
- toggleContinuousButton.setText("Activate Continuous");
- toggleContinuousButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- toggleContinuousButtonMousePressed(evt);
- }
- });
- activateSmoothingContinuousPanel.add(toggleContinuousButton);
-
- controlsPanel.add(activateSmoothingContinuousPanel);
-
- led1Button.setText("Led1");
- led1Button.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- led1ButtonMousePressed(evt);
- }
- });
- setLedsPanel.add(led1Button);
-
- led2Button.setText("Led2");
- led2Button.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- led2ButtonMousePressed(evt);
- }
- });
- setLedsPanel.add(led2Button);
-
- led3Button.setText("Led3");
- led3Button.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- led3ButtonMousePressed(evt);
- }
- });
- setLedsPanel.add(led3Button);
-
- led4Button.setText("Led4");
- led4Button.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- led4ButtonMousePressed(evt);
- }
- });
- setLedsPanel.add(led4Button);
-
- setLedsButton.setText("Set leds");
- setLedsButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- setLedsButtonMousePressed(evt);
- }
- });
- setLedsPanel.add(setLedsButton);
-
- controlsPanel.add(setLedsPanel);
-
- alphaSmoothingTextField.setMinimumSize(new java.awt.Dimension(100, 20));
- alphaSmoothingTextField.setPreferredSize(new java.awt.Dimension(100, 20));
- setAlphaSmoothingPanel.add(alphaSmoothingTextField);
-
- alphaSmoothingButton.setText("Set alpha smoothing");
- alphaSmoothingButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- alphaSmoothingButtonMousePressed(evt);
- }
- });
- setAlphaSmoothingPanel.add(alphaSmoothingButton);
-
- controlsPanel.add(setAlphaSmoothingPanel);
-
- orientationThresholdTextField.setMinimumSize(new java.awt.Dimension(100, 20));
- orientationThresholdTextField.setPreferredSize(new java.awt.Dimension(100, 20));
- setOrientationThresholdPanel.add(orientationThresholdTextField);
-
- orientationThresholdButton.setText("Set orientation threshold");
- orientationThresholdButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- orientationThresholdButtonMousePressed(evt);
- }
- });
- setOrientationThresholdPanel.add(orientationThresholdButton);
-
- controlsPanel.add(setOrientationThresholdPanel);
-
- accelerationThresholdTextField.setPreferredSize(new java.awt.Dimension(100, 20));
- setAccelerationThresholdPanel.add(accelerationThresholdTextField);
-
- accelerationThresholdButton.setText("Set acceleration threshold");
- accelerationThresholdButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- accelerationThresholdButtonMousePressed(evt);
- }
- });
- setAccelerationThresholdPanel.add(accelerationThresholdButton);
-
- controlsPanel.add(setAccelerationThresholdPanel);
-
- getStatusButton.setText("Get status");
- getStatusButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- getStatusButtonMousePressed(evt);
- }
- });
- getStatusPanel.add(getStatusButton);
-
- batteryText.setFont(new java.awt.Font("Tahoma", 0, 14));
- batteryText.setText("Battery level :");
- getStatusPanel.add(batteryText);
-
- batteryLevelText.setFont(new java.awt.Font("Arial", 0, 14));
- batteryLevelText.setText(" %");
- getStatusPanel.add(batteryLevelText);
-
- controlsPanel.add(getStatusPanel);
-
- setIrSensitivySpinner.setPreferredSize(new java.awt.Dimension(50, 18));
- setIrSensitivySpinner.addChangeListener(new javax.swing.event.ChangeListener() {
- public void stateChanged(javax.swing.event.ChangeEvent evt) {
- setIrSensitivySpinnerStateChanged(evt);
- }
- });
- setIrSensitivyPanel.add(setIrSensitivySpinner);
-
- setIrSensitivyButton.setText("SetIrSensivity");
- setIrSensitivyButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- setIrSensitivyButtonMousePressed(evt);
- }
- });
- setIrSensitivyPanel.add(setIrSensitivyButton);
-
- setTimeoutButton.setText("Set timeouts in ms");
- setTimeoutButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- setTimeoutButtonMousePressed(evt);
- }
- });
- setIrSensitivyPanel.add(setTimeoutButton);
-
- controlsPanel.add(setIrSensitivyPanel);
-
- normalTimeoutSpinner.setPreferredSize(new java.awt.Dimension(40, 18));
- normalTimeoutSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
- public void stateChanged(javax.swing.event.ChangeEvent evt) {
- normalTimeoutSpinnerStateChanged(evt);
- }
- });
- setTimeoutPanel.add(normalTimeoutSpinner);
-
- normalTimeoutText.setText("Normal timeout");
- setTimeoutPanel.add(normalTimeoutText);
-
- expansionHandshakeTimeoutSpinner.setPreferredSize(new java.awt.Dimension(40, 18));
- expansionHandshakeTimeoutSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
- public void stateChanged(javax.swing.event.ChangeEvent evt) {
- expansionHandshakeTimeoutSpinnerStateChanged(evt);
- }
- });
- setTimeoutPanel.add(expansionHandshakeTimeoutSpinner);
-
- expansionHandshakeTimeoutText.setText("Expansion handshake timeout");
- setTimeoutPanel.add(expansionHandshakeTimeoutText);
-
- controlsPanel.add(setTimeoutPanel);
-
- toggleSensorBarPositionButton.setText("Set sensor bar above");
- toggleSensorBarPositionButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- toggleSensorBarPositionButtonMousePressed(evt);
- }
- });
- setIRConfPanel.add(toggleSensorBarPositionButton);
-
- 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);
- }
- });
- setIRConfPanel.add(toggleScreenAspectRatioButton);
-
- controlsPanel.add(setIRConfPanel);
-
- xLabel.setText("X");
- setVirtualResolutionPanel.add(xLabel);
-
- xResolutionTextField.setMinimumSize(new java.awt.Dimension(40, 20));
- xResolutionTextField.setPreferredSize(new java.awt.Dimension(40, 20));
- setVirtualResolutionPanel.add(xResolutionTextField);
-
- yLabel.setText("Y");
- setVirtualResolutionPanel.add(yLabel);
-
- yResolutionTextField.setFocusTraversalPolicyProvider(true);
- yResolutionTextField.setMinimumSize(new java.awt.Dimension(40, 20));
- yResolutionTextField.setPreferredSize(new java.awt.Dimension(40, 20));
- setVirtualResolutionPanel.add(yResolutionTextField);
-
- setVirtualResolutionButton.setText("Set virtual resolution");
- setVirtualResolutionButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- setVirtualResolutionButtonMousePressed(evt);
- }
- });
- setVirtualResolutionPanel.add(setVirtualResolutionButton);
-
- controlsPanel.add(setVirtualResolutionPanel);
-
- mouseIRControlButton.setText("Start infrared mouse control");
- mouseIRControlButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- mouseIRControlButtonMousePressed(evt);
- }
- });
- startMouseControlPanel.add(mouseIRControlButton);
-
- controlsPanel.add(startMouseControlPanel);
-
- expansionText.setText("No expansion connected.");
- exPansionPanel.add(expansionText);
-
- controlsPanel.add(exPansionPanel);
-
- showExpansionWiimoteButton.setText("No expansion connected");
- showExpansionWiimoteButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- showExpansionWiimoteButtonMousePressed(evt);
- }
- });
- expansionButtonPanel.add(showExpansionWiimoteButton);
-
- controlsPanel.add(expansionButtonPanel);
-
- reconnectWiimotesButton.setText("Reconnect wiimote");
- reconnectWiimotesButton.addMouseListener(new java.awt.event.MouseAdapter() {
- public void mousePressed(java.awt.event.MouseEvent evt) {
- reconnectWiimotesButtonMousePressed(evt);
- }
- });
- messagesPanel.add(reconnectWiimotesButton);
-
- 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;
- if (expansionFrame instanceof NunchukGuiTest) {
- ((NunchukGuiTest) expansionFrame).requestThresholdsUpdate();
- }
- }// 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
-
- private void normalTimeoutSpinnerStateChanged(
- javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_normalTimeoutSpinnerStateChanged
- String value = normalTimeoutSpinner.getValue().toString();
- boolean isInt = true;
- int valueInt = 0;
- try {
- valueInt = Integer.parseInt(value);
- } catch (NumberFormatException e) {
- isInt = false;
- messageText.setText("Wrong value for normal timeout.");
- }
- if (isInt) {
- if (valueInt > 1000) {
- normalTimeoutSpinner.setValue("1000");
- } else if (valueInt < 0) {
- normalTimeoutSpinner.setValue("0");
- }
- }
- }// GEN-LAST:event_normalTimeoutSpinnerStateChanged
-
- private void expansionHandshakeTimeoutSpinnerStateChanged(
- javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_expansionHandshakeTimeoutSpinnerStateChanged
- String value = expansionHandshakeTimeoutSpinner.getValue().toString();
- boolean isInt = true;
- int valueInt = 0;
- try {
- valueInt = Integer.parseInt(value);
- } catch (NumberFormatException e) {
- isInt = false;
- messageText.setText("Wrong value for expansion handshake timeout.");
- }
- if (isInt) {
- if (valueInt > 1000) {
- expansionHandshakeTimeoutSpinner.setValue("1000");
- } else if (valueInt < 0) {
- expansionHandshakeTimeoutSpinner.setValue("0");
- }
- }
- }// GEN-LAST:event_expansionHandshakeTimeoutSpinnerStateChanged
-
- private void setIrSensitivySpinnerStateChanged(
- javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_setIrSensitivySpinnerStateChanged
- String value = setIrSensitivySpinner.getValue().toString();
- boolean isInt = true;
- int valueInt = 0;
- try {
- valueInt = Integer.parseInt(value);
- } catch (NumberFormatException e) {
- isInt = false;
- messageText.setText("Wrong value for IR senstivity.");
- }
- if (isInt) {
- if (valueInt > 5) {
- setIrSensitivySpinner.setValue("1000");
- } else if (valueInt < 0) {
- setIrSensitivySpinner.setValue("0");
- }
- }
- }// GEN-LAST:event_setIrSensitivySpinnerStateChanged
-
- private void setIrSensitivyButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_setIrSensitivyButtonMousePressed
- String value = setIrSensitivySpinner.getValue().toString();
- boolean isInt = true;
- int valueInt = 0;
- try {
- valueInt = Integer.parseInt(value);
- } catch (NumberFormatException e) {
- isInt = false;
- messageText
- .setText("Wrong value for IR sensitivity. It must be an int !");
- }
- if (isInt) {
- if (valueInt >= 1 && valueInt <= 5) {
- wiimote.setIrSensitivity(valueInt);
- messageText.setText("IR senstivity set to: " + valueInt + ".");
- } else {
- messageText
- .setText("Wrong value for IR senstivity. It muset be between 1 and 5 !");
- }
- }
- }// GEN-LAST:event_setIrSensitivyButtonMousePressed
-
- private void setTimeoutButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_setTimeoutButtonMousePressed
- // get normal timeout
- String value = normalTimeoutSpinner.getValue().toString();
- boolean isInt = true;
- short valueInt = 0;
- try {
- valueInt = Short.parseShort(value);
- } catch (NumberFormatException e) {
- isInt = false;
- messageText
- .setText("Wrong value for normal timeout. It must be an int !");
- }
- // get expansion handshake timeout
- String value2 = expansionHandshakeTimeoutSpinner.getValue().toString();
- boolean isInt2 = true;
- short valueInt2 = 0;
- try {
- valueInt2 = Short.parseShort(value2);
- } catch (NumberFormatException e) {
- isInt2 = false;
- messageText
- .setText("Wrong value for expansion handshake timeout. It must be an int !");
- }
- if (isInt && isInt2) {
- if (valueInt > 0 && valueInt2 > 0) {
- wiimote.setTimeout(valueInt, valueInt2);
- messageText.setText("Normal timeout set to: " + valueInt
- + " and expansion handshake timeout set to: "
- + valueInt2 + "!");
- } else {
- messageText
- .setText("Wrong value for one of the timeout value. It must be an integer > 0 !");
- }
- }
- }// GEN-LAST:event_setTimeoutButtonMousePressed
-
- private void reconnectWiimotesButtonMousePressed(
- java.awt.event.MouseEvent evt) {// GEN-FIRST:event_reconnectWiimotesButtonMousePressed
- // stop manager
- WiiUseApiManager.shutdown();
-
- // unregister previous wiimote
- if (wiimote != null) {
- onDisconnectionEvent(null);
- }
-
- // Reset Gui
- // remove frame for expansion
- if (expansionFrame != null) {
- if (expansionFrame instanceof NunchukGuiTest) {
- ((NunchukGuiTest) expansionFrame).unRegisterListeners();
- }else if (expansionFrame instanceof ClassicControllerGuiTest) {
- ((ClassicControllerGuiTest) expansionFrame).unRegisterListeners();
- }
- expansionFrame.setEnabled(false);
- expansionFrame.dispose();
- expansionFrame = null;
- }
-
- // setup buttons In first state
- toggleRumbleButton.setText("Activate Rumble");
- toggleRumbleButton.setEnabled(true);
- toggleMotionSensingTrackingButton
- .setText("Activate motion sensing Tracking");
- toggleMotionSensingTrackingButton.setEnabled(true);
- toggleIRTrackingButton.setText("Activate IR Tracking");
- toggleIRTrackingButton.setEnabled(true);
- toggleContinuousButton.setText("Activate Continuous");
- toggleContinuousButton.setEnabled(true);
- toggleScreenAspectRatioButton.setText("Set screen aspect ratio 4/3");
- toggleScreenAspectRatioButton.setEnabled(true);
- toggleSensorBarPositionButton.setText("Set sensor bar above");
- toggleSensorBarPositionButton.setEnabled(true);
- toggleSmoothingButton.setText("Activate Smoothing");
- toggleSmoothingButton.setEnabled(true);
- mouseIRControlButton.setText("Start infrared mouse control");
- mouseIRControlButton.setEnabled(true);
-
- // get wiimote
- Wiimote[] listWiimote = WiiUseApiManager.getWiimotes(1, true);
- if (listWiimote != null && listWiimote.length > 0) {
- wiimote = listWiimote[0];
-
- // registers listeners
- registerListeners();
- initWiimote();
-
- isFirstStatusGot = false;
- getStatusButtonMousePressed(null);
- }
- }// GEN-LAST:event_reconnectWiimotesButtonMousePressed
-
- private void showExpansionWiimoteButtonMousePressed(
- java.awt.event.MouseEvent evt) {// GEN-FIRST:event_showExpansionWiimoteButtonMousePressed
- if (expansionFrame != null) {
- if (showExpansionWiimoteButton.isEnabled()) {// expansion frame
- // not shown
- // show it
- expansionFrame.setEnabled(true);
- expansionFrame.setVisible(true);
- showExpansionWiimoteButton.setEnabled(false);
- if (expansionFrame instanceof NunchukGuiTest){
- showExpansionWiimoteButton.setText("Hide Nunchuk");
- messageText.setText("Nunchuk displayed !");
- }else if(expansionFrame instanceof GuitarHero3GuiTest){
- showExpansionWiimoteButton.setText("Hide Guitar");
- messageText.setText("Guitar displayed !");
- }else if(expansionFrame instanceof ClassicControllerGuiTest){
- showExpansionWiimoteButton.setText("Hide Classic controller");
- messageText.setText("Classic controller displayed !");
- }
- } else {// already being shown
- expansionFrame.setEnabled(false);
- expansionFrame.setVisible(false);
- showExpansionWiimoteButton.setEnabled(true);
- if (expansionFrame instanceof NunchukGuiTest){
- showExpansionWiimoteButton.setText("Show Nunchuk");
- messageText.setText("Nunchuk hidden !");
- }else if(expansionFrame instanceof GuitarHero3GuiTest){
- showExpansionWiimoteButton.setText("Show Guitar");
- messageText.setText("Guitar hidden !");
- }else if(expansionFrame instanceof ClassicControllerGuiTest){
- showExpansionWiimoteButton.setText("Show Classic controller");
- messageText.setText("Classic controller hidden !");
- }
- }
- }
- }// GEN-LAST:event_showExpansionWiimoteButtonMousePressed
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JPanel accelerationPanel;
- private javax.swing.JButton accelerationThresholdButton;
- private javax.swing.JTextField accelerationThresholdTextField;
- private javax.swing.JPanel activateMotionSensingPanel;
- private javax.swing.JPanel activateRumbleIRPanel;
- private javax.swing.JPanel activateSmoothingContinuousPanel;
- private javax.swing.JButton alphaSmoothingButton;
- private javax.swing.JTextField alphaSmoothingTextField;
- private javax.swing.JLabel batteryLevelText;
- private javax.swing.JLabel batteryText;
- private javax.swing.JPanel buttonsPanel;
- private javax.swing.JPanel controlsPanel;
- private javax.swing.JPanel exPansionPanel;
- private javax.swing.JPanel expansionButtonPanel;
- private javax.swing.JSpinner expansionHandshakeTimeoutSpinner;
- private javax.swing.JLabel expansionHandshakeTimeoutText;
- private javax.swing.JLabel expansionText;
- private javax.swing.JPanel fixedWiimotePanel;
- private javax.swing.JPanel gForcePanel;
- private javax.swing.JButton getStatusButton;
- private javax.swing.JPanel getStatusPanel;
- 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 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.JSpinner normalTimeoutSpinner;
- private javax.swing.JLabel normalTimeoutText;
- private javax.swing.JButton orientationThresholdButton;
- private javax.swing.JTextField orientationThresholdTextField;
- private javax.swing.JButton reconnectWiimotesButton;
- private javax.swing.JPanel rightPanel;
- private javax.swing.JPanel setAccelerationThresholdPanel;
- private javax.swing.JPanel setAlphaSmoothingPanel;
- private javax.swing.JPanel setIRConfPanel;
- private javax.swing.JButton setIrSensitivyButton;
- private javax.swing.JPanel setIrSensitivyPanel;
- private javax.swing.JSpinner setIrSensitivySpinner;
- private javax.swing.JButton setLedsButton;
- private javax.swing.JPanel setLedsPanel;
- private javax.swing.JPanel setOrientationThresholdPanel;
- private javax.swing.JButton setTimeoutButton;
- private javax.swing.JPanel setTimeoutPanel;
- private javax.swing.JButton setVirtualResolutionButton;
- private javax.swing.JPanel setVirtualResolutionPanel;
- private javax.swing.JButton showExpansionWiimoteButton;
- private javax.swing.JPanel startMouseControlPanel;
- 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/java/src/wiiusej/utils/AccelerationExpansionEventPanel.java b/java/src/wiiusej/utils/AccelerationExpansionEventPanel.java
deleted file mode 100644
index cb3021f..0000000
--- a/java/src/wiiusej/utils/AccelerationExpansionEventPanel.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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 wiiusej.values.RawAcceleration;
-import wiiusej.wiiusejevents.GenericEvent;
-import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
-
-/**
- * Panel to display Acceleration in a MotionSensingEvent from an expansion.
- *
- * @author guiguito
- */
-public class AccelerationExpansionEventPanel extends AccelerationPanel {
-
- @Override
- public RawAcceleration getRawAccelerationValue(GenericEvent e) {
- if (e instanceof NunchukEvent) {
- return ((NunchukEvent) e).getNunchukMotionSensingEvent()
- .getRawAcceleration();
- }
- return null;
- }
-
-}
diff --git a/java/src/wiiusej/utils/AccelerationPanel.java b/java/src/wiiusej/utils/AccelerationPanel.java
deleted file mode 100644
index 15f1551..0000000
--- a/java/src/wiiusej/utils/AccelerationPanel.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/**
- * 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.wiiusejevents.GenericEvent;
-import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * This panel is used to watch raw acceleration values from a
- * MotionSensingEvent.
- *
- * @author guiguito
- */
-public abstract 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();
- }
-
- /**
- * Constructor used to choose the colors used by the AccelerationPanel.
- *
- * @param bgColor
- * background color.
- * @param xColor
- * x color.
- * @param yColor
- * y color.
- * @param zColor
- * z color.
- * @param lColor
- * line color.
- */
- public AccelerationPanel(Color bgColor, Color xColor, Color yColor,
- Color zColor, Color lColor) {
- backgroundColor = bgColor;
- this.xColor = xColor;
- this.yColor = yColor;
- this.zColor = zColor;
- 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
- 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(WiimoteButtonsEvent arg0) {
- // nothing
- }
-
- public void onIrEvent(IREvent arg0) {
- // nothing
- }
-
- public void onMotionSensingEvent(MotionSensingEvent arg0) {
- draw(arg0);
- }
-
- public void onExpansionEvent(ExpansionEvent arg0) {
- draw(arg0);
- }
-
- public void onStatusEvent(StatusEvent arg0) {
- // nothing
- }
-
- public void onDisconnectionEvent(DisconnectionEvent arg0) {
- // Clear points.
- values.clear();
- repaint();
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
- // nothing
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
- // nothing
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
- // nothing
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerInsertedEvent(
- ClassicControllerInsertedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerRemovedEvent(
- ClassicControllerRemovedEvent arg0) {
- // nothing
- }
-
- private void draw(GenericEvent arg0) {
- if (values.size() >= getWidth()) {
- // if there are as many values as pixels in the width
- // clear points
- values.clear();
- }
- RawAcceleration rawAcceleration = getRawAccelerationValue(arg0);
- if (rawAcceleration != null)
- values.add(rawAcceleration);
- repaint();
- }
-
- public abstract RawAcceleration getRawAccelerationValue(GenericEvent e);
-
- public Color getBackgroundColor() {
- return backgroundColor;
- }
-
- public Color getLineColor() {
- return lineColor;
- }
-
- public Color getXColor() {
- return xColor;
- }
-
- public Color getYColor() {
- return yColor;
- }
-
- public Color getZColor() {
- return zColor;
- }
-
- public void setBackgroundColor(Color backgroundColor) {
- this.backgroundColor = backgroundColor;
- }
-
- public void setLineColor(Color lineColor) {
- this.lineColor = lineColor;
- }
-
- public void setXColor(Color xColor) {
- this.xColor = xColor;
- }
-
- public void setYColor(Color yColor) {
- this.yColor = yColor;
- }
-
- public void setZColor(Color zColor) {
- this.zColor = zColor;
- }
-
- public void clearView() {
- 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/java/src/wiiusej/utils/AccelerationWiimoteEventPanel.java b/java/src/wiiusej/utils/AccelerationWiimoteEventPanel.java
deleted file mode 100644
index 4e716de..0000000
--- a/java/src/wiiusej/utils/AccelerationWiimoteEventPanel.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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 wiiusej.values.RawAcceleration;
-import wiiusej.wiiusejevents.GenericEvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-
-/**
- * Panel to display Acceleration in a MotionSensingEvent from a wiimote.
- * @author guiguito
- */
-public class AccelerationWiimoteEventPanel extends AccelerationPanel {
-
- @Override
- public RawAcceleration getRawAccelerationValue(GenericEvent e) {
- if (e instanceof MotionSensingEvent) {
- return ((MotionSensingEvent) e).getRawAcceleration();
- }
- return null;
- }
-
-}
diff --git a/java/src/wiiusej/utils/ButtonsEventPanel.java b/java/src/wiiusej/utils/ButtonsEventPanel.java
deleted file mode 100644
index 97f9b19..0000000
--- a/java/src/wiiusej/utils/ButtonsEventPanel.java
+++ /dev/null
@@ -1,382 +0,0 @@
-/**
- * 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.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * This panel is used to see what buttons are pressed on the wiimote. 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 WiimoteButtonsEvent buttons;
- private Color pressedColor = Color.RED;
- private Color heldColor = Color.ORANGE;
- private Color releasedColor = Color.YELLOW;
- private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 13, 13);
-
- /**
- * 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);
- 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");
- 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(WiimoteButtonsEvent 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 onExpansionEvent(ExpansionEvent e) {
- // nothing
- }
-
- public void onStatusEvent(StatusEvent arg0) {
- // nothing
- }
-
- public void onDisconnectionEvent(DisconnectionEvent arg0) {
- clearView();
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
- // nothing
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
- // nothing
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
- // nothing
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerInsertedEvent(
- ClassicControllerInsertedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerRemovedEvent(
- ClassicControllerRemovedEvent arg0) {
- // nothing
- }
-
- public Color getHeldColor() {
- return heldColor;
- }
-
- public Color getPressedColor() {
- return pressedColor;
- }
-
- public Color getReleasedColor() {
- return releasedColor;
- }
-
- public Shape getShape() {
- return shape;
- }
-
- public void setHeldColor(Color heldColor) {
- this.heldColor = heldColor;
- }
-
- public void setPressedColor(Color pressedColor) {
- this.pressedColor = pressedColor;
- }
-
- public void setReleasedColor(Color releasedColor) {
- this.releasedColor = releasedColor;
- }
-
- public void setShape(Shape shape) {
- this.shape = shape;
- }
-
- public void clearView() {
- 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/java/src/wiiusej/utils/ClassicControllerButtonsEventPanel.java b/java/src/wiiusej/utils/ClassicControllerButtonsEventPanel.java
deleted file mode 100644
index 9bec5a9..0000000
--- a/java/src/wiiusej/utils/ClassicControllerButtonsEventPanel.java
+++ /dev/null
@@ -1,500 +0,0 @@
-/**
- * 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.wiiusejevents.physicalevents.ClassicControllerButtonsEvent;
-import wiiusej.wiiusejevents.physicalevents.ClassicControllerEvent;
-import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.JoystickEvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * This panel is used to display what happens on the classic controller.
- *
- * @author guiguito
- */
-public class ClassicControllerButtonsEventPanel extends javax.swing.JPanel implements WiimoteListener {
-
- private Image mImage;// image for double buffering
- private Image wiimoteImage;// image for double buffering
- private ClassicControllerEvent event;
- private Color pressedColor = Color.RED;
- private Color heldColor = Color.ORANGE;
- private Color releasedColor = Color.YELLOW;
- private Color joystickColor = Color.PINK;
- private Color shoulderColor = Color.BLUE;
- private Shape shapeJoystick = new java.awt.geom.Ellipse2D.Double(0, 0, 15, 15);
- private Shape shapeButton = new java.awt.geom.Ellipse2D.Double(0, 0, 20, 20);
- private static int xAmplitude = 20;
- private static int yAmplitude = 20;
-
- /**
- * Default constructor. Red : button just pressed. Orange : button held.
- * Yellow : button just released.
- */
- public ClassicControllerButtonsEventPanel() {
- Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
- java.net.URL url = ButtonsEventPanel.class.getResource("/img/classiccontroller.png");
- wiimoteImage = toolkit.createImage(url);
- 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 jsColor
- * color of the joysticks.
- * @param shouldColor
- * color of the shoulders.
- * @param js
- * shape drawn on the joysticks.
- * @param sh
- * shape drawn on the buttons.
- */
- public ClassicControllerButtonsEventPanel(Color pressColor, Color hColor, Color relColor,
- Color jsColor, Color shouldColor, Shape js, Shape sh) {
- pressedColor = pressColor;
- heldColor = hColor;
- releasedColor = relColor;
- shapeButton = sh;
- shapeJoystick = js;
- joystickColor = jsColor;
- shoulderColor = shouldColor;
- Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();
- wiimoteImage = toolkit.createImage("img\\wiimote.png");
- initComponents();
- }
-
- /** 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
- @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 classic controller
- g2.drawImage(wiimoteImage, 0, 0, this);
- g2.setTransform(new AffineTransform());
-
- if (event != null) {
- // draw buttons pushed
- ClassicControllerButtonsEvent buttons = event.getButtonsEvent();
-
- /* button A */
- if (buttons.isButtonAJustPressed()) {
- drawFunction(g2, pressedColor, 304, 76, shapeButton);
- }
- if (buttons.isButtonAHeld()) {
- drawFunction(g2, heldColor, 304, 76, shapeButton);
- }
- if (buttons.isButtonAJustReleased()) {
- drawFunction(g2, releasedColor, 304, 76, shapeButton);
- }
-
- /* button B */
- if (buttons.isButtonBJustPressed()) {
- drawFunction(g2, pressedColor, 269, 98, shapeButton);
- }
- if (buttons.isButtonBHeld()) {
- drawFunction(g2, heldColor, 269, 98, shapeButton);
- }
- if (buttons.isButtonBJustReleased()) {
- drawFunction(g2, releasedColor, 269, 98, shapeButton);
- }
-
- /* button Down */
- if (buttons.isButtonDownJustPressed()) {
- drawFunction(g2, pressedColor, 60, 97, shapeButton);
- }
- if (buttons.isButtonDownHeld()) {
- drawFunction(g2, heldColor, 60, 97, shapeButton);
- }
- if (buttons.isButtonDownJustReleased()) {
- drawFunction(g2, releasedColor, 60, 97, shapeButton);
- }
-
- /* button FullLeft */
- if (buttons.isButtonFullLeftJustPressed()) {
- drawFunction(g2, pressedColor, 55, 4, shapeButton);
- }
- if (buttons.isButtonFullLeftHeld()) {
- drawFunction(g2, heldColor, 55, 4, shapeButton);
- }
- if (buttons.isButtonFullLeftJustReleased()) {
- drawFunction(g2, releasedColor, 55, 4, shapeButton);
- }
-
- /* button FullRight */
- if (buttons.isButtonFullRightJustPressed()) {
- drawFunction(g2, pressedColor, 276, 4, shapeButton);
- }
- if (buttons.isButtonFullRightHeld()) {
- drawFunction(g2, heldColor, 276, 4, shapeButton);
- }
- if (buttons.isButtonFullRightJustReleased()) {
- drawFunction(g2, releasedColor, 276, 4, shapeButton);
- }
-
- /* button Home */
- if (buttons.isButtonHomeJustPressed()) {
- drawFunction(g2, pressedColor, 166, 76, shapeButton);
- }
- if (buttons.isButtonHomeHeld()) {
- drawFunction(g2, heldColor, 166, 76, shapeButton);
- }
- if (buttons.isButtonHomeJustReleased()) {
- drawFunction(g2, releasedColor, 166, 76, shapeButton);
- }
-
- /* button Left */
- if (buttons.isButtonLeftJustPressed()) {
- drawFunction(g2, pressedColor, 34, 75, shapeButton);
- }
- if (buttons.isButtonLeftHeld()) {
- drawFunction(g2, heldColor, 34, 75, shapeButton);
- }
- if (buttons.isButtonLeftJustReleased()) {
- drawFunction(g2, releasedColor, 34, 75, shapeButton);
- }
-
- /* button Minus */
- if (buttons.isButtonMinusJustPressed()) {
- drawFunction(g2, pressedColor, 140, 76, shapeButton);
- }
- if (buttons.isButtonMinusHeld()) {
- drawFunction(g2, heldColor, 140, 76, shapeButton);
- }
- if (buttons.isButtonMinusJustReleased()) {
- drawFunction(g2, releasedColor, 140, 76, shapeButton);
- }
-
- /* button Plus */
- if (buttons.isButtonPlusJustPressed()) {
- drawFunction(g2, pressedColor, 191, 76, shapeButton);
- }
- if (buttons.isButtonPlusHeld()) {
- drawFunction(g2, heldColor, 191, 76, shapeButton);
- }
- if (buttons.isButtonPlusJustReleased()) {
- drawFunction(g2, releasedColor, 191, 76, shapeButton);
- }
-
- /* button Right */
- if (buttons.isButtonRightJustPressed()) {
- drawFunction(g2, pressedColor, 86, 75, shapeButton);
- }
- if (buttons.isButtonRightHeld()) {
- drawFunction(g2, heldColor, 86, 75, shapeButton);
- }
- if (buttons.isButtonRightJustReleased()) {
- drawFunction(g2, releasedColor, 86, 353, shapeButton);
- }
-
- /* button Up */
- if (buttons.isButtonUpJustPressed()) {
- drawFunction(g2, pressedColor, 60, 50, shapeButton);
- }
- if (buttons.isButtonUpHeld()) {
- drawFunction(g2, heldColor, 60, 50, shapeButton);
- }
- if (buttons.isButtonUpJustReleased()) {
- drawFunction(g2, releasedColor, 60, 50, shapeButton);
- }
-
- /* button X */
- if (buttons.isButtonXJustPressed()) {
- drawFunction(g2, pressedColor, 271, 53, shapeButton);
- }
- if (buttons.isButtonXHeld()) {
- drawFunction(g2, heldColor, 271, 53, shapeButton);
- }
- if (buttons.isButtonXJustReleased()) {
- drawFunction(g2, releasedColor, 271, 53, shapeButton);
- }
-
- /* button Y */
- if (buttons.isButtonYJustPressed()) {
- drawFunction(g2, pressedColor, 237, 76, shapeButton);
- }
- if (buttons.isButtonYHeld()) {
- drawFunction(g2, heldColor, 237, 76, shapeButton);
- }
- if (buttons.isButtonYJustReleased()) {
- drawFunction(g2, releasedColor, 237, 76, shapeButton);
- }
-
- /* button ZL */
- if (buttons.isButtonZLJustPressed()) {
- drawFunction(g2, pressedColor, 123, 4, shapeButton);
- }
- if (buttons.isButtonZLHeld()) {
- drawFunction(g2, heldColor, 123, 4, shapeButton);
- }
- if (buttons.isButtonZLJustReleased()) {
- drawFunction(g2, releasedColor, 123, 4, shapeButton);
- }
-
- /* button ZR */
- if (buttons.isButtonZRJustPressed()) {
- drawFunction(g2, pressedColor, 208, 4, shapeButton);
- }
- if (buttons.isButtonZRHeld()) {
- drawFunction(g2, heldColor, 208, 4, shapeButton);
- }
- if (buttons.isButtonZRJustReleased()) {
- drawFunction(g2, releasedColor, 208, 4, shapeButton);
- }
-
- //joysticks
- int halfWidth = (int) Math.round(shapeJoystick.getBounds().getWidth() / 2);
- int halfHeight = (int) Math.round(shapeJoystick.getBounds().getHeight() / 2);
-
- // left joystick
- JoystickEvent jl = event.getClassicControllerLeftJoystickEvent();
- int xCenter1 = 121;
- int yCenter1 = 125;
-
- double xAng1 = Math.sin(jl.getAngle() * Math.PI / 180.0) * jl.getMagnitude();
- double yAng1 = Math.cos(jl.getAngle() * Math.PI / 180.0) * jl.getMagnitude();
-
- int xShift1 = (int) Math.round(xAng1 * xAmplitude);
- int yShift1 = (int) Math.round(yAng1 * yAmplitude);
- int x1 = xCenter1 + xShift1 - halfWidth;
- int y1 = yCenter1 - yShift1 - halfHeight;
- // draw shape
- drawFunction(g2, joystickColor, x1, y1, shapeJoystick);
-
- //Right joystick
- JoystickEvent jr = event.getClassicControllerRightJoystickEvent();
- int xCenter2 = 213;
- int yCenter2 = 125;
-
- double xAng2 = Math.sin(jr.getAngle() * Math.PI / 180.0) * jr.getMagnitude();
- double yAng2 = Math.cos(jr.getAngle() * Math.PI / 180.0) * jr.getMagnitude();
-
- int xShift2 = (int) Math.round(xAng2 * xAmplitude);
- int yShift2 = (int) Math.round(yAng2 * yAmplitude);
- int x2 = xCenter2 + xShift2 - halfWidth;
- int y2 = yCenter2 - yShift2 - halfHeight;
- // draw shape
- drawFunction(g2, joystickColor, x2, y2, shapeJoystick);
-
- event = null;
- }
-
- // put offscreen image on the screen
- g.drawImage(mImage, 0, 0, null);
- }
-
- /**
- * Function used to factorize code.
- *
- * @param g2
- * where to draw a shape.
- * @param col
- * color to use.
- * @param x
- * x coordinates.
- * @param y
- * y coordinates.
- * @param sh
- * shape to draw.
- */
- private void drawFunction(Graphics2D g2, Color col, int x, int y, Shape sh) {
- g2.setPaint(col);
- g2.translate(x, y);
- g2.draw(sh);
- g2.fill(sh);
- 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(WiimoteButtonsEvent arg0) {
- //do nothing
- }
-
- public void onIrEvent(IREvent arg0) {
- //do nothing
- }
-
- public void onMotionSensingEvent(MotionSensingEvent arg0) {
- //do nothing
- }
-
- public void onExpansionEvent(ExpansionEvent arg0) {
- if (arg0 instanceof ClassicControllerEvent) {
- event = (ClassicControllerEvent) arg0;
- }
- repaint();
- }
-
- public void onStatusEvent(StatusEvent arg0) {
- //do nothing
- }
-
- public void onDisconnectionEvent(DisconnectionEvent arg0) {
- //do nothing
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
- //do nothing
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
- //do nothing
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
- //do nothing
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
- //do nothing
- }
-
- public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent arg0) {
- //do nothing
- }
-
- public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {
- clearView();
- }
-
- public Color getHeldColor() {
- return heldColor;
- }
-
- public Color getJoystickColor() {
- return joystickColor;
- }
-
- public Color getPressedColor() {
- return pressedColor;
- }
-
- public Color getReleasedColor() {
- return releasedColor;
- }
-
- public Color getShoulderColor() {
- return shoulderColor;
- }
-
- public Shape getShapeButton() {
- return shapeButton;
- }
-
- public Shape getShapeJoystick() {
- return shapeJoystick;
- }
-
- public void setHeldColor(Color heldColor) {
- this.heldColor = heldColor;
- }
-
- public void setJoystickColor(Color joystickColor) {
- this.joystickColor = joystickColor;
- }
-
- public void setPressedColor(Color pressedColor) {
- this.pressedColor = pressedColor;
- }
-
- public void setReleasedColor(Color releasedColor) {
- this.releasedColor = releasedColor;
- }
-
- public void setShoulderColor(Color shoulderColor) {
- this.shoulderColor = shoulderColor;
- }
-
- public void setShapeButton(Shape shapeButton) {
- this.shapeButton = shapeButton;
- }
-
- public void setShapeJoystick(Shape shapeJoystick) {
- this.shapeJoystick = shapeJoystick;
- }
-
- public void clearView() {
- event = null;
- repaint();
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- // End of variables declaration//GEN-END:variables
-}
diff --git a/java/src/wiiusej/utils/GForceExpansionEventPanel.java b/java/src/wiiusej/utils/GForceExpansionEventPanel.java
deleted file mode 100644
index d5852b0..0000000
--- a/java/src/wiiusej/utils/GForceExpansionEventPanel.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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 wiiusej.values.GForce;
-import wiiusej.wiiusejevents.GenericEvent;
-import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
-
-/**
- * Panel to display GForce in a MotionSensingEvent from an expansion.
- *
- * @author guiguito
- */
-public class GForceExpansionEventPanel extends GForcePanel{
-
- @Override
- public GForce getGForceValue(GenericEvent e) {
- if (e instanceof NunchukEvent){
- return ((NunchukEvent)e).getNunchukMotionSensingEvent().getGforce();
- }
- return null;
- }
-
-}
diff --git a/java/src/wiiusej/utils/GForcePanel.java b/java/src/wiiusej/utils/GForcePanel.java
deleted file mode 100644
index dc57b30..0000000
--- a/java/src/wiiusej/utils/GForcePanel.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/**
- * 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.wiiusejevents.GenericEvent;
-import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * This panel is used to watch gravity force values from a MotionSensingEvent.
- *
- * @author guiguito
- */
-public abstract 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(WiimoteButtonsEvent arg0) {
- // nothing
- }
-
- public void onIrEvent(IREvent arg0) {
- // nothing
- }
-
- public void onMotionSensingEvent(MotionSensingEvent arg0) {
- draw(arg0);
- }
-
- public void onExpansionEvent(ExpansionEvent arg0) {
- draw(arg0);
- }
-
- public void onStatusEvent(StatusEvent arg0) {
- // nothing
- }
-
- public void onDisconnectionEvent(DisconnectionEvent arg0) {
- // Clear points.
- values.clear();
- repaint();
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
- // nothing
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
- // nothing
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
- // nothing
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerInsertedEvent(
- ClassicControllerInsertedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerRemovedEvent(
- ClassicControllerRemovedEvent arg0) {
- // nothing
- }
-
- private void draw(GenericEvent arg0) {
- if (values.size() >= getWidth()) {
- // if there are as many values as pixels in the width
- // clear points
- values.clear();
- }
- GForce gforce = getGForceValue(arg0);
- if (gforce != null)
- values.add(gforce);
- repaint();
- }
-
- public abstract GForce getGForceValue(GenericEvent e);
-
- public Color getBackgroundColor() {
- return backgroundColor;
- }
-
- public Color getLineColor() {
- return lineColor;
- }
-
- public Color getXColor() {
- return xColor;
- }
-
- public Color getYColor() {
- return yColor;
- }
-
- public Color getZColor() {
- return zColor;
- }
-
- public void setBackgroundColor(Color backgroundColor) {
- this.backgroundColor = backgroundColor;
- }
-
- public void setLineColor(Color lineColor) {
- this.lineColor = lineColor;
- }
-
- public void setXColor(Color xColor) {
- this.xColor = xColor;
- }
-
- public void setYColor(Color yColor) {
- this.yColor = yColor;
- }
-
- public void setZColor(Color zColor) {
- this.zColor = zColor;
- }
-
- public void clearView() {
- 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/java/src/wiiusej/utils/GForceWiimoteEventPanel.java b/java/src/wiiusej/utils/GForceWiimoteEventPanel.java
deleted file mode 100644
index 1ae710e..0000000
--- a/java/src/wiiusej/utils/GForceWiimoteEventPanel.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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 wiiusej.values.GForce;
-import wiiusej.wiiusejevents.GenericEvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-
-/**
- * Panel to display GForce in a MotionSensingEvent from a wiimote.
- *
- * @author guiguito
- */
-public class GForceWiimoteEventPanel extends GForcePanel {
-
- @Override
- public GForce getGForceValue(GenericEvent e) {
- if (e instanceof MotionSensingEvent) {
- return ((MotionSensingEvent) e).getGforce();
- }
- return null;
- }
-}
diff --git a/java/src/wiiusej/utils/GuitarHero3ButtonsEventPanel.java b/java/src/wiiusej/utils/GuitarHero3ButtonsEventPanel.java
deleted file mode 100644
index fe03337..0000000
--- a/java/src/wiiusej/utils/GuitarHero3ButtonsEventPanel.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/**
- * 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 wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.GuitarHeroButtonsEvent;
-import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * This panel is used to display what happens on the buttons of the
- * Guitar Hero 3 controller.
- * @author guiguito
- */
-public class GuitarHero3ButtonsEventPanel extends javax.swing.JPanel implements WiimoteListener {
-
- /** Creates new form GuitarHero3ButtonsEventPanel */
- public GuitarHero3ButtonsEventPanel() {
- initComponents();
- }
-
- /** 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();
- plusButton = new javax.swing.JToggleButton();
- minusButton = new javax.swing.JToggleButton();
- strumPanel = new javax.swing.JPanel();
- strumUpButton = new javax.swing.JToggleButton();
- strumDownButton = new javax.swing.JToggleButton();
- RightPanel = new javax.swing.JPanel();
- coloredButtonsPanel = new javax.swing.JPanel();
- orangeButton = new javax.swing.JToggleButton();
- blueButton = new javax.swing.JToggleButton();
- yellowButton = new javax.swing.JToggleButton();
- redButton = new javax.swing.JToggleButton();
- greenButton = new javax.swing.JToggleButton();
-
- setBackground(new java.awt.Color(0, 0, 0));
- setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS));
-
- leftPanel.setBackground(new java.awt.Color(0, 0, 0));
- leftPanel.setLayout(new javax.swing.BoxLayout(leftPanel, javax.swing.BoxLayout.LINE_AXIS));
-
- plusButton.setBackground(new java.awt.Color(255, 255, 255));
- plusButton.setFont(new java.awt.Font("Arial", 1, 24));
- plusButton.setText("+");
- leftPanel.add(plusButton);
-
- minusButton.setBackground(new java.awt.Color(255, 255, 255));
- minusButton.setFont(new java.awt.Font("Arial", 1, 24));
- minusButton.setText("-");
- leftPanel.add(minusButton);
-
- strumPanel.setBackground(new java.awt.Color(0, 0, 0));
- strumPanel.setLayout(new javax.swing.BoxLayout(strumPanel, javax.swing.BoxLayout.Y_AXIS));
-
- strumUpButton.setBackground(new java.awt.Color(255, 255, 255));
- strumUpButton.setFont(new java.awt.Font("Arial", 1, 24));
- strumUpButton.setText("Strum UP");
- strumPanel.add(strumUpButton);
-
- strumDownButton.setBackground(new java.awt.Color(255, 255, 255));
- strumDownButton.setFont(new java.awt.Font("Arial", 1, 24));
- strumDownButton.setText("Strum DOWN");
- strumPanel.add(strumDownButton);
-
- leftPanel.add(strumPanel);
-
- add(leftPanel);
-
- RightPanel.setBackground(new java.awt.Color(0, 0, 0));
- RightPanel.setLayout(new javax.swing.BoxLayout(RightPanel, javax.swing.BoxLayout.LINE_AXIS));
-
- coloredButtonsPanel.setLayout(new javax.swing.BoxLayout(coloredButtonsPanel, javax.swing.BoxLayout.LINE_AXIS));
-
- orangeButton.setBackground(new java.awt.Color(255, 153, 0));
- orangeButton.setFont(new java.awt.Font("Arial", 1, 24));
- orangeButton.setText("O");
- coloredButtonsPanel.add(orangeButton);
-
- blueButton.setBackground(new java.awt.Color(0, 0, 204));
- blueButton.setFont(new java.awt.Font("Arial", 1, 24));
- blueButton.setText("O");
- coloredButtonsPanel.add(blueButton);
-
- yellowButton.setBackground(new java.awt.Color(255, 255, 0));
- yellowButton.setFont(new java.awt.Font("Arial", 1, 24));
- yellowButton.setText("O");
- coloredButtonsPanel.add(yellowButton);
-
- redButton.setBackground(new java.awt.Color(255, 0, 0));
- redButton.setFont(new java.awt.Font("Arial", 1, 24));
- redButton.setText("O");
- coloredButtonsPanel.add(redButton);
-
- greenButton.setBackground(new java.awt.Color(51, 255, 0));
- greenButton.setFont(new java.awt.Font("Arial", 1, 24));
- greenButton.setText("O");
- coloredButtonsPanel.add(greenButton);
-
- RightPanel.add(coloredButtonsPanel);
-
- add(RightPanel);
- }// //GEN-END:initComponents
- public void onButtonsEvent(WiimoteButtonsEvent arg0) {
- //do nothing
- }
-
- public void onIrEvent(IREvent arg0) {
- //do nothing
- }
-
- public void onMotionSensingEvent(MotionSensingEvent arg0) {
- //do nothing
- }
-
- public void onExpansionEvent(ExpansionEvent arg0) {
- if (arg0 instanceof GuitarHeroEvent) {
- GuitarHeroEvent guitar = (GuitarHeroEvent) arg0;
- GuitarHeroButtonsEvent buttons = guitar.getButtonsEvent();
-
- //orange button
- if (buttons.isButtonOrangeJustPressed()) {
- orangeButton.setSelected(true);
- orangeButton.setText("X");
- } else if (buttons.isButtonOrangeJustReleased()) {
- orangeButton.setSelected(false);
- orangeButton.setText("O");
- }
-
- //blue button
- if (buttons.isButtonBlueJustPressed()) {
- blueButton.setSelected(true);
- blueButton.setText("X");
- } else if (buttons.isButtonBlueJustReleased()) {
- blueButton.setSelected(false);
- blueButton.setText("O");
- }
-
- //Yellow button
- if (buttons.isButtonYellowJustPressed()) {
- yellowButton.setSelected(true);
- yellowButton.setText("X");
- } else if (buttons.isButtonYellowJustReleased()) {
- yellowButton.setSelected(false);
- yellowButton.setText("O");
- }
-
- //Red button
- if (buttons.isButtonRedJustPressed()) {
- redButton.setSelected(true);
- redButton.setText("X");
- } else if (buttons.isButtonRedJustReleased()) {
- redButton.setSelected(false);
- redButton.setText("O");
- }
-
- //Green button
- if (buttons.isButtonGreenJustPressed()) {
- greenButton.setSelected(true);
- greenButton.setText("X");
- } else if (buttons.isButtonGreenJustReleased()) {
- greenButton.setSelected(false);
- greenButton.setText("O");
- }
-
- //Plus button
- if (buttons.isButtonPlusJustPressed()) {
- plusButton.setSelected(true);
- } else if (buttons.isButtonPlusJustReleased()) {
- plusButton.setSelected(false);
- }
-
- //Minus button
- if (buttons.isButtonMinusJustPressed()) {
- minusButton.setSelected(true);
- } else if (buttons.isButtonMinusJustReleased()) {
- minusButton.setSelected(false);
- }
-
- //Strum up button
- if (buttons.isButtonStrumUpJustPressed()) {
- strumUpButton.setSelected(true);
- } else if (buttons.isButtonStrumUpJustReleased()) {
- strumUpButton.setSelected(false);
- }
-
- //Strum down button
- if (buttons.isButtonStrumDownJustPressed()) {
- strumDownButton.setSelected(true);
- } else if (buttons.isButtonStrumDownJustReleased()) {
- strumDownButton.setSelected(false);
- }
- }
- }
-
- public void onStatusEvent(StatusEvent arg0) {
- //do nothing
- }
-
- public void onDisconnectionEvent(DisconnectionEvent arg0) {
- //do nothing
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
- //do nothing
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
- //do nothing
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
- //do nothing
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
- //do nothing
- }
-
- public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent arg0) {
- //do nothing
- }
-
- public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {
- //do nothing
- }
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JPanel RightPanel;
- private javax.swing.JToggleButton blueButton;
- private javax.swing.JPanel coloredButtonsPanel;
- private javax.swing.JToggleButton greenButton;
- private javax.swing.JPanel leftPanel;
- private javax.swing.JToggleButton minusButton;
- private javax.swing.JToggleButton orangeButton;
- private javax.swing.JToggleButton plusButton;
- private javax.swing.JToggleButton redButton;
- private javax.swing.JToggleButton strumDownButton;
- private javax.swing.JPanel strumPanel;
- private javax.swing.JToggleButton strumUpButton;
- private javax.swing.JToggleButton yellowButton;
- // End of variables declaration//GEN-END:variables
-}
diff --git a/java/src/wiiusej/utils/GuitarHeroJoystickEventPanel.java b/java/src/wiiusej/utils/GuitarHeroJoystickEventPanel.java
deleted file mode 100644
index 6fd906f..0000000
--- a/java/src/wiiusej/utils/GuitarHeroJoystickEventPanel.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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 wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.GuitarHeroEvent;
-import wiiusej.wiiusejevents.physicalevents.JoystickEvent;
-
-/**
- * Panel to display Guitar Hero 3 controller joystick events.
- *
- * @author guiguito
- */
-public class GuitarHeroJoystickEventPanel extends JoystickEventPanel{
-
- @Override
- public JoystickEvent getJoystickEvent(ExpansionEvent e) {
- if (e instanceof GuitarHeroEvent){
- return ((GuitarHeroEvent)e).getGuitarHeroJoystickEvent();
- }
- return null;
- }
-
-}
diff --git a/java/src/wiiusej/utils/IRPanel.java b/java/src/wiiusej/utils/IRPanel.java
deleted file mode 100644
index 9d4cf79..0000000
--- a/java/src/wiiusej/utils/IRPanel.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/**
- * 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.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * This 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 (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(WiimoteButtonsEvent 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 onExpansionEvent(ExpansionEvent e) {
- // 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();
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent e) {
- // nothing
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent e) {
- // nothing
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
- // nothing
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerInsertedEvent(
- ClassicControllerInsertedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerRemovedEvent(
- ClassicControllerRemovedEvent arg0) {
- // nothing
- }
-
- public Color getBackgroundColor() {
- return backgroundColor;
- }
-
- public Color getBorderColor() {
- return borderColor;
- }
-
- public Color getColor() {
- return color;
- }
-
- public Shape getShape() {
- return shape;
- }
-
- public void setBackgroundColor(Color backgroundColor) {
- this.backgroundColor = backgroundColor;
- }
-
- public void setBorderColor(Color borderColor) {
- this.borderColor = borderColor;
- }
-
- public void setColor(Color color) {
- this.color = color;
- }
-
- public void setShape(Shape shape) {
- this.shape = shape;
- }
-
- public void clearView() {
- initArrays();
- 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/java/src/wiiusej/utils/JoystickEventPanel.java b/java/src/wiiusej/utils/JoystickEventPanel.java
deleted file mode 100644
index 2883216..0000000
--- a/java/src/wiiusej/utils/JoystickEventPanel.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/**
- * 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.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.JoystickEvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * Panel to display joystick events.
- *
- * @author guiguito
- */
-public abstract class JoystickEventPanel extends javax.swing.JPanel implements
- WiimoteListener {
-
- private Image mImage;// image for double buffering
- private Color backgroundColor = Color.BLACK;
- private Color borderColor = Color.RED;
- private Color pointColor = Color.RED;
- private Shape shape = new java.awt.geom.Ellipse2D.Double(0, 0, 30, 30);
- private JoystickEvent lastJoystickEvent = null;
-
- /** Creates new form JoystickPanel */
- public JoystickEventPanel() {
- initComponents();
- }
-
- /**
- * Constructor used to choose the colors used by the JoystickPanel.
- *
- * @param bgColor
- * background color.
- * @param pColor
- * point color.
- * @param bdColor
- * border color for the shape.
- * @param sh
- * shape of what is drawn.
- */
- public JoystickEventPanel(Color bgColor, Color pColor, Color bdColor,
- Shape sh) {
- backgroundColor = bgColor;
- pointColor = pColor;
- shape = sh;
- borderColor = bdColor;
- 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);
- g2.setTransform(new AffineTransform());
-
- // compute center
- int xCenter = (int) Math.round(d.getWidth() / 2.0);
- int yCenter = (int) Math.round(d.getHeight() / 2.0);
-
- // compute coordinates
- if (lastJoystickEvent != null) {
- double xAng = Math.sin(lastJoystickEvent.getAngle() * Math.PI
- / 180.0)
- * lastJoystickEvent.getMagnitude();
- double yAng = Math.cos(lastJoystickEvent.getAngle() * Math.PI
- / 180.0)
- * lastJoystickEvent.getMagnitude();
- int halfWidth = (int) Math.round(shape.getBounds().getWidth() / 2);
- int halHeight = (int) Math.round(shape.getBounds().getHeight() / 2);
- int xAmplitude = (int) Math.round(xCenter - shape.getBounds().getWidth());
- int yAmplitude = (int) Math.round(xCenter - shape.getBounds().getHeight());
- int xShift = (int) Math.round(xAng * xAmplitude);
- int yShift = (int) Math.round(yAng * yAmplitude);
- int x = xCenter + xShift - halfWidth;
- int y = yCenter - yShift - halHeight;
- // shape
- g2.translate(x, y);
- g2.setPaint(borderColor);
- g2.draw(shape);
- g2.setPaint(pointColor);
- g2.fill(shape);
- }
- // 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(WiimoteButtonsEvent arg0) {
- // nothing
- }
-
- public void onIrEvent(IREvent arg0) {
- // nothing
- }
-
- public void onMotionSensingEvent(MotionSensingEvent arg0) {
- // nothing
- }
-
- public void onExpansionEvent(ExpansionEvent arg0) {
- JoystickEvent joy = getJoystickEvent(arg0);
- if (joy != null) {
- lastJoystickEvent = joy;
- }
- repaint();
- }
-
- public void onStatusEvent(StatusEvent arg0) {
- // nothing
- }
-
- public void onDisconnectionEvent(DisconnectionEvent arg0) {
- // nothing
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
- // nothing
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
- // nothing
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
- // nothing
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerInsertedEvent(
- ClassicControllerInsertedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerRemovedEvent(
- ClassicControllerRemovedEvent arg0) {
- // nothing
- }
-
- public Color getBackgroundColor() {
- return backgroundColor;
- }
-
- public Color getPointColor() {
- return pointColor;
- }
-
- public Color getBorderColor() {
- return borderColor;
- }
-
- public Shape getShape() {
- return shape;
- }
-
- public void setBackgroundColor(Color backgroundColor) {
- this.backgroundColor = backgroundColor;
- }
-
- public void setPointColor(Color pointColor) {
- this.pointColor = pointColor;
- }
-
- public void setBorderColor(Color borderColor) {
- this.borderColor = borderColor;
- }
-
- public void setShape(Shape shape) {
- this.shape = shape;
- }
-
- public abstract JoystickEvent getJoystickEvent(ExpansionEvent e);
-
- /**
- * 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/java/src/wiiusej/utils/NunchukJoystickEventPanel.java b/java/src/wiiusej/utils/NunchukJoystickEventPanel.java
deleted file mode 100644
index 9d088bc..0000000
--- a/java/src/wiiusej/utils/NunchukJoystickEventPanel.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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 wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.JoystickEvent;
-import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
-
-/**
- * Panel to display nunchuk joystick events.
- *
- * @author guiguito
- */
-public class NunchukJoystickEventPanel extends JoystickEventPanel {
-
- @Override
- public JoystickEvent getJoystickEvent(ExpansionEvent e) {
- if (e instanceof NunchukEvent) {
- return ((NunchukEvent) e).getNunchukJoystickEvent();
- }
- return null;
- }
-}
diff --git a/java/src/wiiusej/utils/OrientationExpansionEventPanel.java b/java/src/wiiusej/utils/OrientationExpansionEventPanel.java
deleted file mode 100644
index f5e3856..0000000
--- a/java/src/wiiusej/utils/OrientationExpansionEventPanel.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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 wiiusej.values.Orientation;
-import wiiusej.wiiusejevents.GenericEvent;
-import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
-
-/**
- * Panel to display Orientation in a MotionSensingEvent from an expansion.
- *
- * @author guiguito
- */
-public class OrientationExpansionEventPanel extends OrientationPanel {
-
- @Override
- public Orientation getOrientationValue(GenericEvent e) {
- if (e instanceof NunchukEvent) {
- return ((NunchukEvent) e).getNunchukMotionSensingEvent()
- .getOrientation();
- }
- return null;
- }
-}
diff --git a/java/src/wiiusej/utils/OrientationPanel.java b/java/src/wiiusej/utils/OrientationPanel.java
deleted file mode 100644
index 839fdfd..0000000
--- a/java/src/wiiusej/utils/OrientationPanel.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/**
- * 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.wiiusejevents.GenericEvent;
-import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
-import wiiusej.wiiusejevents.physicalevents.IREvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
-import wiiusej.wiiusejevents.utils.WiimoteListener;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
-import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
-
-/**
- * This panel is used to watch orientation values from a MotionSensingEvent.
- *
- * @author guiguito
- */
-public abstract 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(WiimoteButtonsEvent arg0) {
- // nothing
- }
-
- public void onIrEvent(IREvent arg0) {
- // nothing
- }
-
- public void onMotionSensingEvent(MotionSensingEvent arg0) {
- draw(arg0);
- }
-
- public void onExpansionEvent(ExpansionEvent arg0) {
- draw(arg0);
- }
-
- public void onStatusEvent(StatusEvent arg0) {
- // nothing
- }
-
- public void onDisconnectionEvent(DisconnectionEvent arg0) {
- // Clear points.
- values.clear();
- repaint();
- }
-
- public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {
- // nothing
- }
-
- public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {
- // nothing
- }
-
- public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {
- // nothing
- }
-
- public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerInsertedEvent(
- ClassicControllerInsertedEvent arg0) {
- // nothing
- }
-
- public void onClassicControllerRemovedEvent(
- ClassicControllerRemovedEvent arg0) {
- // nothing
- }
-
- private void draw(GenericEvent arg0) {
- if (values.size() >= getWidth()) {
- // if there are as many values as pixels in the width
- // clear points
- values.clear();
- }
- Orientation orientation = getOrientationValue(arg0);
- if (orientation != null)
- values.add(orientation);
- repaint();
- }
-
- public abstract Orientation getOrientationValue(GenericEvent e);
-
- public Color getBackgroundColor() {
- return backgroundColor;
- }
-
- public Color getLineColor() {
- return lineColor;
- }
-
- public Color getPitchColor() {
- return pitchColor;
- }
-
- public Color getRollColor() {
- return rollColor;
- }
-
- public Color getYawColor() {
- return yawColor;
- }
-
- public void setBackgroundColor(Color backgroundColor) {
- this.backgroundColor = backgroundColor;
- }
-
- public void setLineColor(Color lineColor) {
- this.lineColor = lineColor;
- }
-
- public void setPitchColor(Color pitchColor) {
- this.pitchColor = pitchColor;
- }
-
- public void setRollColor(Color rollColor) {
- this.rollColor = rollColor;
- }
-
- public void setYawColor(Color yawColor) {
- this.yawColor = yawColor;
- }
-
- public void clearView() {
- 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/java/src/wiiusej/utils/OrientationWiimoteEventPanel.java b/java/src/wiiusej/utils/OrientationWiimoteEventPanel.java
deleted file mode 100644
index e38f3c9..0000000
--- a/java/src/wiiusej/utils/OrientationWiimoteEventPanel.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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 wiiusej.values.Orientation;
-import wiiusej.wiiusejevents.GenericEvent;
-import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
-
-/**
- * Panel to display Orientation in a MotionSensingEvent from a wiimote.
- *
- * @author guiguito
- */
-public class OrientationWiimoteEventPanel extends OrientationPanel {
-
- @Override
- public Orientation getOrientationValue(GenericEvent e) {
- if (e instanceof MotionSensingEvent) {
- return ((MotionSensingEvent) e).getOrientation();
- }
- return null;
- }
-
-}
diff --git a/java/wiiuse.dll b/java/wiiuse.dll
index 7774620..98b517f 100644
Binary files a/java/wiiuse.dll and b/java/wiiuse.dll differ
diff --git a/java/wiiusej.dll b/java/wiiusej.dll
index 708f8fb..f320600 100644
Binary files a/java/wiiusej.dll and b/java/wiiusej.dll differ
diff --git a/java/wiiusej.jar b/java/wiiusej.jar
new file mode 100644
index 0000000..951377e
Binary files /dev/null and b/java/wiiusej.jar differ