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

View File

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

View File

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

View File

@@ -37,10 +37,12 @@ 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 {
public class NunchukGuiTest extends javax.swing.JFrame implements
WiimoteListener {
private Wiimote wiimote;
private boolean isThresholdsRequested = true;
@@ -56,15 +58,20 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
wiimote.addWiiMoteEventListeners(this);
wiimote.addWiiMoteEventListeners((OrientationPanel) orientationPanel);
wiimote.addWiiMoteEventListeners((GForcePanel) gForcePanel);
wiimote.addWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
wiimote.addWiiMoteEventListeners((NunchukJoystickEventPanel)joystickEventsPanel);
wiimote
.addWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
wiimote
.addWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel);
}
public void unRegisterListeners() {
wiimote.removeWiiMoteEventListeners((OrientationPanel) orientationPanel);
wiimote
.removeWiiMoteEventListeners((OrientationPanel) orientationPanel);
wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel);
wiimote.removeWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
wiimote.removeWiiMoteEventListeners((NunchukJoystickEventPanel)joystickEventsPanel);
wiimote
.removeWiiMoteEventListeners((AccelerationPanel) rawAccelerationPanel);
wiimote
.removeWiiMoteEventListeners((NunchukJoystickEventPanel) joystickEventsPanel);
wiimote.removeWiiMoteEventListeners(this);
}
@@ -72,16 +79,17 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
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.
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated
// Code">//GEN-BEGIN:initComponents
private void initComponents() {
topPanels = new javax.swing.JPanel();
joystickEventsPanel = joystickEventsPanel = new NunchukJoystickEventPanel();
joystickEventsPanel = new NunchukJoystickEventPanel();
motionSensingEventsPanel = new javax.swing.JPanel();
motionSensingEventsTabbedPanels = new javax.swing.JTabbedPane();
rawAccelerationPanel = new AccelerationExpansionEventPanel();
@@ -102,97 +110,120 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
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.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.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.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);
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)
);
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");
joystickEventsPanel.getAccessibleContext()
.setAccessibleName("Joystick");
motionSensingEventsPanel.setMinimumSize(new java.awt.Dimension(200, 200));
motionSensingEventsPanel
.setMinimumSize(new java.awt.Dimension(200, 200));
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);
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)
);
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);
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);
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)
);
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);
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)
);
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);
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)
);
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));
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));
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));
@@ -208,11 +239,13 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
setNunchukValuesPanel.add(nunchukButtonsEventPanel);
nunchukOrientationTextField.setPreferredSize(new java.awt.Dimension(60, 20));
nunchukOrientationTextField.setPreferredSize(new java.awt.Dimension(60,
20));
nunchukOrientationPanel.add(nunchukOrientationTextField);
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) {
nunchukOrientationButtonMousePressed(evt);
}
@@ -221,11 +254,13 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
setNunchukValuesPanel.add(nunchukOrientationPanel);
nunchukAccelerationTextField.setPreferredSize(new java.awt.Dimension(60, 20));
nunchukAccelerationTextField.setPreferredSize(new java.awt.Dimension(
60, 20));
nunchukAccelerationPanel.add(nunchukAccelerationTextField);
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) {
nunchukAccelerationButtonMousePressed(evt);
}
@@ -236,26 +271,45 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
messageText.setText("Message:");
javax.swing.GroupLayout messagePanelLayout = new javax.swing.GroupLayout(messagePanel);
javax.swing.GroupLayout messagePanelLayout = new javax.swing.GroupLayout(
messagePanel);
messagePanel.setLayout(messagePanelLayout);
messagePanelLayout.setHorizontalGroup(
messagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
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)
.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)))
);
.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);
@@ -263,23 +317,28 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
pack();
}// </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 {
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 !");
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
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 !");
messageText
.setText("Number is not an integer, nunchuk acceleration threshold not set !");
}
}// GEN-LAST:event_nunchukAccelerationButtonMousePressed
@@ -313,8 +372,12 @@ public class NunchukGuiTest extends javax.swing.JFrame implements WiimoteListene
}
if (isThresholdsRequested) {
MotionSensingEvent evt = nunchuk.getNunchukMotionSensingEvent();
nunchukAccelerationTextField.setText(evt.getAccelerationThreshold()+"");
nunchukOrientationTextField.setText(evt.getOrientationThreshold()+"");
nunchukAccelerationTextField.setText(evt
.getAccelerationThreshold()
+ "");
nunchukOrientationTextField.setText(evt
.getOrientationThreshold()
+ "");
isThresholdsRequested = false;
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -21,7 +21,7 @@ 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 {

View File

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

View File

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

View File

@@ -42,7 +42,8 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
*
* @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 Color xColor = Color.RED;
@@ -206,7 +207,8 @@ public abstract class GForcePanel extends javax.swing.JPanel implements WiimoteL
values.clear();
}
GForce gforce = getGForceValue(arg0);
if (gforce != null) values.add(gforce);
if (gforce != null)
values.add(gforce);
repaint();
}

