From d62a354d9acaac925e96f4811d3870533542b893 Mon Sep 17 00:00:00 2001 From: Rik Veenboer Date: Sat, 12 Feb 2011 22:34:43 +0000 Subject: [PATCH] RumblepadDevice aangepast aan nieuwe actions systeem. Enkele problemen worden duidelijk: - Toevoegen van release event mist bij opgeven van slechts press. - Verschillende macro's lopen door elkaar / stoppen niet. - iTunes's playPause functionaliteit lijkt next te invoken. --- java/src/pm/Main.java | 7 ++- .../javainput/rumblepad/RumblepadDevice.java | 62 +++++++++---------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/java/src/pm/Main.java b/java/src/pm/Main.java index 2ddd3d5..28df6b3 100644 --- a/java/src/pm/Main.java +++ b/java/src/pm/Main.java @@ -6,6 +6,7 @@ import pm.application.Winamp.WinampApplication; import pm.application.example.ExampleApplication; import pm.application.iTunes.iTunesApplication; import pm.device.gui.GUIDevice; +import pm.device.javainput.rumblepad.RumblepadDevice; import pm.device.jintellitype.JIntellitypeDevice; import pm.exception.application.ApplicationExitException; import pm.exception.device.DeviceExitException; @@ -33,7 +34,7 @@ public class Main extends TaskListener { public void initialise() throws DeviceInitialiseException { add(new JIntellitypeDevice()); - //add(new RumblepadDevice()); + add(new RumblepadDevice()); //add(new GUIDevice()); for (Device device : deviceList) { device.initialise(); @@ -41,8 +42,8 @@ public class Main extends TaskListener { add(new ExampleApplication()); //add(new WinampApplication()); - //add(new iTunesApplication()); - //applicationCycle.next(); + add(new iTunesApplication()); + applicationCycle.next(); for (Application application : applicationCycle) { application.start(); } diff --git a/java/src/pm/device/javainput/rumblepad/RumblepadDevice.java b/java/src/pm/device/javainput/rumblepad/RumblepadDevice.java index 4db30ac..1a08e42 100644 --- a/java/src/pm/device/javainput/rumblepad/RumblepadDevice.java +++ b/java/src/pm/device/javainput/rumblepad/RumblepadDevice.java @@ -3,13 +3,15 @@ package pm.device.javainput.rumblepad; import pm.Action; import pm.Button; import pm.Target; +import pm.Task; import pm.device.javainput.DirectionButton; import pm.device.javainput.JavaInputDevice; -import pm.exception.MacroException; import pm.exception.device.DeviceInitialiseException; import pm.exception.event.UnknownButtonException; import pm.exception.event.UnknownDirectionException; +import pm.macro.event.Hold; import pm.macro.event.Press; +import pm.task.Continuous; import de.hardcode.jxinput.event.JXInputButtonEvent; import de.hardcode.jxinput.event.JXInputDirectionalEvent; @@ -18,37 +20,33 @@ public class RumblepadDevice extends JavaInputDevice { public void initialise() throws DeviceInitialiseException { super.initialise(NAME); - try { - add( - new Press(RumblepadButton.ONE), - Action.PLAY.setTarget(Target.APPLICATION)); - add( - new Press(RumblepadButton.TWO), - Action.PAUSE.setTarget(Target.APPLICATION)); - add( - new Press(RumblepadButton.THREE), - Action.RESUME.setTarget(Target.APPLICATION)); - add( - new Press(RumblepadButton.SIX), - Action.NEXT.setTarget(Target.APPLICATION)); - add( - new Press(RumblepadButton.EIGHT), - Action.PREVIOUS.setTarget(Target.APPLICATION)); - add( - new Press(RumblepadButton.FIVE), - Action.FORWARD.setTarget(Target.APPLICATION)); - add( - new Press(RumblepadButton.SEVEN), - Action.REWIND.setTarget(Target.APPLICATION)); - add( - new Press(RumblepadButton.NINE), - Action.VOLUME_DOWN.setTarget(Target.APPLICATION)); - add( - new Press(RumblepadButton.TEN), - Action.VOLUME_UP.setTarget(Target.APPLICATION)); - } catch (MacroException e) { - e.printStackTrace(); - } + add( + new Press(RumblepadButton.ONE), + new Task(Action.PLAY, Target.APPLICATION)); + add( + new Press(RumblepadButton.TWO), + new Task(Action.PAUSE, Target.APPLICATION)); + add( + new Press(RumblepadButton.THREE), + new Task(Action.RESUME, Target.APPLICATION)); + add( + new Press(RumblepadButton.SIX), + new Task(Action.NEXT, Target.APPLICATION)); + add( + new Press(RumblepadButton.EIGHT), + new Task(Action.PREVIOUS, Target.APPLICATION)); + add( + new Hold(RumblepadButton.FIVE), + new Continuous(Action.FORWARD, Target.APPLICATION, 300)); + add( + new Hold(RumblepadButton.SEVEN), + new Continuous(Action.REWIND, Target.APPLICATION, 300)); + add( + new Hold(RumblepadButton.NINE), + new Continuous(Action.VOLUME_DOWN, Target.APPLICATION, 100)); + add( + new Hold(RumblepadButton.TEN), + new Continuous(Action.VOLUME_UP, Target.APPLICATION, 100)); } protected Button getButton(JXInputButtonEvent event) throws UnknownButtonException {