Rumblepad geimplementeerd, actions toegevoegd en begin gemaakt met iTunes implementatie. Die geeft rare Jacob foutmeldingen over de versie.
This commit is contained in:
@@ -11,8 +11,11 @@ import pm.exception.action.TargetNotSetException;
|
||||
public enum Action {
|
||||
START ("start"),
|
||||
TEST ("test"),
|
||||
EXIT ("exit");
|
||||
|
||||
EXIT ("exit"),
|
||||
PLAY ("play"),
|
||||
PAUSE ("pause"),
|
||||
RESUME ("resume");
|
||||
|
||||
protected String action;
|
||||
protected Target target;
|
||||
|
||||
|
||||
50
java/src/pm/application/iTunes/iTunes.java
Normal file
50
java/src/pm/application/iTunes/iTunes.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package pm.application.iTunes;
|
||||
|
||||
import pm.application.Application;
|
||||
|
||||
import com.jacob.activeX.ActiveXComponent;
|
||||
import com.jacob.com.ComThread;
|
||||
import com.jacob.com.Dispatch;
|
||||
|
||||
public class iTunes extends Application{
|
||||
|
||||
Dispatch iTunesController;
|
||||
|
||||
public iTunes() {
|
||||
connect();
|
||||
}
|
||||
|
||||
protected void connect() {
|
||||
try {
|
||||
ComThread.InitMTA(true);
|
||||
ActiveXComponent iTunesCom = new ActiveXComponent("iTunes.Application");
|
||||
iTunesController = (Dispatch)iTunesCom.getObject();
|
||||
} catch (Exception e) { } // Ignore JacobVersion exception
|
||||
}
|
||||
|
||||
public void play() {
|
||||
System.out.println("play");
|
||||
invoke("play");
|
||||
}
|
||||
|
||||
public void pause() {
|
||||
invoke("pause");
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
invoke("resume");
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
ComThread.Release();
|
||||
}
|
||||
|
||||
protected void invoke(String invocation) {
|
||||
Dispatch.call(iTunesController, invocation);
|
||||
}
|
||||
|
||||
public static void main(String argv[]) throws Exception {
|
||||
new iTunes();
|
||||
}
|
||||
|
||||
}
|
||||
41
java/src/pm/device/javainput/rumblepad/RumblepadButton.java
Normal file
41
java/src/pm/device/javainput/rumblepad/RumblepadButton.java
Normal 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());
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
31
java/src/pm/device/textinput/TextinputDevice.java
Normal file
31
java/src/pm/device/textinput/TextinputDevice.java
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user