From c36054596ba38594a9ca1e290acd50f06dd712f9 Mon Sep 17 00:00:00 2001 From: bepo23 Date: Tue, 2 Jun 2009 06:22:12 +0000 Subject: [PATCH] Re-Integrated the project 'Andgee' (wiigee port to Android) into wiigee. For those who don't need android support: Please remove the files to get wiigee compiled without the android SDK installed. I'm looking forward to find a practicable solution for a possible release version to run without modifications or not-needed SDKs installed. Additionally there was an uncommented line within the HMM implementation which should be commented for 'productivity' environments. This has been fixed. Thanks to all the hints given from the wiigee supporters! git-svn-id: svn://svn.code.sf.net/p/wiigee/code/trunk@74 c7eff9ee-dd40-0410-8832-91a4d88773cf --- nbproject/project.properties | 4 +- src/control/AndroidWiigee.java | 108 +++++++++++++++++++++++++++++++++ src/control/WiimoteWiigee.java | 3 - src/device/AndroidDevice.java | 80 ++++++++++++++++++++++++ src/logic/HMM.java | 4 +- 5 files changed, 193 insertions(+), 6 deletions(-) create mode 100644 src/control/AndroidWiigee.java create mode 100644 src/device/AndroidDevice.java diff --git a/nbproject/project.properties b/nbproject/project.properties index 2391cef..8828ce8 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -23,11 +23,13 @@ dist.dir=dist dist.jar=${dist.dir}/wiigee-lib.jar dist.javadoc.dir=${dist.dir}/javadoc excludes= +file.reference.android.jar=../../../android-sdk-mac_x86-1.5_r2/platforms/android-1.5/android.jar file.reference.bluecove-2.1.0.jar=lib/bluecove-2.1.0.jar includes=** jar.compress=false javac.classpath=\ - ${file.reference.bluecove-2.1.0.jar} + ${file.reference.bluecove-2.1.0.jar}:\ + ${file.reference.android.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/src/control/AndroidWiigee.java b/src/control/AndroidWiigee.java new file mode 100644 index 0000000..571a08b --- /dev/null +++ b/src/control/AndroidWiigee.java @@ -0,0 +1,108 @@ +/* + * 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 control; + +import device.AndroidDevice; +import event.GestureListener; +import filter.Filter; +import 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/control/WiimoteWiigee.java b/src/control/WiimoteWiigee.java index c56901f..7bdc9c4 100755 --- a/src/control/WiimoteWiigee.java +++ b/src/control/WiimoteWiigee.java @@ -26,9 +26,6 @@ package control; import java.io.IOException; import java.util.Vector; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.bluetooth.BluetoothStateException; import javax.bluetooth.DiscoveryAgent; import javax.bluetooth.LocalDevice; diff --git a/src/device/AndroidDevice.java b/src/device/AndroidDevice.java new file mode 100644 index 0000000..ca4b2cb --- /dev/null +++ b/src/device/AndroidDevice.java @@ -0,0 +1,80 @@ +/* + * 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 device; + +import android.hardware.SensorListener; +import android.hardware.SensorManager; + +/** + * Android based device implementation + * + * @author liangj01 + * + */ +public class AndroidDevice extends Device implements SensorListener { + + 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; + + } + + @Override + public void onSensorChanged(int sensor, float[] values) { + if (this.accelerationEnabled() && sensor == 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}); + } + } + + @Override + public void onAccuracyChanged(int arg0, int arg1) { + // TODO + } + +} diff --git a/src/logic/HMM.java b/src/logic/HMM.java index 33ff28f..0bfd6d3 100755 --- a/src/logic/HMM.java +++ b/src/logic/HMM.java @@ -135,7 +135,7 @@ public class HMM { double nenner=0; for(int k=0; k