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:
guilhem.duche
2008-05-26 20:46:46 +00:00
parent eb0b4dcd01
commit 70cd478118
3 changed files with 1299 additions and 1175 deletions

View File

@@ -47,6 +47,8 @@ public class WiiUseApiManager extends Thread {
private AtomicBoolean running = new AtomicBoolean(false); private AtomicBoolean running = new AtomicBoolean(false);
private boolean leave = false;
public static int WIIUSE_STACK_UNKNOWN = 0; public static int WIIUSE_STACK_UNKNOWN = 0;
public static int WIIUSE_STACK_MS = 1; public static int WIIUSE_STACK_MS = 1;
public static int WIIUSE_STACK_BLUESOLEIL = 2; public static int WIIUSE_STACK_BLUESOLEIL = 2;
@@ -247,6 +249,14 @@ public class WiiUseApiManager extends Thread {
wiiuse.cleanUp(); wiiuse.cleanUp();
} }
/**
* Stop wiiuseJ definitively for this program.
*/
public void definitiveShutdown(){
leave = true;
shutdown();
}
/** /**
* Activate the rumble for the wiimote with the given id. * Activate the rumble for the wiimote with the given id.
* *
@@ -548,7 +558,7 @@ public class WiiUseApiManager extends Thread {
@Override @Override
public void run() { public void run() {
while (true) { while (!leave) {
try { try {
semaphore.acquire(); semaphore.acquire();
} catch (InterruptedException e) { } catch (InterruptedException e) {

View File

@@ -30,11 +30,14 @@ public class Main {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true); Wiimote[] wiimotes = WiiUseApiManager.getWiimotes(1, true);
if (wiimotes.length>0){ WiiuseJGuiTest gui = null;
WiiuseJGuiTest gui = new WiiuseJGuiTest(wiimotes[0]); if (wiimotes.length > 0) {
gui.setDefaultCloseOperation(gui.EXIT_ON_CLOSE); gui = new WiiuseJGuiTest(wiimotes[0]);
gui.setVisible(true); } else {
} gui = new WiiuseJGuiTest();
}
gui.setDefaultCloseOperation(gui.EXIT_ON_CLOSE);
gui.setVisible(true);
} }
} }

File diff suppressed because it is too large Load Diff