Mogelijkheid tot het sturen van Actions naar Devices toegevoegd. Gestures ingevoerd in de WiimoteDevice. Herkennen is nog niet constant succesvol!

This commit is contained in:
2011-02-14 19:25:19 +00:00
parent b0e2b09487
commit 6ee9e9fff1
12 changed files with 274 additions and 39 deletions

View File

@@ -0,0 +1,70 @@
package pm.device.wiimote.gesture;
import org.wiigee.device.Device;
import org.wiigee.event.ButtonListener;
import org.wiigee.event.ButtonPressedEvent;
import org.wiigee.event.GestureListener;
import pm.device.wiimote.gesture.event.Close;
import pm.device.wiimote.gesture.event.Recognize;
import pm.device.wiimote.gesture.event.Train;
public class GestureDevice extends Device /*implements AccelerationListener */{
public static final boolean AUTOFILTERING = true;
//public static final boolean AUTOMOTION = true;
public GestureDevice(boolean autofiltering/*, boolean automotion*/) {
super(autofiltering);
/*if (automotion) {
addAccelerationListener(this);
}*/
}
public GestureDevice() {
this(AUTOFILTERING/*, AUTOMOTION*/);
}
public void add(GestureListener gestureListener) {
addGestureListener(gestureListener);
}
public void add(double[] vector) {
fireAccelerationEvent(vector);
}
public void recognize() {
fireButtonPressedEvent(new Recognize(this));
}
public void train() {
fireButtonPressedEvent(new Train(this));
}
public void close() {
fireButtonPressedEvent(new Close(this));
}
public void stop() {
fireButtonReleasedEvent(0);
}
public void fireButtonPressedEvent(ButtonPressedEvent buttonPressedEvent) {
for (ButtonListener bttnLstnr : buttonlistener) {
bttnLstnr.buttonPressReceived(buttonPressedEvent);
}
if (buttonPressedEvent.isRecognitionInitEvent() || buttonPressedEvent.isTrainInitEvent()) {
this.resetAccelerationFilters();
}
}
/*public void accelerationReceived(AccelerationEvent event) {}
public void motionStartReceived(MotionStartEvent event) {
//System.out.println("Motion start!");
recognize();
}
public void motionStopReceived(MotionStopEvent event) {
//System.out.println("Motion stop!");
stop();
}*/
}