Moved InfraredEvent. Divided DeviceListenerInterface to ButtonListener and AccelerationListener. Added RotationListener for basic Wii Motion Plus support (isn't used for gesture recognition yet), but readout works. wiigee is one of the first libs to support the wii motion plus. Thanks to anyone, who contributed to find out the initialization procedure (wiibrew-wiki, cwiid).
git-svn-id: svn://svn.code.sf.net/p/wiigee/code/trunk@93 c7eff9ee-dd40-0410-8832-91a4d88773cf
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008 Benjamin Poppinga
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
||||
@@ -32,7 +32,7 @@ import org.wiigee.device.*;
|
||||
* This Event would be generated if an acceleration has been detected.
|
||||
* It contains information about the force applied to the device in each
|
||||
* direction (x, y, z). Further it contains the absolute value of this
|
||||
* vector and the source which generated this event (wiimote).
|
||||
* vector and the source which generated this event (Device).
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*
|
||||
@@ -41,10 +41,9 @@ public class AccelerationEvent extends EventObject {
|
||||
|
||||
double X, Y, Z;
|
||||
double absvalue;
|
||||
Device source;
|
||||
|
||||
/**
|
||||
* Create a WiimoteAccelerationEvent with a specific source,
|
||||
* Create an AccelerationEvent with a specific source,
|
||||
* all the three acceleration values and the calculated absolute
|
||||
* value.
|
||||
*
|
||||
@@ -56,16 +55,11 @@ public class AccelerationEvent extends EventObject {
|
||||
*/
|
||||
public AccelerationEvent(Device source, double X, double Y, double Z, double absvalue) {
|
||||
super(source);
|
||||
this.source=source;
|
||||
this.X=X;
|
||||
this.Y=Y;
|
||||
this.Z=Z;
|
||||
this.absvalue=absvalue;
|
||||
}
|
||||
|
||||
public Device getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return X;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008 Benjamin Poppinga
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
||||
@@ -28,40 +28,24 @@ import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* This interface has to be implemented if the application should react
|
||||
* to pure acceleration data or button press/release. This could be
|
||||
* useful if you want to graphically display the acceleration data or
|
||||
* something else in your application.
|
||||
* to pure acceleration data. This could be useful if you want to e.g.
|
||||
* graphically display the acceleration data in your application.
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public interface DeviceListener extends EventListener {
|
||||
public interface AccelerationListener extends EventListener {
|
||||
|
||||
/**
|
||||
* This method would be called if a Wiimote source has been accelerated.
|
||||
* This method would be called if a Device source has been accelerated.
|
||||
*
|
||||
* @param event The acceleration representation as an event.
|
||||
*/
|
||||
public abstract void accelerationReceived(AccelerationEvent event);
|
||||
|
||||
/**
|
||||
* This method would be called if a Wiimote button has been pressed.
|
||||
*
|
||||
* @param event The button representation as an event.
|
||||
*/
|
||||
public abstract void buttonPressReceived(ButtonPressedEvent event);
|
||||
|
||||
/**
|
||||
* This method would be called if a Wiimote button has been released.
|
||||
*
|
||||
* @param event This is actually a meta-event NOT containing which button
|
||||
* has been released.
|
||||
*/
|
||||
public abstract void buttonReleaseReceived(ButtonReleasedEvent event);
|
||||
|
||||
/**
|
||||
* This method would be called if a Wiimote is in idle state and then a
|
||||
* motion starts or if a Wiimote is in motion and then the motion stops and
|
||||
* the Wiimote is in idle state.
|
||||
* This method would be called if a Device is in idle state and then a
|
||||
* motion starts or if a Device is in motion and then the motion stops and
|
||||
* the Device is in idle state.
|
||||
*
|
||||
* @param event This is the event which contains if the Wiimote is now
|
||||
* in motion or not.
|
||||
@@ -69,15 +53,13 @@ public interface DeviceListener extends EventListener {
|
||||
public abstract void motionStartReceived(MotionStartEvent event);
|
||||
|
||||
/**
|
||||
* This method would be called if a Wiimote is in motion and then the motion
|
||||
* stops and the Wiimote is in idle state.
|
||||
* This method would be called if a Device is in motion and then the motion
|
||||
* stops and the Device is in idle state.
|
||||
*
|
||||
* @param event This is the event which contains if the Wiimote is now
|
||||
* @param event This is the event which contains if the Device is now
|
||||
* in motion or not.
|
||||
*/
|
||||
public abstract void motionStopReceived(MotionStopEvent event);
|
||||
|
||||
public abstract void infraredReceived(InfraredEvent event);
|
||||
|
||||
|
||||
}
|
||||
63
src/org/wiigee/event/InfraredEvent.java → src/org/wiigee/event/ButtonListener.java
Executable file → Normal file
63
src/org/wiigee/event/InfraredEvent.java → src/org/wiigee/event/ButtonListener.java
Executable file → Normal file
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008 Benjamin Poppinga
|
||||
*
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: benjamin.poppinga@informatik.uni-oldenburg.de
|
||||
*
|
||||
@@ -16,7 +16,7 @@
|
||||
* 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.
|
||||
@@ -24,40 +24,31 @@
|
||||
|
||||
package org.wiigee.event;
|
||||
|
||||
import java.util.EventObject;
|
||||
import org.wiigee.device.Device;
|
||||
import java.util.EventListener;
|
||||
|
||||
public class InfraredEvent extends EventObject {
|
||||
/**
|
||||
* This interface has to be implemented if the application should react
|
||||
* to button press/releases.
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public interface ButtonListener extends EventListener {
|
||||
|
||||
|
||||
/**
|
||||
* This method would be called if a Device button has been pressed.
|
||||
*
|
||||
* @param event The button representation as an event.
|
||||
*/
|
||||
public abstract void buttonPressReceived(ButtonPressedEvent event);
|
||||
|
||||
/**
|
||||
* This method would be called if a Device button has been released.
|
||||
*
|
||||
* @param event This is actually a meta-event NOT containing which button
|
||||
* has been released.
|
||||
*/
|
||||
public abstract void buttonReleaseReceived(ButtonReleasedEvent event);
|
||||
|
||||
protected Device wiimote;
|
||||
protected int[][] coordinates;
|
||||
protected int[] size;
|
||||
protected boolean[] valid;
|
||||
|
||||
public InfraredEvent(Device source, int[][] coordinates, int[] size) {
|
||||
super(source);
|
||||
this.coordinates=coordinates;
|
||||
this.size=size;
|
||||
this.valid = new boolean[4];
|
||||
for(int i=0; i<this.coordinates.length; i++) {
|
||||
this.valid[i] = (this.coordinates[i][0]<1023 && this.coordinates[i][1]<1023);
|
||||
}
|
||||
}
|
||||
|
||||
public Device getSource() {
|
||||
return this.wiimote;
|
||||
}
|
||||
|
||||
public boolean isValid(int i) {
|
||||
return this.valid[i];
|
||||
}
|
||||
|
||||
public int[][] getCoordinates() {
|
||||
return this.coordinates;
|
||||
}
|
||||
|
||||
public int[] getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user