Implementeren van macro's begonnen.
This commit is contained in:
@@ -8,10 +8,9 @@ import pm.action.Action;
|
|||||||
import pm.application.Application;
|
import pm.application.Application;
|
||||||
import pm.application.voorbeeld.VoorbeeldApplication;
|
import pm.application.voorbeeld.VoorbeeldApplication;
|
||||||
import pm.device.Device;
|
import pm.device.Device;
|
||||||
import pm.device.example.ExampleDevice;
|
import pm.device.javainput.extreme3d.Extreme3DDevice;
|
||||||
import pm.device.rumblepad.RumblepadDevice;
|
|
||||||
import pm.exception.ActionException;
|
import pm.exception.ActionException;
|
||||||
import pm.exception.ActionNotImplementedException;
|
import pm.exception.NotImplementedActionException;
|
||||||
import pm.exception.EventException;
|
import pm.exception.EventException;
|
||||||
|
|
||||||
public class Main extends Target {
|
public class Main extends Target {
|
||||||
@@ -51,8 +50,9 @@ public class Main extends Target {
|
|||||||
|
|
||||||
public void start() throws Exception {
|
public void start() throws Exception {
|
||||||
//addDevice(new ExampleDevice());
|
//addDevice(new ExampleDevice());
|
||||||
addDevice(new RumblepadDevice());
|
//addDevice(new RumblepadDevice());
|
||||||
|
addDevice(new Extreme3DDevice());
|
||||||
|
|
||||||
Application application = new VoorbeeldApplication();
|
Application application = new VoorbeeldApplication();
|
||||||
addApplication(application);
|
addApplication(application);
|
||||||
currentApplication = application;
|
currentApplication = application;
|
||||||
@@ -88,7 +88,7 @@ public class Main extends Target {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
target.invoke(action);
|
target.invoke(action);
|
||||||
} catch (ActionNotImplementedException e) {
|
} catch (NotImplementedActionException e) {
|
||||||
// Todo: log.write(...)
|
// Todo: log.write(...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
|
|
||||||
import pm.action.Action;
|
import pm.action.Action;
|
||||||
import pm.exception.ActionException;
|
import pm.exception.ActionException;
|
||||||
import pm.exception.ActionInvokeException;
|
import pm.exception.InvokeActionException;
|
||||||
|
|
||||||
public abstract class Target {
|
public abstract class Target {
|
||||||
public void invoke(Action action) throws ActionException {
|
public void invoke(Action action) throws ActionException {
|
||||||
@@ -14,7 +14,7 @@ public abstract class Target {
|
|||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
} catch (InvocationTargetException e) {}
|
} catch (InvocationTargetException e) {}
|
||||||
throw new ActionInvokeException();
|
throw new InvokeActionException();
|
||||||
// Todo: informatie doorgeven over wat er precies is foutgegaan
|
// Todo: informatie doorgeven over wat er precies is foutgegaan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package pm.action;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import pm.event.Target;
|
import pm.event.Target;
|
||||||
import pm.exception.ActionNotImplementedException;
|
import pm.exception.NotImplementedActionException;
|
||||||
|
|
||||||
public enum Action {
|
public enum Action {
|
||||||
START ("start"),
|
START ("start"),
|
||||||
@@ -25,11 +25,11 @@ public enum Action {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Method getMethod(Object object) throws ActionNotImplementedException {
|
public Method getMethod(Object object) throws NotImplementedActionException {
|
||||||
try {
|
try {
|
||||||
return object.getClass().getMethod(action);
|
return object.getClass().getMethod(action);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
} catch (NoSuchMethodException e) {}
|
} catch (NoSuchMethodException e) {}
|
||||||
throw new ActionNotImplementedException();
|
throw new NotImplementedActionException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,14 @@ import java.util.Queue;
|
|||||||
import pm.action.Action;
|
import pm.action.Action;
|
||||||
import pm.event.Target;
|
import pm.event.Target;
|
||||||
|
|
||||||
|
|
||||||
public abstract class Device {
|
public abstract class Device {
|
||||||
protected static Queue<Action> actionQueue;
|
protected static Queue<Action> actionQueue;
|
||||||
|
protected MacroListener macroListener;
|
||||||
|
|
||||||
|
public Device() {
|
||||||
|
macroListener = new MacroListener();
|
||||||
|
macroListener.start();
|
||||||
|
}
|
||||||
|
|
||||||
public void addAction(Action action, Target target) {
|
public void addAction(Action action, Target target) {
|
||||||
action.setTarget(target);
|
action.setTarget(target);
|
||||||
@@ -17,7 +22,7 @@ public abstract class Device {
|
|||||||
public static void initialise(Queue<Action> actionQueue) {
|
public static void initialise(Queue<Action> actionQueue) {
|
||||||
Device.actionQueue = actionQueue;
|
Device.actionQueue = actionQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void start();
|
public void start() {}
|
||||||
public abstract void exit();
|
public void exit() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,131 +0,0 @@
|
|||||||
package pm.device;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.Queue;
|
|
||||||
|
|
||||||
import de.hardcode.jxinput.Axis;
|
|
||||||
import de.hardcode.jxinput.Button;
|
|
||||||
import de.hardcode.jxinput.Directional;
|
|
||||||
import de.hardcode.jxinput.JXInputDevice;
|
|
||||||
import de.hardcode.jxinput.JXInputManager;
|
|
||||||
import de.hardcode.jxinput.event.JXInputAxisEvent;
|
|
||||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
|
||||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
|
||||||
import de.hardcode.jxinput.event.JXInputEventManager;
|
|
||||||
|
|
||||||
import pm.action.Action;
|
|
||||||
import pm.event.Target;
|
|
||||||
import pm.exception.ServiceJavaInputDeviceNotFoundException;
|
|
||||||
import pm.exception.ServiceJavaInputException;
|
|
||||||
|
|
||||||
public abstract class JavaInputDevice extends Device {
|
|
||||||
protected static int SLEEP = 100;
|
|
||||||
|
|
||||||
public boolean run = true;
|
|
||||||
|
|
||||||
public JavaInputListener javaInputListener;
|
|
||||||
public Queue<JXInputAxisEvent> axisEventQueue;
|
|
||||||
public Queue<JXInputButtonEvent> buttonEventQueue;
|
|
||||||
public Queue<JXInputDirectionalEvent> directionalEventQueue;
|
|
||||||
//public static JavaInputService jxinputService;
|
|
||||||
|
|
||||||
protected JXInputDevice jxinputDevice;
|
|
||||||
|
|
||||||
protected JavaInputDevice(String name) throws ServiceJavaInputException {
|
|
||||||
axisEventQueue = new LinkedList<JXInputAxisEvent>();
|
|
||||||
buttonEventQueue = new LinkedList<JXInputButtonEvent>();
|
|
||||||
directionalEventQueue = new LinkedList<JXInputDirectionalEvent>();
|
|
||||||
javaInputListener = new JavaInputListener(axisEventQueue, buttonEventQueue, directionalEventQueue);
|
|
||||||
|
|
||||||
/*if (jxinputService == null) {
|
|
||||||
throw new ServiceJavaInputException();
|
|
||||||
}*/
|
|
||||||
//JXInputDevice x = jxinputService.getDevice(name);
|
|
||||||
jxinputDevice = getDevice(name);
|
|
||||||
System.out.printf("Initialized: %s\n", jxinputDevice.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JXInputDevice getDevice(String name) throws ServiceJavaInputException {
|
|
||||||
int numberOfDevices = JXInputManager.getNumberOfDevices();
|
|
||||||
for (int i = 0; i < numberOfDevices; ++i) {
|
|
||||||
JXInputDevice device = JXInputManager.getJXInputDevice(i);
|
|
||||||
if (device.getName().startsWith(name)) {
|
|
||||||
return device;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new ServiceJavaInputDeviceNotFoundException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void start() {
|
|
||||||
startListeners();
|
|
||||||
startUpdateThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void startUpdateThread() {
|
|
||||||
new Thread() {
|
|
||||||
public void run() {
|
|
||||||
while (run) {
|
|
||||||
JXInputManager.updateFeatures();
|
|
||||||
boolean sleep = true;
|
|
||||||
if (!axisEventQueue.isEmpty()) {
|
|
||||||
processEvent(axisEventQueue.poll());
|
|
||||||
sleep = false;
|
|
||||||
}
|
|
||||||
if (!buttonEventQueue.isEmpty()) {
|
|
||||||
processEvent(buttonEventQueue.poll());
|
|
||||||
sleep = false;
|
|
||||||
}
|
|
||||||
if (!directionalEventQueue.isEmpty()) {
|
|
||||||
processEvent(directionalEventQueue.poll());
|
|
||||||
sleep = false;
|
|
||||||
}
|
|
||||||
if (sleep) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(SLEEP);
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void processEvent(JXInputAxisEvent event) {
|
|
||||||
addAction(Action.START, Target.APPLICATION);
|
|
||||||
//System.out.println(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void processEvent(JXInputButtonEvent event) {
|
|
||||||
addAction(Action.TEST, Target.APPLICATION);
|
|
||||||
//System.out.println(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void processEvent(JXInputDirectionalEvent event) {
|
|
||||||
addAction(Action.EXIT, Target.APPLICATION);
|
|
||||||
//System.out.println(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void startListeners() {
|
|
||||||
for (int i = 0; i < jxinputDevice.getMaxNumberOfAxes(); ++i) {
|
|
||||||
Axis axis = jxinputDevice.getAxis(i);
|
|
||||||
if (axis != null) {
|
|
||||||
JXInputEventManager.addListener(javaInputListener, axis);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < jxinputDevice.getMaxNumberOfButtons(); ++i) {
|
|
||||||
Button button = jxinputDevice.getButton(i);
|
|
||||||
if (button != null) {
|
|
||||||
JXInputEventManager.addListener(javaInputListener, button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < jxinputDevice.getMaxNumberOfDirectionals(); ++i) {
|
|
||||||
Directional directional = jxinputDevice.getDirectional(i);
|
|
||||||
if (directional != null) {
|
|
||||||
JXInputEventManager.addListener(javaInputListener, directional);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void exit() {
|
|
||||||
run = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package pm.device;
|
|
||||||
|
|
||||||
import java.util.Queue;
|
|
||||||
|
|
||||||
import de.hardcode.jxinput.event.JXInputAxisEvent;
|
|
||||||
import de.hardcode.jxinput.event.JXInputAxisEventListener;
|
|
||||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
|
||||||
import de.hardcode.jxinput.event.JXInputButtonEventListener;
|
|
||||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
|
||||||
import de.hardcode.jxinput.event.JXInputDirectionalEventListener;
|
|
||||||
|
|
||||||
public class JavaInputListener implements JXInputAxisEventListener, JXInputButtonEventListener, JXInputDirectionalEventListener {
|
|
||||||
|
|
||||||
protected Queue<JXInputAxisEvent> axisEventQueue;
|
|
||||||
protected Queue<JXInputButtonEvent> buttonEventQueue;
|
|
||||||
protected Queue<JXInputDirectionalEvent> directonalEventQueue;
|
|
||||||
|
|
||||||
public JavaInputListener(Queue<JXInputAxisEvent> axisEventQueue, Queue<JXInputButtonEvent> buttonEventQueue, Queue<JXInputDirectionalEvent> directonalEventQueue) {
|
|
||||||
this.axisEventQueue = axisEventQueue;
|
|
||||||
this.buttonEventQueue = buttonEventQueue;
|
|
||||||
this.directonalEventQueue = directonalEventQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changed(JXInputAxisEvent event) {
|
|
||||||
axisEventQueue.add(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changed(JXInputButtonEvent event) {
|
|
||||||
buttonEventQueue.add(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changed(JXInputDirectionalEvent event) {
|
|
||||||
directonalEventQueue.add(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
9
java/src/pm/device/MacroListener.java
Normal file
9
java/src/pm/device/MacroListener.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package pm.device;
|
||||||
|
|
||||||
|
import pm.device.macro.Macro;
|
||||||
|
|
||||||
|
public class MacroListener extends Thread {
|
||||||
|
/*public void add(Macro macro, Action action, Target target) {
|
||||||
|
|
||||||
|
}*/
|
||||||
|
}
|
||||||
40
java/src/pm/device/javainput/JavaInputDevice.java
Normal file
40
java/src/pm/device/javainput/JavaInputDevice.java
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package pm.device.javainput;
|
||||||
|
|
||||||
|
import de.hardcode.jxinput.JXInputDevice;
|
||||||
|
import de.hardcode.jxinput.JXInputManager;
|
||||||
|
import de.hardcode.jxinput.event.JXInputAxisEvent;
|
||||||
|
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||||
|
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||||
|
|
||||||
|
import pm.device.Device;
|
||||||
|
import pm.exception.DeviceException;
|
||||||
|
import pm.exception.JavaInputDeviceNotFoundException;
|
||||||
|
|
||||||
|
public abstract class JavaInputDevice extends Device {
|
||||||
|
protected JavaInputListener javaInputListener;
|
||||||
|
//protected JXInputDevice jxinputDevice;
|
||||||
|
|
||||||
|
protected JavaInputDevice(String name) throws DeviceException {
|
||||||
|
super();
|
||||||
|
javaInputListener = new JavaInputListener(this, getDevice(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
javaInputListener.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JXInputDevice getDevice(String name) throws DeviceException {
|
||||||
|
int numberOfDevices = JXInputManager.getNumberOfDevices();
|
||||||
|
for (int i = 0; i < numberOfDevices; ++i) {
|
||||||
|
JXInputDevice device = JXInputManager.getJXInputDevice(i);
|
||||||
|
if (device.getName().startsWith(name)) {
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new JavaInputDeviceNotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processEvent(JXInputAxisEvent event) {}
|
||||||
|
public void processEvent(JXInputButtonEvent event) {}
|
||||||
|
public void processEvent(JXInputDirectionalEvent event) {}
|
||||||
|
}
|
||||||
97
java/src/pm/device/javainput/JavaInputListener.java
Normal file
97
java/src/pm/device/javainput/JavaInputListener.java
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
package pm.device.javainput;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Queue;
|
||||||
|
|
||||||
|
import de.hardcode.jxinput.Axis;
|
||||||
|
import de.hardcode.jxinput.Button;
|
||||||
|
import de.hardcode.jxinput.Directional;
|
||||||
|
import de.hardcode.jxinput.JXInputDevice;
|
||||||
|
import de.hardcode.jxinput.JXInputManager;
|
||||||
|
import de.hardcode.jxinput.event.JXInputAxisEvent;
|
||||||
|
import de.hardcode.jxinput.event.JXInputAxisEventListener;
|
||||||
|
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||||
|
import de.hardcode.jxinput.event.JXInputButtonEventListener;
|
||||||
|
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||||
|
import de.hardcode.jxinput.event.JXInputDirectionalEventListener;
|
||||||
|
import de.hardcode.jxinput.event.JXInputEventManager;
|
||||||
|
|
||||||
|
public class JavaInputListener extends Thread implements JXInputAxisEventListener, JXInputButtonEventListener, JXInputDirectionalEventListener {
|
||||||
|
protected static int SLEEP = 100;
|
||||||
|
|
||||||
|
protected boolean run;
|
||||||
|
protected JavaInputDevice javaInputDevice;
|
||||||
|
protected JXInputDevice jxinputDevice;
|
||||||
|
protected Queue<JXInputAxisEvent> axisEventQueue;
|
||||||
|
protected Queue<JXInputButtonEvent> buttonEventQueue;
|
||||||
|
protected Queue<JXInputDirectionalEvent> directionalEventQueue;
|
||||||
|
|
||||||
|
public JavaInputListener(JavaInputDevice javaInputDevice, JXInputDevice jxinputDevice) {
|
||||||
|
this.javaInputDevice = javaInputDevice;
|
||||||
|
this.jxinputDevice = jxinputDevice;
|
||||||
|
axisEventQueue = new LinkedList<JXInputAxisEvent>();
|
||||||
|
buttonEventQueue = new LinkedList<JXInputButtonEvent>();
|
||||||
|
directionalEventQueue = new LinkedList<JXInputDirectionalEvent>();
|
||||||
|
addListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addListeners() {
|
||||||
|
for (int i = 0; i < jxinputDevice.getMaxNumberOfAxes(); ++i) {
|
||||||
|
Axis axis = jxinputDevice.getAxis(i);
|
||||||
|
if (axis != null) {
|
||||||
|
JXInputEventManager.addListener(this, axis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < jxinputDevice.getMaxNumberOfButtons(); ++i) {
|
||||||
|
Button button = jxinputDevice.getButton(i);
|
||||||
|
if (button != null) {
|
||||||
|
JXInputEventManager.addListener(this, button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < jxinputDevice.getMaxNumberOfDirectionals(); ++i) {
|
||||||
|
Directional directional = jxinputDevice.getDirectional(i);
|
||||||
|
if (directional != null) {
|
||||||
|
JXInputEventManager.addListener(this, directional);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changed(JXInputAxisEvent event) {
|
||||||
|
axisEventQueue.add(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changed(JXInputButtonEvent event) {
|
||||||
|
buttonEventQueue.add(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changed(JXInputDirectionalEvent event) {
|
||||||
|
directionalEventQueue.add(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
run = true;
|
||||||
|
System.out.println("begonneuh");
|
||||||
|
while (run) {
|
||||||
|
JXInputManager.updateFeatures();
|
||||||
|
boolean sleep = true;
|
||||||
|
if (!axisEventQueue.isEmpty()) {
|
||||||
|
javaInputDevice.processEvent(axisEventQueue.poll());
|
||||||
|
sleep = false;
|
||||||
|
}
|
||||||
|
if (!buttonEventQueue.isEmpty()) {
|
||||||
|
javaInputDevice.processEvent(buttonEventQueue.poll());
|
||||||
|
sleep = false;
|
||||||
|
}
|
||||||
|
if (!directionalEventQueue.isEmpty()) {
|
||||||
|
javaInputDevice.processEvent(directionalEventQueue.poll());
|
||||||
|
sleep = false;
|
||||||
|
}
|
||||||
|
if (sleep) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(SLEEP);
|
||||||
|
} catch (InterruptedException e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("klaaaur");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package pm.device.rumblepad;
|
package pm.device.javainput;
|
||||||
|
|
||||||
import pm.device.JavaInputDevice;
|
|
||||||
import pm.exception.ServiceJavaInputException;
|
import pm.exception.ServiceJavaInputException;
|
||||||
|
|
||||||
public class RumblepadDevice extends JavaInputDevice {
|
public class RumblepadDevice extends JavaInputDevice {
|
||||||
@@ -9,6 +8,5 @@ public class RumblepadDevice extends JavaInputDevice {
|
|||||||
|
|
||||||
public RumblepadDevice() throws ServiceJavaInputException {
|
public RumblepadDevice() throws ServiceJavaInputException {
|
||||||
super(NAME);
|
super(NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
47
java/src/pm/device/javainput/extreme3d/Extreme3DButton.java
Normal file
47
java/src/pm/device/javainput/extreme3d/Extreme3DButton.java
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package pm.device.javainput.extreme3d;
|
||||||
|
|
||||||
|
public enum Extreme3DButton {
|
||||||
|
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"),
|
||||||
|
ELEVEN ("Button 10"),
|
||||||
|
TWELVE ("Button 11");
|
||||||
|
|
||||||
|
/*TWO (0x0001),
|
||||||
|
ONE (0x0002),
|
||||||
|
B (0x0004),
|
||||||
|
A (0x0008),
|
||||||
|
MINUS (0x0010),
|
||||||
|
HOME (0x0080),
|
||||||
|
LEFT (0x0100),
|
||||||
|
RIGHT (0x0200),
|
||||||
|
DOWN (0x0400),
|
||||||
|
UP (0x0800),
|
||||||
|
PLUS (0x1000),
|
||||||
|
ALL (0x1F9F);*/
|
||||||
|
|
||||||
|
protected String code;
|
||||||
|
|
||||||
|
Extreme3DButton(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int getCode() {
|
||||||
|
return code;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
static Extreme3DButton create(String name) throws Exception {
|
||||||
|
try {
|
||||||
|
return Extreme3DButton.valueOf(name);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new Exception("Moet ik nou heeel boos worden?? " + name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
java/src/pm/device/javainput/extreme3d/Extreme3DDevice.java
Normal file
60
java/src/pm/device/javainput/extreme3d/Extreme3DDevice.java
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
package pm.device.javainput.extreme3d;
|
||||||
|
|
||||||
|
import de.hardcode.jxinput.Button;
|
||||||
|
import de.hardcode.jxinput.Directional;
|
||||||
|
import de.hardcode.jxinput.event.JXInputAxisEvent;
|
||||||
|
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||||
|
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||||
|
|
||||||
|
import pm.action.Action;
|
||||||
|
import pm.device.javainput.JavaInputDevice;
|
||||||
|
import pm.device.macro.Macro;
|
||||||
|
import pm.event.Target;
|
||||||
|
import pm.exception.DeviceException;
|
||||||
|
|
||||||
|
public class Extreme3DDevice extends JavaInputDevice {
|
||||||
|
|
||||||
|
protected static final String NAME = "Logitech Extreme 3D";
|
||||||
|
|
||||||
|
public Extreme3DDevice() throws DeviceException {
|
||||||
|
super(NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
super.start();
|
||||||
|
/*macroListener.addMacro(
|
||||||
|
new Macro(
|
||||||
|
new Hold(Button.A),
|
||||||
|
new Press(Button.B),
|
||||||
|
new Press(Button.TWO),
|
||||||
|
new Release(Button.A)),
|
||||||
|
Action.EXIT, Target.APPLICATION));*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processEvent(JXInputAxisEvent event) {
|
||||||
|
//addAction(Action.START, Target.APPLICATION);
|
||||||
|
//System.out.println(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processEvent(JXInputButtonEvent event) {
|
||||||
|
//addAction(Action.TEST, Target.APPLICATION);
|
||||||
|
Button button = event.getButton();
|
||||||
|
Extreme3DButton x = null;
|
||||||
|
try {
|
||||||
|
x = Extreme3DButton.create(button.getName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.out.println(x);
|
||||||
|
//System.out.println(button.getType() + " " + button.getName() +" " + event.getButton().getState());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processEvent(JXInputDirectionalEvent event) {
|
||||||
|
//addAction(Action.EXIT, Target.APPLICATION);
|
||||||
|
Directional directional = event.getDirectional();
|
||||||
|
|
||||||
|
System.out.println(directional.getValue() + " [" + directional.getName() + "] " + directional.getResolution() + " " + directional.getDirection());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
5
java/src/pm/device/macro/Macro.java
Normal file
5
java/src/pm/device/macro/Macro.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package pm.device.macro;
|
||||||
|
|
||||||
|
public class Macro {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package pm.exception;
|
package pm.exception;
|
||||||
|
|
||||||
public class ServiceException extends Exception {
|
public class DeviceException extends Exception {
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package pm.exception;
|
package pm.exception;
|
||||||
|
|
||||||
public class ActionInvokeException extends ActionException {
|
public class InvokeActionException extends ActionException {
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package pm.exception;
|
package pm.exception;
|
||||||
|
|
||||||
public class ServiceJavaInputException extends ServiceException {
|
public class JavaInputDeviceNotFoundException extends DeviceException {
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package pm.exception;
|
package pm.exception;
|
||||||
|
|
||||||
public class ActionNotImplementedException extends ActionException {
|
public class NotImplementedActionException extends ActionException {
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package pm.exception;
|
|
||||||
|
|
||||||
public class ServiceJavaInputDeviceNotFoundException extends ServiceJavaInputException {
|
|
||||||
protected static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ package pm.service.javainput;
|
|||||||
import de.hardcode.jxinput.JXInputDevice;
|
import de.hardcode.jxinput.JXInputDevice;
|
||||||
import de.hardcode.jxinput.JXInputManager;
|
import de.hardcode.jxinput.JXInputManager;
|
||||||
|
|
||||||
import pm.exception.ServiceJavaInputDeviceNotFoundException;
|
import pm.exception.JavaInputDeviceNotFoundException;
|
||||||
import pm.exception.ServiceJavaInputException;
|
import pm.exception.ServiceJavaInputException;
|
||||||
import pm.service.Service;
|
import pm.service.Service;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ public class JavaInputService extends Service {
|
|||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new ServiceJavaInputDeviceNotFoundException();
|
throw new JavaInputDeviceNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initialize() {
|
public static void initialize() {
|
||||||
|
|||||||
Reference in New Issue
Block a user