wiiusej 0.12 clean1 before release

git-svn-id: http://wiiusej.googlecode.com/svn/trunk@158 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
guilhem.duche
2008-06-01 09:50:30 +00:00
parent 2fb184eda3
commit b2c8a6d87d
35 changed files with 1219 additions and 1080 deletions

View File

@@ -36,7 +36,7 @@ public class WiiUseApi {
* *
* @return the only instace of WiiUseApi. * @return the only instace of WiiUseApi.
*/ */
static WiiUseApi getInstance() { protected static WiiUseApi getInstance() {
return instance; return instance;
} }
@@ -334,7 +334,8 @@ public class WiiUseApi {
* Force the bluetooth stack type.(useful only for windows) * Force the bluetooth stack type.(useful only for windows)
* *
* @param bluetoothStackType * @param bluetoothStackType
* must be WiiUseApi.WIIUSE_STACK_UNKNOWN or WiiUseApi.WIIUSE_STACK_MS or * must be WiiUseApi.WIIUSE_STACK_UNKNOWN or
* WiiUseApi.WIIUSE_STACK_MS or
* WiiUseApi.WIIUSE_STACK_BLUESOLEIL. * WiiUseApi.WIIUSE_STACK_BLUESOLEIL.
*/ */
native void windowsSetBluetoothStack(int bluetoothStackType); native void windowsSetBluetoothStack(int bluetoothStackType);

View File

@@ -23,7 +23,6 @@ import javax.swing.event.EventListenerList;
import wiiusej.wiiusejevents.utils.EventsGatherer; import wiiusej.wiiusejevents.utils.EventsGatherer;
import wiiusej.wiiusejevents.utils.WiiUseApiListener; import wiiusej.wiiusejevents.utils.WiiUseApiListener;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent; import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
/** /**
@@ -53,7 +52,7 @@ public class WiiUseApiManager extends Thread {
public static int WIIUSE_STACK_MS = 1; public static int WIIUSE_STACK_MS = 1;
public static int WIIUSE_STACK_BLUESOLEIL = 2; public static int WIIUSE_STACK_BLUESOLEIL = 2;
public static WiiUseApiManager getInstance() { private static WiiUseApiManager getInstance() {
return instance; return instance;
} }
@@ -115,7 +114,8 @@ public class WiiUseApiManager extends Thread {
boolean rumble, boolean forceStackType, int stackType) { boolean rumble, boolean forceStackType, int stackType) {
WiiUseApiManager manager = getInstance(); WiiUseApiManager manager = getInstance();
if (manager.leave) return null;//wiiusej definitively stopped if (manager.leave)
return null;// wiiusej definitively stopped
if (manager.connected <= 0 && !manager.running.get()) { if (manager.connected <= 0 && !manager.running.get()) {
// connect wiimotes. // connect wiimotes.
@@ -131,7 +131,6 @@ public class WiiUseApiManager extends Thread {
// Set leds on wiimote // Set leds on wiimote
for (Wiimote wiimote : manager.wiimotes) { for (Wiimote wiimote : manager.wiimotes) {
int id = wiimote.getId(); int id = wiimote.getId();
short leds = 0;
if (id % 4 == 0) { if (id % 4 == 0) {
wiimote.setLeds(true, true, true, true); wiimote.setLeds(true, true, true, true);
} else if (id % 4 == 1) { } else if (id % 4 == 1) {
@@ -208,7 +207,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote to disconnect. * id of the wiimote to disconnect.
*/ */
public void closeConnection(int id) { protected void closeConnection(int id) {
int index = 0; int index = 0;
boolean found = false; boolean found = false;
while (index < wiimotes.length && !found) { while (index < wiimotes.length && !found) {
@@ -236,29 +235,31 @@ public class WiiUseApiManager extends Thread {
* *
* @return the number of wiimotes connected. * @return the number of wiimotes connected.
*/ */
public int getNbConnectedWiimotes() { public static int getNbConnectedWiimotes() {
return connected; return getInstance().connected;
} }
/** /**
* Stop thread and shutdown wiiuse Api. * Stop thread and shutdown wiiuse Api.
*/ */
public void shutdown() { public static void shutdown() {
if (connected > 0) { WiiUseApiManager manager = getInstance();
for (Wiimote wim : wiimotes) { if (manager.connected > 0) {
for (Wiimote wim : manager.wiimotes) {
if (wim != null) if (wim != null)
wim.disconnect(); wim.disconnect();
} }
} }
running.set(false); manager.running.set(false);
wiiuse.cleanUp(); manager.wiiuse.cleanUp();
} }
/** /**
* Stop wiiuseJ definitively for this program. * Stop wiiuseJ definitively for this program. It finishes Wiiusej thread
* and shutdown wiiuse API.
*/ */
public void definitiveShutdown(){ public static void definitiveShutdown() {
leave = true; getInstance().leave = true;
shutdown(); shutdown();
} }
@@ -268,7 +269,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void activateRumble(int id) { protected void activateRumble(int id) {
wiiuse.activateRumble(id); wiiuse.activateRumble(id);
} }
@@ -278,7 +279,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void deactivateRumble(int id) { protected void deactivateRumble(int id) {
wiiuse.deactivateRumble(id); wiiuse.deactivateRumble(id);
} }
@@ -288,7 +289,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void activateIRTRacking(int id) { protected void activateIRTRacking(int id) {
wiiuse.activateIRTracking(id); wiiuse.activateIRTracking(id);
} }
@@ -298,7 +299,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void deactivateIRTRacking(int id) { protected void deactivateIRTRacking(int id) {
wiiuse.deactivateIRTracking(id); wiiuse.deactivateIRTracking(id);
} }
@@ -308,7 +309,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void activateMotionSensing(int id) { protected void activateMotionSensing(int id) {
wiiuse.activateMotionSensing(id); wiiuse.activateMotionSensing(id);
} }
@@ -318,7 +319,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void deactivateMotionSensing(int id) { protected void deactivateMotionSensing(int id) {
wiiuse.deactivateMotionSensing(id); wiiuse.deactivateMotionSensing(id);
} }
@@ -328,7 +329,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void activateSmoothing(int id) { protected void activateSmoothing(int id) {
wiiuse.activateSmoothing(id); wiiuse.activateSmoothing(id);
} }
@@ -338,7 +339,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void deactivateSmoothing(int id) { protected void deactivateSmoothing(int id) {
wiiuse.deactivateSmoothing(id); wiiuse.deactivateSmoothing(id);
} }
@@ -348,7 +349,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void activateContinuous(int id) { protected void activateContinuous(int id) {
wiiuse.activateContinuous(id); wiiuse.activateContinuous(id);
} }
@@ -358,7 +359,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void deactivateContinuous(int id) { protected void deactivateContinuous(int id) {
wiiuse.deactivateContinuous(id); wiiuse.deactivateContinuous(id);
} }
@@ -376,7 +377,8 @@ public class WiiUseApiManager extends Thread {
* @param l4 * @param l4
* status of led4. True : ON, False : OFF. * status of led4. True : ON, False : OFF.
*/ */
public void setLeds(int id, boolean l1, boolean l2, boolean l3, boolean l4) { protected void setLeds(int id, boolean l1, boolean l2, boolean l3,
boolean l4) {
wiiuse.setLeds(id, l1, l2, l3, l4); wiiuse.setLeds(id, l1, l2, l3, l4);
} }
@@ -389,7 +391,7 @@ public class WiiUseApiManager extends Thread {
* @param th * @param th
* threshold in degrees. * threshold in degrees.
*/ */
public void setOrientationThreshold(int id, float th) { protected void setOrientationThreshold(int id, float th) {
wiiuse.setOrientThreshold(id, th); wiiuse.setOrientThreshold(id, th);
} }
@@ -402,7 +404,7 @@ public class WiiUseApiManager extends Thread {
* @param th * @param th
* threshold. * threshold.
*/ */
public void setAccelerationThreshold(int id, int th) { protected void setAccelerationThreshold(int id, int th) {
wiiuse.setAccelThreshold(id, th); wiiuse.setAccelThreshold(id, th);
} }
@@ -414,7 +416,7 @@ public class WiiUseApiManager extends Thread {
* @param th * @param th
* threshold. * threshold.
*/ */
public void setAlphaSmoothing(int id, float th) { protected void setAlphaSmoothing(int id, float th) {
wiiuse.setAlphaSmoothing(id, th); wiiuse.setAlphaSmoothing(id, th);
} }
@@ -424,7 +426,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void reSync(int id) { protected void reSync(int id) {
wiiuse.reSync(id); wiiuse.reSync(id);
} }
@@ -434,7 +436,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void setScreenAspectRatio43(int id) { protected void setScreenAspectRatio43(int id) {
wiiuse.setScreenRatio43(id); wiiuse.setScreenRatio43(id);
} }
@@ -444,7 +446,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void setScreenAspectRatio169(int id) { protected void setScreenAspectRatio169(int id) {
wiiuse.setScreenRatio169(id); wiiuse.setScreenRatio169(id);
} }
@@ -454,7 +456,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void setSensorBarAboveScreen(int id) { protected void setSensorBarAboveScreen(int id) {
wiiuse.setSensorBarAboveScreen(id); wiiuse.setSensorBarAboveScreen(id);
} }
@@ -464,7 +466,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void setSensorBarBelowScreen(int id) { protected void setSensorBarBelowScreen(int id) {
wiiuse.setSensorBarBelowScreen(id); wiiuse.setSensorBarBelowScreen(id);
} }
@@ -480,7 +482,7 @@ public class WiiUseApiManager extends Thread {
* @param y * @param y
* y resolution. * y resolution.
*/ */
public void setVirtualResolution(int id, int x, int y) { protected void setVirtualResolution(int id, int x, int y) {
wiiuse.setVirtualScreenResolution(id, x, y); wiiuse.setVirtualScreenResolution(id, x, y);
} }
@@ -490,7 +492,7 @@ public class WiiUseApiManager extends Thread {
* @param id * @param id
* id of the wiimote. * id of the wiimote.
*/ */
public void getStatus(int id) { protected void getStatus(int id) {
wiiuse.getStatus(id); wiiuse.getStatus(id);
} }
@@ -505,7 +507,8 @@ public class WiiUseApiManager extends Thread {
* The timeout in millisecondsd to wait for an expansion * The timeout in millisecondsd to wait for an expansion
* handshake. * handshake.
*/ */
public void setTimeout(int id, short normalTimeout, short expansionTimeout) { protected void setTimeout(int id, short normalTimeout,
short expansionTimeout) {
wiiuse.setTimeout(id, normalTimeout, expansionTimeout); wiiuse.setTimeout(id, normalTimeout, expansionTimeout);
} }
@@ -519,7 +522,7 @@ public class WiiUseApiManager extends Thread {
* 1, then level will be set to 1. If the level is > 5, then * 1, then level will be set to 1. If the level is > 5, then
* level will be set to 5. * level will be set to 5.
*/ */
public void setIrSensitivity(int id, int level) { protected void setIrSensitivity(int id, int level) {
wiiuse.setIrSensitivity(id, level); wiiuse.setIrSensitivity(id, level);
} }
@@ -532,7 +535,7 @@ public class WiiUseApiManager extends Thread {
* @param th * @param th
* threshold in degrees. * threshold in degrees.
*/ */
public void setNunchukOrientationThreshold(int id, float th) { protected void setNunchukOrientationThreshold(int id, float th) {
wiiuse.setNunchukOrientationThreshold(id, th); wiiuse.setNunchukOrientationThreshold(id, th);
} }
@@ -545,7 +548,7 @@ public class WiiUseApiManager extends Thread {
* @param th * @param th
* threshold. * threshold.
*/ */
public void setNunchukAccelerationThreshold(int id, int th) { protected void setNunchukAccelerationThreshold(int id, int th) {
wiiuse.setNunchukAccelerationThreshold(id, th); wiiuse.setNunchukAccelerationThreshold(id, th);
} }
@@ -616,7 +619,7 @@ public class WiiUseApiManager extends Thread {
* @param listener * @param listener
* a WiiUseApiListener * a WiiUseApiListener
*/ */
public void addWiiUseApiListener(WiiUseApiListener listener) { protected void addWiiUseApiListener(WiiUseApiListener listener) {
listeners.add(WiiUseApiListener.class, listener); listeners.add(WiiUseApiListener.class, listener);
} }
@@ -626,7 +629,7 @@ public class WiiUseApiManager extends Thread {
* @param listener * @param listener
* a WiiUseApiListener * a WiiUseApiListener
*/ */
public void removeWiiUseApiListener(WiiUseApiListener listener) { protected void removeWiiUseApiListener(WiiUseApiListener listener) {
listeners.remove(WiiUseApiListener.class, listener); listeners.remove(WiiUseApiListener.class, listener);
} }
@@ -635,7 +638,7 @@ public class WiiUseApiManager extends Thread {
* *
* @return the list of WiiUseApiListeners. * @return the list of WiiUseApiListeners.
*/ */
public WiiUseApiListener[] getWiiUseApiListeners() { protected WiiUseApiListener[] getWiiUseApiListeners() {
return listeners.getListeners(WiiUseApiListener.class); return listeners.getListeners(WiiUseApiListener.class);
} }

View File

@@ -22,6 +22,7 @@ import wiiusej.WiiUseApiManager;
/** /**
* This class is used to close wiiusej cleanly. * This class is used to close wiiusej cleanly.
*
* @author guiguito * @author guiguito
*/ */
public class CloseGuiTestCleanly implements WindowListener { public class CloseGuiTestCleanly implements WindowListener {
@@ -31,7 +32,7 @@ public class CloseGuiTestCleanly implements WindowListener{
} }
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
WiiUseApiManager.getInstance().shutdown(); WiiUseApiManager.definitiveShutdown();
} }
public void windowClosed(WindowEvent e) { public void windowClosed(WindowEvent e) {

View File

@@ -21,12 +21,14 @@ import wiiusej.Wiimote;
/** /**
* Main Class to launch WiiuseJ GUI Test. * Main Class to launch WiiuseJ GUI Test.
*
* @author guiguito * @author guiguito
*/ */
public class Main { public class Main {
/** /**
* @param args the command line arguments * @param args
* the command line arguments
*/ */
public static void main(String[] args) { public static void main(String[] args) {
Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true); Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
@@ -36,7 +38,7 @@ public class Main {
} else { } else {
gui = new WiiuseJGuiTest(); gui = new WiiuseJGuiTest();
} }
gui.setDefaultCloseOperation(gui.EXIT_ON_CLOSE); gui.setDefaultCloseOperation(WiiuseJGuiTest.EXIT_ON_CLOSE);
gui.setVisible(true); gui.setVisible(true);
} }

View File

@@ -37,10 +37,12 @@ import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/** /**
* This frame is used to display events from a nunchuk.
* *
* @author guiguito * @author guiguito
*/ */
public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListener { public class NunchukGuiTest extends javax.swing.JFrame implements
WiimoteListener {
private Wiimote wiimote; private Wiimote wiimote;
private boolean isThresholdsRequested = true; private boolean isThresholdsRequested = true;
@@ -56,15 +58,20 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
wiimote.addWiiMoteEventListeners(this); wiimote.addWiiMoteEventListeners(this);
wiimote.addWiiMoteEventListeners((OrientationPanel) orientationPanel); wiimote.addWiiMoteEventListeners((OrientationPanel) orientationPanel);
wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel); wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel);
wiimote.addWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel); wiimote
wiimote.addWiiMoteEventListeners((NunchukJoystickEventPanel)joystickEventsPanel); .addWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
wiimote
.addWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel);
} }
public void unRegisterListeners() { public void unRegisterListeners() {
wiimote.removeWiiMoteEventListeners((OrientationPanel) orientationPanel); wiimote
.removeWiiMoteEventListeners((OrientationPanel) orientationPanel);
wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel); wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel);
wiimote.removeWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel); wiimote
wiimote.removeWiiMoteEventListeners((NunchukJoystickEventPanel)joystickEventsPanel); .removeWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
wiimote
.removeWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel);
wiimote.removeWiiMoteEventListeners(this); wiimote.removeWiiMoteEventListeners(this);
} }
@@ -72,16 +79,17 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
isThresholdsRequested = true; isThresholdsRequested = true;
} }
/** This method is called from within the constructor to /**
* initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is always
* always regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated
// Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
topPanels = new javax.swing.JPanel(); topPanels = new javax.swing.JPanel();
joystickEventsPanel = joystickEventsPanel = new NunchukJoystickEventPanel(); joystickEventsPanel = new NunchukJoystickEventPanel();
motionSensingEventsPanel = new javax.swing.JPanel(); motionSensingEventsPanel = new javax.swing.JPanel();
motionSensingEventsTabbedPanels = new javax.swing.JTabbedPane(); motionSensingEventsTabbedPanels = new javax.swing.JTabbedPane();
rawAccelerationPanel = new AccelerationExpansionEventPanel(); rawAccelerationPanel = new AccelerationExpansionEventPanel();
@@ -102,97 +110,120 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(400, 400)); setMinimumSize(new java.awt.Dimension(400, 400));
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS)); getContentPane().setLayout(
new javax.swing.BoxLayout(getContentPane(),
javax.swing.BoxLayout.Y_AXIS));
topPanels.setMinimumSize(new java.awt.Dimension(400, 200)); topPanels.setMinimumSize(new java.awt.Dimension(400, 200));
topPanels.setPreferredSize(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)); topPanels.setLayout(new javax.swing.BoxLayout(topPanels,
javax.swing.BoxLayout.LINE_AXIS));
joystickEventsPanel.setBackground(new java.awt.Color(0, 0, 0)); 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.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.setToolTipText("JoystickEvent");
joystickEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200)); joystickEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200));
javax.swing.GroupLayout joystickEventsPanelLayout = new javax.swing.GroupLayout(joystickEventsPanel); javax.swing.GroupLayout joystickEventsPanelLayout = new javax.swing.GroupLayout(
joystickEventsPanel);
joystickEventsPanel.setLayout(joystickEventsPanelLayout); joystickEventsPanel.setLayout(joystickEventsPanelLayout);
joystickEventsPanelLayout.setHorizontalGroup( joystickEventsPanelLayout.setHorizontalGroup(joystickEventsPanelLayout
joystickEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 601, Short.MAX_VALUE) .addGap(0, 601, Short.MAX_VALUE));
); joystickEventsPanelLayout.setVerticalGroup(joystickEventsPanelLayout
joystickEventsPanelLayout.setVerticalGroup( .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
joystickEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 174, Short.MAX_VALUE));
.addGap(0, 174, Short.MAX_VALUE)
);
topPanels.add(joystickEventsPanel); topPanels.add(joystickEventsPanel);
joystickEventsPanel.getAccessibleContext().setAccessibleName("Joystick"); joystickEventsPanel.getAccessibleContext()
.setAccessibleName("Joystick");
motionSensingEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200)); motionSensingEventsPanel
.setMinimumSize(new java.awt.Dimension(200, 200));
rawAccelerationPanel.setToolTipText("Nunchuk MotionSensingEvent"); rawAccelerationPanel.setToolTipText("Nunchuk MotionSensingEvent");
javax.swing.GroupLayout rawAccelerationPanelLayout = new javax.swing.GroupLayout(rawAccelerationPanel); javax.swing.GroupLayout rawAccelerationPanelLayout = new javax.swing.GroupLayout(
rawAccelerationPanel);
rawAccelerationPanel.setLayout(rawAccelerationPanelLayout); rawAccelerationPanel.setLayout(rawAccelerationPanelLayout);
rawAccelerationPanelLayout.setHorizontalGroup( rawAccelerationPanelLayout
rawAccelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .setHorizontalGroup(rawAccelerationPanelLayout
.addGap(0, 597, Short.MAX_VALUE) .createParallelGroup(
); javax.swing.GroupLayout.Alignment.LEADING)
rawAccelerationPanelLayout.setVerticalGroup( .addGap(0, 597, Short.MAX_VALUE));
rawAccelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) rawAccelerationPanelLayout.setVerticalGroup(rawAccelerationPanelLayout
.addGap(0, 175, Short.MAX_VALUE) .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
); .addGap(0, 175, Short.MAX_VALUE));
motionSensingEventsTabbedPanels.addTab("RawAcceleration", rawAccelerationPanel); motionSensingEventsTabbedPanels.addTab("RawAcceleration",
rawAccelerationPanel);
javax.swing.GroupLayout orientationPanelLayout = new javax.swing.GroupLayout(orientationPanel); javax.swing.GroupLayout orientationPanelLayout = new javax.swing.GroupLayout(
orientationPanel);
orientationPanel.setLayout(orientationPanelLayout); orientationPanel.setLayout(orientationPanelLayout);
orientationPanelLayout.setHorizontalGroup( orientationPanelLayout.setHorizontalGroup(orientationPanelLayout
orientationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 597, Short.MAX_VALUE) .addGap(0, 597, Short.MAX_VALUE));
); orientationPanelLayout.setVerticalGroup(orientationPanelLayout
orientationPanelLayout.setVerticalGroup( .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
orientationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 175, Short.MAX_VALUE));
.addGap(0, 175, Short.MAX_VALUE)
);
motionSensingEventsTabbedPanels.addTab("Orientation", orientationPanel); motionSensingEventsTabbedPanels.addTab("Orientation", orientationPanel);
javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(gForcePanel); javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(
gForcePanel);
gForcePanel.setLayout(gForcePanelLayout); gForcePanel.setLayout(gForcePanelLayout);
gForcePanelLayout.setHorizontalGroup( gForcePanelLayout.setHorizontalGroup(gForcePanelLayout
gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 597, Short.MAX_VALUE) .addGap(0, 597, Short.MAX_VALUE));
); gForcePanelLayout.setVerticalGroup(gForcePanelLayout
gForcePanelLayout.setVerticalGroup( .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 175, Short.MAX_VALUE));
.addGap(0, 175, Short.MAX_VALUE)
);
motionSensingEventsTabbedPanels.addTab("GForce", gForcePanel); motionSensingEventsTabbedPanels.addTab("GForce", gForcePanel);
javax.swing.GroupLayout motionSensingEventsPanelLayout = new javax.swing.GroupLayout(motionSensingEventsPanel); javax.swing.GroupLayout motionSensingEventsPanelLayout = new javax.swing.GroupLayout(
motionSensingEventsPanel);
motionSensingEventsPanel.setLayout(motionSensingEventsPanelLayout); motionSensingEventsPanel.setLayout(motionSensingEventsPanelLayout);
motionSensingEventsPanelLayout.setHorizontalGroup( motionSensingEventsPanelLayout
motionSensingEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .setHorizontalGroup(motionSensingEventsPanelLayout
.addComponent(motionSensingEventsTabbedPanels, javax.swing.GroupLayout.DEFAULT_SIZE, 602, Short.MAX_VALUE) .createParallelGroup(
); javax.swing.GroupLayout.Alignment.LEADING)
motionSensingEventsPanelLayout.setVerticalGroup( .addComponent(motionSensingEventsTabbedPanels,
motionSensingEventsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.DEFAULT_SIZE, 602,
.addComponent(motionSensingEventsTabbedPanels, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE) 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); topPanels.add(motionSensingEventsPanel);
getContentPane().add(topPanels); getContentPane().add(topPanels);
setNunchukValuesPanel.setMinimumSize(new java.awt.Dimension(400, 200)); setNunchukValuesPanel.setMinimumSize(new java.awt.Dimension(400, 200));
setNunchukValuesPanel.setPreferredSize(new java.awt.Dimension(400, 200)); setNunchukValuesPanel
setNunchukValuesPanel.setLayout(new javax.swing.BoxLayout(setNunchukValuesPanel, javax.swing.BoxLayout.Y_AXIS)); .setPreferredSize(new java.awt.Dimension(400, 200));
setNunchukValuesPanel.setLayout(new javax.swing.BoxLayout(
setNunchukValuesPanel, javax.swing.BoxLayout.Y_AXIS));
nunchukButtonsEventPanel.setToolTipText("Nunchuk ButtonsEvent"); nunchukButtonsEventPanel.setToolTipText("Nunchuk ButtonsEvent");
nunchukButtonsEventPanel.setMinimumSize(new java.awt.Dimension(100, 100)); nunchukButtonsEventPanel
nunchukButtonsEventPanel.setPreferredSize(new java.awt.Dimension(100, 100)); .setMinimumSize(new java.awt.Dimension(100, 100));
nunchukButtonsEventPanel.setLayout(new javax.swing.BoxLayout(nunchukButtonsEventPanel, javax.swing.BoxLayout.LINE_AXIS)); nunchukButtonsEventPanel.setPreferredSize(new java.awt.Dimension(100,
100));
nunchukButtonsEventPanel.setLayout(new javax.swing.BoxLayout(
nunchukButtonsEventPanel, javax.swing.BoxLayout.LINE_AXIS));
cButton.setText("C"); cButton.setText("C");
cButton.setMaximumSize(new java.awt.Dimension(50, 50)); cButton.setMaximumSize(new java.awt.Dimension(50, 50));
@@ -208,11 +239,13 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
setNunchukValuesPanel.add(nunchukButtonsEventPanel); setNunchukValuesPanel.add(nunchukButtonsEventPanel);
nunchukOrientationTextField.setPreferredSize(new java.awt.Dimension(60, 20)); nunchukOrientationTextField.setPreferredSize(new java.awt.Dimension(60,
20));
nunchukOrientationPanel.add(nunchukOrientationTextField); nunchukOrientationPanel.add(nunchukOrientationTextField);
nunchukOrientationButton.setText("Set Orientation Threshold"); nunchukOrientationButton.setText("Set Orientation Threshold");
nunchukOrientationButton.addMouseListener(new java.awt.event.MouseAdapter() { nunchukOrientationButton
.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) { public void mousePressed(java.awt.event.MouseEvent evt) {
nunchukOrientationButtonMousePressed(evt); nunchukOrientationButtonMousePressed(evt);
} }
@@ -221,11 +254,13 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
setNunchukValuesPanel.add(nunchukOrientationPanel); setNunchukValuesPanel.add(nunchukOrientationPanel);
nunchukAccelerationTextField.setPreferredSize(new java.awt.Dimension(60, 20)); nunchukAccelerationTextField.setPreferredSize(new java.awt.Dimension(
60, 20));
nunchukAccelerationPanel.add(nunchukAccelerationTextField); nunchukAccelerationPanel.add(nunchukAccelerationTextField);
nunchukAccelerationButton.setText("Set Acceleration Threshold"); nunchukAccelerationButton.setText("Set Acceleration Threshold");
nunchukAccelerationButton.addMouseListener(new java.awt.event.MouseAdapter() { nunchukAccelerationButton
.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) { public void mousePressed(java.awt.event.MouseEvent evt) {
nunchukAccelerationButtonMousePressed(evt); nunchukAccelerationButtonMousePressed(evt);
} }
@@ -236,26 +271,45 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
messageText.setText("Message:"); messageText.setText("Message:");
javax.swing.GroupLayout messagePanelLayout = new javax.swing.GroupLayout(messagePanel); javax.swing.GroupLayout messagePanelLayout = new javax.swing.GroupLayout(
messagePanel);
messagePanel.setLayout(messagePanelLayout); messagePanel.setLayout(messagePanelLayout);
messagePanelLayout.setHorizontalGroup( messagePanelLayout
messagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .setHorizontalGroup(messagePanelLayout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 1216, Short.MAX_VALUE) .addGap(0, 1216, Short.MAX_VALUE)
.addGroup(messagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(
.addGroup(messagePanelLayout.createSequentialGroup() messagePanelLayout
.addGap(0, 0, Short.MAX_VALUE) .createParallelGroup(
.addComponent(messageText) javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE))) .addGroup(
); messagePanelLayout
messagePanelLayout.setVerticalGroup( .createSequentialGroup()
messagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .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) .addGap(0, 34, Short.MAX_VALUE)
.addGroup(messagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(
.addGroup(messagePanelLayout.createSequentialGroup() messagePanelLayout
.addGap(0, 0, Short.MAX_VALUE) .createParallelGroup(
.addComponent(messageText) javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE))) .addGroup(
); messagePanelLayout
.createSequentialGroup()
.addGap(0, 0,
Short.MAX_VALUE)
.addComponent(
messageText)
.addGap(0, 0,
Short.MAX_VALUE))));
setNunchukValuesPanel.add(messagePanel); setNunchukValuesPanel.add(messagePanel);
@@ -263,23 +317,28 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void nunchukOrientationButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nunchukOrientationButtonMousePressed
private void nunchukOrientationButtonMousePressed(
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukOrientationButtonMousePressed
try { try {
float nb = Float.parseFloat(nunchukOrientationTextField.getText()); float nb = Float.parseFloat(nunchukOrientationTextField.getText());
wiimote.setNunchukOrientationThreshold(nb); wiimote.setNunchukOrientationThreshold(nb);
messageText.setText("Nunchuk orientation threshold set to " + nb); messageText.setText("Nunchuk orientation threshold set to " + nb);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
messageText.setText("Number is not an integer, nunchuk orientation threshold not set !"); messageText
.setText("Number is not an integer, nunchuk orientation threshold not set !");
} }
}// GEN-LAST:event_nunchukOrientationButtonMousePressed }// GEN-LAST:event_nunchukOrientationButtonMousePressed
private void nunchukAccelerationButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nunchukAccelerationButtonMousePressed private void nunchukAccelerationButtonMousePressed(
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_nunchukAccelerationButtonMousePressed
try { try {
int nb = Integer.parseInt(nunchukAccelerationTextField.getText()); int nb = Integer.parseInt(nunchukAccelerationTextField.getText());
wiimote.setNunchukAccelerationThreshold(nb); wiimote.setNunchukAccelerationThreshold(nb);
messageText.setText("Nunchuk acceleration threshold set to " + nb); messageText.setText("Nunchuk acceleration threshold set to " + nb);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
messageText.setText("Number is not an integer, nunchuk acceleration threshold not set !"); messageText
.setText("Number is not an integer, nunchuk acceleration threshold not set !");
} }
}// GEN-LAST:event_nunchukAccelerationButtonMousePressed }// GEN-LAST:event_nunchukAccelerationButtonMousePressed
@@ -313,8 +372,12 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
} }
if (isThresholdsRequested) { if (isThresholdsRequested) {
MotionSensingEvent evt = nunchuk.getNunchukMotionSensingEvent(); MotionSensingEvent evt = nunchuk.getNunchukMotionSensingEvent();
nunchukAccelerationTextField.setText(evt.getAccelerationThreshold()+""); nunchukAccelerationTextField.setText(evt
nunchukOrientationTextField.setText(evt.getOrientationThreshold()+""); .getAccelerationThreshold()
+ "");
nunchukOrientationTextField.setText(evt
.getOrientationThreshold()
+ "");
isThresholdsRequested = false; isThresholdsRequested = false;
} }
} }

View File

@@ -34,7 +34,7 @@ import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/** /**
* This class used to test WiiuseJ. * This class used to test WiiuseJ in text mode.
* *
* @author guiguito * @author guiguito
*/ */
@@ -61,8 +61,6 @@ public class Tests implements WiimoteListener {
} }
} }
private static int nb = 0;
public void onButtonsEvent(WiimoteButtonsEvent e) { public void onButtonsEvent(WiimoteButtonsEvent e) {
if (dump == DISPLAY_EACH_VALUE) { if (dump == DISPLAY_EACH_VALUE) {
// System.out.println("*********** WIIMOTE ID : "+ // System.out.println("*********** WIIMOTE ID : "+
@@ -353,10 +351,10 @@ public class Tests implements WiimoteListener {
* @param args * @param args
*/ */
public static void main(String[] args) { public static void main(String[] args) {
Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(4, true); Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
if (wiimotes.length > 0) { if (wiimotes.length > 0) {
System.out.println(wiimotes[0]); System.out.println(wiimotes[0]);
Tests tests = new Tests(wiimotes[0]); new Tests(wiimotes[0]);
} else { } else {
System.out.println("No wiimotes found !!!"); System.out.println("No wiimotes found !!!");
} }

View File

@@ -231,7 +231,7 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
showExpansionWiimoteButton.setText("Show Nunchuk"); showExpansionWiimoteButton.setText("Show Nunchuk");
expansionFrame = new NunchukGuiTest(wiimote); expansionFrame = new NunchukGuiTest(wiimote);
expansionFrame expansionFrame
.setDefaultCloseOperation(expansionFrame.HIDE_ON_CLOSE); .setDefaultCloseOperation(NunchukGuiTest.HIDE_ON_CLOSE);
expansionFrame.addWindowListener(buttonSetter); expansionFrame.addWindowListener(buttonSetter);
isFirstStatusGot = true; isFirstStatusGot = true;
} }
@@ -275,7 +275,7 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
showExpansionWiimoteButton.setEnabled(true); showExpansionWiimoteButton.setEnabled(true);
showExpansionWiimoteButton.setText("Show nunchuk"); showExpansionWiimoteButton.setText("Show nunchuk");
expansionFrame = new NunchukGuiTest(wiimote); expansionFrame = new NunchukGuiTest(wiimote);
expansionFrame.setDefaultCloseOperation(expansionFrame.HIDE_ON_CLOSE); expansionFrame.setDefaultCloseOperation(NunchukGuiTest.HIDE_ON_CLOSE);
expansionFrame.addWindowListener(buttonSetter); expansionFrame.addWindowListener(buttonSetter);
} }
@@ -1188,8 +1188,7 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
private void reconnectWiimotesButtonMousePressed( private void reconnectWiimotesButtonMousePressed(
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_reconnectWiimotesButtonMousePressed java.awt.event.MouseEvent evt) {// GEN-FIRST:event_reconnectWiimotesButtonMousePressed
// stop manager // stop manager
WiiUseApiManager manager = WiiUseApiManager.getInstance(); WiiUseApiManager.shutdown();
manager.shutdown();
// unregister previous wiimote // unregister previous wiimote
if (wiimote != null) { if (wiimote != null) {

View File

@@ -21,6 +21,7 @@ import wiiusej.wiiusejevents.GenericEvent;
import wiiusej.wiiusejevents.physicalevents.NunchukEvent; import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
/** /**
* Panel to display Acceleration in a MotionSensingEvent from an expansion.
* *
* @author guiguito * @author guiguito
*/ */
@@ -29,7 +30,8 @@ public class AccelerationExpansionEventPanel extends AccelerationPanel{
@Override @Override
public RawAcceleration getRawAccelerationValue(GenericEvent e) { public RawAcceleration getRawAccelerationValue(GenericEvent e) {
if (e instanceof NunchukEvent) { if (e instanceof NunchukEvent) {
return ((NunchukEvent)e).getNunchukMotionSensingEvent().getRawAcceleration(); return ((NunchukEvent) e).getNunchukMotionSensingEvent()
.getRawAcceleration();
} }
return null; return null;
} }

View File

@@ -158,7 +158,8 @@ public abstract class AccelerationPanel extends javax.swing.JPanel implements
*/ */
private void checkOffScreenImage() { private void checkOffScreenImage() {
Dimension d = getSize(); Dimension d = getSize();
if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { if (mImage == null || mImage.getWidth(null) != d.width
|| mImage.getHeight(null) != d.height) {
mImage = createImage(d.width, d.height); mImage = createImage(d.width, d.height);
} }
} }
@@ -204,7 +205,8 @@ public abstract class AccelerationPanel extends javax.swing.JPanel implements
values.clear(); values.clear();
} }
RawAcceleration rawAcceleration = getRawAccelerationValue(arg0); RawAcceleration rawAcceleration = getRawAccelerationValue(arg0);
if (rawAcceleration != null) values.add(rawAcceleration); if (rawAcceleration != null)
values.add(rawAcceleration);
repaint(); repaint();
} }

View File

@@ -21,7 +21,7 @@ import wiiusej.wiiusejevents.GenericEvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
/** /**
* * Panel to display Acceleration in a MotionSensingEvent from a wiimote.
* @author guiguito * @author guiguito
*/ */
public class AccelerationWiimoteEventPanel extends AccelerationPanel { public class AccelerationWiimoteEventPanel extends AccelerationPanel {

View File

@@ -37,8 +37,8 @@ import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/** /**
* This panel is used to see what buttons are pressed. It displays the result of * This panel is used to see what buttons are pressed on the wiimote. It
* last ButtonsEvent. * displays the result of last ButtonsEvent.
* *
* @author guiguito * @author guiguito
*/ */

View File

@@ -21,6 +21,7 @@ import wiiusej.wiiusejevents.GenericEvent;
import wiiusej.wiiusejevents.physicalevents.NunchukEvent; import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
/** /**
* Panel to display GForce in a MotionSensingEvent from an expansion.
* *
* @author guiguito * @author guiguito
*/ */

View File

@@ -42,7 +42,8 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
* *
* @author guiguito * @author guiguito
*/ */
public abstract class GForcePanel extends javax.swing.JPanel implements WiimoteListener { public abstract class GForcePanel extends javax.swing.JPanel implements
WiimoteListener {
private Image mImage;// image for double buffering private Image mImage;// image for double buffering
private Color xColor = Color.RED; private Color xColor = Color.RED;
@@ -206,7 +207,8 @@ public abstract class GForcePanel extends javax.swing.JPanel implements WiimoteL
values.clear(); values.clear();
} }
GForce gforce = getGForceValue(arg0); GForce gforce = getGForceValue(arg0);
if (gforce != null) values.add(gforce); if (gforce != null)
values.add(gforce);
repaint(); repaint();
} }

View File

@@ -21,6 +21,7 @@ import wiiusej.wiiusejevents.GenericEvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
/** /**
* Panel to display GForce in a MotionSensingEvent from a wiimote.
* *
* @author guiguito * @author guiguito
*/ */

View File

@@ -37,6 +37,7 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/** /**
* This panel is used to see what the IR camera of the wiimote sees. * This panel is used to see what the IR camera of the wiimote sees.
*
* @author guiguito * @author guiguito
*/ */
public class IRPanel extends javax.swing.JPanel implements WiimoteListener { public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
@@ -52,11 +53,9 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
private int nbPoints = -1; private int nbPoints = -1;
/** /**
* Default constructor for IR Panel. * Default constructor for IR Panel. Background color : black. IR sources
* Background color : black. * color : yellow. Border color of IR sources : blue. Shape of the IR
* IR sources color : yellow. * sources : circle with a diameter of 10.
* Border color of IR sources : blue.
* Shape of the IR sources : circle with a diameter of 10.
*/ */
public IRPanel() { public IRPanel() {
shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10); shape = new java.awt.geom.Ellipse2D.Double(0, 0, 10, 10);
@@ -66,10 +65,15 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
/** /**
* Constructor used to parameterize the IR panel. * Constructor used to parameterize the IR panel.
* @param bgColor color. *
* @param ptColor IR sources color. * @param bgColor
* @param bdColor border color of IR sources. * color.
* @param sh Shape of the IR sources. * @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) { public IRPanel(Color bgColor, Color ptColor, Color bdColor, Shape sh) {
backgroundColor = bgColor; backgroundColor = bgColor;
@@ -98,7 +102,8 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
offG.setColor(backgroundColor); offG.setColor(backgroundColor);
offG.fillRect(0, 0, d.width, d.height); offG.fillRect(0, 0, d.width, d.height);
Graphics2D g2 = (Graphics2D) mImage.getGraphics(); Graphics2D g2 = (Graphics2D) mImage.getGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
// draw points // draw points
int i = 0; int i = 0;
@@ -107,7 +112,8 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
double y = yCoordinates[i]; double y = yCoordinates[i];
long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0); long xx = getWidth() - Math.round((double) getWidth() * x / 1024.0);
long yy = getHeight() - Math.round((double) getHeight() * y / 768.0); long yy = getHeight()
- Math.round((double) getHeight() * y / 768.0);
g2.translate(xx, yy); g2.translate(xx, yy);
g2.setPaint(borderColor); g2.setPaint(borderColor);
@@ -123,12 +129,14 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
} }
/** /**
* check if the mImage variable has been initialized. If it's not the case it initializes it * check if the mImage variable has been initialized. If it's not the case
* with the dimensions of the panel. mImage is for double buffering. * it initializes it with the dimensions of the panel. mImage is for double
* buffering.
*/ */
private void checkOffScreenImage() { private void checkOffScreenImage() {
Dimension d = getSize(); Dimension d = getSize();
if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { if (mImage == null || mImage.getWidth(null) != d.width
|| mImage.getHeight(null) != d.height) {
mImage = createImage(d.width, d.height); mImage = createImage(d.width, d.height);
} }
} }
@@ -222,24 +230,23 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
repaint(); repaint();
} }
/** This method is called from within the constructor to /**
* initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is always
* always regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated
// Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(layout.createParallelGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
.addGap(0, 400, Short.MAX_VALUE) Short.MAX_VALUE));
); layout.setVerticalGroup(layout.createParallelGroup(
layout.setVerticalGroup( javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) Short.MAX_VALUE));
.addGap(0, 300, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables

View File

@@ -37,9 +37,11 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/** /**
* Panel to display joystick events. * Panel to display joystick events.
*
* @author guiguito * @author guiguito
*/ */
public abstract class JoystickEventPanel extends javax.swing.JPanel implements WiimoteListener { public abstract class JoystickEventPanel extends javax.swing.JPanel implements
WiimoteListener {
private Image mImage;// image for double buffering private Image mImage;// image for double buffering
private Color backgroundColor = Color.BLACK; private Color backgroundColor = Color.BLACK;
@@ -65,7 +67,8 @@ public abstract class JoystickEventPanel extends javax.swing.JPanel implements W
* @param sh * @param sh
* shape of what is drawn. * shape of what is drawn.
*/ */
public JoystickEventPanel(Color bgColor, Color pColor, Color bdColor, Shape sh) { public JoystickEventPanel(Color bgColor, Color pColor, Color bdColor,
Shape sh) {
backgroundColor = bgColor; backgroundColor = bgColor;
pointColor = pColor; pointColor = pColor;
shape = sh; shape = sh;
@@ -92,8 +95,12 @@ public abstract class JoystickEventPanel extends javax.swing.JPanel implements W
// compute coordinates // compute coordinates
if (lastJoystickEvent != null) { if (lastJoystickEvent != null) {
double xAng = Math.sin(lastJoystickEvent.getAngle() * Math.PI / 180.0) * lastJoystickEvent.getMagnitude(); double xAng = Math.sin(lastJoystickEvent.getAngle() * Math.PI
double yAng = Math.cos(lastJoystickEvent.getAngle() * Math.PI / 180.0) * lastJoystickEvent.getMagnitude(); / 180.0)
* lastJoystickEvent.getMagnitude();
double yAng = Math.cos(lastJoystickEvent.getAngle() * Math.PI
/ 180.0)
* lastJoystickEvent.getMagnitude();
int dx = (int) Math.round(shape.getBounds().getWidth() / 2); int dx = (int) Math.round(shape.getBounds().getWidth() / 2);
int dy = (int) Math.round(shape.getBounds().getHeight() / 2); int dy = (int) Math.round(shape.getBounds().getHeight() / 2);
double xTemp = xAng * (xCenter - dx * 2); double xTemp = xAng * (xCenter - dx * 2);
@@ -125,7 +132,8 @@ public abstract class JoystickEventPanel extends javax.swing.JPanel implements W
*/ */
private void checkOffScreenImage() { private void checkOffScreenImage() {
Dimension d = getSize(); Dimension d = getSize();
if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) { if (mImage == null || mImage.getWidth(null) != d.width
|| mImage.getHeight(null) != d.height) {
mImage = createImage(d.width, d.height); mImage = createImage(d.width, d.height);
} }
} }
@@ -200,24 +208,23 @@ public abstract class JoystickEventPanel extends javax.swing.JPanel implements W
public abstract JoystickEvent getJoystikEvent(ExpansionEvent e); public abstract JoystickEvent getJoystikEvent(ExpansionEvent e);
/** This method is called from within the constructor to /**
* initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is always
* always regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated
// Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(layout.createParallelGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
.addGap(0, 400, Short.MAX_VALUE) Short.MAX_VALUE));
); layout.setVerticalGroup(layout.createParallelGroup(
layout.setVerticalGroup( javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) Short.MAX_VALUE));
.addGap(0, 300, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables

View File

@@ -22,6 +22,7 @@ import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
/** /**
* Panel to display nunchuk joystick events. * Panel to display nunchuk joystick events.
*
* @author guiguito * @author guiguito
*/ */
public class NunchukJoystickEventPanel extends JoystickEventPanel { public class NunchukJoystickEventPanel extends JoystickEventPanel {

View File

@@ -21,6 +21,7 @@ import wiiusej.wiiusejevents.GenericEvent;
import wiiusej.wiiusejevents.physicalevents.NunchukEvent; import wiiusej.wiiusejevents.physicalevents.NunchukEvent;
/** /**
* Panel to display Orientation in a MotionSensingEvent from an expansion.
* *
* @author guiguito * @author guiguito
*/ */
@@ -29,7 +30,8 @@ public class OrientationExpansionEventPanel extends OrientationPanel {
@Override @Override
public Orientation getOrientationValue(GenericEvent e) { public Orientation getOrientationValue(GenericEvent e) {
if (e instanceof NunchukEvent) { if (e instanceof NunchukEvent) {
return ((NunchukEvent) e).getNunchukMotionSensingEvent().getOrientation(); return ((NunchukEvent) e).getNunchukMotionSensingEvent()
.getOrientation();
} }
return null; return null;
} }

View File

@@ -208,7 +208,8 @@ public abstract class OrientationPanel extends javax.swing.JPanel implements
values.clear(); values.clear();
} }
Orientation orientation = getOrientationValue(arg0); Orientation orientation = getOrientationValue(arg0);
if (orientation != null) values.add(orientation); if (orientation != null)
values.add(orientation);
repaint(); repaint();
} }

View File

@@ -21,6 +21,7 @@ import wiiusej.wiiusejevents.GenericEvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
/** /**
* Panel to display Orientation in a MotionSensingEvent from a wiimote.
* *
* @author guiguito * @author guiguito
*/ */

View File

@@ -18,6 +18,7 @@ package wiiusej.values;
/** /**
* Represents gravity force on each axis. * Represents gravity force on each axis.
*
* @author guiguito * @author guiguito
*/ */
public class GForce { public class GForce {
@@ -37,9 +38,13 @@ public class GForce {
/** /**
* Constructor with gravity force on each axis. * Constructor with gravity force on each axis.
* @param xx x value *
* @param yy x value * @param xx
* @param zz x value * x value
* @param yy
* x value
* @param zz
* x value
*/ */
public GForce(float xx, float yy, float zz) { public GForce(float xx, float yy, float zz) {
x = xx; x = xx;

View File

@@ -18,6 +18,7 @@ package wiiusej.values;
/** /**
* Class used for IR sources. * Class used for IR sources.
*
* @author guiguito * @author guiguito
*/ */
public class IRSource { public class IRSource {
@@ -50,60 +51,56 @@ public class IRSource{
size = si; size = si;
} }
/** /**
* Return x interpolated coordinates. * Return x interpolated coordinates.
*
* @return the x * @return the x
*/ */
public int getX() { public int getX() {
return x; return x;
} }
/** /**
* Return y interpolated coordinates. * Return y interpolated coordinates.
*
* @return the y * @return the y
*/ */
public int getY() { public int getY() {
return y; return y;
} }
/** /**
* Return raw X coordinate (0-1023). * Return raw X coordinate (0-1023).
*
* @return the rx * @return the rx
*/ */
public short getRx() { public short getRx() {
return rx; return rx;
} }
/** /**
* Return raw Y coordinate (0-1023). * Return raw Y coordinate (0-1023).
*
* @return the ry * @return the ry
*/ */
public short getRy() { public short getRy() {
return ry; return ry;
} }
/** /**
* Return size of the IR dot (0-15). * Return size of the IR dot (0-15).
*
* @return the size * @return the size
*/ */
public short getSize() { public short getSize() {
return size; return size;
} }
@Override @Override
public String toString() { public String toString() {
return "Interpolated coordinates ("+x+","+y+"), Raw coordinates("+rx+","+ry+"), source size : "+size+")"; return "Interpolated coordinates (" + x + "," + y
+ "), Raw coordinates(" + rx + "," + ry + "), source size : "
+ size + ")";
} }
} }

View File

@@ -18,6 +18,7 @@ package wiiusej.values;
/** /**
* Represents raw acceleration on each axis. * Represents raw acceleration on each axis.
*
* @author guiguito * @author guiguito
*/ */
public class RawAcceleration { public class RawAcceleration {
@@ -37,9 +38,13 @@ public class RawAcceleration {
/** /**
* Constructor with raw acceleration on each axis. * Constructor with raw acceleration on each axis.
* @param xx x value *
* @param yy x value * @param xx
* @param zz x value * x value
* @param yy
* x value
* @param zz
* x value
*/ */
public RawAcceleration(short xx, short yy, short zz) { public RawAcceleration(short xx, short yy, short zz) {
x = xx; x = xx;
@@ -53,6 +58,7 @@ public class RawAcceleration {
public short getX() { public short getX() {
return x; return x;
} }
/** /**
* @return the y * @return the y
*/ */

View File

@@ -20,6 +20,7 @@ import wiiusej.wiiusejevents.GenericEvent;
/** /**
* Class which represents a buttons event. * Class which represents a buttons event.
*
* @author guiguito * @author guiguito
*/ */
public abstract class ButtonsEvent extends GenericEvent { public abstract class ButtonsEvent extends GenericEvent {
@@ -31,10 +32,15 @@ public abstract class ButtonsEvent extends GenericEvent{
/** /**
* Constructor of the button Event. * Constructor of the button Event.
* @param id id of the wiimote concerned. *
* @param buttonsJustPressed buttons just pressed. * @param id
* @param buttonsJustReleased buttons just released. * id of the wiimote concerned.
* @param buttonsHeld buttons just held. * @param buttonsJustPressed
* buttons just pressed.
* @param buttonsJustReleased
* buttons just released.
* @param buttonsHeld
* buttons just held.
*/ */
public ButtonsEvent(int id, short buttonsJustPressed, public ButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) { short buttonsJustReleased, short buttonsHeld) {
@@ -104,7 +110,8 @@ public abstract class ButtonsEvent extends GenericEvent{
} }
protected boolean isButtonPressed(short buttonBitsDefinition) { protected boolean isButtonPressed(short buttonBitsDefinition) {
return isButtonHeld(buttonBitsDefinition)||isButtonJustPressed(buttonBitsDefinition); return isButtonHeld(buttonBitsDefinition)
|| isButtonJustPressed(buttonBitsDefinition);
} }
@Override @Override

View File

@@ -18,17 +18,18 @@ package wiiusej.wiiusejevents.physicalevents;
import wiiusej.wiiusejevents.GenericEvent; import wiiusej.wiiusejevents.GenericEvent;
/** /**
* Mother Class of all expansions. * Mother Class of all expansions event.
*
* @author guiguito * @author guiguito
*/ */
public abstract class ExpansionEvent extends GenericEvent { public abstract class ExpansionEvent extends GenericEvent {
/** /**
* Constructor of an ExpansionEvent. * Constructor of an ExpansionEvent.
* @param id id of the wiimote to which the expansion is connected. *
* @param id
* id of the wiimote to which the expansion is connected.
*/ */
public ExpansionEvent(int id) { public ExpansionEvent(int id) {
super(id); super(id);

View File

@@ -30,10 +30,15 @@ public class NunchukButtonsEvent extends ButtonsEvent {
/** /**
* Constructor of the nunchuk button Event. * Constructor of the nunchuk button Event.
* @param id id of the wiimote. *
* @param buttonsJustPressed buttons just pressed. * @param id
* @param buttonsJustReleased buttons just released. * id of the wiimote.
* @param buttonsHeld buttons just pressed. * @param buttonsJustPressed
* buttons just pressed.
* @param buttonsJustReleased
* buttons just released.
* @param buttonsHeld
* buttons just pressed.
*/ */
public NunchukButtonsEvent(int id, short buttonsJustPressed, public NunchukButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) { short buttonsJustReleased, short buttonsHeld) {
@@ -82,5 +87,4 @@ public class NunchukButtonsEvent extends ButtonsEvent {
+ super.toString(); + super.toString();
} }
} }

View File

@@ -104,8 +104,6 @@ public class NunchukEvent extends ExpansionEvent {
max2, min1, min2, center1, center2); max2, min1, min2, center1, center2);
} }
/** /**
* Tell if there is a nunchuk motion sensing Event. * Tell if there is a nunchuk motion sensing Event.
* *

View File

@@ -45,10 +45,15 @@ public class WiimoteButtonsEvent extends ButtonsEvent {
/** /**
* Constructor of the wiimote button Event. * Constructor of the wiimote button Event.
* @param id id of the wiimote. *
* @param buttonsJustPressed buttons just pressed. * @param id
* @param buttonsJustReleased buttons just released. * id of the wiimote.
* @param buttonsHeld buttons held. * @param buttonsJustPressed
* buttons just pressed.
* @param buttonsJustReleased
* buttons just released.
* @param buttonsHeld
* buttons held.
*/ */
public WiimoteButtonsEvent(int id, short buttonsJustPressed, public WiimoteButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) { short buttonsJustReleased, short buttonsHeld) {

View File

@@ -103,9 +103,10 @@ public class EventsGatherer {
* @param distance * @param distance
* Pixel Distance between first two dots. * Pixel Distance between first two dots.
*/ */
public void prepareIRevent(int x, int y, float z, int ax, int ay, int xVRes, public void prepareIRevent(int x, int y, float z, int ax, int ay,
int yVRes, int xOffset, int yOffset, short sensorBarPostion, int xVRes, int yVRes, int xOffset, int yOffset,
short screenAsPectRatio, short irSensitivity, float distance) { short sensorBarPostion, short screenAsPectRatio,
short irSensitivity, float distance) {
genericEvent.prepareIRevent(x, y, z, ax, ay, xVRes, yVRes, xOffset, genericEvent.prepareIRevent(x, y, z, ax, ay, xVRes, yVRes, xOffset,
yOffset, sensorBarPostion, screenAsPectRatio, irSensitivity, yOffset, sensorBarPostion, screenAsPectRatio, irSensitivity,
distance); distance);
@@ -238,19 +239,20 @@ public class EventsGatherer {
* @param center2 * @param center2
* center joystick value 2. * center joystick value 2.
*/ */
public void addNunchunkEventToPreparedWiimoteEvent(short buttonsJustPressed, public void addNunchunkEventToPreparedWiimoteEvent(
short buttonsJustReleased, short buttonsHeld, short buttonsJustPressed, short buttonsJustReleased,
float orientationThreshold, int accelerationThreshold, short buttonsHeld, float orientationThreshold,
boolean smoothingState, float alphaSmooth, float r, float p, int accelerationThreshold, boolean smoothingState,
float ya, float ar, float ap, float x, float y, float z, short xx, float alphaSmooth, float r, float p, float ya, float ar, float ap,
short yy, short zz, float angle, float magnitude, short max1, float x, float y, float z, short xx, short yy, short zz,
short max2, short min1, short min2, short center1, short center2){ float angle, float magnitude, short max1, short max2, short min1,
short min2, short center1, short center2) {
if (genericEvent != null) { if (genericEvent != null) {
genericEvent.setNunchukEvent(buttonsJustPressed, genericEvent.setNunchukEvent(buttonsJustPressed,
buttonsJustReleased, buttonsHeld, orientationThreshold, buttonsJustReleased, buttonsHeld, orientationThreshold,
accelerationThreshold, smoothingState, alphaSmooth, r, p, ya, accelerationThreshold, smoothingState, alphaSmooth, r, p,
ar, ap, x, y, z, xx, yy, zz, angle, magnitude, max1, max2, ya, ar, ap, x, y, z, xx, yy, zz, angle, magnitude, max1,
min1, min2, center1, center2); max2, min1, min2, center1, center2);
} }
} }

View File

@@ -18,8 +18,6 @@ package wiiusej.wiiusejevents.utils;
import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent; import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
/** /**
* This is the interface to implement to listen to events from the wiiuse API. * This is the interface to implement to listen to events from the wiiuse API.
* *
@@ -28,12 +26,10 @@ import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
public interface WiiUseApiListener extends java.util.EventListener { public interface WiiUseApiListener extends java.util.EventListener {
/** /**
* Method called when a WiiUseApiEvent occurs. * Method called when a WiiUseApiEvent occurs. A WiiUseApiEvent can be : -
* A WiiUseApiEvent can be : * WiimoteEvent (Storing ButtonsEvent and eventually IREvent and
* - WiimoteEvent (Storing ButtonsEvent and * MotionSensingEvent) - StatusEvent - DisconnectionEvent
* eventually IREvent and MotionSensingEvent) *
* - StatusEvent
* - DisconnectionEvent
* @param e * @param e
*/ */
void onWiiUseApiEvent(WiiUseApiEvent e); void onWiiUseApiEvent(WiiUseApiEvent e);

View File

@@ -26,9 +26,10 @@ import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent; import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
/** /**
* This is the interface to implement to listen to events from wiimotes. * This is the interface to implement to listen to events from wiimotes. The
* The differents methods are called in this order : * differents methods are called in this order : onButtonsEvent, onIrEvent,
* onButtonsEvent, onIrEvent, onMotionSensingEvent, onStatusEvent, onDisconnectionEvent. * onMotionSensingEvent, onExpansionEvent, onStatusEvent, onDisconnectionEvent
* onNunchukInsertedEvent, onNunchukRemovedEvent.
* *
* @author guiguito * @author guiguito
*/ */
@@ -36,60 +37,71 @@ public interface WiimoteListener extends java.util.EventListener {
/** /**
* Method called on a button Event. * Method called on a button Event.
* @param e the buttonEvent with the last informations *
* about the buttons of the wiimote. * @param e
* the buttonEvent with the last informations about the buttons
* of the wiimote.
*/ */
void onButtonsEvent(WiimoteButtonsEvent e); void onButtonsEvent(WiimoteButtonsEvent e);
/** /**
* Method called when an IR event occurs. * Method called when an IR event occurs.
* @param e the IREvent with the IR points seen. *
* @param e
* the IREvent with the IR points seen.
*/ */
void onIrEvent(IREvent e); void onIrEvent(IREvent e);
/** /**
* Method called when a motion sensing event occurs. * Method called when a motion sensing event occurs.
* @param e the motion sensing event with orientation and acceleration. *
* @param e
* the motion sensing event with orientation and acceleration.
*/ */
void onMotionSensingEvent(MotionSensingEvent e); void onMotionSensingEvent(MotionSensingEvent e);
/** /**
* Method called when an expansion event occurs. * Method called when an expansion event occurs.
* @param e the expansion event occured. *
* @param e
* the expansion event occured.
*/ */
void onExpansionEvent(ExpansionEvent e); void onExpansionEvent(ExpansionEvent e);
/** /**
* Method called on a status event. * Method called on a status event. A status event occurs when : - we ask it -
* A status event occurs when : * an expansion controller has been plugged - an expansion controller has
* - we ask it * been unplugged This is where you can get the different values of the
* - an expansion controller has been plugged * parameters setup on your wiimote.
* - an expansion controller has been unplugged *
* This is where you can get the different values of * @param e
* the parameters setup on your wiimote. * the status event.
* @param e the status event.
*/ */
void onStatusEvent(StatusEvent e); void onStatusEvent(StatusEvent e);
/** /**
* This is the method called when a disconnection event occurs. * This is the method called when a disconnection event occurs. A
* A disconnection event happens when : * disconnection event happens when : - there are no battery left - the
* - there are no battery left * wiimote has just been turned off - the connection is dropped
* - the wiimote has just been turned off *
* - the connection is dropped * @param e
* @param e the disconnection event. * the disconnection event.
*/ */
void onDisconnectionEvent(DisconnectionEvent e); void onDisconnectionEvent(DisconnectionEvent e);
/** /**
* This is the method called when a NunchukInsertedEvent occurs. * This is the method called when a NunchukInsertedEvent occurs.
* @param e the NunchukInsertedEvent. *
* @param e
* the NunchukInsertedEvent.
*/ */
void onNunchukInsertedEvent(NunchukInsertedEvent e); void onNunchukInsertedEvent(NunchukInsertedEvent e);
/** /**
* This is the method called when a NunchukRemovedEvent occurs. * This is the method called when a NunchukRemovedEvent occurs.
* @param e the NunchukRemovedEvent. *
* @param e
* the NunchukRemovedEvent.
*/ */
void onNunchukRemovedEvent(NunchukRemovedEvent e); void onNunchukRemovedEvent(NunchukRemovedEvent e);
} }

View File

@@ -16,9 +16,9 @@
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
/** /**
* Class representing a disconnection event. * Class representing a disconnection event.
*
* @author guiguito * @author guiguito
*/ */
public class DisconnectionEvent extends WiiUseApiEvent { public class DisconnectionEvent extends WiiUseApiEvent {
@@ -37,7 +37,8 @@ public class DisconnectionEvent extends WiiUseApiEvent {
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :" + super.getWiimoteId() + " ********/\n"; out += "/*********** DISCONNECTION EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n";
return out; return out;
} }

View File

@@ -16,9 +16,9 @@
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
/** /**
* Event that represents the connection of a nunchuk to a wiimote. * Event that represents the connection of a nunchuk to a wiimote.
*
* @author guiguito * @author guiguito
* *
*/ */
@@ -26,20 +26,25 @@ public class NunchukInsertedEvent extends WiiUseApiEvent {
/** /**
* Construct the NunchukInsertedEvent setting up the id. * Construct the NunchukInsertedEvent setting up the id.
* @param id id of the wiimote. *
* @param id
* id of the wiimote.
*/ */
public NunchukInsertedEvent(int id) { public NunchukInsertedEvent(int id) {
super(id, WIIUSE_NUNCHUK_INSERTED); super(id, WIIUSE_NUNCHUK_INSERTED);
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see wiiusej.wiiusejevents.WiiUseApiEvent#toString() * @see wiiusej.wiiusejevents.WiiUseApiEvent#toString()
*/ */
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** NUNCHUK INSERTED EVENT : WIIMOTE ID :" + super.getWiimoteId() + " ********/\n"; out += "/*********** NUNCHUK INSERTED EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n";
return out; return out;
} }

View File

@@ -16,29 +16,34 @@
*/ */
package wiiusej.wiiusejevents.wiiuseapievents; package wiiusej.wiiusejevents.wiiuseapievents;
/** /**
* Event that represents the connection of a nunchuk to a wiimote. * Event that represents the connection of a nunchuk to a wiimote.
*
* @author guiguito * @author guiguito
*/ */
public class NunchukRemovedEvent extends WiiUseApiEvent { public class NunchukRemovedEvent extends WiiUseApiEvent {
/** /**
* Construct the NunchukInsertedEvent setting up the id. * Construct the NunchukInsertedEvent setting up the id.
* @param id id of the wiimote. *
* @param id
* id of the wiimote.
*/ */
public NunchukRemovedEvent(int id) { public NunchukRemovedEvent(int id) {
super(id, WIIUSE_NUNCHUK_REMOVED); super(id, WIIUSE_NUNCHUK_REMOVED);
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see wiiusej.wiiusejevents.WiiUseApiEvent#toString() * @see wiiusej.wiiusejevents.WiiUseApiEvent#toString()
*/ */
@Override @Override
public String toString() { public String toString() {
String out = ""; String out = "";
/* Status */ /* Status */
out += "/*********** NUNCHUK REMOVED EVENT : WIIMOTE ID :" + super.getWiimoteId() + " ********/\n"; out += "/*********** NUNCHUK REMOVED EVENT : WIIMOTE ID :"
+ super.getWiimoteId() + " ********/\n";
return out; return out;
} }

View File

@@ -157,9 +157,10 @@ public class WiimoteEvent extends WiiUseApiEvent {
* @param distance * @param distance
* Pixel Distance between first two dots * Pixel Distance between first two dots
*/ */
public void prepareIRevent(int x, int y, float z, int ax, int ay, int xVRes, public void prepareIRevent(int x, int y, float z, int ax, int ay,
int yVRes, int xOffset, int yOffset, short sensorBarPostion, int xVRes, int yVRes, int xOffset, int yOffset,
short screenAsPectRatio, short irSensitivity, float distance) { short sensorBarPostion, short screenAsPectRatio,
short irSensitivity, float distance) {
if (infraredEvent == null) { if (infraredEvent == null) {
infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes, infraredEvent = new IREvent(getWiimoteId(), x, y, z, ax, ay, xVRes,
yVRes, xOffset, yOffset, sensorBarPostion, yVRes, xOffset, yOffset, sensorBarPostion,