From d6a6705bef789b179a090febb746c53f6428a943 Mon Sep 17 00:00:00 2001 From: bepo23 Date: Fri, 5 Jun 2009 08:54:45 +0000 Subject: [PATCH] Renamed package namespaces to assure a better usability with other libraries. git-svn-id: svn://svn.code.sf.net/p/wiigee/code/trunk@87 c7eff9ee-dd40-0410-8832-91a4d88773cf --- src/org/wiigee/control/AndroidWiigee.java | 108 ----- .../control/WiimoteDeviceDiscovery.java | 108 ----- src/org/wiigee/control/WiimoteWiigee.java | 193 --------- src/org/wiigee/device/AndroidDevice.java | 83 ---- src/org/wiigee/device/Device.java | 2 - src/org/wiigee/device/Wiimote.java | 401 ------------------ src/org/wiigee/device/WiimoteStreamer.java | 298 ------------- src/org/wiigee/event/InfraredEvent.java | 8 +- 8 files changed, 4 insertions(+), 1197 deletions(-) delete mode 100644 src/org/wiigee/control/AndroidWiigee.java delete mode 100755 src/org/wiigee/control/WiimoteDeviceDiscovery.java delete mode 100755 src/org/wiigee/control/WiimoteWiigee.java delete mode 100644 src/org/wiigee/device/AndroidDevice.java delete mode 100755 src/org/wiigee/device/Wiimote.java delete mode 100755 src/org/wiigee/device/WiimoteStreamer.java diff --git a/src/org/wiigee/control/AndroidWiigee.java b/src/org/wiigee/control/AndroidWiigee.java deleted file mode 100644 index 3ee43e7..0000000 --- a/src/org/wiigee/control/AndroidWiigee.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * wiigee - accelerometerbased gesture recognition - * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga - * - * Developed at University of Oldenburg - * Contact: benjamin.poppinga@informatik.uni-oldenburg.de - * - * This file is part of wiigee. - * - * wiigee is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -package org.wiigee.control; - -import org.wiigee.device.AndroidDevice; -import org.wiigee.event.GestureListener; -import org.wiigee.filter.Filter; -import org.wiigee.util.Log; - -/** - * This is for using wiigee on Android Smartphones. This port has been - * initiated by Maarten 'MrSnowflake' Krijn and updated by 'zl25drexel' - * under the pseudonym 'Andgee'. - * - * It has been re-integrated into wiigee on 29th May of 2009. - * - * @author Maarten 'MrSnowflake' Krijn - * @author zl25drexel - * @author Benjamin 'BePo' Poppinga - */ -public class AndroidWiigee { - - protected static String version = "1.0 alpha"; - protected static String releasedate = "20090529"; - protected static AndroidWiigee instance; - - private AndroidDevice device; - - private AndroidWiigee() { - device = new AndroidDevice(); - } - - public static synchronized AndroidWiigee getInstance() { - Log.write("This is AndroidWiigee (Andgee) version "+version+" ("+releasedate+")"); - Log.write("This is an Android adaptation of Wiigee (http://wiigee.sourceforge.net/)"); - Log.write("So many thanks to the Wiigee team for their awsome recognition lib!"); - - if(instance == null) { - instance = new AndroidWiigee(); - return instance; - } else { - return instance; - } - } - - public void addGestureListener(GestureListener listener) { - device.addGestureListener(listener); - } - - public void addFilter(Filter filter) { - device.addFilter(filter); - } - - - public AndroidDevice getDevice() { - return device; - } - - - /** - * Sets the Trainbutton for all wiimotes; - * - * @param b Button encoding, see static Wiimote values - */ - public void setTrainButton(int b) { - device.setTrainButton(b); - } - - /** - * Sets the Recognitionbutton for all wiimotes; - * - * @param b Button encoding, see static Wiimote values - */ - public void setRecognitionButton(int b) { - device.setRecognitionButton(b); - } - - /** - * Sets the CloseGesturebutton for all wiimotes; - * - * @param b Button encoding, see static Wiimote values - */ - public void setCloseGestureButton(int b) { - device.setCloseGestureButton(b); - } - -} diff --git a/src/org/wiigee/control/WiimoteDeviceDiscovery.java b/src/org/wiigee/control/WiimoteDeviceDiscovery.java deleted file mode 100755 index 84b707c..0000000 --- a/src/org/wiigee/control/WiimoteDeviceDiscovery.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * wiigee - accelerometerbased gesture recognition - * Copyright (C) 2007, 2008 Benjamin Poppinga - * - * Developed at University of Oldenburg - * Contact: benjamin.poppinga@informatik.uni-oldenburg.de - * - * This file is part of wiigee. - * - * wiigee is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.wiigee.control; - -import java.io.IOException; -import java.util.Vector; - -import javax.bluetooth.DeviceClass; -import javax.bluetooth.DiscoveryListener; -import javax.bluetooth.RemoteDevice; -import javax.bluetooth.ServiceRecord; - -import org.wiigee.util.Log; - -import org.wiigee.device.Wiimote; - -public class WiimoteDeviceDiscovery implements DiscoveryListener { - - private Vector devices; - private boolean isInquiring; - private Object lock; - - public WiimoteDeviceDiscovery(Object lock) { - super(); - this.lock=lock; - this.devices = new Vector(); - //this.isInquiring=true; - } - - public void deviceDiscovered(RemoteDevice newdevice, DeviceClass devclass) { - Log.write("Device discovered: " - + newdevice.getBluetoothAddress() + " - "); - // add the device to the vector - if (!devices.contains(newdevice) - && devclass.getMajorDeviceClass() == 1280 - && devclass.getMinorDeviceClass() == 4) { - Log.write("Is a Wiimote!"); - devices.addElement(newdevice); - } else { - Log.write("Is NOT a Wiimote!"); - } - } - - public void inquiryCompleted(int discType) { - switch (discType) { - case WiimoteDeviceDiscovery.INQUIRY_COMPLETED: - Log.write("Inquiry completed."); - break; - - case WiimoteDeviceDiscovery.INQUIRY_ERROR: - Log.write("Inquiry error."); - break; - - case WiimoteDeviceDiscovery.INQUIRY_TERMINATED: - Log.write("Inquiry terminated."); - break; - } - synchronized(this.lock) { - this.lock.notify(); - } - //this.isInquiring=false; - } - - public void serviceSearchCompleted(int arg0, int arg1) { - // not necessary - } - - public void servicesDiscovered(int arg0, ServiceRecord[] arg1) { - // not necessary - } - - public boolean isInquirying() { - return this.isInquiring; - } - - public Vector getDiscoveredWiimotes() throws IOException { - Vector wiimotes = new Vector(); - - for (int i = 0; i < devices.size(); i++) { - wiimotes.add(new Wiimote(devices.elementAt(i).getBluetoothAddress())); - } - - return wiimotes; - } - -} diff --git a/src/org/wiigee/control/WiimoteWiigee.java b/src/org/wiigee/control/WiimoteWiigee.java deleted file mode 100755 index 3843b6b..0000000 --- a/src/org/wiigee/control/WiimoteWiigee.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * wiigee - accelerometerbased gesture recognition - * Copyright (C) 2007, 2008 Benjamin Poppinga - * - * Developed at University of Oldenburg - * Contact: benjamin.poppinga@informatik.uni-oldenburg.de - * - * This file is part of wiigee. - * - * wiigee is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -package org.wiigee.control; - -import java.io.IOException; -import java.util.Vector; - -import javax.bluetooth.DiscoveryAgent; -import javax.bluetooth.LocalDevice; - -import org.wiigee.util.Log; -import org.wiigee.device.Wiimote; -import org.wiigee.event.DeviceListener; -import org.wiigee.event.GestureListener; -import org.wiigee.filter.Filter; - -// Singleton -public class WiimoteWiigee { - - protected static String version = "1.5 alpha"; - protected static String releasedate = "20090524"; - protected static WiimoteWiigee instance; - private static Object lock = new Object(); - private Vector devices; - - private WiimoteWiigee() { - String stack; - String stackVersion; - String l2capFeature; - String bluecoveVersion; - - Log.write("This is wiigee version " + version + " (" + releasedate + ")"); - - // Bluecove - bluecoveVersion = LocalDevice.getProperty("bluecove"); - if(!bluecoveVersion.equals("")) { - - stack = LocalDevice.getProperty("bluecove.stack"); - stackVersion = LocalDevice.getProperty("bluecove.stack.version"); - Log.write("You are using the "+stack+" Bluetooth stack (Version "+stackVersion+")"); - - l2capFeature = LocalDevice.getProperty("bluecove.feature.l2cap"); - Log.write("L2CAP supported: "+l2capFeature); - - if(l2capFeature.equals("true")) { - Log.write("wiigee: found a supported stack!"); - - // set min id for Bluecove - Log.write(Log.DEBUG, "JSR82 PSM Minimum Restriction -- OFF", null); - System.setProperty("bluecove.jsr82.psm_minimum_off", "true"); - } - } else { - Log.write("No Bluecove Library detected - trying anyway..."); - } - } - - public static WiimoteWiigee getInstance() { - if (instance == null) { - instance = new WiimoteWiigee(); - return instance; - } else { - return instance; - } - } - - /** - * Returns an array of discovered wiimotes. - * - * @return Array of discovered wiimotes or null if - * none discoverd. - */ - public Wiimote[] getDevices() throws IOException { - this.devices = this.discoverWiimotes(); - for (int i = 0; i < this.devices.size(); i++) { - this.devices.elementAt(i).setLED(i + 1); - } - Wiimote[] out = new Wiimote[this.devices.size()]; - for (int i = 0; i < this.devices.size(); i++) { - out[i] = this.devices.elementAt(i); - } - return out; - } - - /** - * Discover the wiimotes around the bluetooth host and - * make them available public via getWiimotes method. - * - * @return Array of discovered wiimotes. - */ - private Vector discoverWiimotes() throws IOException { - WiimoteDeviceDiscovery deviceDiscovery = new WiimoteDeviceDiscovery(lock); - LocalDevice localDevice = LocalDevice.getLocalDevice(); - Log.write("Your Computers Bluetooth MAC: " + localDevice.getBluetoothAddress()); - - Log.write("Starting device inquiry..."); - DiscoveryAgent discoveryAgent = localDevice.getDiscoveryAgent(); - discoveryAgent.startInquiry(DiscoveryAgent.GIAC, deviceDiscovery); - - - try { - synchronized (lock) { - lock.wait(); - } - } catch (InterruptedException e) { - Log.write("Problems during device discovery."); - e.printStackTrace(); - } - - Log.write("Device discovery completed!"); - return deviceDiscovery.getDiscoveredWiimotes(); - } - - /** - * Returns the number of wiimotes discovered. - * - * @return Number of wiimotes discovered. - */ - public int getNumberOfDevices() { - return this.devices.size(); - } - - /** - * Sets the Trainbutton for all wiimotes; - * - * @param b Button encoding, see static Wiimote values - */ - public void setTrainButton(int b) { - for (int i = 0; i < this.devices.size(); i++) { - this.devices.elementAt(i).setTrainButton(b); - } - } - - /** - * Sets the Recognitionbutton for all wiimotes; - * - * @param b Button encoding, see static Wiimote values - */ - public void setRecognitionButton(int b) { - for (int i = 0; i < this.devices.size(); i++) { - this.devices.elementAt(i).setRecognitionButton(b); - } - } - - /** - * Sets the CloseGesturebutton for all wiimotes; - * - * @param b Button encoding, see static Wiimote values - */ - public void setCloseGestureButton(int b) { - for (int i = 0; i < this.devices.size(); i++) { - this.devices.elementAt(i).setCloseGestureButton(b); - } - } - - public void addDeviceListener(DeviceListener listener) { - for (int i = 0; i < this.devices.size(); i++) { - this.devices.elementAt(i).addDeviceListener(listener); - } - } - - public void addGestureListener(GestureListener listener) { - for (int i = 0; i < this.devices.size(); i++) { - this.devices.elementAt(i).addGestureListener(listener); - } - } - - public void addFilter(Filter filter) { - for (int i = 0; i < this.devices.size(); i++) { - this.devices.elementAt(i).addFilter(filter); - } - } -} diff --git a/src/org/wiigee/device/AndroidDevice.java b/src/org/wiigee/device/AndroidDevice.java deleted file mode 100644 index 2ffbf99..0000000 --- a/src/org/wiigee/device/AndroidDevice.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * wiigee - accelerometerbased gesture recognition - * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga - * - * Developed at University of Oldenburg - * Contact: benjamin.poppinga@informatik.uni-oldenburg.de - * - * This file is part of wiigee. - * - * wiigee is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.wiigee.device; - -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; - -/** - * Android based device implementation - * - * @author liangj01 - * - */ -public class AndroidDevice extends Device implements SensorEventListener { - - private float x0, y0, z0, x1, y1, z1; - - public AndroidDevice() { - // 'Calibrate' values - this.x0 = 0; - this.y0 = -SensorManager.STANDARD_GRAVITY; - this.z0 = 0; - this.x1 = SensorManager.STANDARD_GRAVITY; - this.y1 = 0; - this.z1 = SensorManager.STANDARD_GRAVITY; - - } - - public void onSensorChanged(SensorEvent sevent) { - Sensor sensor = sevent.sensor; - float[] values = sevent.values; - - if (this.accelerationEnabled() && sensor.getType() == SensorManager.SENSOR_ACCELEROMETER) { - - double x, y, z; - float xraw, yraw, zraw; - /* - * calculation of acceleration vectors starts here. further - * information about normation exist in the public papers or - * the various www-sources. - * - */ - xraw = values[SensorManager.DATA_X]; - yraw = values[SensorManager.DATA_Y]; - zraw = values[SensorManager.DATA_Z]; - - x = (double) (xraw - x0) / (double) (x1 - x0); - y = (double) (yraw - y0) / (double) (y1 - y0); - z = (double) (zraw - z0) / (double) (z1 - z0); - - this.fireAccelerationEvent(new double[] {x, y, z}); - } - } - - public void onAccuracyChanged(Sensor arg0, int arg1) { - // Nothing to do. - } - -} diff --git a/src/org/wiigee/device/Device.java b/src/org/wiigee/device/Device.java index 0696513..7102bd3 100644 --- a/src/org/wiigee/device/Device.java +++ b/src/org/wiigee/device/Device.java @@ -24,8 +24,6 @@ package org.wiigee.device; -import org.wiigee.logic.ProcessingUnit; -import org.wiigee.logic.TriggeredProcessingUnit; import java.io.IOException; import java.util.Vector; diff --git a/src/org/wiigee/device/Wiimote.java b/src/org/wiigee/device/Wiimote.java deleted file mode 100755 index b560618..0000000 --- a/src/org/wiigee/device/Wiimote.java +++ /dev/null @@ -1,401 +0,0 @@ -/* - * wiigee - accelerometerbased gesture recognition - * Copyright (C) 2007, 2008 Benjamin Poppinga - * - * Developed at University of Oldenburg - * Contact: benjamin.poppinga@informatik.uni-oldenburg.de - * - * This file is part of wiigee. - * - * wiigee is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package org.wiigee.device; - -import java.io.IOException; -import java.util.Random; -import javax.bluetooth.L2CAPConnection; -import javax.microedition.io.Connector; -import org.wiigee.event.*; -import org.wiigee.util.Log; - -/** - * @author Benjamin 'BePo' Poppinga - * This class represents the basic functions of the wiimote. - * If you want your wiimote to e.g. vibrate you'll do this here. - * - */ -public class Wiimote extends Device { - - // Fixed number values. - public static final int MOTION = 0; - public static final int BUTTON_2 = 1; - public static final int BUTTON_1 = 2; - public static final int BUTTON_B = 3; - public static final int BUTTON_A = 4; - public static final int BUTTON_MINUS = 5; - public static final int BUTTON_HOME = 8; - public static final int BUTTON_LEFT = 9; - public static final int BUTTON_RIGHT = 10; - public static final int BUTTON_DOWN = 11; - public static final int BUTTON_UP = 12; - public static final int BUTTON_PLUS = 13; - - // Reports - public static final byte CMD_SET_REPORT = 0x52; - - // IR Modes - public static final byte IR_MODE_STANDARD = 1; - public static final byte IR_MODE_EXTENDED = 0x03; - - // Modes / Channels - public static final byte MODE_BUTTONS = 0x30; - public static final byte MODE_BUTTONS_ACCELERATION = 0x31; - public static final byte MODE_BUTTONS_ACCELERATION_INFRARED = 0x33; - - - // Bluetooth-adress as string representation - private String btaddress; - - // LED encoded as byte - byte ledencoding; - - - // control connection, send commands to wiimote - private L2CAPConnection controlCon; - - // receive connection, receive answers from wiimote - private L2CAPConnection receiveCon; - - - // Functional - private boolean vibrating; - private boolean calibrated; - private boolean infraredenabled; - private WiimoteStreamer wms; - - - /** - * Creates a new wiimote-device with a specific bluetooth mac-adress. - * - * @param btaddress - * String representation of the mac-adress e.g. 00191D68B57C - */ - public Wiimote(String btaddress) throws IOException { - btaddress = this.removeChar(btaddress, ':'); - this.btaddress=btaddress; - this.vibrating=false; - this.connect(); - this.calibrateAccelerometer(); - this.streamData(true); - this.enableAccelerationSensors(); - //this.enableInfraredCamera(); - } - - /** - * Creates the two needed connections to send and receive commands - * to and from the wiimote-device. - * - */ - public void connect() throws IOException { - this.controlCon = (L2CAPConnection)Connector.open("btl2cap://"+ - this.btaddress+":11;authenticate=false;encrypt=false;master=false", - Connector.WRITE); // 11 - this.receiveCon = (L2CAPConnection)Connector.open("btl2cap://"+ - this.btaddress+":13;authenticate=false;encrypt=false;master=false", - Connector.READ); // 13 - } - - /** - * Disconnects the wiimote and closes the two connections. - */ - public void disconnect() { - this.vibrating=false; - try { - this.controlCon.close(); - this.receiveCon.close(); - Log.write("Disconnected wiimote."); - } catch(Exception e) { - Log.write("Failure during disconnect of wiimote."); - } - } - - /** - * @return - * Receiving data connection - */ - public L2CAPConnection getReceiveConnection() { - return this.receiveCon; - } - - /** - * This method makes the Wiimote-Class reacting to incoming data. - * For just controlling and sending commands to the wiimote - * (vibration, LEDs, ...) it's not necessary to call this method. - * - * @param value - * true, if the class should react to incoming data. - * false, if you only want to send commands to wiimote and - * only the control-connection is used. - */ - public void streamData(boolean value) { - if(value==true) { - if(this.wms==null) { - this.wms = new WiimoteStreamer(this); - } - wms.start(); } - else if(this.wms!=null) { - wms.stopThread(); - } - } - - /** - * Write data to a register inside of the wiimote. - * - * @param offset The memory offset, 3 bytes. - * @param data The data to be written, max. 16 bytes. - * @throws IOException - */ - public void writeRegister(byte[] offset, byte[] data) throws IOException { - byte[] raw = new byte[23]; - raw[0] = CMD_SET_REPORT; - raw[1] = 0x16; // Write channel - raw[2] = 0x04; // Register - for(int i=0; i0) { - byte tmp = (byte)value; - this.ledencoding=(byte)(tmp<<4); - this.sendRaw(new byte[] {CMD_SET_REPORT, 0x11, this.ledencoding}); - } else { - // Random LED change :) - this.setLED(new Random().nextInt(16)); - } - } - - /** - * Initializes the calibration of the accerlarometer. This is done once - * per each controller in program lifetime. - * - * @throws IOException - */ - private void calibrateAccelerometer() throws IOException { - // calibration command - this.readEEPROM(new byte[] {0x00, 0x00, 0x20}, new byte[] {0x00, 0x07}); - this.calibrated=true; - } - - /** - * Activates the acceleration sensor. You have to call the - * streamData(true) method to react to this acceleration data. - * Otherwise the wiimote would send data the whole time and - * nothing else would happen. - * - */ - @Override - public void enableAccelerationSensors() throws IOException { - super.enableAccelerationSensors(); - if(!this.calibrated) { - this.calibrateAccelerometer(); - } - - // enable acceleration in continuous mode - this.sendRaw(new byte[] {CMD_SET_REPORT, 0x12, 0x04, 0x31}); - } - - /** - * Deactivates the acceleration sensors. - * - */ - @Override - public void disableAccelerationSensors() throws IOException { - super.disableAccelerationSensors(); - this.sendRaw(new byte[] {CMD_SET_REPORT, 0x12, 0x00, 0x30}); - } - - /** - * Enables the infrared camera in front of the wiimote to track - * IR sources in the field of view of the camera. This could be used - * to a lot of amazing stuff. Using this Mode could slow down the - * recognition of acceleration gestures during the increased data - * size transmitted. - */ - public void enableInfraredCamera() throws IOException { - this.accelerationenabled=true; - this.infraredenabled=true; - if(!this.calibrated) { - this.calibrateAccelerometer(); - } - - //write 0x04 to output 0x13 - this.sendRaw(new byte[] {CMD_SET_REPORT, 0x13, 0x04}); - - // write 0x04 to output 0x1a - this.sendRaw(new byte[] {CMD_SET_REPORT, 0x1a, 0x04}); - - // write 0x08 to reguster 0xb00030 - this.writeRegister(new byte[] {(byte)0xb0, 0x00, 0x30}, new byte[] {0x08}); - - // write sensivity block 1 to register 0xb00000 - this.writeRegister(new byte[] {(byte)0xb0, 0x00, 0x00}, new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte)0x90, 0x00, (byte)0xc0}); - - // write sensivity block 2 to register 0xb0001a - this.writeRegister(new byte[] {(byte)0xb0, 0x00, (byte)0x1a}, new byte[] {0x40, 0x00}); - - // write ir-mode to register 0xb00033 - this.writeRegister(new byte[] {(byte)0xb0, 0x00, 0x33}, new byte[] {0x03}); - - // enable continuous acceleration and IR cam on channel 33 - this.sendRaw(new byte[] {CMD_SET_REPORT, 0x12, 0x00, 0x33}); - - } - - - /** - * With this method you gain access over the vibrate function of - * the wiimote. You got to try which time in milliseconds would - * fit your requirements. - * - * @param milliseconds - * time the wiimote would vibrate - */ - public void vibrateForTime(long milliseconds) throws IOException { - try { - if(!vibrating) { - this.vibrating=true; - byte tmp = (byte)(this.ledencoding | 0x01); - this.sendRaw(new byte[] {CMD_SET_REPORT, 0x11, tmp}); - Thread.sleep(milliseconds); - this.sendRaw(new byte[] {CMD_SET_REPORT, 0x11, this.ledencoding}); - this.vibrating=false; - } - } catch (InterruptedException e) { - System.out.println("WiiMoteThread interrupted."); - } - } - - public boolean infraredEnabled() { - return this.infraredenabled; - } - - // ###### Hilfsmethoden - // TODO - private String removeChar(String s, char c) { - String r = ""; - for (int i = 0; i < s.length(); i ++) { - if (s.charAt(i) != c) r += s.charAt(i); - } - return r; - } - - /** - * Fires a infrared event - * - * @param coordinates - * @param size - */ - public void fireInfraredEvent(int[][] coordinates, int[] size) { - InfraredEvent w = new InfraredEvent(this, coordinates, size); - for(int i=0; i