Aantal reorganisaties om implementatie van macro's ondubbelzinnig duidelijk te maken.
This commit is contained in:
@@ -2,11 +2,11 @@ package pm.device;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
import pm.action.Action;
|
||||
import pm.event.Target;
|
||||
import pm.action.Actions;
|
||||
import pm.action.Targets;
|
||||
|
||||
public abstract class Device {
|
||||
protected static Queue<Action> actionQueue;
|
||||
protected static Queue<Actions> actionQueue;
|
||||
protected MacroListener macroListener;
|
||||
|
||||
public Device() {
|
||||
@@ -14,12 +14,12 @@ public abstract class Device {
|
||||
macroListener.start();
|
||||
}
|
||||
|
||||
public void addAction(Action action, Target target) {
|
||||
public void addAction(Actions action, Targets target) {
|
||||
action.setTarget(target);
|
||||
actionQueue.add(action);
|
||||
}
|
||||
|
||||
public static void initialise(Queue<Action> actionQueue) {
|
||||
public static void initialise(Queue<Actions> actionQueue) {
|
||||
Device.actionQueue = actionQueue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package pm.device;
|
||||
|
||||
import pm.device.macro.Macro;
|
||||
import pm.Macro;
|
||||
|
||||
import pm.action.Actions;
|
||||
import pm.action.Targets;
|
||||
|
||||
|
||||
public class MacroListener extends Thread {
|
||||
/*public void add(Macro macro, Action action, Target target) {
|
||||
public void add(Macro macro, Actions action, Targets target) {
|
||||
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package pm.device.example;
|
||||
|
||||
import pm.action.Action;
|
||||
import pm.action.Actions;
|
||||
import pm.action.Targets;
|
||||
import pm.device.Device;
|
||||
import pm.event.Target;
|
||||
|
||||
public class ExampleDevice extends Device {
|
||||
public void start() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package pm.device.javainput.extreme3d;
|
||||
|
||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||
import pm.device.macro.Button;
|
||||
import pm.Button;
|
||||
import pm.exception.event.UnknownButtonException;
|
||||
|
||||
public enum Extreme3DButton implements Button {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package pm.device.javainput.extreme3d;
|
||||
|
||||
import de.hardcode.jxinput.Button;
|
||||
import de.hardcode.jxinput.Directional;
|
||||
import de.hardcode.jxinput.event.JXInputAxisEvent;
|
||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||
|
||||
import pm.Macro;
|
||||
import pm.device.javainput.JavaInputDevice;
|
||||
import pm.exception.DeviceException;
|
||||
import pm.exception.EventException;
|
||||
@@ -21,13 +20,13 @@ public class Extreme3DDevice extends JavaInputDevice {
|
||||
|
||||
public void start() {
|
||||
super.start();
|
||||
/*macroListener.addMacro(
|
||||
macroListener.addMacro(
|
||||
new Macro(
|
||||
new Hold(Button.A),
|
||||
new Press(Button.B),
|
||||
new Press(Button.TWO),
|
||||
new Release(Button.A)),
|
||||
Action.EXIT, Target.APPLICATION));*/
|
||||
Action.EXIT, Target.APPLICATION));
|
||||
}
|
||||
|
||||
public void processEvent(JXInputAxisEvent event) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package pm.device.javainput.extreme3d;
|
||||
|
||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||
import pm.device.macro.Button;
|
||||
import pm.Button;
|
||||
import pm.exception.event.UnknownDirectionException;
|
||||
|
||||
public enum Extreme3DDirection implements Button {
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package pm.device.macro;
|
||||
|
||||
public interface Action {
|
||||
public Button button = null;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package pm.device.macro;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import wiitunes.interaction.macro.Action;
|
||||
import wiitunes.interaction.macro.Button;
|
||||
import wiitunes.interaction.macro.Buttons;
|
||||
import wiitunes.interaction.macro.Combination;
|
||||
import wiitunes.interaction.macro.action.Hold;
|
||||
import wiitunes.interaction.macro.action.Press;
|
||||
import wiitunes.interaction.macro.action.Release;
|
||||
|
||||
public class Actions {
|
||||
protected Combination[] combinationArray;
|
||||
|
||||
public Actions(Action... actionArray) {
|
||||
ArrayList<Combination> combinationList = new ArrayList<Combination>();
|
||||
Buttons heldButtons = new Buttons();
|
||||
for (Action action : actionArray) {
|
||||
if (action instanceof Press) {
|
||||
Button button = ((Press) action).button;
|
||||
Buttons buttons = new Buttons(button);
|
||||
combinationList.add(new Combination(buttons, null, heldButtons));
|
||||
combinationList.add(new Combination(null, buttons, heldButtons));
|
||||
} else if (action instanceof Release) {
|
||||
Button button = ((Release) action).button;
|
||||
Buttons buttons = new Buttons(button);
|
||||
heldButtons = heldButtons.clone();
|
||||
heldButtons.remove(button);
|
||||
combinationList.add(new Combination(null, buttons, heldButtons));
|
||||
} else if (action instanceof Hold) {
|
||||
Button button = ((Hold) action).button;
|
||||
Buttons buttons = new Buttons(button);
|
||||
combinationList.add(new Combination(buttons, null, heldButtons));
|
||||
heldButtons = heldButtons.clone();
|
||||
heldButtons.add(button);
|
||||
}
|
||||
}
|
||||
combinationArray = (Combination[]) combinationList.toArray(new Combination[0]);
|
||||
}
|
||||
|
||||
public Combination get(int step) {
|
||||
return combinationArray[step];
|
||||
}
|
||||
|
||||
public int count() {
|
||||
return combinationArray.length;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String string = String.format("Gesture contains %d actions:\n", combinationArray.length);;
|
||||
for (Combination combination : combinationArray) {
|
||||
string += String.format("> %s\n", combination);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package pm.device.macro;
|
||||
|
||||
public interface Button {
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package pm.device.macro;
|
||||
|
||||
public class Macro {
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package pm.device.macro.action;
|
||||
|
||||
import pm.device.macro.Action;
|
||||
import pm.device.macro.Button;
|
||||
|
||||
public class Hold implements Action {
|
||||
public Button button;
|
||||
|
||||
public Hold(Button button) {
|
||||
this.button = button;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package pm.device.macro.action;
|
||||
|
||||
import pm.device.macro.Action;
|
||||
import pm.device.macro.Button;
|
||||
|
||||
public class Press implements Action {
|
||||
public Button button;
|
||||
|
||||
public Press(Button button) {
|
||||
this.button = button;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package pm.device.macro.action;
|
||||
|
||||
import pm.device.macro.Action;
|
||||
import pm.device.macro.Button;
|
||||
|
||||
public class Release implements Action {
|
||||
public Button button;
|
||||
|
||||
public Release(Button button) {
|
||||
this.button = button;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user