1

I am woring on simple example to use Wii Remote control on a Ev3 using Lejos 0.9.1-beta. I am using WiiRemoteJ and Bluecove 2.1.1-SNAPSHOT and the example works on my Mac, but I have the next error on my EV3:

Native Library bluecove_arm not available WR

I found a solution on the next link, but I don't know how to compile and create a new jar inside of the EV3.

Can you help me please?

This is my code

package test;

import wiiremotej.*;
import wiiremotej.event.*;

import com.intel.bluetooth.BlueCoveConfigProperties;

import lejos.hardware.lcd.LCD;


public class Wii extends WiiRemoteAdapter {

    private WiiRemote remote;

    private static boolean accelerometerSource = true; 

    private static int y = 0;
    private static int lastY = 0;


    public static void main(String args[]) {
        System.setProperty(BlueCoveConfigProperties.PROPERTY_JSR_82_PSM_MINIMUM_OFF, "true");
        WiiRemoteJ.setConsoleLoggingOff();

        try {
            LCD.drawString("Buscando WR", 0, 2);
            WiiRemote remote = null;

            while (remote == null) {
                try {
                    remote = WiiRemoteJ.findRemote();
                    LCD.drawString("WR encontrado", 0, 2);
                } 
                catch (Exception e) {
                    remote = null;
                    LCD.drawString("ERROR", 0, 2);
                }
            }

            remote.addWiiRemoteListener(new Wii(remote));
            remote.setAccelerometerEnabled(true);
            remote.setSpeakerEnabled(false);
            remote.setIRSensorEnabled(false, WRIREvent.BASIC);
            remote.setLEDIlluminated(0, false);

            remote.getButtonMaps().add(new ButtonMap(WRButtonEvent.HOME, ButtonMap.NUNCHUK, WRNunchukExtensionEvent.C,
                    new int[] { java.awt.event.KeyEvent.VK_CONTROL }, java.awt.event.InputEvent.BUTTON1_MASK, 0, -1));

            final WiiRemote remoteF = remote;
            Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
                public void run() {
                    remoteF.disconnect();
                }
            }));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public Wii(WiiRemote remote) {
        this.remote = remote;
    }

    public void accelerationInputReceived(WRAccelerationEvent evt) {
        //Doblar derecha y izquierda
        if(accelerometerSource){
            lastY = y;
            //300 es el centro
            y = (int)(evt.getYAcceleration()/5*300)+300;
            if( y < lastY - 2){
                LCD.drawString("Izquierda", 3, 2);
            }
            else if( y > lastY + 2){
                LCD.drawString("Derecha", 3, 2);
            }
        }
    }

    public void buttonInputReceived(WRButtonEvent evt) {
        if (evt.isPressed(WRButtonEvent.ONE)){
            LCD.drawString("Avanzar", 5, 2);
        }
        if (evt.isPressed(WRButtonEvent.TWO)){
            LCD.drawString("Retroceder", 5, 2);
        }           
    }

    public void disconnected() {
        System.out.println("Remote disconnected... Please Wii again.");
        System.exit(0);
    }

    public void statusReported(WRStatusEvent evt) {
    }

    public void IRInputReceived(WRIREvent evt) {
    }

    public void extensionConnected(WiiRemoteExtension extension) {
        System.out.println("Extension connected!");
        try {
            remote.setExtensionEnabled(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void extensionPartiallyInserted() {
        System.out.println("Extension partially inserted. Push it in more next time!");
    }

    public void extensionUnknown() {
        System.out.println("Extension unknown. Did you try to plug in a toaster or something?");
    }

    public void extensionDisconnected(WiiRemoteExtension extension) {
        System.out.println("Extension disconnected. Why'd you unplug it, eh?");
    }   

}
Community
  • 1
  • 1

0 Answers0