fixed reconnection. Added definitive close.
git-svn-id: http://wiiusej.googlecode.com/svn/trunk@156 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
@@ -47,6 +47,8 @@ public class WiiUseApiManager extends Thread {
|
||||
|
||||
private AtomicBoolean running = new AtomicBoolean(false);
|
||||
|
||||
private boolean leave = false;
|
||||
|
||||
public static int WIIUSE_STACK_UNKNOWN = 0;
|
||||
public static int WIIUSE_STACK_MS = 1;
|
||||
public static int WIIUSE_STACK_BLUESOLEIL = 2;
|
||||
@@ -247,6 +249,14 @@ public class WiiUseApiManager extends Thread {
|
||||
wiiuse.cleanUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop wiiuseJ definitively for this program.
|
||||
*/
|
||||
public void definitiveShutdown(){
|
||||
leave = true;
|
||||
shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the rumble for the wiimote with the given id.
|
||||
*
|
||||
@@ -548,7 +558,7 @@ public class WiiUseApiManager extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
while (true) {
|
||||
while (!leave) {
|
||||
try {
|
||||
semaphore.acquire();
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
@@ -30,11 +30,14 @@ public class Main {
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
|
||||
WiiuseJGuiTest gui = null;
|
||||
if (wiimotes.length > 0) {
|
||||
WiiuseJGuiTest gui = new WiiuseJGuiTest(wiimotes[0]);
|
||||
gui = new WiiuseJGuiTest(wiimotes[0]);
|
||||
} else {
|
||||
gui = new WiiuseJGuiTest();
|
||||
}
|
||||
gui.setDefaultCloseOperation(gui.EXIT_ON_CLOSE);
|
||||
gui.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,9 +46,11 @@ import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;
|
||||
|
||||
/**
|
||||
* Gui class to test WiiuseJ.
|
||||
*
|
||||
* @author guiguito
|
||||
*/
|
||||
public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListener {
|
||||
public class WiiuseJGuiTest extends javax.swing.JFrame implements
|
||||
WiimoteListener {
|
||||
|
||||
private Wiimote wiimote;
|
||||
private Robot robot = null;
|
||||
@@ -89,16 +91,28 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
}
|
||||
};
|
||||
|
||||
/** Creates new form WiiuseJGuiTest */
|
||||
/**
|
||||
* default constructor
|
||||
*/
|
||||
public WiiuseJGuiTest() {
|
||||
initComponents();
|
||||
this.addWindowListener(new CloseGuiTestCleanly());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form WiiuseJGuiTest
|
||||
*/
|
||||
public WiiuseJGuiTest(Wiimote wiimote) {
|
||||
initComponents();
|
||||
this.addWindowListener(new CloseGuiTestCleanly());
|
||||
if (wiimote != null) {
|
||||
this.wiimote = wiimote;
|
||||
registerListeners();
|
||||
initWiimote();
|
||||
isFirstStatusGot = false;
|
||||
getStatusButtonMousePressed(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all views
|
||||
@@ -117,9 +131,11 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
private void unregisterListeners() {
|
||||
wiimote.removeWiiMoteEventListeners((IRPanel) irViewPanel);
|
||||
wiimote.removeWiiMoteEventListeners((ButtonsEventPanel) buttonsPanel);
|
||||
wiimote.removeWiiMoteEventListeners((OrientationPanel) motionSensingPanel);
|
||||
wiimote
|
||||
.removeWiiMoteEventListeners((OrientationPanel) motionSensingPanel);
|
||||
wiimote.removeWiiMoteEventListeners((GForcePanel) gForcePanel);
|
||||
wiimote.removeWiiMoteEventListeners((AccelerationPanel) accelerationPanel);
|
||||
wiimote
|
||||
.removeWiiMoteEventListeners((AccelerationPanel) accelerationPanel);
|
||||
wiimote.removeWiiMoteEventListeners(this);
|
||||
}
|
||||
|
||||
@@ -195,8 +211,10 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
|
||||
public void onMotionSensingEvent(MotionSensingEvent arg0) {
|
||||
if (statusMotionRequested) {// Status requested
|
||||
accelerationThresholdTextField.setText("" + arg0.getAccelerationThreshold());
|
||||
orientationThresholdTextField.setText("" + arg0.getOrientationThreshold());
|
||||
accelerationThresholdTextField.setText(""
|
||||
+ arg0.getAccelerationThreshold());
|
||||
orientationThresholdTextField.setText(""
|
||||
+ arg0.getOrientationThreshold());
|
||||
alphaSmoothingTextField.setText("" + arg0.getAlphaSmoothing());
|
||||
statusMotionRequested = false;
|
||||
}
|
||||
@@ -212,7 +230,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
showExpansionWiimoteButton.setEnabled(true);
|
||||
showExpansionWiimoteButton.setText("Show Nunchuk");
|
||||
expansionFrame = new NunchukGuiTest(wiimote);
|
||||
expansionFrame.setDefaultCloseOperation(expansionFrame.HIDE_ON_CLOSE);
|
||||
expansionFrame
|
||||
.setDefaultCloseOperation(expansionFrame.HIDE_ON_CLOSE);
|
||||
expansionFrame.addWindowListener(buttonSetter);
|
||||
isFirstStatusGot = true;
|
||||
}
|
||||
@@ -275,12 +294,13 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
}
|
||||
}
|
||||
|
||||
/** 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() {
|
||||
|
||||
leftPanel = new javax.swing.JPanel();
|
||||
@@ -356,80 +376,100 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
leftPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
|
||||
|
||||
irViewPanel.setBackground(new java.awt.Color(0, 0, 0));
|
||||
irViewPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 153, 153), 2, true), "IR View", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 0, 51)));
|
||||
irViewPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
|
||||
new javax.swing.border.LineBorder(new java.awt.Color(0, 153,
|
||||
153), 2, true), "IR View",
|
||||
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
||||
javax.swing.border.TitledBorder.DEFAULT_POSITION,
|
||||
new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 0,
|
||||
51)));
|
||||
irViewPanel.setToolTipText("IREvent");
|
||||
|
||||
javax.swing.GroupLayout irViewPanelLayout = new javax.swing.GroupLayout(irViewPanel);
|
||||
javax.swing.GroupLayout irViewPanelLayout = new javax.swing.GroupLayout(
|
||||
irViewPanel);
|
||||
irViewPanel.setLayout(irViewPanelLayout);
|
||||
irViewPanelLayout.setHorizontalGroup(
|
||||
irViewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 272, Short.MAX_VALUE)
|
||||
);
|
||||
irViewPanelLayout.setVerticalGroup(
|
||||
irViewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 299, Short.MAX_VALUE)
|
||||
);
|
||||
irViewPanelLayout.setHorizontalGroup(irViewPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 272, Short.MAX_VALUE));
|
||||
irViewPanelLayout.setVerticalGroup(irViewPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 299, Short.MAX_VALUE));
|
||||
|
||||
accelerationPanel.setToolTipText("MotionSensingEvent");
|
||||
|
||||
javax.swing.GroupLayout accelerationPanelLayout = new javax.swing.GroupLayout(accelerationPanel);
|
||||
javax.swing.GroupLayout accelerationPanelLayout = new javax.swing.GroupLayout(
|
||||
accelerationPanel);
|
||||
accelerationPanel.setLayout(accelerationPanelLayout);
|
||||
accelerationPanelLayout.setHorizontalGroup(
|
||||
accelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 279, Short.MAX_VALUE)
|
||||
);
|
||||
accelerationPanelLayout.setVerticalGroup(
|
||||
accelerationPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 213, Short.MAX_VALUE)
|
||||
);
|
||||
accelerationPanelLayout.setHorizontalGroup(accelerationPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 279, Short.MAX_VALUE));
|
||||
accelerationPanelLayout.setVerticalGroup(accelerationPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 213, Short.MAX_VALUE));
|
||||
|
||||
jTabbedPane1.addTab("Acceleration", accelerationPanel);
|
||||
|
||||
javax.swing.GroupLayout motionSensingPanelLayout = new javax.swing.GroupLayout(motionSensingPanel);
|
||||
javax.swing.GroupLayout motionSensingPanelLayout = new javax.swing.GroupLayout(
|
||||
motionSensingPanel);
|
||||
motionSensingPanel.setLayout(motionSensingPanelLayout);
|
||||
motionSensingPanelLayout.setHorizontalGroup(
|
||||
motionSensingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 279, Short.MAX_VALUE)
|
||||
);
|
||||
motionSensingPanelLayout.setVerticalGroup(
|
||||
motionSensingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 213, Short.MAX_VALUE)
|
||||
);
|
||||
motionSensingPanelLayout.setHorizontalGroup(motionSensingPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 279, Short.MAX_VALUE));
|
||||
motionSensingPanelLayout.setVerticalGroup(motionSensingPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 213, Short.MAX_VALUE));
|
||||
|
||||
jTabbedPane1.addTab("Orientation", motionSensingPanel);
|
||||
|
||||
javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(gForcePanel);
|
||||
javax.swing.GroupLayout gForcePanelLayout = new javax.swing.GroupLayout(
|
||||
gForcePanel);
|
||||
gForcePanel.setLayout(gForcePanelLayout);
|
||||
gForcePanelLayout.setHorizontalGroup(
|
||||
gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 279, Short.MAX_VALUE)
|
||||
);
|
||||
gForcePanelLayout.setVerticalGroup(
|
||||
gForcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 213, Short.MAX_VALUE)
|
||||
);
|
||||
gForcePanelLayout.setHorizontalGroup(gForcePanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 279, Short.MAX_VALUE));
|
||||
gForcePanelLayout.setVerticalGroup(gForcePanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 213, Short.MAX_VALUE));
|
||||
|
||||
jTabbedPane1.addTab("GForce", gForcePanel);
|
||||
|
||||
javax.swing.GroupLayout leftPanelLayout = new javax.swing.GroupLayout(leftPanel);
|
||||
javax.swing.GroupLayout leftPanelLayout = new javax.swing.GroupLayout(
|
||||
leftPanel);
|
||||
leftPanel.setLayout(leftPanelLayout);
|
||||
leftPanelLayout.setHorizontalGroup(
|
||||
leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(irViewPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 284, Short.MAX_VALUE)
|
||||
);
|
||||
leftPanelLayout.setVerticalGroup(
|
||||
leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, leftPanelLayout.createSequentialGroup()
|
||||
.addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(irViewPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
leftPanelLayout.setHorizontalGroup(leftPanelLayout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addComponent(
|
||||
irViewPanel, javax.swing.GroupLayout.Alignment.TRAILING,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jTabbedPane1,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE, 284,
|
||||
Short.MAX_VALUE));
|
||||
leftPanelLayout
|
||||
.setVerticalGroup(leftPanelLayout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(
|
||||
javax.swing.GroupLayout.Alignment.TRAILING,
|
||||
leftPanelLayout
|
||||
.createSequentialGroup()
|
||||
.addComponent(
|
||||
jTabbedPane1,
|
||||
javax.swing.GroupLayout.PREFERRED_SIZE,
|
||||
238,
|
||||
javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(
|
||||
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(
|
||||
irViewPanel,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE,
|
||||
Short.MAX_VALUE)));
|
||||
|
||||
jTabbedPane1.getAccessibleContext().setAccessibleName("Orientation");
|
||||
|
||||
rightPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
|
||||
rightPanel.setLayout(new javax.swing.BoxLayout(rightPanel, javax.swing.BoxLayout.LINE_AXIS));
|
||||
rightPanel.setLayout(new javax.swing.BoxLayout(rightPanel,
|
||||
javax.swing.BoxLayout.LINE_AXIS));
|
||||
|
||||
fixedWiimotePanel.setMaximumSize(new java.awt.Dimension(120, 32767));
|
||||
fixedWiimotePanel.setMinimumSize(new java.awt.Dimension(120, 100));
|
||||
@@ -442,16 +482,15 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
buttonsPanel.setOpaque(false);
|
||||
buttonsPanel.setPreferredSize(new java.awt.Dimension(120, 484));
|
||||
|
||||
javax.swing.GroupLayout buttonsPanelLayout = new javax.swing.GroupLayout(buttonsPanel);
|
||||
javax.swing.GroupLayout buttonsPanelLayout = new javax.swing.GroupLayout(
|
||||
buttonsPanel);
|
||||
buttonsPanel.setLayout(buttonsPanelLayout);
|
||||
buttonsPanelLayout.setHorizontalGroup(
|
||||
buttonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 120, Short.MAX_VALUE)
|
||||
);
|
||||
buttonsPanelLayout.setVerticalGroup(
|
||||
buttonsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 484, Short.MAX_VALUE)
|
||||
);
|
||||
buttonsPanelLayout.setHorizontalGroup(buttonsPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 120, Short.MAX_VALUE));
|
||||
buttonsPanelLayout.setVerticalGroup(buttonsPanelLayout
|
||||
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 484, Short.MAX_VALUE));
|
||||
|
||||
fixedWiimotePanel.add(buttonsPanel);
|
||||
buttonsPanel.setBounds(0, 0, 120, 484);
|
||||
@@ -471,7 +510,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
activateRumbleIRPanel.add(toggleRumbleButton);
|
||||
|
||||
toggleIRTrackingButton.setText("Activate IR Tracking");
|
||||
toggleIRTrackingButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
toggleIRTrackingButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
toggleIRTrackingButtonMousePressed(evt);
|
||||
}
|
||||
@@ -480,8 +520,10 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
|
||||
controlsPanel.add(activateRumbleIRPanel);
|
||||
|
||||
toggleMotionSensingTrackingButton.setText("Activate motion sensing Tracking");
|
||||
toggleMotionSensingTrackingButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
toggleMotionSensingTrackingButton
|
||||
.setText("Activate motion sensing Tracking");
|
||||
toggleMotionSensingTrackingButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
toggleMotionSensingTrackingButtonMousePressed(evt);
|
||||
}
|
||||
@@ -491,7 +533,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
controlsPanel.add(activateMotionSensingPanel);
|
||||
|
||||
toggleSmoothingButton.setText("Activate Smoothing");
|
||||
toggleSmoothingButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
toggleSmoothingButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
toggleSmoothingButtonMousePressed(evt);
|
||||
}
|
||||
@@ -499,7 +542,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
activateSmoothingContinuousPanel.add(toggleSmoothingButton);
|
||||
|
||||
toggleContinuousButton.setText("Activate Continuous");
|
||||
toggleContinuousButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
toggleContinuousButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
toggleContinuousButtonMousePressed(evt);
|
||||
}
|
||||
@@ -551,11 +595,13 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
controlsPanel.add(setLedsPanel);
|
||||
|
||||
alphaSmoothingTextField.setMinimumSize(new java.awt.Dimension(100, 20));
|
||||
alphaSmoothingTextField.setPreferredSize(new java.awt.Dimension(100, 20));
|
||||
alphaSmoothingTextField
|
||||
.setPreferredSize(new java.awt.Dimension(100, 20));
|
||||
setAlphaSmoothingPanel.add(alphaSmoothingTextField);
|
||||
|
||||
alphaSmoothingButton.setText("Set alpha smoothing");
|
||||
alphaSmoothingButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
alphaSmoothingButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
alphaSmoothingButtonMousePressed(evt);
|
||||
}
|
||||
@@ -564,12 +610,15 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
|
||||
controlsPanel.add(setAlphaSmoothingPanel);
|
||||
|
||||
orientationThresholdTextField.setMinimumSize(new java.awt.Dimension(100, 20));
|
||||
orientationThresholdTextField.setPreferredSize(new java.awt.Dimension(100, 20));
|
||||
orientationThresholdTextField.setMinimumSize(new java.awt.Dimension(
|
||||
100, 20));
|
||||
orientationThresholdTextField.setPreferredSize(new java.awt.Dimension(
|
||||
100, 20));
|
||||
setOrientationThresholdPanel.add(orientationThresholdTextField);
|
||||
|
||||
orientationThresholdButton.setText("Set orientation threshold");
|
||||
orientationThresholdButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
orientationThresholdButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
orientationThresholdButtonMousePressed(evt);
|
||||
}
|
||||
@@ -578,11 +627,13 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
|
||||
controlsPanel.add(setOrientationThresholdPanel);
|
||||
|
||||
accelerationThresholdTextField.setPreferredSize(new java.awt.Dimension(100, 20));
|
||||
accelerationThresholdTextField.setPreferredSize(new java.awt.Dimension(
|
||||
100, 20));
|
||||
setAccelerationThresholdPanel.add(accelerationThresholdTextField);
|
||||
|
||||
accelerationThresholdButton.setText("Set acceleration threshold");
|
||||
accelerationThresholdButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
accelerationThresholdButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
accelerationThresholdButtonMousePressed(evt);
|
||||
}
|
||||
@@ -610,7 +661,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
controlsPanel.add(getStatusPanel);
|
||||
|
||||
setIrSensitivySpinner.setPreferredSize(new java.awt.Dimension(50, 18));
|
||||
setIrSensitivySpinner.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
setIrSensitivySpinner
|
||||
.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||
setIrSensitivySpinnerStateChanged(evt);
|
||||
}
|
||||
@@ -618,7 +670,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
setIrSensitivyPanel.add(setIrSensitivySpinner);
|
||||
|
||||
setIrSensitivyButton.setText("SetIrSensivity");
|
||||
setIrSensitivyButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
setIrSensitivyButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
setIrSensitivyButtonMousePressed(evt);
|
||||
}
|
||||
@@ -636,7 +689,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
controlsPanel.add(setIrSensitivyPanel);
|
||||
|
||||
normalTimeoutSpinner.setPreferredSize(new java.awt.Dimension(40, 18));
|
||||
normalTimeoutSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
normalTimeoutSpinner
|
||||
.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||
normalTimeoutSpinnerStateChanged(evt);
|
||||
}
|
||||
@@ -646,8 +700,10 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
normalTimeoutText.setText("Normal timeout");
|
||||
setTimeoutPanel.add(normalTimeoutText);
|
||||
|
||||
expansionHandshakeTimeoutSpinner.setPreferredSize(new java.awt.Dimension(40, 18));
|
||||
expansionHandshakeTimeoutSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
expansionHandshakeTimeoutSpinner
|
||||
.setPreferredSize(new java.awt.Dimension(40, 18));
|
||||
expansionHandshakeTimeoutSpinner
|
||||
.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||
expansionHandshakeTimeoutSpinnerStateChanged(evt);
|
||||
}
|
||||
@@ -660,7 +716,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
controlsPanel.add(setTimeoutPanel);
|
||||
|
||||
toggleSensorBarPositionButton.setText("Set sensor bar above");
|
||||
toggleSensorBarPositionButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
toggleSensorBarPositionButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
toggleSensorBarPositionButtonMousePressed(evt);
|
||||
}
|
||||
@@ -668,7 +725,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
setIRConfPanel.add(toggleSensorBarPositionButton);
|
||||
|
||||
toggleScreenAspectRatioButton.setText("Set screen aspect ratio 4/3");
|
||||
toggleScreenAspectRatioButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
toggleScreenAspectRatioButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
toggleScreenAspectRatioButtonMousePressed(evt);
|
||||
}
|
||||
@@ -693,7 +751,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
setVirtualResolutionPanel.add(yResolutionTextField);
|
||||
|
||||
setVirtualResolutionButton.setText("Set virtual resolution");
|
||||
setVirtualResolutionButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
setVirtualResolutionButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
setVirtualResolutionButtonMousePressed(evt);
|
||||
}
|
||||
@@ -703,7 +762,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
controlsPanel.add(setVirtualResolutionPanel);
|
||||
|
||||
mouseIRControlButton.setText("Start infrared mouse control");
|
||||
mouseIRControlButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
mouseIRControlButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
mouseIRControlButtonMousePressed(evt);
|
||||
}
|
||||
@@ -716,7 +776,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
exPansionPanel.add(expansionText);
|
||||
|
||||
showExpansionWiimoteButton.setText("No expansion connected");
|
||||
showExpansionWiimoteButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
showExpansionWiimoteButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
showExpansionWiimoteButtonMousePressed(evt);
|
||||
}
|
||||
@@ -726,7 +787,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
controlsPanel.add(exPansionPanel);
|
||||
|
||||
reconnectWiimotesButton.setText("Reconnect wiimote");
|
||||
reconnectWiimotesButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
reconnectWiimotesButton
|
||||
.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mousePressed(java.awt.event.MouseEvent evt) {
|
||||
reconnectWiimotesButtonMousePressed(evt);
|
||||
}
|
||||
@@ -745,24 +807,40 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
|
||||
rightPanel.add(controlsPanel);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
|
||||
getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(leftPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(leftPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE)
|
||||
);
|
||||
layout
|
||||
.setHorizontalGroup(layout
|
||||
.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(
|
||||
layout
|
||||
.createSequentialGroup()
|
||||
.addComponent(
|
||||
leftPanel,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE,
|
||||
Short.MAX_VALUE)
|
||||
.addPreferredGap(
|
||||
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(
|
||||
rightPanel,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE,
|
||||
498, Short.MAX_VALUE)));
|
||||
layout.setVerticalGroup(layout.createParallelGroup(
|
||||
javax.swing.GroupLayout.Alignment.LEADING).addComponent(
|
||||
leftPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
|
||||
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(rightPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
|
||||
573, Short.MAX_VALUE));
|
||||
|
||||
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
|
||||
setBounds((screenSize.width-800)/2, (screenSize.height-600)/2, 800, 600);
|
||||
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit()
|
||||
.getScreenSize();
|
||||
setBounds((screenSize.width - 800) / 2, (screenSize.height - 600) / 2,
|
||||
800, 600);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void toggleRumbleButtonMousePressed(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleRumbleButtonMousePressed
|
||||
if (toggleRumbleButton.isEnabled()) {
|
||||
wiimote.activateRumble();
|
||||
@@ -777,7 +855,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
}
|
||||
}// GEN-LAST:event_toggleRumbleButtonMousePressed
|
||||
|
||||
private void toggleIRTrackingButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleIRTrackingButtonMousePressed
|
||||
private void toggleIRTrackingButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleIRTrackingButtonMousePressed
|
||||
if (toggleIRTrackingButton.isEnabled()) {
|
||||
wiimote.activateIRTRacking();
|
||||
toggleIRTrackingButton.setEnabled(false);
|
||||
@@ -792,16 +871,19 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
}
|
||||
}// GEN-LAST:event_toggleIRTrackingButtonMousePressed
|
||||
|
||||
private void toggleMotionSensingTrackingButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleMotionSensingTrackingButtonMousePressed
|
||||
private void toggleMotionSensingTrackingButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleMotionSensingTrackingButtonMousePressed
|
||||
if (toggleMotionSensingTrackingButton.isEnabled()) {
|
||||
wiimote.activateMotionSensing();
|
||||
toggleMotionSensingTrackingButton.setEnabled(false);
|
||||
toggleMotionSensingTrackingButton.setText("Deactivate Motion Sensing");
|
||||
toggleMotionSensingTrackingButton
|
||||
.setText("Deactivate Motion Sensing");
|
||||
messageText.setText("Motion Sensing activated");
|
||||
} else {
|
||||
wiimote.deactivateMotionSensing();
|
||||
toggleMotionSensingTrackingButton.setEnabled(true);
|
||||
toggleMotionSensingTrackingButton.setText("Activate Motion Sensing");
|
||||
toggleMotionSensingTrackingButton
|
||||
.setText("Activate Motion Sensing");
|
||||
((OrientationPanel) motionSensingPanel).onDisconnectionEvent(null);
|
||||
((GForcePanel) gForcePanel).onDisconnectionEvent(null);
|
||||
messageText.setText("Motion Sensing deactivated");
|
||||
@@ -822,7 +904,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
}
|
||||
}// GEN-LAST:event_toggleSmoothingButtonMousePressed
|
||||
|
||||
private void toggleContinuousButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleContinuousButtonMousePressed
|
||||
private void toggleContinuousButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleContinuousButtonMousePressed
|
||||
if (toggleContinuousButton.isEnabled()) {
|
||||
wiimote.activateContinuous();
|
||||
toggleContinuousButton.setEnabled(false);
|
||||
@@ -880,27 +963,33 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
wiimote.setAlphaSmoothingValue(nb);
|
||||
messageText.setText("Alpha smoothing set to " + nb);
|
||||
} catch (NumberFormatException e) {
|
||||
messageText.setText("Number is not a float, alpha smoothing not set !");
|
||||
messageText
|
||||
.setText("Number is not a float, alpha smoothing not set !");
|
||||
}
|
||||
}// GEN-LAST:event_alphaSmoothingButtonMousePressed
|
||||
|
||||
private void orientationThresholdButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_orientationThresholdButtonMousePressed
|
||||
private void orientationThresholdButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_orientationThresholdButtonMousePressed
|
||||
try {
|
||||
float nb = Float.parseFloat(orientationThresholdTextField.getText());
|
||||
float nb = Float
|
||||
.parseFloat(orientationThresholdTextField.getText());
|
||||
wiimote.setOrientationThreshold(nb);
|
||||
messageText.setText("Orientation threshold set to " + nb);
|
||||
} catch (NumberFormatException e) {
|
||||
messageText.setText("Number is not a float, orientation threshold not set !");
|
||||
messageText
|
||||
.setText("Number is not a float, orientation threshold not set !");
|
||||
}
|
||||
}// GEN-LAST:event_orientationThresholdButtonMousePressed
|
||||
|
||||
private void accelerationThresholdButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_accelerationThresholdButtonMousePressed
|
||||
private void accelerationThresholdButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_accelerationThresholdButtonMousePressed
|
||||
try {
|
||||
int nb = Integer.parseInt(accelerationThresholdTextField.getText());
|
||||
wiimote.setAccelerationThreshold(nb);
|
||||
messageText.setText("Acceleration threshold set to " + nb);
|
||||
} catch (NumberFormatException e) {
|
||||
messageText.setText("Number is not an integer, acceleration threshold not set !");
|
||||
messageText
|
||||
.setText("Number is not an integer, acceleration threshold not set !");
|
||||
}
|
||||
}// GEN-LAST:event_accelerationThresholdButtonMousePressed
|
||||
|
||||
@@ -913,7 +1002,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
}
|
||||
}// GEN-LAST:event_getStatusButtonMousePressed
|
||||
|
||||
private void toggleSensorBarPositionButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleSensorBarPositionButtonMousePressed
|
||||
private void toggleSensorBarPositionButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleSensorBarPositionButtonMousePressed
|
||||
if (toggleSensorBarPositionButton.isEnabled()) {
|
||||
wiimote.setSensorBarBelowScreen();
|
||||
toggleSensorBarPositionButton.setEnabled(false);
|
||||
@@ -927,28 +1017,34 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
}
|
||||
}// GEN-LAST:event_toggleSensorBarPositionButtonMousePressed
|
||||
|
||||
private void toggleScreenAspectRatioButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_toggleScreenAspectRatioButtonMousePressed
|
||||
private void toggleScreenAspectRatioButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_toggleScreenAspectRatioButtonMousePressed
|
||||
if (toggleScreenAspectRatioButton.isEnabled()) {
|
||||
wiimote.setScreenAspectRatio43();
|
||||
toggleScreenAspectRatioButton.setEnabled(false);
|
||||
toggleScreenAspectRatioButton.setText("Set screen aspect ratio 16/9");
|
||||
toggleScreenAspectRatioButton
|
||||
.setText("Set screen aspect ratio 16/9");
|
||||
messageText.setText("creen aspect ratio to 4/3");
|
||||
} else {
|
||||
wiimote.setScreenAspectRatio169();
|
||||
toggleScreenAspectRatioButton.setEnabled(true);
|
||||
toggleScreenAspectRatioButton.setText("Set screen aspect ratio 4/3");
|
||||
toggleScreenAspectRatioButton
|
||||
.setText("Set screen aspect ratio 4/3");
|
||||
messageText.setText("Screen aspect ratio to 16/9");
|
||||
}
|
||||
}// GEN-LAST:event_toggleScreenAspectRatioButtonMousePressed
|
||||
|
||||
private void setVirtualResolutionButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_setVirtualResolutionButtonMousePressed
|
||||
private void setVirtualResolutionButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_setVirtualResolutionButtonMousePressed
|
||||
try {
|
||||
int xres = Integer.parseInt(xResolutionTextField.getText());
|
||||
int yres = Integer.parseInt(yResolutionTextField.getText());
|
||||
wiimote.setVirtualResolution(xres, yres);
|
||||
messageText.setText("Virtual resolution set to " + xres + "X" + yres);
|
||||
messageText.setText("Virtual resolution set to " + xres + "X"
|
||||
+ yres);
|
||||
} catch (NumberFormatException e) {
|
||||
messageText.setText("A number in the virtual resolution is not an integer. Virtual resolution not set!");
|
||||
messageText
|
||||
.setText("A number in the virtual resolution is not an integer. Virtual resolution not set!");
|
||||
}
|
||||
}// GEN-LAST:event_setVirtualResolutionButtonMousePressed
|
||||
|
||||
@@ -960,7 +1056,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
robot = new Robot();
|
||||
messageText.setText("Infrared mouse control started");
|
||||
} catch (AWTException ex) {
|
||||
Logger.getLogger(WiiuseJGuiTest.class.getName()).log(Level.SEVERE, null, ex);
|
||||
Logger.getLogger(WiiuseJGuiTest.class.getName()).log(
|
||||
Level.SEVERE, null, ex);
|
||||
}
|
||||
} else {
|
||||
mouseIRControlButton.setEnabled(true);
|
||||
@@ -970,7 +1067,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
}
|
||||
}// GEN-LAST:event_mouseIRControlButtonMousePressed
|
||||
|
||||
private void normalTimeoutSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_normalTimeoutSpinnerStateChanged
|
||||
private void normalTimeoutSpinnerStateChanged(
|
||||
javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_normalTimeoutSpinnerStateChanged
|
||||
String value = normalTimeoutSpinner.getValue().toString();
|
||||
boolean isInt = true;
|
||||
int valueInt = 0;
|
||||
@@ -989,7 +1087,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
}
|
||||
}// GEN-LAST:event_normalTimeoutSpinnerStateChanged
|
||||
|
||||
private void expansionHandshakeTimeoutSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_expansionHandshakeTimeoutSpinnerStateChanged
|
||||
private void expansionHandshakeTimeoutSpinnerStateChanged(
|
||||
javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_expansionHandshakeTimeoutSpinnerStateChanged
|
||||
String value = expansionHandshakeTimeoutSpinner.getValue().toString();
|
||||
boolean isInt = true;
|
||||
int valueInt = 0;
|
||||
@@ -1008,7 +1107,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
}
|
||||
}// GEN-LAST:event_expansionHandshakeTimeoutSpinnerStateChanged
|
||||
|
||||
private void setIrSensitivySpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_setIrSensitivySpinnerStateChanged
|
||||
private void setIrSensitivySpinnerStateChanged(
|
||||
javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_setIrSensitivySpinnerStateChanged
|
||||
String value = setIrSensitivySpinner.getValue().toString();
|
||||
boolean isInt = true;
|
||||
int valueInt = 0;
|
||||
@@ -1035,14 +1135,16 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
valueInt = Integer.parseInt(value);
|
||||
} catch (NumberFormatException e) {
|
||||
isInt = false;
|
||||
messageText.setText("Wrong value for IR sensitivity. It must be an int !");
|
||||
messageText
|
||||
.setText("Wrong value for IR sensitivity. It must be an int !");
|
||||
}
|
||||
if (isInt) {
|
||||
if (valueInt >= 1 && valueInt <= 5) {
|
||||
wiimote.setIrSensitivity(valueInt);
|
||||
messageText.setText("IR senstivity set to: " + valueInt + ".");
|
||||
} else {
|
||||
messageText.setText("Wrong value for IR senstivity. It muset be between 1 and 5 !");
|
||||
messageText
|
||||
.setText("Wrong value for IR senstivity. It muset be between 1 and 5 !");
|
||||
}
|
||||
}
|
||||
}// GEN-LAST:event_setIrSensitivyButtonMousePressed
|
||||
@@ -1056,7 +1158,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
valueInt = Short.parseShort(value);
|
||||
} catch (NumberFormatException e) {
|
||||
isInt = false;
|
||||
messageText.setText("Wrong value for normal timeout. It must be an int !");
|
||||
messageText
|
||||
.setText("Wrong value for normal timeout. It must be an int !");
|
||||
}
|
||||
// get expansion handshake timeout
|
||||
String value2 = expansionHandshakeTimeoutSpinner.getValue().toString();
|
||||
@@ -1066,22 +1169,27 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
valueInt2 = Short.parseShort(value2);
|
||||
} catch (NumberFormatException e) {
|
||||
isInt2 = false;
|
||||
messageText.setText("Wrong value for expansion handshake timeout. It must be an int !");
|
||||
messageText
|
||||
.setText("Wrong value for expansion handshake timeout. It must be an int !");
|
||||
}
|
||||
if (isInt && isInt2) {
|
||||
if (valueInt > 0 && valueInt2 > 0) {
|
||||
wiimote.setTimeout(valueInt, valueInt2);
|
||||
messageText.setText("Normal timeout set to: " + valueInt + " and expansion handshake timeout set to: " + valueInt2 + "!");
|
||||
messageText.setText("Normal timeout set to: " + valueInt
|
||||
+ " and expansion handshake timeout set to: "
|
||||
+ valueInt2 + "!");
|
||||
} else {
|
||||
messageText.setText("Wrong value for one of the timeout value. It must be an integer > 0 !");
|
||||
messageText
|
||||
.setText("Wrong value for one of the timeout value. It must be an integer > 0 !");
|
||||
}
|
||||
}
|
||||
}// GEN-LAST:event_setTimeoutButtonMousePressed
|
||||
|
||||
private void reconnectWiimotesButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_reconnectWiimotesButtonMousePressed
|
||||
private void reconnectWiimotesButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_reconnectWiimotesButtonMousePressed
|
||||
// stop manager
|
||||
WiiUseApiManager manager = WiiUseApiManager.getInstance();
|
||||
manager.shutdown();
|
||||
manager.definitiveShutdown();
|
||||
|
||||
// unregister previous wiimote
|
||||
if (wiimote != null) {
|
||||
@@ -1102,7 +1210,8 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
// setup buttons In first state
|
||||
toggleRumbleButton.setText("Activate Rumble");
|
||||
toggleRumbleButton.setEnabled(true);
|
||||
toggleMotionSensingTrackingButton.setText("Activate motion sensing Tracking");
|
||||
toggleMotionSensingTrackingButton
|
||||
.setText("Activate motion sensing Tracking");
|
||||
toggleMotionSensingTrackingButton.setEnabled(true);
|
||||
toggleIRTrackingButton.setText("Activate IR Tracking");
|
||||
toggleIRTrackingButton.setEnabled(true);
|
||||
@@ -1131,9 +1240,11 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements WiimoteListene
|
||||
}
|
||||
}// GEN-LAST:event_reconnectWiimotesButtonMousePressed
|
||||
|
||||
private void showExpansionWiimoteButtonMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_showExpansionWiimoteButtonMousePressed
|
||||
private void showExpansionWiimoteButtonMousePressed(
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_showExpansionWiimoteButtonMousePressed
|
||||
if (expansionFrame != null) {
|
||||
if (showExpansionWiimoteButton.isEnabled()) {//expansion frame not shown
|
||||
if (showExpansionWiimoteButton.isEnabled()) {// expansion frame
|
||||
// not shown
|
||||
// show it
|
||||
expansionFrame.setEnabled(true);
|
||||
expansionFrame.setVisible(true);
|
||||
|
||||
Reference in New Issue
Block a user