 |
WiiLi.org a new revolution
|
| View previous topic :: View next topic |
| Author |
Message |
dju
Joined: 15 Mar 2008 Posts: 14
Digg It |
Posted: Sat Mar 15, 2008 4:24 am Post subject: wiiRemoteDiscovered never call |
|
|
Hello,
I just bought a Dlink DBT-122 key to connect my Wiimote (i would like to track a 3d IR point with 2 wiimote). I develop under linux, eclipse 3.3, JDK 1.6, with avetana BT.
When I try to connect my Wiimote, wiiRemoteDiscovered() method is never call. However the wiimote's LEDs are still flashing, thatwhy I think my Wiimote was detected.
My code:
| Code: | import wiiremotej.IRLight;
import wiiremotej.WiiRemote;
import wiiremotej.WiiRemoteJ;
import wiiremotej.event.WRAccelerationEvent;
import wiiremotej.event.WRCombinedEvent;
import wiiremotej.event.WRIREvent;
import wiiremotej.event.WiiRemoteAdapter;
import wiiremotej.event.WiiRemoteDiscoveredEvent;
import wiiremotej.event.WiiRemoteDiscoveryListener;
public class WiiTest implements Runnable {
private float x = 0.0f;
private float y = 0.0f;
private float z = 0.0f;
private float screenY = 0.0f;
private float screenX = 0.0f;
private double pointerX = 0.0f;
private double pointerY = 0.0f;
private boolean pointerVisible = false;
private int inc = 1;
private int[] samplesX;
private int sampleXOffset;
private int[] samplesY;
private int sampleYOffset;
private int[] samplesZ;
private int sampleZOffset;
private boolean remoteConnected = false;
public WiiTest() {
samplesX = new int[800];
samplesZ = new int[800];
samplesY = new int[800];
new Thread(this).start();
WiimoteDiscoveryListener discoveryListener = new WiimoteDiscoveryListener();
WiiRemoteJ.findRemotes(discoveryListener, 1);
}
/* ---------------------------------------------------- */
/* Runnable methods */
/* ---------------------------------------------------- */
public void run() {
while (true) {
Thread.yield();
try {
Thread.sleep(100);
//canvas.repaint(0);
} catch (InterruptedException e) {
}
//canvas.repaint();
}
}
/* ---------------------------------------------------- */
/* Private classes */
/* ---------------------------------------------------- */
private class WiimoteDiscoveryListener implements
WiiRemoteDiscoveryListener {
public void findFinished(int numberFound) {
System.out.println("Found " + numberFound + " remotes!");
}
public void wiiRemoteDiscovered(WiiRemoteDiscoveredEvent evt) {
WiiRemote remote = evt.getWiiRemote();
try {
remote.setAccelerometerEnabled(true);
remote.setIRSensorEnabled(true, WRIREvent.EXTENDED);
remote.setLEDIlluminated(0, true);
remote.setLEDIlluminated(2, true);
} catch (Exception e) {
e.printStackTrace();
}
evt.getWiiRemote().addWiiRemoteListener(
new WiimoteActions(evt.getWiiRemote()));
WiiTest.this.remoteConnected = true;
// Wiimote3D.this.wiiRemote = remote;
}
}
private class WiimoteActions extends WiiRemoteAdapter {
WiimoteActions(WiiRemote remote) {
}
/*
* (non-Javadoc)
*
* @see wiiremotej.event.WiiRemoteAdapter#combinedInputReceived(wiiremotej.event.WRCombinedEvent)
*/
@Override
public void combinedInputReceived(WRCombinedEvent event) {
WRAccelerationEvent accelerationEvent = event
.getAccelerationEvent();
if (accelerationEvent != null) {
if (accelerationEvent.isStill()) {
WiiTest.this.z = (float) (accelerationEvent.getRoll() / 3.2f);
WiiTest.this.x = (float) (accelerationEvent.getPitch() / 3.2f);
// System.out.println
// System.out.println ( "roll: " + accelerationEvent.getRoll());
}
WiiTest.this.samplesX[WiiTest.this.sampleXOffset++] = (int) (accelerationEvent
.getXAcceleration() / 5 * 300) + 300;
if (WiiTest.this.sampleXOffset == 800) {
WiiTest.this.sampleXOffset = 0;
}
WiiTest.this.samplesY[WiiTest.this.sampleYOffset++] = (int) (accelerationEvent
.getYAcceleration() / 5 * 300) + 300;
if (WiiTest.this.sampleYOffset == 800) {
WiiTest.this.sampleYOffset = 0;
}
WiiTest.this.samplesZ[WiiTest.this.sampleZOffset++] = (int) (accelerationEvent
.getZAcceleration() / 5 * 300) + 300;
if (WiiTest.this.sampleZOffset == 800) {
WiiTest.this.sampleZOffset = 0;
}
}
}
/*
* (non-Javadoc)
*
* @see wiiremotej.event.WiiRemoteAdapter#disconnected()
*/
@Override
public void disconnected() {
WiiTest.this.remoteConnected = false;
// Wiimote3D.this.wiiRemote = null;
System.out.println("Remote Disconnected");
}
/*
* (non-Javadoc)
*
* @see wiiremotej.event.WiiRemoteAdapter#IRInputReceived(wiiremotej.event.WRIREvent)
*/
@Override
public void IRInputReceived(WRIREvent event) {
boolean positionData = false;
IRLight[] irLights = event.getIRLights();
if (irLights != null) {
for (IRLight irLight : irLights) {
if (irLight != null) {
System.out.println(" IRLIGHT: x=" + irLight.getX() +
", y=" + irLight.getY() + ", size=" +
irLight.getSize());
WiiTest.this.pointerX = irLight.getX();
WiiTest.this.pointerY = irLight.getY();
positionData = true;
}
}
}
WiiTest.this.pointerVisible = positionData;
// System.out.println("---------------");
}
}
/* ---------------------------------------------------- */
/* Application Enty Point (main) */
/* ---------------------------------------------------- */
public static void main(String[] args) {
WiiTest wm3d = new WiiTest();
// JPanel graphPanel = new JPanel();
// graphPanel.setMinimumSize(new Dimension(200,100));
// graphPanel.setPreferredSize(new Dimension(200,100));
// wiimote3dFrame.add(graphPanel,BorderLayout.NORTH);
}
}
|
Thank in advance
Julien |
|
| Back to top |
|
 |
Cha0s Site Admin
Joined: 17 Jan 2007 Posts: 468
Digg It |
Posted: Sat Mar 15, 2008 6:17 am Post subject: |
|
|
Try using the findRemote() method for testing purposes. If that works, we can do further debugging. _________________ Cha0s |
|
| Back to top |
|
 |
dju
Joined: 15 Mar 2008 Posts: 14
Digg It |
Posted: Sat Mar 15, 2008 1:13 pm Post subject: |
|
|
Hello,
Thanks for your quick reply Cha0s !!
Clearly start by use WRLImpl helps a lot.
The problem came from avetana BT, the bug was fixed by Nemno (thanks Nemno too). You can find the solution int he last part of the first thread of this forum (please allow me to post an URL ) .
The problem is not only on UBUNTU (GUTSY) but also on Mandriva 2008 |
|
| Back to top |
|
 |
Cha0s Site Admin
Joined: 17 Jan 2007 Posts: 468
Digg It |
Posted: Sat Mar 15, 2008 9:06 pm Post subject: |
|
|
I'll add that OS to the list there. Thanks for the heads up. _________________ Cha0s |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|