Werking nader bestudeerd, enkele dingen ligt aangepast.
This commit is contained in:
@@ -33,17 +33,17 @@ public abstract class Device {
|
||||
|
||||
protected void add(Sequence startSequence, Sequence stopSequence, Continuous continuous) {
|
||||
add(startSequence, continuous);
|
||||
add(stopSequence, new Stopper(continuous));
|
||||
add(stopSequence, new Stopper(continuous));
|
||||
}
|
||||
|
||||
protected void add(Event startEvent, Event stopEvent, Continuous continuous) {
|
||||
add(startEvent, continuous);
|
||||
add(stopEvent, new Stopper(continuous));
|
||||
add(stopEvent, new Stopper(continuous));
|
||||
}
|
||||
|
||||
protected void add(Press startPress, Press stopPress, Continuous continuous) {
|
||||
add(new Macro(startPress), continuous);
|
||||
add(new Macro(stopPress), new Stopper(continuous));
|
||||
add(new Macro(stopPress), new Stopper(continuous));
|
||||
}
|
||||
|
||||
protected void add(Hold hold, Continuous continuous) {
|
||||
|
||||
@@ -8,6 +8,10 @@ public class Task {
|
||||
this.action = action;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public Task(Action action) {
|
||||
this(action, Target.MAIN);
|
||||
}
|
||||
|
||||
public Action getAction() {
|
||||
return action;
|
||||
|
||||
@@ -52,13 +52,7 @@ public class WinampApplication extends Application {
|
||||
WinampController.rew5Secs();
|
||||
break;
|
||||
case MUTE:
|
||||
if(muted) {
|
||||
WinampController.setVolume(volume);
|
||||
} else {
|
||||
volume = WinampController.getVolume();
|
||||
WinampController.setVolume(0);
|
||||
}
|
||||
muted = !muted;
|
||||
toggleMute();
|
||||
break;
|
||||
case VOLUME_UP:
|
||||
WinampController.increaseVolume();
|
||||
@@ -67,7 +61,16 @@ public class WinampApplication extends Application {
|
||||
WinampController.decreaseVolume();
|
||||
break;
|
||||
}
|
||||
} catch (InvalidHandle e) {
|
||||
} catch (InvalidHandle e) {}
|
||||
}
|
||||
|
||||
protected void toggleMute() throws InvalidHandle {
|
||||
if (!muted) {
|
||||
volume = WinampController.getVolume();
|
||||
}
|
||||
try {
|
||||
WinampController.setVolume(muted ? volume : 0);
|
||||
} catch (InvalidParameter e) {}
|
||||
muted = !muted;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@ package pm.device.gui;
|
||||
|
||||
import pm.Device;
|
||||
|
||||
public class GUIDevice extends Device {
|
||||
|
||||
public class GUIDevice extends Device {
|
||||
protected GUIDeviceUI gui;
|
||||
|
||||
public GUIDevice() {
|
||||
|
||||
@@ -7,27 +7,28 @@ import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import pm.Action;
|
||||
import pm.Target;
|
||||
import pm.task.ActionProvider;
|
||||
import pm.Task;
|
||||
import pm.task.TaskGatherer;
|
||||
|
||||
import layout.TableLayout;
|
||||
import layout.TableLayoutConstraints;
|
||||
|
||||
public class GUIDeviceUI extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
private JButton play;
|
||||
private JButton pause;
|
||||
private JButton resume;
|
||||
private JButton next;
|
||||
private JButton previous;
|
||||
private JButton forward;
|
||||
private JButton rewind;
|
||||
private JButton mute;
|
||||
private JButton volumeUp;
|
||||
private JButton volumeDown;
|
||||
protected JButton play;
|
||||
protected JButton pause;
|
||||
protected JButton resume;
|
||||
protected JButton next;
|
||||
protected JButton previous;
|
||||
protected JButton forward;
|
||||
protected JButton rewind;
|
||||
protected JButton mute;
|
||||
protected JButton volumeUp;
|
||||
protected JButton volumeDown;
|
||||
|
||||
//ActionProvider.add
|
||||
//TaskGatherer.add
|
||||
public GUIDeviceUI() {
|
||||
initComponents();
|
||||
setSize(30, 300);
|
||||
@@ -155,43 +156,43 @@ public class GUIDeviceUI extends JFrame {
|
||||
add(volumeDown, new TableLayoutConstraints(0, 9, 0, 9, TableLayoutConstraints.FULL, TableLayoutConstraints.FULL));
|
||||
}
|
||||
|
||||
private void playAction(ActionEvent e) {
|
||||
ActionProvider.add(Action.PLAY.setTarget(Target.APPLICATION));
|
||||
protected void playAction(ActionEvent e) {
|
||||
TaskGatherer.add(new Task(Action.PLAY, Target.APPLICATION));
|
||||
}
|
||||
|
||||
private void pauseAction(ActionEvent e) {
|
||||
ActionProvider.add(Action.PAUSE.setTarget(Target.APPLICATION));
|
||||
protected void pauseAction(ActionEvent e) {
|
||||
TaskGatherer.add(new Task(Action.PAUSE, Target.APPLICATION));
|
||||
}
|
||||
|
||||
private void resumeAction(ActionEvent e) {
|
||||
ActionProvider.add(Action.RESUME.setTarget(Target.APPLICATION));
|
||||
protected void resumeAction(ActionEvent e) {
|
||||
TaskGatherer.add(new Task(Action.RESUME, Target.APPLICATION));
|
||||
}
|
||||
|
||||
private void nextAction(ActionEvent e) {
|
||||
ActionProvider.add(Action.NEXT.setTarget(Target.APPLICATION));
|
||||
protected void nextAction(ActionEvent e) {
|
||||
TaskGatherer.add(new Task(Action.NEXT, Target.APPLICATION));
|
||||
}
|
||||
|
||||
private void previousAction(ActionEvent e) {
|
||||
ActionProvider.add(Action.PREVIOUS.setTarget(Target.APPLICATION));
|
||||
protected void previousAction(ActionEvent e) {
|
||||
TaskGatherer.add(new Task(Action.PREVIOUS, Target.APPLICATION));
|
||||
}
|
||||
|
||||
private void forwardAction(ActionEvent e) {
|
||||
ActionProvider.add(Action.FORWARD.setTarget(Target.APPLICATION));
|
||||
protected void forwardAction(ActionEvent e) {
|
||||
TaskGatherer.add(new Task(Action.FORWARD, Target.APPLICATION));
|
||||
}
|
||||
|
||||
private void rewindAction(ActionEvent e) {
|
||||
ActionProvider.add(Action.REWIND.setTarget(Target.APPLICATION));
|
||||
protected void rewindAction(ActionEvent e) {
|
||||
TaskGatherer.add(new Task(Action.REWIND, Target.APPLICATION));
|
||||
}
|
||||
|
||||
private void muteAction(ActionEvent e) {
|
||||
ActionProvider.add(Action.MUTE.setTarget(Target.APPLICATION));
|
||||
protected void muteAction(ActionEvent e) {
|
||||
TaskGatherer.add(new Task(Action.MUTE, Target.APPLICATION));
|
||||
}
|
||||
|
||||
private void volumeUpAction(ActionEvent e) {
|
||||
ActionProvider.add(Action.VOLUME_UP.setTarget(Target.APPLICATION));
|
||||
protected void volumeUpAction(ActionEvent e) {
|
||||
TaskGatherer.add(new Task(Action.VOLUME_UP, Target.APPLICATION));
|
||||
}
|
||||
|
||||
private void volumeDownAction(ActionEvent e) {
|
||||
ActionProvider.add(Action.VOLUME_DOWN.setTarget(Target.APPLICATION));
|
||||
protected void volumeDownAction(ActionEvent e) {
|
||||
TaskGatherer.add(new Task(Action.VOLUME_DOWN, Target.APPLICATION));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import pm.exception.event.UnknownDirectionException;
|
||||
import pm.macro.event.Hold;
|
||||
import pm.macro.event.Press;
|
||||
import pm.task.Continuous;
|
||||
import pm.task.Dynamic;
|
||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||
|
||||
@@ -37,12 +38,10 @@ public class RumblepadDevice extends JavaInputDevice {
|
||||
new Task(Action.PREVIOUS, Target.APPLICATION));
|
||||
add(
|
||||
new Hold(RumblepadButton.FIVE),
|
||||
new Continuous(Action.FORWARD, Target.APPLICATION, 200){
|
||||
public int getSleep() {return sleep - 30 * iteration;}});
|
||||
new Dynamic(Action.FORWARD, Target.APPLICATION, 200, -30));
|
||||
add(
|
||||
new Hold(RumblepadButton.SEVEN),
|
||||
new Continuous(Action.REWIND, Target.APPLICATION, 200){
|
||||
public int getSleep() {return sleep - 30 * iteration;}});
|
||||
new Dynamic(Action.REWIND, Target.APPLICATION, 200, -30));
|
||||
add(
|
||||
new Hold(RumblepadButton.NINE),
|
||||
new Continuous(Action.VOLUME_DOWN, Target.APPLICATION, 100));
|
||||
|
||||
@@ -56,7 +56,7 @@ public class JIntellitypeDevice extends Device implements HotkeyListener, Intell
|
||||
public void onHotKey(int id) {
|
||||
Hotkey hotkey = hotkeyList.get(id);
|
||||
add(hotkeyList.get(id));
|
||||
add(new Release(hotkey.getButton()));
|
||||
add(new Release(hotkey.getButton()));
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
|
||||
@@ -5,6 +5,8 @@ import pm.Target;
|
||||
import pm.Task;
|
||||
|
||||
public class Continuous extends Task {
|
||||
protected static final int SLEEP = 0;
|
||||
|
||||
protected int sleep;
|
||||
protected int iteration;
|
||||
protected boolean stop;
|
||||
@@ -16,7 +18,7 @@ public class Continuous extends Task {
|
||||
}
|
||||
|
||||
public Continuous(Action action, Target target) {
|
||||
this(action, target, 0);
|
||||
this(action, target, SLEEP);
|
||||
}
|
||||
|
||||
public void nextIteration() {
|
||||
|
||||
24
java/src/pm/task/Dynamic.java
Normal file
24
java/src/pm/task/Dynamic.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package pm.task;
|
||||
|
||||
import pm.Action;
|
||||
import pm.Target;
|
||||
|
||||
public class Dynamic extends Continuous {
|
||||
protected static final int RATE = 10;
|
||||
|
||||
protected int rate;
|
||||
|
||||
public Dynamic(Action action, Target target, int sleep, int rate) {
|
||||
super(action, target, sleep);
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public Dynamic(Action action, Target target, int sleep) {
|
||||
super(action, target, sleep);
|
||||
this.rate = RATE;
|
||||
}
|
||||
|
||||
public int getSleep() {
|
||||
return sleep + rate * iteration;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user