Rumblepad geimplementeerd, actions toegevoegd en begin gemaakt met iTunes implementatie. Die geeft rare Jacob foutmeldingen over de versie.

This commit is contained in:
Bram Veenboer
2011-02-08 21:01:37 +00:00
parent e9c0216ad9
commit 0fb1a1fb71
6 changed files with 191 additions and 3 deletions

View File

@@ -0,0 +1,41 @@
package pm.device.javainput.rumblepad;
import de.hardcode.jxinput.event.JXInputButtonEvent;
import pm.Button;
import pm.exception.event.UnknownButtonException;
public enum RumblepadButton implements Button {
ONE ("Button 0"),
TWO ("Button 1"),
THREE ("Button 2"),
FOUR ("Button 3"),
FIVE ("Button 4"),
SIX ("Button 5"),
SEVEN ("Button 6"),
EIGHT ("Button 7"),
NINE ("Button 8"),
TEN ("Button 9");
protected String code;
private RumblepadButton(String code) {
this.code = code;
}
public String getCode() {
return code;
}
public static RumblepadButton create(String code) throws UnknownButtonException {
for (RumblepadButton button : RumblepadButton.values()) {
if (button.getCode().equals(code)) {
return button;
}
}
throw new UnknownButtonException();
}
public static RumblepadButton create(JXInputButtonEvent event) throws UnknownButtonException {
return create(event.getButton().getName());
}
}

View File

@@ -1,7 +1,11 @@
package pm.device.javainput.rumblepad;
import pm.Action;
import pm.Target;
import pm.device.javainput.JavaInputDevice;
import pm.exception.DeviceException;
import pm.exception.MacroException;
import pm.macro.event.Press;
public class RumblepadDevice extends JavaInputDevice {
@@ -9,5 +13,25 @@ public class RumblepadDevice extends JavaInputDevice {
public RumblepadDevice() throws DeviceException {
super(NAME);
}
}
public void start() {
super.start();
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.FOUR),
Action.EXIT.setTarget(Target.MAIN));
} catch (MacroException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,39 @@
package pm.device.javainput.rumblepad;
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
import pm.Button;
import pm.exception.event.UnknownDirectionException;
public enum RumblepadDirection implements Button {
NORTH (0),
NORTHEAST (45),
EAST (90),
SOUTHEAST (135),
SOUTH (180),
SOUTHWEST (225),
WEST (270),
NORTHWEST (315);
protected int code;
private RumblepadDirection(int code) {
this.code = code;
}
public int getCode() {
return code;
}
public static RumblepadDirection create(int angle) throws UnknownDirectionException {
for (RumblepadDirection button : RumblepadDirection.values()) {
if (button.getCode() == angle) {
return button;
}
}
throw new UnknownDirectionException();
}
public static RumblepadDirection create(JXInputDirectionalEvent event) throws UnknownDirectionException {
return create(event.getDirectional().getDirection() / 100);
}
}

View File

@@ -0,0 +1,31 @@
package pm.device.textinput;
import java.util.Scanner;
import pm.device.Device;
public class TextinputDevice extends Device {
static final int SLEEP = 50;
Scanner textinputScanner;
boolean run;
public TextinputDevice() {
textinputScanner = new Scanner(System.in);
run = true;
}
public void start() {
while(run) {
String textinput = textinputScanner.next();
if(textinput != null) {
System.out.println(textinput);
}
try {
Thread.sleep(SLEEP);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}