small modifs for 0.12. Improve closing wiiusej.
git-svn-id: http://wiiusej.googlecode.com/svn/trunk@157 ae48ae66-6a45-0410-b38e-211266189506
This commit is contained in:
@@ -112,9 +112,13 @@ public class WiiUseApiManager extends Thread {
|
||||
* @return an array with connected wiimotes or NULL.
|
||||
*/
|
||||
private synchronized static Wiimote[] getWiimotesPrivate(int nb,
|
||||
boolean rumble, boolean forceStackType, int stackType) {
|
||||
boolean rumble, boolean forceStackType, int stackType) {
|
||||
WiiUseApiManager manager = getInstance();
|
||||
|
||||
if (manager.leave) return null;//wiiusej definitively stopped
|
||||
|
||||
if (manager.connected <= 0 && !manager.running.get()) {
|
||||
//connect wiimotes.
|
||||
int nbWiimotes = manager.connectWiimotes(nb, rumble,
|
||||
forceStackType, stackType);
|
||||
manager.wiimotes = new Wiimote[nbWiimotes];
|
||||
@@ -152,15 +156,16 @@ public class WiiUseApiManager extends Thread {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (manager.connected == 0) {
|
||||
|
||||
if (manager.connected == 0) {//no wiimote connected
|
||||
//return empty array
|
||||
return new Wiimote[0];
|
||||
}
|
||||
|
||||
if (!manager.isAlive())
|
||||
if (!manager.isAlive())//start wiiuseJ polling
|
||||
manager.start();
|
||||
|
||||
manager.semaphore.release();
|
||||
manager.semaphore.release(1);
|
||||
|
||||
return manager.wiimotes;
|
||||
}
|
||||
|
||||
@@ -1189,7 +1189,7 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
|
||||
java.awt.event.MouseEvent evt) {// GEN-FIRST:event_reconnectWiimotesButtonMousePressed
|
||||
// stop manager
|
||||
WiiUseApiManager manager = WiiUseApiManager.getInstance();
|
||||
manager.definitiveShutdown();
|
||||
manager.shutdown();
|
||||
|
||||
// unregister previous wiimote
|
||||
if (wiimote != null) {
|
||||
@@ -1228,7 +1228,7 @@ public class WiiuseJGuiTest extends javax.swing.JFrame implements
|
||||
|
||||
// get wiimote
|
||||
Wiimote[] listWiimote = WiiUseApiManager.getWiimotes(1, true);
|
||||
if (listWiimote.length > 0) {
|
||||
if (listWiimote!=null && listWiimote.length > 0) {
|
||||
wiimote = listWiimote[0];
|
||||
|
||||
// registers listeners
|
||||
|
||||
Reference in New Issue
Block a user