diff --git a/java/build.xml b/java/build.xml index 397c9e9..05ce1cb 100644 --- a/java/build.xml +++ b/java/build.xml @@ -1,5 +1,8 @@ + + + diff --git a/java/src/mimis/device/lirc/LircDevice.java b/java/src/mimis/device/lirc/LircDevice.java index cc7a429..5b6662f 100644 --- a/java/src/mimis/device/lirc/LircDevice.java +++ b/java/src/mimis/device/lirc/LircDevice.java @@ -2,14 +2,14 @@ package mimis.device.lirc; import mimis.application.cmd.CMDApplication; import mimis.device.Device; -import mimis.device.lirc.button.ColorButton; -import mimis.device.lirc.button.NumberButton; import mimis.device.lirc.remote.DenonRC176Button; import mimis.device.lirc.remote.PhiliphsRCLE011Button; import mimis.device.lirc.remote.SamsungBN5901015AButton; import mimis.exception.worker.ActivateException; import mimis.exception.worker.DeactivateException; import mimis.input.Button; +import mimis.input.button.ColorButton; +import mimis.input.button.NumberButton; import mimis.input.state.Press; import mimis.input.state.Release; import mimis.util.Multiplexer; diff --git a/java/src/mimis/device/lirc/remote/ColorButton.java b/java/src/mimis/device/lirc/remote/ColorButton.java deleted file mode 100644 index 72eedd9..0000000 --- a/java/src/mimis/device/lirc/remote/ColorButton.java +++ /dev/null @@ -1,7 +0,0 @@ -package mimis.device.lirc.remote; - -import mimis.input.Button; - -public enum ColorButton implements Button { - RED, GREEN, YELLOW, BLUE; -} diff --git a/java/src/mimis/device/wiimote/WiimoteDevice.java b/java/src/mimis/device/wiimote/WiimoteDevice.java index a1aeb5f..77259bf 100644 --- a/java/src/mimis/device/wiimote/WiimoteDevice.java +++ b/java/src/mimis/device/wiimote/WiimoteDevice.java @@ -2,6 +2,7 @@ package mimis.device.wiimote; import mimis.device.Device; import mimis.device.wiimote.gesture.GestureDevice; +import mimis.device.wiimote.motion.MotionDevice; import mimis.exception.button.UnknownButtonException; import mimis.exception.device.DeviceNotFoundException; import mimis.exception.worker.ActivateException; @@ -12,6 +13,7 @@ import mimis.input.state.Press; import mimis.input.state.Release; import mimis.util.ArrayCycle; import mimis.value.Action; +import mimis.value.Signal; import mimis.worker.Component; import mimis.worker.Worker; @@ -37,6 +39,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener protected Wiimote wiimote; protected boolean connected; protected GestureDevice gestureDevice; + protected MotionDevice motionDevice; protected int gestureId; protected LedWorker ledWorker; protected boolean disconnect; @@ -52,12 +55,15 @@ public class WiimoteDevice extends Component implements Device, GestureListener wiimoteDiscovery = new WiimoteDiscovery(this); gestureDevice = new GestureDevice(); gestureDevice.add(this); + motionDevice = new MotionDevice(this); gestureId = 0; ledWorker = new LedWorker(); } /* Worker */ protected void activate() throws ActivateException { + motionDevice.setRouter(router); + motionDevice.start(); parser(Action.ADD, taskMapCycle.player); wiimote = null; try { @@ -93,6 +99,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener super.deactivate(); ledWorker.stop(); wiimoteDiscovery.stop(); + motionDevice.stop(); if (disconnect) { if (wiimote != null) { wiimote.disconnect(); @@ -111,6 +118,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener } wiimoteService.exit(); wiimoteDiscovery.exit(); + motionDevice.exit(); } /* Events */ @@ -128,35 +136,46 @@ public class WiimoteDevice extends Component implements Device, GestureListener parser(Action.RESET, taskMapCycle.like); parser(Action.ADD, taskMapCycle.player); break; + case RECOGNIZE: + log.debug("Gesture recognize press"); + gestureDevice.recognize(Signal.BEGIN); + break; case TRAIN: - log.debug("Gesture train"); - gestureDevice.train(); + log.debug("Gesture train press"); + gestureDevice.train(Signal.BEGIN); + break; + case CLOSE: + log.debug("Gesture close press"); + gestureDevice.close(Signal.BEGIN); break; case SAVE: log.debug("Gesture save"); - gestureDevice.close(); - gestureDevice.saveGesture(gestureId, "C:\\gesture-" + gestureId); + gestureDevice.close(Signal.END); + gestureDevice.saveGesture(gestureId, "tmp/gesture #" + gestureId); ++gestureId; break; case LOAD: log.debug("Gesture load"); for (int i = 0; i < gestureId; ++i) { - gestureDevice.loadGesture("C:\\gesture-" + i); + gestureDevice.loadGesture("tmp/gesture #" + gestureId); } break; - case RECOGNIZE: - log.debug("Gesture recognize"); - gestureDevice.recognize(); - break; } } public void end(Action action) { switch (action) { - case TRAIN: case RECOGNIZE: - log.debug("Gesture stop"); - gestureDevice.stop(); + log.debug("Gesture recognize release"); + gestureDevice.recognize(Signal.END); + break; + case TRAIN: + log.debug("Gesture train release"); + gestureDevice.train(Signal.END); + break; + case CLOSE: + log.debug("Gesture close release"); + gestureDevice.close(Signal.END); break; } } @@ -172,9 +191,9 @@ public class WiimoteDevice extends Component implements Device, GestureListener public synchronized void connect() throws DeviceNotFoundException { wiimote = wiimoteService.getDevice(this); //wiimote.activateContinuous(); + wiimote.activateMotionSensing(); wiimoteDiscovery.stop(); ledWorker.start(); - //sleep(10000); } /* Listeners */ @@ -196,6 +215,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener public void onMotionSensingEvent(MotionSensingEvent event) { gestureDevice.add(event.getGforce()); + motionDevice.add(event); } public void onIrEvent(IREvent event) { @@ -203,6 +223,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener } public void gestureReceived(GestureEvent event) { + log.debug(event.isValid()); if (event.isValid()) { System.out.printf("id #%d, prob %.0f%%, valid %b\n", event.getId(), 100 * event.getProbability(), event.isValid()); } diff --git a/java/src/mimis/device/wiimote/WiimoteService.java b/java/src/mimis/device/wiimote/WiimoteService.java index affa201..6ff2480 100644 --- a/java/src/mimis/device/wiimote/WiimoteService.java +++ b/java/src/mimis/device/wiimote/WiimoteService.java @@ -89,7 +89,6 @@ public class WiimoteService extends WiiUseApiManager implements WiimoteListener } public void onStatusEvent(StatusEvent event) { - //log.debug(event); if (event.isConnected()) { WiimoteDevice wiimoteDevice = getWiimoteDevice(event); wiimoteDevice.connected = true; diff --git a/java/src/mimis/device/wiimote/WiimoteTaskMapCycle.java b/java/src/mimis/device/wiimote/WiimoteTaskMapCycle.java index 6bdff3f..a4b7a45 100644 --- a/java/src/mimis/device/wiimote/WiimoteTaskMapCycle.java +++ b/java/src/mimis/device/wiimote/WiimoteTaskMapCycle.java @@ -20,10 +20,10 @@ public class WiimoteTaskMapCycle extends TaskMapCycle { /* Gesture */ gesture = new TaskMap(); - gesture.add(WiimoteButton.A, new Task(Action.TRAIN)); - gesture.add(WiimoteButton.B, new Task(Action.SAVE)); - gesture.add(WiimoteButton.DOWN, new Task(Action.LOAD)); - gesture.add(WiimoteButton.HOME, new Task(Action.RECOGNIZE)); + gesture.add(WiimoteButton.A, new Task(Action.TRAIN, Target.SELF)); + gesture.add(WiimoteButton.B, new Task(Action.SAVE, Target.SELF)); + gesture.add(WiimoteButton.DOWN, new Task(Action.LOAD, Target.SELF)); + gesture.add(WiimoteButton.HOME, new Task(Action.RECOGNIZE, Target.SELF)); add(gesture); /* Player */ diff --git a/java/src/mimis/device/wiimote/gesture/GestureDevice.java b/java/src/mimis/device/wiimote/gesture/GestureDevice.java index 96ad5a0..9ee18b4 100644 --- a/java/src/mimis/device/wiimote/gesture/GestureDevice.java +++ b/java/src/mimis/device/wiimote/gesture/GestureDevice.java @@ -1,29 +1,35 @@ package mimis.device.wiimote.gesture; -import mimis.device.wiimote.gesture.event.Close; -import mimis.device.wiimote.gesture.event.Recognize; -import mimis.device.wiimote.gesture.event.Train; +import mimis.value.Signal; import org.wiigee.device.Device; +import org.wiigee.event.AccelerationEvent; +import org.wiigee.event.AccelerationListener; import org.wiigee.event.ButtonListener; import org.wiigee.event.ButtonPressedEvent; +import org.wiigee.event.ButtonReleasedEvent; import org.wiigee.event.GestureListener; +import org.wiigee.event.MotionStartEvent; +import org.wiigee.event.MotionStopEvent; import wiiusej.values.GForce; -public class GestureDevice extends Device /*implements AccelerationListener */{ +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 static final boolean AUTOMOTION = false; public GestureDevice() { - this(AUTOFILTERING/*, AUTOMOTION*/); + this(AUTOFILTERING, AUTOMOTION); + } + + public GestureDevice(boolean autofiltering, boolean automotion) { + super(autofiltering); + if (automotion) { + addAccelerationListener(this); + } + this.setRecognitionButton(ButtonPressedEvent.BUTTON_A); + this.setTrainButton(ButtonPressedEvent.BUTTON_B); + this.setCloseGestureButton(ButtonPressedEvent.BUTTON_HOME); } public void add(GestureListener gestureListener) { @@ -42,40 +48,65 @@ public class GestureDevice extends Device /*implements AccelerationListener */{ fireAccelerationEvent(vector); } - public void recognize() { - fireButtonPressedEvent(new Recognize(this)); + public void recognize(Signal signal) { + switch (signal) { + case BEGIN: + fireButtonPressedEvent(ButtonPressedEvent.BUTTON_A); + break; + case END: + fireButtonReleasedEvent(ButtonPressedEvent.BUTTON_A); + break; + } } - public void train() { - fireButtonPressedEvent(new Train(this)); + public void train(Signal signal) { + switch (signal) { + case BEGIN: + fireButtonPressedEvent(ButtonPressedEvent.BUTTON_B); + break; + case END: + fireButtonReleasedEvent(ButtonPressedEvent.BUTTON_B); + break; + } } - public void close() { - fireButtonPressedEvent(new Close(this)); + public void close(Signal signal) { + switch (signal) { + case BEGIN: + fireButtonPressedEvent(ButtonPressedEvent.BUTTON_HOME); + break; + case END: + fireButtonReleasedEvent(ButtonPressedEvent.BUTTON_HOME); + break; + } } - public void stop() { - fireButtonReleasedEvent(0); - } - - public void fireButtonPressedEvent(ButtonPressedEvent buttonPressedEvent) { - for (ButtonListener bttnLstnr : buttonlistener) { - bttnLstnr.buttonPressReceived(buttonPressedEvent); + public void fireButtonPressedEvent(int button) { + ButtonPressedEvent buttonPressedEvent = new ButtonPressedEvent(this, button); + for (ButtonListener buttonListener : buttonlistener) { + buttonListener.buttonPressReceived(buttonPressedEvent); } if (buttonPressedEvent.isRecognitionInitEvent() || buttonPressedEvent.isTrainInitEvent()) { - this.resetAccelerationFilters(); + resetAccelerationFilters(); } } - /*public void accelerationReceived(AccelerationEvent event) {} + public void fireButtonReleasedEvent(int button) { + ButtonReleasedEvent buttonReleasedEvent = new ButtonReleasedEvent(this, button); + for (ButtonListener buttonListener : buttonlistener) { + buttonListener.buttonReleaseReceived(buttonReleasedEvent); + } + } + + public void accelerationReceived(AccelerationEvent event) {} public void motionStartReceived(MotionStartEvent event) { - //System.out.println("Motion start!"); - recognize(); + System.out.println("Motion start !" + System.currentTimeMillis()); + recognize(Signal.BEGIN); } public void motionStopReceived(MotionStopEvent event) { - //System.out.println("Motion stop!"); - stop(); - }*/ + System.out.println("Motion stop! " + + System.currentTimeMillis()); + recognize(Signal.END); + } } diff --git a/java/src/mimis/device/wiimote/gesture/event/Close.java b/java/src/mimis/device/wiimote/gesture/event/Close.java deleted file mode 100644 index 2708aa7..0000000 --- a/java/src/mimis/device/wiimote/gesture/event/Close.java +++ /dev/null @@ -1,24 +0,0 @@ -package mimis.device.wiimote.gesture.event; - -import org.wiigee.device.Device; -import org.wiigee.event.ButtonPressedEvent; - -public class Close extends ButtonPressedEvent { - protected static final long serialVersionUID = 1L; - - public Close(Device device) { - super(device, 0); - } - - public boolean isRecognitionInitEvent() { - return false; - } - - public boolean isTrainInitEvent() { - return false; - } - - public boolean isCloseGestureInitEvent() { - return true; - } -} diff --git a/java/src/mimis/device/wiimote/gesture/event/Recognize.java b/java/src/mimis/device/wiimote/gesture/event/Recognize.java deleted file mode 100644 index 72f0e41..0000000 --- a/java/src/mimis/device/wiimote/gesture/event/Recognize.java +++ /dev/null @@ -1,24 +0,0 @@ -package mimis.device.wiimote.gesture.event; - -import org.wiigee.device.Device; -import org.wiigee.event.ButtonPressedEvent; - -public class Recognize extends ButtonPressedEvent { - protected static final long serialVersionUID = 1L; - - public Recognize(Device device) { - super(device, 0); - } - - public boolean isRecognitionInitEvent() { - return true; - } - - public boolean isTrainInitEvent() { - return false; - } - - public boolean isCloseGestureInitEvent() { - return false; - } -} diff --git a/java/src/mimis/device/wiimote/gesture/event/Train.java b/java/src/mimis/device/wiimote/gesture/event/Train.java deleted file mode 100644 index f9030ab..0000000 --- a/java/src/mimis/device/wiimote/gesture/event/Train.java +++ /dev/null @@ -1,24 +0,0 @@ -package mimis.device.wiimote.gesture.event; - -import org.wiigee.device.Device; -import org.wiigee.event.ButtonPressedEvent; - -public class Train extends ButtonPressedEvent { - protected static final long serialVersionUID = 1L; - - public Train(Device device) { - super(device, 0); - } - - public boolean isRecognitionInitEvent() { - return false; - } - - public boolean isTrainInitEvent() { - return true; - } - - public boolean isCloseGestureInitEvent() { - return false; - } -} diff --git a/java/src/mimis/device/wiimote/motion/MotionData.java b/java/src/mimis/device/wiimote/motion/MotionData.java new file mode 100644 index 0000000..3a0ddfc --- /dev/null +++ b/java/src/mimis/device/wiimote/motion/MotionData.java @@ -0,0 +1,29 @@ +package mimis.device.wiimote.motion; + +import java.io.Serializable; + +import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; + +public class MotionData implements Serializable { + protected static final long serialVersionUID = 1L; + + protected int time; + protected MotionSensingEvent event; + + public MotionData(long time, MotionSensingEvent event) { + this((int) time, event); + } + + public MotionData(int time, MotionSensingEvent event) { + this.time = time; + this.event = event; + } + + public int getTime() { + return time; + } + + public MotionSensingEvent getEvent() { + return event; + } +} diff --git a/java/src/mimis/device/wiimote/motion/MotionDevice.java b/java/src/mimis/device/wiimote/motion/MotionDevice.java new file mode 100644 index 0000000..397b013 --- /dev/null +++ b/java/src/mimis/device/wiimote/motion/MotionDevice.java @@ -0,0 +1,190 @@ +package mimis.device.wiimote.motion; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.ArrayList; + +import mimis.device.lirc.LircButton; +import mimis.device.lirc.remote.PhiliphsRCLE011Button; +import mimis.device.wiimote.WiimoteDevice; +import mimis.exception.worker.ActivateException; +import mimis.exception.worker.DeactivateException; +import mimis.input.Button; +import mimis.input.button.ColorButton; +import mimis.input.button.NumberButton; +import mimis.input.state.State; +import mimis.value.Action; +import mimis.worker.Component; +import mimis.worker.Worker; +import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent; + +public class MotionDevice extends Component { + protected WiimoteDevice wiimoteDevice; + protected int id; + protected long start; + protected boolean replay; + protected Action action; + + public ReplayWorker replayWorker; + public ArrayList motionList; + + public MotionDevice(WiimoteDevice wiimoteDevice) { + this.wiimoteDevice = wiimoteDevice; + id = 0; + start = -1; + replay = false; + action = Action.TRAIN; + replayWorker = new ReplayWorker(); + motionList = new ArrayList(); + } + + public void activate() throws ActivateException { + super.activate(); + listen(State.class); + } + + public void deactivate() throws DeactivateException { + replayWorker.stop(); + super.deactivate(); + } + + public void exit() { + super.exit(); + replayWorker.exit(); + } + + public void release(Button button) { + if (button instanceof LircButton) { + PhiliphsRCLE011Button lircButton = (PhiliphsRCLE011Button) button; + log.debug(lircButton); + switch (lircButton) { + case CLOCK: + action = Action.TRAIN; + break; + case OUT: + action = Action.RECOGNIZE; + break; + case MUTE: + wiimoteDevice.begin(Action.CLOSE); + break; + case SCREEN_UP: + wiimoteDevice.begin(Action.SAVE); + break; + case SCREEN_DOWN: + wiimoteDevice.begin(Action.LOAD); + break; + } + } else if (button instanceof NumberButton) { + NumberButton numberButton = (NumberButton) button; + id = numberButton.ordinal(); + if (replay == false) { + release(ColorButton.YELLOW); + } else { + log.debug("Set file to #" + id); + } + } else if (button instanceof ColorButton) { + ColorButton colorButton = (ColorButton) button; + log.debug(colorButton.name()); + synchronized (motionList) { + switch (colorButton) { + case GREEN: + log.debug("Start capturing motion"); + motionList.clear(); + start = System.currentTimeMillis(); + break; + case RED: + if (replayWorker.active()) { + log.debug("Stop replaying motion"); + replayWorker.stop(); + } else { + log.debug("Writing motion to file #" + id); + try { + FileOutputStream fileOutputStream = new FileOutputStream(String.format("tmp/motion #%d.bin", id)); + ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream); + objectOutputStream.writeObject(motionList.size()); + for (MotionData motionData : motionList) { + objectOutputStream.writeObject(motionData); + } + objectOutputStream.close(); + } catch (IOException e) { + log.error(e); + } + motionList.clear(); + start = -1; + } + break; + case YELLOW: + log.debug("Replaying motion from file #" + id); + replay = true; + replayWorker.start(); + break; + } + } + } + } + + public void add(MotionSensingEvent event) { + if (start > 0) { + synchronized (motionList) { + motionList.add(new MotionData(System.currentTimeMillis() - start, event)); + } + } + } + + class ReplayWorker extends Worker { + protected ObjectInputStream objectInputStream; + protected int count, i, time; + + protected void activate() throws ActivateException { + try { + FileInputStream fileInputStream = new FileInputStream(String.format("tmp/motion #%d.bin", id)); + objectInputStream = new ObjectInputStream(fileInputStream); + count = (Integer) objectInputStream.readObject(); + i = time = 0; + wiimoteDevice.begin(action); + super.activate(); + return; + } catch (FileNotFoundException e) { + log.error(e); + } catch (IOException e) { + log.error(e); + } catch (ClassNotFoundException e) { + log.error(e); + } + } + + protected void deactivate() throws DeactivateException { + log.debug(String.format("Replay stopped (%d ms)", time)); + wiimoteDevice.end(action); + replay = false; + try { + objectInputStream.close(); + } catch (IOException e) { + log.debug(e); + } + super.deactivate(); + } + protected void work() { + if (i++ < count) { + try { + Object object = objectInputStream.readObject(); + MotionData motionData = (MotionData) object; + wiimoteDevice.onMotionSensingEvent(motionData.getEvent()); + sleep(motionData.getTime() - time); + time = motionData.getTime(); + return; + } catch (IOException e) { + log.error(e); + } catch (ClassNotFoundException e) { + log.error(e); + } + } + stop(); + } + } + +} diff --git a/java/src/mimis/device/lirc/button/ColorButton.java b/java/src/mimis/input/button/ColorButton.java similarity index 72% rename from java/src/mimis/device/lirc/button/ColorButton.java rename to java/src/mimis/input/button/ColorButton.java index 5857ebc..3543777 100644 --- a/java/src/mimis/device/lirc/button/ColorButton.java +++ b/java/src/mimis/input/button/ColorButton.java @@ -1,4 +1,4 @@ -package mimis.device.lirc.button; +package mimis.input.button; import mimis.input.Button; diff --git a/java/src/mimis/device/lirc/button/NumberButton.java b/java/src/mimis/input/button/NumberButton.java similarity index 77% rename from java/src/mimis/device/lirc/button/NumberButton.java rename to java/src/mimis/input/button/NumberButton.java index dabd14b..f31b16b 100644 --- a/java/src/mimis/device/lirc/button/NumberButton.java +++ b/java/src/mimis/input/button/NumberButton.java @@ -1,4 +1,4 @@ -package mimis.device.lirc.button; +package mimis.input.button; import mimis.input.Button; diff --git a/java/src/mimis/value/Action.java b/java/src/mimis/value/Action.java index 293d67c..7928c34 100644 --- a/java/src/mimis/value/Action.java +++ b/java/src/mimis/value/Action.java @@ -1,5 +1,5 @@ package mimis.value; public enum Action { - EXIT, FORWARD, MUTE, NEXT, PAUSE, PLAY, PREVIOUS, REPEAT, RESUME, REWIND, START, TEST, VOLUME_DOWN, VOLUME_UP, FULLSCREEN, TRAIN, STOP, SAVE, RECOGNIZE, LOAD, SHUFFLE, FADEOUT, QUIT, VISUALISER, LIKE, DISLIKE, ACTIVATE, SHIFT, UNSHIFT, ADD, REMOVE, RESET, CURRENT; + EXIT, FORWARD, MUTE, NEXT, PAUSE, PLAY, PREVIOUS, REPEAT, RESUME, REWIND, START, TEST, VOLUME_DOWN, VOLUME_UP, FULLSCREEN, TRAIN, STOP, SAVE, RECOGNIZE, LOAD, SHUFFLE, FADEOUT, QUIT, VISUALISER, LIKE, DISLIKE, ACTIVATE, SHIFT, UNSHIFT, ADD, REMOVE, RESET, CURRENT, CLOSE; } diff --git a/java/src/mimis/worker/Component.java b/java/src/mimis/worker/Component.java index d166a3e..288d0e8 100644 --- a/java/src/mimis/worker/Component.java +++ b/java/src/mimis/worker/Component.java @@ -1,8 +1,11 @@ package mimis.worker; +import mimis.input.Button; import mimis.input.Feedback; import mimis.input.Input; import mimis.input.Task; +import mimis.input.state.Press; +import mimis.input.state.Release; import mimis.input.state.State; import mimis.parser.ParserInput; import mimis.router.Router; @@ -62,14 +65,24 @@ public abstract class Component extends Listener { } public void input(Input input) { - if (input instanceof Task) { - log.debug("task " + ((Task) input).getAction()); + if (input instanceof State) { + state((State) input); + } else if (input instanceof Task) { task((Task) input); } else if (input instanceof Feedback) { feedback((Feedback) input); } } + protected void state(State state) { + Button button = state.getButton(); + if (state instanceof Press) { + press(button); + } else if (state instanceof Release) { + release(button); + } + } + protected void task(Task task) { Action action = task.getAction(); switch (task.getSignal()) { @@ -98,6 +111,8 @@ public abstract class Component extends Listener { } } + protected void press(Button button) {} + protected void release(Button button) {} protected void feedback(Feedback feedback) {} protected void action(Action action) {} protected void begin(Action action) {} diff --git a/java/src/org/wiigee/device/Device.java b/java/src/org/wiigee/device/Device.java index 0f6e016..1559d8b 100644 --- a/java/src/org/wiigee/device/Device.java +++ b/java/src/org/wiigee/device/Device.java @@ -173,7 +173,7 @@ public class Device { this.processingunit.saveGesture(id, filename); } - // ###### Event-Methoden + // ###### Event-Methods /** Fires an acceleration event. * @param vector Consists of three values: * acceleration on X, Y and Z axis. diff --git a/java/src/org/wiigee/event/ButtonReleasedEvent.java b/java/src/org/wiigee/event/ButtonReleasedEvent.java index 9c3b776..cbe1eb0 100644 --- a/java/src/org/wiigee/event/ButtonReleasedEvent.java +++ b/java/src/org/wiigee/event/ButtonReleasedEvent.java @@ -34,16 +34,15 @@ import org.wiigee.device.Device; * @author Benjamin 'BePo' Poppinga */ public class ButtonReleasedEvent extends ActionStopEvent { + int button; - int button; + public ButtonReleasedEvent(Device source, int button) { + super(source); + this.button = button; + } - public ButtonReleasedEvent(Device source, int button) { - super(source); - this.button = button; - } + public int getButton() { + return this.button; + } - public int getButton() { - return this.button; - } - } diff --git a/java/src/org/wiigee/logic/TriggeredProcessingUnit.java b/java/src/org/wiigee/logic/TriggeredProcessingUnit.java index d5f7bd1..8c59d12 100644 --- a/java/src/org/wiigee/logic/TriggeredProcessingUnit.java +++ b/java/src/org/wiigee/logic/TriggeredProcessingUnit.java @@ -112,7 +112,7 @@ public class TriggeredProcessingUnit extends ProcessingUnit { Log.write("Recognition started!"); this.analyzing=true; } - + System.err.println(analyzing + " " + learning + " " + event.isCloseGestureInitEvent()); // CloseGestureButton = starts the training of the model with multiple // recognized gestures, contained in trainsequence if((!this.analyzing && !this.learning) && diff --git a/java/src/wiiusej/values/GForce.java b/java/src/wiiusej/values/GForce.java index da79ed2..6dac881 100644 --- a/java/src/wiiusej/values/GForce.java +++ b/java/src/wiiusej/values/GForce.java @@ -16,12 +16,15 @@ */ package wiiusej.values; +import java.io.Serializable; + /** * Represents gravity force on each axis. * * @author guiguito */ -public class GForce { +public class GForce implements Serializable { + protected static final long serialVersionUID = 1L; private float x; private float y; diff --git a/java/src/wiiusej/values/Orientation.java b/java/src/wiiusej/values/Orientation.java index 124d890..1421bab 100644 --- a/java/src/wiiusej/values/Orientation.java +++ b/java/src/wiiusej/values/Orientation.java @@ -16,12 +16,15 @@ */ package wiiusej.values; +import java.io.Serializable; + /** * Class that represents the orientation of the wiimote. * * @author guiguito */ -public class Orientation { +public class Orientation implements Serializable { + protected static final long serialVersionUID = 1L; private float roll; private float pitch; diff --git a/java/src/wiiusej/values/RawAcceleration.java b/java/src/wiiusej/values/RawAcceleration.java index f38fac6..9f0f9a9 100644 --- a/java/src/wiiusej/values/RawAcceleration.java +++ b/java/src/wiiusej/values/RawAcceleration.java @@ -16,12 +16,15 @@ */ package wiiusej.values; +import java.io.Serializable; + /** * Represents raw acceleration on each axis. * * @author guiguito */ -public class RawAcceleration { +public class RawAcceleration implements Serializable { + protected static final long serialVersionUID = 1L; private short x; private short y; diff --git a/java/src/wiiusej/wiiusejevents/GenericEvent.java b/java/src/wiiusej/wiiusejevents/GenericEvent.java index 18d8429..7677755 100644 --- a/java/src/wiiusej/wiiusejevents/GenericEvent.java +++ b/java/src/wiiusej/wiiusejevents/GenericEvent.java @@ -16,12 +16,15 @@ */ package wiiusej.wiiusejevents; +import java.io.Serializable; + /** * Abstract mother class representing an event with a wiimote id. * * @author guiguito */ -public abstract class GenericEvent { +public abstract class GenericEvent implements Serializable { + protected static final long serialVersionUID = 1L; /* ID */ private int wiimoteId = -1; diff --git a/java/src/wiiusej/wiiusejevents/physicalevents/MotionSensingEvent.java b/java/src/wiiusej/wiiusejevents/physicalevents/MotionSensingEvent.java index 0945a48..11f4756 100644 --- a/java/src/wiiusej/wiiusejevents/physicalevents/MotionSensingEvent.java +++ b/java/src/wiiusej/wiiusejevents/physicalevents/MotionSensingEvent.java @@ -27,8 +27,9 @@ import wiiusej.wiiusejevents.GenericEvent; * @author guiguito */ public class MotionSensingEvent extends GenericEvent { + protected static final long serialVersionUID = 1L; - /* Motion Sensing */ + /* Motion Sensing */ private Orientation orientation; private GForce gforce; private RawAcceleration acceleration;