This commit is contained in:
79
java/src/org/wiigee/event/AccelerationEvent.java
Normal file
79
java/src/org/wiigee/event/AccelerationEvent.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
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 (Device).
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*
|
||||
*/
|
||||
public class AccelerationEvent extends EventObject {
|
||||
|
||||
double X, Y, Z;
|
||||
double absvalue;
|
||||
|
||||
/**
|
||||
* Create an AccelerationEvent with a specific source,
|
||||
* all the three acceleration values and the calculated absolute
|
||||
* value.
|
||||
*
|
||||
* @param source The source which has been accelerated (Wiimote).
|
||||
* @param X The value of acceleration in the x direction.
|
||||
* @param Y The value of acceleration in the y direction.
|
||||
* @param Z The value of acceleration in the z direction.
|
||||
* @param absvalue The absolute value of this acceleration vector.
|
||||
*/
|
||||
public AccelerationEvent(Device source, double X, double Y, double Z, double absvalue) {
|
||||
super(source);
|
||||
this.X=X;
|
||||
this.Y=Y;
|
||||
this.Z=Z;
|
||||
this.absvalue=absvalue;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return X;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return Y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return Z;
|
||||
}
|
||||
|
||||
public double getAbsValue() {
|
||||
return absvalue;
|
||||
}
|
||||
}
|
||||
65
java/src/org/wiigee/event/AccelerationListener.java
Normal file
65
java/src/org/wiigee/event/AccelerationListener.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* This interface has to be implemented if the application should react
|
||||
* 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 AccelerationListener extends EventListener {
|
||||
|
||||
/**
|
||||
* 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 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.
|
||||
*/
|
||||
public abstract void motionStartReceived(MotionStartEvent event);
|
||||
|
||||
/**
|
||||
* 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 Device is now
|
||||
* in motion or not.
|
||||
*/
|
||||
public abstract void motionStopReceived(MotionStopEvent event);
|
||||
|
||||
|
||||
}
|
||||
84
java/src/org/wiigee/event/ActionStartEvent.java
Normal file
84
java/src/org/wiigee/event/ActionStartEvent.java
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
import org.wiigee.device.Device;
|
||||
|
||||
/**
|
||||
* An ActionStartEvent is an Event where other different events can
|
||||
* be derived from, if they can be considered as an event actually starting
|
||||
* a process like e.g. Training, Recognition, ...
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public class ActionStartEvent extends EventObject {
|
||||
|
||||
protected boolean trainbutton;
|
||||
protected boolean recognitionbutton;
|
||||
protected boolean closegesturebutton;
|
||||
|
||||
public ActionStartEvent(Device source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is true if this button press has been done by the
|
||||
* individual defined RecognitionButton which has to be
|
||||
* set during initialization of a Wiimote.
|
||||
*
|
||||
* @return Is this button press initiated by the recognition button.
|
||||
* @see device.Wiimote#setRecognitionButton(int) setRecognitionButton()
|
||||
*/
|
||||
public boolean isRecognitionInitEvent() {
|
||||
return this.recognitionbutton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is true if this button press has been done by the
|
||||
* individual defined TrainButton which has to be
|
||||
* set during initialization of a Wiimote.
|
||||
*
|
||||
* @return Is this button pres initiated by the training button.
|
||||
* @see device.Wiimote#setTrainButton(int) setTrainButton()
|
||||
*/
|
||||
public boolean isTrainInitEvent() {
|
||||
return this.trainbutton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is true if this button press has been done by the
|
||||
* individual defined CloseGestureButton which has to be
|
||||
* set during initialization of a Wiimote.
|
||||
*
|
||||
* @return Is this button press initiated by the close gesture button.
|
||||
* @see device.Wiimote#setCloseGestureButton(int) setCloseGestureButton()
|
||||
*/
|
||||
public boolean isCloseGestureInitEvent() {
|
||||
return this.closegesturebutton;
|
||||
}
|
||||
|
||||
}
|
||||
43
java/src/org/wiigee/event/ActionStopEvent.java
Normal file
43
java/src/org/wiigee/event/ActionStopEvent.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import java.util.EventObject;
|
||||
import org.wiigee.device.Device;
|
||||
|
||||
/**
|
||||
* An ActionStopEvent is an Event where other different events can
|
||||
* be derived from, if they can be considered as an event actually stopping
|
||||
* a process like e.g. Training, Recognition, ...
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public class ActionStopEvent extends EventObject {
|
||||
|
||||
public ActionStopEvent(Device source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
}
|
||||
54
java/src/org/wiigee/event/ButtonListener.java
Normal file
54
java/src/org/wiigee/event/ButtonListener.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
|
||||
}
|
||||
80
java/src/org/wiigee/event/ButtonPressedEvent.java
Normal file
80
java/src/org/wiigee/event/ButtonPressedEvent.java
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import org.wiigee.device.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* This Event would be generated if a button on a wiimote has been
|
||||
* pressed by user. It contains the source (wiimote) and an integer
|
||||
* representation of which button has been pressed. Please note that
|
||||
* there exist enumeration constants in the class, so you don't
|
||||
* have to use this integer values directly.
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public class ButtonPressedEvent extends ActionStartEvent {
|
||||
|
||||
// Fixed number values.
|
||||
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;
|
||||
|
||||
int button;
|
||||
|
||||
/**
|
||||
* Create a WiimoteButtonPressedEvent with the Wiimote source whose
|
||||
* Button has been pressed and the integer representation of the button.
|
||||
*
|
||||
* @param source
|
||||
* @param button
|
||||
*/
|
||||
public ButtonPressedEvent(Device source, int button) {
|
||||
super(source);
|
||||
this.button=button;
|
||||
|
||||
if(source.getRecognitionButton()==button) {
|
||||
this.recognitionbutton=true;
|
||||
} else if(source.getTrainButton()==button) {
|
||||
this.trainbutton=true;
|
||||
} else if(source.getCloseGestureButton()==button) {
|
||||
this.closegesturebutton=true;
|
||||
}
|
||||
}
|
||||
|
||||
public int getButton() {
|
||||
return this.button;
|
||||
}
|
||||
|
||||
}
|
||||
49
java/src/org/wiigee/event/ButtonReleasedEvent.java
Normal file
49
java/src/org/wiigee/event/ButtonReleasedEvent.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import org.wiigee.device.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* This event would be generated if a button was released.
|
||||
* contains: source (wiimote).
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public class ButtonReleasedEvent extends ActionStopEvent {
|
||||
|
||||
int button;
|
||||
|
||||
public ButtonReleasedEvent(Device source, int button) {
|
||||
super(source);
|
||||
this.button = button;
|
||||
}
|
||||
|
||||
public int getButton() {
|
||||
return this.button;
|
||||
}
|
||||
|
||||
}
|
||||
71
java/src/org/wiigee/event/GestureEvent.java
Normal file
71
java/src/org/wiigee/event/GestureEvent.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import org.wiigee.logic.ProcessingUnit;
|
||||
|
||||
/**
|
||||
* This event would be generated if a gesture has been detected.
|
||||
* It contains information about the gesture "name" or type,
|
||||
* the accelerationstreamanalyzer which generated the event (source)
|
||||
* and the probability calculated from the bayes classifier.
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public class GestureEvent {
|
||||
|
||||
int id;
|
||||
boolean valid;
|
||||
double probability;
|
||||
ProcessingUnit analyzer;
|
||||
|
||||
/** Create a GestureEvent
|
||||
*
|
||||
* @param source The Source, which detected the gesture.
|
||||
* @param id A gesture ID for identifying a gesture.
|
||||
* @param probability The Bayes-Classifier calculated probability.
|
||||
*/
|
||||
public GestureEvent(ProcessingUnit source, boolean valid, int id, double probability) {
|
||||
this.analyzer = source;
|
||||
this.valid = valid;
|
||||
this.id = id;
|
||||
this.probability = probability;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return this.valid;
|
||||
}
|
||||
|
||||
public double getProbability() {
|
||||
return this.probability;
|
||||
}
|
||||
|
||||
public ProcessingUnit getSource() {
|
||||
return this.analyzer;
|
||||
}
|
||||
}
|
||||
47
java/src/org/wiigee/event/GestureListener.java
Normal file
47
java/src/org/wiigee/event/GestureListener.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
*
|
||||
* This is the GestureListener interface which has to be implemented
|
||||
* by any application which should receive recognized gestures.
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*
|
||||
*/
|
||||
public interface GestureListener extends EventListener {
|
||||
|
||||
/**
|
||||
* This method would be called if a gesture has been recognized.
|
||||
*
|
||||
* @param event The GestureEvent containing information about
|
||||
* the recognized gesture.
|
||||
*/
|
||||
public abstract void gestureReceived(GestureEvent event);
|
||||
|
||||
}
|
||||
69
java/src/org/wiigee/event/InfraredEvent.java
Normal file
69
java/src/org/wiigee/event/InfraredEvent.java
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import java.util.EventObject;
|
||||
import org.wiigee.device.Device;
|
||||
|
||||
/**
|
||||
* An infrared event consists of a set of coordinates, containing values
|
||||
* from [0, 1024] in width to [0, 768] in height. for each point there is
|
||||
* a given size and if the detected infrared spot is valid.
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public class InfraredEvent extends EventObject {
|
||||
|
||||
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 boolean[] getValids() {
|
||||
return this.valid;
|
||||
}
|
||||
|
||||
public boolean isValid(int i) {
|
||||
return this.valid[i];
|
||||
}
|
||||
|
||||
public int[][] getCoordinates() {
|
||||
return this.coordinates;
|
||||
}
|
||||
|
||||
public int[] getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
}
|
||||
40
java/src/org/wiigee/event/InfraredListener.java
Normal file
40
java/src/org/wiigee/event/InfraredListener.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* Interface to implement if a class should receive InfraredEvents
|
||||
* via the given method. Therefore implement this Interface and add
|
||||
* the class as a Listener to the Wiimote.
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public interface InfraredListener extends EventListener {
|
||||
|
||||
public abstract void infraredReceived(InfraredEvent event);
|
||||
|
||||
}
|
||||
63
java/src/org/wiigee/event/MotionStartEvent.java
Normal file
63
java/src/org/wiigee/event/MotionStartEvent.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import org.wiigee.device.Device;
|
||||
|
||||
/**
|
||||
* This Event gets fired, if the Device starts to move.
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public class MotionStartEvent extends ActionStartEvent {
|
||||
|
||||
public MotionStartEvent(Device source) {
|
||||
super(source);
|
||||
|
||||
if(source.getRecognitionButton()==Device.MOTION) {
|
||||
this.recognitionbutton=true;
|
||||
} else if(source.getTrainButton()==Device.MOTION) {
|
||||
this.trainbutton=true;
|
||||
} else if(source.getCloseGestureButton()==Device.MOTION) {
|
||||
this.closegesturebutton=true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTrainInitEvent() {
|
||||
return this.trainbutton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCloseGestureInitEvent() {
|
||||
return this.closegesturebutton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecognitionInitEvent() {
|
||||
return this.recognitionbutton;
|
||||
}
|
||||
|
||||
}
|
||||
42
java/src/org/wiigee/event/MotionStopEvent.java
Normal file
42
java/src/org/wiigee/event/MotionStopEvent.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import org.wiigee.device.Device;
|
||||
|
||||
/**
|
||||
*
|
||||
* This event would be generated if a motion stops.
|
||||
* contains: source.
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public class MotionStopEvent extends ActionStopEvent {
|
||||
|
||||
public MotionStopEvent(Device source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
}
|
||||
65
java/src/org/wiigee/event/RotationEvent.java
Normal file
65
java/src/org/wiigee/event/RotationEvent.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import java.util.EventObject;
|
||||
import org.wiigee.device.Device;
|
||||
|
||||
/**
|
||||
* A RotationEvents contains the current relative rotation to the last
|
||||
* given reset position. If the device has never been resetted before,
|
||||
* the last position is the Wiimotes initial position. This event contains
|
||||
* all three angles - pitch, yaw, roll - which are only determined using
|
||||
* the Wii Motion Plus extension. There wouldn't be a RotationEvent without
|
||||
* this extension.
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public class RotationEvent extends EventObject {
|
||||
|
||||
protected double pitch;
|
||||
protected double yaw;
|
||||
protected double roll;
|
||||
|
||||
public RotationEvent(Device source, double pitch, double roll, double yaw) {
|
||||
super(source);
|
||||
this.pitch = pitch;
|
||||
this.roll = roll;
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
public double getPitch() {
|
||||
return this.pitch;
|
||||
}
|
||||
|
||||
public double getYaw() {
|
||||
return this.yaw;
|
||||
}
|
||||
|
||||
public double getRoll() {
|
||||
return this.roll;
|
||||
}
|
||||
|
||||
}
|
||||
43
java/src/org/wiigee/event/RotationListener.java
Normal file
43
java/src/org/wiigee/event/RotationListener.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* Implement this interface to get informed about events only
|
||||
* occuring if a Wii Motion Plus is attached. If implemented and added
|
||||
* as a Listener, the RotationSpeedEvents and RotationEvent would be
|
||||
* retrieved.
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public interface RotationListener extends EventListener {
|
||||
|
||||
public abstract void rotationSpeedReceived(RotationSpeedEvent event);
|
||||
|
||||
public abstract void rotationReceived(RotationEvent event);
|
||||
|
||||
}
|
||||
60
java/src/org/wiigee/event/RotationSpeedEvent.java
Normal file
60
java/src/org/wiigee/event/RotationSpeedEvent.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* wiigee - accelerometerbased gesture recognition
|
||||
* Copyright (C) 2007, 2008, 2009 Benjamin Poppinga
|
||||
*
|
||||
* Developed at University of Oldenburg
|
||||
* Contact: wiigee@benjaminpoppinga.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.event;
|
||||
|
||||
import java.util.EventObject;
|
||||
import org.wiigee.device.Device;
|
||||
|
||||
/**
|
||||
* The RotationSpeedEvent contains the raw angle velocities - psi, theta, phi.
|
||||
* This event only occurs, if a Wii Motion Plus is attached.
|
||||
*
|
||||
* @author Benjamin 'BePo' Poppinga
|
||||
*/
|
||||
public class RotationSpeedEvent extends EventObject {
|
||||
|
||||
protected double psi;
|
||||
protected double theta;
|
||||
protected double phi;
|
||||
|
||||
public RotationSpeedEvent(Device source, double psi, double theta, double phi) {
|
||||
super(source);
|
||||
this.psi = psi;
|
||||
this.theta = theta;
|
||||
this.phi = phi;
|
||||
}
|
||||
|
||||
public double getPsi() {
|
||||
return this.psi;
|
||||
}
|
||||
|
||||
public double getTheta() {
|
||||
return this.theta;
|
||||
}
|
||||
|
||||
public double getPhi() {
|
||||
return this.phi;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user