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:
@@ -46,6 +46,8 @@ public class WiiUseApiManager extends Thread {
|
||||
private int connected = -1;
|
||||
|
||||
private AtomicBoolean running = new AtomicBoolean(false);
|
||||
|
||||
private boolean leave = false;
|
||||
|
||||
public static int WIIUSE_STACK_UNKNOWN = 0;
|
||||
public static int WIIUSE_STACK_MS = 1;
|
||||
@@ -246,6 +248,14 @@ public class WiiUseApiManager extends Thread {
|
||||
running.set(false);
|
||||
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);
|
||||
if (wiimotes.length>0){
|
||||
WiiuseJGuiTest gui = new WiiuseJGuiTest(wiimotes[0]);
|
||||
gui.setDefaultCloseOperation(gui.EXIT_ON_CLOSE);
|
||||
gui.setVisible(true);
|
||||
}
|
||||
WiiuseJGuiTest gui = null;
|
||||
if (wiimotes.length > 0) {
|
||||
gui = new WiiuseJGuiTest(wiimotes[0]);
|
||||
} else {
|
||||
gui = new WiiuseJGuiTest();
|
||||
}
|
||||
gui.setDefaultCloseOperation(gui.EXIT_ON_CLOSE);
|
||||
gui.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user