View File

@@ -21,6 +21,7 @@ import wiiusej.wiiusejevents.GenericEvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
/**
* Panel to display GForce in a MotionSensingEvent from a wiimote.
*
* @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.
*
* @author guiguito
*/
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;
/**
* 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.
* 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);
@@ -66,10 +65,15 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
/**
* 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.
*
* @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;
@@ -98,7 +102,8 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
offG.setColor(backgroundColor);
offG.fillRect(0, 0, d.width, d.height);
Graphics2D g2 = (Graphics2D) mImage.getGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
// draw points
int i = 0;
@@ -107,7 +112,8 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
double y = yCoordinates[i];
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.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
* with the dimensions of the panel. mImage is for double buffering.
* check if the mImage variable has been initialized. If it's not the case
* it initializes it with the dimensions of the panel. mImage is for double
* buffering.
*/
private void checkOffScreenImage() {
Dimension d = getSize();
if (mImage == null || mImage.getWidth(null) != d.width || mImage.getHeight(null) != d.height) {
if (mImage == null || mImage.getWidth(null) != d.width
|| mImage.getHeight(null) != d.height) {
mImage = createImage(d.width, d.height);
}
}
@@ -222,24 +230,23 @@ public class IRPanel extends javax.swing.JPanel implements WiimoteListener {
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.
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated
// Code">//GEN-BEGIN:initComponents
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
layout.setHorizontalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
Short.MAX_VALUE));
layout.setVerticalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
Short.MAX_VALUE));
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,6 +18,7 @@ package wiiusej.values;
/**
* Class used for IR sources.
*
* @author guiguito
*/
public class IRSource {
@@ -50,60 +51,56 @@ public class IRSource{
size = si;
}
/**
* Return x interpolated coordinates.
*
* @return the x
*/
public int getX() {
return x;
}
/**
* Return y interpolated coordinates.
*
* @return the y
*/
public int getY() {
return y;
}
/**
* Return raw X coordinate (0-1023).
*
* @return the rx
*/
public short getRx() {
return rx;
}
/**
* Return raw Y coordinate (0-1023).
*
* @return the ry
*/
public short getRy() {
return ry;
}
/**
* Return size of the IR dot (0-15).
*
* @return the size
*/
public short getSize() {
return size;
}
@Override
public String toString() {
return "Interpolated coordinates ("+x+","+y+"), Raw coordinates("+rx+","+ry+"), source size : "+size+")";
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.
*
* @author guiguito
*/
public class RawAcceleration {
@@ -37,9 +38,13 @@ public class RawAcceleration {
/**
* Constructor with raw acceleration on each axis.
* @param xx x value
* @param yy x value
* @param zz x value
*
* @param xx
* x value
* @param yy
* x value
* @param zz
* x value
*/
public RawAcceleration(short xx, short yy, short zz) {
x = xx;
@@ -53,6 +58,7 @@ public class RawAcceleration {
public short getX() {
return x;
}
/**
* @return the y
*/

View File

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

View File

@@ -18,17 +18,18 @@ package wiiusej.wiiusejevents.physicalevents;
import wiiusej.wiiusejevents.GenericEvent;
/**
* Mother Class of all expansions.
* Mother Class of all expansions event.
*
* @author guiguito
*/
public abstract class ExpansionEvent extends GenericEvent {
/**
* 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) {
super(id);

View File

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

View File

@@ -104,8 +104,6 @@ public class NunchukEvent extends ExpansionEvent {
max2, min1, min2, center1, center2);
}
/**
* 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.
* @param id id of the wiimote.
* @param buttonsJustPressed buttons just pressed.
* @param buttonsJustReleased buttons just released.
* @param buttonsHeld buttons held.
*
* @param id
* id of the wiimote.
* @param buttonsJustPressed
* buttons just pressed.
* @param buttonsJustReleased
* buttons just released.
* @param buttonsHeld
* buttons held.
*/
public WiimoteButtonsEvent(int id, short buttonsJustPressed,
short buttonsJustReleased, short buttonsHeld) {

View File

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

View File

@@ -18,8 +18,6 @@ package wiiusej.wiiusejevents.utils;
import wiiusej.wiiusejevents.wiiuseapievents.WiiUseApiEvent;
/**
* 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 {
/**
* Method called when a WiiUseApiEvent occurs.
* A WiiUseApiEvent can be :
* - WiimoteEvent (Storing ButtonsEvent and
* eventually IREvent and MotionSensingEvent)
* - StatusEvent
* - DisconnectionEvent
* Method called when a WiiUseApiEvent occurs. A WiiUseApiEvent can be : -
* WiimoteEvent (Storing ButtonsEvent and eventually IREvent and
* MotionSensingEvent) - StatusEvent - DisconnectionEvent
*
* @param e
*/
void onWiiUseApiEvent(WiiUseApiEvent e);

View File

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

View File

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

View File

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

View File

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

View File

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