iTunes verder geimplementeerd en de eightfold switch renamed. Het lijkt er nu op dat play en pause bijvoorbeeld twee keer worden uitgevoerd als je één keer een knop indrukt. Misschien moeten dit macro's worden waarin ook om een release gevraagd wordt.
Met doorspoelen of terugspoelen, hoe maak je het mogelijk dat er gespoeld wordt totdat je de knop loslaat? Daar moet over nagedacht worden.
This commit is contained in:
@@ -14,7 +14,15 @@ public enum Action {
|
||||
EXIT ("exit"),
|
||||
PLAY ("play"),
|
||||
PAUSE ("pause"),
|
||||
RESUME ("resume");
|
||||
RESUME ("resume"),
|
||||
NEXT ("next"),
|
||||
PREVIOUS ("previous"),
|
||||
FORWARD ("forward"),
|
||||
REWIND ("rewind"),
|
||||
MUTE ("mute"),
|
||||
VOLUME_UP ("volumeUp"),
|
||||
VULUME_DOWN ("volumeDown");
|
||||
|
||||
|
||||
protected String action;
|
||||
protected Target target;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Main {
|
||||
//add(new ExampleDevice());
|
||||
add(new RumblepadDevice());
|
||||
//add(new Extreme3DDevice());
|
||||
add(new JIntellitypeDevice());
|
||||
//add(new JIntellitypeDevice());
|
||||
//add(new WiimoteDevice());
|
||||
for (Device device : deviceList) {
|
||||
device.start();
|
||||
|
||||
@@ -8,6 +8,10 @@ import com.dt.iTunesController.iTunes;
|
||||
import com.dt.iTunesController.iTunesEventsInterface;
|
||||
|
||||
public class iTunesApplication extends Application implements iTunesEventsInterface {
|
||||
|
||||
protected final int VOLUME_CHANGE_RATE = 5;
|
||||
protected final int SEEK_TIME = 1000;
|
||||
|
||||
protected iTunes iTunes;
|
||||
protected boolean connected;
|
||||
|
||||
@@ -15,7 +19,7 @@ public class iTunesApplication extends Application implements iTunesEventsInterf
|
||||
iTunes = new iTunes();
|
||||
connected = false;
|
||||
}
|
||||
|
||||
|
||||
public void start() {
|
||||
if (!connected) {
|
||||
iTunes.connect();
|
||||
@@ -49,6 +53,70 @@ public class iTunesApplication extends Application implements iTunesEventsInterf
|
||||
}
|
||||
}
|
||||
|
||||
public void next() {
|
||||
if (connected) {
|
||||
iTunes.nextTrack();
|
||||
}
|
||||
}
|
||||
|
||||
public void previous() {
|
||||
if (connected) {
|
||||
iTunes.previousTrack();
|
||||
}
|
||||
}
|
||||
|
||||
public void forward() {
|
||||
if (connected) {
|
||||
iTunes.fastForward();
|
||||
//sleep(SEEK_TIME);
|
||||
//resume();
|
||||
}
|
||||
}
|
||||
|
||||
public void rewind() {
|
||||
if (connected) {
|
||||
iTunes.rewind();
|
||||
//sleep(SEEK_TIME);
|
||||
//resume();
|
||||
}
|
||||
}
|
||||
|
||||
protected void sleep(int time) {
|
||||
try {
|
||||
Thread.sleep(time);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void mute() {
|
||||
if (connected) {
|
||||
iTunes.setMute(iTunes.getMute());
|
||||
}
|
||||
}
|
||||
|
||||
protected int volume() {
|
||||
if (connected) {
|
||||
return iTunes.getSoundVolume();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void volumeUp() {
|
||||
if (connected) {
|
||||
iTunes.setSoundVolume(volume() + VOLUME_CHANGE_RATE);
|
||||
}
|
||||
}
|
||||
|
||||
public void volumeDown() {
|
||||
if (connected) {
|
||||
iTunes.setSoundVolume(volume() - VOLUME_CHANGE_RATE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* iTunesEventInterface => naar eigen class? */
|
||||
@Override
|
||||
public void onDatabaseChangedEvent(int[][] deletedObjectIDs,
|
||||
|
||||
@@ -4,7 +4,7 @@ import pm.Button;
|
||||
import pm.exception.event.UnknownDirectionException;
|
||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||
|
||||
public enum EightfoldDirection implements Button {
|
||||
public enum DirectionalSwitch implements Button {
|
||||
NORTH (0),
|
||||
NORTHEAST (45),
|
||||
EAST (90),
|
||||
@@ -16,7 +16,7 @@ public enum EightfoldDirection implements Button {
|
||||
|
||||
protected int code;
|
||||
|
||||
private EightfoldDirection(int code) {
|
||||
private DirectionalSwitch(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ public enum EightfoldDirection implements Button {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static EightfoldDirection create(int angle) throws UnknownDirectionException {
|
||||
for (EightfoldDirection button : EightfoldDirection.values()) {
|
||||
public static DirectionalSwitch create(int angle) throws UnknownDirectionException {
|
||||
for (DirectionalSwitch button : DirectionalSwitch.values()) {
|
||||
if (button.getCode() == angle) {
|
||||
return button;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public enum EightfoldDirection implements Button {
|
||||
throw new UnknownDirectionException();
|
||||
}
|
||||
|
||||
public static EightfoldDirection create(JXInputDirectionalEvent event) throws UnknownDirectionException {
|
||||
public static DirectionalSwitch create(JXInputDirectionalEvent event) throws UnknownDirectionException {
|
||||
return create(event.getDirectional().getDirection() / 100);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import pm.Action;
|
||||
import pm.Button;
|
||||
import pm.Macro;
|
||||
import pm.Target;
|
||||
import pm.device.javainput.EightfoldDirection;
|
||||
import pm.device.javainput.DirectionalSwitch;
|
||||
import pm.device.javainput.JavaInputDevice;
|
||||
import pm.exception.DeviceException;
|
||||
import pm.exception.MacroException;
|
||||
@@ -46,6 +46,6 @@ public class Extreme3DDevice extends JavaInputDevice {
|
||||
}
|
||||
|
||||
protected Button getButton(JXInputDirectionalEvent event) throws UnknownDirectionException {
|
||||
return EightfoldDirection.create(event);
|
||||
return DirectionalSwitch.create(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import pm.Action;
|
||||
import pm.Button;
|
||||
import pm.Macro;
|
||||
import pm.Target;
|
||||
import pm.device.javainput.EightfoldDirection;
|
||||
import pm.device.javainput.DirectionalSwitch;
|
||||
import pm.device.javainput.JavaInputDevice;
|
||||
import pm.exception.DeviceException;
|
||||
import pm.exception.MacroException;
|
||||
@@ -35,10 +35,23 @@ public class RumblepadDevice extends JavaInputDevice {
|
||||
new Press(RumblepadButton.THREE),
|
||||
Action.RESUME.setTarget(Target.APPLICATION));
|
||||
add(
|
||||
new Macro(
|
||||
new Press(RumblepadButton.NINE)
|
||||
),
|
||||
Action.EXIT.setTarget(Target.MAIN));
|
||||
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.VULUME_DOWN.setTarget(Target.APPLICATION));
|
||||
add(
|
||||
new Press(RumblepadButton.TEN),
|
||||
Action.VOLUME_UP.setTarget(Target.APPLICATION));
|
||||
} catch (MacroException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -49,6 +62,6 @@ public class RumblepadDevice extends JavaInputDevice {
|
||||
}
|
||||
|
||||
protected Button getButton(JXInputDirectionalEvent event) throws UnknownDirectionException {
|
||||
return EightfoldDirection.create(event);
|
||||
return DirectionalSwitch.create(event);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user