diff --git a/WiiUseJ/src/tests/Tests.java b/WiiUseJ/src/tests/Tests.java index 8412aec..1979759 100644 --- a/WiiUseJ/src/tests/Tests.java +++ b/WiiUseJ/src/tests/Tests.java @@ -42,10 +42,12 @@ public class Tests implements WiimoteListener { e.printStackTrace(); } } - + + private static int nb = 0; + @Override public void wiimoteEvent(WiiMoteEvent e) { - + System.out.println("Number of events : "+nb++); if (dump == DISPLAY_EACH_VALUE) { // System.out.println("*********** WIIMOTE ID : "+ // e.getWiimoteId() + " **************"); @@ -171,7 +173,7 @@ public class Tests implements WiimoteListener { } /* get status */ - if (e.isButtonMinusJustPressed() && e.isButtonPlusJustPressed()) { + if (e.isButtonUpJustPressed()) { wiimote.getStatus(); } diff --git a/WiiUseJ/src/wiiusej/WiiUseApiManager.java b/WiiUseJ/src/wiiusej/WiiUseApiManager.java index 5eeac4b..d5c3d2e 100644 --- a/WiiUseJ/src/wiiusej/WiiUseApiManager.java +++ b/WiiUseJ/src/wiiusej/WiiUseApiManager.java @@ -55,9 +55,9 @@ public class WiiUseApiManager extends Thread { if (manager.connected < 0) { int nbWiimotes = manager.connectWiimotes(nb); manager.wiimotes = new Wiimote[nbWiimotes]; - for (int i = 0; i < nbWiimotes; i++) { + for (int i = 1; i <= nbWiimotes; i++) { Wiimote wim = new Wiimote(i, manager); - manager.wiimotes[i] = wim; + manager.wiimotes[i-1] = wim; manager.addWiiUseApiListener(wim); } } @@ -99,8 +99,8 @@ public class WiiUseApiManager extends Thread { * id of the wiimote to disconnect. */ public void closeConnection(int id) { - removeWiiUseApiListener(wiimotes[id]); - wiimotes[id] = null; + removeWiiUseApiListener(wiimotes[id-1]); + wiimotes[id-1] = null; requests.add(new WiiUseApiRequest(id, WiiUseApiRequest.WIIUSE_CLOSE_CONNECTION_REQUEST)); System.out.println("Wiimote " + id + " disconnected !"); diff --git a/WiiUseJ/src/wiiusej/wiiuseapievents/EventsGatherer.java b/WiiUseJ/src/wiiusej/wiiuseapievents/EventsGatherer.java index 699348f..f7e9a8b 100644 --- a/WiiUseJ/src/wiiusej/wiiuseapievents/EventsGatherer.java +++ b/WiiUseJ/src/wiiusej/wiiuseapievents/EventsGatherer.java @@ -30,7 +30,7 @@ public class EventsGatherer { * @param e * the event to add. */ - private void addEvent(WiiUseApiEvent e) { + private void addEvent(WiiUseApiEvent e) { events[index] = e; index++; } @@ -136,7 +136,7 @@ public class EventsGatherer { */ public void addStatusEvent(int id, boolean connect, float batt, short led, boolean speak, int attach, boolean rumbleState, - float orientationThreshold, float accelerationThreshold, + float orientationThreshold, int accelerationThreshold, float alphaSmooth, boolean continuousState, boolean smoothingState, boolean irState, boolean motionSensingState) { StatusEvent evt = new StatusEvent(id, connect, batt, led, speak, diff --git a/WiiUseJ/src/wiiusej/wiiuseapievents/StatusEvent.java b/WiiUseJ/src/wiiusej/wiiuseapievents/StatusEvent.java index cff2f67..c11b98f 100644 --- a/WiiUseJ/src/wiiusej/wiiuseapievents/StatusEvent.java +++ b/WiiUseJ/src/wiiusej/wiiuseapievents/StatusEvent.java @@ -29,7 +29,7 @@ public class StatusEvent extends WiiUseApiEvent { private float orientationThreshold = 0; - private float accelerationThreshold = 0; + private int accelerationThreshold = 0; private float alphaSmoothing = 0; @@ -87,7 +87,7 @@ public class StatusEvent extends WiiUseApiEvent { */ public StatusEvent(int id, boolean connect, float batt, short led, boolean speak, int attach, boolean rumbleState, - float orientationThreshold, float accelerationThreshold, + float orientationThreshold, int accelerationThreshold, float alphaSmooth, boolean continuousState, boolean smoothingState, boolean irState, boolean motionSensingState) { super(id, WiiUseApiEvent.STATUS_EVENT); @@ -174,7 +174,7 @@ public class StatusEvent extends WiiUseApiEvent { * * @return the accelerationThreshold */ - public float getAccelerationThreshold() { + public int getAccelerationThreshold() { return accelerationThreshold; }