Simpele feedback van iTunes naar Wiimote toegevoegd, daartoe kleine fouten in initialisatie van Device gerepareerd. Exceptions moeten worden nagekeken!
This commit is contained in:
@@ -4,6 +4,7 @@ import pm.event.Task;
|
||||
import pm.event.EventHandler;
|
||||
import pm.event.task.Continuous;
|
||||
import pm.event.task.Stopper;
|
||||
import pm.exception.InitialiseException;
|
||||
import pm.exception.device.DeviceExitException;
|
||||
import pm.exception.device.DeviceInitialiseException;
|
||||
import pm.macro.Sequence;
|
||||
@@ -21,6 +22,7 @@ public abstract class Device extends EventHandler {
|
||||
}
|
||||
|
||||
public Device() {
|
||||
super();
|
||||
sequenceListener = new SequenceListener(this);
|
||||
}
|
||||
|
||||
@@ -77,7 +79,9 @@ public abstract class Device extends EventHandler {
|
||||
}
|
||||
|
||||
/* Device default methods */
|
||||
public void initialise() throws DeviceInitialiseException {}
|
||||
public void initialise() throws InitialiseException {
|
||||
super.initialise();
|
||||
}
|
||||
|
||||
public void exit() throws DeviceExitException {
|
||||
stop();
|
||||
|
||||
@@ -19,6 +19,8 @@ public class Event {
|
||||
}
|
||||
|
||||
public boolean compatible(EventListener eventListener) {
|
||||
System.out.println("Event compatible()");
|
||||
System.out.println(eventListener);
|
||||
switch (target) {
|
||||
case ALL:
|
||||
return true;
|
||||
|
||||
@@ -11,6 +11,7 @@ import pm.device.panel.PanelDevice;
|
||||
import pm.device.wiimote.WiimoteDevice;
|
||||
import pm.event.EventHandler;
|
||||
import pm.event.EventSpreader;
|
||||
import pm.exception.InitialiseException;
|
||||
import pm.exception.device.DeviceExitException;
|
||||
import pm.exception.device.DeviceInitialiseException;
|
||||
|
||||
@@ -28,8 +29,8 @@ public abstract class Manager extends EventHandler {
|
||||
public void initialise() throws DeviceInitialiseException {
|
||||
//add(new JIntellitypeDevice());
|
||||
//add(new PlayerDevice());
|
||||
add(new RumblepadDevice());
|
||||
//add(new WiimoteDevice());
|
||||
//add(new RumblepadDevice());
|
||||
add(new WiimoteDevice());
|
||||
//add(new GUIDevice());
|
||||
//add(new TextDevice());
|
||||
add(new PanelDevice());
|
||||
@@ -51,7 +52,7 @@ public abstract class Manager extends EventHandler {
|
||||
device.initialise();
|
||||
device.start();
|
||||
System.out.println("Device started: " + device);
|
||||
} catch (DeviceInitialiseException e) {
|
||||
} catch (InitialiseException e) {
|
||||
removeList.add(device);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package pm.application.itunes;
|
||||
|
||||
import pm.Application;
|
||||
import pm.event.Feedback;
|
||||
import pm.exception.application.ApplicationExitException;
|
||||
import pm.value.Action;
|
||||
|
||||
@@ -87,8 +88,14 @@ public class iTunesApplication extends Application implements iTunesEventsInterf
|
||||
|
||||
/* iTunesEventInterface => naar eigen class? */
|
||||
public void onDatabaseChangedEvent(int[][] deletedObjectIDs, int[][] changedObjectIDs) {}
|
||||
public void onPlayerPlayEvent(ITTrack iTrack) {}
|
||||
public void onPlayerStopEvent(ITTrack iTrack) {}
|
||||
public void onPlayerPlayEvent(ITTrack iTrack) {
|
||||
System.out.println("iTunes play");
|
||||
eventSpreader.add(new Feedback());
|
||||
}
|
||||
public void onPlayerStopEvent(ITTrack iTrack) {
|
||||
System.out.println("iTunes stop");
|
||||
eventSpreader.add(new Feedback());
|
||||
}
|
||||
public void onPlayerPlayingTrackChangedEvent(ITTrack iTrack) {}
|
||||
public void onCOMCallsDisabledEvent(ITCOMDisabledReason reason) {}
|
||||
public void onCOMCallsEnabledEvent() {}
|
||||
|
||||
@@ -8,12 +8,13 @@ import pm.Button;
|
||||
import pm.Device;
|
||||
import pm.Macro;
|
||||
import pm.device.wiimote.gesture.GestureDevice;
|
||||
import pm.event.Feedback;
|
||||
import pm.event.Task;
|
||||
import pm.event.task.Continuous;
|
||||
import pm.event.task.Dynamic;
|
||||
import pm.exception.InitialiseException;
|
||||
import pm.exception.button.UnknownButtonException;
|
||||
import pm.exception.device.DeviceExitException;
|
||||
import pm.exception.device.DeviceInitialiseException;
|
||||
import pm.exception.macro.StateOrderException;
|
||||
import pm.macro.state.Hold;
|
||||
import pm.macro.state.Press;
|
||||
@@ -30,6 +31,7 @@ import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||
|
||||
public class WiimoteDevice extends Device implements GestureListener {
|
||||
protected static final int CONNECT_MAX = 10;
|
||||
protected static final int RUMBLE = 150;
|
||||
|
||||
protected static WiimoteService wiimoteService;
|
||||
|
||||
@@ -48,7 +50,8 @@ public class WiimoteDevice extends Device implements GestureListener {
|
||||
gestureDevice.add(this);
|
||||
}
|
||||
|
||||
public void initialise() throws DeviceInitialiseException {
|
||||
public void initialise() throws InitialiseException {
|
||||
super.initialise();
|
||||
wiimote = wiimoteService.getDevice(this);
|
||||
wiimote.activateMotionSensing();
|
||||
/*add(
|
||||
@@ -178,4 +181,9 @@ public class WiimoteDevice extends Device implements GestureListener {
|
||||
System.out.printf("id #%d, prob %.0f%%, valid %b\n", event.getId(), 100 * event.getProbability(), event.isValid());
|
||||
}
|
||||
}
|
||||
|
||||
public void feedback(Feedback feedback) {
|
||||
System.out.println("Wiimote feedback");
|
||||
wiimote.rumble(RUMBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public abstract class EventHandler extends EventListener {
|
||||
}
|
||||
|
||||
public void event(Event event) {
|
||||
System.out.println(event);
|
||||
if (event instanceof Feedback) {
|
||||
feedback((Feedback) event);
|
||||
} else if (event instanceof Task) {
|
||||
|
||||
@@ -15,6 +15,10 @@ public abstract class EventListener extends Worker {
|
||||
}
|
||||
|
||||
public void add(Event event) {
|
||||
System.out.println("Eventlistener krijgt event via add()");
|
||||
System.out.println(this);
|
||||
System.out.println(event);
|
||||
System.out.println(">>>");
|
||||
eventQueue.add(event);
|
||||
synchronized (available) {
|
||||
available.notifyAll();
|
||||
|
||||
@@ -7,7 +7,7 @@ import pm.value.Target;
|
||||
|
||||
public class LocalSpreader extends EventSpreader {
|
||||
public void event(Event event) {
|
||||
System.out.println("localspread");
|
||||
System.out.println("LocalSpreader krijgt event via evet()");
|
||||
System.out.println(application);
|
||||
Target target = event.getTarget();
|
||||
switch (target) {
|
||||
|
||||
@@ -496,4 +496,14 @@ public class Wiimote implements WiiUseApiListener {
|
||||
public Calibration getCalibration() {
|
||||
return manager.getCalibration(id);
|
||||
}
|
||||
|
||||
public void rumble(int milliseconds) {
|
||||
activateRumble();
|
||||
try {
|
||||
Thread.sleep(milliseconds);
|
||||
} catch (InterruptedException e) {
|
||||
} finally {
|
||||
deactivateRumble();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user